//>>built
define("demos/i18n/model",["dojo","dijit","dojox"],function(_1,_2,_3){_1.provide("demos.i18n.model");_1.declare("i18nTreeModel",null,{geoname:null,countries:null,constructor:function(_4){this.lang=_4.lang||"en";this.geonames=new _3.rpc.Service(_1.moduleUrl("dojox.rpc.SMDLibrary","geonames.smd"));},destroy:function(){},getRoot:function(_5,_6){_5({type:"root",root:true,name:"Continents"});},mayHaveChildren:function(_7){return _7.root||_7.type=="continent"||_7.type=="country";},getChildren:function(_8,_9,_a){switch(_8.root?"top":_8.type){case "top":var d=_1.xhrGet({url:"continents.json",handleAs:"json-comment-optional"});d.addCallback(_9);break;case "continent":var _b=function(_c){var _d=_1.filter(_c,function(c){c.type="country";return c.continent==_8.iso;});_9(_d);};if(!this.countries){var _e=this.geonames.getCountryInfo({lang:this.lang});_e.addCallback(this,function(_f){this.countries=_f.geonames;_b(this.countries);});}else{_b(this.countries);}break;case "country":if(!this.d2){this.d2=_1.xhrGet({url:"languages.json",handleAs:"json-comment-optional"});this.d2.addCallback(this,function(_10){return _1.filter(_10,function(l){return l.iso==this.lang;})[0]||{};});}this.d2.addCallback(function(_11){var ary=_1.filter(_8.languages.split(","),function(loc){return loc;});var _12=_1.map(ary,function(loc){loc=loc.toLowerCase();var _13=loc.replace(/-.*/,"");var _14=_11[_13]||"";return {type:"locale",iso:loc,lang:_13,name:_14+" ‫("+loc+")‬"};});_9(_12);return _11;});break;}},getIdentity:function(_15){return _15.root?"world":(_15.key||_15.iso||_15.countryCode);},getLabel:function(_16){return _16.name||_16.countryName;},newItem:function(_17,_18){},pasteItem:function(_19,_1a,_1b,_1c){},onChange:function(_1d){},onChildrenChange:function(_1e,_1f){},onDelete:function(_20,_21){}});});