recurly-3.0.5.js 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218
  1. ;(function(){
  2. /**
  3. * Require the given path.
  4. *
  5. * @param {String} path
  6. * @return {Object} exports
  7. * @api public
  8. */
  9. function require(path, parent, orig) {
  10. var resolved = require.resolve(path);
  11. // lookup failed
  12. if (null == resolved) {
  13. orig = orig || path;
  14. parent = parent || 'root';
  15. var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
  16. err.path = orig;
  17. err.parent = parent;
  18. err.require = true;
  19. throw err;
  20. }
  21. var module = require.modules[resolved];
  22. // perform real require()
  23. // by invoking the module's
  24. // registered function
  25. if (!module._resolving && !module.exports) {
  26. var mod = {};
  27. mod.exports = {};
  28. mod.client = mod.component = true;
  29. module._resolving = true;
  30. module.call(this, mod.exports, require.relative(resolved), mod);
  31. delete module._resolving;
  32. module.exports = mod.exports;
  33. }
  34. return module.exports;
  35. }
  36. /**
  37. * Registered modules.
  38. */
  39. require.modules = {};
  40. /**
  41. * Registered aliases.
  42. */
  43. require.aliases = {};
  44. /**
  45. * Resolve `path`.
  46. *
  47. * Lookup:
  48. *
  49. * - PATH/index.js
  50. * - PATH.js
  51. * - PATH
  52. *
  53. * @param {String} path
  54. * @return {String} path or null
  55. * @api private
  56. */
  57. require.resolve = function(path) {
  58. if (path.charAt(0) === '/') path = path.slice(1);
  59. var paths = [
  60. path,
  61. path + '.js',
  62. path + '.json',
  63. path + '/index.js',
  64. path + '/index.json'
  65. ];
  66. for (var i = 0; i < paths.length; i++) {
  67. var path = paths[i];
  68. if (require.modules.hasOwnProperty(path)) return path;
  69. if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
  70. }
  71. };
  72. /**
  73. * Normalize `path` relative to the current path.
  74. *
  75. * @param {String} curr
  76. * @param {String} path
  77. * @return {String}
  78. * @api private
  79. */
  80. require.normalize = function(curr, path) {
  81. var segs = [];
  82. if ('.' != path.charAt(0)) return path;
  83. curr = curr.split('/');
  84. path = path.split('/');
  85. for (var i = 0; i < path.length; ++i) {
  86. if ('..' == path[i]) {
  87. curr.pop();
  88. } else if ('.' != path[i] && '' != path[i]) {
  89. segs.push(path[i]);
  90. }
  91. }
  92. return curr.concat(segs).join('/');
  93. };
  94. /**
  95. * Register module at `path` with callback `definition`.
  96. *
  97. * @param {String} path
  98. * @param {Function} definition
  99. * @api private
  100. */
  101. require.register = function(path, definition) {
  102. require.modules[path] = definition;
  103. };
  104. /**
  105. * Alias a module definition.
  106. *
  107. * @param {String} from
  108. * @param {String} to
  109. * @api private
  110. */
  111. require.alias = function(from, to) {
  112. if (!require.modules.hasOwnProperty(from)) {
  113. throw new Error('Failed to alias "' + from + '", it does not exist');
  114. }
  115. require.aliases[to] = from;
  116. };
  117. /**
  118. * Return a require function relative to the `parent` path.
  119. *
  120. * @param {String} parent
  121. * @return {Function}
  122. * @api private
  123. */
  124. require.relative = function(parent) {
  125. var p = require.normalize(parent, '..');
  126. /**
  127. * lastIndexOf helper.
  128. */
  129. function lastIndexOf(arr, obj) {
  130. var i = arr.length;
  131. while (i--) {
  132. if (arr[i] === obj) return i;
  133. }
  134. return -1;
  135. }
  136. /**
  137. * The relative require() itself.
  138. */
  139. function localRequire(path) {
  140. var resolved = localRequire.resolve(path);
  141. return require(resolved, parent, path);
  142. }
  143. /**
  144. * Resolve relative to the parent.
  145. */
  146. localRequire.resolve = function(path) {
  147. var c = path.charAt(0);
  148. if ('/' == c) return path.slice(1);
  149. if ('.' == c) return require.normalize(p, path);
  150. // resolve deps by returning
  151. // the dep in the nearest "deps"
  152. // directory
  153. var segs = parent.split('/');
  154. var i = lastIndexOf(segs, 'deps') + 1;
  155. if (!i) i = 0;
  156. path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
  157. return path;
  158. };
  159. /**
  160. * Check if module is defined at `path`.
  161. */
  162. localRequire.exists = function(path) {
  163. return require.modules.hasOwnProperty(localRequire.resolve(path));
  164. };
  165. return localRequire;
  166. };
  167. require.register("visionmedia-node-querystring/index.js", function(exports, require, module){
  168. /**
  169. * Object#toString() ref for stringify().
  170. */
  171. var toString = Object.prototype.toString;
  172. /**
  173. * Object#hasOwnProperty ref
  174. */
  175. var hasOwnProperty = Object.prototype.hasOwnProperty;
  176. /**
  177. * Array#indexOf shim.
  178. */
  179. var indexOf = typeof Array.prototype.indexOf === 'function'
  180. ? function(arr, el) { return arr.indexOf(el); }
  181. : function(arr, el) {
  182. for (var i = 0; i < arr.length; i++) {
  183. if (arr[i] === el) return i;
  184. }
  185. return -1;
  186. };
  187. /**
  188. * Array.isArray shim.
  189. */
  190. var isArray = Array.isArray || function(arr) {
  191. return toString.call(arr) == '[object Array]';
  192. };
  193. /**
  194. * Object.keys shim.
  195. */
  196. var objectKeys = Object.keys || function(obj) {
  197. var ret = [];
  198. for (var key in obj) {
  199. if (obj.hasOwnProperty(key)) {
  200. ret.push(key);
  201. }
  202. }
  203. return ret;
  204. };
  205. /**
  206. * Array#forEach shim.
  207. */
  208. var forEach = typeof Array.prototype.forEach === 'function'
  209. ? function(arr, fn) { return arr.forEach(fn); }
  210. : function(arr, fn) {
  211. for (var i = 0; i < arr.length; i++) fn(arr[i]);
  212. };
  213. /**
  214. * Array#reduce shim.
  215. */
  216. var reduce = function(arr, fn, initial) {
  217. if (typeof arr.reduce === 'function') return arr.reduce(fn, initial);
  218. var res = initial;
  219. for (var i = 0; i < arr.length; i++) res = fn(res, arr[i]);
  220. return res;
  221. };
  222. /**
  223. * Cache non-integer test regexp.
  224. */
  225. var isint = /^[0-9]+$/;
  226. function promote(parent, key) {
  227. if (parent[key].length == 0) return parent[key] = {}
  228. var t = {};
  229. for (var i in parent[key]) {
  230. if (hasOwnProperty.call(parent[key], i)) {
  231. t[i] = parent[key][i];
  232. }
  233. }
  234. parent[key] = t;
  235. return t;
  236. }
  237. function parse(parts, parent, key, val) {
  238. var part = parts.shift();
  239. // illegal
  240. if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return;
  241. // end
  242. if (!part) {
  243. if (isArray(parent[key])) {
  244. parent[key].push(val);
  245. } else if ('object' == typeof parent[key]) {
  246. parent[key] = val;
  247. } else if ('undefined' == typeof parent[key]) {
  248. parent[key] = val;
  249. } else {
  250. parent[key] = [parent[key], val];
  251. }
  252. // array
  253. } else {
  254. var obj = parent[key] = parent[key] || [];
  255. if (']' == part) {
  256. if (isArray(obj)) {
  257. if ('' != val) obj.push(val);
  258. } else if ('object' == typeof obj) {
  259. obj[objectKeys(obj).length] = val;
  260. } else {
  261. obj = parent[key] = [parent[key], val];
  262. }
  263. // prop
  264. } else if (~indexOf(part, ']')) {
  265. part = part.substr(0, part.length - 1);
  266. if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
  267. parse(parts, obj, part, val);
  268. // key
  269. } else {
  270. if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
  271. parse(parts, obj, part, val);
  272. }
  273. }
  274. }
  275. /**
  276. * Merge parent key/val pair.
  277. */
  278. function merge(parent, key, val){
  279. if (~indexOf(key, ']')) {
  280. var parts = key.split('[')
  281. , len = parts.length
  282. , last = len - 1;
  283. parse(parts, parent, 'base', val);
  284. // optimize
  285. } else {
  286. if (!isint.test(key) && isArray(parent.base)) {
  287. var t = {};
  288. for (var k in parent.base) t[k] = parent.base[k];
  289. parent.base = t;
  290. }
  291. set(parent.base, key, val);
  292. }
  293. return parent;
  294. }
  295. /**
  296. * Compact sparse arrays.
  297. */
  298. function compact(obj) {
  299. if ('object' != typeof obj) return obj;
  300. if (isArray(obj)) {
  301. var ret = [];
  302. for (var i in obj) {
  303. if (hasOwnProperty.call(obj, i)) {
  304. ret.push(obj[i]);
  305. }
  306. }
  307. return ret;
  308. }
  309. for (var key in obj) {
  310. obj[key] = compact(obj[key]);
  311. }
  312. return obj;
  313. }
  314. /**
  315. * Parse the given obj.
  316. */
  317. function parseObject(obj){
  318. var ret = { base: {} };
  319. forEach(objectKeys(obj), function(name){
  320. merge(ret, name, obj[name]);
  321. });
  322. return compact(ret.base);
  323. }
  324. /**
  325. * Parse the given str.
  326. */
  327. function parseString(str){
  328. var ret = reduce(String(str).split('&'), function(ret, pair){
  329. var eql = indexOf(pair, '=')
  330. , brace = lastBraceInKey(pair)
  331. , key = pair.substr(0, brace || eql)
  332. , val = pair.substr(brace || eql, pair.length)
  333. , val = val.substr(indexOf(val, '=') + 1, val.length);
  334. // ?foo
  335. if ('' == key) key = pair, val = '';
  336. if ('' == key) return ret;
  337. return merge(ret, decode(key), decode(val));
  338. }, { base: {} }).base;
  339. return compact(ret);
  340. }
  341. /**
  342. * Parse the given query `str` or `obj`, returning an object.
  343. *
  344. * @param {String} str | {Object} obj
  345. * @return {Object}
  346. * @api public
  347. */
  348. exports.parse = function(str){
  349. if (null == str || '' == str) return {};
  350. return 'object' == typeof str
  351. ? parseObject(str)
  352. : parseString(str);
  353. };
  354. /**
  355. * Turn the given `obj` into a query string
  356. *
  357. * @param {Object} obj
  358. * @return {String}
  359. * @api public
  360. */
  361. var stringify = exports.stringify = function(obj, prefix) {
  362. if (isArray(obj)) {
  363. return stringifyArray(obj, prefix);
  364. } else if ('[object Object]' == toString.call(obj)) {
  365. return stringifyObject(obj, prefix);
  366. } else if ('string' == typeof obj) {
  367. return stringifyString(obj, prefix);
  368. } else {
  369. return prefix + '=' + encodeURIComponent(String(obj));
  370. }
  371. };
  372. /**
  373. * Stringify the given `str`.
  374. *
  375. * @param {String} str
  376. * @param {String} prefix
  377. * @return {String}
  378. * @api private
  379. */
  380. function stringifyString(str, prefix) {
  381. if (!prefix) throw new TypeError('stringify expects an object');
  382. return prefix + '=' + encodeURIComponent(str);
  383. }
  384. /**
  385. * Stringify the given `arr`.
  386. *
  387. * @param {Array} arr
  388. * @param {String} prefix
  389. * @return {String}
  390. * @api private
  391. */
  392. function stringifyArray(arr, prefix) {
  393. var ret = [];
  394. if (!prefix) throw new TypeError('stringify expects an object');
  395. for (var i = 0; i < arr.length; i++) {
  396. ret.push(stringify(arr[i], prefix + '[' + i + ']'));
  397. }
  398. return ret.join('&');
  399. }
  400. /**
  401. * Stringify the given `obj`.
  402. *
  403. * @param {Object} obj
  404. * @param {String} prefix
  405. * @return {String}
  406. * @api private
  407. */
  408. function stringifyObject(obj, prefix) {
  409. var ret = []
  410. , keys = objectKeys(obj)
  411. , key;
  412. for (var i = 0, len = keys.length; i < len; ++i) {
  413. key = keys[i];
  414. if ('' == key) continue;
  415. if (null == obj[key]) {
  416. ret.push(encodeURIComponent(key) + '=');
  417. } else {
  418. ret.push(stringify(obj[key], prefix
  419. ? prefix + '[' + encodeURIComponent(key) + ']'
  420. : encodeURIComponent(key)));
  421. }
  422. }
  423. return ret.join('&');
  424. }
  425. /**
  426. * Set `obj`'s `key` to `val` respecting
  427. * the weird and wonderful syntax of a qs,
  428. * where "foo=bar&foo=baz" becomes an array.
  429. *
  430. * @param {Object} obj
  431. * @param {String} key
  432. * @param {String} val
  433. * @api private
  434. */
  435. function set(obj, key, val) {
  436. var v = obj[key];
  437. if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return;
  438. if (undefined === v) {
  439. obj[key] = val;
  440. } else if (isArray(v)) {
  441. v.push(val);
  442. } else {
  443. obj[key] = [v, val];
  444. }
  445. }
  446. /**
  447. * Locate last brace in `str` within the key.
  448. *
  449. * @param {String} str
  450. * @return {Number}
  451. * @api private
  452. */
  453. function lastBraceInKey(str) {
  454. var len = str.length
  455. , brace
  456. , c;
  457. for (var i = 0; i < len; ++i) {
  458. c = str[i];
  459. if (']' == c) brace = false;
  460. if ('[' == c) brace = true;
  461. if ('=' == c && !brace) return i;
  462. }
  463. }
  464. /**
  465. * Decode `str`.
  466. *
  467. * @param {String} str
  468. * @return {String}
  469. * @api private
  470. */
  471. function decode(str) {
  472. try {
  473. return decodeURIComponent(str.replace(/\+/g, ' '));
  474. } catch (err) {
  475. return str;
  476. }
  477. }
  478. });
  479. require.register("component-emitter/index.js", function(exports, require, module){
  480. /**
  481. * Expose `Emitter`.
  482. */
  483. module.exports = Emitter;
  484. /**
  485. * Initialize a new `Emitter`.
  486. *
  487. * @api public
  488. */
  489. function Emitter(obj) {
  490. if (obj) return mixin(obj);
  491. };
  492. /**
  493. * Mixin the emitter properties.
  494. *
  495. * @param {Object} obj
  496. * @return {Object}
  497. * @api private
  498. */
  499. function mixin(obj) {
  500. for (var key in Emitter.prototype) {
  501. obj[key] = Emitter.prototype[key];
  502. }
  503. return obj;
  504. }
  505. /**
  506. * Listen on the given `event` with `fn`.
  507. *
  508. * @param {String} event
  509. * @param {Function} fn
  510. * @return {Emitter}
  511. * @api public
  512. */
  513. Emitter.prototype.on =
  514. Emitter.prototype.addEventListener = function(event, fn){
  515. this._callbacks = this._callbacks || {};
  516. (this._callbacks[event] = this._callbacks[event] || [])
  517. .push(fn);
  518. return this;
  519. };
  520. /**
  521. * Adds an `event` listener that will be invoked a single
  522. * time then automatically removed.
  523. *
  524. * @param {String} event
  525. * @param {Function} fn
  526. * @return {Emitter}
  527. * @api public
  528. */
  529. Emitter.prototype.once = function(event, fn){
  530. var self = this;
  531. this._callbacks = this._callbacks || {};
  532. function on() {
  533. self.off(event, on);
  534. fn.apply(this, arguments);
  535. }
  536. on.fn = fn;
  537. this.on(event, on);
  538. return this;
  539. };
  540. /**
  541. * Remove the given callback for `event` or all
  542. * registered callbacks.
  543. *
  544. * @param {String} event
  545. * @param {Function} fn
  546. * @return {Emitter}
  547. * @api public
  548. */
  549. Emitter.prototype.off =
  550. Emitter.prototype.removeListener =
  551. Emitter.prototype.removeAllListeners =
  552. Emitter.prototype.removeEventListener = function(event, fn){
  553. this._callbacks = this._callbacks || {};
  554. // all
  555. if (0 == arguments.length) {
  556. this._callbacks = {};
  557. return this;
  558. }
  559. // specific event
  560. var callbacks = this._callbacks[event];
  561. if (!callbacks) return this;
  562. // remove all handlers
  563. if (1 == arguments.length) {
  564. delete this._callbacks[event];
  565. return this;
  566. }
  567. // remove specific handler
  568. var cb;
  569. for (var i = 0; i < callbacks.length; i++) {
  570. cb = callbacks[i];
  571. if (cb === fn || cb.fn === fn) {
  572. callbacks.splice(i, 1);
  573. break;
  574. }
  575. }
  576. return this;
  577. };
  578. /**
  579. * Emit `event` with the given args.
  580. *
  581. * @param {String} event
  582. * @param {Mixed} ...
  583. * @return {Emitter}
  584. */
  585. Emitter.prototype.emit = function(event){
  586. this._callbacks = this._callbacks || {};
  587. var args = [].slice.call(arguments, 1)
  588. , callbacks = this._callbacks[event];
  589. if (callbacks) {
  590. callbacks = callbacks.slice(0);
  591. for (var i = 0, len = callbacks.length; i < len; ++i) {
  592. callbacks[i].apply(this, args);
  593. }
  594. }
  595. return this;
  596. };
  597. /**
  598. * Return array of callbacks for `event`.
  599. *
  600. * @param {String} event
  601. * @return {Array}
  602. * @api public
  603. */
  604. Emitter.prototype.listeners = function(event){
  605. this._callbacks = this._callbacks || {};
  606. return this._callbacks[event] || [];
  607. };
  608. /**
  609. * Check if this emitter has `event` handlers.
  610. *
  611. * @param {String} event
  612. * @return {Boolean}
  613. * @api public
  614. */
  615. Emitter.prototype.hasListeners = function(event){
  616. return !! this.listeners(event).length;
  617. };
  618. });
  619. require.register("component-indexof/index.js", function(exports, require, module){
  620. module.exports = function(arr, obj){
  621. if (arr.indexOf) return arr.indexOf(obj);
  622. for (var i = 0; i < arr.length; ++i) {
  623. if (arr[i] === obj) return i;
  624. }
  625. return -1;
  626. };
  627. });
  628. require.register("component-object/index.js", function(exports, require, module){
  629. /**
  630. * HOP ref.
  631. */
  632. var has = Object.prototype.hasOwnProperty;
  633. /**
  634. * Return own keys in `obj`.
  635. *
  636. * @param {Object} obj
  637. * @return {Array}
  638. * @api public
  639. */
  640. exports.keys = Object.keys || function(obj){
  641. var keys = [];
  642. for (var key in obj) {
  643. if (has.call(obj, key)) {
  644. keys.push(key);
  645. }
  646. }
  647. return keys;
  648. };
  649. /**
  650. * Return own values in `obj`.
  651. *
  652. * @param {Object} obj
  653. * @return {Array}
  654. * @api public
  655. */
  656. exports.values = function(obj){
  657. var vals = [];
  658. for (var key in obj) {
  659. if (has.call(obj, key)) {
  660. vals.push(obj[key]);
  661. }
  662. }
  663. return vals;
  664. };
  665. /**
  666. * Merge `b` into `a`.
  667. *
  668. * @param {Object} a
  669. * @param {Object} b
  670. * @return {Object} a
  671. * @api public
  672. */
  673. exports.merge = function(a, b){
  674. for (var key in b) {
  675. if (has.call(b, key)) {
  676. a[key] = b[key];
  677. }
  678. }
  679. return a;
  680. };
  681. /**
  682. * Return length of `obj`.
  683. *
  684. * @param {Object} obj
  685. * @return {Number}
  686. * @api public
  687. */
  688. exports.length = function(obj){
  689. return exports.keys(obj).length;
  690. };
  691. /**
  692. * Check if `obj` is empty.
  693. *
  694. * @param {Object} obj
  695. * @return {Boolean}
  696. * @api public
  697. */
  698. exports.isEmpty = function(obj){
  699. return 0 == exports.length(obj);
  700. };
  701. });
  702. require.register("component-event/index.js", function(exports, require, module){
  703. var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
  704. unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
  705. prefix = bind !== 'addEventListener' ? 'on' : '';
  706. /**
  707. * Bind `el` event `type` to `fn`.
  708. *
  709. * @param {Element} el
  710. * @param {String} type
  711. * @param {Function} fn
  712. * @param {Boolean} capture
  713. * @return {Function}
  714. * @api public
  715. */
  716. exports.bind = function(el, type, fn, capture){
  717. el[bind](prefix + type, fn, capture || false);
  718. return fn;
  719. };
  720. /**
  721. * Unbind `el` event `type`'s callback `fn`.
  722. *
  723. * @param {Element} el
  724. * @param {String} type
  725. * @param {Function} fn
  726. * @param {Boolean} capture
  727. * @return {Function}
  728. * @api public
  729. */
  730. exports.unbind = function(el, type, fn, capture){
  731. el[unbind](prefix + type, fn, capture || false);
  732. return fn;
  733. };
  734. });
  735. require.register("component-clone/index.js", function(exports, require, module){
  736. /**
  737. * Module dependencies.
  738. */
  739. var type;
  740. try {
  741. type = require('component-type');
  742. } catch (_) {
  743. type = require('type');
  744. }
  745. /**
  746. * Module exports.
  747. */
  748. module.exports = clone;
  749. /**
  750. * Clones objects.
  751. *
  752. * @param {Mixed} any object
  753. * @api public
  754. */
  755. function clone(obj){
  756. switch (type(obj)) {
  757. case 'object':
  758. var copy = {};
  759. for (var key in obj) {
  760. if (obj.hasOwnProperty(key)) {
  761. copy[key] = clone(obj[key]);
  762. }
  763. }
  764. return copy;
  765. case 'array':
  766. var copy = new Array(obj.length);
  767. for (var i = 0, l = obj.length; i < l; i++) {
  768. copy[i] = clone(obj[i]);
  769. }
  770. return copy;
  771. case 'regexp':
  772. // from millermedeiros/amd-utils - MIT
  773. var flags = '';
  774. flags += obj.multiline ? 'm' : '';
  775. flags += obj.global ? 'g' : '';
  776. flags += obj.ignoreCase ? 'i' : '';
  777. return new RegExp(obj.source, flags);
  778. case 'date':
  779. return new Date(obj.getTime());
  780. default: // string, number, boolean, …
  781. return obj;
  782. }
  783. }
  784. });
  785. require.register("component-bind/index.js", function(exports, require, module){
  786. /**
  787. * Slice reference.
  788. */
  789. var slice = [].slice;
  790. /**
  791. * Bind `obj` to `fn`.
  792. *
  793. * @param {Object} obj
  794. * @param {Function|String} fn or string
  795. * @return {Function}
  796. * @api public
  797. */
  798. module.exports = function(obj, fn){
  799. if ('string' == typeof fn) fn = obj[fn];
  800. if ('function' != typeof fn) throw new Error('bind() requires a function');
  801. var args = [].slice.call(arguments, 2);
  802. return function(){
  803. return fn.apply(obj, args.concat(slice.call(arguments)));
  804. }
  805. };
  806. });
  807. require.register("component-props/index.js", function(exports, require, module){
  808. /**
  809. * Global Names
  810. */
  811. var globals = /\b(this|Array|Date|Object|Math|JSON)\b/g;
  812. /**
  813. * Return immediate identifiers parsed from `str`.
  814. *
  815. * @param {String} str
  816. * @param {String|Function} map function or prefix
  817. * @return {Array}
  818. * @api public
  819. */
  820. module.exports = function(str, fn){
  821. var p = unique(props(str));
  822. if (fn && 'string' == typeof fn) fn = prefixed(fn);
  823. if (fn) return map(str, p, fn);
  824. return p;
  825. };
  826. /**
  827. * Return immediate identifiers in `str`.
  828. *
  829. * @param {String} str
  830. * @return {Array}
  831. * @api private
  832. */
  833. function props(str) {
  834. return str
  835. .replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g, '')
  836. .replace(globals, '')
  837. .match(/[$a-zA-Z_]\w*/g)
  838. || [];
  839. }
  840. /**
  841. * Return `str` with `props` mapped with `fn`.
  842. *
  843. * @param {String} str
  844. * @param {Array} props
  845. * @param {Function} fn
  846. * @return {String}
  847. * @api private
  848. */
  849. function map(str, props, fn) {
  850. var re = /\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;
  851. return str.replace(re, function(_){
  852. if ('(' == _[_.length - 1]) return fn(_);
  853. if (!~props.indexOf(_)) return _;
  854. return fn(_);
  855. });
  856. }
  857. /**
  858. * Return unique array.
  859. *
  860. * @param {Array} arr
  861. * @return {Array}
  862. * @api private
  863. */
  864. function unique(arr) {
  865. var ret = [];
  866. for (var i = 0; i < arr.length; i++) {
  867. if (~ret.indexOf(arr[i])) continue;
  868. ret.push(arr[i]);
  869. }
  870. return ret;
  871. }
  872. /**
  873. * Map with prefix `str`.
  874. */
  875. function prefixed(str) {
  876. return function(_){
  877. return str + _;
  878. };
  879. }
  880. });
  881. require.register("component-to-function/index.js", function(exports, require, module){
  882. /**
  883. * Module Dependencies
  884. */
  885. var expr = require('props');
  886. /**
  887. * Expose `toFunction()`.
  888. */
  889. module.exports = toFunction;
  890. /**
  891. * Convert `obj` to a `Function`.
  892. *
  893. * @param {Mixed} obj
  894. * @return {Function}
  895. * @api private
  896. */
  897. function toFunction(obj) {
  898. switch ({}.toString.call(obj)) {
  899. case '[object Object]':
  900. return objectToFunction(obj);
  901. case '[object Function]':
  902. return obj;
  903. case '[object String]':
  904. return stringToFunction(obj);
  905. case '[object RegExp]':
  906. return regexpToFunction(obj);
  907. default:
  908. return defaultToFunction(obj);
  909. }
  910. }
  911. /**
  912. * Default to strict equality.
  913. *
  914. * @param {Mixed} val
  915. * @return {Function}
  916. * @api private
  917. */
  918. function defaultToFunction(val) {
  919. return function(obj){
  920. return val === obj;
  921. }
  922. }
  923. /**
  924. * Convert `re` to a function.
  925. *
  926. * @param {RegExp} re
  927. * @return {Function}
  928. * @api private
  929. */
  930. function regexpToFunction(re) {
  931. return function(obj){
  932. return re.test(obj);
  933. }
  934. }
  935. /**
  936. * Convert property `str` to a function.
  937. *
  938. * @param {String} str
  939. * @return {Function}
  940. * @api private
  941. */
  942. function stringToFunction(str) {
  943. // immediate such as "> 20"
  944. if (/^ *\W+/.test(str)) return new Function('_', 'return _ ' + str);
  945. // properties such as "name.first" or "age > 18" or "age > 18 && age < 36"
  946. return new Function('_', 'return ' + get(str));
  947. }
  948. /**
  949. * Convert `object` to a function.
  950. *
  951. * @param {Object} object
  952. * @return {Function}
  953. * @api private
  954. */
  955. function objectToFunction(obj) {
  956. var match = {}
  957. for (var key in obj) {
  958. match[key] = typeof obj[key] === 'string'
  959. ? defaultToFunction(obj[key])
  960. : toFunction(obj[key])
  961. }
  962. return function(val){
  963. if (typeof val !== 'object') return false;
  964. for (var key in match) {
  965. if (!(key in val)) return false;
  966. if (!match[key](val[key])) return false;
  967. }
  968. return true;
  969. }
  970. }
  971. /**
  972. * Built the getter function. Supports getter style functions
  973. *
  974. * @param {String} str
  975. * @return {String}
  976. * @api private
  977. */
  978. function get(str) {
  979. var props = expr(str);
  980. if (!props.length) return '_.' + str;
  981. var val;
  982. for(var i = 0, prop; prop = props[i]; i++) {
  983. val = '_.' + prop;
  984. val = "('function' == typeof " + val + " ? " + val + "() : " + val + ")";
  985. str = str.replace(new RegExp(prop, 'g'), val);
  986. }
  987. return str;
  988. }
  989. });
  990. require.register("component-each/index.js", function(exports, require, module){
  991. /**
  992. * Module dependencies.
  993. */
  994. var type = require('type');
  995. var toFunction = require('to-function');
  996. /**
  997. * HOP reference.
  998. */
  999. var has = Object.prototype.hasOwnProperty;
  1000. /**
  1001. * Iterate the given `obj` and invoke `fn(val, i)`
  1002. * in optional context `ctx`.
  1003. *
  1004. * @param {String|Array|Object} obj
  1005. * @param {Function} fn
  1006. * @param {Object} [ctx]
  1007. * @api public
  1008. */
  1009. module.exports = function(obj, fn, ctx){
  1010. fn = toFunction(fn);
  1011. ctx = ctx || this;
  1012. switch (type(obj)) {
  1013. case 'array':
  1014. return array(obj, fn, ctx);
  1015. case 'object':
  1016. if ('number' == typeof obj.length) return array(obj, fn, ctx);
  1017. return object(obj, fn, ctx);
  1018. case 'string':
  1019. return string(obj, fn, ctx);
  1020. }
  1021. };
  1022. /**
  1023. * Iterate string chars.
  1024. *
  1025. * @param {String} obj
  1026. * @param {Function} fn
  1027. * @param {Object} ctx
  1028. * @api private
  1029. */
  1030. function string(obj, fn, ctx) {
  1031. for (var i = 0; i < obj.length; ++i) {
  1032. fn.call(ctx, obj.charAt(i), i);
  1033. }
  1034. }
  1035. /**
  1036. * Iterate object keys.
  1037. *
  1038. * @param {Object} obj
  1039. * @param {Function} fn
  1040. * @param {Object} ctx
  1041. * @api private
  1042. */
  1043. function object(obj, fn, ctx) {
  1044. for (var key in obj) {
  1045. if (has.call(obj, key)) {
  1046. fn.call(ctx, key, obj[key]);
  1047. }
  1048. }
  1049. }
  1050. /**
  1051. * Iterate array-ish.
  1052. *
  1053. * @param {Array|Object} obj
  1054. * @param {Function} fn
  1055. * @param {Object} ctx
  1056. * @api private
  1057. */
  1058. function array(obj, fn, ctx) {
  1059. for (var i = 0; i < obj.length; ++i) {
  1060. fn.call(ctx, obj[i], i);
  1061. }
  1062. }
  1063. });
  1064. require.register("component-find/index.js", function(exports, require, module){
  1065. /**
  1066. * Module dependencies.
  1067. */
  1068. var toFunction = require('to-function');
  1069. /**
  1070. * Find the first value in `arr` with when `fn(val, i)` is truthy.
  1071. *
  1072. * @param {Array} arr
  1073. * @param {Function} fn
  1074. * @return {Array}
  1075. * @api public
  1076. */
  1077. module.exports = function(arr, fn){
  1078. // callback
  1079. if ('function' != typeof fn) {
  1080. if (Object(fn) === fn) fn = objectToFunction(fn);
  1081. else fn = toFunction(fn);
  1082. }
  1083. // filter
  1084. for (var i = 0, len = arr.length; i < len; ++i) {
  1085. if (fn(arr[i], i)) return arr[i];
  1086. }
  1087. };
  1088. /**
  1089. * Convert `obj` into a match function.
  1090. *
  1091. * @param {Object} obj
  1092. * @return {Function}
  1093. * @api private
  1094. */
  1095. function objectToFunction(obj) {
  1096. return function(o){
  1097. for (var key in obj) {
  1098. if (o[key] != obj[key]) return false;
  1099. }
  1100. return true;
  1101. }
  1102. }
  1103. });
  1104. require.register("component-json/index.js", function(exports, require, module){
  1105. module.exports = 'undefined' == typeof JSON
  1106. ? require('component-json-fallback')
  1107. : JSON;
  1108. });
  1109. require.register("component-type/index.js", function(exports, require, module){
  1110. /**
  1111. * toString ref.
  1112. */
  1113. var toString = Object.prototype.toString;
  1114. /**
  1115. * Return the type of `val`.
  1116. *
  1117. * @param {Mixed} val
  1118. * @return {String}
  1119. * @api public
  1120. */
  1121. module.exports = function(val){
  1122. switch (toString.call(val)) {
  1123. case '[object Function]': return 'function';
  1124. case '[object Date]': return 'date';
  1125. case '[object RegExp]': return 'regexp';
  1126. case '[object Arguments]': return 'arguments';
  1127. case '[object Array]': return 'array';
  1128. case '[object String]': return 'string';
  1129. }
  1130. if (val === null) return 'null';
  1131. if (val === undefined) return 'undefined';
  1132. if (val && val.nodeType === 1) return 'element';
  1133. if (val === Object(val)) return 'object';
  1134. return typeof val;
  1135. };
  1136. });
  1137. require.register("component-trim/index.js", function(exports, require, module){
  1138. exports = module.exports = trim;
  1139. function trim(str){
  1140. if (str.trim) return str.trim();
  1141. return str.replace(/^\s*|\s*$/g, '');
  1142. }
  1143. exports.left = function(str){
  1144. if (str.trimLeft) return str.trimLeft();
  1145. return str.replace(/^\s*/, '');
  1146. };
  1147. exports.right = function(str){
  1148. if (str.trimRight) return str.trimRight();
  1149. return str.replace(/\s*$/, '');
  1150. };
  1151. });
  1152. require.register("component-map/index.js", function(exports, require, module){
  1153. /**
  1154. * Module dependencies.
  1155. */
  1156. var toFunction = require('to-function');
  1157. /**
  1158. * Map the given `arr` with callback `fn(val, i)`.
  1159. *
  1160. * @param {Array} arr
  1161. * @param {Function} fn
  1162. * @return {Array}
  1163. * @api public
  1164. */
  1165. module.exports = function(arr, fn){
  1166. var ret = [];
  1167. fn = toFunction(fn);
  1168. for (var i = 0; i < arr.length; ++i) {
  1169. ret.push(fn(arr[i], i));
  1170. }
  1171. return ret;
  1172. };
  1173. });
  1174. require.register("yields-merge/index.js", function(exports, require, module){
  1175. /**
  1176. * merge `b`'s properties with `a`'s.
  1177. *
  1178. * example:
  1179. *
  1180. * var user = {};
  1181. * merge(user, console);
  1182. * // > { log: fn, dir: fn ..}
  1183. *
  1184. * @param {Object} a
  1185. * @param {Object} b
  1186. * @return {Object}
  1187. */
  1188. module.exports = function (a, b) {
  1189. for (var k in b) a[k] = b[k];
  1190. return a;
  1191. };
  1192. });
  1193. require.register("learnboost-jsonp/index.js", function(exports, require, module){
  1194. /**
  1195. * Module dependencies
  1196. */
  1197. var debug = require('debug')('jsonp');
  1198. /**
  1199. * Module exports.
  1200. */
  1201. module.exports = jsonp;
  1202. /**
  1203. * Callback index.
  1204. */
  1205. var count = 0;
  1206. /**
  1207. * Noop function.
  1208. */
  1209. function noop(){}
  1210. /**
  1211. * JSONP handler
  1212. *
  1213. * Options:
  1214. * - param {String} qs parameter (`callback`)
  1215. * - timeout {Number} how long after a timeout error is emitted (`60000`)
  1216. *
  1217. * @param {String} url
  1218. * @param {Object|Function} optional options / callback
  1219. * @param {Function} optional callback
  1220. */
  1221. function jsonp(url, opts, fn){
  1222. if ('function' == typeof opts) {
  1223. fn = opts;
  1224. opts = {};
  1225. }
  1226. if (!opts) opts = {};
  1227. var prefix = opts.prefix || '__jp';
  1228. var param = opts.param || 'callback';
  1229. var timeout = null != opts.timeout ? opts.timeout : 60000;
  1230. var enc = encodeURIComponent;
  1231. var target = document.getElementsByTagName('script')[0] || document.head;
  1232. var script;
  1233. var timer;
  1234. // generate a unique id for this request
  1235. var id = prefix + (count++);
  1236. if (timeout) {
  1237. timer = setTimeout(function(){
  1238. cleanup();
  1239. if (fn) fn(new Error('Timeout'));
  1240. }, timeout);
  1241. }
  1242. function cleanup(){
  1243. script.parentNode.removeChild(script);
  1244. window[id] = noop;
  1245. }
  1246. window[id] = function(data){
  1247. debug('jsonp got', data);
  1248. if (timer) clearTimeout(timer);
  1249. cleanup();
  1250. if (fn) fn(null, data);
  1251. };
  1252. // add qs component
  1253. url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc(id);
  1254. url = url.replace('?&', '?');
  1255. debug('jsonp req "%s"', url);
  1256. // create script
  1257. script = document.createElement('script');
  1258. script.src = url;
  1259. target.parentNode.insertBefore(script, target);
  1260. }
  1261. });
  1262. require.register("visionmedia-debug/debug.js", function(exports, require, module){
  1263. /**
  1264. * Expose `debug()` as the module.
  1265. */
  1266. module.exports = debug;
  1267. /**
  1268. * Create a debugger with the given `name`.
  1269. *
  1270. * @param {String} name
  1271. * @return {Type}
  1272. * @api public
  1273. */
  1274. function debug(name) {
  1275. if (!debug.enabled(name)) return function(){};
  1276. return function(fmt){
  1277. fmt = coerce(fmt);
  1278. var curr = new Date;
  1279. var ms = curr - (debug[name] || curr);
  1280. debug[name] = curr;
  1281. fmt = name
  1282. + ' '
  1283. + fmt
  1284. + ' +' + debug.humanize(ms);
  1285. // This hackery is required for IE8
  1286. // where `console.log` doesn't have 'apply'
  1287. window.console
  1288. && console.log
  1289. && Function.prototype.apply.call(console.log, console, arguments);
  1290. }
  1291. }
  1292. /**
  1293. * The currently active debug mode names.
  1294. */
  1295. debug.names = [];
  1296. debug.skips = [];
  1297. /**
  1298. * Enables a debug mode by name. This can include modes
  1299. * separated by a colon and wildcards.
  1300. *
  1301. * @param {String} name
  1302. * @api public
  1303. */
  1304. debug.enable = function(name) {
  1305. try {
  1306. localStorage.debug = name;
  1307. } catch(e){}
  1308. var split = (name || '').split(/[\s,]+/)
  1309. , len = split.length;
  1310. for (var i = 0; i < len; i++) {
  1311. name = split[i].replace('*', '.*?');
  1312. if (name[0] === '-') {
  1313. debug.skips.push(new RegExp('^' + name.substr(1) + '$'));
  1314. }
  1315. else {
  1316. debug.names.push(new RegExp('^' + name + '$'));
  1317. }
  1318. }
  1319. };
  1320. /**
  1321. * Disable debug output.
  1322. *
  1323. * @api public
  1324. */
  1325. debug.disable = function(){
  1326. debug.enable('');
  1327. };
  1328. /**
  1329. * Humanize the given `ms`.
  1330. *
  1331. * @param {Number} m
  1332. * @return {String}
  1333. * @api private
  1334. */
  1335. debug.humanize = function(ms) {
  1336. var sec = 1000
  1337. , min = 60 * 1000
  1338. , hour = 60 * min;
  1339. if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
  1340. if (ms >= min) return (ms / min).toFixed(1) + 'm';
  1341. if (ms >= sec) return (ms / sec | 0) + 's';
  1342. return ms + 'ms';
  1343. };
  1344. /**
  1345. * Returns true if the given mode name is enabled, false otherwise.
  1346. *
  1347. * @param {String} name
  1348. * @return {Boolean}
  1349. * @api public
  1350. */
  1351. debug.enabled = function(name) {
  1352. for (var i = 0, len = debug.skips.length; i < len; i++) {
  1353. if (debug.skips[i].test(name)) {
  1354. return false;
  1355. }
  1356. }
  1357. for (var i = 0, len = debug.names.length; i < len; i++) {
  1358. if (debug.names[i].test(name)) {
  1359. return true;
  1360. }
  1361. }
  1362. return false;
  1363. };
  1364. /**
  1365. * Coerce `val`.
  1366. */
  1367. function coerce(val) {
  1368. if (val instanceof Error) return val.stack || val.message;
  1369. return val;
  1370. }
  1371. // persist
  1372. try {
  1373. if (window.localStorage) debug.enable(localStorage.debug);
  1374. } catch(e){}
  1375. });
  1376. require.register("johntron-asap/asap.js", function(exports, require, module){
  1377. "use strict";
  1378. // Use the fastest possible means to execute a task in a future turn
  1379. // of the event loop.
  1380. // linked list of tasks (single, with head node)
  1381. var head = {task: void 0, next: null};
  1382. var tail = head;
  1383. var flushing = false;
  1384. var requestFlush = void 0;
  1385. var hasSetImmediate = typeof setImmediate === "function";
  1386. var domain;
  1387. if (typeof global != 'undefined') {
  1388. // Avoid shims from browserify.
  1389. // The existence of `global` in browsers is guaranteed by browserify.
  1390. var process = global.process;
  1391. }
  1392. // Note that some fake-Node environments,
  1393. // like the Mocha test runner, introduce a `process` global.
  1394. var isNodeJS = !!process && ({}).toString.call(process) === "[object process]";
  1395. function flush() {
  1396. /* jshint loopfunc: true */
  1397. while (head.next) {
  1398. head = head.next;
  1399. var task = head.task;
  1400. head.task = void 0;
  1401. try {
  1402. task();
  1403. } catch (e) {
  1404. if (isNodeJS) {
  1405. // In node, uncaught exceptions are considered fatal errors.
  1406. // Re-throw them to interrupt flushing!
  1407. // Ensure continuation if an uncaught exception is suppressed
  1408. // listening process.on("uncaughtException") or domain("error").
  1409. requestFlush();
  1410. throw e;
  1411. } else {
  1412. // In browsers, uncaught exceptions are not fatal.
  1413. // Re-throw them asynchronously to avoid slow-downs.
  1414. throw e;
  1415. }
  1416. }
  1417. }
  1418. flushing = false;
  1419. }
  1420. if (isNodeJS) {
  1421. // Node.js
  1422. requestFlush = function () {
  1423. // Ensure flushing is not bound to any domain.
  1424. var currentDomain = process.domain;
  1425. if (currentDomain) {
  1426. domain = domain || (1,require)("domain");
  1427. domain.active = process.domain = null;
  1428. }
  1429. // Avoid tick recursion - use setImmediate if it exists.
  1430. if (flushing && hasSetImmediate) {
  1431. setImmediate(flush);
  1432. } else {
  1433. process.nextTick(flush);
  1434. }
  1435. if (currentDomain) {
  1436. domain.active = process.domain = currentDomain;
  1437. }
  1438. };
  1439. } else if (hasSetImmediate) {
  1440. // In IE10, or https://github.com/NobleJS/setImmediate
  1441. requestFlush = function () {
  1442. setImmediate(flush);
  1443. };
  1444. } else if (typeof MessageChannel !== "undefined") {
  1445. // modern browsers
  1446. // http://www.nonblocking.io/2011/06/windownexttick.html
  1447. var channel = new MessageChannel();
  1448. // At least Safari Version 6.0.5 (8536.30.1) intermittently cannot create
  1449. // working message ports the first time a page loads.
  1450. channel.port1.onmessage = function () {
  1451. requestFlush = requestPortFlush;
  1452. channel.port1.onmessage = flush;
  1453. flush();
  1454. };
  1455. var requestPortFlush = function () {
  1456. // Opera requires us to provide a message payload, regardless of
  1457. // whether we use it.
  1458. channel.port2.postMessage(0);
  1459. };
  1460. requestFlush = function () {
  1461. setTimeout(flush, 0);
  1462. requestPortFlush();
  1463. };
  1464. } else {
  1465. // old browsers
  1466. requestFlush = function () {
  1467. setTimeout(flush, 0);
  1468. };
  1469. }
  1470. function asap(task) {
  1471. if (isNodeJS && process.domain) {
  1472. task = process.domain.bind(task);
  1473. }
  1474. tail = tail.next = {task: task, next: null};
  1475. if (!flushing) {
  1476. requestFlush();
  1477. flushing = true;
  1478. }
  1479. };
  1480. module.exports = asap;
  1481. });
  1482. require.register("chrissrogers-promise/index.js", function(exports, require, module){
  1483. 'use strict';
  1484. //This file contains then/promise specific extensions to the core promise API
  1485. var Promise = require('./core.js')
  1486. var asap = require('asap')
  1487. module.exports = Promise
  1488. /* Static Functions */
  1489. function ValuePromise(value) {
  1490. this.then = function (onFulfilled) {
  1491. if (typeof onFulfilled !== 'function') return this
  1492. return new Promise(function (resolve, reject) {
  1493. asap(function () {
  1494. try {
  1495. resolve(onFulfilled(value))
  1496. } catch (ex) {
  1497. reject(ex);
  1498. }
  1499. })
  1500. })
  1501. }
  1502. }
  1503. ValuePromise.prototype = Promise.prototype
  1504. var TRUE = new ValuePromise(true)
  1505. var FALSE = new ValuePromise(false)
  1506. var NULL = new ValuePromise(null)
  1507. var UNDEFINED = new ValuePromise(undefined)
  1508. var ZERO = new ValuePromise(0)
  1509. var EMPTYSTRING = new ValuePromise('')
  1510. Promise.resolve = function (value) {
  1511. if (value instanceof Promise) return value
  1512. if (value === null) return NULL
  1513. if (value === undefined) return UNDEFINED
  1514. if (value === true) return TRUE
  1515. if (value === false) return FALSE
  1516. if (value === 0) return ZERO
  1517. if (value === '') return EMPTYSTRING
  1518. if (typeof value === 'object' || typeof value === 'function') {
  1519. try {
  1520. var then = value.then
  1521. if (typeof then === 'function') {
  1522. return new Promise(then.bind(value))
  1523. }
  1524. } catch (ex) {
  1525. return new Promise(function (resolve, reject) {
  1526. reject(ex)
  1527. })
  1528. }
  1529. }
  1530. return new ValuePromise(value)
  1531. }
  1532. Promise.from = Promise.cast = function (value) {
  1533. var err = new Error('Promise.from and Promise.cast are deprecated, use Promise.resolve instead')
  1534. err.name = 'Warning'
  1535. console.warn(err.stack)
  1536. return Promise.resolve(value)
  1537. }
  1538. Promise.denodeify = function (fn, argumentCount) {
  1539. argumentCount = argumentCount || Infinity
  1540. return function () {
  1541. var self = this
  1542. var args = Array.prototype.slice.call(arguments)
  1543. return new Promise(function (resolve, reject) {
  1544. while (args.length && args.length > argumentCount) {
  1545. args.pop()
  1546. }
  1547. args.push(function (err, res) {
  1548. if (err) reject(err)
  1549. else resolve(res)
  1550. })
  1551. fn.apply(self, args)
  1552. })
  1553. }
  1554. }
  1555. Promise.nodeify = function (fn) {
  1556. return function () {
  1557. var args = Array.prototype.slice.call(arguments)
  1558. var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null
  1559. try {
  1560. return fn.apply(this, arguments).nodeify(callback)
  1561. } catch (ex) {
  1562. if (callback === null || typeof callback == 'undefined') {
  1563. return new Promise(function (resolve, reject) { reject(ex) })
  1564. } else {
  1565. asap(function () {
  1566. callback(ex)
  1567. })
  1568. }
  1569. }
  1570. }
  1571. }
  1572. Promise.all = function () {
  1573. var calledWithArray = arguments.length === 1 && Array.isArray(arguments[0])
  1574. var args = Array.prototype.slice.call(calledWithArray ? arguments[0] : arguments)
  1575. if (!calledWithArray) {
  1576. var err = new Error('Promise.all should be called with a single array, calling it with multiple arguments is deprecated')
  1577. err.name = 'Warning'
  1578. console.warn(err.stack)
  1579. }
  1580. return new Promise(function (resolve, reject) {
  1581. if (args.length === 0) return resolve([])
  1582. var remaining = args.length
  1583. function res(i, val) {
  1584. try {
  1585. if (val && (typeof val === 'object' || typeof val === 'function')) {
  1586. var then = val.then
  1587. if (typeof then === 'function') {
  1588. then.call(val, function (val) { res(i, val) }, reject)
  1589. return
  1590. }
  1591. }
  1592. args[i] = val
  1593. if (--remaining === 0) {
  1594. resolve(args);
  1595. }
  1596. } catch (ex) {
  1597. reject(ex)
  1598. }
  1599. }
  1600. for (var i = 0; i < args.length; i++) {
  1601. res(i, args[i])
  1602. }
  1603. })
  1604. }
  1605. Promise.reject = function (value) {
  1606. return new Promise(function (resolve, reject) {
  1607. reject(value);
  1608. });
  1609. }
  1610. Promise.race = function (values) {
  1611. return new Promise(function (resolve, reject) {
  1612. values.forEach(function(value){
  1613. Promise.resolve(value).then(resolve, reject);
  1614. })
  1615. });
  1616. }
  1617. /* Prototype Methods */
  1618. Promise.prototype.done = function (onFulfilled, onRejected) {
  1619. var self = arguments.length ? this.then.apply(this, arguments) : this
  1620. self.then(null, function (err) {
  1621. asap(function () {
  1622. throw err
  1623. })
  1624. })
  1625. }
  1626. Promise.prototype.nodeify = function (callback) {
  1627. if (typeof callback != 'function') return this
  1628. this.then(function (value) {
  1629. asap(function () {
  1630. callback(null, value)
  1631. })
  1632. }, function (err) {
  1633. asap(function () {
  1634. callback(err)
  1635. })
  1636. })
  1637. }
  1638. Promise.prototype['catch'] = function (onRejected) {
  1639. return this.then(null, onRejected);
  1640. }
  1641. });
  1642. require.register("chrissrogers-promise/core.js", function(exports, require, module){
  1643. 'use strict';
  1644. var asap = require('asap')
  1645. module.exports = Promise
  1646. function Promise(fn) {
  1647. if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new')
  1648. if (typeof fn !== 'function') throw new TypeError('not a function')
  1649. var state = null
  1650. var value = null
  1651. var deferreds = []
  1652. var self = this
  1653. this.then = function(onFulfilled, onRejected) {
  1654. return new self.constructor(function(resolve, reject) {
  1655. handle(new Handler(onFulfilled, onRejected, resolve, reject))
  1656. })
  1657. }
  1658. function handle(deferred) {
  1659. if (state === null) {
  1660. deferreds.push(deferred)
  1661. return
  1662. }
  1663. asap(function() {
  1664. var cb = state ? deferred.onFulfilled : deferred.onRejected
  1665. if (cb === null) {
  1666. (state ? deferred.resolve : deferred.reject)(value)
  1667. return
  1668. }
  1669. var ret
  1670. try {
  1671. ret = cb(value)
  1672. }
  1673. catch (e) {
  1674. deferred.reject(e)
  1675. return
  1676. }
  1677. deferred.resolve(ret)
  1678. })
  1679. }
  1680. function resolve(newValue) {
  1681. try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
  1682. if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.')
  1683. if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
  1684. var then = newValue.then
  1685. if (typeof then === 'function') {
  1686. doResolve(then.bind(newValue), resolve, reject)
  1687. return
  1688. }
  1689. }
  1690. state = true
  1691. value = newValue
  1692. finale()
  1693. } catch (e) { reject(e) }
  1694. }
  1695. function reject(newValue) {
  1696. state = false
  1697. value = newValue
  1698. finale()
  1699. }
  1700. function finale() {
  1701. for (var i = 0, len = deferreds.length; i < len; i++)
  1702. handle(deferreds[i])
  1703. deferreds = null
  1704. }
  1705. doResolve(fn, resolve, reject)
  1706. }
  1707. function Handler(onFulfilled, onRejected, resolve, reject){
  1708. this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null
  1709. this.onRejected = typeof onRejected === 'function' ? onRejected : null
  1710. this.resolve = resolve
  1711. this.reject = reject
  1712. }
  1713. /**
  1714. * Take a potentially misbehaving resolver function and make sure
  1715. * onFulfilled and onRejected are only called once.
  1716. *
  1717. * Makes no guarantees about asynchrony.
  1718. */
  1719. function doResolve(fn, onFulfilled, onRejected) {
  1720. var done = false;
  1721. try {
  1722. fn(function (value) {
  1723. if (done) return
  1724. done = true
  1725. onFulfilled(value)
  1726. }, function (reason) {
  1727. if (done) return
  1728. done = true
  1729. onRejected(reason)
  1730. })
  1731. } catch (ex) {
  1732. if (done) return
  1733. done = true
  1734. onRejected(ex)
  1735. }
  1736. }
  1737. });
  1738. require.register("kewah-mixin/index.js", function(exports, require, module){
  1739. if (typeof Object.keys === 'function') {
  1740. module.exports = function(to, from) {
  1741. Object.keys(from).forEach(function(property) {
  1742. Object.defineProperty(to, property, Object.getOwnPropertyDescriptor(from, property));
  1743. });
  1744. };
  1745. } else {
  1746. module.exports = function(to, from) {
  1747. for (var property in from) {
  1748. if (from.hasOwnProperty(property)) {
  1749. to[property] = from[property];
  1750. }
  1751. }
  1752. };
  1753. }
  1754. });
  1755. require.register("pluma-par/dist/par.js", function(exports, require, module){
  1756. /*! par 0.3.0 Original author Alan Plum <me@pluma.io>. Released into the Public Domain under the UNLICENSE. @preserve */
  1757. var slice = Array.prototype.slice;
  1758. function par(fn) {
  1759. var args0 = slice.call(arguments, 1);
  1760. return function() {
  1761. var argsN = slice.call(arguments, 0),
  1762. args = [];
  1763. args.push.apply(args, args0);
  1764. args.push.apply(args, argsN);
  1765. return fn.apply(this, args);
  1766. };
  1767. }
  1768. function rpartial(fn) {
  1769. var argsN = slice.call(arguments, 1);
  1770. return function() {
  1771. var args = slice.call(arguments, 0);
  1772. args.push.apply(args, argsN);
  1773. return fn.apply(this, args);
  1774. };
  1775. }
  1776. par.rpartial = rpartial;
  1777. par.lpartial = par;
  1778. module.exports = par;
  1779. });
  1780. require.register("ianstormtaylor-to-no-case/index.js", function(exports, require, module){
  1781. /**
  1782. * Expose `toNoCase`.
  1783. */
  1784. module.exports = toNoCase;
  1785. /**
  1786. * Test whether a string is camel-case.
  1787. */
  1788. var hasSpace = /\s/;
  1789. var hasCamel = /[a-z][A-Z]/;
  1790. var hasSeparator = /[\W_]/;
  1791. /**
  1792. * Remove any starting case from a `string`, like camel or snake, but keep
  1793. * spaces and punctuation that may be important otherwise.
  1794. *
  1795. * @param {String} string
  1796. * @return {String}
  1797. */
  1798. function toNoCase (string) {
  1799. if (hasSpace.test(string)) return string.toLowerCase();
  1800. if (hasSeparator.test(string)) string = unseparate(string);
  1801. if (hasCamel.test(string)) string = uncamelize(string);
  1802. return string.toLowerCase();
  1803. }
  1804. /**
  1805. * Separator splitter.
  1806. */
  1807. var separatorSplitter = /[\W_]+(.|$)/g;
  1808. /**
  1809. * Un-separate a `string`.
  1810. *
  1811. * @param {String} string
  1812. * @return {String}
  1813. */
  1814. function unseparate (string) {
  1815. return string.replace(separatorSplitter, function (m, next) {
  1816. return next ? ' ' + next : '';
  1817. });
  1818. }
  1819. /**
  1820. * Camelcase splitter.
  1821. */
  1822. var camelSplitter = /(.)([A-Z]+)/g;
  1823. /**
  1824. * Un-camelcase a `string`.
  1825. *
  1826. * @param {String} string
  1827. * @return {String}
  1828. */
  1829. function uncamelize (string) {
  1830. return string.replace(camelSplitter, function (m, previous, uppers) {
  1831. return previous + ' ' + uppers.toLowerCase().split('').join(' ');
  1832. });
  1833. }
  1834. });
  1835. require.register("ianstormtaylor-to-space-case/index.js", function(exports, require, module){
  1836. var clean = require('to-no-case');
  1837. /**
  1838. * Expose `toSpaceCase`.
  1839. */
  1840. module.exports = toSpaceCase;
  1841. /**
  1842. * Convert a `string` to space case.
  1843. *
  1844. * @param {String} string
  1845. * @return {String}
  1846. */
  1847. function toSpaceCase (string) {
  1848. return clean(string).replace(/[\W_]+(.|$)/g, function (matches, match) {
  1849. return match ? ' ' + match : '';
  1850. });
  1851. }
  1852. });
  1853. require.register("ianstormtaylor-to-slug-case/index.js", function(exports, require, module){
  1854. var toSpace = require('to-space-case');
  1855. /**
  1856. * Expose `toSlugCase`.
  1857. */
  1858. module.exports = toSlugCase;
  1859. /**
  1860. * Convert a `string` to slug case.
  1861. *
  1862. * @param {String} string
  1863. * @return {String}
  1864. */
  1865. function toSlugCase (string) {
  1866. return toSpace(string).replace(/\s/g, '-');
  1867. }
  1868. });
  1869. require.register("recurly/lib/index.js", function(exports, require, module){
  1870. /*!
  1871. * Module dependencies.
  1872. */
  1873. var Recurly = require('./recurly');
  1874. /**
  1875. * Export a single instance.
  1876. */
  1877. module.exports = exports = new Recurly();
  1878. /**
  1879. * Hack for testing.
  1880. */
  1881. exports.Recurly = Recurly;
  1882. });
  1883. require.register("recurly/lib/recurly.js", function(exports, require, module){
  1884. /*!
  1885. * Module dependencies.
  1886. */
  1887. var bind = require('bind');
  1888. var json = require('json');
  1889. var each = require('each');
  1890. var type = require('type');
  1891. var merge = require('merge');
  1892. var mixin = require('mixin');
  1893. var jsonp = require('jsonp');
  1894. var qs = require('querystring');
  1895. var Emitter = require('emitter');
  1896. var errors = require('./errors');
  1897. var version = require('./version');
  1898. var debug = require('debug')('recurly');
  1899. /**
  1900. * Default configuration values.
  1901. *
  1902. * @private
  1903. * @type {Object}
  1904. */
  1905. var defaults = {
  1906. currency: 'USD'
  1907. , timeout: 60000
  1908. , publicKey: ''
  1909. , api: 'https://api.recurly.com/js/v1'
  1910. };
  1911. /**
  1912. * API mixins.
  1913. *
  1914. * @type {Array}
  1915. * @private
  1916. */
  1917. var mixins = [
  1918. 'open'
  1919. , 'coupon'
  1920. , 'paypal'
  1921. , 'plan'
  1922. , 'tax'
  1923. , 'token'
  1924. , 'pricing'
  1925. , 'validate'
  1926. ];
  1927. /**
  1928. * Export `Recurly`.
  1929. */
  1930. module.exports = Recurly;
  1931. /**
  1932. * Initialize defaults.
  1933. *
  1934. * @param {Object} options
  1935. * @constructor
  1936. * @public
  1937. */
  1938. function Recurly (options) {
  1939. this.id = 0;
  1940. this.version = version;
  1941. this.configured = false;
  1942. this.config = merge({}, defaults);
  1943. if (options) this.configure(options);
  1944. }
  1945. /**
  1946. * Inherits `Emitter`.
  1947. */
  1948. Emitter(Recurly.prototype);
  1949. /**
  1950. * Configure settings.
  1951. *
  1952. * @param {String|Object} options Either publicKey or object containing
  1953. * publicKey and other optional members
  1954. * @param {String} options.publicKey
  1955. * @param {String} [options.currency]
  1956. * @param {String} [options.api]
  1957. * @public
  1958. */
  1959. Recurly.prototype.configure = function configure (options) {
  1960. if (this.configured) throw errors('already-configured');
  1961. debug('configure');
  1962. if (type(options) === 'string') options = { publicKey: options };
  1963. if ('publicKey' in options) {
  1964. this.config.publicKey = options.publicKey;
  1965. } else {
  1966. throw errors('missing-public-key');
  1967. }
  1968. if ('api' in options) {
  1969. this.config.api = options.api;
  1970. }
  1971. if ('currency' in options) {
  1972. this.config.currency = options.currency;
  1973. }
  1974. this.configured = true;
  1975. };
  1976. /**
  1977. * Assembles the API endpoint.
  1978. *
  1979. * @return {String} route
  1980. * @private
  1981. */
  1982. Recurly.prototype.url = function url (route) {
  1983. return this.config.api + route;
  1984. };
  1985. /**
  1986. * Issues an API request.
  1987. *
  1988. * @param {String} route
  1989. * @param {Object} [data]
  1990. * @param {Function} done
  1991. * @throws {Error} If `configure` has not been called.
  1992. * @private
  1993. */
  1994. Recurly.prototype.request = function request (route, data, done) {
  1995. debug('request');
  1996. if (false === this.configured) {
  1997. throw errors('not-configured');
  1998. }
  1999. if ('function' == type(data)) {
  2000. done = data;
  2001. data = {};
  2002. }
  2003. var url = this.url(route);
  2004. var timeout = this.config.timeout;
  2005. data.version = this.version;
  2006. data.key = this.config.publicKey;
  2007. url += '?' + qs.stringify(data);
  2008. this.cache(url, function (res, set) {
  2009. if (res) return done(null, res);
  2010. jsonp(url, { timeout: timeout }, function (err, res) {
  2011. if (err) return done(err);
  2012. if (res.error) {
  2013. done(errors('api-error', res.error));
  2014. } else {
  2015. done(null, set(res));
  2016. }
  2017. });
  2018. });
  2019. };
  2020. /**
  2021. * Caches an object
  2022. *
  2023. * TODO: figure out invalidation & expiry
  2024. *
  2025. * @param {String} url
  2026. * @param {Function} done
  2027. * @private
  2028. */
  2029. Recurly.prototype.cache = function cache (url, done) {
  2030. debug('cache');
  2031. var stored = localStorage.getItem(url);
  2032. if (stored) {
  2033. debug('cache found ' + url);
  2034. return done(json.parse(stored));
  2035. } else {
  2036. debug('cache set ' + url);
  2037. return done(null, set);
  2038. }
  2039. function set (obj) {
  2040. // disabled for now
  2041. // localStorage.setItem(url, json.stringify(obj));
  2042. return obj;
  2043. }
  2044. };
  2045. /**
  2046. * Load the `mixins` onto Recurly.prototype.
  2047. */
  2048. each(mixins, function (name) {
  2049. mixin(Recurly.prototype, require('./recurly/' + name));
  2050. });
  2051. });
  2052. require.register("recurly/lib/version.js", function(exports, require, module){
  2053. /**
  2054. * Current package/component version.
  2055. */
  2056. module.exports = '3.0.5';
  2057. });
  2058. require.register("recurly/lib/errors.js", function(exports, require, module){
  2059. /**
  2060. * dependencies
  2061. */
  2062. var mixin = require('mixin');
  2063. /**
  2064. * Export `errors`.
  2065. */
  2066. module.exports = exports = errors;
  2067. /**
  2068. * Error accessor.
  2069. *
  2070. * @param {String} name
  2071. * @param {Object} options
  2072. * @return {Error}
  2073. */
  2074. function errors (name, options) {
  2075. return errors.get(name, options);
  2076. }
  2077. /**
  2078. * Defined errors.
  2079. *
  2080. * @type {Object}
  2081. * @private
  2082. */
  2083. errors.map = {};
  2084. /**
  2085. * Base url for documention.
  2086. *
  2087. * @type {String}
  2088. * @private
  2089. */
  2090. errors.baseURL = '';
  2091. /**
  2092. * Sets the `baseURL` for docs.
  2093. *
  2094. * @param {String} url
  2095. * @public
  2096. */
  2097. errors.doc = function (baseURL) {
  2098. errors.baseURL = baseURL;
  2099. };
  2100. /**
  2101. * Gets errors defined by `name`.
  2102. *
  2103. * @param {String} name
  2104. * @param {Object} context
  2105. * @return {Error}
  2106. * @public
  2107. */
  2108. errors.get = function (name, context) {
  2109. if (!(name in errors.map)) {
  2110. throw new Error('invalid error');
  2111. } else {
  2112. return new errors.map[name](context);
  2113. }
  2114. };
  2115. /**
  2116. * Registers an error defined by `name` with `config`.
  2117. *
  2118. * @param {String} name
  2119. * @param {Object} config
  2120. * @return {Error}
  2121. * @public
  2122. */
  2123. errors.add = function (name, config) {
  2124. config = config || {};
  2125. function RecurlyError (context) {
  2126. Error.call(this);
  2127. this.name = this.code = name;
  2128. this.message = config.message;
  2129. mixin(this, context || {});
  2130. if (config.help) {
  2131. this.help = errors.baseURL + config.help;
  2132. this.message += ' (need help? ' + this.help + ')';
  2133. }
  2134. };
  2135. RecurlyError.prototype = new Error();
  2136. return errors.map[name] = RecurlyError;
  2137. };
  2138. /**
  2139. * Internal definations.
  2140. *
  2141. * TODO(gjohnson): open source this as a component
  2142. * and move these out.
  2143. */
  2144. errors.doc('https://docs.recurly.com/js');
  2145. errors.add('already-configured', {
  2146. message: 'Configuration may only be set once.',
  2147. help: '#identify-your-site'
  2148. });
  2149. errors.add('not-configured', {
  2150. message: 'Not configured. You must first call recurly.configure().',
  2151. help: '#identify-your-site'
  2152. });
  2153. errors.add('missing-public-key', {
  2154. message: 'The publicKey setting is required.',
  2155. help: '#identify-your-site'
  2156. });
  2157. errors.add('api-error', {
  2158. message: 'There was an error with your request.'
  2159. });
  2160. errors.add('validation', {
  2161. message: 'There was an error validating your request.'
  2162. });
  2163. errors.add('missing-callback', {
  2164. message: 'Missing callback'
  2165. });
  2166. errors.add('invalid-options', {
  2167. message: 'Options must be an object'
  2168. });
  2169. errors.add('missing-plan', {
  2170. message: 'A plan must be specified.'
  2171. });
  2172. errors.add('missing-coupon', {
  2173. message: 'A coupon must be specified.'
  2174. });
  2175. errors.add('invalid-item', {
  2176. message: 'The given item does not appear to be a valid recurly plan, coupon, addon, or taxable address.'
  2177. });
  2178. errors.add('invalid-addon', {
  2179. message: 'The given addon_code is not among the valid addons for the specified plan.'
  2180. });
  2181. errors.add('invalid-currency', {
  2182. message: 'The given currency is not among the valid codes for the specified plan.'
  2183. });
  2184. errors.add('unremovable-item', {
  2185. message: 'The given item cannot be removed.'
  2186. });
  2187. });
  2188. require.register("recurly/lib/util/dom.js", function(exports, require, module){
  2189. /**
  2190. * dependencies
  2191. */
  2192. var slug = require('to-slug-case');
  2193. var type = require('type');
  2194. var each = require('each');
  2195. var map = require('map');
  2196. /**
  2197. * expose
  2198. */
  2199. module.exports = {
  2200. element: element,
  2201. value: value,
  2202. data: data
  2203. };
  2204. /**
  2205. * Detects whether an object is an html element.
  2206. *
  2207. * @param {Mixed} node
  2208. * @return {HTMLElement|Boolean} node
  2209. */
  2210. function element (node) {
  2211. var isJQuery = window.jQuery && node instanceof jQuery;
  2212. var isArray = type(node) === 'array';
  2213. if (isJQuery || isArray) node = node[0];
  2214. var isElem = typeof HTMLElement !== 'undefined'
  2215. ? node instanceof HTMLElement
  2216. : node && node.nodeType === 1;
  2217. return isElem && node;
  2218. };
  2219. /**
  2220. * Gets or sets the value of a given HTML form element
  2221. *
  2222. * supports text inputs, radio inputs, and selects
  2223. *
  2224. * @param {HTMLElement} node
  2225. * @return {String} value of the element
  2226. */
  2227. function value (node, value) {
  2228. if (!element(node)) return null;
  2229. return typeof value !== 'undefined'
  2230. ? valueSet(node, value)
  2231. : valueGet(node);
  2232. }
  2233. /**
  2234. * Gets an HTMLElement's value property in the context of a form
  2235. *
  2236. * @param {HTMLElement} node
  2237. * @return {String} node's value
  2238. */
  2239. function valueGet (node) {
  2240. node = element(node);
  2241. var nodeType = node && node.type && node.type.toLowerCase();
  2242. var value;
  2243. if (!nodeType) {
  2244. value = '';
  2245. } else if ('options' in node) {
  2246. value = node.options[node.selectedIndex].value;
  2247. } else if (nodeType === 'checkbox') {
  2248. if (node.checked) value = node.value;
  2249. } else if (nodeType === 'radio') {
  2250. var radios = document.querySelectorAll('input[data-recurly="' + data(node, 'recurly') + '"]');
  2251. each(radios, function (radio) {
  2252. if (radio.checked) value = radio.value;
  2253. });
  2254. } else if ('value' in node) {
  2255. value = node.value;
  2256. }
  2257. return value;
  2258. }
  2259. /**
  2260. * Updates an element's value property if
  2261. * one exists; else innerText if it exists
  2262. *
  2263. * @param {Array[HTMLElement]} nodes
  2264. * @param {Mixed} value
  2265. */
  2266. function valueSet (nodes, value) {
  2267. if (type(nodes) !== 'array') nodes = [nodes];
  2268. each(nodes, function (node) {
  2269. if (!node) return;
  2270. else if ('value' in node)
  2271. node.value = value;
  2272. else if ('textContent' in node)
  2273. node.textContent = value;
  2274. else if ('innerText' in node)
  2275. node.innerText = value;
  2276. });
  2277. }
  2278. /**
  2279. * Gets or sets a node's data attribute
  2280. *
  2281. * @param {HTMLElement} node
  2282. * @param {String} key
  2283. * @param {Mixed} [value]
  2284. */
  2285. function data (node, key, value) {
  2286. node = element(node);
  2287. if (!node) return;
  2288. return typeof value !== 'undefined'
  2289. ? dataSet(node, key, value)
  2290. : dataGet(node, key);
  2291. }
  2292. /**
  2293. * Gets a node's data attribute
  2294. *
  2295. * @param {HTMLElement} node
  2296. * @param {String} key
  2297. */
  2298. function dataGet (node, key) {
  2299. return node.dataset
  2300. ? node.dataset[key]
  2301. : node.getAttribute('data-' + slug(key));
  2302. }
  2303. /**
  2304. * sets a node's data attribute
  2305. *
  2306. * @param {HTMLElement} node
  2307. * @param {String} key
  2308. * @param {Mixed} value
  2309. */
  2310. function dataSet (node, key, value) {
  2311. if (node.dataset) node.dataset[key] = value;
  2312. else node.setAttribute('data-' + slug(key), value);
  2313. }
  2314. });
  2315. require.register("recurly/lib/util/parse-card.js", function(exports, require, module){
  2316. /**
  2317. * Removes dashes and spaces from a card number.
  2318. *
  2319. * @param {Number|String} number
  2320. * @return {String} parsed card number
  2321. */
  2322. module.exports = function parseCard (number) {
  2323. return number && number.toString().replace(/[-\s]/g, '');
  2324. };
  2325. });
  2326. require.register("recurly/lib/recurly/open.js", function(exports, require, module){
  2327. /*!
  2328. * Module dependencies.
  2329. */
  2330. var bind = require('bind');
  2331. var type = require('type');
  2332. var json = require('json');
  2333. var events = require('event');
  2334. var qs = require('querystring');
  2335. var errors = require('../errors');
  2336. var debug = require('debug')('recurly:open');
  2337. /**
  2338. * Issues an API request to a popup window.
  2339. *
  2340. * TODO(*): configurable window name?
  2341. * TODO(*): configurable window properties?
  2342. *
  2343. * @param {String} url
  2344. * @param {Object} [data]
  2345. * @param {Function} [done]
  2346. * @throws {Error} If `configure` has not been called.
  2347. * @return {Window}
  2348. * @private
  2349. */
  2350. exports.open = function (url, data, done) {
  2351. debug('open');
  2352. if (false === this.configured) {
  2353. throw errors('not-configured');
  2354. }
  2355. if ('function' == type(data)) {
  2356. done = data;
  2357. data = {};
  2358. }
  2359. data = data || {};
  2360. data.version = this.version;
  2361. data.event = 'recurly-open-' + this.id++;
  2362. data.key = this.config.publicKey;
  2363. this.once(data.event, done);
  2364. if (!/^https?:\/\//.test(url)) url = this.url(url);
  2365. url += (~url.indexOf('?') ? '&' : '?') + qs.stringify(data);
  2366. this.relay(function () {
  2367. window.open(url);
  2368. });
  2369. };
  2370. /**
  2371. * Relay mixin.
  2372. *
  2373. * Inspects the window for intent to relay a message,
  2374. * then attempts to send it off. closes the window once
  2375. * dispatched.
  2376. *
  2377. * @param {Function} done
  2378. * @private
  2379. */
  2380. exports.relay = function (done) {
  2381. var self = this;
  2382. if (false === this.configured) {
  2383. throw errors('not-configured');
  2384. }
  2385. events.bind(window, 'message', function listener (event) {
  2386. var data = json.parse(event.data);
  2387. var name = data.recurly_event;
  2388. var body = data.recurly_message;
  2389. var err = body.error ? errors('api-error', body.error) : null;
  2390. events.unbind(window, 'message', listener);
  2391. if (name) self.emit(name, err, body);
  2392. if (frame) document.body.removeChild(frame);
  2393. });
  2394. if ('documentMode' in document) {
  2395. var frame = document.createElement('iframe');
  2396. frame.width = frame.height = 0;
  2397. frame.src = this.url('/relay');
  2398. frame.name = 'recurly-relay';
  2399. frame.style.display = 'none';
  2400. frame.onload = bind(this, done);
  2401. document.body.appendChild(frame);
  2402. } else {
  2403. done();
  2404. }
  2405. };
  2406. });
  2407. require.register("recurly/lib/recurly/coupon.js", function(exports, require, module){
  2408. /*!
  2409. * Module dependencies.
  2410. */
  2411. var type = require('type');
  2412. var debug = require('debug')('recurly:coupon');
  2413. var errors = require('../errors');
  2414. /**
  2415. * Coupon mixin.
  2416. *
  2417. * Retrieves coupon information for the `plan`. The `callback` signature
  2418. * is `err, plan` where `err` may be a request or server error, and `plan`
  2419. * is a representation of the requested plan.
  2420. *
  2421. * @param {Object} options
  2422. * @param {Function} callback
  2423. */
  2424. exports.coupon = function (options, callback) {
  2425. debug('%j', options);
  2426. if ('function' !== type(callback)) {
  2427. throw errors('missing-callback');
  2428. }
  2429. if ('object' !== type(options)) {
  2430. throw errors('invalid-options');
  2431. }
  2432. if (!('plan' in options)) {
  2433. throw errors('missing-plan');
  2434. }
  2435. if (!('coupon' in options)) {
  2436. throw errors('missing-coupon');
  2437. }
  2438. this.request('/plans/' + options.plan + '/coupons/' + options.coupon, options, callback);
  2439. };
  2440. });
  2441. require.register("recurly/lib/recurly/paypal.js", function(exports, require, module){
  2442. /*!
  2443. * Module dependencies.
  2444. */
  2445. var debug = require('debug')('recurly:paypal');
  2446. /**
  2447. * Paypal mixin.
  2448. *
  2449. * @param {Object} data
  2450. * @param {Function} done callback
  2451. */
  2452. exports.paypal = function (data, done) {
  2453. debug('start');
  2454. this.open('/paypal/start', data, done);
  2455. };
  2456. });
  2457. require.register("recurly/lib/recurly/plan.js", function(exports, require, module){
  2458. /*!
  2459. * Module dependencies.
  2460. */
  2461. var type = require('type');
  2462. var debug = require('debug')('recurly:plan');
  2463. /**
  2464. * Plan mixin.
  2465. *
  2466. * Retrieves information for the `plan`. The `callback` signature
  2467. * is `err, plan` where `err` may be a request or server error, and `plan`
  2468. * is a representation of the requested plan.
  2469. *
  2470. * @param {String} code
  2471. * @param {Function} callback
  2472. */
  2473. exports.plan = function (code, callback) {
  2474. debug('%s', code);
  2475. if ('function' != type(callback)) {
  2476. throw new Error('Missing callback');
  2477. }
  2478. if ('undefined' == type(code)) {
  2479. return callback(new Error('Missing plan code'));
  2480. }
  2481. this.request('/plans/' + code, callback);
  2482. };
  2483. });
  2484. require.register("recurly/lib/recurly/tax.js", function(exports, require, module){
  2485. /*!
  2486. * Module dependencies.
  2487. */
  2488. var type = require('type');
  2489. var clone = require('clone');
  2490. var debug = require('debug')('recurly:tax');
  2491. /**
  2492. * Tax mixin.
  2493. *
  2494. * Provides a tax estiamte for the given address.
  2495. *
  2496. * @param {Object} options
  2497. * @param {Object} options.postal_code
  2498. * @param {Object} options.country
  2499. * @param {Object} [options.vat_number] Used for VAT exemptions
  2500. * @param {Function} callback
  2501. */
  2502. exports.tax = function (options, callback) {
  2503. var request = clone(options);
  2504. if ('function' != type(callback)) {
  2505. throw new Error('Missing callback');
  2506. }
  2507. if (!('currency' in request)) {
  2508. request.currency = this.config.currency;
  2509. }
  2510. this.request('/tax', request, callback);
  2511. };
  2512. });
  2513. require.register("recurly/lib/recurly/token.js", function(exports, require, module){
  2514. /*!
  2515. * Module dependencies.
  2516. */
  2517. var bind = require('bind');
  2518. var each = require('each');
  2519. var type = require('type');
  2520. var index = require('indexof');
  2521. var debug = require('debug')('recurly:token');
  2522. var dom = require('../util/dom');
  2523. var parseCard = require('../util/parse-card');
  2524. var errors = require('../errors');
  2525. /**
  2526. * Fields that are sent to API.
  2527. *
  2528. * @type {Array}
  2529. * @private
  2530. */
  2531. var fields = [
  2532. 'first_name'
  2533. , 'last_name'
  2534. , 'number'
  2535. , 'month'
  2536. , 'year'
  2537. , 'cvv'
  2538. , 'address1'
  2539. , 'address2'
  2540. , 'country'
  2541. , 'city'
  2542. , 'state'
  2543. , 'postal_code'
  2544. , 'phone'
  2545. , 'vat_number'
  2546. , 'token'
  2547. ];
  2548. /**
  2549. * Generates a token from customer data.
  2550. *
  2551. * The callback signature: `err, response` where `err` is a
  2552. * connection, request, or server error, and `response` is the
  2553. * recurly service response. The generated token is accessed
  2554. * at `response.token`.
  2555. *
  2556. * @param {Object|HTMLFormElement} options Billing properties or an HTMLFormElement
  2557. * with children corresponding to billing properties via 'data-reurly' attributes.
  2558. * @param {String} options.first_name customer first name
  2559. * @param {String} options.last_name customer last name
  2560. * @param {String|Number} options.number card number
  2561. * @param {String|Number} options.month card expiration month
  2562. * @param {String|Number} options.year card expiration year
  2563. * @param {String|Number} options.cvv card verification value
  2564. * @param {String} [options.address1]
  2565. * @param {String} [options.address2]
  2566. * @param {String} [options.country]
  2567. * @param {String} [options.city]
  2568. * @param {String} [options.state]
  2569. * @param {String|Number} [options.postal_code]
  2570. * @param {Function} done callback
  2571. */
  2572. exports.token = function (options, done) {
  2573. var open = bind(this, this.open);
  2574. var data = normalize(options);
  2575. var input = data.values;
  2576. var userErrors = validate.call(this, input);
  2577. if ('function' !== type(done)) {
  2578. throw errors('missing-callback');
  2579. }
  2580. if (userErrors.length) {
  2581. return done(errors('validation', { fields: userErrors }));
  2582. }
  2583. this.request('/token', input, function (err, res) {
  2584. if (err) return done(err);
  2585. if (data.fields.token && res.id) {
  2586. data.fields.token.value = res.id;
  2587. }
  2588. done(null, res);
  2589. });
  2590. };
  2591. /**
  2592. * Parses options out of a form element and normalizes according to rules.
  2593. *
  2594. * @param {Object|HTMLFormElement} options
  2595. * @return {Object}
  2596. */
  2597. function normalize (options) {
  2598. var el = dom.element(options);
  2599. var data = { fields: {}, values: {} };
  2600. if (el && 'form' === el.nodeName.toLowerCase()) {
  2601. each(el.querySelectorAll('[data-recurly]'), function (field) {
  2602. var name = dom.data(field, 'recurly');
  2603. if (~index(fields, name)) {
  2604. data.fields[name] = field;
  2605. data.values[name] = dom.value(field);
  2606. }
  2607. });
  2608. } else {
  2609. data.values = options;
  2610. }
  2611. data.values.number = parseCard(data.values.number);
  2612. return data;
  2613. }
  2614. /**
  2615. * Checks user input on a token call
  2616. *
  2617. * @param {Object} input
  2618. * @return {Array} indicates which fields are not valid
  2619. */
  2620. function validate (input) {
  2621. var errors = [];
  2622. if (!this.validate.cardNumber(input.number)) {
  2623. errors.push('number');
  2624. }
  2625. if (!this.validate.expiry(input.month, input.year)) {
  2626. errors.push('month', 'year');
  2627. }
  2628. if (!input.first_name) {
  2629. errors.push('first_name');
  2630. }
  2631. if (!input.last_name) {
  2632. errors.push('last_name');
  2633. }
  2634. return errors;
  2635. }
  2636. });
  2637. require.register("recurly/lib/recurly/validate.js", function(exports, require, module){
  2638. /*!
  2639. * Module dependencies.
  2640. */
  2641. var find = require('find');
  2642. var trim = require('trim');
  2643. var index = require('indexof');
  2644. var parseCard = require('../util/parse-card');
  2645. /**
  2646. * Card patterns.
  2647. *
  2648. * @private
  2649. */
  2650. var types = [
  2651. {
  2652. type: 'discover',
  2653. pattern: /^(6011|622|64[4-9]|65)/,
  2654. lengths: [16]
  2655. }
  2656. , {
  2657. type: 'master',
  2658. pattern: /^5[0-5]/,
  2659. lengths: [16]
  2660. }
  2661. , {
  2662. type: 'american_express',
  2663. pattern: /^3[47]/,
  2664. lengths: [15]
  2665. }
  2666. , {
  2667. type: 'visa',
  2668. pattern: /^4/,
  2669. lengths: [13, 16]
  2670. }
  2671. , {
  2672. type: 'jcb',
  2673. pattern: /^35[2-8]\d/,
  2674. lengths: [16]
  2675. }
  2676. , {
  2677. type: 'diners_club',
  2678. pattern: /^(30[0-5]|309|36|3[89]|54|55|2014|2149)/,
  2679. lengths: [14]
  2680. }
  2681. ];
  2682. /**
  2683. * Validate mixin.
  2684. *
  2685. * @public
  2686. */
  2687. exports.validate = {
  2688. /**
  2689. * Validates a credit card number via luhn algorithm.
  2690. *
  2691. * @param {Number|String} number The card number.
  2692. * @return {Boolean}
  2693. * @see https://sites.google.com/site/abapexamples/javascript/luhn-validation
  2694. */
  2695. cardNumber: function (number) {
  2696. var str = parseCard(number);
  2697. var ca, sum = 0, mul = 1;
  2698. var i = str.length;
  2699. while (i--) {
  2700. ca = parseInt(str.charAt(i), 10) * mul;
  2701. sum += ca - (ca > 9) * 9;
  2702. mul ^= 3;
  2703. }
  2704. return sum % 10 === 0 && sum > 0;
  2705. },
  2706. /**
  2707. * Returns the type of the card number as a string.
  2708. *
  2709. * TODO(chrissrogers): Maybe undefined instread of "unknown"?
  2710. *
  2711. * @param {Number|String} number The card number
  2712. * @return {String} card type
  2713. */
  2714. cardType: function (number) {
  2715. var str = parseCard(number);
  2716. var card = find(types, function (card) {
  2717. return card.pattern.test(str) && ~index(card.lengths, str.length);
  2718. });
  2719. return card && card.type || 'unknown';
  2720. },
  2721. /**
  2722. * Validates whether an expiry month is present or future.
  2723. *
  2724. * @param {Numer|String} month The 2 digit month
  2725. * @param {Numer|String} year The 2 or 4 digit year
  2726. * @return {Boolean}
  2727. */
  2728. expiry: function (month, year) {
  2729. month = parseInt(month, 10) - 1;
  2730. if (month < 0 || month > 11) return false;
  2731. year = parseInt(year, 10);
  2732. year += year < 100 ? 2000 : 0;
  2733. var expiry = new Date;
  2734. expiry.setYear(year);
  2735. expiry.setDate(1);
  2736. expiry.setHours(0);
  2737. expiry.setMinutes(0);
  2738. expiry.setSeconds(0);
  2739. expiry.setMonth(month + 1);
  2740. return new Date < expiry;
  2741. },
  2742. /**
  2743. * Validates whether a number looks like a cvv.
  2744. *
  2745. * e.g.: '123', '0321'
  2746. *
  2747. * @param {Number|String} number The card verification value
  2748. * @return {Boolean}
  2749. */
  2750. cvv: function (number) {
  2751. number = trim(number + '');
  2752. return /^\d+$/.test(number) && (number.length === 3 || number.length === 4);
  2753. }
  2754. };
  2755. });
  2756. require.register("recurly/lib/recurly/pricing/index.js", function(exports, require, module){
  2757. /**
  2758. * dependencies
  2759. */
  2760. var Emitter = require('emitter');
  2761. var index = require('indexof');
  2762. var each = require('each');
  2763. var type = require('type');
  2764. var bind = require('bind');
  2765. var find = require('find');
  2766. var mixin = require('mixin');
  2767. var keys = require('object').keys;
  2768. var json = require('json');
  2769. var debug = require('debug')('recurly:pricing');
  2770. var PricingPromise = require('./promise');
  2771. var Calculations = require('./calculations');
  2772. var errors = require('../../errors');
  2773. /**
  2774. * expose
  2775. */
  2776. exports.Pricing = Pricing;
  2777. /**
  2778. * Pricing
  2779. *
  2780. * @constructor
  2781. * @param {Recurly} recurly
  2782. * @public
  2783. */
  2784. function Pricing (recurly) {
  2785. if (this instanceof require('../../recurly')) return new Pricing(this);
  2786. this.recurly = recurly;
  2787. this.reset();
  2788. }
  2789. Emitter(Pricing.prototype);
  2790. /**
  2791. * Subscription properties
  2792. */
  2793. Pricing.properties = [
  2794. 'plan'
  2795. , 'addon'
  2796. , 'coupon'
  2797. , 'address'
  2798. , 'currency'
  2799. ];
  2800. /**
  2801. * Resets the pricing calculator
  2802. *
  2803. * @public
  2804. */
  2805. Pricing.prototype.reset = function () {
  2806. this.items = {};
  2807. this.items.addons = [];
  2808. this.currency(this.recurly.config.currency);
  2809. };
  2810. /**
  2811. * Removes an object from the pricing model
  2812. *
  2813. * example
  2814. *
  2815. * .remove({ plan: 'plan_code' });
  2816. * .remove({ addon: 'addon_code' });
  2817. * .remove({ coupon: 'coupon_code' });
  2818. * .remove({ address: true }); // to remove without specifying a code
  2819. *
  2820. * @param {Object} opts
  2821. * @param {Function} [done] callback
  2822. * @public
  2823. */
  2824. Pricing.prototype.remove = function (opts, done) {
  2825. var self = this;
  2826. var item;
  2827. debug('remove');
  2828. return new PricingPromise(function (resolve, reject) {
  2829. var prop = keys(opts)[0];
  2830. var id = opts[prop];
  2831. if (!~index(Pricing.properties, prop)) return reject(errors('invalid-item'));
  2832. if (prop === 'addon') {
  2833. var pos = index(self.items.addons, findAddon(self.items.addons, { code: id }));
  2834. if (~pos) {
  2835. item = self.items.addons.splice(pos);
  2836. }
  2837. } else if (self.items[prop] && (id === self.items[prop].code || id === true)) {
  2838. item = self.items[prop]
  2839. delete self.items[prop];
  2840. } else {
  2841. return reject(errors('unremovable-item', {
  2842. type: prop
  2843. , id: id
  2844. , reason: 'does not exist on this pricing instance.'
  2845. }));
  2846. }
  2847. }, this).nodeify(done);
  2848. };
  2849. /**
  2850. * Provides a subscription price estimate using current state
  2851. *
  2852. * @param {Function} [done] callback
  2853. * @public
  2854. */
  2855. Pricing.prototype.reprice = function (done) {
  2856. var self = this;
  2857. debug('reprice');
  2858. return new PricingPromise(function (resolve, reject) {
  2859. if (!self.items.plan) return reject(errors('missing-plan'));
  2860. Calculations(self, function (price) {
  2861. if (json.stringify(price) === json.stringify(self.price)) return resolve(price);
  2862. self.price = price;
  2863. self.emit('change', price);
  2864. resolve(price);
  2865. });
  2866. }, this).nodeify(done);
  2867. };
  2868. /**
  2869. * Updates plan
  2870. *
  2871. * @param {String} planCode
  2872. * @param {Object} [meta]
  2873. * @param {Number} [meta.quantity]
  2874. * @param {Function} [done] callback
  2875. * @public
  2876. */
  2877. Pricing.prototype.plan = function (planCode, meta, done) {
  2878. var self = this;
  2879. var plan = this.items.plan;
  2880. var quantity;
  2881. if (type(meta) === 'function') {
  2882. done = meta;
  2883. meta = undefined;
  2884. }
  2885. meta = meta || {};
  2886. // meta.quantity, plan.quantity, 1
  2887. if (plan && plan.quantity) quantity = plan.quantity;
  2888. if (meta.quantity) quantity = parseInt(meta.quantity, 10);
  2889. if (!quantity || quantity < 1) quantity = 1;
  2890. return new PricingPromise(function (resolve, reject) {
  2891. if (plan && plan.code === planCode) {
  2892. plan.quantity = quantity;
  2893. return resolve(plan);
  2894. }
  2895. self.recurly.plan(planCode, function (err, plan) {
  2896. if (err) return reject(err);
  2897. plan.quantity = quantity;
  2898. self.items.plan = plan;
  2899. if (!(self.items.currency in plan.price)) {
  2900. self.currency(keys(plan.price)[0]);
  2901. }
  2902. debug('set.plan');
  2903. self.emit('set.plan', plan);
  2904. resolve(plan);
  2905. });
  2906. }, this).nodeify(done);
  2907. };
  2908. /**
  2909. * Updates addon
  2910. *
  2911. * @param {String} addonCode
  2912. * @param {Object} [meta]
  2913. * @param {Number} [meta.quantity]
  2914. * @param {Function} [done] callback
  2915. * @public
  2916. */
  2917. Pricing.prototype.addon = function (addonCode, meta, done) {
  2918. var self = this;
  2919. if (type(meta) === 'function') {
  2920. done = meta;
  2921. meta = undefined;
  2922. }
  2923. meta = meta || {};
  2924. return new PricingPromise(function (resolve, reject) {
  2925. if (!self.items.plan) return reject(errors('missing-plan'));
  2926. var planAddon = findAddon(self.items.plan.addons, addonCode);
  2927. if (!planAddon) {
  2928. return reject(errors('invalid-addon', {
  2929. planCode: self.items.plan.code
  2930. , addonCode: addonCode
  2931. }));
  2932. }
  2933. var quantity = addonQuantity(meta, planAddon);
  2934. var addon = findAddon(self.items.addons, addonCode);
  2935. if (quantity === 0) {
  2936. self.remove({ addon: addonCode });
  2937. }
  2938. if (addon) {
  2939. addon.quantity = quantity;
  2940. } else {
  2941. addon = json.parse(json.stringify(planAddon));
  2942. addon.quantity = quantity;
  2943. self.items.addons.push(addon);
  2944. }
  2945. debug('set.addon');
  2946. self.emit('set.addon', addon);
  2947. resolve(addon);
  2948. }, this).nodeify(done);
  2949. };
  2950. /**
  2951. * Updates coupon
  2952. *
  2953. * @param {String} couponCode
  2954. * @param {Function} [done] callback
  2955. * @public
  2956. */
  2957. Pricing.prototype.coupon = function (couponCode, done) {
  2958. var self = this;
  2959. var coupon = this.items.coupon;
  2960. return new PricingPromise(function (resolve, reject) {
  2961. if (!self.items.plan) return reject(errors('missing-plan'));
  2962. if (coupon) {
  2963. if (coupon.code === couponCode) return resolve(coupon);
  2964. else self.remove({ coupon: coupon.code });
  2965. }
  2966. if (!couponCode) return resolve();
  2967. self.recurly.coupon({ plan: self.items.plan.code, coupon: couponCode }, function (err, coupon) {
  2968. if (err && err.code !== 'not_found') return reject(err);
  2969. self.items.coupon = coupon;
  2970. debug('set.coupon');
  2971. self.emit('set.coupon', coupon);
  2972. resolve(coupon);
  2973. });
  2974. }, this).nodeify(done);
  2975. };
  2976. /**
  2977. * Updates address
  2978. *
  2979. * @param {Object} address
  2980. * @param {String} address.country
  2981. * @param {String|Number} address.postal_code
  2982. * @param {String} address.vat_number
  2983. * @param {Function} [done] callback
  2984. * @public
  2985. */
  2986. Pricing.prototype.address = function (address, done) {
  2987. var self = this;
  2988. return new PricingPromise(function (resolve, reject) {
  2989. if (json.stringify(address) === json.stringify(self.items.address)) {
  2990. return resolve(self.items.address);
  2991. }
  2992. self.items.address = address;
  2993. debug('set.address');
  2994. self.emit('set.address', address);
  2995. resolve(address);
  2996. }, this).nodeify(done);
  2997. };
  2998. /**
  2999. * Updates or retrieves currency code
  3000. *
  3001. * @param {String} code
  3002. * @param {Function} [done] callback
  3003. * @public
  3004. */
  3005. Pricing.prototype.currency = function (code, done) {
  3006. var self = this;
  3007. var plan = this.items.plan
  3008. var currency = this.items.currency;
  3009. return new PricingPromise(function (resolve, reject) {
  3010. if (currency === code) return resolve(currency);
  3011. if (plan && !(code in plan.price)) {
  3012. return reject(errors('invalid-currency', {
  3013. currencyCode: code
  3014. , planCurrencies: keys(plan.price)
  3015. }));
  3016. }
  3017. self.items.currency = code;
  3018. debug('set.currency');
  3019. self.emit('set.currency', code);
  3020. resolve(code);
  3021. }, this).nodeify(done);
  3022. };
  3023. /**
  3024. * DOM attachment mixin
  3025. */
  3026. mixin(Pricing.prototype, require('./attach'));
  3027. /**
  3028. * Utility functions
  3029. */
  3030. function addonQuantity (meta, planAddon) {
  3031. var qty = 1;
  3032. if ('quantity' in planAddon) qty = planAddon.quantity;
  3033. if ('quantity' in meta) qty = meta.quantity;
  3034. return parseInt(qty, 10) || 0;
  3035. }
  3036. function findAddon (addons, code) {
  3037. return addons && find(addons, { code: code });
  3038. }
  3039. });
  3040. require.register("recurly/lib/recurly/pricing/promise.js", function(exports, require, module){
  3041. /**
  3042. * Dependencies
  3043. */
  3044. var Promise = require('promise');
  3045. var mixin = require('mixin');
  3046. var bind = require('bind');
  3047. var each = require('each');
  3048. var type = require('type');
  3049. var par = require('par');
  3050. var debug = require('debug')('recurly:pricing:promise');
  3051. /**
  3052. * Expose
  3053. */
  3054. module.exports = PricingPromise;
  3055. /**
  3056. * PricingPromise
  3057. *
  3058. * issues repricing when .done
  3059. *
  3060. * contains .then wrappers for Pricing property methods
  3061. *
  3062. * Usage
  3063. *
  3064. * var pricing = recurly.Pricing();
  3065. *
  3066. * pricing
  3067. * .plan('basic')
  3068. * .addon('addon1')
  3069. * .then(process)
  3070. * .catch(errors)
  3071. * .done();
  3072. *
  3073. * @param {Function} resolver
  3074. * @param {Pricing} pricing bound instance
  3075. * @constructor
  3076. * @public
  3077. */
  3078. function PricingPromise (resolver, pricing) {
  3079. if (!(this instanceof PricingPromise)) return new PricingPromise(resolver, pricing);
  3080. var self = this;
  3081. this.pricing = pricing;
  3082. this.constructor = par.rpartial(this.constructor, pricing);
  3083. Promise.call(this, resolver);
  3084. // for each pricing method, create a promise wrapper method
  3085. each(require('./').Pricing.prototype, function (method) {
  3086. self[method] = function () {
  3087. var args = arguments;
  3088. return self.then(function () {
  3089. return self.pricing[method].apply(self.pricing, args);
  3090. });
  3091. };
  3092. });
  3093. }
  3094. mixin(PricingPromise.prototype, Promise.prototype);
  3095. PricingPromise.prototype.constructor = PricingPromise;
  3096. /**
  3097. * Adds a reprice and completes the control flow
  3098. *
  3099. * @param {Function} onFulfilled
  3100. * @param {Function} onRejected
  3101. * @return {Pricing} bound pricing instance
  3102. * @public
  3103. */
  3104. PricingPromise.prototype.done = function () {
  3105. Promise.prototype.done.apply(this.then(this.reprice), arguments);
  3106. return this.pricing;
  3107. };
  3108. /**
  3109. * Adds a reprice if a callback is passed
  3110. *
  3111. * @param {Function} [done] callback
  3112. * @public
  3113. */
  3114. PricingPromise.prototype.nodeify = function (done) {
  3115. if (type(done) === 'function') this.reprice();
  3116. return Promise.prototype.nodeify.apply(this, arguments);
  3117. };
  3118. });
  3119. require.register("recurly/lib/recurly/pricing/calculations.js", function(exports, require, module){
  3120. /**
  3121. * dependencies
  3122. */
  3123. var each = require('each');
  3124. var bind = require('bind');
  3125. var find = require('find');
  3126. /**
  3127. * expose
  3128. */
  3129. module.exports = Calculations;
  3130. /**
  3131. * Subscription calculation calculation
  3132. *
  3133. * @param {Pricing} pricing
  3134. * @constructor
  3135. * @public
  3136. */
  3137. function Calculations (pricing, done) {
  3138. if (!(this instanceof Calculations)) {
  3139. return new Calculations(pricing, done);
  3140. }
  3141. this.pricing = pricing;
  3142. this.items = pricing.items;
  3143. this.price = {
  3144. now: {},
  3145. next: {},
  3146. addons: {},
  3147. currency: {
  3148. code: this.items.currency,
  3149. symbol: this.planPrice().symbol
  3150. }
  3151. };
  3152. this.subtotal();
  3153. this.tax(function () {
  3154. this.total();
  3155. each(this.price.now, decimal, this.price.now);
  3156. each(this.price.next, decimal, this.price.next);
  3157. each(this.price.addons, decimal, this.price.addons);
  3158. done(this.price);
  3159. });
  3160. }
  3161. /**
  3162. * Calculates subtotal
  3163. *
  3164. * @private
  3165. */
  3166. Calculations.prototype.subtotal = function () {
  3167. var subtotal = this.planPrice().amount;
  3168. this.price.now.subtotal = subtotal;
  3169. this.price.next.subtotal = subtotal;
  3170. if (this.items.plan.trial) this.price.now.subtotal = 0;
  3171. this.addons();
  3172. this.price.now.subtotal += this.price.now.addons;
  3173. this.price.next.subtotal += this.price.next.addons;
  3174. this.discount();
  3175. this.price.now.subtotal -= this.price.now.discount;
  3176. this.price.next.subtotal -= this.price.next.discount;
  3177. this.setupFee();
  3178. this.price.now.subtotal += this.price.now.setup_fee;
  3179. };
  3180. /**
  3181. * Calculates tax
  3182. *
  3183. * @param {Function} done
  3184. * @private
  3185. */
  3186. Calculations.prototype.tax = function (done) {
  3187. this.price.now.tax = 0;
  3188. this.price.next.tax = 0;
  3189. if (this.items.address) {
  3190. var self = this;
  3191. this.pricing.recurly.tax(this.items.address, function applyTax (err, taxes) {
  3192. if (err) {
  3193. self.pricing.emit('error', err);
  3194. } else {
  3195. each(taxes, function (tax) {
  3196. if (tax.type === 'usst' && self.items.plan.tax_exempt) return;
  3197. self.price.now.tax += self.price.now.subtotal * tax.rate;
  3198. self.price.next.tax += self.price.next.subtotal * tax.rate;
  3199. });
  3200. // tax estimation prefers partial cents to always round up
  3201. self.price.now.tax = Math.ceil(self.price.now.tax * 100) / 100;
  3202. self.price.next.tax = Math.ceil(self.price.next.tax * 100) / 100;
  3203. }
  3204. done.call(self);
  3205. });
  3206. } else done.call(this);
  3207. };
  3208. /**
  3209. * Calculates total
  3210. *
  3211. * @private
  3212. */
  3213. Calculations.prototype.total = function () {
  3214. this.price.now.total = this.price.now.subtotal + this.price.now.tax;
  3215. this.price.next.total = this.price.next.subtotal + this.price.next.tax;
  3216. };
  3217. /**
  3218. * Computes addon prices and applies addons to the subtotal
  3219. *
  3220. * @private
  3221. */
  3222. Calculations.prototype.addons = function () {
  3223. this.price.now.addons = 0;
  3224. this.price.next.addons = 0;
  3225. each(this.items.plan.addons, function (addon) {
  3226. var price = addon.price[this.items.currency].unit_amount;
  3227. this.price.addons[addon.code] = price;
  3228. var selected = find(this.items.addons, { code: addon.code });
  3229. if (selected) {
  3230. price = price * selected.quantity;
  3231. if (!this.items.plan.trial) this.price.now.addons += price;
  3232. this.price.next.addons += price;
  3233. }
  3234. }, this);
  3235. };
  3236. /**
  3237. * Applies coupon discount to the subtotal
  3238. *
  3239. * @private
  3240. */
  3241. Calculations.prototype.discount = function () {
  3242. var coupon = this.items.coupon;
  3243. this.price.now.discount = 0;
  3244. this.price.next.discount = 0;
  3245. if (coupon) {
  3246. if (coupon.discount.rate) {
  3247. this.price.now.discount = Math.round(this.price.now.subtotal * coupon.discount.rate * 100) / 100;
  3248. this.price.next.discount = Math.round(this.price.next.subtotal * coupon.discount.rate * 100) / 100;
  3249. } else {
  3250. this.price.now.discount = coupon.discount.amount[this.items.currency];
  3251. this.price.next.discount = coupon.discount.amount[this.items.currency];
  3252. }
  3253. }
  3254. };
  3255. /**
  3256. * Applies plan setup fee to the subtotal
  3257. *
  3258. * @private
  3259. */
  3260. Calculations.prototype.setupFee = function () {
  3261. this.price.now.setup_fee = this.planPrice().setup_fee;
  3262. this.price.next.setup_fee = 0;
  3263. };
  3264. /**
  3265. * Get the price structure of a plan based on currency
  3266. *
  3267. * @return {Object}
  3268. * @private
  3269. */
  3270. Calculations.prototype.planPrice = function () {
  3271. var plan = this.items.plan;
  3272. var price = plan.price[this.items.currency];
  3273. price.amount = price.unit_amount * (plan.quantity || 1);
  3274. return price;
  3275. };
  3276. /**
  3277. * Applies a decimal transform on an object's member
  3278. *
  3279. * @param {String} prop Property on {this} to transform
  3280. * @this {Object} on which to apply decimal transformation
  3281. * @private
  3282. */
  3283. function decimal (prop) {
  3284. this[prop] = (Math.round(Math.max(this[prop], 0) * 100) / 100).toFixed(2);
  3285. }
  3286. });
  3287. require.register("recurly/lib/recurly/pricing/attach.js", function(exports, require, module){
  3288. /**
  3289. * dependencies
  3290. */
  3291. var each = require('each');
  3292. var events = require('event');
  3293. var find = require('find');
  3294. var type = require('type');
  3295. var dom = require('../../util/dom');
  3296. var debug = require('debug')('recurly:pricing:attach');
  3297. /**
  3298. * bind a dom element to pricing values
  3299. *
  3300. * @param {HTMLElement} el
  3301. */
  3302. exports.attach = function (el) {
  3303. var self = this;
  3304. var elems = {};
  3305. var el = dom.element(el);
  3306. if (!el) throw new Error('invalid dom element');
  3307. if (this.attach.detatch) this.attach.detatch();
  3308. self.on('change', update);
  3309. each(el.querySelectorAll('[data-recurly]'), function (elem) {
  3310. // 'zip' -> 'postal_code'
  3311. if (dom.data(elem, 'recurly') === 'zip') dom.data(elem, 'recurly', 'postal_code');
  3312. var name = dom.data(elem, 'recurly');
  3313. if (!elems[name]) elems[name] = [];
  3314. elems[name].push(elem);
  3315. events.bind(elem, 'change', change);
  3316. events.bind(elem, 'propertychange', change);
  3317. });
  3318. this.attach.detatch = detatch;
  3319. change();
  3320. function change (event) {
  3321. debug('change');
  3322. var targetName = event && event.target && dom.data(event.target, 'recurly');
  3323. targetName = targetName || window.event && window.event.srcElement;
  3324. var pricing = self.plan(dom.value(elems.plan), { quantity: dom.value(elems.plan_quantity) });
  3325. if (target('currency')) {
  3326. pricing = pricing.currency(dom.value(elems.currency));
  3327. }
  3328. if (target('addon') && elems.addon) {
  3329. addons();
  3330. }
  3331. if (target('coupon') && elems.coupon) {
  3332. pricing = pricing.coupon(dom.value(elems.coupon)).then(null, ignoreBadCoupons);
  3333. }
  3334. if (target('country') || target('postal_code') || target('vat_number')) {
  3335. pricing = pricing.address({
  3336. country: dom.value(elems.country),
  3337. postal_code: dom.value(elems.postal_code),
  3338. vat_number: dom.value(elems.vat_number)
  3339. });
  3340. }
  3341. pricing.done();
  3342. function addons () {
  3343. each(elems.addon, function (node) {
  3344. var plan = self.items.plan;
  3345. var addonCode = dom.data(node, 'recurlyAddon');
  3346. if (plan.addons && find(plan.addons, { code: addonCode })) {
  3347. pricing = pricing.addon(addonCode, { quantity: dom.value(node) });
  3348. }
  3349. });
  3350. }
  3351. function target (name) {
  3352. if (!targetName) return true;
  3353. if (targetName === name) return true;
  3354. return false
  3355. }
  3356. };
  3357. function update (price) {
  3358. dom.value(elems.currency_code, price.currency.code);
  3359. dom.value(elems.currency_symbol, price.currency.symbol);
  3360. each(['addons', 'discount', 'setup_fee', 'subtotal', 'tax', 'total'], function (value) {
  3361. dom.value(elems[value + '_now'], price.now[value]);
  3362. dom.value(elems[value + '_next'], price.next[value]);
  3363. });
  3364. if (elems.addonPrice) {
  3365. each(elems.addonPrice, function (elem) {
  3366. var addonPrice = price.addons[dom.data(elem, 'recurlyAddon')];
  3367. if (addonPrice) dom.value(elem, addonPrice);
  3368. });
  3369. }
  3370. }
  3371. function detatch () {
  3372. each(elems, function (name, elems) {
  3373. each(elems, function (elem) {
  3374. events.unbind(elem, 'change', change);
  3375. events.unbind(elem, 'propertychange', change);
  3376. }, this);
  3377. }, this);
  3378. }
  3379. };
  3380. function ignoreBadCoupons (err) {
  3381. if (err.code === 'not-found') return;
  3382. else throw err;
  3383. }
  3384. /**
  3385. * Backward-compatibility
  3386. *
  3387. * @deprecated
  3388. */
  3389. exports.binding = exports.attach;
  3390. });
  3391. require.alias("visionmedia-node-querystring/index.js", "recurly/deps/querystring/index.js");
  3392. require.alias("visionmedia-node-querystring/index.js", "querystring/index.js");
  3393. require.alias("component-emitter/index.js", "recurly/deps/emitter/index.js");
  3394. require.alias("component-emitter/index.js", "emitter/index.js");
  3395. require.alias("component-indexof/index.js", "recurly/deps/indexof/index.js");
  3396. require.alias("component-indexof/index.js", "indexof/index.js");
  3397. require.alias("component-object/index.js", "recurly/deps/object/index.js");
  3398. require.alias("component-object/index.js", "object/index.js");
  3399. require.alias("component-event/index.js", "recurly/deps/event/index.js");
  3400. require.alias("component-event/index.js", "event/index.js");
  3401. require.alias("component-clone/index.js", "recurly/deps/clone/index.js");
  3402. require.alias("component-clone/index.js", "clone/index.js");
  3403. require.alias("component-type/index.js", "component-clone/deps/type/index.js");
  3404. require.alias("component-bind/index.js", "recurly/deps/bind/index.js");
  3405. require.alias("component-bind/index.js", "bind/index.js");
  3406. require.alias("component-each/index.js", "recurly/deps/each/index.js");
  3407. require.alias("component-each/index.js", "each/index.js");
  3408. require.alias("component-to-function/index.js", "component-each/deps/to-function/index.js");
  3409. require.alias("component-props/index.js", "component-to-function/deps/props/index.js");
  3410. require.alias("component-type/index.js", "component-each/deps/type/index.js");
  3411. require.alias("component-find/index.js", "recurly/deps/find/index.js");
  3412. require.alias("component-find/index.js", "find/index.js");
  3413. require.alias("component-to-function/index.js", "component-find/deps/to-function/index.js");
  3414. require.alias("component-props/index.js", "component-to-function/deps/props/index.js");
  3415. require.alias("component-json/index.js", "recurly/deps/json/index.js");
  3416. require.alias("component-json/index.js", "json/index.js");
  3417. require.alias("component-type/index.js", "recurly/deps/type/index.js");
  3418. require.alias("component-type/index.js", "type/index.js");
  3419. require.alias("component-trim/index.js", "recurly/deps/trim/index.js");
  3420. require.alias("component-trim/index.js", "trim/index.js");
  3421. require.alias("component-map/index.js", "recurly/deps/map/index.js");
  3422. require.alias("component-map/index.js", "map/index.js");
  3423. require.alias("component-to-function/index.js", "component-map/deps/to-function/index.js");
  3424. require.alias("component-props/index.js", "component-to-function/deps/props/index.js");
  3425. require.alias("yields-merge/index.js", "recurly/deps/merge/index.js");
  3426. require.alias("yields-merge/index.js", "merge/index.js");
  3427. require.alias("learnboost-jsonp/index.js", "recurly/deps/jsonp/index.js");
  3428. require.alias("learnboost-jsonp/index.js", "recurly/deps/jsonp/index.js");
  3429. require.alias("learnboost-jsonp/index.js", "jsonp/index.js");
  3430. require.alias("visionmedia-debug/debug.js", "learnboost-jsonp/deps/debug/debug.js");
  3431. require.alias("visionmedia-debug/debug.js", "learnboost-jsonp/deps/debug/index.js");
  3432. require.alias("visionmedia-debug/debug.js", "visionmedia-debug/index.js");
  3433. require.alias("learnboost-jsonp/index.js", "learnboost-jsonp/index.js");
  3434. require.alias("visionmedia-debug/debug.js", "recurly/deps/debug/debug.js");
  3435. require.alias("visionmedia-debug/debug.js", "recurly/deps/debug/index.js");
  3436. require.alias("visionmedia-debug/debug.js", "debug/index.js");
  3437. require.alias("visionmedia-debug/debug.js", "visionmedia-debug/index.js");
  3438. require.alias("chrissrogers-promise/index.js", "recurly/deps/promise/index.js");
  3439. require.alias("chrissrogers-promise/core.js", "recurly/deps/promise/core.js");
  3440. require.alias("chrissrogers-promise/index.js", "promise/index.js");
  3441. require.alias("johntron-asap/asap.js", "chrissrogers-promise/deps/asap/asap.js");
  3442. require.alias("johntron-asap/asap.js", "chrissrogers-promise/deps/asap/index.js");
  3443. require.alias("johntron-asap/asap.js", "johntron-asap/index.js");
  3444. require.alias("kewah-mixin/index.js", "recurly/deps/mixin/index.js");
  3445. require.alias("kewah-mixin/index.js", "recurly/deps/mixin/index.js");
  3446. require.alias("kewah-mixin/index.js", "mixin/index.js");
  3447. require.alias("kewah-mixin/index.js", "kewah-mixin/index.js");
  3448. require.alias("pluma-par/dist/par.js", "recurly/deps/par/dist/par.js");
  3449. require.alias("pluma-par/dist/par.js", "recurly/deps/par/index.js");
  3450. require.alias("pluma-par/dist/par.js", "par/index.js");
  3451. require.alias("pluma-par/dist/par.js", "pluma-par/index.js");
  3452. require.alias("ianstormtaylor-to-slug-case/index.js", "recurly/deps/to-slug-case/index.js");
  3453. require.alias("ianstormtaylor-to-slug-case/index.js", "to-slug-case/index.js");
  3454. require.alias("ianstormtaylor-to-space-case/index.js", "ianstormtaylor-to-slug-case/deps/to-space-case/index.js");
  3455. require.alias("ianstormtaylor-to-no-case/index.js", "ianstormtaylor-to-space-case/deps/to-no-case/index.js");
  3456. require.alias("recurly/lib/index.js", "recurly/index.js");if (typeof exports == "object") {
  3457. module.exports = require("recurly");
  3458. } else if (typeof define == "function" && define.amd) {
  3459. define([], function(){ return require("recurly"); });
  3460. } else {
  3461. this["recurly"] = require("recurly");
  3462. }})();