twenty-sdk 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/dist/catalog-sync-C3eVfUoF.mjs +16 -0
  3. package/dist/catalog-sync-CPVoL1dR.js +1 -0
  4. package/dist/cli/commands/{deploy.d.ts → app/deploy.d.ts} +4 -0
  5. package/dist/cli/commands/app/index.d.ts +2 -0
  6. package/dist/cli/commands/{uninstall.d.ts → app/uninstall.d.ts} +1 -1
  7. package/dist/cli/commands/deprecated.d.ts +2 -0
  8. package/dist/cli/commands/{dev.d.ts → dev/dev.d.ts} +1 -1
  9. package/dist/cli/commands/dev/function/index.d.ts +2 -0
  10. package/dist/cli/commands/dev/index.d.ts +2 -0
  11. package/dist/cli/utilities/api/api-client.d.ts +3 -0
  12. package/dist/cli/utilities/api/api-service.d.ts +1 -0
  13. package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +4 -0
  14. package/dist/cli/utilities/build/manifest/utils/validate-view-filter-operands.d.ts +6 -0
  15. package/dist/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state.d.ts +0 -1
  16. package/dist/cli.cjs +110 -110
  17. package/dist/cli.mjs +3045 -2931
  18. package/dist/define/index.cjs +14 -14
  19. package/dist/define/index.cjs.map +1 -1
  20. package/dist/define/index.d.ts +68 -553
  21. package/dist/define/index.mjs +1623 -1977
  22. package/dist/define/index.mjs.map +1 -1
  23. package/dist/front-component/index.cjs +13 -13
  24. package/dist/front-component/index.cjs.map +1 -1
  25. package/dist/front-component/index.d.ts +10 -2
  26. package/dist/front-component/index.mjs +1420 -1312
  27. package/dist/front-component/index.mjs.map +1 -1
  28. package/dist/{get-function-input-schema-BZ7_XyUh-dQlwid60.mjs → get-function-input-schema-BZ7_XyUh-CTltddyp.mjs} +1 -1
  29. package/dist/get-function-input-schema-BZ7_XyUh-CsGwFW9C.js +1 -0
  30. package/dist/logic-function/index.d.ts +2 -7
  31. package/dist/login-oauth-Bjd38X4F.js +298 -0
  32. package/dist/{uninstall-D3ZmcXyd.mjs → login-oauth-DxrMUIpb.mjs} +4181 -4391
  33. package/dist/operations.cjs +1 -1
  34. package/dist/operations.mjs +8 -8
  35. package/dist/ui/index.cjs +20 -20
  36. package/dist/ui/index.mjs +6277 -6170
  37. package/package.json +2 -2
  38. package/dist/get-function-input-schema-BZ7_XyUh-DmvaQHSU.js +0 -1
  39. package/dist/uninstall-BwJTMGOV.js +0 -287
  40. /package/dist/cli/commands/{install.d.ts → app/install.d.ts} +0 -0
  41. /package/dist/cli/commands/{publish.d.ts → app/publish.d.ts} +0 -0
  42. /package/dist/cli/commands/{add.d.ts → dev/add.d.ts} +0 -0
  43. /package/dist/cli/commands/{build.d.ts → dev/build.d.ts} +0 -0
  44. /package/dist/cli/commands/{catalog-sync.d.ts → dev/catalog-sync.d.ts} +0 -0
  45. /package/dist/cli/commands/{dev-once.d.ts → dev/dev-once.d.ts} +0 -0
  46. /package/dist/cli/commands/{exec.d.ts → dev/exec.d.ts} +0 -0
  47. /package/dist/cli/commands/{logs.d.ts → dev/logs.d.ts} +0 -0
  48. /package/dist/cli/commands/{typecheck.d.ts → dev/typecheck.d.ts} +0 -0
  49. /package/dist/cli/commands/{server.d.ts → docker/index.d.ts} +0 -0
  50. /package/dist/cli/commands/{app-command.d.ts → index.d.ts} +0 -0
  51. /package/dist/cli/commands/{remote.d.ts → remote/index.d.ts} +0 -0
package/dist/cli.cjs CHANGED
@@ -1,50 +1,57 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var qg=Object.create;var Fo=Object.defineProperty;var Hg=Object.getOwnPropertyDescriptor;var zg=Object.getOwnPropertyNames;var Kg=Object.getPrototypeOf,jg=Object.prototype.hasOwnProperty;var Yg=(f,s,r,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of zg(s))!jg.call(f,d)&&d!==r&&Fo(f,d,{get:()=>s[d],enumerable:!(l=Hg(s,d))||l.enumerable});return f};var Jg=(f,s,r)=>(r=f!=null?qg(Kg(f)):{},Yg(s||!f||!f.__esModule?Fo(r,"default",{value:f,enumerable:!0}):r,f));const H=require("path"),Zg=require("chalk"),v=require("./uninstall-BwJTMGOV.js"),Xg=require("inquirer"),tt=require("node:fs/promises"),te=require("uuid"),Qg=require("chokidar"),ev=require("crypto"),bn=require("node:child_process"),tv=require("node:path"),C=require("react/jsx-runtime"),At=require("react"),Bo=require("commander"),nv=require("util"),Dt=f=>f&&f.__esModule?f:{default:f},Yi=Dt(H),y=Dt(Zg),je=Dt(Xg),ko=Dt(Qg),rv=Dt(ev),Po=Dt(tv),Vo=Dt(At),Q=process.env.INIT_CWD||process.cwd(),pt=f=>f&&!f?.startsWith("/")?H.join(Q,f):f;var Cn={exports:{}};var iv=Cn.exports,Lo;function sv(){return Lo||(Lo=1,(function(f,s){(function(){var r,l="4.17.21",d=200,w="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",I="Expected a function",R="Invalid `variable` option passed into `_.template`",$="__lodash_hash_undefined__",q=500,Z="__lodash_placeholder__",K=1,Ye=2,V=4,D=1,Pe=2,xe=1,Je=2,Tn=4,Le=8,bt=16,Ie=32,Ee=64,rt=128,nn=256,Ir=512,jo=30,Yo="...",Jo=800,Zo=16,Zi=1,Xo=2,Qo=3,Ct=1/0,gt=9007199254740991,eu=17976931348623157e292,Rn=NaN,Ze=4294967295,tu=Ze-1,nu=Ze>>>1,ru=[["ary",rt],["bind",xe],["bindKey",Je],["curry",Le],["curryRight",bt],["flip",Ir],["partial",Ie],["partialRight",Ee],["rearg",nn]],Mt="[object Arguments]",Fn="[object Array]",iu="[object AsyncFunction]",rn="[object Boolean]",sn="[object Date]",su="[object DOMException]",Pn="[object Error]",Ln="[object Function]",Xi="[object GeneratorFunction]",Ve="[object Map]",an="[object Number]",au="[object Null]",it="[object Object]",Qi="[object Promise]",ou="[object Proxy]",on="[object RegExp]",Ge="[object Set]",un="[object String]",On="[object Symbol]",uu="[object Undefined]",ln="[object WeakMap]",lu="[object WeakSet]",cn="[object ArrayBuffer]",Wt="[object DataView]",Er="[object Float32Array]",Ar="[object Float64Array]",br="[object Int8Array]",Cr="[object Int16Array]",Tr="[object Int32Array]",Rr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",Pr="[object Uint16Array]",Lr="[object Uint32Array]",cu=/\b__p \+= '';/g,fu=/\b(__p \+=) '' \+/g,du=/(__e\(.*?\)|\b__t\)) \+\n'';/g,es=/&(?:amp|lt|gt|quot|#39);/g,ts=/[&<>"']/g,hu=RegExp(es.source),pu=RegExp(ts.source),gu=/<%-([\s\S]+?)%>/g,vu=/<%([\s\S]+?)%>/g,ns=/<%=([\s\S]+?)%>/g,mu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yu=/^\w*$/,_u=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Or=/[\\^$.*+?()[\]{}|]/g,wu=RegExp(Or.source),Nr=/^\s+/,Su=/\s/,xu=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Iu=/\{\n\/\* \[wrapped with (.+)\] \*/,Eu=/,? & /,Au=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,bu=/[()=,{}\[\]\/\s]/,Cu=/\\(\\)?/g,Tu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rs=/\w*$/,Ru=/^[-+]0x[0-9a-f]+$/i,Fu=/^0b[01]+$/i,Pu=/^\[object .+?Constructor\]$/,Lu=/^0o[0-7]+$/i,Ou=/^(?:0|[1-9]\d*)$/,Nu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Nn=/($^)/,$u=/['\n\r\u2028\u2029\\]/g,$n="\\ud800-\\udfff",Uu="\\u0300-\\u036f",Du="\\ufe20-\\ufe2f",Mu="\\u20d0-\\u20ff",is=Uu+Du+Mu,ss="\\u2700-\\u27bf",as="a-z\\xdf-\\xf6\\xf8-\\xff",Wu="\\xac\\xb1\\xd7\\xf7",Bu="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ku="\\u2000-\\u206f",Vu=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",os="A-Z\\xc0-\\xd6\\xd8-\\xde",us="\\ufe0e\\ufe0f",ls=Wu+Bu+ku+Vu,$r="['’]",Gu="["+$n+"]",cs="["+ls+"]",Un="["+is+"]",fs="\\d+",qu="["+ss+"]",ds="["+as+"]",hs="[^"+$n+ls+fs+ss+as+os+"]",Ur="\\ud83c[\\udffb-\\udfff]",Hu="(?:"+Un+"|"+Ur+")",ps="[^"+$n+"]",Dr="(?:\\ud83c[\\udde6-\\uddff]){2}",Mr="[\\ud800-\\udbff][\\udc00-\\udfff]",Bt="["+os+"]",gs="\\u200d",vs="(?:"+ds+"|"+hs+")",zu="(?:"+Bt+"|"+hs+")",ms="(?:"+$r+"(?:d|ll|m|re|s|t|ve))?",ys="(?:"+$r+"(?:D|LL|M|RE|S|T|VE))?",_s=Hu+"?",ws="["+us+"]?",Ku="(?:"+gs+"(?:"+[ps,Dr,Mr].join("|")+")"+ws+_s+")*",ju="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Yu="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ss=ws+_s+Ku,Ju="(?:"+[qu,Dr,Mr].join("|")+")"+Ss,Zu="(?:"+[ps+Un+"?",Un,Dr,Mr,Gu].join("|")+")",Xu=RegExp($r,"g"),Qu=RegExp(Un,"g"),Wr=RegExp(Ur+"(?="+Ur+")|"+Zu+Ss,"g"),el=RegExp([Bt+"?"+ds+"+"+ms+"(?="+[cs,Bt,"$"].join("|")+")",zu+"+"+ys+"(?="+[cs,Bt+vs,"$"].join("|")+")",Bt+"?"+vs+"+"+ms,Bt+"+"+ys,Yu,ju,fs,Ju].join("|"),"g"),tl=RegExp("["+gs+$n+is+us+"]"),nl=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,rl=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],il=-1,ee={};ee[Er]=ee[Ar]=ee[br]=ee[Cr]=ee[Tr]=ee[Rr]=ee[Fr]=ee[Pr]=ee[Lr]=!0,ee[Mt]=ee[Fn]=ee[cn]=ee[rn]=ee[Wt]=ee[sn]=ee[Pn]=ee[Ln]=ee[Ve]=ee[an]=ee[it]=ee[on]=ee[Ge]=ee[un]=ee[ln]=!1;var X={};X[Mt]=X[Fn]=X[cn]=X[Wt]=X[rn]=X[sn]=X[Er]=X[Ar]=X[br]=X[Cr]=X[Tr]=X[Ve]=X[an]=X[it]=X[on]=X[Ge]=X[un]=X[On]=X[Rr]=X[Fr]=X[Pr]=X[Lr]=!0,X[Pn]=X[Ln]=X[ln]=!1;var sl={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},al={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ol={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},ul={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ll=parseFloat,cl=parseInt,xs=typeof v.commonjsGlobal=="object"&&v.commonjsGlobal&&v.commonjsGlobal.Object===Object&&v.commonjsGlobal,fl=typeof self=="object"&&self&&self.Object===Object&&self,fe=xs||fl||Function("return this")(),Br=s&&!s.nodeType&&s,Tt=Br&&!0&&f&&!f.nodeType&&f,Is=Tt&&Tt.exports===Br,kr=Is&&xs.process,Oe=(function(){try{var p=Tt&&Tt.require&&Tt.require("util").types;return p||kr&&kr.binding&&kr.binding("util")}catch{}})(),Es=Oe&&Oe.isArrayBuffer,As=Oe&&Oe.isDate,bs=Oe&&Oe.isMap,Cs=Oe&&Oe.isRegExp,Ts=Oe&&Oe.isSet,Rs=Oe&&Oe.isTypedArray;function Ae(p,_,m){switch(m.length){case 0:return p.call(_);case 1:return p.call(_,m[0]);case 2:return p.call(_,m[0],m[1]);case 3:return p.call(_,m[0],m[1],m[2])}return p.apply(_,m)}function dl(p,_,m,b){for(var O=-1,z=p==null?0:p.length;++O<z;){var oe=p[O];_(b,oe,m(oe),p)}return b}function Ne(p,_){for(var m=-1,b=p==null?0:p.length;++m<b&&_(p[m],m,p)!==!1;);return p}function hl(p,_){for(var m=p==null?0:p.length;m--&&_(p[m],m,p)!==!1;);return p}function Fs(p,_){for(var m=-1,b=p==null?0:p.length;++m<b;)if(!_(p[m],m,p))return!1;return!0}function vt(p,_){for(var m=-1,b=p==null?0:p.length,O=0,z=[];++m<b;){var oe=p[m];_(oe,m,p)&&(z[O++]=oe)}return z}function Dn(p,_){var m=p==null?0:p.length;return!!m&&kt(p,_,0)>-1}function Vr(p,_,m){for(var b=-1,O=p==null?0:p.length;++b<O;)if(m(_,p[b]))return!0;return!1}function ne(p,_){for(var m=-1,b=p==null?0:p.length,O=Array(b);++m<b;)O[m]=_(p[m],m,p);return O}function mt(p,_){for(var m=-1,b=_.length,O=p.length;++m<b;)p[O+m]=_[m];return p}function Gr(p,_,m,b){var O=-1,z=p==null?0:p.length;for(b&&z&&(m=p[++O]);++O<z;)m=_(m,p[O],O,p);return m}function pl(p,_,m,b){var O=p==null?0:p.length;for(b&&O&&(m=p[--O]);O--;)m=_(m,p[O],O,p);return m}function qr(p,_){for(var m=-1,b=p==null?0:p.length;++m<b;)if(_(p[m],m,p))return!0;return!1}var gl=Hr("length");function vl(p){return p.split("")}function ml(p){return p.match(Au)||[]}function Ps(p,_,m){var b;return m(p,function(O,z,oe){if(_(O,z,oe))return b=z,!1}),b}function Mn(p,_,m,b){for(var O=p.length,z=m+(b?1:-1);b?z--:++z<O;)if(_(p[z],z,p))return z;return-1}function kt(p,_,m){return _===_?Rl(p,_,m):Mn(p,Ls,m)}function yl(p,_,m,b){for(var O=m-1,z=p.length;++O<z;)if(b(p[O],_))return O;return-1}function Ls(p){return p!==p}function Os(p,_){var m=p==null?0:p.length;return m?Kr(p,_)/m:Rn}function Hr(p){return function(_){return _==null?r:_[p]}}function zr(p){return function(_){return p==null?r:p[_]}}function Ns(p,_,m,b,O){return O(p,function(z,oe,J){m=b?(b=!1,z):_(m,z,oe,J)}),m}function _l(p,_){var m=p.length;for(p.sort(_);m--;)p[m]=p[m].value;return p}function Kr(p,_){for(var m,b=-1,O=p.length;++b<O;){var z=_(p[b]);z!==r&&(m=m===r?z:m+z)}return m}function jr(p,_){for(var m=-1,b=Array(p);++m<p;)b[m]=_(m);return b}function wl(p,_){return ne(_,function(m){return[m,p[m]]})}function $s(p){return p&&p.slice(0,Ws(p)+1).replace(Nr,"")}function be(p){return function(_){return p(_)}}function Yr(p,_){return ne(_,function(m){return p[m]})}function fn(p,_){return p.has(_)}function Us(p,_){for(var m=-1,b=p.length;++m<b&&kt(_,p[m],0)>-1;);return m}function Ds(p,_){for(var m=p.length;m--&&kt(_,p[m],0)>-1;);return m}function Sl(p,_){for(var m=p.length,b=0;m--;)p[m]===_&&++b;return b}var xl=zr(sl),Il=zr(al);function El(p){return"\\"+ul[p]}function Al(p,_){return p==null?r:p[_]}function Vt(p){return tl.test(p)}function bl(p){return nl.test(p)}function Cl(p){for(var _,m=[];!(_=p.next()).done;)m.push(_.value);return m}function Jr(p){var _=-1,m=Array(p.size);return p.forEach(function(b,O){m[++_]=[O,b]}),m}function Ms(p,_){return function(m){return p(_(m))}}function yt(p,_){for(var m=-1,b=p.length,O=0,z=[];++m<b;){var oe=p[m];(oe===_||oe===Z)&&(p[m]=Z,z[O++]=m)}return z}function Wn(p){var _=-1,m=Array(p.size);return p.forEach(function(b){m[++_]=b}),m}function Tl(p){var _=-1,m=Array(p.size);return p.forEach(function(b){m[++_]=[b,b]}),m}function Rl(p,_,m){for(var b=m-1,O=p.length;++b<O;)if(p[b]===_)return b;return-1}function Fl(p,_,m){for(var b=m+1;b--;)if(p[b]===_)return b;return b}function Gt(p){return Vt(p)?Ll(p):gl(p)}function qe(p){return Vt(p)?Ol(p):vl(p)}function Ws(p){for(var _=p.length;_--&&Su.test(p.charAt(_)););return _}var Pl=zr(ol);function Ll(p){for(var _=Wr.lastIndex=0;Wr.test(p);)++_;return _}function Ol(p){return p.match(Wr)||[]}function Nl(p){return p.match(el)||[]}var $l=(function p(_){_=_==null?fe:qt.defaults(fe.Object(),_,qt.pick(fe,rl));var m=_.Array,b=_.Date,O=_.Error,z=_.Function,oe=_.Math,J=_.Object,Zr=_.RegExp,Ul=_.String,$e=_.TypeError,Bn=m.prototype,Dl=z.prototype,Ht=J.prototype,kn=_["__core-js_shared__"],Vn=Dl.toString,Y=Ht.hasOwnProperty,Ml=0,Bs=(function(){var e=/[^.]+$/.exec(kn&&kn.keys&&kn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Gn=Ht.toString,Wl=Vn.call(J),Bl=fe._,kl=Zr("^"+Vn.call(Y).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qn=Is?_.Buffer:r,_t=_.Symbol,Hn=_.Uint8Array,ks=qn?qn.allocUnsafe:r,zn=Ms(J.getPrototypeOf,J),Vs=J.create,Gs=Ht.propertyIsEnumerable,Kn=Bn.splice,qs=_t?_t.isConcatSpreadable:r,dn=_t?_t.iterator:r,Rt=_t?_t.toStringTag:r,jn=(function(){try{var e=Nt(J,"defineProperty");return e({},"",{}),e}catch{}})(),Vl=_.clearTimeout!==fe.clearTimeout&&_.clearTimeout,Gl=b&&b.now!==fe.Date.now&&b.now,ql=_.setTimeout!==fe.setTimeout&&_.setTimeout,Yn=oe.ceil,Jn=oe.floor,Xr=J.getOwnPropertySymbols,Hl=qn?qn.isBuffer:r,Hs=_.isFinite,zl=Bn.join,Kl=Ms(J.keys,J),ue=oe.max,he=oe.min,jl=b.now,Yl=_.parseInt,zs=oe.random,Jl=Bn.reverse,Qr=Nt(_,"DataView"),hn=Nt(_,"Map"),ei=Nt(_,"Promise"),zt=Nt(_,"Set"),pn=Nt(_,"WeakMap"),gn=Nt(J,"create"),Zn=pn&&new pn,Kt={},Zl=$t(Qr),Xl=$t(hn),Ql=$t(ei),ec=$t(zt),tc=$t(pn),Xn=_t?_t.prototype:r,vn=Xn?Xn.valueOf:r,Ks=Xn?Xn.toString:r;function o(e){if(ie(e)&&!N(e)&&!(e instanceof k)){if(e instanceof Ue)return e;if(Y.call(e,"__wrapped__"))return ja(e)}return new Ue(e)}var jt=(function(){function e(){}return function(t){if(!re(t))return{};if(Vs)return Vs(t);e.prototype=t;var n=new e;return e.prototype=r,n}})();function Qn(){}function Ue(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}o.templateSettings={escape:gu,evaluate:vu,interpolate:ns,variable:"",imports:{_:o}},o.prototype=Qn.prototype,o.prototype.constructor=o,Ue.prototype=jt(Qn.prototype),Ue.prototype.constructor=Ue;function k(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ze,this.__views__=[]}function nc(){var e=new k(this.__wrapped__);return e.__actions__=ye(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ye(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ye(this.__views__),e}function rc(){if(this.__filtered__){var e=new k(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function ic(){var e=this.__wrapped__.value(),t=this.__dir__,n=N(e),i=t<0,a=n?e.length:0,u=mf(0,a,this.__views__),c=u.start,h=u.end,g=h-c,S=i?h:c-1,x=this.__iteratees__,E=x.length,A=0,T=he(g,this.__takeCount__);if(!n||!i&&a==g&&T==g)return ma(e,this.__actions__);var P=[];e:for(;g--&&A<T;){S+=t;for(var M=-1,L=e[S];++M<E;){var B=x[M],G=B.iteratee,Re=B.type,me=G(L);if(Re==Xo)L=me;else if(!me){if(Re==Zi)continue e;break e}}P[A++]=L}return P}k.prototype=jt(Qn.prototype),k.prototype.constructor=k;function Ft(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function sc(){this.__data__=gn?gn(null):{},this.size=0}function ac(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function oc(e){var t=this.__data__;if(gn){var n=t[e];return n===$?r:n}return Y.call(t,e)?t[e]:r}function uc(e){var t=this.__data__;return gn?t[e]!==r:Y.call(t,e)}function lc(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=gn&&t===r?$:t,this}Ft.prototype.clear=sc,Ft.prototype.delete=ac,Ft.prototype.get=oc,Ft.prototype.has=uc,Ft.prototype.set=lc;function st(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function cc(){this.__data__=[],this.size=0}function fc(e){var t=this.__data__,n=er(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():Kn.call(t,n,1),--this.size,!0}function dc(e){var t=this.__data__,n=er(t,e);return n<0?r:t[n][1]}function hc(e){return er(this.__data__,e)>-1}function pc(e,t){var n=this.__data__,i=er(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}st.prototype.clear=cc,st.prototype.delete=fc,st.prototype.get=dc,st.prototype.has=hc,st.prototype.set=pc;function at(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function gc(){this.size=0,this.__data__={hash:new Ft,map:new(hn||st),string:new Ft}}function vc(e){var t=dr(this,e).delete(e);return this.size-=t?1:0,t}function mc(e){return dr(this,e).get(e)}function yc(e){return dr(this,e).has(e)}function _c(e,t){var n=dr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}at.prototype.clear=gc,at.prototype.delete=vc,at.prototype.get=mc,at.prototype.has=yc,at.prototype.set=_c;function Pt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new at;++t<n;)this.add(e[t])}function wc(e){return this.__data__.set(e,$),this}function Sc(e){return this.__data__.has(e)}Pt.prototype.add=Pt.prototype.push=wc,Pt.prototype.has=Sc;function He(e){var t=this.__data__=new st(e);this.size=t.size}function xc(){this.__data__=new st,this.size=0}function Ic(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Ec(e){return this.__data__.get(e)}function Ac(e){return this.__data__.has(e)}function bc(e,t){var n=this.__data__;if(n instanceof st){var i=n.__data__;if(!hn||i.length<d-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new at(i)}return n.set(e,t),this.size=n.size,this}He.prototype.clear=xc,He.prototype.delete=Ic,He.prototype.get=Ec,He.prototype.has=Ac,He.prototype.set=bc;function js(e,t){var n=N(e),i=!n&&Ut(e),a=!n&&!i&&Et(e),u=!n&&!i&&!a&&Xt(e),c=n||i||a||u,h=c?jr(e.length,Ul):[],g=h.length;for(var S in e)(t||Y.call(e,S))&&!(c&&(S=="length"||a&&(S=="offset"||S=="parent")||u&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||ct(S,g)))&&h.push(S);return h}function Ys(e){var t=e.length;return t?e[fi(0,t-1)]:r}function Cc(e,t){return hr(ye(e),Lt(t,0,e.length))}function Tc(e){return hr(ye(e))}function ti(e,t,n){(n!==r&&!ze(e[t],n)||n===r&&!(t in e))&&ot(e,t,n)}function mn(e,t,n){var i=e[t];(!(Y.call(e,t)&&ze(i,n))||n===r&&!(t in e))&&ot(e,t,n)}function er(e,t){for(var n=e.length;n--;)if(ze(e[n][0],t))return n;return-1}function Rc(e,t,n,i){return wt(e,function(a,u,c){t(i,a,n(a),c)}),i}function Js(e,t){return e&&Qe(t,le(t),e)}function Fc(e,t){return e&&Qe(t,we(t),e)}function ot(e,t,n){t=="__proto__"&&jn?jn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ni(e,t){for(var n=-1,i=t.length,a=m(i),u=e==null;++n<i;)a[n]=u?r:Ui(e,t[n]);return a}function Lt(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function De(e,t,n,i,a,u){var c,h=t&K,g=t&Ye,S=t&V;if(n&&(c=a?n(e,i,a,u):n(e)),c!==r)return c;if(!re(e))return e;var x=N(e);if(x){if(c=_f(e),!h)return ye(e,c)}else{var E=pe(e),A=E==Ln||E==Xi;if(Et(e))return wa(e,h);if(E==it||E==Mt||A&&!a){if(c=g||A?{}:Wa(e),!h)return g?uf(e,Fc(c,e)):of(e,Js(c,e))}else{if(!X[E])return a?e:{};c=wf(e,E,h)}}u||(u=new He);var T=u.get(e);if(T)return T;u.set(e,c),go(e)?e.forEach(function(L){c.add(De(L,t,n,L,e,u))}):ho(e)&&e.forEach(function(L,B){c.set(B,De(L,t,n,B,e,u))});var P=S?g?xi:Si:g?we:le,M=x?r:P(e);return Ne(M||e,function(L,B){M&&(B=L,L=e[B]),mn(c,B,De(L,t,n,B,e,u))}),c}function Pc(e){var t=le(e);return function(n){return Zs(n,e,t)}}function Zs(e,t,n){var i=n.length;if(e==null)return!i;for(e=J(e);i--;){var a=n[i],u=t[a],c=e[a];if(c===r&&!(a in e)||!u(c))return!1}return!0}function Xs(e,t,n){if(typeof e!="function")throw new $e(I);return En(function(){e.apply(r,n)},t)}function yn(e,t,n,i){var a=-1,u=Dn,c=!0,h=e.length,g=[],S=t.length;if(!h)return g;n&&(t=ne(t,be(n))),i?(u=Vr,c=!1):t.length>=d&&(u=fn,c=!1,t=new Pt(t));e:for(;++a<h;){var x=e[a],E=n==null?x:n(x);if(x=i||x!==0?x:0,c&&E===E){for(var A=S;A--;)if(t[A]===E)continue e;g.push(x)}else u(t,E,i)||g.push(x)}return g}var wt=Aa(Xe),Qs=Aa(ii,!0);function Lc(e,t){var n=!0;return wt(e,function(i,a,u){return n=!!t(i,a,u),n}),n}function tr(e,t,n){for(var i=-1,a=e.length;++i<a;){var u=e[i],c=t(u);if(c!=null&&(h===r?c===c&&!Te(c):n(c,h)))var h=c,g=u}return g}function Oc(e,t,n,i){var a=e.length;for(n=U(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:U(i),i<0&&(i+=a),i=n>i?0:mo(i);n<i;)e[n++]=t;return e}function ea(e,t){var n=[];return wt(e,function(i,a,u){t(i,a,u)&&n.push(i)}),n}function de(e,t,n,i,a){var u=-1,c=e.length;for(n||(n=xf),a||(a=[]);++u<c;){var h=e[u];t>0&&n(h)?t>1?de(h,t-1,n,i,a):mt(a,h):i||(a[a.length]=h)}return a}var ri=ba(),ta=ba(!0);function Xe(e,t){return e&&ri(e,t,le)}function ii(e,t){return e&&ta(e,t,le)}function nr(e,t){return vt(t,function(n){return ft(e[n])})}function Ot(e,t){t=xt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[et(t[n++])];return n&&n==i?e:r}function na(e,t,n){var i=t(e);return N(e)?i:mt(i,n(e))}function ge(e){return e==null?e===r?uu:au:Rt&&Rt in J(e)?vf(e):Rf(e)}function si(e,t){return e>t}function Nc(e,t){return e!=null&&Y.call(e,t)}function $c(e,t){return e!=null&&t in J(e)}function Uc(e,t,n){return e>=he(t,n)&&e<ue(t,n)}function ai(e,t,n){for(var i=n?Vr:Dn,a=e[0].length,u=e.length,c=u,h=m(u),g=1/0,S=[];c--;){var x=e[c];c&&t&&(x=ne(x,be(t))),g=he(x.length,g),h[c]=!n&&(t||a>=120&&x.length>=120)?new Pt(c&&x):r}x=e[0];var E=-1,A=h[0];e:for(;++E<a&&S.length<g;){var T=x[E],P=t?t(T):T;if(T=n||T!==0?T:0,!(A?fn(A,P):i(S,P,n))){for(c=u;--c;){var M=h[c];if(!(M?fn(M,P):i(e[c],P,n)))continue e}A&&A.push(P),S.push(T)}}return S}function Dc(e,t,n,i){return Xe(e,function(a,u,c){t(i,n(a),u,c)}),i}function _n(e,t,n){t=xt(t,e),e=Ga(e,t);var i=e==null?e:e[et(We(t))];return i==null?r:Ae(i,e,n)}function ra(e){return ie(e)&&ge(e)==Mt}function Mc(e){return ie(e)&&ge(e)==cn}function Wc(e){return ie(e)&&ge(e)==sn}function wn(e,t,n,i,a){return e===t?!0:e==null||t==null||!ie(e)&&!ie(t)?e!==e&&t!==t:Bc(e,t,n,i,wn,a)}function Bc(e,t,n,i,a,u){var c=N(e),h=N(t),g=c?Fn:pe(e),S=h?Fn:pe(t);g=g==Mt?it:g,S=S==Mt?it:S;var x=g==it,E=S==it,A=g==S;if(A&&Et(e)){if(!Et(t))return!1;c=!0,x=!1}if(A&&!x)return u||(u=new He),c||Xt(e)?Ua(e,t,n,i,a,u):pf(e,t,g,n,i,a,u);if(!(n&D)){var T=x&&Y.call(e,"__wrapped__"),P=E&&Y.call(t,"__wrapped__");if(T||P){var M=T?e.value():e,L=P?t.value():t;return u||(u=new He),a(M,L,n,i,u)}}return A?(u||(u=new He),gf(e,t,n,i,a,u)):!1}function kc(e){return ie(e)&&pe(e)==Ve}function oi(e,t,n,i){var a=n.length,u=a,c=!i;if(e==null)return!u;for(e=J(e);a--;){var h=n[a];if(c&&h[2]?h[1]!==e[h[0]]:!(h[0]in e))return!1}for(;++a<u;){h=n[a];var g=h[0],S=e[g],x=h[1];if(c&&h[2]){if(S===r&&!(g in e))return!1}else{var E=new He;if(i)var A=i(S,x,g,e,t,E);if(!(A===r?wn(x,S,D|Pe,i,E):A))return!1}}return!0}function ia(e){if(!re(e)||Ef(e))return!1;var t=ft(e)?kl:Pu;return t.test($t(e))}function Vc(e){return ie(e)&&ge(e)==on}function Gc(e){return ie(e)&&pe(e)==Ge}function qc(e){return ie(e)&&_r(e.length)&&!!ee[ge(e)]}function sa(e){return typeof e=="function"?e:e==null?Se:typeof e=="object"?N(e)?ua(e[0],e[1]):oa(e):To(e)}function ui(e){if(!In(e))return Kl(e);var t=[];for(var n in J(e))Y.call(e,n)&&n!="constructor"&&t.push(n);return t}function Hc(e){if(!re(e))return Tf(e);var t=In(e),n=[];for(var i in e)i=="constructor"&&(t||!Y.call(e,i))||n.push(i);return n}function li(e,t){return e<t}function aa(e,t){var n=-1,i=_e(e)?m(e.length):[];return wt(e,function(a,u,c){i[++n]=t(a,u,c)}),i}function oa(e){var t=Ei(e);return t.length==1&&t[0][2]?ka(t[0][0],t[0][1]):function(n){return n===e||oi(n,e,t)}}function ua(e,t){return bi(e)&&Ba(t)?ka(et(e),t):function(n){var i=Ui(n,e);return i===r&&i===t?Di(n,e):wn(t,i,D|Pe)}}function rr(e,t,n,i,a){e!==t&&ri(t,function(u,c){if(a||(a=new He),re(u))zc(e,t,c,n,rr,i,a);else{var h=i?i(Ti(e,c),u,c+"",e,t,a):r;h===r&&(h=u),ti(e,c,h)}},we)}function zc(e,t,n,i,a,u,c){var h=Ti(e,n),g=Ti(t,n),S=c.get(g);if(S){ti(e,n,S);return}var x=u?u(h,g,n+"",e,t,c):r,E=x===r;if(E){var A=N(g),T=!A&&Et(g),P=!A&&!T&&Xt(g);x=g,A||T||P?N(h)?x=h:se(h)?x=ye(h):T?(E=!1,x=wa(g,!0)):P?(E=!1,x=Sa(g,!0)):x=[]:An(g)||Ut(g)?(x=h,Ut(h)?x=yo(h):(!re(h)||ft(h))&&(x=Wa(g))):E=!1}E&&(c.set(g,x),a(x,g,i,u,c),c.delete(g)),ti(e,n,x)}function la(e,t){var n=e.length;if(n)return t+=t<0?n:0,ct(t,n)?e[t]:r}function ca(e,t,n){t.length?t=ne(t,function(u){return N(u)?function(c){return Ot(c,u.length===1?u[0]:u)}:u}):t=[Se];var i=-1;t=ne(t,be(F()));var a=aa(e,function(u,c,h){var g=ne(t,function(S){return S(u)});return{criteria:g,index:++i,value:u}});return _l(a,function(u,c){return af(u,c,n)})}function Kc(e,t){return fa(e,t,function(n,i){return Di(e,i)})}function fa(e,t,n){for(var i=-1,a=t.length,u={};++i<a;){var c=t[i],h=Ot(e,c);n(h,c)&&Sn(u,xt(c,e),h)}return u}function jc(e){return function(t){return Ot(t,e)}}function ci(e,t,n,i){var a=i?yl:kt,u=-1,c=t.length,h=e;for(e===t&&(t=ye(t)),n&&(h=ne(e,be(n)));++u<c;)for(var g=0,S=t[u],x=n?n(S):S;(g=a(h,x,g,i))>-1;)h!==e&&Kn.call(h,g,1),Kn.call(e,g,1);return e}function da(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==u){var u=a;ct(a)?Kn.call(e,a,1):pi(e,a)}}return e}function fi(e,t){return e+Jn(zs()*(t-e+1))}function Yc(e,t,n,i){for(var a=-1,u=ue(Yn((t-e)/(n||1)),0),c=m(u);u--;)c[i?u:++a]=e,e+=n;return c}function di(e,t){var n="";if(!e||t<1||t>gt)return n;do t%2&&(n+=e),t=Jn(t/2),t&&(e+=e);while(t);return n}function W(e,t){return Ri(Va(e,t,Se),e+"")}function Jc(e){return Ys(Qt(e))}function Zc(e,t){var n=Qt(e);return hr(n,Lt(t,0,n.length))}function Sn(e,t,n,i){if(!re(e))return e;t=xt(t,e);for(var a=-1,u=t.length,c=u-1,h=e;h!=null&&++a<u;){var g=et(t[a]),S=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=c){var x=h[g];S=i?i(x,g,h):r,S===r&&(S=re(x)?x:ct(t[a+1])?[]:{})}mn(h,g,S),h=h[g]}return e}var ha=Zn?function(e,t){return Zn.set(e,t),e}:Se,Xc=jn?function(e,t){return jn(e,"toString",{configurable:!0,enumerable:!1,value:Wi(t),writable:!0})}:Se;function Qc(e){return hr(Qt(e))}function Me(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var u=m(a);++i<a;)u[i]=e[i+t];return u}function ef(e,t){var n;return wt(e,function(i,a,u){return n=t(i,a,u),!n}),!!n}function ir(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=nu){for(;i<a;){var u=i+a>>>1,c=e[u];c!==null&&!Te(c)&&(n?c<=t:c<t)?i=u+1:a=u}return a}return hi(e,t,Se,n)}function hi(e,t,n,i){var a=0,u=e==null?0:e.length;if(u===0)return 0;t=n(t);for(var c=t!==t,h=t===null,g=Te(t),S=t===r;a<u;){var x=Jn((a+u)/2),E=n(e[x]),A=E!==r,T=E===null,P=E===E,M=Te(E);if(c)var L=i||P;else S?L=P&&(i||A):h?L=P&&A&&(i||!T):g?L=P&&A&&!T&&(i||!M):T||M?L=!1:L=i?E<=t:E<t;L?a=x+1:u=x}return he(u,tu)}function pa(e,t){for(var n=-1,i=e.length,a=0,u=[];++n<i;){var c=e[n],h=t?t(c):c;if(!n||!ze(h,g)){var g=h;u[a++]=c===0?0:c}}return u}function ga(e){return typeof e=="number"?e:Te(e)?Rn:+e}function Ce(e){if(typeof e=="string")return e;if(N(e))return ne(e,Ce)+"";if(Te(e))return Ks?Ks.call(e):"";var t=e+"";return t=="0"&&1/e==-Ct?"-0":t}function St(e,t,n){var i=-1,a=Dn,u=e.length,c=!0,h=[],g=h;if(n)c=!1,a=Vr;else if(u>=d){var S=t?null:df(e);if(S)return Wn(S);c=!1,a=fn,g=new Pt}else g=t?[]:h;e:for(;++i<u;){var x=e[i],E=t?t(x):x;if(x=n||x!==0?x:0,c&&E===E){for(var A=g.length;A--;)if(g[A]===E)continue e;t&&g.push(E),h.push(x)}else a(g,E,n)||(g!==h&&g.push(E),h.push(x))}return h}function pi(e,t){return t=xt(t,e),e=Ga(e,t),e==null||delete e[et(We(t))]}function va(e,t,n,i){return Sn(e,t,n(Ot(e,t)),i)}function sr(e,t,n,i){for(var a=e.length,u=i?a:-1;(i?u--:++u<a)&&t(e[u],u,e););return n?Me(e,i?0:u,i?u+1:a):Me(e,i?u+1:0,i?a:u)}function ma(e,t){var n=e;return n instanceof k&&(n=n.value()),Gr(t,function(i,a){return a.func.apply(a.thisArg,mt([i],a.args))},n)}function gi(e,t,n){var i=e.length;if(i<2)return i?St(e[0]):[];for(var a=-1,u=m(i);++a<i;)for(var c=e[a],h=-1;++h<i;)h!=a&&(u[a]=yn(u[a]||c,e[h],t,n));return St(de(u,1),t,n)}function ya(e,t,n){for(var i=-1,a=e.length,u=t.length,c={};++i<a;){var h=i<u?t[i]:r;n(c,e[i],h)}return c}function vi(e){return se(e)?e:[]}function mi(e){return typeof e=="function"?e:Se}function xt(e,t){return N(e)?e:bi(e,t)?[e]:Ka(j(e))}var tf=W;function It(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:Me(e,t,n)}var _a=Vl||function(e){return fe.clearTimeout(e)};function wa(e,t){if(t)return e.slice();var n=e.length,i=ks?ks(n):new e.constructor(n);return e.copy(i),i}function yi(e){var t=new e.constructor(e.byteLength);return new Hn(t).set(new Hn(e)),t}function nf(e,t){var n=t?yi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function rf(e){var t=new e.constructor(e.source,rs.exec(e));return t.lastIndex=e.lastIndex,t}function sf(e){return vn?J(vn.call(e)):{}}function Sa(e,t){var n=t?yi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function xa(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,u=Te(e),c=t!==r,h=t===null,g=t===t,S=Te(t);if(!h&&!S&&!u&&e>t||u&&c&&g&&!h&&!S||i&&c&&g||!n&&g||!a)return 1;if(!i&&!u&&!S&&e<t||S&&n&&a&&!i&&!u||h&&n&&a||!c&&a||!g)return-1}return 0}function af(e,t,n){for(var i=-1,a=e.criteria,u=t.criteria,c=a.length,h=n.length;++i<c;){var g=xa(a[i],u[i]);if(g){if(i>=h)return g;var S=n[i];return g*(S=="desc"?-1:1)}}return e.index-t.index}function Ia(e,t,n,i){for(var a=-1,u=e.length,c=n.length,h=-1,g=t.length,S=ue(u-c,0),x=m(g+S),E=!i;++h<g;)x[h]=t[h];for(;++a<c;)(E||a<u)&&(x[n[a]]=e[a]);for(;S--;)x[h++]=e[a++];return x}function Ea(e,t,n,i){for(var a=-1,u=e.length,c=-1,h=n.length,g=-1,S=t.length,x=ue(u-h,0),E=m(x+S),A=!i;++a<x;)E[a]=e[a];for(var T=a;++g<S;)E[T+g]=t[g];for(;++c<h;)(A||a<u)&&(E[T+n[c]]=e[a++]);return E}function ye(e,t){var n=-1,i=e.length;for(t||(t=m(i));++n<i;)t[n]=e[n];return t}function Qe(e,t,n,i){var a=!n;n||(n={});for(var u=-1,c=t.length;++u<c;){var h=t[u],g=i?i(n[h],e[h],h,n,e):r;g===r&&(g=e[h]),a?ot(n,h,g):mn(n,h,g)}return n}function of(e,t){return Qe(e,Ai(e),t)}function uf(e,t){return Qe(e,Da(e),t)}function ar(e,t){return function(n,i){var a=N(n)?dl:Rc,u=t?t():{};return a(n,e,F(i,2),u)}}function Yt(e){return W(function(t,n){var i=-1,a=n.length,u=a>1?n[a-1]:r,c=a>2?n[2]:r;for(u=e.length>3&&typeof u=="function"?(a--,u):r,c&&ve(n[0],n[1],c)&&(u=a<3?r:u,a=1),t=J(t);++i<a;){var h=n[i];h&&e(t,h,i,u)}return t})}function Aa(e,t){return function(n,i){if(n==null)return n;if(!_e(n))return e(n,i);for(var a=n.length,u=t?a:-1,c=J(n);(t?u--:++u<a)&&i(c[u],u,c)!==!1;);return n}}function ba(e){return function(t,n,i){for(var a=-1,u=J(t),c=i(t),h=c.length;h--;){var g=c[e?h:++a];if(n(u[g],g,u)===!1)break}return t}}function lf(e,t,n){var i=t&xe,a=xn(e);function u(){var c=this&&this!==fe&&this instanceof u?a:e;return c.apply(i?n:this,arguments)}return u}function Ca(e){return function(t){t=j(t);var n=Vt(t)?qe(t):r,i=n?n[0]:t.charAt(0),a=n?It(n,1).join(""):t.slice(1);return i[e]()+a}}function Jt(e){return function(t){return Gr(bo(Ao(t).replace(Xu,"")),e,"")}}function xn(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=jt(e.prototype),i=e.apply(n,t);return re(i)?i:n}}function cf(e,t,n){var i=xn(e);function a(){for(var u=arguments.length,c=m(u),h=u,g=Zt(a);h--;)c[h]=arguments[h];var S=u<3&&c[0]!==g&&c[u-1]!==g?[]:yt(c,g);if(u-=S.length,u<n)return La(e,t,or,a.placeholder,r,c,S,r,r,n-u);var x=this&&this!==fe&&this instanceof a?i:e;return Ae(x,this,c)}return a}function Ta(e){return function(t,n,i){var a=J(t);if(!_e(t)){var u=F(n,3);t=le(t),n=function(h){return u(a[h],h,a)}}var c=e(t,n,i);return c>-1?a[u?t[c]:c]:r}}function Ra(e){return lt(function(t){var n=t.length,i=n,a=Ue.prototype.thru;for(e&&t.reverse();i--;){var u=t[i];if(typeof u!="function")throw new $e(I);if(a&&!c&&fr(u)=="wrapper")var c=new Ue([],!0)}for(i=c?i:n;++i<n;){u=t[i];var h=fr(u),g=h=="wrapper"?Ii(u):r;g&&Ci(g[0])&&g[1]==(rt|Le|Ie|nn)&&!g[4].length&&g[9]==1?c=c[fr(g[0])].apply(c,g[3]):c=u.length==1&&Ci(u)?c[h]():c.thru(u)}return function(){var S=arguments,x=S[0];if(c&&S.length==1&&N(x))return c.plant(x).value();for(var E=0,A=n?t[E].apply(this,S):x;++E<n;)A=t[E].call(this,A);return A}})}function or(e,t,n,i,a,u,c,h,g,S){var x=t&rt,E=t&xe,A=t&Je,T=t&(Le|bt),P=t&Ir,M=A?r:xn(e);function L(){for(var B=arguments.length,G=m(B),Re=B;Re--;)G[Re]=arguments[Re];if(T)var me=Zt(L),Fe=Sl(G,me);if(i&&(G=Ia(G,i,a,T)),u&&(G=Ea(G,u,c,T)),B-=Fe,T&&B<S){var ae=yt(G,me);return La(e,t,or,L.placeholder,n,G,ae,h,g,S-B)}var Ke=E?n:this,ht=A?Ke[e]:e;return B=G.length,h?G=Ff(G,h):P&&B>1&&G.reverse(),x&&g<B&&(G.length=g),this&&this!==fe&&this instanceof L&&(ht=M||xn(ht)),ht.apply(Ke,G)}return L}function Fa(e,t){return function(n,i){return Dc(n,e,t(i),{})}}function ur(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Ce(n),i=Ce(i)):(n=ga(n),i=ga(i)),a=e(n,i)}return a}}function _i(e){return lt(function(t){return t=ne(t,be(F())),W(function(n){var i=this;return e(t,function(a){return Ae(a,i,n)})})})}function lr(e,t){t=t===r?" ":Ce(t);var n=t.length;if(n<2)return n?di(t,e):t;var i=di(t,Yn(e/Gt(t)));return Vt(t)?It(qe(i),0,e).join(""):i.slice(0,e)}function ff(e,t,n,i){var a=t&xe,u=xn(e);function c(){for(var h=-1,g=arguments.length,S=-1,x=i.length,E=m(x+g),A=this&&this!==fe&&this instanceof c?u:e;++S<x;)E[S]=i[S];for(;g--;)E[S++]=arguments[++h];return Ae(A,a?n:this,E)}return c}function Pa(e){return function(t,n,i){return i&&typeof i!="number"&&ve(t,n,i)&&(n=i=r),t=dt(t),n===r?(n=t,t=0):n=dt(n),i=i===r?t<n?1:-1:dt(i),Yc(t,n,i,e)}}function cr(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=Be(t),n=Be(n)),e(t,n)}}function La(e,t,n,i,a,u,c,h,g,S){var x=t&Le,E=x?c:r,A=x?r:c,T=x?u:r,P=x?r:u;t|=x?Ie:Ee,t&=~(x?Ee:Ie),t&Tn||(t&=-4);var M=[e,t,a,T,E,P,A,h,g,S],L=n.apply(r,M);return Ci(e)&&qa(L,M),L.placeholder=i,Ha(L,e,t)}function wi(e){var t=oe[e];return function(n,i){if(n=Be(n),i=i==null?0:he(U(i),292),i&&Hs(n)){var a=(j(n)+"e").split("e"),u=t(a[0]+"e"+(+a[1]+i));return a=(j(u)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var df=zt&&1/Wn(new zt([,-0]))[1]==Ct?function(e){return new zt(e)}:Vi;function Oa(e){return function(t){var n=pe(t);return n==Ve?Jr(t):n==Ge?Tl(t):wl(t,e(t))}}function ut(e,t,n,i,a,u,c,h){var g=t&Je;if(!g&&typeof e!="function")throw new $e(I);var S=i?i.length:0;if(S||(t&=-97,i=a=r),c=c===r?c:ue(U(c),0),h=h===r?h:U(h),S-=a?a.length:0,t&Ee){var x=i,E=a;i=a=r}var A=g?r:Ii(e),T=[e,t,n,i,a,x,E,u,c,h];if(A&&Cf(T,A),e=T[0],t=T[1],n=T[2],i=T[3],a=T[4],h=T[9]=T[9]===r?g?0:e.length:ue(T[9]-S,0),!h&&t&(Le|bt)&&(t&=-25),!t||t==xe)var P=lf(e,t,n);else t==Le||t==bt?P=cf(e,t,h):(t==Ie||t==(xe|Ie))&&!a.length?P=ff(e,t,n,i):P=or.apply(r,T);var M=A?ha:qa;return Ha(M(P,T),e,t)}function Na(e,t,n,i){return e===r||ze(e,Ht[n])&&!Y.call(i,n)?t:e}function $a(e,t,n,i,a,u){return re(e)&&re(t)&&(u.set(t,e),rr(e,t,r,$a,u),u.delete(t)),e}function hf(e){return An(e)?r:e}function Ua(e,t,n,i,a,u){var c=n&D,h=e.length,g=t.length;if(h!=g&&!(c&&g>h))return!1;var S=u.get(e),x=u.get(t);if(S&&x)return S==t&&x==e;var E=-1,A=!0,T=n&Pe?new Pt:r;for(u.set(e,t),u.set(t,e);++E<h;){var P=e[E],M=t[E];if(i)var L=c?i(M,P,E,t,e,u):i(P,M,E,e,t,u);if(L!==r){if(L)continue;A=!1;break}if(T){if(!qr(t,function(B,G){if(!fn(T,G)&&(P===B||a(P,B,n,i,u)))return T.push(G)})){A=!1;break}}else if(!(P===M||a(P,M,n,i,u))){A=!1;break}}return u.delete(e),u.delete(t),A}function pf(e,t,n,i,a,u,c){switch(n){case Wt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case cn:return!(e.byteLength!=t.byteLength||!u(new Hn(e),new Hn(t)));case rn:case sn:case an:return ze(+e,+t);case Pn:return e.name==t.name&&e.message==t.message;case on:case un:return e==t+"";case Ve:var h=Jr;case Ge:var g=i&D;if(h||(h=Wn),e.size!=t.size&&!g)return!1;var S=c.get(e);if(S)return S==t;i|=Pe,c.set(e,t);var x=Ua(h(e),h(t),i,a,u,c);return c.delete(e),x;case On:if(vn)return vn.call(e)==vn.call(t)}return!1}function gf(e,t,n,i,a,u){var c=n&D,h=Si(e),g=h.length,S=Si(t),x=S.length;if(g!=x&&!c)return!1;for(var E=g;E--;){var A=h[E];if(!(c?A in t:Y.call(t,A)))return!1}var T=u.get(e),P=u.get(t);if(T&&P)return T==t&&P==e;var M=!0;u.set(e,t),u.set(t,e);for(var L=c;++E<g;){A=h[E];var B=e[A],G=t[A];if(i)var Re=c?i(G,B,A,t,e,u):i(B,G,A,e,t,u);if(!(Re===r?B===G||a(B,G,n,i,u):Re)){M=!1;break}L||(L=A=="constructor")}if(M&&!L){var me=e.constructor,Fe=t.constructor;me!=Fe&&"constructor"in e&&"constructor"in t&&!(typeof me=="function"&&me instanceof me&&typeof Fe=="function"&&Fe instanceof Fe)&&(M=!1)}return u.delete(e),u.delete(t),M}function lt(e){return Ri(Va(e,r,Za),e+"")}function Si(e){return na(e,le,Ai)}function xi(e){return na(e,we,Da)}var Ii=Zn?function(e){return Zn.get(e)}:Vi;function fr(e){for(var t=e.name+"",n=Kt[t],i=Y.call(Kt,t)?n.length:0;i--;){var a=n[i],u=a.func;if(u==null||u==e)return a.name}return t}function Zt(e){var t=Y.call(o,"placeholder")?o:e;return t.placeholder}function F(){var e=o.iteratee||Bi;return e=e===Bi?sa:e,arguments.length?e(arguments[0],arguments[1]):e}function dr(e,t){var n=e.__data__;return If(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ei(e){for(var t=le(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,Ba(a)]}return t}function Nt(e,t){var n=Al(e,t);return ia(n)?n:r}function vf(e){var t=Y.call(e,Rt),n=e[Rt];try{e[Rt]=r;var i=!0}catch{}var a=Gn.call(e);return i&&(t?e[Rt]=n:delete e[Rt]),a}var Ai=Xr?function(e){return e==null?[]:(e=J(e),vt(Xr(e),function(t){return Gs.call(e,t)}))}:Gi,Da=Xr?function(e){for(var t=[];e;)mt(t,Ai(e)),e=zn(e);return t}:Gi,pe=ge;(Qr&&pe(new Qr(new ArrayBuffer(1)))!=Wt||hn&&pe(new hn)!=Ve||ei&&pe(ei.resolve())!=Qi||zt&&pe(new zt)!=Ge||pn&&pe(new pn)!=ln)&&(pe=function(e){var t=ge(e),n=t==it?e.constructor:r,i=n?$t(n):"";if(i)switch(i){case Zl:return Wt;case Xl:return Ve;case Ql:return Qi;case ec:return Ge;case tc:return ln}return t});function mf(e,t,n){for(var i=-1,a=n.length;++i<a;){var u=n[i],c=u.size;switch(u.type){case"drop":e+=c;break;case"dropRight":t-=c;break;case"take":t=he(t,e+c);break;case"takeRight":e=ue(e,t-c);break}}return{start:e,end:t}}function yf(e){var t=e.match(Iu);return t?t[1].split(Eu):[]}function Ma(e,t,n){t=xt(t,e);for(var i=-1,a=t.length,u=!1;++i<a;){var c=et(t[i]);if(!(u=e!=null&&n(e,c)))break;e=e[c]}return u||++i!=a?u:(a=e==null?0:e.length,!!a&&_r(a)&&ct(c,a)&&(N(e)||Ut(e)))}function _f(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Y.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Wa(e){return typeof e.constructor=="function"&&!In(e)?jt(zn(e)):{}}function wf(e,t,n){var i=e.constructor;switch(t){case cn:return yi(e);case rn:case sn:return new i(+e);case Wt:return nf(e,n);case Er:case Ar:case br:case Cr:case Tr:case Rr:case Fr:case Pr:case Lr:return Sa(e,n);case Ve:return new i;case an:case un:return new i(e);case on:return rf(e);case Ge:return new i;case On:return sf(e)}}function Sf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(xu,`{
2
+ "use strict";var lm=Object.create;var Fo=Object.defineProperty;var cm=Object.getOwnPropertyDescriptor;var fm=Object.getOwnPropertyNames;var dm=Object.getPrototypeOf,pm=Object.prototype.hasOwnProperty;var hm=(l,s,r,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of fm(s))!pm.call(l,d)&&d!==r&&Fo(l,d,{get:()=>s[d],enumerable:!(c=cm(s,d))||c.enumerable});return l};var gm=(l,s,r)=>(r=l!=null?lm(dm(l)):{},hm(s||!l||!l.__esModule?Fo(r,"default",{value:l,enumerable:!0}):r,l));const q=require("path"),m=require("./login-oauth-Bjd38X4F.js"),tt=require("node:fs/promises"),mm=require("chalk"),vm=require("inquirer"),Q=require("uuid"),ym=require("chokidar"),_m=require("crypto"),Tn=require("node:child_process"),wm=require("node:path"),T=require("react/jsx-runtime"),At=require("react"),Xo=require("commander"),Sm=require("util"),Mt=l=>l&&l.__esModule?l:{default:l},Ji=Mt(q),y=Mt(mm),je=Mt(vm),Qo=Mt(ym),xm=Mt(_m),Lo=Mt(wm),eu=Mt(At),Z=process.env.INIT_CWD||process.cwd(),pe=l=>l&&!l?.startsWith("/")?q.join(Z,l):l,Im=async l=>{const s=q.join(l,"package.json");if(await m.pathExists(s))try{const r=await tt.readFile(s,"utf-8"),c=JSON.parse(r);return c.dependencies?.["twenty-sdk"]??c.devDependencies?.["twenty-sdk"]??void 0}catch{return}},No=l=>{const s=l.match(/(\d+)\./);if(s)return parseInt(s[1],10);const r=l.match(/^[~^>=<]*(\d+)$/);return r?parseInt(r[1],10):null},tn=async l=>{const s=m.packageJson.version,r=await Im(l);if(!r)return;const c=No(s),d=No(r);c===null||d===null||c!==d&&(console.warn(y.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${d}.x but the CLI running is v${s}. Major version mismatches may cause unexpected behavior.
3
+ Update with: npm install -g twenty-sdk@${d}`)),console.warn(""))};class tu{async execute(s){s.private?await this.executePrivate(s):await this.executeNpm(s)}async executeNpm(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Publishing to npm...")),console.log(y.default.gray(`App path: ${r}
4
+ `));const c=await m.appPublish({appPath:r,npmTag:s.tag,onProgress:d=>console.log(y.default.gray(d))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green("✓ Published to npm successfully"))}async executePrivate(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Deploying application...")),console.log(y.default.gray(`App path: ${r}
5
+ `));const c=D=>console.log(y.default.gray(D)),d=await m.appBuild({appPath:r,tarball:!0,onProgress:c});d.success||(console.error(y.default.red(d.error.message)),process.exit(1));const x=await m.appDeploy({tarballPath:d.data.tarballPath,remote:s.remote,onProgress:c});x.success||(console.error(y.default.red(x.error.message)),process.exit(1));const E=await m.readJson(Ji.default.join(r,"package.json")).catch(()=>{}),C=E?.name??x.data.name,R=E?.version??"unknown",U=m.ConfigService.getActiveRemote();console.log(y.default.green(`
6
+ ✓ Published ${C} v${R} to ${U}
7
+ `)),console.log(" To install deployed application: `yarn twenty app:install`")}}class nu{async execute(s){const r=s.appPath??Z;await tn(r),await m.checkServerVersionCompatibility(),console.log(y.default.blue("Installing application...")),console.log(y.default.gray(`App path: ${r}
8
+ `));const c=await m.appInstall({appPath:r,remote:s.remote});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green("✓ Application installed"))}}class ru{async execute({appPath:s=Z,askForConfirmation:r}){console.log(y.default.blue("🚀 Uninstall Twenty Application")),console.log(y.default.gray(`📁 App Path: ${s}
9
+ `)),r&&!await this.confirmationPrompt()&&(console.error(y.default.red("⛔️ Aborting uninstall")),process.exit(1));const c=await m.appUninstall({appPath:s});return c.success?(console.log(y.default.green("✅ Application uninstalled successfully")),{success:!0,data:void 0}):(console.error(y.default.red("❌ Uninstall failed:"),c.error.message),{success:!1,error:c.error.message})}async confirmationPrompt(){const{confirmation:s}=await je.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}const Em=l=>{const s=new tu,r=new nu,c=new ru;l.command("app:publish [appPath]").description("Build and publish to npm (default) or server registry").option("--private","Push to a Twenty server's registry instead of npm").option("-r, --remote <name>","Publish to a specific remote (with --private)").option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async(d,x)=>{await s.execute({appPath:pe(d),private:x.private,remote:x.remote,tag:x.tag})}),l.command("app:install [appPath]").description("Install a deployed app on the server").option("-r, --remote <name>","Install on a specific remote").action(async(d,x)=>{await r.execute({appPath:pe(d),remote:x.remote})}),l.command("app:uninstall [appPath]").description("Uninstall app from server").option("-y, --yes","Skip confirmation prompt").action(async(d,x)=>{try{const E=await c.execute({appPath:pe(d),askForConfirmation:!x?.yes});process.exit(E.success?0:1)}catch{process.exit(1)}})};var Cn={exports:{}};var Am=Cn.exports,Oo;function bm(){return Oo||(Oo=1,(function(l,s){(function(){var r,c="4.17.21",d=200,x="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",E="Expected a function",C="Invalid `variable` option passed into `_.template`",R="__lodash_hash_undefined__",U=500,D="__lodash_placeholder__",H=1,ht=2,Se=4,ke=1,bt=2,xe=1,Ye=2,Pn=4,Fe=8,Ct=16,Ie=32,Ee=64,rt=128,rn=256,Er=512,pu=30,hu="...",gu=800,mu=16,Xi=1,vu=2,yu=3,Tt=1/0,gt=9007199254740991,_u=17976931348623157e292,Rn=NaN,Je=4294967295,wu=Je-1,Su=Je>>>1,xu=[["ary",rt],["bind",xe],["bindKey",Ye],["curry",Fe],["curryRight",Ct],["flip",Er],["partial",Ie],["partialRight",Ee],["rearg",rn]],Wt="[object Arguments]",Fn="[object Array]",Iu="[object AsyncFunction]",sn="[object Boolean]",an="[object Date]",Eu="[object DOMException]",Ln="[object Error]",Nn="[object Function]",Qi="[object GeneratorFunction]",Ve="[object Map]",on="[object Number]",Au="[object Null]",it="[object Object]",es="[object Promise]",bu="[object Proxy]",un="[object RegExp]",Ge="[object Set]",ln="[object String]",On="[object Symbol]",Cu="[object Undefined]",cn="[object WeakMap]",Tu="[object WeakSet]",fn="[object ArrayBuffer]",Bt="[object DataView]",Ar="[object Float32Array]",br="[object Float64Array]",Cr="[object Int8Array]",Tr="[object Int16Array]",Pr="[object Int32Array]",Rr="[object Uint8Array]",Fr="[object Uint8ClampedArray]",Lr="[object Uint16Array]",Nr="[object Uint32Array]",Pu=/\b__p \+= '';/g,Ru=/\b(__p \+=) '' \+/g,Fu=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ts=/&(?:amp|lt|gt|quot|#39);/g,ns=/[&<>"']/g,Lu=RegExp(ts.source),Nu=RegExp(ns.source),Ou=/<%-([\s\S]+?)%>/g,Uu=/<%([\s\S]+?)%>/g,rs=/<%=([\s\S]+?)%>/g,$u=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Du=/^\w*$/,Mu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Or=/[\\^$.*+?()[\]{}|]/g,Wu=RegExp(Or.source),Ur=/^\s+/,Bu=/\s/,ku=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vu=/\{\n\/\* \[wrapped with (.+)\] \*/,Gu=/,? & /,qu=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Hu=/[()=,{}\[\]\/\s]/,zu=/\\(\\)?/g,Ku=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,is=/\w*$/,ju=/^[-+]0x[0-9a-f]+$/i,Yu=/^0b[01]+$/i,Ju=/^\[object .+?Constructor\]$/,Zu=/^0o[0-7]+$/i,Xu=/^(?:0|[1-9]\d*)$/,Qu=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Un=/($^)/,el=/['\n\r\u2028\u2029\\]/g,$n="\\ud800-\\udfff",tl="\\u0300-\\u036f",nl="\\ufe20-\\ufe2f",rl="\\u20d0-\\u20ff",ss=tl+nl+rl,as="\\u2700-\\u27bf",os="a-z\\xdf-\\xf6\\xf8-\\xff",il="\\xac\\xb1\\xd7\\xf7",sl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",al="\\u2000-\\u206f",ol=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",us="A-Z\\xc0-\\xd6\\xd8-\\xde",ls="\\ufe0e\\ufe0f",cs=il+sl+al+ol,$r="['’]",ul="["+$n+"]",fs="["+cs+"]",Dn="["+ss+"]",ds="\\d+",ll="["+as+"]",ps="["+os+"]",hs="[^"+$n+cs+ds+as+os+us+"]",Dr="\\ud83c[\\udffb-\\udfff]",cl="(?:"+Dn+"|"+Dr+")",gs="[^"+$n+"]",Mr="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+us+"]",ms="\\u200d",vs="(?:"+ps+"|"+hs+")",fl="(?:"+kt+"|"+hs+")",ys="(?:"+$r+"(?:d|ll|m|re|s|t|ve))?",_s="(?:"+$r+"(?:D|LL|M|RE|S|T|VE))?",ws=cl+"?",Ss="["+ls+"]?",dl="(?:"+ms+"(?:"+[gs,Mr,Wr].join("|")+")"+Ss+ws+")*",pl="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",hl="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xs=Ss+ws+dl,gl="(?:"+[ll,Mr,Wr].join("|")+")"+xs,ml="(?:"+[gs+Dn+"?",Dn,Mr,Wr,ul].join("|")+")",vl=RegExp($r,"g"),yl=RegExp(Dn,"g"),Br=RegExp(Dr+"(?="+Dr+")|"+ml+xs,"g"),_l=RegExp([kt+"?"+ps+"+"+ys+"(?="+[fs,kt,"$"].join("|")+")",fl+"+"+_s+"(?="+[fs,kt+vs,"$"].join("|")+")",kt+"?"+vs+"+"+ys,kt+"+"+_s,hl,pl,ds,gl].join("|"),"g"),wl=RegExp("["+ms+$n+ss+ls+"]"),Sl=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,xl=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Il=-1,X={};X[Ar]=X[br]=X[Cr]=X[Tr]=X[Pr]=X[Rr]=X[Fr]=X[Lr]=X[Nr]=!0,X[Wt]=X[Fn]=X[fn]=X[sn]=X[Bt]=X[an]=X[Ln]=X[Nn]=X[Ve]=X[on]=X[it]=X[un]=X[Ge]=X[ln]=X[cn]=!1;var J={};J[Wt]=J[Fn]=J[fn]=J[Bt]=J[sn]=J[an]=J[Ar]=J[br]=J[Cr]=J[Tr]=J[Pr]=J[Ve]=J[on]=J[it]=J[un]=J[Ge]=J[ln]=J[On]=J[Rr]=J[Fr]=J[Lr]=J[Nr]=!0,J[Ln]=J[Nn]=J[cn]=!1;var El={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Al={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},bl={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Cl={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tl=parseFloat,Pl=parseInt,Is=typeof m.commonjsGlobal=="object"&&m.commonjsGlobal&&m.commonjsGlobal.Object===Object&&m.commonjsGlobal,Rl=typeof self=="object"&&self&&self.Object===Object&&self,le=Is||Rl||Function("return this")(),kr=s&&!s.nodeType&&s,Pt=kr&&!0&&l&&!l.nodeType&&l,Es=Pt&&Pt.exports===kr,Vr=Es&&Is.process,Le=(function(){try{var h=Pt&&Pt.require&&Pt.require("util").types;return h||Vr&&Vr.binding&&Vr.binding("util")}catch{}})(),As=Le&&Le.isArrayBuffer,bs=Le&&Le.isDate,Cs=Le&&Le.isMap,Ts=Le&&Le.isRegExp,Ps=Le&&Le.isSet,Rs=Le&&Le.isTypedArray;function Ae(h,_,v){switch(v.length){case 0:return h.call(_);case 1:return h.call(_,v[0]);case 2:return h.call(_,v[0],v[1]);case 3:return h.call(_,v[0],v[1],v[2])}return h.apply(_,v)}function Fl(h,_,v,b){for(var O=-1,z=h==null?0:h.length;++O<z;){var se=h[O];_(b,se,v(se),h)}return b}function Ne(h,_){for(var v=-1,b=h==null?0:h.length;++v<b&&_(h[v],v,h)!==!1;);return h}function Ll(h,_){for(var v=h==null?0:h.length;v--&&_(h[v],v,h)!==!1;);return h}function Fs(h,_){for(var v=-1,b=h==null?0:h.length;++v<b;)if(!_(h[v],v,h))return!1;return!0}function mt(h,_){for(var v=-1,b=h==null?0:h.length,O=0,z=[];++v<b;){var se=h[v];_(se,v,h)&&(z[O++]=se)}return z}function Mn(h,_){var v=h==null?0:h.length;return!!v&&Vt(h,_,0)>-1}function Gr(h,_,v){for(var b=-1,O=h==null?0:h.length;++b<O;)if(v(_,h[b]))return!0;return!1}function ee(h,_){for(var v=-1,b=h==null?0:h.length,O=Array(b);++v<b;)O[v]=_(h[v],v,h);return O}function vt(h,_){for(var v=-1,b=_.length,O=h.length;++v<b;)h[O+v]=_[v];return h}function qr(h,_,v,b){var O=-1,z=h==null?0:h.length;for(b&&z&&(v=h[++O]);++O<z;)v=_(v,h[O],O,h);return v}function Nl(h,_,v,b){var O=h==null?0:h.length;for(b&&O&&(v=h[--O]);O--;)v=_(v,h[O],O,h);return v}function Hr(h,_){for(var v=-1,b=h==null?0:h.length;++v<b;)if(_(h[v],v,h))return!0;return!1}var Ol=zr("length");function Ul(h){return h.split("")}function $l(h){return h.match(qu)||[]}function Ls(h,_,v){var b;return v(h,function(O,z,se){if(_(O,z,se))return b=z,!1}),b}function Wn(h,_,v,b){for(var O=h.length,z=v+(b?1:-1);b?z--:++z<O;)if(_(h[z],z,h))return z;return-1}function Vt(h,_,v){return _===_?jl(h,_,v):Wn(h,Ns,v)}function Dl(h,_,v,b){for(var O=v-1,z=h.length;++O<z;)if(b(h[O],_))return O;return-1}function Ns(h){return h!==h}function Os(h,_){var v=h==null?0:h.length;return v?jr(h,_)/v:Rn}function zr(h){return function(_){return _==null?r:_[h]}}function Kr(h){return function(_){return h==null?r:h[_]}}function Us(h,_,v,b,O){return O(h,function(z,se,Y){v=b?(b=!1,z):_(v,z,se,Y)}),v}function Ml(h,_){var v=h.length;for(h.sort(_);v--;)h[v]=h[v].value;return h}function jr(h,_){for(var v,b=-1,O=h.length;++b<O;){var z=_(h[b]);z!==r&&(v=v===r?z:v+z)}return v}function Yr(h,_){for(var v=-1,b=Array(h);++v<h;)b[v]=_(v);return b}function Wl(h,_){return ee(_,function(v){return[v,h[v]]})}function $s(h){return h&&h.slice(0,Bs(h)+1).replace(Ur,"")}function be(h){return function(_){return h(_)}}function Jr(h,_){return ee(_,function(v){return h[v]})}function dn(h,_){return h.has(_)}function Ds(h,_){for(var v=-1,b=h.length;++v<b&&Vt(_,h[v],0)>-1;);return v}function Ms(h,_){for(var v=h.length;v--&&Vt(_,h[v],0)>-1;);return v}function Bl(h,_){for(var v=h.length,b=0;v--;)h[v]===_&&++b;return b}var kl=Kr(El),Vl=Kr(Al);function Gl(h){return"\\"+Cl[h]}function ql(h,_){return h==null?r:h[_]}function Gt(h){return wl.test(h)}function Hl(h){return Sl.test(h)}function zl(h){for(var _,v=[];!(_=h.next()).done;)v.push(_.value);return v}function Zr(h){var _=-1,v=Array(h.size);return h.forEach(function(b,O){v[++_]=[O,b]}),v}function Ws(h,_){return function(v){return h(_(v))}}function yt(h,_){for(var v=-1,b=h.length,O=0,z=[];++v<b;){var se=h[v];(se===_||se===D)&&(h[v]=D,z[O++]=v)}return z}function Bn(h){var _=-1,v=Array(h.size);return h.forEach(function(b){v[++_]=b}),v}function Kl(h){var _=-1,v=Array(h.size);return h.forEach(function(b){v[++_]=[b,b]}),v}function jl(h,_,v){for(var b=v-1,O=h.length;++b<O;)if(h[b]===_)return b;return-1}function Yl(h,_,v){for(var b=v+1;b--;)if(h[b]===_)return b;return b}function qt(h){return Gt(h)?Zl(h):Ol(h)}function qe(h){return Gt(h)?Xl(h):Ul(h)}function Bs(h){for(var _=h.length;_--&&Bu.test(h.charAt(_)););return _}var Jl=Kr(bl);function Zl(h){for(var _=Br.lastIndex=0;Br.test(h);)++_;return _}function Xl(h){return h.match(Br)||[]}function Ql(h){return h.match(_l)||[]}var ec=(function h(_){_=_==null?le:Ht.defaults(le.Object(),_,Ht.pick(le,xl));var v=_.Array,b=_.Date,O=_.Error,z=_.Function,se=_.Math,Y=_.Object,Xr=_.RegExp,tc=_.String,Oe=_.TypeError,kn=v.prototype,nc=z.prototype,zt=Y.prototype,Vn=_["__core-js_shared__"],Gn=nc.toString,j=zt.hasOwnProperty,rc=0,ks=(function(){var e=/[^.]+$/.exec(Vn&&Vn.keys&&Vn.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),qn=zt.toString,ic=Gn.call(Y),sc=le._,ac=Xr("^"+Gn.call(j).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hn=Es?_.Buffer:r,_t=_.Symbol,zn=_.Uint8Array,Vs=Hn?Hn.allocUnsafe:r,Kn=Ws(Y.getPrototypeOf,Y),Gs=Y.create,qs=zt.propertyIsEnumerable,jn=kn.splice,Hs=_t?_t.isConcatSpreadable:r,pn=_t?_t.iterator:r,Rt=_t?_t.toStringTag:r,Yn=(function(){try{var e=Ut(Y,"defineProperty");return e({},"",{}),e}catch{}})(),oc=_.clearTimeout!==le.clearTimeout&&_.clearTimeout,uc=b&&b.now!==le.Date.now&&b.now,lc=_.setTimeout!==le.setTimeout&&_.setTimeout,Jn=se.ceil,Zn=se.floor,Qr=Y.getOwnPropertySymbols,cc=Hn?Hn.isBuffer:r,zs=_.isFinite,fc=kn.join,dc=Ws(Y.keys,Y),ae=se.max,fe=se.min,pc=b.now,hc=_.parseInt,Ks=se.random,gc=kn.reverse,ei=Ut(_,"DataView"),hn=Ut(_,"Map"),ti=Ut(_,"Promise"),Kt=Ut(_,"Set"),gn=Ut(_,"WeakMap"),mn=Ut(Y,"create"),Xn=gn&&new gn,jt={},mc=$t(ei),vc=$t(hn),yc=$t(ti),_c=$t(Kt),wc=$t(gn),Qn=_t?_t.prototype:r,vn=Qn?Qn.valueOf:r,js=Qn?Qn.toString:r;function o(e){if(ne(e)&&!$(e)&&!(e instanceof V)){if(e instanceof Ue)return e;if(j.call(e,"__wrapped__"))return Ya(e)}return new Ue(e)}var Yt=(function(){function e(){}return function(t){if(!te(t))return{};if(Gs)return Gs(t);e.prototype=t;var n=new e;return e.prototype=r,n}})();function er(){}function Ue(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}o.templateSettings={escape:Ou,evaluate:Uu,interpolate:rs,variable:"",imports:{_:o}},o.prototype=er.prototype,o.prototype.constructor=o,Ue.prototype=Yt(er.prototype),Ue.prototype.constructor=Ue;function V(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Je,this.__views__=[]}function Sc(){var e=new V(this.__wrapped__);return e.__actions__=ve(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ve(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ve(this.__views__),e}function xc(){if(this.__filtered__){var e=new V(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Ic(){var e=this.__wrapped__.value(),t=this.__dir__,n=$(e),i=t<0,a=n?e.length:0,u=$f(0,a,this.__views__),f=u.start,p=u.end,g=p-f,w=i?p:f-1,S=this.__iteratees__,I=S.length,A=0,P=fe(g,this.__takeCount__);if(!n||!i&&a==g&&P==g)return ya(e,this.__actions__);var L=[];e:for(;g--&&A<P;){w+=t;for(var W=-1,N=e[w];++W<I;){var k=S[W],G=k.iteratee,Pe=k.type,me=G(N);if(Pe==vu)N=me;else if(!me){if(Pe==Xi)continue e;break e}}L[A++]=N}return L}V.prototype=Yt(er.prototype),V.prototype.constructor=V;function Ft(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Ec(){this.__data__=mn?mn(null):{},this.size=0}function Ac(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function bc(e){var t=this.__data__;if(mn){var n=t[e];return n===R?r:n}return j.call(t,e)?t[e]:r}function Cc(e){var t=this.__data__;return mn?t[e]!==r:j.call(t,e)}function Tc(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=mn&&t===r?R:t,this}Ft.prototype.clear=Ec,Ft.prototype.delete=Ac,Ft.prototype.get=bc,Ft.prototype.has=Cc,Ft.prototype.set=Tc;function st(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Pc(){this.__data__=[],this.size=0}function Rc(e){var t=this.__data__,n=tr(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():jn.call(t,n,1),--this.size,!0}function Fc(e){var t=this.__data__,n=tr(t,e);return n<0?r:t[n][1]}function Lc(e){return tr(this.__data__,e)>-1}function Nc(e,t){var n=this.__data__,i=tr(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}st.prototype.clear=Pc,st.prototype.delete=Rc,st.prototype.get=Fc,st.prototype.has=Lc,st.prototype.set=Nc;function at(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Oc(){this.size=0,this.__data__={hash:new Ft,map:new(hn||st),string:new Ft}}function Uc(e){var t=pr(this,e).delete(e);return this.size-=t?1:0,t}function $c(e){return pr(this,e).get(e)}function Dc(e){return pr(this,e).has(e)}function Mc(e,t){var n=pr(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}at.prototype.clear=Oc,at.prototype.delete=Uc,at.prototype.get=$c,at.prototype.has=Dc,at.prototype.set=Mc;function Lt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new at;++t<n;)this.add(e[t])}function Wc(e){return this.__data__.set(e,R),this}function Bc(e){return this.__data__.has(e)}Lt.prototype.add=Lt.prototype.push=Wc,Lt.prototype.has=Bc;function He(e){var t=this.__data__=new st(e);this.size=t.size}function kc(){this.__data__=new st,this.size=0}function Vc(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Gc(e){return this.__data__.get(e)}function qc(e){return this.__data__.has(e)}function Hc(e,t){var n=this.__data__;if(n instanceof st){var i=n.__data__;if(!hn||i.length<d-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new at(i)}return n.set(e,t),this.size=n.size,this}He.prototype.clear=kc,He.prototype.delete=Vc,He.prototype.get=Gc,He.prototype.has=qc,He.prototype.set=Hc;function Ys(e,t){var n=$(e),i=!n&&Dt(e),a=!n&&!i&&Et(e),u=!n&&!i&&!a&&Qt(e),f=n||i||a||u,p=f?Yr(e.length,tc):[],g=p.length;for(var w in e)(t||j.call(e,w))&&!(f&&(w=="length"||a&&(w=="offset"||w=="parent")||u&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||ct(w,g)))&&p.push(w);return p}function Js(e){var t=e.length;return t?e[di(0,t-1)]:r}function zc(e,t){return hr(ve(e),Nt(t,0,e.length))}function Kc(e){return hr(ve(e))}function ni(e,t,n){(n!==r&&!ze(e[t],n)||n===r&&!(t in e))&&ot(e,t,n)}function yn(e,t,n){var i=e[t];(!(j.call(e,t)&&ze(i,n))||n===r&&!(t in e))&&ot(e,t,n)}function tr(e,t){for(var n=e.length;n--;)if(ze(e[n][0],t))return n;return-1}function jc(e,t,n,i){return wt(e,function(a,u,f){t(i,a,n(a),f)}),i}function Zs(e,t){return e&&Xe(t,oe(t),e)}function Yc(e,t){return e&&Xe(t,_e(t),e)}function ot(e,t,n){t=="__proto__"&&Yn?Yn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ri(e,t){for(var n=-1,i=t.length,a=v(i),u=e==null;++n<i;)a[n]=u?r:Di(e,t[n]);return a}function Nt(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function $e(e,t,n,i,a,u){var f,p=t&H,g=t&ht,w=t&Se;if(n&&(f=a?n(e,i,a,u):n(e)),f!==r)return f;if(!te(e))return e;var S=$(e);if(S){if(f=Mf(e),!p)return ve(e,f)}else{var I=de(e),A=I==Nn||I==Qi;if(Et(e))return Sa(e,p);if(I==it||I==Wt||A&&!a){if(f=g||A?{}:Ba(e),!p)return g?Cf(e,Yc(f,e)):bf(e,Zs(f,e))}else{if(!J[I])return a?e:{};f=Wf(e,I,p)}}u||(u=new He);var P=u.get(e);if(P)return P;u.set(e,f),mo(e)?e.forEach(function(N){f.add($e(N,t,n,N,e,u))}):ho(e)&&e.forEach(function(N,k){f.set(k,$e(N,t,n,k,e,u))});var L=w?g?Ii:xi:g?_e:oe,W=S?r:L(e);return Ne(W||e,function(N,k){W&&(k=N,N=e[k]),yn(f,k,$e(N,t,n,k,e,u))}),f}function Jc(e){var t=oe(e);return function(n){return Xs(n,e,t)}}function Xs(e,t,n){var i=n.length;if(e==null)return!i;for(e=Y(e);i--;){var a=n[i],u=t[a],f=e[a];if(f===r&&!(a in e)||!u(f))return!1}return!0}function Qs(e,t,n){if(typeof e!="function")throw new Oe(E);return An(function(){e.apply(r,n)},t)}function _n(e,t,n,i){var a=-1,u=Mn,f=!0,p=e.length,g=[],w=t.length;if(!p)return g;n&&(t=ee(t,be(n))),i?(u=Gr,f=!1):t.length>=d&&(u=dn,f=!1,t=new Lt(t));e:for(;++a<p;){var S=e[a],I=n==null?S:n(S);if(S=i||S!==0?S:0,f&&I===I){for(var A=w;A--;)if(t[A]===I)continue e;g.push(S)}else u(t,I,i)||g.push(S)}return g}var wt=ba(Ze),ea=ba(si,!0);function Zc(e,t){var n=!0;return wt(e,function(i,a,u){return n=!!t(i,a,u),n}),n}function nr(e,t,n){for(var i=-1,a=e.length;++i<a;){var u=e[i],f=t(u);if(f!=null&&(p===r?f===f&&!Te(f):n(f,p)))var p=f,g=u}return g}function Xc(e,t,n,i){var a=e.length;for(n=M(n),n<0&&(n=-n>a?0:a+n),i=i===r||i>a?a:M(i),i<0&&(i+=a),i=n>i?0:yo(i);n<i;)e[n++]=t;return e}function ta(e,t){var n=[];return wt(e,function(i,a,u){t(i,a,u)&&n.push(i)}),n}function ce(e,t,n,i,a){var u=-1,f=e.length;for(n||(n=kf),a||(a=[]);++u<f;){var p=e[u];t>0&&n(p)?t>1?ce(p,t-1,n,i,a):vt(a,p):i||(a[a.length]=p)}return a}var ii=Ca(),na=Ca(!0);function Ze(e,t){return e&&ii(e,t,oe)}function si(e,t){return e&&na(e,t,oe)}function rr(e,t){return mt(t,function(n){return ft(e[n])})}function Ot(e,t){t=xt(t,e);for(var n=0,i=t.length;e!=null&&n<i;)e=e[Qe(t[n++])];return n&&n==i?e:r}function ra(e,t,n){var i=t(e);return $(e)?i:vt(i,n(e))}function he(e){return e==null?e===r?Cu:Au:Rt&&Rt in Y(e)?Uf(e):jf(e)}function ai(e,t){return e>t}function Qc(e,t){return e!=null&&j.call(e,t)}function ef(e,t){return e!=null&&t in Y(e)}function tf(e,t,n){return e>=fe(t,n)&&e<ae(t,n)}function oi(e,t,n){for(var i=n?Gr:Mn,a=e[0].length,u=e.length,f=u,p=v(u),g=1/0,w=[];f--;){var S=e[f];f&&t&&(S=ee(S,be(t))),g=fe(S.length,g),p[f]=!n&&(t||a>=120&&S.length>=120)?new Lt(f&&S):r}S=e[0];var I=-1,A=p[0];e:for(;++I<a&&w.length<g;){var P=S[I],L=t?t(P):P;if(P=n||P!==0?P:0,!(A?dn(A,L):i(w,L,n))){for(f=u;--f;){var W=p[f];if(!(W?dn(W,L):i(e[f],L,n)))continue e}A&&A.push(L),w.push(P)}}return w}function nf(e,t,n,i){return Ze(e,function(a,u,f){t(i,n(a),u,f)}),i}function wn(e,t,n){t=xt(t,e),e=qa(e,t);var i=e==null?e:e[Qe(Me(t))];return i==null?r:Ae(i,e,n)}function ia(e){return ne(e)&&he(e)==Wt}function rf(e){return ne(e)&&he(e)==fn}function sf(e){return ne(e)&&he(e)==an}function Sn(e,t,n,i,a){return e===t?!0:e==null||t==null||!ne(e)&&!ne(t)?e!==e&&t!==t:af(e,t,n,i,Sn,a)}function af(e,t,n,i,a,u){var f=$(e),p=$(t),g=f?Fn:de(e),w=p?Fn:de(t);g=g==Wt?it:g,w=w==Wt?it:w;var S=g==it,I=w==it,A=g==w;if(A&&Et(e)){if(!Et(t))return!1;f=!0,S=!1}if(A&&!S)return u||(u=new He),f||Qt(e)?Da(e,t,n,i,a,u):Nf(e,t,g,n,i,a,u);if(!(n&ke)){var P=S&&j.call(e,"__wrapped__"),L=I&&j.call(t,"__wrapped__");if(P||L){var W=P?e.value():e,N=L?t.value():t;return u||(u=new He),a(W,N,n,i,u)}}return A?(u||(u=new He),Of(e,t,n,i,a,u)):!1}function of(e){return ne(e)&&de(e)==Ve}function ui(e,t,n,i){var a=n.length,u=a,f=!i;if(e==null)return!u;for(e=Y(e);a--;){var p=n[a];if(f&&p[2]?p[1]!==e[p[0]]:!(p[0]in e))return!1}for(;++a<u;){p=n[a];var g=p[0],w=e[g],S=p[1];if(f&&p[2]){if(w===r&&!(g in e))return!1}else{var I=new He;if(i)var A=i(w,S,g,e,t,I);if(!(A===r?Sn(S,w,ke|bt,i,I):A))return!1}}return!0}function sa(e){if(!te(e)||Gf(e))return!1;var t=ft(e)?ac:Ju;return t.test($t(e))}function uf(e){return ne(e)&&he(e)==un}function lf(e){return ne(e)&&de(e)==Ge}function cf(e){return ne(e)&&wr(e.length)&&!!X[he(e)]}function aa(e){return typeof e=="function"?e:e==null?we:typeof e=="object"?$(e)?la(e[0],e[1]):ua(e):Po(e)}function li(e){if(!En(e))return dc(e);var t=[];for(var n in Y(e))j.call(e,n)&&n!="constructor"&&t.push(n);return t}function ff(e){if(!te(e))return Kf(e);var t=En(e),n=[];for(var i in e)i=="constructor"&&(t||!j.call(e,i))||n.push(i);return n}function ci(e,t){return e<t}function oa(e,t){var n=-1,i=ye(e)?v(e.length):[];return wt(e,function(a,u,f){i[++n]=t(a,u,f)}),i}function ua(e){var t=Ai(e);return t.length==1&&t[0][2]?Va(t[0][0],t[0][1]):function(n){return n===e||ui(n,e,t)}}function la(e,t){return Ci(e)&&ka(t)?Va(Qe(e),t):function(n){var i=Di(n,e);return i===r&&i===t?Mi(n,e):Sn(t,i,ke|bt)}}function ir(e,t,n,i,a){e!==t&&ii(t,function(u,f){if(a||(a=new He),te(u))df(e,t,f,n,ir,i,a);else{var p=i?i(Pi(e,f),u,f+"",e,t,a):r;p===r&&(p=u),ni(e,f,p)}},_e)}function df(e,t,n,i,a,u,f){var p=Pi(e,n),g=Pi(t,n),w=f.get(g);if(w){ni(e,n,w);return}var S=u?u(p,g,n+"",e,t,f):r,I=S===r;if(I){var A=$(g),P=!A&&Et(g),L=!A&&!P&&Qt(g);S=g,A||P||L?$(p)?S=p:re(p)?S=ve(p):P?(I=!1,S=Sa(g,!0)):L?(I=!1,S=xa(g,!0)):S=[]:bn(g)||Dt(g)?(S=p,Dt(p)?S=_o(p):(!te(p)||ft(p))&&(S=Ba(g))):I=!1}I&&(f.set(g,S),a(S,g,i,u,f),f.delete(g)),ni(e,n,S)}function ca(e,t){var n=e.length;if(n)return t+=t<0?n:0,ct(t,n)?e[t]:r}function fa(e,t,n){t.length?t=ee(t,function(u){return $(u)?function(f){return Ot(f,u.length===1?u[0]:u)}:u}):t=[we];var i=-1;t=ee(t,be(F()));var a=oa(e,function(u,f,p){var g=ee(t,function(w){return w(u)});return{criteria:g,index:++i,value:u}});return Ml(a,function(u,f){return Af(u,f,n)})}function pf(e,t){return da(e,t,function(n,i){return Mi(e,i)})}function da(e,t,n){for(var i=-1,a=t.length,u={};++i<a;){var f=t[i],p=Ot(e,f);n(p,f)&&xn(u,xt(f,e),p)}return u}function hf(e){return function(t){return Ot(t,e)}}function fi(e,t,n,i){var a=i?Dl:Vt,u=-1,f=t.length,p=e;for(e===t&&(t=ve(t)),n&&(p=ee(e,be(n)));++u<f;)for(var g=0,w=t[u],S=n?n(w):w;(g=a(p,S,g,i))>-1;)p!==e&&jn.call(p,g,1),jn.call(e,g,1);return e}function pa(e,t){for(var n=e?t.length:0,i=n-1;n--;){var a=t[n];if(n==i||a!==u){var u=a;ct(a)?jn.call(e,a,1):gi(e,a)}}return e}function di(e,t){return e+Zn(Ks()*(t-e+1))}function gf(e,t,n,i){for(var a=-1,u=ae(Jn((t-e)/(n||1)),0),f=v(u);u--;)f[i?u:++a]=e,e+=n;return f}function pi(e,t){var n="";if(!e||t<1||t>gt)return n;do t%2&&(n+=e),t=Zn(t/2),t&&(e+=e);while(t);return n}function B(e,t){return Ri(Ga(e,t,we),e+"")}function mf(e){return Js(en(e))}function vf(e,t){var n=en(e);return hr(n,Nt(t,0,n.length))}function xn(e,t,n,i){if(!te(e))return e;t=xt(t,e);for(var a=-1,u=t.length,f=u-1,p=e;p!=null&&++a<u;){var g=Qe(t[a]),w=n;if(g==="__proto__"||g==="constructor"||g==="prototype")return e;if(a!=f){var S=p[g];w=i?i(S,g,p):r,w===r&&(w=te(S)?S:ct(t[a+1])?[]:{})}yn(p,g,w),p=p[g]}return e}var ha=Xn?function(e,t){return Xn.set(e,t),e}:we,yf=Yn?function(e,t){return Yn(e,"toString",{configurable:!0,enumerable:!1,value:Bi(t),writable:!0})}:we;function _f(e){return hr(en(e))}function De(e,t,n){var i=-1,a=e.length;t<0&&(t=-t>a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var u=v(a);++i<a;)u[i]=e[i+t];return u}function wf(e,t){var n;return wt(e,function(i,a,u){return n=t(i,a,u),!n}),!!n}function sr(e,t,n){var i=0,a=e==null?i:e.length;if(typeof t=="number"&&t===t&&a<=Su){for(;i<a;){var u=i+a>>>1,f=e[u];f!==null&&!Te(f)&&(n?f<=t:f<t)?i=u+1:a=u}return a}return hi(e,t,we,n)}function hi(e,t,n,i){var a=0,u=e==null?0:e.length;if(u===0)return 0;t=n(t);for(var f=t!==t,p=t===null,g=Te(t),w=t===r;a<u;){var S=Zn((a+u)/2),I=n(e[S]),A=I!==r,P=I===null,L=I===I,W=Te(I);if(f)var N=i||L;else w?N=L&&(i||A):p?N=L&&A&&(i||!P):g?N=L&&A&&!P&&(i||!W):P||W?N=!1:N=i?I<=t:I<t;N?a=S+1:u=S}return fe(u,wu)}function ga(e,t){for(var n=-1,i=e.length,a=0,u=[];++n<i;){var f=e[n],p=t?t(f):f;if(!n||!ze(p,g)){var g=p;u[a++]=f===0?0:f}}return u}function ma(e){return typeof e=="number"?e:Te(e)?Rn:+e}function Ce(e){if(typeof e=="string")return e;if($(e))return ee(e,Ce)+"";if(Te(e))return js?js.call(e):"";var t=e+"";return t=="0"&&1/e==-Tt?"-0":t}function St(e,t,n){var i=-1,a=Mn,u=e.length,f=!0,p=[],g=p;if(n)f=!1,a=Gr;else if(u>=d){var w=t?null:Ff(e);if(w)return Bn(w);f=!1,a=dn,g=new Lt}else g=t?[]:p;e:for(;++i<u;){var S=e[i],I=t?t(S):S;if(S=n||S!==0?S:0,f&&I===I){for(var A=g.length;A--;)if(g[A]===I)continue e;t&&g.push(I),p.push(S)}else a(g,I,n)||(g!==p&&g.push(I),p.push(S))}return p}function gi(e,t){return t=xt(t,e),e=qa(e,t),e==null||delete e[Qe(Me(t))]}function va(e,t,n,i){return xn(e,t,n(Ot(e,t)),i)}function ar(e,t,n,i){for(var a=e.length,u=i?a:-1;(i?u--:++u<a)&&t(e[u],u,e););return n?De(e,i?0:u,i?u+1:a):De(e,i?u+1:0,i?a:u)}function ya(e,t){var n=e;return n instanceof V&&(n=n.value()),qr(t,function(i,a){return a.func.apply(a.thisArg,vt([i],a.args))},n)}function mi(e,t,n){var i=e.length;if(i<2)return i?St(e[0]):[];for(var a=-1,u=v(i);++a<i;)for(var f=e[a],p=-1;++p<i;)p!=a&&(u[a]=_n(u[a]||f,e[p],t,n));return St(ce(u,1),t,n)}function _a(e,t,n){for(var i=-1,a=e.length,u=t.length,f={};++i<a;){var p=i<u?t[i]:r;n(f,e[i],p)}return f}function vi(e){return re(e)?e:[]}function yi(e){return typeof e=="function"?e:we}function xt(e,t){return $(e)?e:Ci(e,t)?[e]:ja(K(e))}var Sf=B;function It(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:De(e,t,n)}var wa=oc||function(e){return le.clearTimeout(e)};function Sa(e,t){if(t)return e.slice();var n=e.length,i=Vs?Vs(n):new e.constructor(n);return e.copy(i),i}function _i(e){var t=new e.constructor(e.byteLength);return new zn(t).set(new zn(e)),t}function xf(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function If(e){var t=new e.constructor(e.source,is.exec(e));return t.lastIndex=e.lastIndex,t}function Ef(e){return vn?Y(vn.call(e)):{}}function xa(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ia(e,t){if(e!==t){var n=e!==r,i=e===null,a=e===e,u=Te(e),f=t!==r,p=t===null,g=t===t,w=Te(t);if(!p&&!w&&!u&&e>t||u&&f&&g&&!p&&!w||i&&f&&g||!n&&g||!a)return 1;if(!i&&!u&&!w&&e<t||w&&n&&a&&!i&&!u||p&&n&&a||!f&&a||!g)return-1}return 0}function Af(e,t,n){for(var i=-1,a=e.criteria,u=t.criteria,f=a.length,p=n.length;++i<f;){var g=Ia(a[i],u[i]);if(g){if(i>=p)return g;var w=n[i];return g*(w=="desc"?-1:1)}}return e.index-t.index}function Ea(e,t,n,i){for(var a=-1,u=e.length,f=n.length,p=-1,g=t.length,w=ae(u-f,0),S=v(g+w),I=!i;++p<g;)S[p]=t[p];for(;++a<f;)(I||a<u)&&(S[n[a]]=e[a]);for(;w--;)S[p++]=e[a++];return S}function Aa(e,t,n,i){for(var a=-1,u=e.length,f=-1,p=n.length,g=-1,w=t.length,S=ae(u-p,0),I=v(S+w),A=!i;++a<S;)I[a]=e[a];for(var P=a;++g<w;)I[P+g]=t[g];for(;++f<p;)(A||a<u)&&(I[P+n[f]]=e[a++]);return I}function ve(e,t){var n=-1,i=e.length;for(t||(t=v(i));++n<i;)t[n]=e[n];return t}function Xe(e,t,n,i){var a=!n;n||(n={});for(var u=-1,f=t.length;++u<f;){var p=t[u],g=i?i(n[p],e[p],p,n,e):r;g===r&&(g=e[p]),a?ot(n,p,g):yn(n,p,g)}return n}function bf(e,t){return Xe(e,bi(e),t)}function Cf(e,t){return Xe(e,Ma(e),t)}function or(e,t){return function(n,i){var a=$(n)?Fl:jc,u=t?t():{};return a(n,e,F(i,2),u)}}function Jt(e){return B(function(t,n){var i=-1,a=n.length,u=a>1?n[a-1]:r,f=a>2?n[2]:r;for(u=e.length>3&&typeof u=="function"?(a--,u):r,f&&ge(n[0],n[1],f)&&(u=a<3?r:u,a=1),t=Y(t);++i<a;){var p=n[i];p&&e(t,p,i,u)}return t})}function ba(e,t){return function(n,i){if(n==null)return n;if(!ye(n))return e(n,i);for(var a=n.length,u=t?a:-1,f=Y(n);(t?u--:++u<a)&&i(f[u],u,f)!==!1;);return n}}function Ca(e){return function(t,n,i){for(var a=-1,u=Y(t),f=i(t),p=f.length;p--;){var g=f[e?p:++a];if(n(u[g],g,u)===!1)break}return t}}function Tf(e,t,n){var i=t&xe,a=In(e);function u(){var f=this&&this!==le&&this instanceof u?a:e;return f.apply(i?n:this,arguments)}return u}function Ta(e){return function(t){t=K(t);var n=Gt(t)?qe(t):r,i=n?n[0]:t.charAt(0),a=n?It(n,1).join(""):t.slice(1);return i[e]()+a}}function Zt(e){return function(t){return qr(Co(bo(t).replace(vl,"")),e,"")}}function In(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Yt(e.prototype),i=e.apply(n,t);return te(i)?i:n}}function Pf(e,t,n){var i=In(e);function a(){for(var u=arguments.length,f=v(u),p=u,g=Xt(a);p--;)f[p]=arguments[p];var w=u<3&&f[0]!==g&&f[u-1]!==g?[]:yt(f,g);if(u-=w.length,u<n)return Na(e,t,ur,a.placeholder,r,f,w,r,r,n-u);var S=this&&this!==le&&this instanceof a?i:e;return Ae(S,this,f)}return a}function Pa(e){return function(t,n,i){var a=Y(t);if(!ye(t)){var u=F(n,3);t=oe(t),n=function(p){return u(a[p],p,a)}}var f=e(t,n,i);return f>-1?a[u?t[f]:f]:r}}function Ra(e){return lt(function(t){var n=t.length,i=n,a=Ue.prototype.thru;for(e&&t.reverse();i--;){var u=t[i];if(typeof u!="function")throw new Oe(E);if(a&&!f&&dr(u)=="wrapper")var f=new Ue([],!0)}for(i=f?i:n;++i<n;){u=t[i];var p=dr(u),g=p=="wrapper"?Ei(u):r;g&&Ti(g[0])&&g[1]==(rt|Fe|Ie|rn)&&!g[4].length&&g[9]==1?f=f[dr(g[0])].apply(f,g[3]):f=u.length==1&&Ti(u)?f[p]():f.thru(u)}return function(){var w=arguments,S=w[0];if(f&&w.length==1&&$(S))return f.plant(S).value();for(var I=0,A=n?t[I].apply(this,w):S;++I<n;)A=t[I].call(this,A);return A}})}function ur(e,t,n,i,a,u,f,p,g,w){var S=t&rt,I=t&xe,A=t&Ye,P=t&(Fe|Ct),L=t&Er,W=A?r:In(e);function N(){for(var k=arguments.length,G=v(k),Pe=k;Pe--;)G[Pe]=arguments[Pe];if(P)var me=Xt(N),Re=Bl(G,me);if(i&&(G=Ea(G,i,a,P)),u&&(G=Aa(G,u,f,P)),k-=Re,P&&k<w){var ie=yt(G,me);return Na(e,t,ur,N.placeholder,n,G,ie,p,g,w-k)}var Ke=I?n:this,pt=A?Ke[e]:e;return k=G.length,p?G=Yf(G,p):L&&k>1&&G.reverse(),S&&g<k&&(G.length=g),this&&this!==le&&this instanceof N&&(pt=W||In(pt)),pt.apply(Ke,G)}return N}function Fa(e,t){return function(n,i){return nf(n,e,t(i),{})}}function lr(e,t){return function(n,i){var a;if(n===r&&i===r)return t;if(n!==r&&(a=n),i!==r){if(a===r)return i;typeof n=="string"||typeof i=="string"?(n=Ce(n),i=Ce(i)):(n=ma(n),i=ma(i)),a=e(n,i)}return a}}function wi(e){return lt(function(t){return t=ee(t,be(F())),B(function(n){var i=this;return e(t,function(a){return Ae(a,i,n)})})})}function cr(e,t){t=t===r?" ":Ce(t);var n=t.length;if(n<2)return n?pi(t,e):t;var i=pi(t,Jn(e/qt(t)));return Gt(t)?It(qe(i),0,e).join(""):i.slice(0,e)}function Rf(e,t,n,i){var a=t&xe,u=In(e);function f(){for(var p=-1,g=arguments.length,w=-1,S=i.length,I=v(S+g),A=this&&this!==le&&this instanceof f?u:e;++w<S;)I[w]=i[w];for(;g--;)I[w++]=arguments[++p];return Ae(A,a?n:this,I)}return f}function La(e){return function(t,n,i){return i&&typeof i!="number"&&ge(t,n,i)&&(n=i=r),t=dt(t),n===r?(n=t,t=0):n=dt(n),i=i===r?t<n?1:-1:dt(i),gf(t,n,i,e)}}function fr(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=We(t),n=We(n)),e(t,n)}}function Na(e,t,n,i,a,u,f,p,g,w){var S=t&Fe,I=S?f:r,A=S?r:f,P=S?u:r,L=S?r:u;t|=S?Ie:Ee,t&=~(S?Ee:Ie),t&Pn||(t&=-4);var W=[e,t,a,P,I,L,A,p,g,w],N=n.apply(r,W);return Ti(e)&&Ha(N,W),N.placeholder=i,za(N,e,t)}function Si(e){var t=se[e];return function(n,i){if(n=We(n),i=i==null?0:fe(M(i),292),i&&zs(n)){var a=(K(n)+"e").split("e"),u=t(a[0]+"e"+(+a[1]+i));return a=(K(u)+"e").split("e"),+(a[0]+"e"+(+a[1]-i))}return t(n)}}var Ff=Kt&&1/Bn(new Kt([,-0]))[1]==Tt?function(e){return new Kt(e)}:Gi;function Oa(e){return function(t){var n=de(t);return n==Ve?Zr(t):n==Ge?Kl(t):Wl(t,e(t))}}function ut(e,t,n,i,a,u,f,p){var g=t&Ye;if(!g&&typeof e!="function")throw new Oe(E);var w=i?i.length:0;if(w||(t&=-97,i=a=r),f=f===r?f:ae(M(f),0),p=p===r?p:M(p),w-=a?a.length:0,t&Ee){var S=i,I=a;i=a=r}var A=g?r:Ei(e),P=[e,t,n,i,a,S,I,u,f,p];if(A&&zf(P,A),e=P[0],t=P[1],n=P[2],i=P[3],a=P[4],p=P[9]=P[9]===r?g?0:e.length:ae(P[9]-w,0),!p&&t&(Fe|Ct)&&(t&=-25),!t||t==xe)var L=Tf(e,t,n);else t==Fe||t==Ct?L=Pf(e,t,p):(t==Ie||t==(xe|Ie))&&!a.length?L=Rf(e,t,n,i):L=ur.apply(r,P);var W=A?ha:Ha;return za(W(L,P),e,t)}function Ua(e,t,n,i){return e===r||ze(e,zt[n])&&!j.call(i,n)?t:e}function $a(e,t,n,i,a,u){return te(e)&&te(t)&&(u.set(t,e),ir(e,t,r,$a,u),u.delete(t)),e}function Lf(e){return bn(e)?r:e}function Da(e,t,n,i,a,u){var f=n&ke,p=e.length,g=t.length;if(p!=g&&!(f&&g>p))return!1;var w=u.get(e),S=u.get(t);if(w&&S)return w==t&&S==e;var I=-1,A=!0,P=n&bt?new Lt:r;for(u.set(e,t),u.set(t,e);++I<p;){var L=e[I],W=t[I];if(i)var N=f?i(W,L,I,t,e,u):i(L,W,I,e,t,u);if(N!==r){if(N)continue;A=!1;break}if(P){if(!Hr(t,function(k,G){if(!dn(P,G)&&(L===k||a(L,k,n,i,u)))return P.push(G)})){A=!1;break}}else if(!(L===W||a(L,W,n,i,u))){A=!1;break}}return u.delete(e),u.delete(t),A}function Nf(e,t,n,i,a,u,f){switch(n){case Bt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case fn:return!(e.byteLength!=t.byteLength||!u(new zn(e),new zn(t)));case sn:case an:case on:return ze(+e,+t);case Ln:return e.name==t.name&&e.message==t.message;case un:case ln:return e==t+"";case Ve:var p=Zr;case Ge:var g=i&ke;if(p||(p=Bn),e.size!=t.size&&!g)return!1;var w=f.get(e);if(w)return w==t;i|=bt,f.set(e,t);var S=Da(p(e),p(t),i,a,u,f);return f.delete(e),S;case On:if(vn)return vn.call(e)==vn.call(t)}return!1}function Of(e,t,n,i,a,u){var f=n&ke,p=xi(e),g=p.length,w=xi(t),S=w.length;if(g!=S&&!f)return!1;for(var I=g;I--;){var A=p[I];if(!(f?A in t:j.call(t,A)))return!1}var P=u.get(e),L=u.get(t);if(P&&L)return P==t&&L==e;var W=!0;u.set(e,t),u.set(t,e);for(var N=f;++I<g;){A=p[I];var k=e[A],G=t[A];if(i)var Pe=f?i(G,k,A,t,e,u):i(k,G,A,e,t,u);if(!(Pe===r?k===G||a(k,G,n,i,u):Pe)){W=!1;break}N||(N=A=="constructor")}if(W&&!N){var me=e.constructor,Re=t.constructor;me!=Re&&"constructor"in e&&"constructor"in t&&!(typeof me=="function"&&me instanceof me&&typeof Re=="function"&&Re instanceof Re)&&(W=!1)}return u.delete(e),u.delete(t),W}function lt(e){return Ri(Ga(e,r,Xa),e+"")}function xi(e){return ra(e,oe,bi)}function Ii(e){return ra(e,_e,Ma)}var Ei=Xn?function(e){return Xn.get(e)}:Gi;function dr(e){for(var t=e.name+"",n=jt[t],i=j.call(jt,t)?n.length:0;i--;){var a=n[i],u=a.func;if(u==null||u==e)return a.name}return t}function Xt(e){var t=j.call(o,"placeholder")?o:e;return t.placeholder}function F(){var e=o.iteratee||ki;return e=e===ki?aa:e,arguments.length?e(arguments[0],arguments[1]):e}function pr(e,t){var n=e.__data__;return Vf(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ai(e){for(var t=oe(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,ka(a)]}return t}function Ut(e,t){var n=ql(e,t);return sa(n)?n:r}function Uf(e){var t=j.call(e,Rt),n=e[Rt];try{e[Rt]=r;var i=!0}catch{}var a=qn.call(e);return i&&(t?e[Rt]=n:delete e[Rt]),a}var bi=Qr?function(e){return e==null?[]:(e=Y(e),mt(Qr(e),function(t){return qs.call(e,t)}))}:qi,Ma=Qr?function(e){for(var t=[];e;)vt(t,bi(e)),e=Kn(e);return t}:qi,de=he;(ei&&de(new ei(new ArrayBuffer(1)))!=Bt||hn&&de(new hn)!=Ve||ti&&de(ti.resolve())!=es||Kt&&de(new Kt)!=Ge||gn&&de(new gn)!=cn)&&(de=function(e){var t=he(e),n=t==it?e.constructor:r,i=n?$t(n):"";if(i)switch(i){case mc:return Bt;case vc:return Ve;case yc:return es;case _c:return Ge;case wc:return cn}return t});function $f(e,t,n){for(var i=-1,a=n.length;++i<a;){var u=n[i],f=u.size;switch(u.type){case"drop":e+=f;break;case"dropRight":t-=f;break;case"take":t=fe(t,e+f);break;case"takeRight":e=ae(e,t-f);break}}return{start:e,end:t}}function Df(e){var t=e.match(Vu);return t?t[1].split(Gu):[]}function Wa(e,t,n){t=xt(t,e);for(var i=-1,a=t.length,u=!1;++i<a;){var f=Qe(t[i]);if(!(u=e!=null&&n(e,f)))break;e=e[f]}return u||++i!=a?u:(a=e==null?0:e.length,!!a&&wr(a)&&ct(f,a)&&($(e)||Dt(e)))}function Mf(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&j.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Ba(e){return typeof e.constructor=="function"&&!En(e)?Yt(Kn(e)):{}}function Wf(e,t,n){var i=e.constructor;switch(t){case fn:return _i(e);case sn:case an:return new i(+e);case Bt:return xf(e,n);case Ar:case br:case Cr:case Tr:case Pr:case Rr:case Fr:case Lr:case Nr:return xa(e,n);case Ve:return new i;case on:case ln:return new i(e);case un:return If(e);case Ge:return new i;case On:return Ef(e)}}function Bf(e,t){var n=t.length;if(!n)return e;var i=n-1;return t[i]=(n>1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ku,`{
3
10
  /* [wrapped with `+t+`] */
4
- `)}function xf(e){return N(e)||Ut(e)||!!(qs&&e&&e[qs])}function ct(e,t){var n=typeof e;return t=t??gt,!!t&&(n=="number"||n!="symbol"&&Ou.test(e))&&e>-1&&e%1==0&&e<t}function ve(e,t,n){if(!re(n))return!1;var i=typeof t;return(i=="number"?_e(n)&&ct(t,n.length):i=="string"&&t in n)?ze(n[t],e):!1}function bi(e,t){if(N(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Te(e)?!0:yu.test(e)||!mu.test(e)||t!=null&&e in J(t)}function If(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ci(e){var t=fr(e),n=o[t];if(typeof n!="function"||!(t in k.prototype))return!1;if(e===n)return!0;var i=Ii(n);return!!i&&e===i[0]}function Ef(e){return!!Bs&&Bs in e}var Af=kn?ft:qi;function In(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Ht;return e===n}function Ba(e){return e===e&&!re(e)}function ka(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in J(n))}}function bf(e){var t=mr(e,function(i){return n.size===q&&n.clear(),i}),n=t.cache;return t}function Cf(e,t){var n=e[1],i=t[1],a=n|i,u=a<(xe|Je|rt),c=i==rt&&n==Le||i==rt&&n==nn&&e[7].length<=t[8]||i==(rt|nn)&&t[7].length<=t[8]&&n==Le;if(!(u||c))return e;i&xe&&(e[2]=t[2],a|=n&xe?0:Tn);var h=t[3];if(h){var g=e[3];e[3]=g?Ia(g,h,t[4]):h,e[4]=g?yt(e[3],Z):t[4]}return h=t[5],h&&(g=e[5],e[5]=g?Ea(g,h,t[6]):h,e[6]=g?yt(e[5],Z):t[6]),h=t[7],h&&(e[7]=h),i&rt&&(e[8]=e[8]==null?t[8]:he(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function Tf(e){var t=[];if(e!=null)for(var n in J(e))t.push(n);return t}function Rf(e){return Gn.call(e)}function Va(e,t,n){return t=ue(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,u=ue(i.length-t,0),c=m(u);++a<u;)c[a]=i[t+a];a=-1;for(var h=m(t+1);++a<t;)h[a]=i[a];return h[t]=n(c),Ae(e,this,h)}}function Ga(e,t){return t.length<2?e:Ot(e,Me(t,0,-1))}function Ff(e,t){for(var n=e.length,i=he(t.length,n),a=ye(e);i--;){var u=t[i];e[i]=ct(u,n)?a[u]:r}return e}function Ti(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var qa=za(ha),En=ql||function(e,t){return fe.setTimeout(e,t)},Ri=za(Xc);function Ha(e,t,n){var i=t+"";return Ri(e,Sf(i,Pf(yf(i),n)))}function za(e){var t=0,n=0;return function(){var i=jl(),a=Zo-(i-n);if(n=i,a>0){if(++t>=Jo)return arguments[0]}else t=0;return e.apply(r,arguments)}}function hr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var u=fi(n,a),c=e[u];e[u]=e[n],e[n]=c}return e.length=t,e}var Ka=bf(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(_u,function(n,i,a,u){t.push(a?u.replace(Cu,"$1"):i||n)}),t});function et(e){if(typeof e=="string"||Te(e))return e;var t=e+"";return t=="0"&&1/e==-Ct?"-0":t}function $t(e){if(e!=null){try{return Vn.call(e)}catch{}try{return e+""}catch{}}return""}function Pf(e,t){return Ne(ru,function(n){var i="_."+n[0];t&n[1]&&!Dn(e,i)&&e.push(i)}),e.sort()}function ja(e){if(e instanceof k)return e.clone();var t=new Ue(e.__wrapped__,e.__chain__);return t.__actions__=ye(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Lf(e,t,n){(n?ve(e,t,n):t===r)?t=1:t=ue(U(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,u=0,c=m(Yn(i/t));a<i;)c[u++]=Me(e,a,a+=t);return c}function Of(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var u=e[t];u&&(a[i++]=u)}return a}function Nf(){var e=arguments.length;if(!e)return[];for(var t=m(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return mt(N(n)?ye(n):[n],de(t,1))}var $f=W(function(e,t){return se(e)?yn(e,de(t,1,se,!0)):[]}),Uf=W(function(e,t){var n=We(t);return se(n)&&(n=r),se(e)?yn(e,de(t,1,se,!0),F(n,2)):[]}),Df=W(function(e,t){var n=We(t);return se(n)&&(n=r),se(e)?yn(e,de(t,1,se,!0),r,n):[]});function Mf(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:U(t),Me(e,t<0?0:t,i)):[]}function Wf(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:U(t),t=i-t,Me(e,0,t<0?0:t)):[]}function Bf(e,t){return e&&e.length?sr(e,F(t,3),!0,!0):[]}function kf(e,t){return e&&e.length?sr(e,F(t,3),!0):[]}function Vf(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&ve(e,t,n)&&(n=0,i=a),Oc(e,t,n,i)):[]}function Ya(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:U(n);return a<0&&(a=ue(i+a,0)),Mn(e,F(t,3),a)}function Ja(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=U(n),a=n<0?ue(i+a,0):he(a,i-1)),Mn(e,F(t,3),a,!0)}function Za(e){var t=e==null?0:e.length;return t?de(e,1):[]}function Gf(e){var t=e==null?0:e.length;return t?de(e,Ct):[]}function qf(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:U(t),de(e,t)):[]}function Hf(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function Xa(e){return e&&e.length?e[0]:r}function zf(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:U(n);return a<0&&(a=ue(i+a,0)),kt(e,t,a)}function Kf(e){var t=e==null?0:e.length;return t?Me(e,0,-1):[]}var jf=W(function(e){var t=ne(e,vi);return t.length&&t[0]===e[0]?ai(t):[]}),Yf=W(function(e){var t=We(e),n=ne(e,vi);return t===We(n)?t=r:n.pop(),n.length&&n[0]===e[0]?ai(n,F(t,2)):[]}),Jf=W(function(e){var t=We(e),n=ne(e,vi);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?ai(n,r,t):[]});function Zf(e,t){return e==null?"":zl.call(e,t)}function We(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Xf(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=U(n),a=a<0?ue(i+a,0):he(a,i-1)),t===t?Fl(e,t,a):Mn(e,Ls,a,!0)}function Qf(e,t){return e&&e.length?la(e,U(t)):r}var ed=W(Qa);function Qa(e,t){return e&&e.length&&t&&t.length?ci(e,t):e}function td(e,t,n){return e&&e.length&&t&&t.length?ci(e,t,F(n,2)):e}function nd(e,t,n){return e&&e.length&&t&&t.length?ci(e,t,r,n):e}var rd=lt(function(e,t){var n=e==null?0:e.length,i=ni(e,t);return da(e,ne(t,function(a){return ct(a,n)?+a:a}).sort(xa)),i});function id(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],u=e.length;for(t=F(t,3);++i<u;){var c=e[i];t(c,i,e)&&(n.push(c),a.push(i))}return da(e,a),n}function Fi(e){return e==null?e:Jl.call(e)}function sd(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&ve(e,t,n)?(t=0,n=i):(t=t==null?0:U(t),n=n===r?i:U(n)),Me(e,t,n)):[]}function ad(e,t){return ir(e,t)}function od(e,t,n){return hi(e,t,F(n,2))}function ud(e,t){var n=e==null?0:e.length;if(n){var i=ir(e,t);if(i<n&&ze(e[i],t))return i}return-1}function ld(e,t){return ir(e,t,!0)}function cd(e,t,n){return hi(e,t,F(n,2),!0)}function fd(e,t){var n=e==null?0:e.length;if(n){var i=ir(e,t,!0)-1;if(ze(e[i],t))return i}return-1}function dd(e){return e&&e.length?pa(e):[]}function hd(e,t){return e&&e.length?pa(e,F(t,2)):[]}function pd(e){var t=e==null?0:e.length;return t?Me(e,1,t):[]}function gd(e,t,n){return e&&e.length?(t=n||t===r?1:U(t),Me(e,0,t<0?0:t)):[]}function vd(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:U(t),t=i-t,Me(e,t<0?0:t,i)):[]}function md(e,t){return e&&e.length?sr(e,F(t,3),!1,!0):[]}function yd(e,t){return e&&e.length?sr(e,F(t,3)):[]}var _d=W(function(e){return St(de(e,1,se,!0))}),wd=W(function(e){var t=We(e);return se(t)&&(t=r),St(de(e,1,se,!0),F(t,2))}),Sd=W(function(e){var t=We(e);return t=typeof t=="function"?t:r,St(de(e,1,se,!0),r,t)});function xd(e){return e&&e.length?St(e):[]}function Id(e,t){return e&&e.length?St(e,F(t,2)):[]}function Ed(e,t){return t=typeof t=="function"?t:r,e&&e.length?St(e,r,t):[]}function Pi(e){if(!(e&&e.length))return[];var t=0;return e=vt(e,function(n){if(se(n))return t=ue(n.length,t),!0}),jr(t,function(n){return ne(e,Hr(n))})}function eo(e,t){if(!(e&&e.length))return[];var n=Pi(e);return t==null?n:ne(n,function(i){return Ae(t,r,i)})}var Ad=W(function(e,t){return se(e)?yn(e,t):[]}),bd=W(function(e){return gi(vt(e,se))}),Cd=W(function(e){var t=We(e);return se(t)&&(t=r),gi(vt(e,se),F(t,2))}),Td=W(function(e){var t=We(e);return t=typeof t=="function"?t:r,gi(vt(e,se),r,t)}),Rd=W(Pi);function Fd(e,t){return ya(e||[],t||[],mn)}function Pd(e,t){return ya(e||[],t||[],Sn)}var Ld=W(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,eo(e,n)});function to(e){var t=o(e);return t.__chain__=!0,t}function Od(e,t){return t(e),e}function pr(e,t){return t(e)}var Nd=lt(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(u){return ni(u,e)};return t>1||this.__actions__.length||!(i instanceof k)||!ct(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:pr,args:[a],thisArg:r}),new Ue(i,this.__chain__).thru(function(u){return t&&!u.length&&u.push(r),u}))});function $d(){return to(this)}function Ud(){return new Ue(this.value(),this.__chain__)}function Dd(){this.__values__===r&&(this.__values__=vo(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function Md(){return this}function Wd(e){for(var t,n=this;n instanceof Qn;){var i=ja(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function Bd(){var e=this.__wrapped__;if(e instanceof k){var t=e;return this.__actions__.length&&(t=new k(this)),t=t.reverse(),t.__actions__.push({func:pr,args:[Fi],thisArg:r}),new Ue(t,this.__chain__)}return this.thru(Fi)}function kd(){return ma(this.__wrapped__,this.__actions__)}var Vd=ar(function(e,t,n){Y.call(e,n)?++e[n]:ot(e,n,1)});function Gd(e,t,n){var i=N(e)?Fs:Lc;return n&&ve(e,t,n)&&(t=r),i(e,F(t,3))}function qd(e,t){var n=N(e)?vt:ea;return n(e,F(t,3))}var Hd=Ta(Ya),zd=Ta(Ja);function Kd(e,t){return de(gr(e,t),1)}function jd(e,t){return de(gr(e,t),Ct)}function Yd(e,t,n){return n=n===r?1:U(n),de(gr(e,t),n)}function no(e,t){var n=N(e)?Ne:wt;return n(e,F(t,3))}function ro(e,t){var n=N(e)?hl:Qs;return n(e,F(t,3))}var Jd=ar(function(e,t,n){Y.call(e,n)?e[n].push(t):ot(e,n,[t])});function Zd(e,t,n,i){e=_e(e)?e:Qt(e),n=n&&!i?U(n):0;var a=e.length;return n<0&&(n=ue(a+n,0)),wr(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&kt(e,t,n)>-1}var Xd=W(function(e,t,n){var i=-1,a=typeof t=="function",u=_e(e)?m(e.length):[];return wt(e,function(c){u[++i]=a?Ae(t,c,n):_n(c,t,n)}),u}),Qd=ar(function(e,t,n){ot(e,n,t)});function gr(e,t){var n=N(e)?ne:aa;return n(e,F(t,3))}function eh(e,t,n,i){return e==null?[]:(N(t)||(t=t==null?[]:[t]),n=i?r:n,N(n)||(n=n==null?[]:[n]),ca(e,t,n))}var th=ar(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function nh(e,t,n){var i=N(e)?Gr:Ns,a=arguments.length<3;return i(e,F(t,4),n,a,wt)}function rh(e,t,n){var i=N(e)?pl:Ns,a=arguments.length<3;return i(e,F(t,4),n,a,Qs)}function ih(e,t){var n=N(e)?vt:ea;return n(e,yr(F(t,3)))}function sh(e){var t=N(e)?Ys:Jc;return t(e)}function ah(e,t,n){(n?ve(e,t,n):t===r)?t=1:t=U(t);var i=N(e)?Cc:Zc;return i(e,t)}function oh(e){var t=N(e)?Tc:Qc;return t(e)}function uh(e){if(e==null)return 0;if(_e(e))return wr(e)?Gt(e):e.length;var t=pe(e);return t==Ve||t==Ge?e.size:ui(e).length}function lh(e,t,n){var i=N(e)?qr:ef;return n&&ve(e,t,n)&&(t=r),i(e,F(t,3))}var ch=W(function(e,t){if(e==null)return[];var n=t.length;return n>1&&ve(e,t[0],t[1])?t=[]:n>2&&ve(t[0],t[1],t[2])&&(t=[t[0]]),ca(e,de(t,1),[])}),vr=Gl||function(){return fe.Date.now()};function fh(e,t){if(typeof t!="function")throw new $e(I);return e=U(e),function(){if(--e<1)return t.apply(this,arguments)}}function io(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,ut(e,rt,r,r,r,r,t)}function so(e,t){var n;if(typeof t!="function")throw new $e(I);return e=U(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Li=W(function(e,t,n){var i=xe;if(n.length){var a=yt(n,Zt(Li));i|=Ie}return ut(e,i,t,n,a)}),ao=W(function(e,t,n){var i=xe|Je;if(n.length){var a=yt(n,Zt(ao));i|=Ie}return ut(t,i,e,n,a)});function oo(e,t,n){t=n?r:t;var i=ut(e,Le,r,r,r,r,r,t);return i.placeholder=oo.placeholder,i}function uo(e,t,n){t=n?r:t;var i=ut(e,bt,r,r,r,r,r,t);return i.placeholder=uo.placeholder,i}function lo(e,t,n){var i,a,u,c,h,g,S=0,x=!1,E=!1,A=!0;if(typeof e!="function")throw new $e(I);t=Be(t)||0,re(n)&&(x=!!n.leading,E="maxWait"in n,u=E?ue(Be(n.maxWait)||0,t):u,A="trailing"in n?!!n.trailing:A);function T(ae){var Ke=i,ht=a;return i=a=r,S=ae,c=e.apply(ht,Ke),c}function P(ae){return S=ae,h=En(B,t),x?T(ae):c}function M(ae){var Ke=ae-g,ht=ae-S,Ro=t-Ke;return E?he(Ro,u-ht):Ro}function L(ae){var Ke=ae-g,ht=ae-S;return g===r||Ke>=t||Ke<0||E&&ht>=u}function B(){var ae=vr();if(L(ae))return G(ae);h=En(B,M(ae))}function G(ae){return h=r,A&&i?T(ae):(i=a=r,c)}function Re(){h!==r&&_a(h),S=0,i=g=a=h=r}function me(){return h===r?c:G(vr())}function Fe(){var ae=vr(),Ke=L(ae);if(i=arguments,a=this,g=ae,Ke){if(h===r)return P(g);if(E)return _a(h),h=En(B,t),T(g)}return h===r&&(h=En(B,t)),c}return Fe.cancel=Re,Fe.flush=me,Fe}var dh=W(function(e,t){return Xs(e,1,t)}),hh=W(function(e,t,n){return Xs(e,Be(t)||0,n)});function ph(e){return ut(e,Ir)}function mr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new $e(I);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],u=n.cache;if(u.has(a))return u.get(a);var c=e.apply(this,i);return n.cache=u.set(a,c)||u,c};return n.cache=new(mr.Cache||at),n}mr.Cache=at;function yr(e){if(typeof e!="function")throw new $e(I);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function gh(e){return so(2,e)}var vh=tf(function(e,t){t=t.length==1&&N(t[0])?ne(t[0],be(F())):ne(de(t,1),be(F()));var n=t.length;return W(function(i){for(var a=-1,u=he(i.length,n);++a<u;)i[a]=t[a].call(this,i[a]);return Ae(e,this,i)})}),Oi=W(function(e,t){var n=yt(t,Zt(Oi));return ut(e,Ie,r,t,n)}),co=W(function(e,t){var n=yt(t,Zt(co));return ut(e,Ee,r,t,n)}),mh=lt(function(e,t){return ut(e,nn,r,r,r,t)});function yh(e,t){if(typeof e!="function")throw new $e(I);return t=t===r?t:U(t),W(e,t)}function _h(e,t){if(typeof e!="function")throw new $e(I);return t=t==null?0:ue(U(t),0),W(function(n){var i=n[t],a=It(n,0,t);return i&&mt(a,i),Ae(e,this,a)})}function wh(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new $e(I);return re(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),lo(e,t,{leading:i,maxWait:t,trailing:a})}function Sh(e){return io(e,1)}function xh(e,t){return Oi(mi(t),e)}function Ih(){if(!arguments.length)return[];var e=arguments[0];return N(e)?e:[e]}function Eh(e){return De(e,V)}function Ah(e,t){return t=typeof t=="function"?t:r,De(e,V,t)}function bh(e){return De(e,K|V)}function Ch(e,t){return t=typeof t=="function"?t:r,De(e,K|V,t)}function Th(e,t){return t==null||Zs(e,t,le(t))}function ze(e,t){return e===t||e!==e&&t!==t}var Rh=cr(si),Fh=cr(function(e,t){return e>=t}),Ut=ra((function(){return arguments})())?ra:function(e){return ie(e)&&Y.call(e,"callee")&&!Gs.call(e,"callee")},N=m.isArray,Ph=Es?be(Es):Mc;function _e(e){return e!=null&&_r(e.length)&&!ft(e)}function se(e){return ie(e)&&_e(e)}function Lh(e){return e===!0||e===!1||ie(e)&&ge(e)==rn}var Et=Hl||qi,Oh=As?be(As):Wc;function Nh(e){return ie(e)&&e.nodeType===1&&!An(e)}function $h(e){if(e==null)return!0;if(_e(e)&&(N(e)||typeof e=="string"||typeof e.splice=="function"||Et(e)||Xt(e)||Ut(e)))return!e.length;var t=pe(e);if(t==Ve||t==Ge)return!e.size;if(In(e))return!ui(e).length;for(var n in e)if(Y.call(e,n))return!1;return!0}function Uh(e,t){return wn(e,t)}function Dh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?wn(e,t,r,n):!!i}function Ni(e){if(!ie(e))return!1;var t=ge(e);return t==Pn||t==su||typeof e.message=="string"&&typeof e.name=="string"&&!An(e)}function Mh(e){return typeof e=="number"&&Hs(e)}function ft(e){if(!re(e))return!1;var t=ge(e);return t==Ln||t==Xi||t==iu||t==ou}function fo(e){return typeof e=="number"&&e==U(e)}function _r(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=gt}function re(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function ie(e){return e!=null&&typeof e=="object"}var ho=bs?be(bs):kc;function Wh(e,t){return e===t||oi(e,t,Ei(t))}function Bh(e,t,n){return n=typeof n=="function"?n:r,oi(e,t,Ei(t),n)}function kh(e){return po(e)&&e!=+e}function Vh(e){if(Af(e))throw new O(w);return ia(e)}function Gh(e){return e===null}function qh(e){return e==null}function po(e){return typeof e=="number"||ie(e)&&ge(e)==an}function An(e){if(!ie(e)||ge(e)!=it)return!1;var t=zn(e);if(t===null)return!0;var n=Y.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Vn.call(n)==Wl}var $i=Cs?be(Cs):Vc;function Hh(e){return fo(e)&&e>=-gt&&e<=gt}var go=Ts?be(Ts):Gc;function wr(e){return typeof e=="string"||!N(e)&&ie(e)&&ge(e)==un}function Te(e){return typeof e=="symbol"||ie(e)&&ge(e)==On}var Xt=Rs?be(Rs):qc;function zh(e){return e===r}function Kh(e){return ie(e)&&pe(e)==ln}function jh(e){return ie(e)&&ge(e)==lu}var Yh=cr(li),Jh=cr(function(e,t){return e<=t});function vo(e){if(!e)return[];if(_e(e))return wr(e)?qe(e):ye(e);if(dn&&e[dn])return Cl(e[dn]());var t=pe(e),n=t==Ve?Jr:t==Ge?Wn:Qt;return n(e)}function dt(e){if(!e)return e===0?e:0;if(e=Be(e),e===Ct||e===-Ct){var t=e<0?-1:1;return t*eu}return e===e?e:0}function U(e){var t=dt(e),n=t%1;return t===t?n?t-n:t:0}function mo(e){return e?Lt(U(e),0,Ze):0}function Be(e){if(typeof e=="number")return e;if(Te(e))return Rn;if(re(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=re(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$s(e);var n=Fu.test(e);return n||Lu.test(e)?cl(e.slice(2),n?2:8):Ru.test(e)?Rn:+e}function yo(e){return Qe(e,we(e))}function Zh(e){return e?Lt(U(e),-gt,gt):e===0?e:0}function j(e){return e==null?"":Ce(e)}var Xh=Yt(function(e,t){if(In(t)||_e(t)){Qe(t,le(t),e);return}for(var n in t)Y.call(t,n)&&mn(e,n,t[n])}),_o=Yt(function(e,t){Qe(t,we(t),e)}),Sr=Yt(function(e,t,n,i){Qe(t,we(t),e,i)}),Qh=Yt(function(e,t,n,i){Qe(t,le(t),e,i)}),ep=lt(ni);function tp(e,t){var n=jt(e);return t==null?n:Js(n,t)}var np=W(function(e,t){e=J(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&ve(t[0],t[1],a)&&(i=1);++n<i;)for(var u=t[n],c=we(u),h=-1,g=c.length;++h<g;){var S=c[h],x=e[S];(x===r||ze(x,Ht[S])&&!Y.call(e,S))&&(e[S]=u[S])}return e}),rp=W(function(e){return e.push(r,$a),Ae(wo,r,e)});function ip(e,t){return Ps(e,F(t,3),Xe)}function sp(e,t){return Ps(e,F(t,3),ii)}function ap(e,t){return e==null?e:ri(e,F(t,3),we)}function op(e,t){return e==null?e:ta(e,F(t,3),we)}function up(e,t){return e&&Xe(e,F(t,3))}function lp(e,t){return e&&ii(e,F(t,3))}function cp(e){return e==null?[]:nr(e,le(e))}function fp(e){return e==null?[]:nr(e,we(e))}function Ui(e,t,n){var i=e==null?r:Ot(e,t);return i===r?n:i}function dp(e,t){return e!=null&&Ma(e,t,Nc)}function Di(e,t){return e!=null&&Ma(e,t,$c)}var hp=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Gn.call(t)),e[t]=n},Wi(Se)),pp=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Gn.call(t)),Y.call(e,t)?e[t].push(n):e[t]=[n]},F),gp=W(_n);function le(e){return _e(e)?js(e):ui(e)}function we(e){return _e(e)?js(e,!0):Hc(e)}function vp(e,t){var n={};return t=F(t,3),Xe(e,function(i,a,u){ot(n,t(i,a,u),i)}),n}function mp(e,t){var n={};return t=F(t,3),Xe(e,function(i,a,u){ot(n,a,t(i,a,u))}),n}var yp=Yt(function(e,t,n){rr(e,t,n)}),wo=Yt(function(e,t,n,i){rr(e,t,n,i)}),_p=lt(function(e,t){var n={};if(e==null)return n;var i=!1;t=ne(t,function(u){return u=xt(u,e),i||(i=u.length>1),u}),Qe(e,xi(e),n),i&&(n=De(n,K|Ye|V,hf));for(var a=t.length;a--;)pi(n,t[a]);return n});function wp(e,t){return So(e,yr(F(t)))}var Sp=lt(function(e,t){return e==null?{}:Kc(e,t)});function So(e,t){if(e==null)return{};var n=ne(xi(e),function(i){return[i]});return t=F(t),fa(e,n,function(i,a){return t(i,a[0])})}function xp(e,t,n){t=xt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var u=e==null?r:e[et(t[i])];u===r&&(i=a,u=n),e=ft(u)?u.call(e):u}return e}function Ip(e,t,n){return e==null?e:Sn(e,t,n)}function Ep(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:Sn(e,t,n,i)}var xo=Oa(le),Io=Oa(we);function Ap(e,t,n){var i=N(e),a=i||Et(e)||Xt(e);if(t=F(t,4),n==null){var u=e&&e.constructor;a?n=i?new u:[]:re(e)?n=ft(u)?jt(zn(e)):{}:n={}}return(a?Ne:Xe)(e,function(c,h,g){return t(n,c,h,g)}),n}function bp(e,t){return e==null?!0:pi(e,t)}function Cp(e,t,n){return e==null?e:va(e,t,mi(n))}function Tp(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:va(e,t,mi(n),i)}function Qt(e){return e==null?[]:Yr(e,le(e))}function Rp(e){return e==null?[]:Yr(e,we(e))}function Fp(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=Be(n),n=n===n?n:0),t!==r&&(t=Be(t),t=t===t?t:0),Lt(Be(e),t,n)}function Pp(e,t,n){return t=dt(t),n===r?(n=t,t=0):n=dt(n),e=Be(e),Uc(e,t,n)}function Lp(e,t,n){if(n&&typeof n!="boolean"&&ve(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=dt(e),t===r?(t=e,e=0):t=dt(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=zs();return he(e+a*(t-e+ll("1e-"+((a+"").length-1))),t)}return fi(e,t)}var Op=Jt(function(e,t,n){return t=t.toLowerCase(),e+(n?Eo(t):t)});function Eo(e){return Mi(j(e).toLowerCase())}function Ao(e){return e=j(e),e&&e.replace(Nu,xl).replace(Qu,"")}function Np(e,t,n){e=j(e),t=Ce(t);var i=e.length;n=n===r?i:Lt(U(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function $p(e){return e=j(e),e&&pu.test(e)?e.replace(ts,Il):e}function Up(e){return e=j(e),e&&wu.test(e)?e.replace(Or,"\\$&"):e}var Dp=Jt(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),Mp=Jt(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),Wp=Ca("toLowerCase");function Bp(e,t,n){e=j(e),t=U(t);var i=t?Gt(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return lr(Jn(a),n)+e+lr(Yn(a),n)}function kp(e,t,n){e=j(e),t=U(t);var i=t?Gt(e):0;return t&&i<t?e+lr(t-i,n):e}function Vp(e,t,n){e=j(e),t=U(t);var i=t?Gt(e):0;return t&&i<t?lr(t-i,n)+e:e}function Gp(e,t,n){return n||t==null?t=0:t&&(t=+t),Yl(j(e).replace(Nr,""),t||0)}function qp(e,t,n){return(n?ve(e,t,n):t===r)?t=1:t=U(t),di(j(e),t)}function Hp(){var e=arguments,t=j(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var zp=Jt(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function Kp(e,t,n){return n&&typeof n!="number"&&ve(e,t,n)&&(t=n=r),n=n===r?Ze:n>>>0,n?(e=j(e),e&&(typeof t=="string"||t!=null&&!$i(t))&&(t=Ce(t),!t&&Vt(e))?It(qe(e),0,n):e.split(t,n)):[]}var jp=Jt(function(e,t,n){return e+(n?" ":"")+Mi(t)});function Yp(e,t,n){return e=j(e),n=n==null?0:Lt(U(n),0,e.length),t=Ce(t),e.slice(n,n+t.length)==t}function Jp(e,t,n){var i=o.templateSettings;n&&ve(e,t,n)&&(t=r),e=j(e),t=Sr({},t,i,Na);var a=Sr({},t.imports,i.imports,Na),u=le(a),c=Yr(a,u),h,g,S=0,x=t.interpolate||Nn,E="__p += '",A=Zr((t.escape||Nn).source+"|"+x.source+"|"+(x===ns?Tu:Nn).source+"|"+(t.evaluate||Nn).source+"|$","g"),T="//# sourceURL="+(Y.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++il+"]")+`
5
- `;e.replace(A,function(L,B,G,Re,me,Fe){return G||(G=Re),E+=e.slice(S,Fe).replace($u,El),B&&(h=!0,E+=`' +
6
- __e(`+B+`) +
7
- '`),me&&(g=!0,E+=`';
11
+ `)}function kf(e){return $(e)||Dt(e)||!!(Hs&&e&&e[Hs])}function ct(e,t){var n=typeof e;return t=t??gt,!!t&&(n=="number"||n!="symbol"&&Xu.test(e))&&e>-1&&e%1==0&&e<t}function ge(e,t,n){if(!te(n))return!1;var i=typeof t;return(i=="number"?ye(n)&&ct(t,n.length):i=="string"&&t in n)?ze(n[t],e):!1}function Ci(e,t){if($(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Te(e)?!0:Du.test(e)||!$u.test(e)||t!=null&&e in Y(t)}function Vf(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ti(e){var t=dr(e),n=o[t];if(typeof n!="function"||!(t in V.prototype))return!1;if(e===n)return!0;var i=Ei(n);return!!i&&e===i[0]}function Gf(e){return!!ks&&ks in e}var qf=Vn?ft:Hi;function En(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||zt;return e===n}function ka(e){return e===e&&!te(e)}function Va(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in Y(n))}}function Hf(e){var t=yr(e,function(i){return n.size===U&&n.clear(),i}),n=t.cache;return t}function zf(e,t){var n=e[1],i=t[1],a=n|i,u=a<(xe|Ye|rt),f=i==rt&&n==Fe||i==rt&&n==rn&&e[7].length<=t[8]||i==(rt|rn)&&t[7].length<=t[8]&&n==Fe;if(!(u||f))return e;i&xe&&(e[2]=t[2],a|=n&xe?0:Pn);var p=t[3];if(p){var g=e[3];e[3]=g?Ea(g,p,t[4]):p,e[4]=g?yt(e[3],D):t[4]}return p=t[5],p&&(g=e[5],e[5]=g?Aa(g,p,t[6]):p,e[6]=g?yt(e[5],D):t[6]),p=t[7],p&&(e[7]=p),i&rt&&(e[8]=e[8]==null?t[8]:fe(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=a,e}function Kf(e){var t=[];if(e!=null)for(var n in Y(e))t.push(n);return t}function jf(e){return qn.call(e)}function Ga(e,t,n){return t=ae(t===r?e.length-1:t,0),function(){for(var i=arguments,a=-1,u=ae(i.length-t,0),f=v(u);++a<u;)f[a]=i[t+a];a=-1;for(var p=v(t+1);++a<t;)p[a]=i[a];return p[t]=n(f),Ae(e,this,p)}}function qa(e,t){return t.length<2?e:Ot(e,De(t,0,-1))}function Yf(e,t){for(var n=e.length,i=fe(t.length,n),a=ve(e);i--;){var u=t[i];e[i]=ct(u,n)?a[u]:r}return e}function Pi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Ha=Ka(ha),An=lc||function(e,t){return le.setTimeout(e,t)},Ri=Ka(yf);function za(e,t,n){var i=t+"";return Ri(e,Bf(i,Jf(Df(i),n)))}function Ka(e){var t=0,n=0;return function(){var i=pc(),a=mu-(i-n);if(n=i,a>0){if(++t>=gu)return arguments[0]}else t=0;return e.apply(r,arguments)}}function hr(e,t){var n=-1,i=e.length,a=i-1;for(t=t===r?i:t;++n<t;){var u=di(n,a),f=e[u];e[u]=e[n],e[n]=f}return e.length=t,e}var ja=Hf(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Mu,function(n,i,a,u){t.push(a?u.replace(zu,"$1"):i||n)}),t});function Qe(e){if(typeof e=="string"||Te(e))return e;var t=e+"";return t=="0"&&1/e==-Tt?"-0":t}function $t(e){if(e!=null){try{return Gn.call(e)}catch{}try{return e+""}catch{}}return""}function Jf(e,t){return Ne(xu,function(n){var i="_."+n[0];t&n[1]&&!Mn(e,i)&&e.push(i)}),e.sort()}function Ya(e){if(e instanceof V)return e.clone();var t=new Ue(e.__wrapped__,e.__chain__);return t.__actions__=ve(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Zf(e,t,n){(n?ge(e,t,n):t===r)?t=1:t=ae(M(t),0);var i=e==null?0:e.length;if(!i||t<1)return[];for(var a=0,u=0,f=v(Jn(i/t));a<i;)f[u++]=De(e,a,a+=t);return f}function Xf(e){for(var t=-1,n=e==null?0:e.length,i=0,a=[];++t<n;){var u=e[t];u&&(a[i++]=u)}return a}function Qf(){var e=arguments.length;if(!e)return[];for(var t=v(e-1),n=arguments[0],i=e;i--;)t[i-1]=arguments[i];return vt($(n)?ve(n):[n],ce(t,1))}var ed=B(function(e,t){return re(e)?_n(e,ce(t,1,re,!0)):[]}),td=B(function(e,t){var n=Me(t);return re(n)&&(n=r),re(e)?_n(e,ce(t,1,re,!0),F(n,2)):[]}),nd=B(function(e,t){var n=Me(t);return re(n)&&(n=r),re(e)?_n(e,ce(t,1,re,!0),r,n):[]});function rd(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:M(t),De(e,t<0?0:t,i)):[]}function id(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:M(t),t=i-t,De(e,0,t<0?0:t)):[]}function sd(e,t){return e&&e.length?ar(e,F(t,3),!0,!0):[]}function ad(e,t){return e&&e.length?ar(e,F(t,3),!0):[]}function od(e,t,n,i){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&ge(e,t,n)&&(n=0,i=a),Xc(e,t,n,i)):[]}function Ja(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:M(n);return a<0&&(a=ae(i+a,0)),Wn(e,F(t,3),a)}function Za(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i-1;return n!==r&&(a=M(n),a=n<0?ae(i+a,0):fe(a,i-1)),Wn(e,F(t,3),a,!0)}function Xa(e){var t=e==null?0:e.length;return t?ce(e,1):[]}function ud(e){var t=e==null?0:e.length;return t?ce(e,Tt):[]}function ld(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:M(t),ce(e,t)):[]}function cd(e){for(var t=-1,n=e==null?0:e.length,i={};++t<n;){var a=e[t];i[a[0]]=a[1]}return i}function Qa(e){return e&&e.length?e[0]:r}function fd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=n==null?0:M(n);return a<0&&(a=ae(i+a,0)),Vt(e,t,a)}function dd(e){var t=e==null?0:e.length;return t?De(e,0,-1):[]}var pd=B(function(e){var t=ee(e,vi);return t.length&&t[0]===e[0]?oi(t):[]}),hd=B(function(e){var t=Me(e),n=ee(e,vi);return t===Me(n)?t=r:n.pop(),n.length&&n[0]===e[0]?oi(n,F(t,2)):[]}),gd=B(function(e){var t=Me(e),n=ee(e,vi);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?oi(n,r,t):[]});function md(e,t){return e==null?"":fc.call(e,t)}function Me(e){var t=e==null?0:e.length;return t?e[t-1]:r}function vd(e,t,n){var i=e==null?0:e.length;if(!i)return-1;var a=i;return n!==r&&(a=M(n),a=a<0?ae(i+a,0):fe(a,i-1)),t===t?Yl(e,t,a):Wn(e,Ns,a,!0)}function yd(e,t){return e&&e.length?ca(e,M(t)):r}var _d=B(eo);function eo(e,t){return e&&e.length&&t&&t.length?fi(e,t):e}function wd(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,F(n,2)):e}function Sd(e,t,n){return e&&e.length&&t&&t.length?fi(e,t,r,n):e}var xd=lt(function(e,t){var n=e==null?0:e.length,i=ri(e,t);return pa(e,ee(t,function(a){return ct(a,n)?+a:a}).sort(Ia)),i});function Id(e,t){var n=[];if(!(e&&e.length))return n;var i=-1,a=[],u=e.length;for(t=F(t,3);++i<u;){var f=e[i];t(f,i,e)&&(n.push(f),a.push(i))}return pa(e,a),n}function Fi(e){return e==null?e:gc.call(e)}function Ed(e,t,n){var i=e==null?0:e.length;return i?(n&&typeof n!="number"&&ge(e,t,n)?(t=0,n=i):(t=t==null?0:M(t),n=n===r?i:M(n)),De(e,t,n)):[]}function Ad(e,t){return sr(e,t)}function bd(e,t,n){return hi(e,t,F(n,2))}function Cd(e,t){var n=e==null?0:e.length;if(n){var i=sr(e,t);if(i<n&&ze(e[i],t))return i}return-1}function Td(e,t){return sr(e,t,!0)}function Pd(e,t,n){return hi(e,t,F(n,2),!0)}function Rd(e,t){var n=e==null?0:e.length;if(n){var i=sr(e,t,!0)-1;if(ze(e[i],t))return i}return-1}function Fd(e){return e&&e.length?ga(e):[]}function Ld(e,t){return e&&e.length?ga(e,F(t,2)):[]}function Nd(e){var t=e==null?0:e.length;return t?De(e,1,t):[]}function Od(e,t,n){return e&&e.length?(t=n||t===r?1:M(t),De(e,0,t<0?0:t)):[]}function Ud(e,t,n){var i=e==null?0:e.length;return i?(t=n||t===r?1:M(t),t=i-t,De(e,t<0?0:t,i)):[]}function $d(e,t){return e&&e.length?ar(e,F(t,3),!1,!0):[]}function Dd(e,t){return e&&e.length?ar(e,F(t,3)):[]}var Md=B(function(e){return St(ce(e,1,re,!0))}),Wd=B(function(e){var t=Me(e);return re(t)&&(t=r),St(ce(e,1,re,!0),F(t,2))}),Bd=B(function(e){var t=Me(e);return t=typeof t=="function"?t:r,St(ce(e,1,re,!0),r,t)});function kd(e){return e&&e.length?St(e):[]}function Vd(e,t){return e&&e.length?St(e,F(t,2)):[]}function Gd(e,t){return t=typeof t=="function"?t:r,e&&e.length?St(e,r,t):[]}function Li(e){if(!(e&&e.length))return[];var t=0;return e=mt(e,function(n){if(re(n))return t=ae(n.length,t),!0}),Yr(t,function(n){return ee(e,zr(n))})}function to(e,t){if(!(e&&e.length))return[];var n=Li(e);return t==null?n:ee(n,function(i){return Ae(t,r,i)})}var qd=B(function(e,t){return re(e)?_n(e,t):[]}),Hd=B(function(e){return mi(mt(e,re))}),zd=B(function(e){var t=Me(e);return re(t)&&(t=r),mi(mt(e,re),F(t,2))}),Kd=B(function(e){var t=Me(e);return t=typeof t=="function"?t:r,mi(mt(e,re),r,t)}),jd=B(Li);function Yd(e,t){return _a(e||[],t||[],yn)}function Jd(e,t){return _a(e||[],t||[],xn)}var Zd=B(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,to(e,n)});function no(e){var t=o(e);return t.__chain__=!0,t}function Xd(e,t){return t(e),e}function gr(e,t){return t(e)}var Qd=lt(function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,a=function(u){return ri(u,e)};return t>1||this.__actions__.length||!(i instanceof V)||!ct(n)?this.thru(a):(i=i.slice(n,+n+(t?1:0)),i.__actions__.push({func:gr,args:[a],thisArg:r}),new Ue(i,this.__chain__).thru(function(u){return t&&!u.length&&u.push(r),u}))});function ep(){return no(this)}function tp(){return new Ue(this.value(),this.__chain__)}function np(){this.__values__===r&&(this.__values__=vo(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function rp(){return this}function ip(e){for(var t,n=this;n instanceof er;){var i=Ya(n);i.__index__=0,i.__values__=r,t?a.__wrapped__=i:t=i;var a=i;n=n.__wrapped__}return a.__wrapped__=e,t}function sp(){var e=this.__wrapped__;if(e instanceof V){var t=e;return this.__actions__.length&&(t=new V(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Fi],thisArg:r}),new Ue(t,this.__chain__)}return this.thru(Fi)}function ap(){return ya(this.__wrapped__,this.__actions__)}var op=or(function(e,t,n){j.call(e,n)?++e[n]:ot(e,n,1)});function up(e,t,n){var i=$(e)?Fs:Zc;return n&&ge(e,t,n)&&(t=r),i(e,F(t,3))}function lp(e,t){var n=$(e)?mt:ta;return n(e,F(t,3))}var cp=Pa(Ja),fp=Pa(Za);function dp(e,t){return ce(mr(e,t),1)}function pp(e,t){return ce(mr(e,t),Tt)}function hp(e,t,n){return n=n===r?1:M(n),ce(mr(e,t),n)}function ro(e,t){var n=$(e)?Ne:wt;return n(e,F(t,3))}function io(e,t){var n=$(e)?Ll:ea;return n(e,F(t,3))}var gp=or(function(e,t,n){j.call(e,n)?e[n].push(t):ot(e,n,[t])});function mp(e,t,n,i){e=ye(e)?e:en(e),n=n&&!i?M(n):0;var a=e.length;return n<0&&(n=ae(a+n,0)),Sr(e)?n<=a&&e.indexOf(t,n)>-1:!!a&&Vt(e,t,n)>-1}var vp=B(function(e,t,n){var i=-1,a=typeof t=="function",u=ye(e)?v(e.length):[];return wt(e,function(f){u[++i]=a?Ae(t,f,n):wn(f,t,n)}),u}),yp=or(function(e,t,n){ot(e,n,t)});function mr(e,t){var n=$(e)?ee:oa;return n(e,F(t,3))}function _p(e,t,n,i){return e==null?[]:($(t)||(t=t==null?[]:[t]),n=i?r:n,$(n)||(n=n==null?[]:[n]),fa(e,t,n))}var wp=or(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function Sp(e,t,n){var i=$(e)?qr:Us,a=arguments.length<3;return i(e,F(t,4),n,a,wt)}function xp(e,t,n){var i=$(e)?Nl:Us,a=arguments.length<3;return i(e,F(t,4),n,a,ea)}function Ip(e,t){var n=$(e)?mt:ta;return n(e,_r(F(t,3)))}function Ep(e){var t=$(e)?Js:mf;return t(e)}function Ap(e,t,n){(n?ge(e,t,n):t===r)?t=1:t=M(t);var i=$(e)?zc:vf;return i(e,t)}function bp(e){var t=$(e)?Kc:_f;return t(e)}function Cp(e){if(e==null)return 0;if(ye(e))return Sr(e)?qt(e):e.length;var t=de(e);return t==Ve||t==Ge?e.size:li(e).length}function Tp(e,t,n){var i=$(e)?Hr:wf;return n&&ge(e,t,n)&&(t=r),i(e,F(t,3))}var Pp=B(function(e,t){if(e==null)return[];var n=t.length;return n>1&&ge(e,t[0],t[1])?t=[]:n>2&&ge(t[0],t[1],t[2])&&(t=[t[0]]),fa(e,ce(t,1),[])}),vr=uc||function(){return le.Date.now()};function Rp(e,t){if(typeof t!="function")throw new Oe(E);return e=M(e),function(){if(--e<1)return t.apply(this,arguments)}}function so(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,ut(e,rt,r,r,r,r,t)}function ao(e,t){var n;if(typeof t!="function")throw new Oe(E);return e=M(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Ni=B(function(e,t,n){var i=xe;if(n.length){var a=yt(n,Xt(Ni));i|=Ie}return ut(e,i,t,n,a)}),oo=B(function(e,t,n){var i=xe|Ye;if(n.length){var a=yt(n,Xt(oo));i|=Ie}return ut(t,i,e,n,a)});function uo(e,t,n){t=n?r:t;var i=ut(e,Fe,r,r,r,r,r,t);return i.placeholder=uo.placeholder,i}function lo(e,t,n){t=n?r:t;var i=ut(e,Ct,r,r,r,r,r,t);return i.placeholder=lo.placeholder,i}function co(e,t,n){var i,a,u,f,p,g,w=0,S=!1,I=!1,A=!0;if(typeof e!="function")throw new Oe(E);t=We(t)||0,te(n)&&(S=!!n.leading,I="maxWait"in n,u=I?ae(We(n.maxWait)||0,t):u,A="trailing"in n?!!n.trailing:A);function P(ie){var Ke=i,pt=a;return i=a=r,w=ie,f=e.apply(pt,Ke),f}function L(ie){return w=ie,p=An(k,t),S?P(ie):f}function W(ie){var Ke=ie-g,pt=ie-w,Ro=t-Ke;return I?fe(Ro,u-pt):Ro}function N(ie){var Ke=ie-g,pt=ie-w;return g===r||Ke>=t||Ke<0||I&&pt>=u}function k(){var ie=vr();if(N(ie))return G(ie);p=An(k,W(ie))}function G(ie){return p=r,A&&i?P(ie):(i=a=r,f)}function Pe(){p!==r&&wa(p),w=0,i=g=a=p=r}function me(){return p===r?f:G(vr())}function Re(){var ie=vr(),Ke=N(ie);if(i=arguments,a=this,g=ie,Ke){if(p===r)return L(g);if(I)return wa(p),p=An(k,t),P(g)}return p===r&&(p=An(k,t)),f}return Re.cancel=Pe,Re.flush=me,Re}var Fp=B(function(e,t){return Qs(e,1,t)}),Lp=B(function(e,t,n){return Qs(e,We(t)||0,n)});function Np(e){return ut(e,Er)}function yr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Oe(E);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],u=n.cache;if(u.has(a))return u.get(a);var f=e.apply(this,i);return n.cache=u.set(a,f)||u,f};return n.cache=new(yr.Cache||at),n}yr.Cache=at;function _r(e){if(typeof e!="function")throw new Oe(E);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function Op(e){return ao(2,e)}var Up=Sf(function(e,t){t=t.length==1&&$(t[0])?ee(t[0],be(F())):ee(ce(t,1),be(F()));var n=t.length;return B(function(i){for(var a=-1,u=fe(i.length,n);++a<u;)i[a]=t[a].call(this,i[a]);return Ae(e,this,i)})}),Oi=B(function(e,t){var n=yt(t,Xt(Oi));return ut(e,Ie,r,t,n)}),fo=B(function(e,t){var n=yt(t,Xt(fo));return ut(e,Ee,r,t,n)}),$p=lt(function(e,t){return ut(e,rn,r,r,r,t)});function Dp(e,t){if(typeof e!="function")throw new Oe(E);return t=t===r?t:M(t),B(e,t)}function Mp(e,t){if(typeof e!="function")throw new Oe(E);return t=t==null?0:ae(M(t),0),B(function(n){var i=n[t],a=It(n,0,t);return i&&vt(a,i),Ae(e,this,a)})}function Wp(e,t,n){var i=!0,a=!0;if(typeof e!="function")throw new Oe(E);return te(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),co(e,t,{leading:i,maxWait:t,trailing:a})}function Bp(e){return so(e,1)}function kp(e,t){return Oi(yi(t),e)}function Vp(){if(!arguments.length)return[];var e=arguments[0];return $(e)?e:[e]}function Gp(e){return $e(e,Se)}function qp(e,t){return t=typeof t=="function"?t:r,$e(e,Se,t)}function Hp(e){return $e(e,H|Se)}function zp(e,t){return t=typeof t=="function"?t:r,$e(e,H|Se,t)}function Kp(e,t){return t==null||Xs(e,t,oe(t))}function ze(e,t){return e===t||e!==e&&t!==t}var jp=fr(ai),Yp=fr(function(e,t){return e>=t}),Dt=ia((function(){return arguments})())?ia:function(e){return ne(e)&&j.call(e,"callee")&&!qs.call(e,"callee")},$=v.isArray,Jp=As?be(As):rf;function ye(e){return e!=null&&wr(e.length)&&!ft(e)}function re(e){return ne(e)&&ye(e)}function Zp(e){return e===!0||e===!1||ne(e)&&he(e)==sn}var Et=cc||Hi,Xp=bs?be(bs):sf;function Qp(e){return ne(e)&&e.nodeType===1&&!bn(e)}function eh(e){if(e==null)return!0;if(ye(e)&&($(e)||typeof e=="string"||typeof e.splice=="function"||Et(e)||Qt(e)||Dt(e)))return!e.length;var t=de(e);if(t==Ve||t==Ge)return!e.size;if(En(e))return!li(e).length;for(var n in e)if(j.call(e,n))return!1;return!0}function th(e,t){return Sn(e,t)}function nh(e,t,n){n=typeof n=="function"?n:r;var i=n?n(e,t):r;return i===r?Sn(e,t,r,n):!!i}function Ui(e){if(!ne(e))return!1;var t=he(e);return t==Ln||t==Eu||typeof e.message=="string"&&typeof e.name=="string"&&!bn(e)}function rh(e){return typeof e=="number"&&zs(e)}function ft(e){if(!te(e))return!1;var t=he(e);return t==Nn||t==Qi||t==Iu||t==bu}function po(e){return typeof e=="number"&&e==M(e)}function wr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=gt}function te(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function ne(e){return e!=null&&typeof e=="object"}var ho=Cs?be(Cs):of;function ih(e,t){return e===t||ui(e,t,Ai(t))}function sh(e,t,n){return n=typeof n=="function"?n:r,ui(e,t,Ai(t),n)}function ah(e){return go(e)&&e!=+e}function oh(e){if(qf(e))throw new O(x);return sa(e)}function uh(e){return e===null}function lh(e){return e==null}function go(e){return typeof e=="number"||ne(e)&&he(e)==on}function bn(e){if(!ne(e)||he(e)!=it)return!1;var t=Kn(e);if(t===null)return!0;var n=j.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Gn.call(n)==ic}var $i=Ts?be(Ts):uf;function ch(e){return po(e)&&e>=-gt&&e<=gt}var mo=Ps?be(Ps):lf;function Sr(e){return typeof e=="string"||!$(e)&&ne(e)&&he(e)==ln}function Te(e){return typeof e=="symbol"||ne(e)&&he(e)==On}var Qt=Rs?be(Rs):cf;function fh(e){return e===r}function dh(e){return ne(e)&&de(e)==cn}function ph(e){return ne(e)&&he(e)==Tu}var hh=fr(ci),gh=fr(function(e,t){return e<=t});function vo(e){if(!e)return[];if(ye(e))return Sr(e)?qe(e):ve(e);if(pn&&e[pn])return zl(e[pn]());var t=de(e),n=t==Ve?Zr:t==Ge?Bn:en;return n(e)}function dt(e){if(!e)return e===0?e:0;if(e=We(e),e===Tt||e===-Tt){var t=e<0?-1:1;return t*_u}return e===e?e:0}function M(e){var t=dt(e),n=t%1;return t===t?n?t-n:t:0}function yo(e){return e?Nt(M(e),0,Je):0}function We(e){if(typeof e=="number")return e;if(Te(e))return Rn;if(te(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=te(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$s(e);var n=Yu.test(e);return n||Zu.test(e)?Pl(e.slice(2),n?2:8):ju.test(e)?Rn:+e}function _o(e){return Xe(e,_e(e))}function mh(e){return e?Nt(M(e),-gt,gt):e===0?e:0}function K(e){return e==null?"":Ce(e)}var vh=Jt(function(e,t){if(En(t)||ye(t)){Xe(t,oe(t),e);return}for(var n in t)j.call(t,n)&&yn(e,n,t[n])}),wo=Jt(function(e,t){Xe(t,_e(t),e)}),xr=Jt(function(e,t,n,i){Xe(t,_e(t),e,i)}),yh=Jt(function(e,t,n,i){Xe(t,oe(t),e,i)}),_h=lt(ri);function wh(e,t){var n=Yt(e);return t==null?n:Zs(n,t)}var Sh=B(function(e,t){e=Y(e);var n=-1,i=t.length,a=i>2?t[2]:r;for(a&&ge(t[0],t[1],a)&&(i=1);++n<i;)for(var u=t[n],f=_e(u),p=-1,g=f.length;++p<g;){var w=f[p],S=e[w];(S===r||ze(S,zt[w])&&!j.call(e,w))&&(e[w]=u[w])}return e}),xh=B(function(e){return e.push(r,$a),Ae(So,r,e)});function Ih(e,t){return Ls(e,F(t,3),Ze)}function Eh(e,t){return Ls(e,F(t,3),si)}function Ah(e,t){return e==null?e:ii(e,F(t,3),_e)}function bh(e,t){return e==null?e:na(e,F(t,3),_e)}function Ch(e,t){return e&&Ze(e,F(t,3))}function Th(e,t){return e&&si(e,F(t,3))}function Ph(e){return e==null?[]:rr(e,oe(e))}function Rh(e){return e==null?[]:rr(e,_e(e))}function Di(e,t,n){var i=e==null?r:Ot(e,t);return i===r?n:i}function Fh(e,t){return e!=null&&Wa(e,t,Qc)}function Mi(e,t){return e!=null&&Wa(e,t,ef)}var Lh=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),e[t]=n},Bi(we)),Nh=Fa(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=qn.call(t)),j.call(e,t)?e[t].push(n):e[t]=[n]},F),Oh=B(wn);function oe(e){return ye(e)?Ys(e):li(e)}function _e(e){return ye(e)?Ys(e,!0):ff(e)}function Uh(e,t){var n={};return t=F(t,3),Ze(e,function(i,a,u){ot(n,t(i,a,u),i)}),n}function $h(e,t){var n={};return t=F(t,3),Ze(e,function(i,a,u){ot(n,a,t(i,a,u))}),n}var Dh=Jt(function(e,t,n){ir(e,t,n)}),So=Jt(function(e,t,n,i){ir(e,t,n,i)}),Mh=lt(function(e,t){var n={};if(e==null)return n;var i=!1;t=ee(t,function(u){return u=xt(u,e),i||(i=u.length>1),u}),Xe(e,Ii(e),n),i&&(n=$e(n,H|ht|Se,Lf));for(var a=t.length;a--;)gi(n,t[a]);return n});function Wh(e,t){return xo(e,_r(F(t)))}var Bh=lt(function(e,t){return e==null?{}:pf(e,t)});function xo(e,t){if(e==null)return{};var n=ee(Ii(e),function(i){return[i]});return t=F(t),da(e,n,function(i,a){return t(i,a[0])})}function kh(e,t,n){t=xt(t,e);var i=-1,a=t.length;for(a||(a=1,e=r);++i<a;){var u=e==null?r:e[Qe(t[i])];u===r&&(i=a,u=n),e=ft(u)?u.call(e):u}return e}function Vh(e,t,n){return e==null?e:xn(e,t,n)}function Gh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:xn(e,t,n,i)}var Io=Oa(oe),Eo=Oa(_e);function qh(e,t,n){var i=$(e),a=i||Et(e)||Qt(e);if(t=F(t,4),n==null){var u=e&&e.constructor;a?n=i?new u:[]:te(e)?n=ft(u)?Yt(Kn(e)):{}:n={}}return(a?Ne:Ze)(e,function(f,p,g){return t(n,f,p,g)}),n}function Hh(e,t){return e==null?!0:gi(e,t)}function zh(e,t,n){return e==null?e:va(e,t,yi(n))}function Kh(e,t,n,i){return i=typeof i=="function"?i:r,e==null?e:va(e,t,yi(n),i)}function en(e){return e==null?[]:Jr(e,oe(e))}function jh(e){return e==null?[]:Jr(e,_e(e))}function Yh(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=We(n),n=n===n?n:0),t!==r&&(t=We(t),t=t===t?t:0),Nt(We(e),t,n)}function Jh(e,t,n){return t=dt(t),n===r?(n=t,t=0):n=dt(n),e=We(e),tf(e,t,n)}function Zh(e,t,n){if(n&&typeof n!="boolean"&&ge(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=dt(e),t===r?(t=e,e=0):t=dt(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var a=Ks();return fe(e+a*(t-e+Tl("1e-"+((a+"").length-1))),t)}return di(e,t)}var Xh=Zt(function(e,t,n){return t=t.toLowerCase(),e+(n?Ao(t):t)});function Ao(e){return Wi(K(e).toLowerCase())}function bo(e){return e=K(e),e&&e.replace(Qu,kl).replace(yl,"")}function Qh(e,t,n){e=K(e),t=Ce(t);var i=e.length;n=n===r?i:Nt(M(n),0,i);var a=n;return n-=t.length,n>=0&&e.slice(n,a)==t}function eg(e){return e=K(e),e&&Nu.test(e)?e.replace(ns,Vl):e}function tg(e){return e=K(e),e&&Wu.test(e)?e.replace(Or,"\\$&"):e}var ng=Zt(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),rg=Zt(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),ig=Ta("toLowerCase");function sg(e,t,n){e=K(e),t=M(t);var i=t?qt(e):0;if(!t||i>=t)return e;var a=(t-i)/2;return cr(Zn(a),n)+e+cr(Jn(a),n)}function ag(e,t,n){e=K(e),t=M(t);var i=t?qt(e):0;return t&&i<t?e+cr(t-i,n):e}function og(e,t,n){e=K(e),t=M(t);var i=t?qt(e):0;return t&&i<t?cr(t-i,n)+e:e}function ug(e,t,n){return n||t==null?t=0:t&&(t=+t),hc(K(e).replace(Ur,""),t||0)}function lg(e,t,n){return(n?ge(e,t,n):t===r)?t=1:t=M(t),pi(K(e),t)}function cg(){var e=arguments,t=K(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var fg=Zt(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function dg(e,t,n){return n&&typeof n!="number"&&ge(e,t,n)&&(t=n=r),n=n===r?Je:n>>>0,n?(e=K(e),e&&(typeof t=="string"||t!=null&&!$i(t))&&(t=Ce(t),!t&&Gt(e))?It(qe(e),0,n):e.split(t,n)):[]}var pg=Zt(function(e,t,n){return e+(n?" ":"")+Wi(t)});function hg(e,t,n){return e=K(e),n=n==null?0:Nt(M(n),0,e.length),t=Ce(t),e.slice(n,n+t.length)==t}function gg(e,t,n){var i=o.templateSettings;n&&ge(e,t,n)&&(t=r),e=K(e),t=xr({},t,i,Ua);var a=xr({},t.imports,i.imports,Ua),u=oe(a),f=Jr(a,u),p,g,w=0,S=t.interpolate||Un,I="__p += '",A=Xr((t.escape||Un).source+"|"+S.source+"|"+(S===rs?Ku:Un).source+"|"+(t.evaluate||Un).source+"|$","g"),P="//# sourceURL="+(j.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Il+"]")+`
12
+ `;e.replace(A,function(N,k,G,Pe,me,Re){return G||(G=Pe),I+=e.slice(w,Re).replace(el,Gl),k&&(p=!0,I+=`' +
13
+ __e(`+k+`) +
14
+ '`),me&&(g=!0,I+=`';
8
15
  `+me+`;
9
- __p += '`),G&&(E+=`' +
16
+ __p += '`),G&&(I+=`' +
10
17
  ((__t = (`+G+`)) == null ? '' : __t) +
11
- '`),S=Fe+L.length,L}),E+=`';
12
- `;var P=Y.call(t,"variable")&&t.variable;if(!P)E=`with (obj) {
13
- `+E+`
18
+ '`),w=Re+N.length,N}),I+=`';
19
+ `;var L=j.call(t,"variable")&&t.variable;if(!L)I=`with (obj) {
20
+ `+I+`
14
21
  }
15
- `;else if(bu.test(P))throw new O(R);E=(g?E.replace(cu,""):E).replace(fu,"$1").replace(du,"$1;"),E="function("+(P||"obj")+`) {
16
- `+(P?"":`obj || (obj = {});
17
- `)+"var __t, __p = ''"+(h?", __e = _.escape":"")+(g?`, __j = Array.prototype.join;
22
+ `;else if(Hu.test(L))throw new O(C);I=(g?I.replace(Pu,""):I).replace(Ru,"$1").replace(Fu,"$1;"),I="function("+(L||"obj")+`) {
23
+ `+(L?"":`obj || (obj = {});
24
+ `)+"var __t, __p = ''"+(p?", __e = _.escape":"")+(g?`, __j = Array.prototype.join;
18
25
  function print() { __p += __j.call(arguments, '') }
19
26
  `:`;
20
- `)+E+`return __p
21
- }`;var M=Co(function(){return z(u,T+"return "+E).apply(r,c)});if(M.source=E,Ni(M))throw M;return M}function Zp(e){return j(e).toLowerCase()}function Xp(e){return j(e).toUpperCase()}function Qp(e,t,n){if(e=j(e),e&&(n||t===r))return $s(e);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=qe(t),u=Us(i,a),c=Ds(i,a)+1;return It(i,u,c).join("")}function eg(e,t,n){if(e=j(e),e&&(n||t===r))return e.slice(0,Ws(e)+1);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Ds(i,qe(t))+1;return It(i,0,a).join("")}function tg(e,t,n){if(e=j(e),e&&(n||t===r))return e.replace(Nr,"");if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Us(i,qe(t));return It(i,a).join("")}function ng(e,t){var n=jo,i=Yo;if(re(t)){var a="separator"in t?t.separator:a;n="length"in t?U(t.length):n,i="omission"in t?Ce(t.omission):i}e=j(e);var u=e.length;if(Vt(e)){var c=qe(e);u=c.length}if(n>=u)return e;var h=n-Gt(i);if(h<1)return i;var g=c?It(c,0,h).join(""):e.slice(0,h);if(a===r)return g+i;if(c&&(h+=g.length-h),$i(a)){if(e.slice(h).search(a)){var S,x=g;for(a.global||(a=Zr(a.source,j(rs.exec(a))+"g")),a.lastIndex=0;S=a.exec(x);)var E=S.index;g=g.slice(0,E===r?h:E)}}else if(e.indexOf(Ce(a),h)!=h){var A=g.lastIndexOf(a);A>-1&&(g=g.slice(0,A))}return g+i}function rg(e){return e=j(e),e&&hu.test(e)?e.replace(es,Pl):e}var ig=Jt(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Mi=Ca("toUpperCase");function bo(e,t,n){return e=j(e),t=n?r:t,t===r?bl(e)?Nl(e):ml(e):e.match(t)||[]}var Co=W(function(e,t){try{return Ae(e,r,t)}catch(n){return Ni(n)?n:new O(n)}}),sg=lt(function(e,t){return Ne(t,function(n){n=et(n),ot(e,n,Li(e[n],e))}),e});function ag(e){var t=e==null?0:e.length,n=F();return e=t?ne(e,function(i){if(typeof i[1]!="function")throw new $e(I);return[n(i[0]),i[1]]}):[],W(function(i){for(var a=-1;++a<t;){var u=e[a];if(Ae(u[0],this,i))return Ae(u[1],this,i)}})}function og(e){return Pc(De(e,K))}function Wi(e){return function(){return e}}function ug(e,t){return e==null||e!==e?t:e}var lg=Ra(),cg=Ra(!0);function Se(e){return e}function Bi(e){return sa(typeof e=="function"?e:De(e,K))}function fg(e){return oa(De(e,K))}function dg(e,t){return ua(e,De(t,K))}var hg=W(function(e,t){return function(n){return _n(n,e,t)}}),pg=W(function(e,t){return function(n){return _n(e,n,t)}});function ki(e,t,n){var i=le(t),a=nr(t,i);n==null&&!(re(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=nr(t,le(t)));var u=!(re(n)&&"chain"in n)||!!n.chain,c=ft(e);return Ne(a,function(h){var g=t[h];e[h]=g,c&&(e.prototype[h]=function(){var S=this.__chain__;if(u||S){var x=e(this.__wrapped__),E=x.__actions__=ye(this.__actions__);return E.push({func:g,args:arguments,thisArg:e}),x.__chain__=S,x}return g.apply(e,mt([this.value()],arguments))})}),e}function gg(){return fe._===this&&(fe._=Bl),this}function Vi(){}function vg(e){return e=U(e),W(function(t){return la(t,e)})}var mg=_i(ne),yg=_i(Fs),_g=_i(qr);function To(e){return bi(e)?Hr(et(e)):jc(e)}function wg(e){return function(t){return e==null?r:Ot(e,t)}}var Sg=Pa(),xg=Pa(!0);function Gi(){return[]}function qi(){return!1}function Ig(){return{}}function Eg(){return""}function Ag(){return!0}function bg(e,t){if(e=U(e),e<1||e>gt)return[];var n=Ze,i=he(e,Ze);t=F(t),e-=Ze;for(var a=jr(i,t);++n<e;)t(n);return a}function Cg(e){return N(e)?ne(e,et):Te(e)?[e]:ye(Ka(j(e)))}function Tg(e){var t=++Ml;return j(e)+t}var Rg=ur(function(e,t){return e+t},0),Fg=wi("ceil"),Pg=ur(function(e,t){return e/t},1),Lg=wi("floor");function Og(e){return e&&e.length?tr(e,Se,si):r}function Ng(e,t){return e&&e.length?tr(e,F(t,2),si):r}function $g(e){return Os(e,Se)}function Ug(e,t){return Os(e,F(t,2))}function Dg(e){return e&&e.length?tr(e,Se,li):r}function Mg(e,t){return e&&e.length?tr(e,F(t,2),li):r}var Wg=ur(function(e,t){return e*t},1),Bg=wi("round"),kg=ur(function(e,t){return e-t},0);function Vg(e){return e&&e.length?Kr(e,Se):0}function Gg(e,t){return e&&e.length?Kr(e,F(t,2)):0}return o.after=fh,o.ary=io,o.assign=Xh,o.assignIn=_o,o.assignInWith=Sr,o.assignWith=Qh,o.at=ep,o.before=so,o.bind=Li,o.bindAll=sg,o.bindKey=ao,o.castArray=Ih,o.chain=to,o.chunk=Lf,o.compact=Of,o.concat=Nf,o.cond=ag,o.conforms=og,o.constant=Wi,o.countBy=Vd,o.create=tp,o.curry=oo,o.curryRight=uo,o.debounce=lo,o.defaults=np,o.defaultsDeep=rp,o.defer=dh,o.delay=hh,o.difference=$f,o.differenceBy=Uf,o.differenceWith=Df,o.drop=Mf,o.dropRight=Wf,o.dropRightWhile=Bf,o.dropWhile=kf,o.fill=Vf,o.filter=qd,o.flatMap=Kd,o.flatMapDeep=jd,o.flatMapDepth=Yd,o.flatten=Za,o.flattenDeep=Gf,o.flattenDepth=qf,o.flip=ph,o.flow=lg,o.flowRight=cg,o.fromPairs=Hf,o.functions=cp,o.functionsIn=fp,o.groupBy=Jd,o.initial=Kf,o.intersection=jf,o.intersectionBy=Yf,o.intersectionWith=Jf,o.invert=hp,o.invertBy=pp,o.invokeMap=Xd,o.iteratee=Bi,o.keyBy=Qd,o.keys=le,o.keysIn=we,o.map=gr,o.mapKeys=vp,o.mapValues=mp,o.matches=fg,o.matchesProperty=dg,o.memoize=mr,o.merge=yp,o.mergeWith=wo,o.method=hg,o.methodOf=pg,o.mixin=ki,o.negate=yr,o.nthArg=vg,o.omit=_p,o.omitBy=wp,o.once=gh,o.orderBy=eh,o.over=mg,o.overArgs=vh,o.overEvery=yg,o.overSome=_g,o.partial=Oi,o.partialRight=co,o.partition=th,o.pick=Sp,o.pickBy=So,o.property=To,o.propertyOf=wg,o.pull=ed,o.pullAll=Qa,o.pullAllBy=td,o.pullAllWith=nd,o.pullAt=rd,o.range=Sg,o.rangeRight=xg,o.rearg=mh,o.reject=ih,o.remove=id,o.rest=yh,o.reverse=Fi,o.sampleSize=ah,o.set=Ip,o.setWith=Ep,o.shuffle=oh,o.slice=sd,o.sortBy=ch,o.sortedUniq=dd,o.sortedUniqBy=hd,o.split=Kp,o.spread=_h,o.tail=pd,o.take=gd,o.takeRight=vd,o.takeRightWhile=md,o.takeWhile=yd,o.tap=Od,o.throttle=wh,o.thru=pr,o.toArray=vo,o.toPairs=xo,o.toPairsIn=Io,o.toPath=Cg,o.toPlainObject=yo,o.transform=Ap,o.unary=Sh,o.union=_d,o.unionBy=wd,o.unionWith=Sd,o.uniq=xd,o.uniqBy=Id,o.uniqWith=Ed,o.unset=bp,o.unzip=Pi,o.unzipWith=eo,o.update=Cp,o.updateWith=Tp,o.values=Qt,o.valuesIn=Rp,o.without=Ad,o.words=bo,o.wrap=xh,o.xor=bd,o.xorBy=Cd,o.xorWith=Td,o.zip=Rd,o.zipObject=Fd,o.zipObjectDeep=Pd,o.zipWith=Ld,o.entries=xo,o.entriesIn=Io,o.extend=_o,o.extendWith=Sr,ki(o,o),o.add=Rg,o.attempt=Co,o.camelCase=Op,o.capitalize=Eo,o.ceil=Fg,o.clamp=Fp,o.clone=Eh,o.cloneDeep=bh,o.cloneDeepWith=Ch,o.cloneWith=Ah,o.conformsTo=Th,o.deburr=Ao,o.defaultTo=ug,o.divide=Pg,o.endsWith=Np,o.eq=ze,o.escape=$p,o.escapeRegExp=Up,o.every=Gd,o.find=Hd,o.findIndex=Ya,o.findKey=ip,o.findLast=zd,o.findLastIndex=Ja,o.findLastKey=sp,o.floor=Lg,o.forEach=no,o.forEachRight=ro,o.forIn=ap,o.forInRight=op,o.forOwn=up,o.forOwnRight=lp,o.get=Ui,o.gt=Rh,o.gte=Fh,o.has=dp,o.hasIn=Di,o.head=Xa,o.identity=Se,o.includes=Zd,o.indexOf=zf,o.inRange=Pp,o.invoke=gp,o.isArguments=Ut,o.isArray=N,o.isArrayBuffer=Ph,o.isArrayLike=_e,o.isArrayLikeObject=se,o.isBoolean=Lh,o.isBuffer=Et,o.isDate=Oh,o.isElement=Nh,o.isEmpty=$h,o.isEqual=Uh,o.isEqualWith=Dh,o.isError=Ni,o.isFinite=Mh,o.isFunction=ft,o.isInteger=fo,o.isLength=_r,o.isMap=ho,o.isMatch=Wh,o.isMatchWith=Bh,o.isNaN=kh,o.isNative=Vh,o.isNil=qh,o.isNull=Gh,o.isNumber=po,o.isObject=re,o.isObjectLike=ie,o.isPlainObject=An,o.isRegExp=$i,o.isSafeInteger=Hh,o.isSet=go,o.isString=wr,o.isSymbol=Te,o.isTypedArray=Xt,o.isUndefined=zh,o.isWeakMap=Kh,o.isWeakSet=jh,o.join=Zf,o.kebabCase=Dp,o.last=We,o.lastIndexOf=Xf,o.lowerCase=Mp,o.lowerFirst=Wp,o.lt=Yh,o.lte=Jh,o.max=Og,o.maxBy=Ng,o.mean=$g,o.meanBy=Ug,o.min=Dg,o.minBy=Mg,o.stubArray=Gi,o.stubFalse=qi,o.stubObject=Ig,o.stubString=Eg,o.stubTrue=Ag,o.multiply=Wg,o.nth=Qf,o.noConflict=gg,o.noop=Vi,o.now=vr,o.pad=Bp,o.padEnd=kp,o.padStart=Vp,o.parseInt=Gp,o.random=Lp,o.reduce=nh,o.reduceRight=rh,o.repeat=qp,o.replace=Hp,o.result=xp,o.round=Bg,o.runInContext=p,o.sample=sh,o.size=uh,o.snakeCase=zp,o.some=lh,o.sortedIndex=ad,o.sortedIndexBy=od,o.sortedIndexOf=ud,o.sortedLastIndex=ld,o.sortedLastIndexBy=cd,o.sortedLastIndexOf=fd,o.startCase=jp,o.startsWith=Yp,o.subtract=kg,o.sum=Vg,o.sumBy=Gg,o.template=Jp,o.times=bg,o.toFinite=dt,o.toInteger=U,o.toLength=mo,o.toLower=Zp,o.toNumber=Be,o.toSafeInteger=Zh,o.toString=j,o.toUpper=Xp,o.trim=Qp,o.trimEnd=eg,o.trimStart=tg,o.truncate=ng,o.unescape=rg,o.uniqueId=Tg,o.upperCase=ig,o.upperFirst=Mi,o.each=no,o.eachRight=ro,o.first=Xa,ki(o,(function(){var e={};return Xe(o,function(t,n){Y.call(o.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),o.VERSION=l,Ne(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){o[e].placeholder=o}),Ne(["drop","take"],function(e,t){k.prototype[e]=function(n){n=n===r?1:ue(U(n),0);var i=this.__filtered__&&!t?new k(this):this.clone();return i.__filtered__?i.__takeCount__=he(n,i.__takeCount__):i.__views__.push({size:he(n,Ze),type:e+(i.__dir__<0?"Right":"")}),i},k.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ne(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Zi||n==Qo;k.prototype[e]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:F(a,3),type:n}),u.__filtered__=u.__filtered__||i,u}}),Ne(["head","last"],function(e,t){var n="take"+(t?"Right":"");k.prototype[e]=function(){return this[n](1).value()[0]}}),Ne(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");k.prototype[e]=function(){return this.__filtered__?new k(this):this[n](1)}}),k.prototype.compact=function(){return this.filter(Se)},k.prototype.find=function(e){return this.filter(e).head()},k.prototype.findLast=function(e){return this.reverse().find(e)},k.prototype.invokeMap=W(function(e,t){return typeof e=="function"?new k(this):this.map(function(n){return _n(n,e,t)})}),k.prototype.reject=function(e){return this.filter(yr(F(e)))},k.prototype.slice=function(e,t){e=U(e);var n=this;return n.__filtered__&&(e>0||t<0)?new k(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=U(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},k.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},k.prototype.toArray=function(){return this.take(Ze)},Xe(k.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=o[i?"take"+(t=="last"?"Right":""):t],u=i||/^find/.test(t);a&&(o.prototype[t]=function(){var c=this.__wrapped__,h=i?[1]:arguments,g=c instanceof k,S=h[0],x=g||N(c),E=function(B){var G=a.apply(o,mt([B],h));return i&&A?G[0]:G};x&&n&&typeof S=="function"&&S.length!=1&&(g=x=!1);var A=this.__chain__,T=!!this.__actions__.length,P=u&&!A,M=g&&!T;if(!u&&x){c=M?c:new k(this);var L=e.apply(c,h);return L.__actions__.push({func:pr,args:[E],thisArg:r}),new Ue(L,A)}return P&&M?e.apply(this,h):(L=this.thru(E),P?i?L.value()[0]:L.value():L)})}),Ne(["pop","push","shift","sort","splice","unshift"],function(e){var t=Bn[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);o.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var u=this.value();return t.apply(N(u)?u:[],a)}return this[n](function(c){return t.apply(N(c)?c:[],a)})}}),Xe(k.prototype,function(e,t){var n=o[t];if(n){var i=n.name+"";Y.call(Kt,i)||(Kt[i]=[]),Kt[i].push({name:t,func:n})}}),Kt[or(r,Je).name]=[{name:"wrapper",func:r}],k.prototype.clone=nc,k.prototype.reverse=rc,k.prototype.value=ic,o.prototype.at=Nd,o.prototype.chain=$d,o.prototype.commit=Ud,o.prototype.next=Dd,o.prototype.plant=Wd,o.prototype.reverse=Bd,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=kd,o.prototype.first=o.prototype.head,dn&&(o.prototype[dn]=Md),o}),qt=$l();Tt?((Tt.exports=qt)._=qt,Br._=qt):fe._=qt}).call(iv)})(Cn,Cn.exports)),Cn.exports}var av=sv();const Hi=f=>{const s=av.startCase(f).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},ov=["src/application.config.ts","src/application-config.ts","src/applicationConfig.ts"],Oo=/serverVariables\s*:\s*\{/,uv=/defineApplication\s*\(\s*\{/,lv=async({projectRoot:f,variables:s})=>{const r=await cv(f);if(r===null)return{status:"skipped-no-config"};const l=await tt.readFile(r,"utf8"),d=s.filter(R=>!new RegExp(`\\b${R.name}\\s*:`).test(l));if(d.length===0)return{status:"skipped-existing"};const w=fv(d);if(Oo.test(l)){const R=l.replace(Oo,$=>`${$}
22
- ${w}`);return await tt.writeFile(r,R,"utf8"),{status:"appended",file:r}}if(!uv.test(l))return{status:"skipped-no-app-call"};const I=l.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(R,$)=>{const q=dv(d,$);return`
23
- ${$}${q}
24
- ${$}});
25
- `});return I===l?{status:"skipped-no-app-call"}:(await tt.writeFile(r,I,"utf8"),{status:"created",file:r})},cv=async f=>{for(const s of ov){const r=`${f}/${s}`;if(await v.pathExists(r))return r}return null},fv=f=>f.map(({name:s,description:r,isSecret:l})=>` ${s}: {
27
+ `)+I+`return __p
28
+ }`;var W=To(function(){return z(u,P+"return "+I).apply(r,f)});if(W.source=I,Ui(W))throw W;return W}function mg(e){return K(e).toLowerCase()}function vg(e){return K(e).toUpperCase()}function yg(e,t,n){if(e=K(e),e&&(n||t===r))return $s(e);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=qe(t),u=Ds(i,a),f=Ms(i,a)+1;return It(i,u,f).join("")}function _g(e,t,n){if(e=K(e),e&&(n||t===r))return e.slice(0,Bs(e)+1);if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Ms(i,qe(t))+1;return It(i,0,a).join("")}function wg(e,t,n){if(e=K(e),e&&(n||t===r))return e.replace(Ur,"");if(!e||!(t=Ce(t)))return e;var i=qe(e),a=Ds(i,qe(t));return It(i,a).join("")}function Sg(e,t){var n=pu,i=hu;if(te(t)){var a="separator"in t?t.separator:a;n="length"in t?M(t.length):n,i="omission"in t?Ce(t.omission):i}e=K(e);var u=e.length;if(Gt(e)){var f=qe(e);u=f.length}if(n>=u)return e;var p=n-qt(i);if(p<1)return i;var g=f?It(f,0,p).join(""):e.slice(0,p);if(a===r)return g+i;if(f&&(p+=g.length-p),$i(a)){if(e.slice(p).search(a)){var w,S=g;for(a.global||(a=Xr(a.source,K(is.exec(a))+"g")),a.lastIndex=0;w=a.exec(S);)var I=w.index;g=g.slice(0,I===r?p:I)}}else if(e.indexOf(Ce(a),p)!=p){var A=g.lastIndexOf(a);A>-1&&(g=g.slice(0,A))}return g+i}function xg(e){return e=K(e),e&&Lu.test(e)?e.replace(ts,Jl):e}var Ig=Zt(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Wi=Ta("toUpperCase");function Co(e,t,n){return e=K(e),t=n?r:t,t===r?Hl(e)?Ql(e):$l(e):e.match(t)||[]}var To=B(function(e,t){try{return Ae(e,r,t)}catch(n){return Ui(n)?n:new O(n)}}),Eg=lt(function(e,t){return Ne(t,function(n){n=Qe(n),ot(e,n,Ni(e[n],e))}),e});function Ag(e){var t=e==null?0:e.length,n=F();return e=t?ee(e,function(i){if(typeof i[1]!="function")throw new Oe(E);return[n(i[0]),i[1]]}):[],B(function(i){for(var a=-1;++a<t;){var u=e[a];if(Ae(u[0],this,i))return Ae(u[1],this,i)}})}function bg(e){return Jc($e(e,H))}function Bi(e){return function(){return e}}function Cg(e,t){return e==null||e!==e?t:e}var Tg=Ra(),Pg=Ra(!0);function we(e){return e}function ki(e){return aa(typeof e=="function"?e:$e(e,H))}function Rg(e){return ua($e(e,H))}function Fg(e,t){return la(e,$e(t,H))}var Lg=B(function(e,t){return function(n){return wn(n,e,t)}}),Ng=B(function(e,t){return function(n){return wn(e,n,t)}});function Vi(e,t,n){var i=oe(t),a=rr(t,i);n==null&&!(te(t)&&(a.length||!i.length))&&(n=t,t=e,e=this,a=rr(t,oe(t)));var u=!(te(n)&&"chain"in n)||!!n.chain,f=ft(e);return Ne(a,function(p){var g=t[p];e[p]=g,f&&(e.prototype[p]=function(){var w=this.__chain__;if(u||w){var S=e(this.__wrapped__),I=S.__actions__=ve(this.__actions__);return I.push({func:g,args:arguments,thisArg:e}),S.__chain__=w,S}return g.apply(e,vt([this.value()],arguments))})}),e}function Og(){return le._===this&&(le._=sc),this}function Gi(){}function Ug(e){return e=M(e),B(function(t){return ca(t,e)})}var $g=wi(ee),Dg=wi(Fs),Mg=wi(Hr);function Po(e){return Ci(e)?zr(Qe(e)):hf(e)}function Wg(e){return function(t){return e==null?r:Ot(e,t)}}var Bg=La(),kg=La(!0);function qi(){return[]}function Hi(){return!1}function Vg(){return{}}function Gg(){return""}function qg(){return!0}function Hg(e,t){if(e=M(e),e<1||e>gt)return[];var n=Je,i=fe(e,Je);t=F(t),e-=Je;for(var a=Yr(i,t);++n<e;)t(n);return a}function zg(e){return $(e)?ee(e,Qe):Te(e)?[e]:ve(ja(K(e)))}function Kg(e){var t=++rc;return K(e)+t}var jg=lr(function(e,t){return e+t},0),Yg=Si("ceil"),Jg=lr(function(e,t){return e/t},1),Zg=Si("floor");function Xg(e){return e&&e.length?nr(e,we,ai):r}function Qg(e,t){return e&&e.length?nr(e,F(t,2),ai):r}function em(e){return Os(e,we)}function tm(e,t){return Os(e,F(t,2))}function nm(e){return e&&e.length?nr(e,we,ci):r}function rm(e,t){return e&&e.length?nr(e,F(t,2),ci):r}var im=lr(function(e,t){return e*t},1),sm=Si("round"),am=lr(function(e,t){return e-t},0);function om(e){return e&&e.length?jr(e,we):0}function um(e,t){return e&&e.length?jr(e,F(t,2)):0}return o.after=Rp,o.ary=so,o.assign=vh,o.assignIn=wo,o.assignInWith=xr,o.assignWith=yh,o.at=_h,o.before=ao,o.bind=Ni,o.bindAll=Eg,o.bindKey=oo,o.castArray=Vp,o.chain=no,o.chunk=Zf,o.compact=Xf,o.concat=Qf,o.cond=Ag,o.conforms=bg,o.constant=Bi,o.countBy=op,o.create=wh,o.curry=uo,o.curryRight=lo,o.debounce=co,o.defaults=Sh,o.defaultsDeep=xh,o.defer=Fp,o.delay=Lp,o.difference=ed,o.differenceBy=td,o.differenceWith=nd,o.drop=rd,o.dropRight=id,o.dropRightWhile=sd,o.dropWhile=ad,o.fill=od,o.filter=lp,o.flatMap=dp,o.flatMapDeep=pp,o.flatMapDepth=hp,o.flatten=Xa,o.flattenDeep=ud,o.flattenDepth=ld,o.flip=Np,o.flow=Tg,o.flowRight=Pg,o.fromPairs=cd,o.functions=Ph,o.functionsIn=Rh,o.groupBy=gp,o.initial=dd,o.intersection=pd,o.intersectionBy=hd,o.intersectionWith=gd,o.invert=Lh,o.invertBy=Nh,o.invokeMap=vp,o.iteratee=ki,o.keyBy=yp,o.keys=oe,o.keysIn=_e,o.map=mr,o.mapKeys=Uh,o.mapValues=$h,o.matches=Rg,o.matchesProperty=Fg,o.memoize=yr,o.merge=Dh,o.mergeWith=So,o.method=Lg,o.methodOf=Ng,o.mixin=Vi,o.negate=_r,o.nthArg=Ug,o.omit=Mh,o.omitBy=Wh,o.once=Op,o.orderBy=_p,o.over=$g,o.overArgs=Up,o.overEvery=Dg,o.overSome=Mg,o.partial=Oi,o.partialRight=fo,o.partition=wp,o.pick=Bh,o.pickBy=xo,o.property=Po,o.propertyOf=Wg,o.pull=_d,o.pullAll=eo,o.pullAllBy=wd,o.pullAllWith=Sd,o.pullAt=xd,o.range=Bg,o.rangeRight=kg,o.rearg=$p,o.reject=Ip,o.remove=Id,o.rest=Dp,o.reverse=Fi,o.sampleSize=Ap,o.set=Vh,o.setWith=Gh,o.shuffle=bp,o.slice=Ed,o.sortBy=Pp,o.sortedUniq=Fd,o.sortedUniqBy=Ld,o.split=dg,o.spread=Mp,o.tail=Nd,o.take=Od,o.takeRight=Ud,o.takeRightWhile=$d,o.takeWhile=Dd,o.tap=Xd,o.throttle=Wp,o.thru=gr,o.toArray=vo,o.toPairs=Io,o.toPairsIn=Eo,o.toPath=zg,o.toPlainObject=_o,o.transform=qh,o.unary=Bp,o.union=Md,o.unionBy=Wd,o.unionWith=Bd,o.uniq=kd,o.uniqBy=Vd,o.uniqWith=Gd,o.unset=Hh,o.unzip=Li,o.unzipWith=to,o.update=zh,o.updateWith=Kh,o.values=en,o.valuesIn=jh,o.without=qd,o.words=Co,o.wrap=kp,o.xor=Hd,o.xorBy=zd,o.xorWith=Kd,o.zip=jd,o.zipObject=Yd,o.zipObjectDeep=Jd,o.zipWith=Zd,o.entries=Io,o.entriesIn=Eo,o.extend=wo,o.extendWith=xr,Vi(o,o),o.add=jg,o.attempt=To,o.camelCase=Xh,o.capitalize=Ao,o.ceil=Yg,o.clamp=Yh,o.clone=Gp,o.cloneDeep=Hp,o.cloneDeepWith=zp,o.cloneWith=qp,o.conformsTo=Kp,o.deburr=bo,o.defaultTo=Cg,o.divide=Jg,o.endsWith=Qh,o.eq=ze,o.escape=eg,o.escapeRegExp=tg,o.every=up,o.find=cp,o.findIndex=Ja,o.findKey=Ih,o.findLast=fp,o.findLastIndex=Za,o.findLastKey=Eh,o.floor=Zg,o.forEach=ro,o.forEachRight=io,o.forIn=Ah,o.forInRight=bh,o.forOwn=Ch,o.forOwnRight=Th,o.get=Di,o.gt=jp,o.gte=Yp,o.has=Fh,o.hasIn=Mi,o.head=Qa,o.identity=we,o.includes=mp,o.indexOf=fd,o.inRange=Jh,o.invoke=Oh,o.isArguments=Dt,o.isArray=$,o.isArrayBuffer=Jp,o.isArrayLike=ye,o.isArrayLikeObject=re,o.isBoolean=Zp,o.isBuffer=Et,o.isDate=Xp,o.isElement=Qp,o.isEmpty=eh,o.isEqual=th,o.isEqualWith=nh,o.isError=Ui,o.isFinite=rh,o.isFunction=ft,o.isInteger=po,o.isLength=wr,o.isMap=ho,o.isMatch=ih,o.isMatchWith=sh,o.isNaN=ah,o.isNative=oh,o.isNil=lh,o.isNull=uh,o.isNumber=go,o.isObject=te,o.isObjectLike=ne,o.isPlainObject=bn,o.isRegExp=$i,o.isSafeInteger=ch,o.isSet=mo,o.isString=Sr,o.isSymbol=Te,o.isTypedArray=Qt,o.isUndefined=fh,o.isWeakMap=dh,o.isWeakSet=ph,o.join=md,o.kebabCase=ng,o.last=Me,o.lastIndexOf=vd,o.lowerCase=rg,o.lowerFirst=ig,o.lt=hh,o.lte=gh,o.max=Xg,o.maxBy=Qg,o.mean=em,o.meanBy=tm,o.min=nm,o.minBy=rm,o.stubArray=qi,o.stubFalse=Hi,o.stubObject=Vg,o.stubString=Gg,o.stubTrue=qg,o.multiply=im,o.nth=yd,o.noConflict=Og,o.noop=Gi,o.now=vr,o.pad=sg,o.padEnd=ag,o.padStart=og,o.parseInt=ug,o.random=Zh,o.reduce=Sp,o.reduceRight=xp,o.repeat=lg,o.replace=cg,o.result=kh,o.round=sm,o.runInContext=h,o.sample=Ep,o.size=Cp,o.snakeCase=fg,o.some=Tp,o.sortedIndex=Ad,o.sortedIndexBy=bd,o.sortedIndexOf=Cd,o.sortedLastIndex=Td,o.sortedLastIndexBy=Pd,o.sortedLastIndexOf=Rd,o.startCase=pg,o.startsWith=hg,o.subtract=am,o.sum=om,o.sumBy=um,o.template=gg,o.times=Hg,o.toFinite=dt,o.toInteger=M,o.toLength=yo,o.toLower=mg,o.toNumber=We,o.toSafeInteger=mh,o.toString=K,o.toUpper=vg,o.trim=yg,o.trimEnd=_g,o.trimStart=wg,o.truncate=Sg,o.unescape=xg,o.uniqueId=Kg,o.upperCase=Ig,o.upperFirst=Wi,o.each=ro,o.eachRight=io,o.first=Qa,Vi(o,(function(){var e={};return Ze(o,function(t,n){j.call(o.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),o.VERSION=c,Ne(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){o[e].placeholder=o}),Ne(["drop","take"],function(e,t){V.prototype[e]=function(n){n=n===r?1:ae(M(n),0);var i=this.__filtered__&&!t?new V(this):this.clone();return i.__filtered__?i.__takeCount__=fe(n,i.__takeCount__):i.__views__.push({size:fe(n,Je),type:e+(i.__dir__<0?"Right":"")}),i},V.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ne(["filter","map","takeWhile"],function(e,t){var n=t+1,i=n==Xi||n==yu;V.prototype[e]=function(a){var u=this.clone();return u.__iteratees__.push({iteratee:F(a,3),type:n}),u.__filtered__=u.__filtered__||i,u}}),Ne(["head","last"],function(e,t){var n="take"+(t?"Right":"");V.prototype[e]=function(){return this[n](1).value()[0]}}),Ne(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");V.prototype[e]=function(){return this.__filtered__?new V(this):this[n](1)}}),V.prototype.compact=function(){return this.filter(we)},V.prototype.find=function(e){return this.filter(e).head()},V.prototype.findLast=function(e){return this.reverse().find(e)},V.prototype.invokeMap=B(function(e,t){return typeof e=="function"?new V(this):this.map(function(n){return wn(n,e,t)})}),V.prototype.reject=function(e){return this.filter(_r(F(e)))},V.prototype.slice=function(e,t){e=M(e);var n=this;return n.__filtered__&&(e>0||t<0)?new V(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=M(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},V.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},V.prototype.toArray=function(){return this.take(Je)},Ze(V.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=o[i?"take"+(t=="last"?"Right":""):t],u=i||/^find/.test(t);a&&(o.prototype[t]=function(){var f=this.__wrapped__,p=i?[1]:arguments,g=f instanceof V,w=p[0],S=g||$(f),I=function(k){var G=a.apply(o,vt([k],p));return i&&A?G[0]:G};S&&n&&typeof w=="function"&&w.length!=1&&(g=S=!1);var A=this.__chain__,P=!!this.__actions__.length,L=u&&!A,W=g&&!P;if(!u&&S){f=W?f:new V(this);var N=e.apply(f,p);return N.__actions__.push({func:gr,args:[I],thisArg:r}),new Ue(N,A)}return L&&W?e.apply(this,p):(N=this.thru(I),L?i?N.value()[0]:N.value():N)})}),Ne(["pop","push","shift","sort","splice","unshift"],function(e){var t=kn[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);o.prototype[e]=function(){var a=arguments;if(i&&!this.__chain__){var u=this.value();return t.apply($(u)?u:[],a)}return this[n](function(f){return t.apply($(f)?f:[],a)})}}),Ze(V.prototype,function(e,t){var n=o[t];if(n){var i=n.name+"";j.call(jt,i)||(jt[i]=[]),jt[i].push({name:t,func:n})}}),jt[ur(r,Ye).name]=[{name:"wrapper",func:r}],V.prototype.clone=Sc,V.prototype.reverse=xc,V.prototype.value=Ic,o.prototype.at=Qd,o.prototype.chain=ep,o.prototype.commit=tp,o.prototype.next=np,o.prototype.plant=ip,o.prototype.reverse=sp,o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=ap,o.prototype.first=o.prototype.head,pn&&(o.prototype[pn]=rp),o}),Ht=ec();Pt?((Pt.exports=Ht)._=Ht,kr._=Ht):le._=Ht}).call(Am)})(Cn,Cn.exports)),Cn.exports}var Cm=bm();const zi=l=>{const s=Cm.startCase(l).toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)},Tm=["src/application.config.ts","src/application-config.ts","src/applicationConfig.ts"],Uo=/serverVariables\s*:\s*\{/,Pm=/defineApplication\s*\(\s*\{/,Rm=async({projectRoot:l,variables:s})=>{const r=await Fm(l);if(r===null)return{status:"skipped-no-config"};const c=await tt.readFile(r,"utf8"),d=s.filter(C=>!new RegExp(`\\b${C.name}\\s*:`).test(c));if(d.length===0)return{status:"skipped-existing"};const x=Lm(d);if(Uo.test(c)){const C=c.replace(Uo,R=>`${R}
29
+ ${x}`);return await tt.writeFile(r,C,"utf8"),{status:"appended",file:r}}if(!Pm.test(c))return{status:"skipped-no-app-call"};const E=c.replace(/\n(\s*)\}\s*\)\s*;?\s*$/,(C,R)=>{const U=Nm(d,R);return`
30
+ ${R}${U}
31
+ ${R}});
32
+ `});return E===c?{status:"skipped-no-app-call"}:(await tt.writeFile(r,E,"utf8"),{status:"created",file:r})},Fm=async l=>{for(const s of Tm){const r=`${l}/${s}`;if(await m.pathExists(r))return r}return null},Lm=l=>l.map(({name:s,description:r,isSecret:c})=>` ${s}: {
26
33
  description: ${JSON.stringify(r)},
27
- isSecret: ${l},
34
+ isSecret: ${c},
28
35
  isRequired: true,
29
36
  },`).join(`
30
- `),dv=(f,s)=>`serverVariables: {
31
- ${f.map(({name:l,description:d,isSecret:w})=>`${s} ${l}: {
37
+ `),Nm=(l,s)=>`serverVariables: {
38
+ ${l.map(({name:c,description:d,isSecret:x})=>`${s} ${c}: {
32
39
  ${s} description: ${JSON.stringify(d)},
33
- ${s} isSecret: ${w},
40
+ ${s} isSecret: ${x},
34
41
  ${s} isRequired: true,
35
42
  ${s} },`).join(`
36
43
  `)}
37
- ${s}},`,hv=({data:f})=>{const s=te.v4(),r=f.description?`
38
- description: '${f.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk/define';
44
+ ${s}},`,Om=({data:l})=>{const s=Q.v4(),r=l.description?`
45
+ description: '${l.description}',`:"";return`import { defineField, FieldType } from 'twenty-sdk/define';
39
46
 
40
47
  export default defineField({
41
48
  universalIdentifier: '${s}',
42
- name: '${f.name}',
43
- label: '${f.label}',
44
- type: FieldType.${f.type},
45
- objectUniversalIdentifier: '${f.objectUniversalIdentifier}',${r}
49
+ name: '${l.name}',
50
+ label: '${l.label}',
51
+ type: FieldType.${l.type},
52
+ objectUniversalIdentifier: '${l.objectUniversalIdentifier}',${r}
46
53
  });
47
- `},ce=f=>f.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/([a-zA-Z])(\d)/g,"$1-$2").replace(/(\d)([a-zA-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase(),pv=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f);return`import { defineFrontComponent } from 'twenty-sdk/define';
54
+ `},ue=l=>l.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/([a-zA-Z])(\d)/g,"$1-$2").replace(/(\d)([a-zA-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").replace(/[^a-zA-Z0-9-]+/g,"-").toLowerCase(),Um=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l);return`import { defineFrontComponent } from 'twenty-sdk/define';
48
55
 
49
56
  // React component - implement your UI here
50
57
  const Component = () => {
@@ -62,7 +69,7 @@ export default defineFrontComponent({
62
69
  description: 'Add a description for your front component',
63
70
  component: Component,
64
71
  });
65
- `},gv=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f);return`import { defineLogicFunction } from 'twenty-sdk/define';
72
+ `},$m=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l);return`import { defineLogicFunction } from 'twenty-sdk/define';
66
73
 
67
74
  // Logic function handler - rename and implement your logic
68
75
  const handler = async (params: {
@@ -99,30 +106,30 @@ export default defineLogicFunction({
99
106
  // eventName: 'objectName.created',
100
107
  // },
101
108
  });
102
- `},No=({name:f,universalIdentifier:s=te.v4(),type:r,viewUniversalIdentifier:l,targetObjectUniversalIdentifier:d})=>{const w=ce(f);let I;return r==="OBJECT"&&d?I=` type: NavigationMenuItemType.OBJECT,
103
- targetObjectUniversalIdentifier: '${d}',`:r==="VIEW"&&l?I=` type: NavigationMenuItemType.VIEW,
104
- viewUniversalIdentifier: '${l}',`:r==="LINK"?I=` type: NavigationMenuItemType.LINK,
105
- link: 'https://example.com',`:r==="FOLDER"?I=" type: NavigationMenuItemType.FOLDER,":I=` type: NavigationMenuItemType.VIEW,
109
+ `},$o=({name:l,universalIdentifier:s=Q.v4(),type:r,viewUniversalIdentifier:c,targetObjectUniversalIdentifier:d})=>{const x=ue(l);let E;return r==="OBJECT"&&d?E=` type: NavigationMenuItemType.OBJECT,
110
+ targetObjectUniversalIdentifier: '${d}',`:r==="VIEW"&&c?E=` type: NavigationMenuItemType.VIEW,
111
+ viewUniversalIdentifier: '${c}',`:r==="LINK"?E=` type: NavigationMenuItemType.LINK,
112
+ link: 'https://example.com',`:r==="FOLDER"?E=" type: NavigationMenuItemType.FOLDER,":E=` type: NavigationMenuItemType.VIEW,
106
113
  // viewUniversalIdentifier: '...',`,`import { defineNavigationMenuItem, NavigationMenuItemType } from 'twenty-sdk/define';
107
114
 
108
115
  export default defineNavigationMenuItem({
109
116
  universalIdentifier: '${s}',
110
- name: '${w}',
117
+ name: '${x}',
111
118
  icon: 'IconList',
112
119
  position: 0,
113
- ${I}
120
+ ${E}
114
121
  });
115
- `},vv=({data:f,universalIdentifier:s=te.v4(),nameFieldUniversalIdentifier:r=te.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
122
+ `},Dm=({data:l,universalIdentifier:s=Q.v4(),nameFieldUniversalIdentifier:r=Q.v4()})=>`import { defineObject, FieldType } from 'twenty-sdk/define';
116
123
 
117
124
  export const NAME_FIELD_UNIVERSAL_IDENTIFIER =
118
125
  '${r}';
119
126
 
120
127
  export default defineObject({
121
128
  universalIdentifier: '${s}',
122
- nameSingular: '${f.nameSingular}',
123
- namePlural: '${f.namePlural}',
124
- labelSingular: '${f.labelSingular}',
125
- labelPlural: '${f.labelPlural}',
129
+ nameSingular: '${l.nameSingular}',
130
+ namePlural: '${l.namePlural}',
131
+ labelSingular: '${l.labelSingular}',
132
+ labelPlural: '${l.labelPlural}',
126
133
  icon: 'IconBox',
127
134
  labelIdentifierFieldMetadataUniversalIdentifier: NAME_FIELD_UNIVERSAL_IDENTIFIER,
128
135
  fields: [
@@ -131,61 +138,61 @@ export default defineObject({
131
138
  type: FieldType.TEXT,
132
139
  name: 'name',
133
140
  label: 'Name',
134
- description: 'Name of the ${f.nameSingular}',
141
+ description: 'Name of the ${l.nameSingular}',
135
142
  icon: 'IconAbc',
136
143
  },
137
144
  ],
138
145
  });
139
- `,mv=({name:f})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
146
+ `,Mm=({name:l})=>`import { defineCommandMenuItem } from 'twenty-sdk/define';
140
147
 
141
148
  export default defineCommandMenuItem({
142
- universalIdentifier: '${te.v4()}',
149
+ universalIdentifier: '${Q.v4()}',
143
150
  frontComponentUniversalIdentifier:
144
151
  'replace-with-existing-front-component-uuid',
145
- label: '${f}',
152
+ label: '${l}',
146
153
  availabilityType: 'GLOBAL',
147
154
  });
148
- `,yv=({name:f})=>`import { definePageLayout } from 'twenty-sdk/define';
155
+ `,Wm=({name:l})=>`import { definePageLayout } from 'twenty-sdk/define';
149
156
 
150
157
  export default definePageLayout({
151
- universalIdentifier: '${te.v4()}',
152
- name: '${f}',
158
+ universalIdentifier: '${Q.v4()}',
159
+ name: '${l}',
153
160
  tabs: [
154
161
  {
155
- universalIdentifier: '${te.v4()}',
162
+ universalIdentifier: '${Q.v4()}',
156
163
  title: 'Overview',
157
164
  widgets: [],
158
165
  },
159
166
  ],
160
167
  });
161
- `,_v=({name:f})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
168
+ `,Bm=({name:l})=>`import { definePageLayoutTab, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
162
169
 
163
170
  export default definePageLayoutTab({
164
- universalIdentifier: '${te.v4()}',
171
+ universalIdentifier: '${Q.v4()}',
165
172
  pageLayoutUniversalIdentifier: 'replace-with-existing-page-layout-uuid',
166
- title: '${f}',
173
+ title: '${l}',
167
174
  position: 1000,
168
175
  icon: 'IconLayout',
169
176
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
170
177
  widgets: [],
171
178
  });
172
- `,wv=({objectLabelSingular:f,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
179
+ `,km=({objectLabelSingular:l,objectUniversalIdentifier:s,fieldsWidgetViewUniversalIdentifier:r})=>`import { definePageLayout, PageLayoutTabLayoutMode } from 'twenty-sdk/define';
173
180
 
174
181
  export default definePageLayout({
175
- universalIdentifier: '${te.v4()}',
176
- name: 'Default ${f} Layout',
182
+ universalIdentifier: '${Q.v4()}',
183
+ name: 'Default ${l} Layout',
177
184
  type: 'RECORD_PAGE',
178
185
  objectUniversalIdentifier: '${s}',
179
186
  tabs: [
180
187
  {
181
- universalIdentifier: '${te.v4()}',
188
+ universalIdentifier: '${Q.v4()}',
182
189
  title: 'Home',
183
190
  position: 10,
184
191
  icon: 'IconHome',
185
192
  layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
186
193
  widgets: [
187
194
  {
188
- universalIdentifier: '${te.v4()}',
195
+ universalIdentifier: '${Q.v4()}',
189
196
  title: 'Fields',
190
197
  type: 'FIELDS',
191
198
  configuration: {
@@ -196,14 +203,14 @@ export default definePageLayout({
196
203
  ],
197
204
  },
198
205
  {
199
- universalIdentifier: '${te.v4()}',
206
+ universalIdentifier: '${Q.v4()}',
200
207
  title: 'Timeline',
201
208
  position: 20,
202
209
  icon: 'IconTimelineEvent',
203
210
  layoutMode: PageLayoutTabLayoutMode.CANVAS,
204
211
  widgets: [
205
212
  {
206
- universalIdentifier: '${te.v4()}',
213
+ universalIdentifier: '${Q.v4()}',
207
214
  title: 'Timeline',
208
215
  type: 'TIMELINE',
209
216
  configuration: {
@@ -214,21 +221,21 @@ export default definePageLayout({
214
221
  },
215
222
  ],
216
223
  });
217
- `,Sv=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f);return`import { defineRole } from 'twenty-sdk/define';
224
+ `,Vm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l);return`import { defineRole } from 'twenty-sdk/define';
218
225
 
219
226
  export const ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER =
220
227
  '${s}';
221
228
 
222
229
  export default defineRole({
223
230
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_ROLE_UNIVERSAL_IDENTIFIER,
224
- label: '${f}',
231
+ label: '${l}',
225
232
  description: 'Add a description for your role',
226
233
  canReadAllObjectRecords: true,
227
234
  canUpdateAllObjectRecords: true,
228
235
  canSoftDeleteAllObjectRecords: true,
229
236
  canDestroyAllObjectRecords: false,
230
237
  });
231
- `},xv=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f);return`import { defineAgent } from 'twenty-sdk/define';
238
+ `},Gm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l);return`import { defineAgent } from 'twenty-sdk/define';
232
239
 
233
240
  export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
234
241
  '${s}';
@@ -236,17 +243,17 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER =
236
243
  export default defineAgent({
237
244
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_AGENT_UNIVERSAL_IDENTIFIER,
238
245
  name: '${r}',
239
- label: '${f}',
246
+ label: '${l}',
240
247
  description: 'Add a description for your agent',
241
248
  prompt: 'Add the agent system prompt here',
242
249
  });
243
- `},Iv=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f),l=r.toUpperCase().replace(/-/g,"_"),d=f.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`import { defineConnectionProvider } from 'twenty-sdk/define';
250
+ `},qm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l),c=r.toUpperCase().replace(/-/g,"_"),d=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return`import { defineConnectionProvider } from 'twenty-sdk/define';
244
251
 
245
- export const ${l}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER =
252
+ export const ${c}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER =
246
253
  '${s}';
247
254
 
248
255
  export default defineConnectionProvider({
249
- universalIdentifier: ${l}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER,
256
+ universalIdentifier: ${c}_CONNECTION_PROVIDER_UNIVERSAL_IDENTIFIER,
250
257
  name: '${r}',
251
258
  displayName: '${d}',
252
259
  type: 'oauth',
@@ -256,11 +263,11 @@ export default defineConnectionProvider({
256
263
  tokenEndpoint: 'https://example.com/oauth/access_token',
257
264
  scopes: [],
258
265
  // Names of serverVariables declared on this app's defineApplication.
259
- clientIdVariable: '${l}_CLIENT_ID',
260
- clientSecretVariable: '${l}_CLIENT_SECRET',
266
+ clientIdVariable: '${c}_CLIENT_ID',
267
+ clientSecretVariable: '${c}_CLIENT_SECRET',
261
268
  },
262
269
  });
263
- `},Ev=({name:f,universalIdentifier:s=te.v4()})=>{const r=ce(f);return`import { defineSkill } from 'twenty-sdk/define';
270
+ `},Hm=({name:l,universalIdentifier:s=Q.v4()})=>{const r=ue(l);return`import { defineSkill } from 'twenty-sdk/define';
264
271
 
265
272
  export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
266
273
  '${s}';
@@ -268,21 +275,21 @@ export const ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER =
268
275
  export default defineSkill({
269
276
  universalIdentifier: ${r.toUpperCase().replace(/-/g,"_")}_SKILL_UNIVERSAL_IDENTIFIER,
270
277
  name: '${r}',
271
- label: '${f}',
278
+ label: '${l}',
272
279
  description: 'Add a description for your skill',
273
280
  content: 'Add the skill content here',
274
281
  });
275
- `},Av=({field:f,index:s,objectUniversalIdentifier:r})=>{const l=f.universalIdentifier??te.v4(),d=f.position??s,w=f.isVisible??!0,I=f.size??200,R="defaultFieldName"in f?` fieldMetadataUniversalIdentifier: generateDefaultFieldUniversalIdentifier({
282
+ `},zm=({field:l,index:s,objectUniversalIdentifier:r})=>{const c=l.universalIdentifier??Q.v4(),d=l.position??s,x=l.isVisible??!0,E=l.size??200,C="defaultFieldName"in l?` fieldMetadataUniversalIdentifier: generateDefaultFieldUniversalIdentifier({
276
283
  objectUniversalIdentifier: '${r}',
277
- fieldName: '${f.defaultFieldName}',
278
- })`:` fieldMetadataUniversalIdentifier: '${f.fieldMetadataUniversalIdentifier}'`;return` {
279
- universalIdentifier: '${l}',
280
- ${R},
284
+ fieldName: '${l.defaultFieldName}',
285
+ })`:` fieldMetadataUniversalIdentifier: '${l.fieldMetadataUniversalIdentifier}'`;return` {
286
+ universalIdentifier: '${c}',
287
+ ${C},
281
288
  position: ${d},
282
- isVisible: ${w},
283
- size: ${I},
284
- }`},zi=({name:f,universalIdentifier:s=te.v4(),objectUniversalIdentifier:r="fill-later",fields:l=[],type:d})=>{const w=ce(f),I=l.some(K=>"defaultFieldName"in K),$=l.length>0?` fields: [
285
- ${l.map((K,Ye)=>Av({field:K,index:Ye,objectUniversalIdentifier:r})).join(`,
289
+ isVisible: ${x},
290
+ size: ${E},
291
+ }`},Ki=({name:l,universalIdentifier:s=Q.v4(),objectUniversalIdentifier:r="fill-later",fields:c=[],type:d})=>{const x=ue(l),E=c.some(H=>"defaultFieldName"in H),R=c.length>0?` fields: [
292
+ ${c.map((H,ht)=>zm({field:H,index:ht,objectUniversalIdentifier:r})).join(`,
286
293
  `)},
287
294
  ],`:` // fields: [
288
295
  // {
@@ -291,19 +298,19 @@ ${l.map((K,Ye)=>Av({field:K,index:Ye,objectUniversalIdentifier:r})).join(`,
291
298
  // position: 0,
292
299
  // isVisible: true,
293
300
  // },
294
- // ],`,q=d!==void 0?` type: '${d}',
295
- `:"";return`${I?`import {
301
+ // ],`,U=d!==void 0?` type: '${d}',
302
+ `:"";return`${E?`import {
296
303
  defineView,
297
304
  generateDefaultFieldUniversalIdentifier,
298
305
  } from 'twenty-sdk/define';`:"import { defineView } from 'twenty-sdk/define';"}
299
306
 
300
307
  export default defineView({
301
308
  universalIdentifier: '${s}',
302
- name: '${w}',
309
+ name: '${x}',
303
310
  objectUniversalIdentifier: '${r}',
304
- ${q} icon: 'IconList',
311
+ ${U} icon: 'IconList',
305
312
  position: 0,
306
- ${$}
313
+ ${R}
307
314
  // filters: [
308
315
  // {
309
316
  // universalIdentifier: '...',
@@ -320,34 +327,27 @@ ${$}
320
327
  // },
321
328
  // ],
322
329
  });
323
- `},bv="src/application.config.ts",xr="src";class Cv{async execute(s,r){try{const l=s??await this.getEntity(),d=this.getFolderName(l),w=r?H.join(Q,r):H.join(Q,xr,d);await v.ensureDir(w);const{name:I,file:R}=await this.getEntityData(l),$=H.join(w,this.getFileName(I,l));if(await v.pathExists($)){const{overwrite:q}=await this.handleFileExist();if(!q)return}await tt.writeFile($,R),console.log(y.default.green(`✓ Created ${d}:`),y.default.cyan(H.relative(Q,$))),l===v.e.Object&&await this.promptAndCreateObjectCompanions(I,r),l===v.e.ConnectionProvider&&await this.registerConnectionProviderServerVariables(I)}catch(l){console.error(y.default.red("Add new entity failed:"),l instanceof Error?l.message:l),process.exit(1)}}async getEntityData(s){switch(s){case v.e.Object:{const r=await this.getObjectData(),l=r.nameSingular,d=te.v4(),w=te.v4();this.lastObjectUniversalIdentifier=d,this.lastNameFieldUniversalIdentifier=w,this.lastObjectLabelSingular=r.labelSingular;const I=vv({data:r,universalIdentifier:d,nameFieldUniversalIdentifier:w});return{name:l,file:I}}case v.e.Field:{const r=await this.getFieldData(),l=r.name,d=hv({data:r});return{name:l,file:d}}case v.e.LogicFunction:{const r=await this.getEntityName(s),l=gv({name:r});return{name:r,file:l}}case v.e.FrontComponent:{const r=await this.getEntityName(s),l=pv({name:r});return{name:r,file:l}}case v.e.Role:{const r=await this.getEntityName(s),l=Sv({name:r});return{name:r,file:l}}case v.e.Skill:{const r=await this.getEntityName(s),l=Ev({name:r});return{name:r,file:l}}case v.e.Agent:{const r=await this.getEntityName(s),l=xv({name:r});return{name:r,file:l}}case v.e.ConnectionProvider:{const r=await this.getEntityName(s),l=Iv({name:r});return{name:r,file:l}}case v.e.View:{const l=(await this.getViewData()).name,d=zi({name:l});return{name:l,file:d}}case v.e.NavigationMenuItem:{const r=await this.getEntityName(s),l=No({name:r});return{name:r,file:l}}case v.e.PageLayout:{const r=await this.getEntityName(s),l=yv({name:r});return{name:r,file:l}}case v.e.PageLayoutTab:{const r=await this.getEntityName(s),l=_v({name:r});return{name:r,file:l}}case v.e.CommandMenuItem:{const r=await this.getEntityName(s),l=mv({name:r});return{name:r,file:l}}default:v.v()}}async promptAndCreateObjectCompanions(s,r){const{createCompanions:l}=await je.default.prompt([{type:"confirm",name:"createCompanions",message:"Also create a view, navigation menu item, and record page layout for this object? (recommended)",default:!0}]);if(!l||!this.lastObjectUniversalIdentifier)return;const d=te.v4(),w=te.v4(),I=zi({name:`all-${ce(s)}`,universalIdentifier:d,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),R=r?H.join(Q,r):H.join(Q,xr,this.getFolderName(v.e.View));await v.ensureDir(R);const $=`all-${ce(s)}.ts`,q=H.join(R,$);if(await v.pathExists(q)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(q,I),console.log(y.default.green("✓ Created view:"),y.default.cyan(H.relative(Q,q)));const Z=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),K=zi({name:`${ce(s)}-record-page-fields`,universalIdentifier:w,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:v._E.FIELDS_WIDGET,fields:Z}),Ye=`${ce(s)}-record-page-fields.ts`,V=H.join(R,Ye);if(await v.pathExists(V)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(V,K),console.log(y.default.green("✓ Created record-page-fields view:"),y.default.cyan(H.relative(Q,V)));const D=No({name:s,type:"OBJECT",targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),Pe=r?H.join(Q,r):H.join(Q,xr,this.getFolderName(v.e.NavigationMenuItem));await v.ensureDir(Pe);const xe=`${ce(s)}.ts`,Je=H.join(Pe,xe);if(await v.pathExists(Je)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(Je,D),console.log(y.default.green("✓ Created navigation menu item:"),y.default.cyan(H.relative(Q,Je)));const Tn=wv({objectLabelSingular:this.lastObjectLabelSingular??s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:w}),Le=r?H.join(Q,r):H.join(Q,xr,this.getFolderName(v.e.PageLayout));await v.ensureDir(Le);const bt=`${ce(s)}-record-page-layout.ts`,Ie=H.join(Le,bt);if(await v.pathExists(Ie)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(Ie,Tn),console.log(y.default.green("✓ Created record page layout:"),y.default.cyan(H.relative(Q,Ie)))}async registerConnectionProviderServerVariables(s){const r=ce(s).toUpperCase().replace(/-/g,"_"),l=[{name:`${r}_CLIENT_ID`,description:"OAuth client ID issued by the third-party provider. Filled in once by the server admin on the application registration.",isSecret:!1},{name:`${r}_CLIENT_SECRET`,description:"OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.",isSecret:!0}],d=await lv({projectRoot:Q,variables:l});switch(d.status){case"appended":case"created":{console.log(y.default.green(`✓ Added ${l.map(w=>w.name).join(" + ")} to defineApplication.serverVariables:`),y.default.cyan(H.relative(Q,d.file)));break}case"skipped-existing":console.log(y.default.dim(` (${l.map(w=>w.name).join(" / ")} already declared on defineApplication.serverVariables)`));break;case"skipped-no-config":case"skipped-no-app-call":console.log(y.default.yellow(`! Couldn't auto-update ${bv}. Add these manually to defineApplication.serverVariables:
324
- `+l.map(w=>` ${w.name}: { description: '...', isSecret: ${w.isSecret}, isRequired: true },`).join(`
325
- `)));break}}buildRecordPageFieldsViewFields(s){const l=["createdAt","updatedAt","createdBy","updatedBy"].map(w=>({defaultFieldName:w,isVisible:!0,size:200}));return(s?[{fieldMetadataUniversalIdentifier:s,isVisible:!0,size:200},...l]:l).map((w,I)=>({...w,position:I}))}async getEntity(){const{entity:s}=await je.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(v.e)}]);return s}async handleFileExist(){return await je.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await je.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:l=>l.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return je.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>Hi(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(v.R),default:v.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return je.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>Hi(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>Hi(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return je.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this view belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${ce(s)}s`}getFileName(s,r){return r===v.e.FrontComponent?`${ce(s)}.tsx`:`${ce(s)}.ts`}}const Tv=async f=>{const s=H.join(f,"package.json");if(await v.pathExists(s))try{const r=await tt.readFile(s,"utf-8"),l=JSON.parse(r);return l.dependencies?.["twenty-sdk"]??l.devDependencies?.["twenty-sdk"]??void 0}catch{return}},$o=f=>{const s=f.match(/(\d+)\./);if(s)return parseInt(s[1],10);const r=f.match(/^[~^>=<]*(\d+)$/);return r?parseInt(r[1],10):null},en=async f=>{const s=v.packageJson.version,r=await Tv(f);if(!r)return;const l=$o(s),d=$o(r);l===null||d===null||l!==d&&(console.warn(y.default.yellow(`⚠ Version mismatch: your app requires twenty-sdk@${d}.x but the CLI running is v${s}. Major version mismatches may cause unexpected behavior.
326
- Update with: npm install -g twenty-sdk@${d}`)),console.warn(""))};class Rv{async execute(s){const r=s.appPath??Q;await en(r),console.log(y.default.blue("Building application...")),console.log(y.default.gray(`App path: ${r}
327
- `));const l=await v.appBuild({appPath:r,tarball:s.tarball,onProgress:d=>console.log(y.default.gray(d))});l.success||(console.error(y.default.red(l.error.message)),process.exit(1)),console.log(y.default.green(`✓ Build succeeded (${l.data.fileCount} file${l.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${l.data.outputDir}`)),l.data.tarballPath&&console.log(y.default.gray(`Tarball: ${l.data.tarballPath}`))}}class Go{async execute(s){s.remote&&v.ConfigService.setActiveRemote(s.remote),console.log(y.default.blue("Syncing marketplace catalog..."));const l=await new v.ApiService().syncMarketplaceCatalog();l.success||(console.error(y.default.red(`Catalog sync failed: ${l.error instanceof Error?l.error.message:String(l.error)}`)),process.exit(1)),console.log(y.default.green("✓ Marketplace catalog synced successfully"))}}class Fv{async execute(s){const r=s.appPath??Q;await en(r),console.log(y.default.blue("Deploying application...")),console.log(y.default.gray(`App path: ${r}
328
- `));const l=Z=>console.log(y.default.gray(Z)),d=await v.appBuild({appPath:r,tarball:!0,onProgress:l});d.success||(console.error(y.default.red(d.error.message)),process.exit(1));const w=await v.appDeploy({tarballPath:d.data.tarballPath,remote:s.remote,onProgress:l});w.success||(console.error(y.default.red(w.error.message)),process.exit(1));const I=await v.readJson(Yi.default.join(r,"package.json")).catch(()=>{}),R=I?.name??w.data.name,$=I?.version??"unknown",q=v.ConfigService.getActiveRemote();console.log(y.default.green(`
329
- Published ${R} v${$} to ${q}
330
- `)),console.log(" To install deployed application: `yarn twenty install`")}}class Pv{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const l=[{message:"Building manifest",status:"info"}],d=await v.buildAndValidateManifest(s.appPath);if(!d.success){for(const I of d.errors)l.push({message:I,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(l),null}if(d.warnings.length>0)for(const I of d.warnings)l.push({message:`⚠ ${I}`,status:"warning"});l.push({message:"Successfully built manifest",status:"success"});const w={manifest:d.manifest,filePaths:d.filePaths};return r.output={result:w},r.status="done",this.state.updatePipeline({appName:d.manifest.application.displayName}),this.state.updateEntitiesFromManifest(d.filePaths),this.state.applyStepEvents(l),w}}class Lv{constructor({apiService:s,state:r,notify:l}){this.hasRetried=!1,this.apiService=s,this.state=r,this.notify=l}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){const d=await v.detectLocalServer();return d&&!this.hasRetried?(this.hasRetried=!0,await new v.ConfigService().setConfig({apiUrl:d}),this.execute()):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:`Cannot reach Twenty server.
330
+ `},Km="src/application.config.ts",Ir="src";class iu{async execute(s,r){try{const c=s??await this.getEntity(),d=this.getFolderName(c),x=r?q.join(Z,r):q.join(Z,Ir,d);await m.ensureDir(x);const{name:E,file:C}=await this.getEntityData(c),R=q.join(x,this.getFileName(E,c));if(await m.pathExists(R)){const{overwrite:U}=await this.handleFileExist();if(!U)return}await tt.writeFile(R,C),console.log(y.default.green(`✓ Created ${d}:`),y.default.cyan(q.relative(Z,R))),c===m.e.Object&&await this.promptAndCreateObjectCompanions(E,r),c===m.e.ConnectionProvider&&await this.registerConnectionProviderServerVariables(E)}catch(c){console.error(y.default.red("Add new entity failed:"),c instanceof Error?c.message:c),process.exit(1)}}async getEntityData(s){switch(s){case m.e.Object:{const r=await this.getObjectData(),c=r.nameSingular,d=Q.v4(),x=Q.v4();this.lastObjectUniversalIdentifier=d,this.lastNameFieldUniversalIdentifier=x,this.lastObjectLabelSingular=r.labelSingular;const E=Dm({data:r,universalIdentifier:d,nameFieldUniversalIdentifier:x});return{name:c,file:E}}case m.e.Field:{const r=await this.getFieldData(),c=r.name,d=Om({data:r});return{name:c,file:d}}case m.e.LogicFunction:{const r=await this.getEntityName(s),c=$m({name:r});return{name:r,file:c}}case m.e.FrontComponent:{const r=await this.getEntityName(s),c=Um({name:r});return{name:r,file:c}}case m.e.Role:{const r=await this.getEntityName(s),c=Vm({name:r});return{name:r,file:c}}case m.e.Skill:{const r=await this.getEntityName(s),c=Hm({name:r});return{name:r,file:c}}case m.e.Agent:{const r=await this.getEntityName(s),c=Gm({name:r});return{name:r,file:c}}case m.e.ConnectionProvider:{const r=await this.getEntityName(s),c=qm({name:r});return{name:r,file:c}}case m.e.View:{const c=(await this.getViewData()).name,d=Ki({name:c});return{name:c,file:d}}case m.e.NavigationMenuItem:{const r=await this.getEntityName(s),c=$o({name:r});return{name:r,file:c}}case m.e.PageLayout:{const r=await this.getEntityName(s),c=Wm({name:r});return{name:r,file:c}}case m.e.PageLayoutTab:{const r=await this.getEntityName(s),c=Bm({name:r});return{name:r,file:c}}case m.e.CommandMenuItem:{const r=await this.getEntityName(s),c=Mm({name:r});return{name:r,file:c}}default:m.$()}}async promptAndCreateObjectCompanions(s,r){const{createCompanions:c}=await je.default.prompt([{type:"confirm",name:"createCompanions",message:"Also create a view, navigation menu item, and record page layout for this object? (recommended)",default:!0}]);if(!c||!this.lastObjectUniversalIdentifier)return;const d=Q.v4(),x=Q.v4(),E=Ki({name:`all-${ue(s)}`,universalIdentifier:d,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fields:this.lastNameFieldUniversalIdentifier?[{fieldMetadataUniversalIdentifier:this.lastNameFieldUniversalIdentifier,position:0,isVisible:!0,size:200}]:[]}),C=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.View));await m.ensureDir(C);const R=`all-${ue(s)}.ts`,U=q.join(C,R);if(await m.pathExists(U)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(U,E),console.log(y.default.green("✓ Created view:"),y.default.cyan(q.relative(Z,U)));const D=this.buildRecordPageFieldsViewFields(this.lastNameFieldUniversalIdentifier),H=Ki({name:`${ue(s)}-record-page-fields`,universalIdentifier:x,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,type:m._E.FIELDS_WIDGET,fields:D}),ht=`${ue(s)}-record-page-fields.ts`,Se=q.join(C,ht);if(await m.pathExists(Se)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(Se,H),console.log(y.default.green("✓ Created record-page-fields view:"),y.default.cyan(q.relative(Z,Se)));const ke=$o({name:s,type:"OBJECT",targetObjectUniversalIdentifier:this.lastObjectUniversalIdentifier}),bt=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.NavigationMenuItem));await m.ensureDir(bt);const xe=`${ue(s)}.ts`,Ye=q.join(bt,xe);if(await m.pathExists(Ye)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(Ye,ke),console.log(y.default.green("✓ Created navigation menu item:"),y.default.cyan(q.relative(Z,Ye)));const Pn=km({objectLabelSingular:this.lastObjectLabelSingular??s,objectUniversalIdentifier:this.lastObjectUniversalIdentifier,fieldsWidgetViewUniversalIdentifier:x}),Fe=r?q.join(Z,r):q.join(Z,Ir,this.getFolderName(m.e.PageLayout));await m.ensureDir(Fe);const Ct=`${ue(s)}-record-page-layout.ts`,Ie=q.join(Fe,Ct);if(await m.pathExists(Ie)){const{overwrite:Ee}=await this.handleFileExist();if(!Ee)return}await tt.writeFile(Ie,Pn),console.log(y.default.green("✓ Created record page layout:"),y.default.cyan(q.relative(Z,Ie)))}async registerConnectionProviderServerVariables(s){const r=ue(s).toUpperCase().replace(/-/g,"_"),c=[{name:`${r}_CLIENT_ID`,description:"OAuth client ID issued by the third-party provider. Filled in once by the server admin on the application registration.",isSecret:!1},{name:`${r}_CLIENT_SECRET`,description:"OAuth client secret issued by the third-party provider. Stored encrypted; never echoed in API responses.",isSecret:!0}],d=await Rm({projectRoot:Z,variables:c});switch(d.status){case"appended":case"created":{console.log(y.default.green(`✓ Added ${c.map(x=>x.name).join(" + ")} to defineApplication.serverVariables:`),y.default.cyan(q.relative(Z,d.file)));break}case"skipped-existing":console.log(y.default.dim(` (${c.map(x=>x.name).join(" / ")} already declared on defineApplication.serverVariables)`));break;case"skipped-no-config":case"skipped-no-app-call":console.log(y.default.yellow(`! Couldn't auto-update ${Km}. Add these manually to defineApplication.serverVariables:
331
+ `+c.map(x=>` ${x.name}: { description: '...', isSecret: ${x.isSecret}, isRequired: true },`).join(`
332
+ `)));break}}buildRecordPageFieldsViewFields(s){const c=["createdAt","updatedAt","createdBy","updatedBy"].map(x=>({defaultFieldName:x,isVisible:!0,size:200}));return(s?[{fieldMetadataUniversalIdentifier:s,isVisible:!0,size:200},...c]:c).map((x,E)=>({...x,position:E}))}async getEntity(){const{entity:s}=await je.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(m.e)}]);return s}async handleFileExist(){return await je.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(s){const{name:r}=await je.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${s}:`,default:"",validate:c=>c.length===0?`${s} name is required`:!0}]);return r}async getFieldData(){return je.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:s=>zi(s.name),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(m.R),default:m.R.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return je.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(s,r)=>s.trim()===r?.nameSingular.trim()?"Name plural must be different from name singular":!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:s=>zi(s.nameSingular),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:s=>zi(s.namePlural),validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}async getViewData(){return je.default.prompt([{type:"input",name:"name",message:"Enter a name for your view:",default:"",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this view belongs to:",default:"fill-later",validate:s=>!s||s.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(s){return`${ue(s)}s`}getFileName(s,r){return r===m.e.FrontComponent?`${ue(s)}.tsx`:`${ue(s)}.ts`}}class su{async execute(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Building application...")),console.log(y.default.gray(`App path: ${r}
333
+ `));const c=await m.appBuild({appPath:r,tarball:s.tarball,onProgress:d=>console.log(y.default.gray(d))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green(`✓ Build succeeded (${c.data.fileCount} file${c.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${c.data.outputDir}`)),c.data.tarballPath&&console.log(y.default.gray(`Tarball: ${c.data.tarballPath}`))}}class au{async execute({appPath:s=Z,postInstall:r=!1,preInstall:c=!1,functionUniversalIdentifier:d,functionName:x,payload:E="{}"}){let C;try{C=JSON.parse(E)}catch{console.error(y.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const R=r?"post install":c?"pre install":d??x;console.log(y.default.blue(`🚀 Executing function "${R}"...`)),console.log(y.default.gray(` Payload: ${JSON.stringify(C)}
334
+ `));const U=r?{appPath:s,postInstall:!0,payload:C}:c?{appPath:s,preInstall:!0,payload:C}:d?{appPath:s,functionUniversalIdentifier:d,payload:C}:{appPath:s,functionName:x,payload:C},D=await m.functionExecute(U);if(!D.success){switch(D.error.code){case m.APP_ERROR_CODES.MANIFEST_NOT_FOUND:{console.error(y.default.red("Failed to build manifest."));break}case m.FUNCTION_ERROR_CODES.FETCH_FUNCTIONS_FAILED:{console.error(y.default.red("Failed to fetch functions:"),D.error.message);break}case m.FUNCTION_ERROR_CODES.FUNCTION_NOT_FOUND:{console.error(y.default.red(D.error.message),`
335
+ `);const Se=D.error.details?.availableFunctions??[];Se.length>0?(console.log(y.default.cyan("Available functions:")),Se.forEach(ke=>{console.log(` - ${y.default.white(ke.name)} (${ke.universalIdentifier})`)})):console.log(y.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case m.FUNCTION_ERROR_CODES.EXECUTION_FAILED:{console.error(y.default.red("Execution failed:"),D.error.message);break}default:console.error(y.default.red(D.error.message))}process.exit(1)}const H=D.data;console.log(y.default.cyan("─".repeat(60))),console.log(y.default.cyan("Execution Result")),console.log(y.default.cyan("".repeat(60)));const ht=H.status==="SUCCESS"?y.default.green:y.default.red;console.log(`${y.default.bold("Status:")} ${ht(H.status)}`),console.log(`${y.default.bold("Duration:")} ${H.duration}ms
336
+ `),m.o(H.data)&&(console.log(y.default.bold("Data:")),console.log(y.default.white(JSON.stringify(H.data,null,2)))),H.error&&(console.log(y.default.bold.red("Error:")),console.log(y.default.red(` Type: ${H.error.errorType}`)),console.log(y.default.red(` Message: ${H.error.errorMessage}
337
+ `)),H.error.stackTrace&&(console.log(y.default.gray("Stack trace:")),console.log(y.default.gray(H.error.stackTrace)))),H.logs&&(console.log(y.default.bold("Logs:")),console.log(y.default.gray(H.logs))),console.log(y.default.cyan("".repeat(60))),H.status!=="SUCCESS"&&process.exit(1)}}class ou{constructor(){this.apiService=new m.ApiService}async execute({appPath:s=Z,functionUniversalIdentifier:r,functionName:c}){try{const d=await m.readManifestFromFile(s);d||process.exit(1),this.logWatchInfo({appName:d.application.displayName,functionUniversalIdentifier:r,functionName:c}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:d.application.universalIdentifier,functionUniversalIdentifier:r,functionName:c})}catch(d){console.error(y.default.red("Watch logs failed:"),d instanceof Error?d.message:d),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:c}){const d=s??"Twenty Application",x=r||c?`function "${r||c}"`:"functions";console.log(y.default.blue(`🚀 Watching ${d} ${x} logs:
338
+ `))}}const jm=l=>`${y.default.cyan(l.file)}:${y.default.yellow(String(l.line))}:${y.default.yellow(String(l.column+1))} - ${y.default.red("error")} ${l.text}`;class uu{async execute(s){const r=s.appPath??Z;console.log(y.default.blue("Running type check...")),console.log(y.default.gray(`App path: ${r}
339
+ `));const c=await m.runTypecheck(r);c.length===0&&(console.log(y.default.green("✓ No type errors found")),process.exit(0));for(const d of c)console.log(jm(d));console.log(`
340
+ `,y.default.red(`✗ Found ${c.length} type error${c.length===1?"":"s"}`)),process.exit(1)}}const et=(l,s)=>console.warn(y.default.yellow(`⚠ \`twenty ${l}\` is deprecated. Use \`twenty ${s}\` instead.`)),Ym=l=>{const s=new su,r=new uu,c=new ou,d=new au,x=new iu,E=new tu,C=new nu,R=new ru;l.command("build [appPath]",{hidden:!0}).option("--tarball","Also pack into a .tgz tarball").action(async(U,D)=>{et("build","dev:build"),await s.execute({appPath:pe(U),tarball:D.tarball})}),l.command("typecheck [appPath]",{hidden:!0}).action(async U=>{et("typecheck","dev:typecheck"),await r.execute({appPath:pe(U)})}),l.command("logs [appPath]",{hidden:!0}).option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Only show logs for the function with this universal ID").option("-n, --functionName <functionName>","Only show logs for the function with this name").action(async(U,D)=>{et("logs","dev:function:logs"),await c.execute({...D,appPath:pe(U)})}),l.command("exec [appPath]",{hidden:!0}).option("--postInstall","Execute post-install logic function if defined").option("--preInstall","Execute pre-install logic function if defined").option("-p, --payload <payload>","JSON payload to send to the function","{}").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Universal ID of the function to execute").option("-n, --functionName <functionName>","Name of the function to execute").action(async(U,D)=>{et("exec","dev:function:exec"),!D?.postInstall&&!D?.preInstall&&!D?.functionUniversalIdentifier&&!D?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await d.execute({...D,payload:D?.payload??"{}",appPath:pe(U)})}),l.command("add [entityType]",{hidden:!0}).option("--path <path>","Path in which the entity should be created.").action(async(U,D)=>{et("add","dev:add"),await x.execute(U,D?.path)}),l.command("publish [appPath]",{hidden:!0}).option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async(U,D)=>{et("publish","app:publish"),await E.execute({appPath:pe(U),tag:D.tag})}),l.command("deploy [appPath]",{hidden:!0}).option("-r, --remote <name>","Deploy to a specific remote").action(async(U,D)=>{et("deploy","app:publish --private"),await E.execute({appPath:pe(U),private:!0,remote:D.remote})}),l.command("install [appPath]",{hidden:!0}).option("-r, --remote <name>","Install on a specific remote").action(async(U,D)=>{et("install","app:install"),await C.execute({appPath:pe(U),remote:D.remote})}),l.command("uninstall [appPath]",{hidden:!0}).option("-y, --yes","Skip confirmation prompt").action(async(U,D)=>{et("uninstall","app:uninstall");try{const H=await R.execute({appPath:pe(U),askForConfirmation:!D?.yes});process.exit(H.success?0:1)}catch{process.exit(1)}}),l.command("catalog-sync",{hidden:!0}).option("-r, --remote <name>","Sync on a specific remote").action(async U=>{et("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:D}=await Promise.resolve().then(()=>require("./catalog-sync-CPVoL1dR.js"));await new D().execute({remote:U.remote})})};class Jm{constructor({state:s,notify:r}){this.state=s,this.notify=r}async execute(s){const r=this.state.steps.buildManifest;r.status="in_progress",this.state.updatePipeline({status:"building"});const c=[{message:"Building manifest",status:"info"}],d=await m.buildAndValidateManifest(s.appPath);if(!d.success){for(const E of d.errors)c.push({message:E,status:"error"});return r.output={result:null},r.status="error",this.state.updatePipeline({status:"error"}),this.state.applyStepEvents(c),null}if(d.warnings.length>0)for(const E of d.warnings)c.push({message:`⚠ ${E}`,status:"warning"});c.push({message:"Successfully built manifest",status:"success"});const x={manifest:d.manifest,filePaths:d.filePaths};return r.output={result:x},r.status="done",this.state.updatePipeline({appName:d.manifest.application.displayName}),this.state.updateEntitiesFromManifest(d.filePaths),this.state.applyStepEvents(c),x}}class Zm{constructor({apiService:s,state:r,notify:c}){this.hasRetried=!1,this.apiService=s,this.state=r,this.notify=c}async execute(){const s=this.state.steps.checkServer,r=await this.apiService.validateAuth();if(!r.serverUp){const d=await m.detectLocalServer();return d&&!this.hasRetried?(this.hasRetried=!0,await new m.ConfigService().setConfig({apiUrl:d}),this.execute()):(s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:`Cannot reach Twenty server.
331
341
 
332
342
  Start a local server:
333
- yarn twenty server start
343
+ yarn twenty docker:start
334
344
 
335
345
  Check server status:
336
- yarn twenty server status
346
+ yarn twenty docker:status
337
347
 
338
- Waiting for server...`,status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}if(!r.authValid)return s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote add --local` to authenticate.",status:"error"}]),this.state.updatePipeline({status:"error"})),!1;const l=s.output.isReady;return s.output={isReady:!0,errorLogged:!1},s.status="done",l||this.notify(),!0}}class Ov{constructor({clientService:s,configService:r,state:l,notify:d}){this.clientService=s,this.configService=r,this.state=l,this.notify=d}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const l=await v.ensureAppAccessTokenIsValidOrRefresh(this.configService,s.credentials);await this.clientService.generateCoreClient({appPath:s.appPath,appAccessToken:l}),r.status="done"}catch(l){this.state.applyStepEvents([{message:`Failed to generate API client: ${l instanceof Error?l.message:String(l)}`,status:"error"}]),r.status="error"}this.notify()}}class Nv{constructor({apiService:s,configService:r,state:l,notify:d}){this.apiService=s,this.configService=r,this.state=l,this.notify=d}async execute(s){try{const r=await v.ensureAppRegistration(this.apiService,this.configService,{name:s.manifest.application.displayName,universalIdentifier:s.manifest.application.universalIdentifier});this.registrationCredentials={clientId:r.clientId,clientSecret:r.clientSecret},this.state.applyStepEvents([{message:r.isNewRegistration?`App registration created: ${s.manifest.application.displayName}`:"Existing app registration found",status:r.isNewRegistration?"success":"info"},...r.isNewRegistration?[{message:"Credentials saved to config.",status:"info"}]:[]])}catch(r){throw this.state.applyStepEvents([{message:`Failed to register app: ${r instanceof Error?r.message:String(r)}`,status:"error"}]),r}this.notify()}}class Uo{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=(await Promise.all(this.watchPaths.map(async r=>{const l=H.join(this.appPath,r);return await v.pathExists(l)?l:null}))).filter(r=>r!==null);s.length!==0&&(this.watcher=ko.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(l),r==="unlink"&&this.handleUnlink(l))}))}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=H.relative(this.appPath,s),l=H.join(v.u,r),d=H.join(this.appPath,l);await v.ensureDir(H.dirname(d)),await v.copy(s,d);const w=await tt.readFile(d),I=rv.default.createHash("md5").update(w).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:l,sourcePath:r,checksum:I})}async handleUnlink(s){const r=H.relative(this.appPath,s),l=H.join(v.u,r),d=H.join(this.appPath,l);await v.remove(d)}}class $v{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=Po.default.join(this.appPath,"node_modules",".bin","tsc");if(!await v.pathExists(s))return;const r=Po.default.join(this.appPath,"tsconfig.json");this.process=bn.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",l=>{this.handleOutput(l.toString())}),this.process.stderr?.on("data",l=>{this.handleOutput(l.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
339
- `);this.buffer=r.pop()??"";for(const l of r)this.processLine(l)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const l=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||l)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=v.parseTscOutputLine(s);r&&this.pendingErrors.push(r)}}const Uv=new Set(["node_modules","dist",".twenty"]);class Dv{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected,this.verbose=s.verbose??!1}async start(){const s=this.appPath;this.watcher=ko.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:r=>{const l=H.relative(s,r);if(l==="")return!1;const d=l.split(Yi.default.sep)[0];return Uv.has(d)||d.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,l)=>{if(r==="addDir"||r==="unlinkDir")return;const d=H.relative(this.appPath,l),w=d.startsWith(v._),I=["package.json","yarn.lock"].includes(d);!(d.endsWith(".ts")||d.endsWith(".tsx"))&&!w&&!I||this.handleChangeDetected(d,r)})}async close(){await this.watcher?.close()}}class Mv{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt,this.shouldSkipTypecheck=s.shouldSkipTypecheck,this.verbose=s.verbose??!1}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new Dv({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:l}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,l);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(l)&&await this.frontComponentsWatcher.restart(l)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.verbose&&this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder,usesSdkClient:s.usesSdkClient}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=v.createLogicFunctionsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=v.createFrontComponentsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Uo({appPath:this.state.appPath,fileFolder:v.b.PublicAsset,watchPaths:[v._],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Uo({appPath:this.state.appPath,fileFolder:v.b.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new $v({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}class Wv{constructor({apiService:s,state:r,notify:l,verbose:d}){this.apiService=s,this.state=r,this.notify=l,this.verbose=d??!1}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const l=[],d=v.manifestUpdateChecksums({manifest:s.manifest,builtFileInfos:s.builtFileInfos});l.push({message:"Manifest checksums set",status:"info"}),await v.writeManifestToOutput(s.appPath,d),l.push({message:"Manifest saved to output directory",status:"info"}),l.push({message:"Syncing manifest",status:"info"});const w=await this.apiService.syncApplication(d);if(w.success){l.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(l);return}const I=this.verbose?null:v.formatManifestValidationErrors(w.error);I?(l.push(...I),l.push({message:"Add --verbose to see full error log",status:"info"})):l.push({message:`Sync failed with error: ${v.serializeError(w.error)}`,status:"error"});const R=I?I[0].message:"Sync failed";r.output={syncStatus:"error",error:R},r.status="error",this.state.updatePipeline({status:"error",error:R}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(l)}}class Bv{constructor({state:s,notify:r,verbose:l}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=s,this.notify=r,this.verbose=l??!1}get isInitialized(){return v.o(this.state.steps.uploadFiles.output.fileUploader)}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new v.FileUploader({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,l){const d=this.state.steps.uploadFiles;if(!d.output.fileUploader)return;d.status="in_progress",this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading"),this.notify();const w=d.output.fileUploader.uploadFile({builtPath:s,fileFolder:l}).then(I=>{I.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${s}: ${I.error}`,status:"error"}))}).catch(I=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${s}: ${I}`,status:"error"})}).finally(()=>{d.output.activeUploads.delete(w),d.output.activeUploads.size===0&&(this.logUploadSummary(),d.status="done",this.notify())});d.output.activeUploads.add(w)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:"error"}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount!==1?"s":""}`,status:"success"}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:l}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,l,r)}}class kv{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=s.debounceMs??2e3,this.state=s.state,this.verbose=s.verbose??!1,this.apiService=new v.ApiService({disableInterceptors:!0});const r=this.apiService,l=new v.ConfigService;this.clientService=new v.ClientService;const d={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Lv({...d,apiService:r}),this.buildManifestStep=new Pv(d),this.registerAppStep=new Nv({...d,apiService:r,configService:l}),this.uploadFilesStep=new Bv({...d,verbose:this.verbose}),this.generateApiClientStep=new Ov({...d,clientService:this.clientService,configService:l}),this.syncApplicationStep=new Wv({...d,apiService:r,verbose:this.verbose}),this.startWatchersStep=new Mv({...d,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){const s=Yi.default.join(this.state.appPath,v.u);await v.ensureDir(s),await v.emptyDir(s),this.verbose||(this.state.addEvent({message:"Add --verbose to see fully detailed logs",status:"info"}),this.state.notify()),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${v.serializeError(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status="done";const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const l=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!=="error"&&l&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(s){await this.registerAppStep.execute({manifest:s});const r=await this.apiService.createDevelopmentApplication({universalIdentifier:s.application.universalIdentifier,name:s.application.displayName});return!r.success||!r.data?(this.state.applyStepEvents([{message:"Failed to install development application",status:"error"},{message:JSON.stringify(r,null,2),status:"error"}]),this.state.updatePipeline({status:"error"}),!1):(this.state.steps.resolveApplication.output={applicationId:r.data.id,universalIdentifier:r.data.universalIdentifier},this.state.steps.resolveApplication.status="done",this.state.applyStepEvents([{message:"Application installed",status:"success"}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0)}}const Vv={objects:v.e.Object,fields:v.e.Field,logicFunctions:v.e.LogicFunction,frontComponents:v.e.FrontComponent,roles:v.e.Role,skills:v.e.Skill,connectionProviders:v.e.ConnectionProvider,views:v.e.View,navigationMenuItems:v.e.NavigationMenuItem,pageLayouts:v.e.PageLayout,pageLayoutTabs:v.e.PageLayoutTab,commandMenuItems:v.e.CommandMenuItem},Gv=200,qv={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class Hv{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.frontendUrl=s.frontendUrl,this.previousObjectsFieldsFingerprint=null,this.steps={checkServer:{output:{isReady:!1,errorLogged:!1},status:"idle"},ensureValidTokens:{output:{},status:"idle"},resolveApplication:{output:{applicationId:null,universalIdentifier:null},status:"idle"},buildManifest:{output:{result:null},status:"idle"},uploadFiles:{output:{fileUploader:null,builtFileInfos:new Map,activeUploads:new Set},status:"idle"},generateApiClient:{output:{},status:"idle"},syncApplication:{output:{syncStatus:"idle",error:null},status:"idle"},startWatchers:{output:{watchersStarted:!1},status:"idle"}},this.pipeline={status:"idle",isSyncing:!1,error:null,appName:null},this.versionInfo=null,this.entities=new Map,this.events=[]}setVersionInfo(s){this.versionInfo=s,this.notify()}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(l=>(this.eventIdCounter+=1,{...l,id:this.eventIdCounter,timestamp:new Date,message:l.message.slice(0,5e3)}));this.events=[...this.events.slice(-(Gv-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const l=new Map(this.entities),d=l.get(s);d?.status&&!qv[d.status].includes(r)||(l.set(s,d?{...d,status:r}:{name:s,path:s,status:r}),this.entities=l)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[l,d]of r)r.set(l,{...d,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[d,w]of Object.entries(s)){const I=Vv[d];if(I)for(const R of w)r.set(R,I)}const l=new Map(this.entities);for(const[d,w]of l)l.set(d,{...w,type:r.get(d)});for(const[d,w]of r)l.has(d)||l.set(d,{name:d,path:d,type:w,status:"pending"});this.entities=l}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),l=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,l}}const ke={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},zv=f=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[f],Kv=f=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[f],jv=f=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[f],Yv={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},Ki=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ji=["↑","⇡","↟","⤒"],qo={[v.e.Object]:"Objects",[v.e.Field]:"Fields",[v.e.LogicFunction]:"Logic functions",[v.e.FrontComponent]:"Front components",[v.e.CommandMenuItem]:"Command menu items",[v.e.Role]:"Roles",[v.e.Skill]:"Skills",[v.e.View]:"Views",[v.e.NavigationMenuItem]:"Navigation menu items",[v.e.PageLayout]:"Page layouts",[v.e.PageLayoutTab]:"Page layout tabs",[v.e.Agent]:"Agents",[v.e.ConnectionProvider]:"Connection providers"},Ho=Object.keys(qo),Jv={info:"gray",success:"green",error:"red",warning:"yellow"},Zv=f=>f.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),Xv=(f,s=40)=>{if(f.length<=s)return f;const r=f.split("/");return r.length<=2?f:`.../${r.slice(-2).join("/")}`},Qv=f=>{const s=new Map;for(const r of Ho)s.set(r,[]);for(const r of f.values()){if(!r.type)continue;const l=s.get(r.type)??[];l.push(r),s.set(r.type,l)}return s},em=f=>!f.frontendUrl||!f.steps.resolveApplication.output.universalIdentifier?null:`${f.frontendUrl}/settings/applications`,tm=f=>f.some(s=>s==="error")?"error":f.some(s=>s==="in_progress")?"in_progress":f.every(s=>s==="done")?"done":"idle",nm=f=>{const s=[...f.entities.values()],r=s.some(I=>I.status==="error"),l=s.some(I=>I.status==="building"),d=s.length>0&&s.every(I=>I.status==="uploading"||I.status==="success"),w=r?"error":l?"in_progress":d?"done":"idle";return[{label:"Application Initialization",status:tm([f.steps.checkServer.status,f.steps.ensureValidTokens.status,f.steps.resolveApplication.status])},{label:"Resources Build",status:w},{label:"Resources Upload",status:f.steps.uploadFiles.status},{label:"Manifest Build",status:f.steps.buildManifest.status},{label:"Application Synchronization",status:f.steps.syncApplication.status},{label:"Api Client Generation",status:f.steps.generateApiClient.status}]},zo=120,rm=Math.round(200/zo),Do=()=>{const f=Math.floor(Date.now()/zo);return{spinnerFrame:Ki[f%Ki.length],uploadFrame:ji[Math.floor(f/rm)%ji.length]}},Ji=f=>{const s=ke[f];return s.icon==="spinner"?Do().spinnerFrame:s.icon==="upload"?Do().uploadFrame:s.icon},Ko=Vo.default.createContext(null),im=Ko.Provider,nt=()=>{const f=Vo.default.useContext(Ko);if(!f)throw new Error("useInk must be used within InkProvider");return f},sm=({uiStatus:f})=>{const{Text:s}=nt(),r=Ji(f),l=ke[f];return C.jsxs(s,{color:l.color,children:[r," "]})},am=({entity:f})=>{const{Box:s,Text:r}=nt();return C.jsxs(s,{children:[C.jsx(sm,{uiStatus:Kv(f.status)}),C.jsx(r,{children:f.name}),f.path!==f.name&&C.jsxs(r,{dimColor:!0,children:[" (",Xv(f.path),")"]})]})},om=({type:f,entities:s})=>{const{Box:r,Text:l}=nt();return s.length===0?null:C.jsxs(r,{flexDirection:"column",marginTop:1,children:[C.jsx(l,{bold:!0,dimColor:!0,children:qo[f]}),s.map(d=>C.jsx(am,{entity:d},d.path))]})},um=()=>{const{Box:f,Text:s}=nt();return C.jsx(f,{marginTop:1,children:C.jsxs(s,{dimColor:!0,children:[C.jsx(s,{color:ke.idle.color,children:ke.idle.icon})," ","pending"," ",C.jsx(s,{color:ke.in_progress.color,children:Ki[0]})," ","building"," ",C.jsx(s,{color:ke.uploading.color,children:ji[0]})," ","uploading"," ",C.jsx(s,{color:ke.done.color,children:ke.done.icon})," ","success"," ",C.jsx(s,{color:ke.error.color,children:ke.error.icon})," ","error"]})})},lm=7,cm=({versionInfo:f})=>{const{Box:s,Text:r}=nt();if(f===null)return null;const{cliVersion:l,localServerVersion:d,latestServerVersion:w,isMinorOrMajorBehind:I,daysBehind:R}=f,$=I&&R!==null&&R>lm,q=d!==null&&w!==null&&d===w;return C.jsxs(s,{children:[C.jsx(r,{dimColor:!0,children:"Versions: "}),C.jsx(r,{dimColor:!0,children:"CLI "}),C.jsxs(r,{children:["v",l]}),d!==null&&C.jsxs(C.Fragment,{children:[C.jsx(r,{dimColor:!0,children:" • Server "}),C.jsxs(r,{color:$?"yellow":void 0,children:["v",d]}),q&&C.jsx(r,{color:"green",children:" ✓ latest"}),$&&w!==null&&C.jsxs(C.Fragment,{children:[C.jsxs(r,{color:"yellow",children:[" → v",w]}),R!==null&&C.jsxs(r,{dimColor:!0,children:[" (",R,"d behind)"]})]})]})]})},fm=({state:f})=>{const{Text:s}=nt(),r=jv(f.pipeline.status),l=Ji(r),d=ke[r],w=Yv[f.pipeline.status];return C.jsxs(s,{color:d.color,children:[l," ",w]})},dm=({label:f,status:s})=>{const{Box:r,Text:l}=nt(),d=zv(s),w=Ji(d),I=ke[d];return C.jsxs(r,{children:[C.jsxs(l,{dimColor:!0,children:[f,": "]}),C.jsxs(l,{color:I.color,children:[w," ",s.replace("_"," ")]})]})},hm=({state:f})=>{const{Box:s,Text:r}=nt(),l=Qv(f.entities),d=em(f);return C.jsxs(s,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[C.jsx(r,{bold:!0,color:"cyan",children:"Application"}),C.jsxs(s,{marginLeft:2,flexDirection:"column",children:[C.jsxs(s,{children:[C.jsx(r,{dimColor:!0,children:"Name: "}),C.jsx(r,{bold:!0,children:f.pipeline.appName??"Loading..."})]}),C.jsxs(s,{children:[C.jsx(r,{dimColor:!0,children:"Overall Status: "}),C.jsx(fm,{state:f})]}),d&&C.jsxs(s,{children:[C.jsx(r,{dimColor:!0,children:"Open:"}),C.jsxs(r,{bold:!0,color:"cyan",children:[" ",d]})]}),C.jsx(cm,{versionInfo:f.versionInfo})]}),C.jsx(s,{marginLeft:2,flexDirection:"column",marginTop:1,children:nm(f).map(w=>C.jsx(dm,{label:w.label,status:w.status},w.label))}),C.jsx(s,{marginLeft:2,flexDirection:"column",children:Ho.map(w=>{const I=l.get(w)??[];return C.jsx(om,{type:w,entities:I},w)})})]})},pm=({event:f})=>{const{Box:s,Text:r}=nt(),l=Jv[f.status],d=Zv(f.timestamp);return C.jsxs(s,{children:[C.jsxs(r,{dimColor:!0,children:[d," "]}),C.jsx(r,{color:l,children:f.message})]})},gm=new Set(["building","syncing"]),Mo=120,vm=80,mm=({uiStateManager:f})=>{const{Box:s,Static:r}=nt(),[,l]=At.useReducer($=>$+1,0),d=At.useRef(null),w=At.useRef(0),I=At.useCallback(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,w.current=Date.now(),l()},vm)},[]);At.useEffect(()=>f.subscribe(()=>{I()}),[f,I]),At.useEffect(()=>{const $=setInterval(()=>{const q=f.getSnapshot();gm.has(q.pipeline.status)&&(Date.now()-w.current<Mo||l())},Mo);return()=>clearInterval($)},[f]),At.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const R=f.getSnapshot();return C.jsxs(C.Fragment,{children:[C.jsx(r,{items:R.events,children:$=>C.jsx(pm,{event:$},$.id)}),C.jsxs(s,{marginTop:1,flexDirection:"column",children:[C.jsx(hm,{state:R}),C.jsx(um,{})]})]})},ym=async f=>{const s=await import("ink"),{render:r,Box:l,Text:d,Static:w}=s,{unmount:I}=r(C.jsx(im,{value:{Box:l,Text:d,Static:w},children:C.jsx(mm,{uiStateManager:f})}),{incrementalRendering:!0});return{unmount:I}};class _m{constructor(s){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(const s of this.listeners)s(this.orchestratorState)}))}}class wm{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async execute(s){const r=s.appPath??Q;await en(r),s.headless&&await v.checkServerVersionCompatibility();const l=await new v.ConfigService().getConfig(),d=new Hv({appPath:r,frontendUrl:l.apiUrl});if(!s.headless){const w=new _m(d);d.onChange=()=>w.notify();const{unmount:I}=await ym(w);this.unmountUI=I,v.getVersionInfo().then(R=>d.setVersionInfo(R))}this.orchestrator=new kv({state:d,verbose:s.verbose,debounceMs:s.debounceMs}),await this.orchestrator.start(),s.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>{this.close().then(()=>process.exit(0))};process.on("SIGINT",s),process.on("SIGTERM",s)}}class Sm{async execute({appPath:s=Q,postInstall:r=!1,preInstall:l=!1,functionUniversalIdentifier:d,functionName:w,payload:I="{}"}){let R;try{R=JSON.parse(I)}catch{console.error(y.default.red("Invalid JSON payload. Please provide valid JSON.")),process.exit(1)}const $=r?"post install":l?"pre install":d??w;console.log(y.default.blue(`🚀 Executing function "${$}"...`)),console.log(y.default.gray(` Payload: ${JSON.stringify(R)}
340
- `));const q=r?{appPath:s,postInstall:!0,payload:R}:l?{appPath:s,preInstall:!0,payload:R}:d?{appPath:s,functionUniversalIdentifier:d,payload:R}:{appPath:s,functionName:w,payload:R},Z=await v.functionExecute(q);if(!Z.success){switch(Z.error.code){case v.APP_ERROR_CODES.MANIFEST_NOT_FOUND:{console.error(y.default.red("Failed to build manifest."));break}case v.FUNCTION_ERROR_CODES.FETCH_FUNCTIONS_FAILED:{console.error(y.default.red("Failed to fetch functions:"),Z.error.message);break}case v.FUNCTION_ERROR_CODES.FUNCTION_NOT_FOUND:{console.error(y.default.red(Z.error.message),`
341
- `);const V=Z.error.details?.availableFunctions??[];V.length>0?(console.log(y.default.cyan("Available functions:")),V.forEach(D=>{console.log(` - ${y.default.white(D.name)} (${D.universalIdentifier})`)})):console.log(y.default.yellow("No functions found for this application. Have you synced your app with `twenty dev`?"));break}case v.FUNCTION_ERROR_CODES.EXECUTION_FAILED:{console.error(y.default.red("Execution failed:"),Z.error.message);break}default:console.error(y.default.red(Z.error.message))}process.exit(1)}const K=Z.data;console.log(y.default.cyan("".repeat(60))),console.log(y.default.cyan("Execution Result")),console.log(y.default.cyan("".repeat(60)));const Ye=K.status==="SUCCESS"?y.default.green:y.default.red;console.log(`${y.default.bold("Status:")} ${Ye(K.status)}`),console.log(`${y.default.bold("Duration:")} ${K.duration}ms
342
- `),v.o(K.data)&&(console.log(y.default.bold("Data:")),console.log(y.default.white(JSON.stringify(K.data,null,2)))),K.error&&(console.log(y.default.bold.red("Error:")),console.log(y.default.red(` Type: ${K.error.errorType}`)),console.log(y.default.red(` Message: ${K.error.errorMessage}
343
- `)),K.error.stackTrace&&(console.log(y.default.gray("Stack trace:")),console.log(y.default.gray(K.error.stackTrace)))),K.logs&&(console.log(y.default.bold("Logs:")),console.log(y.default.gray(K.logs))),console.log(y.default.cyan("".repeat(60))),K.status!=="SUCCESS"&&process.exit(1)}}class xm{async execute(s){const r=s.appPath??Q;await en(r),await v.checkServerVersionCompatibility(),console.log(y.default.blue("Installing application...")),console.log(y.default.gray(`App path: ${r}
344
- `));const l=await v.appInstall({appPath:r,remote:s.remote});l.success||(console.error(y.default.red(l.error.message)),process.exit(1)),console.log(y.default.green("✓ Application installed"))}}class Im{constructor(){this.apiService=new v.ApiService}async execute({appPath:s=Q,functionUniversalIdentifier:r,functionName:l}){try{const d=await v.readManifestFromFile(s);d||process.exit(1),this.logWatchInfo({appName:d.application.displayName,functionUniversalIdentifier:r,functionName:l}),await this.apiService.subscribeToLogs({applicationUniversalIdentifier:d.application.universalIdentifier,functionUniversalIdentifier:r,functionName:l})}catch(d){console.error(y.default.red("Watch logs failed:"),d instanceof Error?d.message:d),process.exit(1)}}logWatchInfo({appName:s,functionUniversalIdentifier:r,functionName:l}){const d=s??"Twenty Application",w=r||l?`function "${r||l}"`:"functions";console.log(y.default.blue(`🚀 Watching ${d} ${w} logs:
345
- `))}}class Em{async execute(s){const r=s.appPath??Q;await en(r),console.log(y.default.blue("Publishing to npm...")),console.log(y.default.gray(`App path: ${r}
346
- `));const l=await v.appPublish({appPath:r,npmTag:s.tag,onProgress:d=>console.log(y.default.gray(d))});l.success||(console.error(y.default.red(l.error.message)),process.exit(1)),console.log(y.default.green("✓ Published to npm successfully"))}}const Am=f=>{try{return new URL(f).hostname.replace(/\./g,"-")}catch{return"remote"}},Wo=async(f,s)=>s?((await v.authLogin({apiKey:s,apiUrl:f})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"):bm(f),bm=async f=>{console.log(y.default.gray("Opening browser for authentication..."));const s=await v.authLoginOAuth({apiUrl:f});if(s.success)return"OAuth";console.log(y.default.yellow(s.error.message));const r=await je.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:d=>d.length>0||"API key is required"}]);return(await v.authLogin({apiKey:r.apiKey,apiUrl:f})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"},Cm=f=>{const s=f.command("remote").description("Manage remote Twenty servers");s.command("add").description("Add a new remote or re-authenticate an existing one").option("--as <name>","Name for this remote").option("--api-key <apiKey>","API key for non-interactive auth").option("--api-url <apiUrl>","Server URL").option("--local","Connect to a local Twenty server (auto-detect)").option("--test","Write to config.test.json (for integration tests)").action(async r=>{const l=r.test?v.getConfigPath(!0):void 0,d=new v.ConfigService(l?{configPath:l}:void 0),w=await d.getRemotes();if(r.as!==void 0&&w.includes(r.as)){const q=await d.getConfigForRemote(r.as);v.ConfigService.setActiveRemote(r.as);const Z=await Wo(q.apiUrl,r.apiKey);console.log(y.default.green(`✓ Re-authenticated "${r.as}" via ${Z}.`)),await d.setDefaultRemote(r.as),console.log(y.default.green(`✓ Default remote set to "${r.as}".`));return}let I=r.apiUrl?v.Sa(r.apiUrl):void 0;if(!I){const q=await v.detectLocalServer();r.local?(q||(console.error(y.default.red(`No local Twenty server found.
347
- Start one with: yarn twenty server start`)),process.exit(1)),console.log(y.default.gray(`Found local server at ${q}`)),I=q):I=v.Sa((await je.default.prompt([{type:"input",name:"apiUrl",message:"Twenty server URL:",validate:Z=>{try{return new URL(Z),!0}catch{return"Please enter a valid URL"}}}])).apiUrl)}const R=r.as??Am(I);v.ConfigService.setActiveRemote(R);const $=await Wo(I,r.apiKey);console.log(y.default.green(`✓ Remote "${R}" added (${I}) via ${$}.`)),await d.setDefaultRemote(R),console.log(y.default.green(`✓ Default remote set to "${R}".`))}),s.command("list").description("List all configured remotes").action(async()=>{const r=new v.ConfigService,l=await r.getRemotes(),d=await r.getDefaultRemote();if(l.length===0){console.log("No remotes configured."),console.log("Use 'twenty remote add' to add one.");return}console.log("");for(const w of l){const I=await r.getConfigForRemote(w),R=I.twentyCLIAccessToken?"oauth":I.apiKey?"api-key":"none",$=w===d,q=$?"* ":" ",Z=$?y.default.bold(w):w;console.log(`${q}${Z} ${y.default.gray(I.apiUrl)} [${R}]`)}console.log(`
348
- `,y.default.gray("Use 'twenty remote switch <name>' to change default"))}),s.command("switch [name]").description("Set the default remote").action(async r=>{const l=new v.ConfigService,d=r??(await je.default.prompt([{type:"list",name:"remote",message:"Select default remote:",choices:await l.getRemotes()}])).remote;(await l.getRemotes()).includes(d)||(console.error(y.default.red(`Remote "${d}" not found.`)),process.exit(1)),await l.setDefaultRemote(d),console.log(y.default.green(`✓ Default remote set to "${d}".`))}),s.command("status").description("Show active remote and authentication status").action(async()=>{const r=new v.ConfigService,l=new v.ApiService,d=v.ConfigService.getActiveRemote(),w=await r.getConfig(),I=w.twentyCLIAccessToken?"oauth":w.apiKey?"api-key":"none";if(console.log(` Remote: ${y.default.bold(d)}`),console.log(` Server: ${w.apiUrl}`),I==="none"){console.log(` Auth: ${y.default.yellow("not configured")}`);return}const{authValid:R}=await l.validateAuth(),$=R?y.default.green(`${I} (valid)`):y.default.red(`${I} (invalid)`);console.log(` Auth: ${$}`)}),s.command("remove <name>").description("Remove a remote").action(async r=>{const l=new v.ConfigService;(await l.getRemotes()).includes(r)||(console.error(y.default.red(`Remote "${r}" not found.`)),process.exit(1)),v.ConfigService.setActiveRemote(r),await l.clearConfig(),console.log(y.default.green(`✓ Remote "${r}" removed.`))})},Tm=f=>{const s=f.command("server").description("Manage a Twenty server (local instance and server-side actions)");s.command("start").description("Start a local Twenty server").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(async r=>{const l=r.test?v.DEFAULT_TEST_PORT:v.DEFAULT_PORT,d=r.port?parseInt(r.port,10):l;(isNaN(d)||d<1||d>65535)&&(console.error(y.default.red("Invalid port number.")),process.exit(1));const w=await v.serverStart({port:d,test:r.test,onProgress:I=>console.log(y.default.gray(I))});w.success||(console.error(y.default.red(w.error.message)),process.exit(1))}),s.command("stop").description("Stop the local Twenty server").option("--test","Stop the test instance").action(r=>{const l=r.test?v.TEST_CONTAINER_NAME:v.CONTAINER_NAME;if(!v.containerExists(l)){console.log(y.default.yellow("No Twenty server container found."));return}bn.execSync(`docker stop ${l}`,{stdio:"ignore"}),console.log(y.default.green("Twenty server stopped."))}),s.command("logs").description("Stream Twenty server logs").option("-n, --lines <lines>","Number of lines to show","50").option("--test","Show logs for the test instance").action(r=>{const l=r.test?v.TEST_CONTAINER_NAME:v.CONTAINER_NAME;if(!v.containerExists(l)){console.log(y.default.yellow("No Twenty server container found."));return}try{bn.spawnSync("docker",["logs","-f","--tail",r.lines,l],{stdio:"inherit"})}catch{}}),s.command("status").description("Show Twenty server status").option("--test","Show status of the test instance").action(async r=>{const l=r.test?v.TEST_CONTAINER_NAME:v.CONTAINER_NAME,d=r.test?v.DEFAULT_TEST_PORT:v.DEFAULT_PORT;if(!v.containerExists(l)){console.log(` Status: ${y.default.gray("not created")}`),console.log(y.default.gray(` Run 'yarn twenty server start${r.test?" --test":""}' to create one.`));return}const w=v.isContainerRunning(l),I=w?v.getContainerPort(l):d,R=w?await v.checkServerHealth(I):!1,$=R?y.default.green("running (healthy)"):w?y.default.yellow("running (starting...)"):y.default.gray("stopped"),q=v.getContainerEnvVar("APP_VERSION",l);console.log(` Status: ${$}`),console.log(` URL: http://localhost:${I}`),q&&console.log(` Version: ${y.default.gray(q)}`),R&&console.log(y.default.gray(" Login: tim@apple.dev / tim@apple.dev"))}),s.command("reset").description("Delete all data and start fresh").option("--test","Reset the test instance").action(r=>{const l=r.test?v.TEST_CONTAINER_NAME:v.CONTAINER_NAME,d=r.test?"twenty-app-dev-test-data":"twenty-app-dev-data",w=r.test?"twenty-app-dev-test-storage":"twenty-app-dev-storage";v.containerExists(l)&&bn.execSync(`docker rm -f ${l}`,{stdio:"ignore"});try{bn.execSync(`docker volume rm ${d} ${w}`,{stdio:"ignore"})}catch{}console.log(y.default.green("Twenty server data reset.")),console.log(y.default.gray(`Run 'yarn twenty server start${r.test?" --test":""}' to start a fresh instance.`))}),s.command("upgrade [version]").description("Upgrade the twenty-app-dev Docker image").option("--test","Upgrade the test instance").action(async(r,l)=>{const d=await v.serverUpgrade({version:r??"latest",test:l.test,onProgress:I=>console.log(y.default.gray(I))});d.success||(console.error(y.default.red(d.error.message)),process.exit(1));const{data:w}=d;if(!w.imageUpdated){console.log(y.default.green(` Already up to date (${w.image}).`));return}console.log(y.default.green(` Upgraded to: ${w.image}`)),w.containerRecreated&&console.log(y.default.gray(` Run 'yarn twenty server start${l.test?" --test":""}' to wait for the server to be ready.`))}),s.command("catalog-sync").description("Trigger a marketplace catalog sync on the server").option("-r, --remote <name>","Sync on a specific remote").action(async r=>{await new Go().execute({remote:r.remote})})};class Rm{async execute(s){const r=s.appPath??Q;await en(r),console.log(y.default.blue("Syncing application...")),console.log(y.default.gray(`App path: ${r}
349
- `));const l=await v.appDevOnce({appPath:r,verbose:s.verbose,onProgress:d=>console.log(y.default.gray(d))});l.success||(console.error(y.default.red(l.error.message)),process.exit(1)),console.log(y.default.green(`
350
- ✓ Synced ${l.data.applicationDisplayName} (${l.data.fileCount} file${l.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${l.data.outputDir}`))}}const Fm=f=>`${y.default.cyan(f.file)}:${y.default.yellow(String(f.line))}:${y.default.yellow(String(f.column+1))} - ${y.default.red("error")} ${f.text}`;class Pm{async execute(s){const r=s.appPath??Q;console.log(y.default.blue("Running type check...")),console.log(y.default.gray(`App path: ${r}
351
- `));const l=await v.runTypecheck(r);l.length===0&&(console.log(y.default.green("✓ No type errors found")),process.exit(0));for(const d of l)console.log(Fm(d));console.log(`
352
- `,y.default.red(`✗ Found ${l.length} type error${l.length===1?"":"s"}`)),process.exit(1)}}class Lm{async execute({appPath:s=Q,askForConfirmation:r}){console.log(y.default.blue("🚀 Uninstall Twenty Application")),console.log(y.default.gray(`📁 App Path: ${s}
353
- `)),r&&!await this.confirmationPrompt()&&(console.error(y.default.red("⛔️ Aborting uninstall")),process.exit(1));const l=await v.appUninstall({appPath:s});return l.success?(console.log(y.default.green("✅ Application uninstalled successfully")),{success:!0,data:void 0}):(console.error(y.default.red("❌ Uninstall failed:"),l.error.message),{success:!1,error:l.error.message})}async confirmationPrompt(){const{confirmation:s}=await je.default.prompt([{type:"confirm",name:"confirmation",message:"Are you sure you want to uninstall this application?",default:!1}]);return s}}const Om=f=>{const s=new Rv,r=new wm,l=new Rm,d=new xm,w=new Em,I=new Pm,R=new Lm,$=new Go,q=new Fv,Z=new Cv,K=new Im,Ye=new Sm;f.command("dev [appPath]").description("Build and sync local application changes (watches by default; use --once for a one-shot sync)").option("-w, --watch","Watch source files and re-sync on every change (default behavior)").option("-o, --once","Build and sync once, then exit (useful for CI, scripts, and pre-commit hooks)").option("--debounceMs <ms>","Debounce in ms (default: 2 000)").option("-v, --verbose","Show detailed logs").option("-d, --debug","Show detailed logs (alias for --verbose)").action(async(V,D)=>{D.once&&D.watch&&(console.error(y.default.red("Error: --once and --watch are mutually exclusive. Watch mode is the default.")),process.exit(1));const Pe={appPath:pt(V),verbose:D.verbose||D.debug,debounceMs:D.debounceMs?parseInt(D.debounceMs,10):void 0};if(D.once){await l.execute(Pe);return}await r.execute(Pe)}),f.command("build [appPath]").description("Build, sync, and generate API client into .twenty/output/").option("--tarball","Also pack into a .tgz tarball").action(async(V,D)=>{await s.execute({appPath:pt(V),tarball:D.tarball})}),f.command("install [appPath]").description("Install a deployed application on the connected server").option("-r, --remote <name>","Install on a specific remote").action(async(V,D)=>{await d.execute({appPath:pt(V),remote:D.remote})}),f.command("deploy [appPath]").description("Publish a new version to a Twenty server's registry").option("-r, --remote <name>","Deploy to a specific remote").action(async(V,D)=>{await q.execute({appPath:pt(V),remote:D.remote})}),f.command("publish [appPath]").description("Build and publish to npm").option("--tag <tag>","npm dist-tag (e.g. beta, next)").action(async(V,D)=>{await w.execute({appPath:pt(V),tag:D.tag})}),f.command("catalog-sync").description("[Deprecated] Moved under server. Use `yarn twenty server catalog-sync`.").option("-r, --remote <name>","Sync on a specific remote").action(async V=>{console.warn(y.default.yellow("`yarn twenty catalog-sync` is deprecated and will be removed in a future release.\nUse `yarn twenty server catalog-sync` instead.\n")),await $.execute({remote:V.remote})}),f.command("typecheck [appPath]").description("Run TypeScript type checking on the application").action(async V=>{await I.execute({appPath:pt(V)})}),f.command("uninstall [appPath]").description("Uninstall application from Twenty").option("-y, --yes","Skip confirmation prompt").action(async(V,D)=>{try{const Pe=await R.execute({appPath:pt(V),askForConfirmation:!D?.yes});process.exit(Pe.success?0:1)}catch{process.exit(1)}}),Cm(f),Tm(f),f.command("add [entityType]").option("--path <path>","Path in which the entity should be created.").description(`Add a new entity to your application (${Object.values(v.e).join("|")})`).action(async(V,D)=>{await Z.execute(V,D?.path)}),f.command("exec [appPath]").option("--postInstall","Execute post-install logic function if defined").option("--preInstall","Execute pre-install logic function if defined").option("-p, --payload <payload>","JSON payload to send to the function","{}").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Universal ID of the function to execute").option("-n, --functionName <functionName>","Name of the function to execute").description("Execute a logic function with a JSON payload").action(async(V,D)=>{!D?.postInstall&&!D?.preInstall&&!D?.functionUniversalIdentifier&&!D?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await Ye.execute({...D,payload:D?.payload??"{}",appPath:pt(V)})}),f.command("logs [appPath]").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Only show logs for the function with this universal ID").option("-n, --functionName <functionName>","Only show logs for the function with this name").description("Watch application function logs").action(async(V,D)=>{await K.execute({...D,appPath:pt(V)})})};nv.inspect.defaultOptions.depth=10;const tn=new Bo.Command;tn.name("twenty").description("CLI for Twenty application development").version(v.packageJson.version);tn.option("-r, --remote <name>","Use a specific remote (overrides the default set by remote switch)");tn.hook("preAction",async f=>{let r=(f.optsWithGlobals?f.optsWithGlobals():f.opts()).remote;r?console.log(y.default.gray(`Using remote: ${r}`)):r=await new v.ConfigService().getDefaultRemote(),v.ConfigService.setActiveRemote(r)});Om(tn);tn.exitOverride();try{tn.parse()}catch(f){f instanceof Bo.CommanderError&&process.exit(f.exitCode),f instanceof Error&&(console.error(y.default.red("Error:"),f.message),process.exit(1))}
348
+ Waiting for server...`,status:"error"}]),this.state.updatePipeline({status:"error"})),!1)}if(!r.authValid)return s.output.errorLogged||(s.output={isReady:!1,errorLogged:!0},s.status="error",this.state.applyStepEvents([{message:"Authentication failed. Run `yarn twenty remote:add --local` to authenticate.",status:"error"}]),this.state.updatePipeline({status:"error"})),!1;const c=s.output.isReady;if(s.output={isReady:!0,errorLogged:!1},s.status="done",!m.o(this.state.frontendUrl)){const d=await this.apiService.getWorkspaceFrontendUrl();m.o(d)&&(this.state.frontendUrl=d)}return c||this.notify(),!0}}class Xm{constructor({clientService:s,configService:r,state:c,notify:d}){this.clientService=s,this.configService=r,this.state=c,this.notify=d}async execute(s){const r=this.state.steps.generateApiClient;r.status="in_progress",this.notify();try{const c=await m.ensureAppAccessTokenIsValidOrRefresh(this.configService,s.credentials);await this.clientService.generateCoreClient({appPath:s.appPath,appAccessToken:c}),r.status="done"}catch(c){this.state.applyStepEvents([{message:`Failed to generate API client: ${c instanceof Error?c.message:String(c)}`,status:"error"}]),r.status="error"}this.notify()}}class Qm{constructor({apiService:s,configService:r,state:c,notify:d}){this.apiService=s,this.configService=r,this.state=c,this.notify=d}async execute(s){try{const r=await m.ensureAppRegistration(this.apiService,this.configService,{name:s.manifest.application.displayName,universalIdentifier:s.manifest.application.universalIdentifier});this.registrationCredentials={clientId:r.clientId,clientSecret:r.clientSecret},this.state.applyStepEvents([{message:r.isNewRegistration?`App registration created: ${s.manifest.application.displayName}`:"Existing app registration found",status:r.isNewRegistration?"success":"info"},...r.isNewRegistration?[{message:"Credentials saved to config.",status:"info"}]:[]])}catch(r){throw this.state.applyStepEvents([{message:`Failed to register app: ${r instanceof Error?r.message:String(r)}`,status:"error"}]),r}this.notify()}}class Do{constructor(s){this.watcher=null,this.appPath=s.appPath,this.fileFolder=s.fileFolder,this.watchPaths=s.watchPaths,this.handleFileBuilt=s.handleFileBuilt}async start(){const s=(await Promise.all(this.watchPaths.map(async r=>{const c=q.join(this.appPath,r);return await m.pathExists(c)?c:null}))).filter(r=>r!==null);s.length!==0&&(this.watcher=Qo.default.watch(s,{awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{r==="addDir"||r==="unlinkDir"||((r==="add"||r==="change")&&this.copyAndNotify(c),r==="unlink"&&this.handleUnlink(c))}))}async close(){await this.watcher?.close()}async copyAndNotify(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),d=q.join(this.appPath,c);await m.ensureDir(q.dirname(d)),await m.copy(s,d);const x=await tt.readFile(d),E=xm.default.createHash("md5").update(x).digest("hex");this.handleFileBuilt({fileFolder:this.fileFolder,builtPath:c,sourcePath:r,checksum:E})}async handleUnlink(s){const r=q.relative(this.appPath,s),c=q.join(m.u,r),d=q.join(this.appPath,c);await m.remove(d)}}class ev{constructor(s){this.process=null,this.pendingErrors=[],this.buffer="",this.hasErrors=!1,this.appPath=s.appPath,this.onErrors=s.onErrors}async start(){const s=Lo.default.join(this.appPath,"node_modules",".bin","tsc");if(!await m.pathExists(s))return;const r=Lo.default.join(this.appPath,"tsconfig.json");this.process=Tn.spawn(s,["--watch","--noEmit","--pretty","false","-p",r],{cwd:this.appPath,stdio:["ignore","pipe","pipe"]}),this.process.on("error",()=>{this.process=null}),this.process.stdout?.on("data",c=>{this.handleOutput(c.toString())}),this.process.stderr?.on("data",c=>{this.handleOutput(c.toString())})}close(){this.process?.kill(),this.process=null}handleOutput(s){this.buffer+=s;const r=this.buffer.split(`
349
+ `);this.buffer=r.pop()??"";for(const c of r)this.processLine(c)}processLine(s){if(s.includes("Starting compilation in watch mode...")||s.includes("Starting incremental compilation...")){this.pendingErrors=[];return}if(s.includes("Watching for file changes.")){const c=this.hasErrors;this.hasErrors=this.pendingErrors.length>0,(this.hasErrors||c)&&this.onErrors(this.pendingErrors),this.pendingErrors=[];return}const r=m.parseTscOutputLine(s);r&&this.pendingErrors.push(r)}}const tv=new Set(["node_modules","dist",".twenty"]);class nv{constructor(s){this.watcher=null,this.appPath=s.appPath,this.handleChangeDetected=s.handleChangeDetected,this.verbose=s.verbose??!1}async start(){const s=this.appPath;this.watcher=Qo.default.watch(this.appPath,{ignoreInitial:!this.verbose,ignored:r=>{const c=q.relative(s,r);if(c==="")return!1;const d=c.split(Ji.default.sep)[0];return tv.has(d)||d.startsWith(".")},awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}}),this.watcher.on("all",(r,c)=>{if(r==="addDir"||r==="unlinkDir")return;const d=q.relative(this.appPath,c),x=d.startsWith(m._),E=["package.json","yarn.lock"].includes(d);!(d.endsWith(".ts")||d.endsWith(".tsx"))&&!x&&!E||this.handleChangeDetected(d,r)})}async close(){await this.watcher?.close()}}class rv{constructor(s){this.manifestWatcher=null,this.logicFunctionsWatcher=null,this.frontComponentsWatcher=null,this.assetWatcher=null,this.dependencyWatcher=null,this.tscWatcher=null,this.state=s.state,this.scheduleSync=s.scheduleSync,this.notify=s.notify,this.onFileBuilt=s.onFileBuilt,this.shouldSkipTypecheck=s.shouldSkipTypecheck,this.verbose=s.verbose??!1}async start(){this.state.steps.startWatchers.status="in_progress",this.notify(),this.manifestWatcher=new nv({appPath:this.state.appPath,handleChangeDetected:this.handleChangeDetected.bind(this),verbose:this.verbose}),await this.manifestWatcher.start()}async handleWatcherRestarts(s){const{logicFunctions:r,frontComponents:c}=s.filePaths;if(!this.state.steps.startWatchers.output.watchersStarted){this.state.steps.startWatchers.output.watchersStarted=!0,this.state.steps.startWatchers.status="done",await this.startFileWatchers(r,c);return}this.logicFunctionsWatcher?.shouldRestart(r)&&await this.logicFunctionsWatcher.restart(r),this.frontComponentsWatcher?.shouldRestart(c)&&await this.frontComponentsWatcher.restart(c)}async close(){this.tscWatcher?.close(),await Promise.all([this.manifestWatcher?.close(),this.logicFunctionsWatcher?.close(),this.frontComponentsWatcher?.close(),this.assetWatcher?.close(),this.dependencyWatcher?.close()])}handleChangeDetected(s,r){this.state.addEvent({message:`Change detected: ${s}`,status:"info"}),r==="unlink"?this.state.removeEntity(s):this.state.updateEntityStatus(s,"building"),this.notify(),this.scheduleSync()}handleFileBuildError(s){this.state.addEvent({message:"Build failed:",status:"error"});for(const r of s)this.state.addEvent({message:r.error,status:"error"});this.notify()}handleFileBuilt(s){this.verbose&&this.state.addEvent({message:`Successfully built ${s.builtPath}`,status:"success"}),this.state.steps.uploadFiles.output.builtFileInfos.set(s.builtPath,{checksum:s.checksum,builtPath:s.builtPath,sourcePath:s.sourcePath,fileFolder:s.fileFolder,usesSdkClient:s.usesSdkClient}),this.onFileBuilt(s),this.notify(),this.scheduleSync()}async startFileWatchers(s,r){await Promise.all([this.startTscWatcher(),this.startLogicFunctionsWatcher(s),this.startFrontComponentsWatcher(r),this.startAssetWatcher(),this.startDependencyWatcher()])}async startLogicFunctionsWatcher(s){this.logicFunctionsWatcher=m.createLogicFunctionsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.logicFunctionsWatcher.start()}async startFrontComponentsWatcher(s){this.frontComponentsWatcher=m.createFrontComponentsWatcher({appPath:this.state.appPath,sourcePaths:s,shouldSkipTypecheck:this.shouldSkipTypecheck,handleBuildError:this.handleFileBuildError.bind(this),handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.frontComponentsWatcher.start()}async startAssetWatcher(){this.assetWatcher=new Do({appPath:this.state.appPath,fileFolder:m.b.PublicAsset,watchPaths:[m._],handleFileBuilt:this.handleFileBuilt.bind(this)}),await this.assetWatcher.start()}async startDependencyWatcher(){this.dependencyWatcher=new Do({appPath:this.state.appPath,fileFolder:m.b.Dependencies,watchPaths:["package.json","yarn.lock"],handleFileBuilt:this.handleFileBuilt.bind(this)}),this.dependencyWatcher.start()}async startTscWatcher(){this.tscWatcher=new ev({appPath:this.state.appPath,onErrors:this.handleTypecheckErrors.bind(this)}),await this.tscWatcher.start()}handleTypecheckErrors(s){s.length===0?this.state.addEvent({message:"Typecheck passed",status:"success"}):this.state.applyStepEvents(s.map(r=>({message:`Type error in ${r.file}(${r.line},${r.column}): ${r.text}`,status:"error"}))),this.notify()}}class iv{constructor({apiService:s,state:r,notify:c,verbose:d}){this.apiService=s,this.state=r,this.notify=c,this.verbose=d??!1}async execute(s){const r=this.state.steps.syncApplication;r.status="in_progress",this.state.updatePipeline({status:"syncing"});const c=[],d=m.manifestUpdateChecksums({manifest:s.manifest,builtFileInfos:s.builtFileInfos});c.push({message:"Manifest checksums set",status:"info"}),await m.writeManifestToOutput(s.appPath,d),c.push({message:"Manifest saved to output directory",status:"info"}),c.push({message:"Syncing manifest",status:"info"});const x=await this.apiService.syncApplication(d);if(x.success){c.push({message:"✓ Synced",status:"success"}),r.output={syncStatus:"synced",error:null},r.status="done",this.state.updatePipeline({status:"synced",error:null}),this.state.updateAllEntitiesStatus("success"),this.state.applyStepEvents(c);return}const E=this.verbose?null:m.formatManifestValidationErrors(x.error);E?(c.push(...E),c.push({message:"Add --verbose to see full error log",status:"info"})):c.push({message:`Sync failed with error: ${m.serializeError(x.error)}`,status:"error"});const C=E?E[0].message:"Sync failed";r.output={syncStatus:"error",error:C},r.status="error",this.state.updatePipeline({status:"error",error:C}),this.state.updateAllEntitiesStatus("error"),this.state.applyStepEvents(c)}}class sv{constructor({state:s,notify:r,verbose:c}){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0,this.state=s,this.notify=r,this.verbose=c??!1}get isInitialized(){return m.o(this.state.steps.uploadFiles.output.fileUploader)}initialize(s){const r=this.state.steps.uploadFiles;r.output={...r.output,fileUploader:new m.FileUploader({appPath:s.appPath,applicationUniversalIdentifier:s.universalIdentifier})},r.status="in_progress",this.notify(),this.uploadPendingFiles()}uploadFile(s,r,c){const d=this.state.steps.uploadFiles;if(!d.output.fileUploader)return;d.status="in_progress",this.totalQueued++,this.verbose&&this.state.addEvent({message:`Uploading ${s}`,status:"info"}),this.state.updateEntityStatus(r,"uploading"),this.notify();const x=d.output.fileUploader.uploadFile({builtPath:s,fileFolder:c}).then(E=>{E.success?(this.uploadedCount++,this.verbose&&this.state.addEvent({message:`Successfully uploaded ${s}`,status:"success"}),this.state.updateEntityStatus(r,"success")):(this.failedCount++,this.state.addEvent({message:`Failed to upload ${s}: ${E.error}`,status:"error"}))}).catch(E=>{this.failedCount++,this.state.addEvent({message:`Upload failed for ${s}: ${E}`,status:"error"})}).finally(()=>{d.output.activeUploads.delete(x),d.output.activeUploads.size===0&&(this.logUploadSummary(),d.status="done",this.notify())});d.output.activeUploads.add(x)}async waitForUploads(){const s=this.state.steps.uploadFiles;for(;s.output.activeUploads.size>0;)await Promise.all(s.output.activeUploads);s.status="done",this.notify()}logUploadSummary(){if(this.totalQueued===0){this.resetCounters();return}this.failedCount>0&&this.state.addEvent({message:`Uploaded ${this.uploadedCount}/${this.totalQueued} files (${this.failedCount} failed)`,status:"error"}),this.state.addEvent({message:`Successfully uploaded ${this.uploadedCount} file${this.uploadedCount!==1?"s":""}`,status:"success"}),this.resetCounters()}resetCounters(){this.uploadedCount=0,this.failedCount=0,this.totalQueued=0}uploadPendingFiles(){for(const[s,{fileFolder:r,sourcePath:c}]of this.state.steps.uploadFiles.output.builtFileInfos.entries())this.uploadFile(s,c,r)}}class av{constructor(s){this.syncTimer=null,this.serverCheckInterval=null,this.skipTypecheck=!0,this.debounceMs=s.debounceMs??2e3,this.state=s.state,this.verbose=s.verbose??!1,this.apiService=new m.ApiService({disableInterceptors:!0});const r=this.apiService,c=new m.ConfigService;this.clientService=new m.ClientService;const d={state:this.state,notify:()=>this.state.notify()};this.checkServerStep=new Zm({...d,apiService:r}),this.buildManifestStep=new Jm(d),this.registerAppStep=new Qm({...d,apiService:r,configService:c}),this.uploadFilesStep=new sv({...d,verbose:this.verbose}),this.generateApiClientStep=new Xm({...d,clientService:this.clientService,configService:c}),this.syncApplicationStep=new iv({...d,apiService:r,verbose:this.verbose}),this.startWatchersStep=new rv({...d,scheduleSync:this.scheduleSync.bind(this),onFileBuilt:this.handleFileBuilt.bind(this),shouldSkipTypecheck:()=>this.skipTypecheck,verbose:this.verbose})}async start(){const s=Ji.default.join(this.state.appPath,m.u);await m.ensureDir(s),await m.emptyDir(s),this.verbose||(this.state.addEvent({message:"Add --verbose to see fully detailed logs",status:"info"}),this.state.notify()),await this.startWatchersStep.start(),this.serverCheckInterval=setInterval(()=>{this.checkServerHealth()},2e3)}async close(){this.serverCheckInterval&&clearInterval(this.serverCheckInterval),await this.startWatchersStep.close()}getState(){return this.state}handleFileBuilt(s){this.state.steps.uploadFiles.output.fileUploader&&this.uploadFilesStep.uploadFile(s.builtPath,s.sourcePath,s.fileFolder)}async checkServerHealth(){const s=this.state.steps.checkServer.output.isReady;await this.checkServerStep.execute()&&!s&&this.scheduleSync()}scheduleSync(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.performSync()},this.debounceMs)}async performSync(){if(!this.state.pipeline.isSyncing){this.state.updatePipeline({isSyncing:!0});try{await this.runSyncPipeline()}catch(s){this.state.addEvent({message:`Sync failed with error: ${m.serializeError(s)}`,status:"error"}),this.state.updatePipeline({status:"error"}),this.state.updateAllEntitiesStatus("error")}finally{this.state.updatePipeline({isSyncing:!1})}}}async runSyncPipeline(){if(!await this.checkServerStep.execute())return;this.state.steps.ensureValidTokens.status="done";const r=await this.buildManifestStep.execute({appPath:this.state.appPath});if(!r||(await this.startWatchersStep.handleWatcherRestarts(r),!this.uploadFilesStep.isInitialized&&!await this.initializePipeline(r.manifest)))return;const c=this.state.hasObjectsOrFieldsChanged(r.manifest);await this.uploadFilesStep.waitForUploads(),await this.syncApplicationStep.execute({manifest:r.manifest,builtFileInfos:this.state.steps.uploadFiles.output.builtFileInfos,appPath:this.state.appPath}),this.state.steps.syncApplication.status!=="error"&&c&&(await this.generateApiClientStep.execute({appPath:this.state.appPath,credentials:this.registerAppStep.registrationCredentials}),this.skipTypecheck=!1)}async initializePipeline(s){await this.registerAppStep.execute({manifest:s});const r=await this.apiService.createDevelopmentApplication({universalIdentifier:s.application.universalIdentifier,name:s.application.displayName});return!r.success||!r.data?(this.state.applyStepEvents([{message:"Failed to install development application",status:"error"},{message:JSON.stringify(r,null,2),status:"error"}]),this.state.updatePipeline({status:"error"}),!1):(this.state.steps.resolveApplication.output={applicationId:r.data.id,universalIdentifier:r.data.universalIdentifier},this.state.steps.resolveApplication.status="done",this.state.applyStepEvents([{message:"Application installed",status:"success"}]),this.uploadFilesStep.initialize({appPath:this.state.appPath,universalIdentifier:s.application.universalIdentifier}),!0)}}const ov={objects:m.e.Object,fields:m.e.Field,logicFunctions:m.e.LogicFunction,frontComponents:m.e.FrontComponent,roles:m.e.Role,skills:m.e.Skill,connectionProviders:m.e.ConnectionProvider,views:m.e.View,navigationMenuItems:m.e.NavigationMenuItem,pageLayouts:m.e.PageLayout,pageLayoutTabs:m.e.PageLayoutTab,commandMenuItems:m.e.CommandMenuItem},uv=200,lv={pending:["building","uploading","success","error"],building:["pending","uploading","success","error"],uploading:["pending","success","error"],success:["pending","building","uploading","error"],error:["pending","building","uploading","success"]};class cv{constructor(s){this.eventIdCounter=0,this.appPath=s.appPath,this.previousObjectsFieldsFingerprint=null,this.steps={checkServer:{output:{isReady:!1,errorLogged:!1},status:"idle"},ensureValidTokens:{output:{},status:"idle"},resolveApplication:{output:{applicationId:null,universalIdentifier:null},status:"idle"},buildManifest:{output:{result:null},status:"idle"},uploadFiles:{output:{fileUploader:null,builtFileInfos:new Map,activeUploads:new Set},status:"idle"},generateApiClient:{output:{},status:"idle"},syncApplication:{output:{syncStatus:"idle",error:null},status:"idle"},startWatchers:{output:{watchersStarted:!1},status:"idle"}},this.pipeline={status:"idle",isSyncing:!1,error:null,appName:null},this.versionInfo=null,this.entities=new Map,this.events=[]}setVersionInfo(s){this.versionInfo=s,this.notify()}notify(){this.onChange?.()}updatePipeline(s){Object.assign(this.pipeline,s),this.notify()}applyStepEvents(s){const r=s.map(c=>(this.eventIdCounter+=1,{...c,id:this.eventIdCounter,timestamp:new Date,message:c.message.slice(0,5e3)}));this.events=[...this.events.slice(-(uv-r.length)),...r]}addEvent(s){this.applyStepEvents([s])}updateEntityStatus(s,r){const c=new Map(this.entities),d=c.get(s);d?.status&&!lv[d.status].includes(r)||(c.set(s,d?{...d,status:r}:{name:s,path:s,status:r}),this.entities=c)}removeEntity(s){const r=new Map(this.entities);r.delete(s),this.entities=r}updateAllEntitiesStatus(s){const r=new Map(this.entities);for(const[c,d]of r)r.set(c,{...d,status:s});this.entities=r}updateEntitiesFromManifest(s){const r=new Map;for(const[d,x]of Object.entries(s)){const E=ov[d];if(E)for(const C of x)r.set(C,E)}const c=new Map(this.entities);for(const[d,x]of c)c.set(d,{...x,type:r.get(d)});for(const[d,x]of r)c.has(d)||c.set(d,{name:d,path:d,type:x,status:"pending"});this.entities=c}hasObjectsOrFieldsChanged(s){const r=JSON.stringify({objects:s.objects,fields:s.fields}),c=r!==this.previousObjectsFieldsFingerprint;return this.previousObjectsFieldsFingerprint=r,c}}const Be={idle:{color:"gray",icon:"○"},in_progress:{color:"yellow",icon:"spinner"},uploading:{color:"cyan",icon:"upload"},done:{color:"green",icon:"✓"},error:{color:"red",icon:"✗"}},fv=l=>({idle:"idle",in_progress:"in_progress",done:"done",error:"error"})[l],dv=l=>({pending:"idle",building:"in_progress",uploading:"uploading",success:"done",error:"error"})[l],pv=l=>({idle:"idle",building:"in_progress",syncing:"in_progress",synced:"done",error:"error"})[l],hv={idle:"Idle",building:"Building...",syncing:"Syncing...",synced:"Synced",error:"Error"},ji=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Yi=["↑","⇡","↟","⤒"],lu={[m.e.Object]:"Objects",[m.e.Field]:"Fields",[m.e.LogicFunction]:"Logic functions",[m.e.FrontComponent]:"Front components",[m.e.CommandMenuItem]:"Command menu items",[m.e.Role]:"Roles",[m.e.Skill]:"Skills",[m.e.View]:"Views",[m.e.NavigationMenuItem]:"Navigation menu items",[m.e.PageLayout]:"Page layouts",[m.e.PageLayoutTab]:"Page layout tabs",[m.e.Agent]:"Agents",[m.e.ConnectionProvider]:"Connection providers"},cu=Object.keys(lu),gv={info:"gray",success:"green",error:"red",warning:"yellow"},mv=l=>l.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),vv=(l,s=40)=>{if(l.length<=s)return l;const r=l.split("/");return r.length<=2?l:`.../${r.slice(-2).join("/")}`},yv=l=>{const s=new Map;for(const r of cu)s.set(r,[]);for(const r of l.values()){if(!r.type)continue;const c=s.get(r.type)??[];c.push(r),s.set(r.type,c)}return s},_v=l=>{const s=l.steps.resolveApplication.output.applicationId;return!m.o(l.frontendUrl)||!m.o(s)?null:`${l.frontendUrl}/settings/applications/${s}`},wv=l=>l.some(s=>s==="error")?"error":l.some(s=>s==="in_progress")?"in_progress":l.every(s=>s==="done")?"done":"idle",Sv=l=>{const s=[...l.entities.values()],r=s.some(E=>E.status==="error"),c=s.some(E=>E.status==="building"),d=s.length>0&&s.every(E=>E.status==="uploading"||E.status==="success"),x=r?"error":c?"in_progress":d?"done":"idle";return[{label:"Application Initialization",status:wv([l.steps.checkServer.status,l.steps.ensureValidTokens.status,l.steps.resolveApplication.status])},{label:"Resources Build",status:x},{label:"Resources Upload",status:l.steps.uploadFiles.status},{label:"Manifest Build",status:l.steps.buildManifest.status},{label:"Application Synchronization",status:l.steps.syncApplication.status},{label:"Api Client Generation",status:l.steps.generateApiClient.status}]},fu=120,xv=Math.round(200/fu),Mo=()=>{const l=Math.floor(Date.now()/fu);return{spinnerFrame:ji[l%ji.length],uploadFrame:Yi[Math.floor(l/xv)%Yi.length]}},Zi=l=>{const s=Be[l];return s.icon==="spinner"?Mo().spinnerFrame:s.icon==="upload"?Mo().uploadFrame:s.icon},du=eu.default.createContext(null),Iv=du.Provider,nt=()=>{const l=eu.default.useContext(du);if(!l)throw new Error("useInk must be used within InkProvider");return l},Ev=({uiStatus:l})=>{const{Text:s}=nt(),r=Zi(l),c=Be[l];return T.jsxs(s,{color:c.color,children:[r," "]})},Av=({entity:l})=>{const{Box:s,Text:r}=nt();return T.jsxs(s,{children:[T.jsx(Ev,{uiStatus:dv(l.status)}),T.jsx(r,{children:l.name}),l.path!==l.name&&T.jsxs(r,{dimColor:!0,children:[" (",vv(l.path),")"]})]})},bv=({type:l,entities:s})=>{const{Box:r,Text:c}=nt();return s.length===0?null:T.jsxs(r,{flexDirection:"column",marginTop:1,children:[T.jsx(c,{bold:!0,dimColor:!0,children:lu[l]}),s.map(d=>T.jsx(Av,{entity:d},d.path))]})},Cv=()=>{const{Box:l,Text:s}=nt();return T.jsx(l,{marginTop:1,children:T.jsxs(s,{dimColor:!0,children:[T.jsx(s,{color:Be.idle.color,children:Be.idle.icon})," ","pending"," ",T.jsx(s,{color:Be.in_progress.color,children:ji[0]})," ","building"," ",T.jsx(s,{color:Be.uploading.color,children:Yi[0]})," ","uploading"," ",T.jsx(s,{color:Be.done.color,children:Be.done.icon})," ","success"," ",T.jsx(s,{color:Be.error.color,children:Be.error.icon})," ","error"]})})},Tv=7,Pv=({versionInfo:l})=>{const{Box:s,Text:r}=nt();if(l===null)return null;const{cliVersion:c,localServerVersion:d,latestServerVersion:x,isMinorOrMajorBehind:E,daysBehind:C}=l,R=E&&C!==null&&C>Tv,U=d!==null&&x!==null&&d===x;return T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Versions: "}),T.jsx(r,{dimColor:!0,children:"CLI "}),T.jsxs(r,{children:["v",c]}),d!==null&&T.jsxs(T.Fragment,{children:[T.jsx(r,{dimColor:!0,children:" • Server "}),T.jsxs(r,{color:R?"yellow":void 0,children:["v",d]}),U&&T.jsx(r,{color:"green",children:" ✓ latest"}),R&&x!==null&&T.jsxs(T.Fragment,{children:[T.jsxs(r,{color:"yellow",children:[" → v",x]}),C!==null&&T.jsxs(r,{dimColor:!0,children:[" (",C,"d behind)"]})]})]})]})},Rv=({state:l})=>{const{Text:s}=nt(),r=pv(l.pipeline.status),c=Zi(r),d=Be[r],x=hv[l.pipeline.status];return T.jsxs(s,{color:d.color,children:[c," ",x]})},Fv=({label:l,status:s})=>{const{Box:r,Text:c}=nt(),d=fv(s),x=Zi(d),E=Be[d];return T.jsxs(r,{children:[T.jsxs(c,{dimColor:!0,children:[l,": "]}),T.jsxs(c,{color:E.color,children:[x," ",s.replace("_"," ")]})]})},Lv=({state:l})=>{const{Box:s,Text:r}=nt(),c=yv(l.entities),d=_v(l);return T.jsxs(s,{flexDirection:"column",borderStyle:"classic",borderColor:"gray",paddingX:1,children:[T.jsx(r,{bold:!0,color:"cyan",children:"Application"}),T.jsxs(s,{marginLeft:2,flexDirection:"column",children:[T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Name: "}),T.jsx(r,{bold:!0,children:l.pipeline.appName??"Loading..."})]}),T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Overall Status: "}),T.jsx(Rv,{state:l})]}),d&&T.jsxs(s,{children:[T.jsx(r,{dimColor:!0,children:"Open:"}),T.jsxs(r,{bold:!0,color:"cyan",children:[" ",d]})]}),T.jsx(Pv,{versionInfo:l.versionInfo})]}),T.jsx(s,{marginLeft:2,flexDirection:"column",marginTop:1,children:Sv(l).map(x=>T.jsx(Fv,{label:x.label,status:x.status},x.label))}),T.jsx(s,{marginLeft:2,flexDirection:"column",children:cu.map(x=>{const E=c.get(x)??[];return T.jsx(bv,{type:x,entities:E},x)})})]})},Nv=({event:l})=>{const{Box:s,Text:r}=nt(),c=gv[l.status],d=mv(l.timestamp);return T.jsxs(s,{children:[T.jsxs(r,{dimColor:!0,children:[d," "]}),T.jsx(r,{color:c,children:l.message})]})},Ov=new Set(["building","syncing"]),Wo=120,Uv=80,$v=({uiStateManager:l})=>{const{Box:s,Static:r}=nt(),[,c]=At.useReducer(R=>R+1,0),d=At.useRef(null),x=At.useRef(0),E=At.useCallback(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,x.current=Date.now(),c()},Uv)},[]);At.useEffect(()=>l.subscribe(()=>{E()}),[l,E]),At.useEffect(()=>{const R=setInterval(()=>{const U=l.getSnapshot();Ov.has(U.pipeline.status)&&(Date.now()-x.current<Wo||c())},Wo);return()=>clearInterval(R)},[l]),At.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const C=l.getSnapshot();return T.jsxs(T.Fragment,{children:[T.jsx(r,{items:C.events,children:R=>T.jsx(Nv,{event:R},R.id)}),T.jsxs(s,{marginTop:1,flexDirection:"column",children:[T.jsx(Lv,{state:C}),T.jsx(Cv,{})]})]})},Dv=async l=>{const s=await import("ink"),{render:r,Box:c,Text:d,Static:x}=s,{unmount:E}=r(T.jsx(Iv,{value:{Box:c,Text:d,Static:x},children:T.jsx($v,{uiStateManager:l})}),{incrementalRendering:!0});return{unmount:E}};class Mv{constructor(s){this.listeners=new Set,this.pendingNotify=!1,this.orchestratorState=s}getSnapshot(){return this.orchestratorState}subscribe(s){return this.listeners.add(s),s(this.orchestratorState),()=>this.listeners.delete(s)}notify(){this.pendingNotify||(this.pendingNotify=!0,queueMicrotask(()=>{this.pendingNotify=!1;for(const s of this.listeners)s(this.orchestratorState)}))}}class Wv{constructor(){this.orchestrator=null,this.unmountUI=null}async close(){this.unmountUI?.(),await this.orchestrator?.close()}getOrchestrator(){return this.orchestrator}async execute(s){const r=s.appPath??Z;await tn(r),s.headless&&await m.checkServerVersionCompatibility();const c=new cv({appPath:r});if(!s.headless){const d=new Mv(c);c.onChange=()=>d.notify();const{unmount:x}=await Dv(d);this.unmountUI=x,m.getVersionInfo().then(E=>c.setVersionInfo(E))}this.orchestrator=new av({state:c,verbose:s.verbose,debounceMs:s.debounceMs}),await this.orchestrator.start(),s.headless||this.setupGracefulShutdown()}setupGracefulShutdown(){const s=()=>{this.close().then(()=>process.exit(0))};process.on("SIGINT",s),process.on("SIGTERM",s)}}class Bv{async execute(s){const r=s.appPath??Z;await tn(r),console.log(y.default.blue("Syncing application...")),console.log(y.default.gray(`App path: ${r}
350
+ `));const c=await m.appDevOnce({appPath:r,verbose:s.verbose,onProgress:d=>console.log(y.default.gray(d))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1)),console.log(y.default.green(`
351
+ ✓ Synced ${c.data.applicationDisplayName} (${c.data.fileCount} file${c.data.fileCount===1?"":"s"})`)),console.log(y.default.gray(`Output: ${c.data.outputDir}`))}}const kv=l=>{const s=new ou,r=new au;l.command("dev:function:logs [appPath]").description("Stream logic function logs").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Only show logs for the function with this universal ID").option("-n, --functionName <functionName>","Only show logs for the function with this name").action(async(c,d)=>{await s.execute({...d,appPath:pe(c)})}),l.command("dev:function:exec [appPath]").description("Execute a logic function").option("--postInstall","Execute post-install logic function if defined").option("--preInstall","Execute pre-install logic function if defined").option("-p, --payload <payload>","JSON payload to send to the function","{}").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Universal ID of the function to execute").option("-n, --functionName <functionName>","Name of the function to execute").action(async(c,d)=>{!d?.postInstall&&!d?.preInstall&&!d?.functionUniversalIdentifier&&!d?.functionName&&(console.error(y.default.red("Error: Either --postInstall, --preInstall, --functionName (-n), or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await r.execute({...d,payload:d?.payload??"{}",appPath:pe(c)})})},Vv=l=>{const s=new su,r=new Wv,c=new Bv,d=new uu,x=new iu,E=async(C,R)=>{const U={appPath:pe(C),verbose:R.verbose||R.debug,debounceMs:R.debounceMs?parseInt(R.debounceMs,10):void 0};if(R.once){await c.execute(U);return}await r.execute(U)};l.command("dev [appPath]",{isDefault:!0}).description("Build and sync local changes (default command)").option("-o, --once","Build and sync once, then exit (useful for CI, scripts, and pre-commit hooks)").option("--debounceMs <ms>","Debounce in ms (default: 2 000)").option("-v, --verbose","Show detailed logs").option("-d, --debug","Show detailed logs (alias for --verbose)").action(E),l.command("dev:build [appPath]").description("Build and generate API client").option("--tarball","Also pack into a .tgz tarball").action(async(C,R)=>{await s.execute({appPath:pe(C),tarball:R.tarball})}),l.command("dev:typecheck [appPath]").description("Run TypeScript type checking").action(async C=>{await d.execute({appPath:pe(C)})}),l.command("dev:add [entityType]").description(`Scaffold a new entity (${Object.values(m.e).join("|")})`).option("--path <path>","Path in which the entity should be created.").action(async(C,R)=>{await x.execute(C,R?.path)}),l.command("dev:catalog-sync").description("Trigger marketplace catalog sync").option("-r, --remote <name>","Sync on a specific remote").action(async C=>{const{CatalogSyncCommand:R}=await Promise.resolve().then(()=>require("./catalog-sync-CPVoL1dR.js"));await new R().execute({remote:C.remote})}),kv(l)},Bo=async l=>{const s=l.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT,r=l.port?parseInt(l.port,10):s;(isNaN(r)||r<1||r>65535)&&(console.error(y.default.red("Invalid port number.")),process.exit(1));const c=await m.serverStart({port:r,test:l.test,onProgress:d=>console.log(y.default.gray(d))});c.success||(console.error(y.default.red(c.error.message)),process.exit(1))},ko=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}Tn.execSync(`docker stop ${s}`,{stdio:"ignore"}),console.log(y.default.green("Twenty server stopped."))},Vo=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME;if(!m.containerExists(s)){console.log(y.default.yellow("No Twenty server container found."));return}try{Tn.spawnSync("docker",["logs","-f","--tail",l.lines,s],{stdio:"inherit"})}catch{}},Go=async l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=l.test?m.DEFAULT_TEST_PORT:m.DEFAULT_PORT;if(!m.containerExists(s)){console.log(` Status: ${y.default.gray("not created")}`),console.log(y.default.gray(` Run 'yarn twenty docker:start${l.test?" --test":""}' to create one.`));return}const c=m.isContainerRunning(s),d=c?m.getContainerPort(s):r,x=c?await m.checkServerHealth(d):!1,E=x?y.default.green("running (healthy)"):c?y.default.yellow("running (starting...)"):y.default.gray("stopped"),C=m.getContainerEnvVar("APP_VERSION",s);console.log(` Status: ${E}`),console.log(` URL: http://localhost:${d}`),C&&console.log(` Version: ${y.default.gray(C)}`),x&&console.log(y.default.gray(" Login: tim@apple.dev / tim@apple.dev"))},qo=l=>{const s=l.test?m.TEST_CONTAINER_NAME:m.CONTAINER_NAME,r=l.test?"twenty-app-dev-test-data":"twenty-app-dev-data",c=l.test?"twenty-app-dev-test-storage":"twenty-app-dev-storage";m.containerExists(s)&&Tn.execSync(`docker rm -f ${s}`,{stdio:"ignore"});try{Tn.execSync(`docker volume rm ${r} ${c}`,{stdio:"ignore"})}catch{}console.log(y.default.green("Twenty server data reset.")),console.log(y.default.gray(`Run 'yarn twenty docker:start${l.test?" --test":""}' to start a fresh instance.`))},Ho=async(l,s)=>{const r=await m.serverUpgrade({version:l??"latest",test:s.test,onProgress:d=>console.log(y.default.gray(d))});r.success||(console.error(y.default.red(r.error.message)),process.exit(1));const{data:c}=r;if(!c.imageUpdated){console.log(y.default.green(` Already up to date (${c.image}).`));return}console.log(y.default.green(` Upgraded to: ${c.image}`)),c.containerRecreated&&console.log(y.default.gray(` Run 'yarn twenty docker:start${s.test?" --test":""}' to wait for the server to be ready.`))},Gv=l=>{l.command("docker:start").description("Start the local Twenty container").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(Bo),l.command("docker:stop").description("Stop the local Twenty container").option("--test","Stop the test instance").action(ko),l.command("docker:logs").description("Stream container logs").option("-n, --lines <lines>","Number of lines to show","50").option("--test","Show logs for the test instance").action(Vo),l.command("docker:status").description("Show container status").option("--test","Show status of the test instance").action(Go),l.command("docker:reset").description("Delete all data and start fresh").option("--test","Reset the test instance").action(qo),l.command("docker:upgrade [version]").description("Upgrade the Docker image").option("--test","Upgrade the test instance").action(Ho);const s=l.command("server",{hidden:!0}).description("Manage a Twenty server (local instance and server-side actions)"),r=(c,d)=>console.warn(y.default.yellow(`⚠ \`twenty server ${c}\` is deprecated. Use \`twenty ${d}\` instead.`));s.command("start").option("-p, --port <port>","HTTP port").option("--test","Start a separate test instance (port 2021)").action(async c=>{r("start","docker:start"),await Bo(c)}),s.command("stop").option("--test","Stop the test instance").action(c=>{r("stop","docker:stop"),ko(c)}),s.command("logs").option("-n, --lines <lines>","Number of lines to show","50").option("--test","Show logs for the test instance").action(c=>{r("logs","docker:logs"),Vo(c)}),s.command("status").option("--test","Show status of the test instance").action(async c=>{r("status","docker:status"),await Go(c)}),s.command("reset").option("--test","Reset the test instance").action(c=>{r("reset","docker:reset"),qo(c)}),s.command("upgrade [version]").option("--test","Upgrade the test instance").action(async(c,d)=>{r("upgrade","docker:upgrade"),await Ho(c,d)}),s.command("catalog-sync").option("-r, --remote <name>","Sync on a specific remote").action(async c=>{r("catalog-sync","dev:catalog-sync");const{CatalogSyncCommand:d}=await Promise.resolve().then(()=>require("./catalog-sync-CPVoL1dR.js"));await new d().execute({remote:c.remote})})},qv=l=>{try{return new URL(l).hostname.replace(/\./g,"-")}catch{return"remote"}},zo=async(l,s)=>s?((await m.authLogin({apiKey:s,apiUrl:l})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"):Hv(l),Hv=async l=>{console.log(y.default.gray("Opening browser for authentication..."));const s=await m.authLoginOAuth({apiUrl:l});if(s.success)return"OAuth";console.log(y.default.yellow(s.error.message));const r=await je.default.prompt([{type:"password",name:"apiKey",message:"API Key:",mask:"*",validate:d=>d.length>0||"API key is required"}]);return(await m.authLogin({apiKey:r.apiKey,apiUrl:l})).success||(console.error(y.default.red("✗ Authentication failed.")),process.exit(1)),"API key"},Ko=async l=>{l.apiUrl&&console.warn(y.default.yellow("⚠ --api-url is deprecated. Use --url instead."));const s=l.test?m.getConfigPath(!0):void 0,r=new m.ConfigService(s?{configPath:s}:void 0),c=await r.getRemotes();if(l.as!==void 0&&c.includes(l.as)){const C=await r.getConfigForRemote(l.as);m.ConfigService.setActiveRemote(l.as);const R=await zo(C.apiUrl,l.apiKey);console.log(y.default.green(`✓ Re-authenticated "${l.as}" via ${R}.`)),await r.setDefaultRemote(l.as),console.log(y.default.green(`✓ Default remote set to "${l.as}".`));return}let d=l.url??l.apiUrl;if(d)d=m.Ra(d);else{const C=await m.detectLocalServer();l.local?(C||(console.error(y.default.red(`No local Twenty server found.
352
+ Start one with: yarn twenty docker:start`)),process.exit(1)),console.log(y.default.gray(`Found local server at ${C}`)),d=C):d=m.Ra((await je.default.prompt([{type:"input",name:"serverUrl",message:"Twenty server URL:",validate:R=>{try{return new URL(R),!0}catch{return"Please enter a valid URL"}}}])).serverUrl)}const x=l.as??qv(d);m.ConfigService.setActiveRemote(x);const E=await zo(d,l.apiKey);console.log(y.default.green(`✓ Remote "${x}" added (${d}) via ${E}.`)),await r.setDefaultRemote(x),console.log(y.default.green(`✓ Default remote set to "${x}".`))},jo=async()=>{const l=new m.ConfigService,s=await l.getRemotes(),r=await l.getDefaultRemote();if(s.length===0){console.log("No remotes configured."),console.log("Use 'twenty remote:add' to add one.");return}console.log("");for(const c of s){const d=await l.getConfigForRemote(c),x=d.twentyCLIAccessToken?"oauth":d.apiKey?"api-key":"none",E=c===r,C=E?"* ":" ",R=E?y.default.bold(c):c;console.log(`${C}${R} ${y.default.gray(d.apiUrl)} [${x}]`)}console.log(`
353
+ `,y.default.gray("Use 'twenty remote:use <name>' to change default"))},Yo=async l=>{const s=new m.ConfigService,r=l??(await je.default.prompt([{type:"list",name:"remote",message:"Select default remote:",choices:await s.getRemotes()}])).remote;(await s.getRemotes()).includes(r)||(console.error(y.default.red(`Remote "${r}" not found.`)),process.exit(1)),await s.setDefaultRemote(r),console.log(y.default.green(`✓ Default remote set to "${r}".`))},Jo=async()=>{const l=new m.ConfigService,s=new m.ApiService,r=m.ConfigService.getActiveRemote(),c=await l.getConfig(),d=c.twentyCLIAccessToken?"oauth":c.apiKey?"api-key":"none";if(console.log(` Remote: ${y.default.bold(r)}`),console.log(` Server: ${c.apiUrl}`),d==="none"){console.log(` Auth: ${y.default.yellow("not configured")}`);return}const{authValid:x}=await s.validateAuth(),E=x?y.default.green(`${d} (valid)`):y.default.red(`${d} (invalid)`);console.log(` Auth: ${E}`)},Zo=async l=>{const s=new m.ConfigService;(await s.getRemotes()).includes(l)||(console.error(y.default.red(`Remote "${l}" not found.`)),process.exit(1)),m.ConfigService.setActiveRemote(l),await s.clearConfig(),console.log(y.default.green(`✓ Remote "${l}" removed.`))},zv=l=>{l.command("remote:add").description("Add or re-authenticate a remote").option("--as <name>","Name for this remote").option("--api-key <apiKey>","API key for non-interactive auth").option("--url <url>","Server URL").option("--api-url <apiUrl>","[deprecated: use --url]").option("--local","Connect to a local Twenty server (auto-detect)").option("--test","Write to config.test.json (for integration tests)").action(Ko),l.command("remote:list").description("List all configured remotes").action(jo),l.command("remote:use [name]").description("Set the default remote").action(Yo),l.command("remote:status").description("Show active remote auth status").action(Jo),l.command("remote:remove <name>").description("Remove a remote").action(Zo);const s=l.command("remote",{hidden:!0}).description("Manage remote Twenty servers"),r=(c,d)=>console.warn(y.default.yellow(`⚠ \`twenty remote ${c}\` is deprecated. Use \`twenty ${d}\` instead.`));s.command("add").option("--as <name>","Name for this remote").option("--api-key <apiKey>","API key for non-interactive auth").option("--url <url>","Server URL").option("--api-url <apiUrl>","[deprecated: use --url]").option("--local","Connect to a local Twenty server (auto-detect)").option("--test","Write to config.test.json (for integration tests)").action(async c=>{r("add","remote:add"),await Ko(c)}),s.command("list").action(async()=>{r("list","remote:list"),await jo()}),s.command("switch [name]").action(async c=>{r("switch","remote:use"),await Yo(c)}),s.command("status").action(async()=>{r("status","remote:status"),await Jo()}),s.command("remove <name>").action(async c=>{r("remove","remote:remove"),await Zo(c)})},Kv=l=>{Vv(l),Em(l),Gv(l),zv(l),Ym(l)};Sm.inspect.defaultOptions.depth=10;const nn=new Xo.Command;nn.name("twenty").description("CLI for Twenty application development").version(m.packageJson.version);nn.option("-r, --remote <name>","Use a specific remote (overrides the default set by remote:use)");nn.hook("preAction",async l=>{let r=(l.optsWithGlobals?l.optsWithGlobals():l.opts()).remote;r?console.log(y.default.gray(`Using remote: ${r}`)):r=await new m.ConfigService().getDefaultRemote(),m.ConfigService.setActiveRemote(r)});Kv(nn);nn.exitOverride();try{nn.parse()}catch(l){l instanceof Xo.CommanderError&&process.exit(l.exitCode),l instanceof Error&&(console.error(y.default.red("Error:"),l.message),process.exit(1))}