moi-computer 0.3.1-next.1 → 0.4.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.
- package/README.md +49 -12
- package/client/features/chat/tool-group/format.ts +22 -1
- package/client/features/dev/HarnessDebugPage.tsx +210 -74
- package/client/main.tsx +10 -2
- package/dist/chunk-19g80zc9.css +1 -0
- package/dist/{chunk-jen6xcm1.js → chunk-2vaafjp4.js} +1 -1
- package/dist/{chunk-vkvb3hjm.js → chunk-35fq49qa.js} +1 -1
- package/dist/chunk-69nhbjhy.js +50 -0
- package/dist/{chunk-sxbfh73c.js → chunk-72atbmh3.js} +1 -1
- package/dist/{chunk-anqmsbjt.js → chunk-7mkv2gr0.js} +1 -1
- package/dist/{chunk-1dfbr7n2.js → chunk-fh2mf6v9.js} +2 -2
- package/dist/chunk-gt7n06ef.js +1 -0
- package/dist/{chunk-hbvfb6sk.js → chunk-jwmc32rp.js} +3 -3
- package/dist/{chunk-yp4srgqt.js → chunk-kh24bstm.js} +2 -2
- package/dist/chunk-sfa4mbmx.js +15 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/harness/claude-code/index.ts +2 -1
- package/server/harness/codex/adapter.ts +100 -9
- package/server/harness/codex/client.ts +34 -1
- package/server/harness/codex/index.ts +2 -1
- package/server/harness/codex/session.ts +32 -8
- package/dist/chunk-339jds4x.js +0 -15
- package/dist/chunk-3xsvsnhr.css +0 -1
- package/dist/chunk-6c8cwpzc.js +0 -1
- package/dist/chunk-qwm5f6qk.js +0 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as h2,c as yd,d as eG,e as VG,f as HU,g as zU,h as T4,i as P3,j as WU,k as nG,l as KU,m as VU,n as $$,o as pq,p as fG,q as pG,r as uG,s as cG,t as dG,u as lG,x as dU,y as Y9}from"/chunk-
|
|
1
|
+
import{b as h2,c as yd,d as eG,e as VG,f as HU,g as zU,h as T4,i as P3,j as WU,k as nG,l as KU,m as VU,n as $$,o as pq,p as fG,q as pG,r as uG,s as cG,t as dG,u as lG,x as dU,y as Y9}from"/chunk-7mkv2gr0.js";import{$ as gC,A as y9,B as ZS,D as fY,E as o3,F as tC,G as U0,H as Q1,I as C1,J as Y1,K as Hq,L as P0,M as GZ,N as F0,O as xN,P as sX,Q as NU,R as j6,S as TN,T as R6,U as Dq,V as t2,W as sJ,X as p2,Y as B1,Z as lX,_ as h5,aa as t3,ba as E1,ca as aC,da as Zj,ea as Jj,fa as $j,ga as nW,z as xq}from"/chunk-sfa4mbmx.js";import{$a as LT,$b as dT,Aa as B3,Ab as yT,Ac as d9,Bb as CY,Bc as sw,Cb as ZV,Cc as n0,Da as gK,Db as uC,Dc as v5,Ea as N1,Eb as bT,Ec as sC,Fa as rU,Gb as Y2,Ha as XT,Hb as xT,Ia as wO,Ib as hT,Ja as QT,Jb as vT,Kb as SO,La as nL,Lb as FC,Ma as UC,Mb as gT,Na as eK,Nb as mT,Oa as YT,Ob as fT,Pa as GT,Pb as SY,Qa as HT,Qb as $Q,Ra as zT,Rb as pT,Sa as WT,Sb as uT,Ta as KT,Ua as pC,Va as VT,Wa as qT,Wb as H_,Xa as UT,Xb as OY,Ya as BT,Yb as cT,Za as FT,Zb as a5,_a as rN,ab as V8,ac as lT,bb as qX,bc as eZ,cb as BC,cc as iT,db as NT,dc as rT,eb as _T,ec as JV,fb as MT,fc as GL,gc as aT,ha as m,hb as AT,hc as sT,ia as a,ib as DT,ja as cJ,jb as PT,jc as nT,ka as _2,kb as OT,lb as wT,lc as oT,ma as Aq,mb as TL,mc as tT,na as B0,nc as eT,oa as p0,ob as jT,oc as ZC,pa as fV,pb as q8,pc as Lj,qa as O$,qb as TT,qc as JC,rb as CT,sb as ST,sc as LC,tb as Y6,tc as $C,ub as ET,va as Tq,vb as IT,vc as XC,wa as T6,wc as QC,xa as w6,xb as kT,xc as X9,yb as RT,yc as ew,za as lJ,zc as KF}from"/chunk-kh24bstm.js";import{Fc as w,Gc as d0,Hc as D9,Ic as fK}from"/chunk-35fq49qa.js";var O_=d0((BH1,P_)=>{var __=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,sy=/\n/g,ny=/^\s*/,oy=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,ty=/^:\s*/,ey=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Zb=/^[;\s]*/,Jb=/^\s+|\s+$/g,$b=`
|
|
2
2
|
`,M_="/",A_="*",i4="",Xb="comment",Qb="declaration";function Yb(Z,J){if(typeof Z!=="string")throw TypeError("First argument must be a string");if(!Z)return[];J=J||{};var $=1,X=1;function Q(B){var F=B.match(sy);if(F)$+=F.length;var N=B.lastIndexOf($b);X=~N?B.length-N:X+B.length}function Y(){var B={line:$,column:X};return function(F){return F.position=new G(B),W(),F}}function G(B){this.start=B,this.end={line:$,column:X},this.source=J.source}G.prototype.content=Z;function H(B){var F=Error(J.source+":"+$+":"+X+": "+B);if(F.reason=B,F.filename=J.source,F.line=$,F.column=X,F.source=Z,J.silent);else throw F}function z(B){var F=B.exec(Z);if(!F)return;var N=F[0];return Q(N),Z=Z.slice(N.length),F}function W(){z(ny)}function V(B){var F;B=B||[];while(F=K())if(F!==!1)B.push(F);return B}function K(){var B=Y();if(M_!=Z.charAt(0)||A_!=Z.charAt(1))return;var F=2;while(i4!=Z.charAt(F)&&(A_!=Z.charAt(F)||M_!=Z.charAt(F+1)))++F;if(F+=2,i4===Z.charAt(F-1))return H("End of comment missing");var N=Z.slice(2,F-2);return X+=2,Q(N),Z=Z.slice(F),X+=2,B({type:Xb,comment:N})}function U(){var B=Y(),F=z(oy);if(!F)return;if(K(),!z(ty))return H("property missing ':'");var N=z(ey),L=B({type:Qb,property:D_(F[0].replace(__,i4)),value:N?D_(N[0].replace(__,i4)):i4});return z(Zb),L}function q(){var B=[];V(B);var F;while(F=U())if(F!==!1)B.push(F),V(B);return B}return W(),q()}function D_(Z){return Z?Z.replace(Jb,i4):i4}P_.exports=Yb});var w_=d0((qZ)=>{var Gb=qZ&&qZ.__importDefault||function(Z){return Z&&Z.__esModule?Z:{default:Z}};Object.defineProperty(qZ,"__esModule",{value:!0});qZ.default=zb;var Hb=Gb(O_());function zb(Z,J){let $=null;if(!Z||typeof Z!=="string")return $;let X=(0,Hb.default)(Z),Q=typeof J==="function";return X.forEach((Y)=>{if(Y.type!=="declaration")return;let{property:G,value:H}=Y;if(Q)J(G,H,Y);else if(H)$=$||{},$[G]=H}),$}});var S_=d0((T_)=>{Object.defineProperty(T_,"__esModule",{value:!0});T_.camelCase=void 0;var Wb=/^--[a-zA-Z0-9_-]+$/,Kb=/-([a-z])/g,Vb=/^[^-]+$/,qb=/^-(webkit|moz|ms|o|khtml)-/,Ub=/^-(ms)-/,Bb=function(Z){return!Z||Vb.test(Z)||Wb.test(Z)},Fb=function(Z,J){return J.toUpperCase()},j_=function(Z,J){return"".concat(J,"-")},Lb=function(Z,J){if(J===void 0)J={};if(Bb(Z))return Z;if(Z=Z.toLowerCase(),J.reactCompat)Z=Z.replace(Ub,j_);else Z=Z.replace(qb,j_);return Z.replace(Kb,Fb)};T_.camelCase=Lb});var I_=d0((Bz,E_)=>{var Nb=Bz&&Bz.__importDefault||function(Z){return Z&&Z.__esModule?Z:{default:Z}},_b=Nb(w_()),Mb=S_();function Uz(Z,J){var $={};if(!Z||typeof Z!=="string")return $;return(0,_b.default)(Z,function(X,Q){if(X&&Q)$[(0,Mb.camelCase)(X,J)]=Q}),$}Uz.default=Uz;E_.exports=Uz});var oM=d0((YU1,nM)=>{var bQ=Object.prototype.hasOwnProperty,sM=Object.prototype.toString,cM=Object.defineProperty,dM=Object.getOwnPropertyDescriptor,lM=function(J){if(typeof Array.isArray==="function")return Array.isArray(J);return sM.call(J)==="[object Array]"},iM=function(J){if(!J||sM.call(J)!=="[object Object]")return!1;var $=bQ.call(J,"constructor"),X=J.constructor&&J.constructor.prototype&&bQ.call(J.constructor.prototype,"isPrototypeOf");if(J.constructor&&!$&&!X)return!1;var Q;for(Q in J);return typeof Q>"u"||bQ.call(J,Q)},rM=function(J,$){if(cM&&$.name==="__proto__")cM(J,$.name,{enumerable:!0,configurable:!0,value:$.newValue,writable:!0});else J[$.name]=$.newValue},aM=function(J,$){if($==="__proto__"){if(!bQ.call(J,$))return;else if(dM)return dM(J,$).value}return J[$]};nM.exports=function Z(){var J,$,X,Q,Y,G,H=arguments[0],z=1,W=arguments.length,V=!1;if(typeof H==="boolean")V=H,H=arguments[1]||{},z=2;if(H==null||typeof H!=="object"&&typeof H!=="function")H={};for(;z<W;++z)if(J=arguments[z],J!=null){for($ in J)if(X=aM(H,$),Q=aM(J,$),H!==Q){if(V&&Q&&(iM(Q)||(Y=lM(Q)))){if(Y)Y=!1,G=X&&lM(X)?X:[];else G=X&&iM(X)?X:{};rM(H,{name:$,newValue:Z(V,G,Q)})}else if(typeof Q<"u")rM(H,{name:$,newValue:Q})}}return H}});var cD=d0((TF1,uD)=>{function CD(Z){if(Z instanceof Map)Z.clear=Z.delete=Z.set=function(){throw Error("map is read-only")};else if(Z instanceof Set)Z.add=Z.clear=Z.delete=function(){throw Error("set is read-only")};return Object.freeze(Z),Object.getOwnPropertyNames(Z).forEach((J)=>{let $=Z[J],X=typeof $;if((X==="object"||X==="function")&&!Object.isFrozen($))CD($)}),Z}class GW{constructor(Z){if(Z.data===void 0)Z.data={};this.data=Z.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function SD(Z){return Z.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function s7(Z,...J){let $=Object.create(null);for(let X in Z)$[X]=Z[X];return J.forEach(function(X){for(let Q in X)$[Q]=X[Q]}),$}var dv="</span>",DD=(Z)=>{return!!Z.scope},lv=(Z,{prefix:J})=>{if(Z.startsWith("language:"))return Z.replace("language:","language-");if(Z.includes(".")){let $=Z.split(".");return[`${J}${$.shift()}`,...$.map((X,Q)=>`${X}${"_".repeat(Q+1)}`)].join(" ")}return`${J}${Z}`};class ED{constructor(Z,J){this.buffer="",this.classPrefix=J.classPrefix,Z.walk(this)}addText(Z){this.buffer+=SD(Z)}openNode(Z){if(!DD(Z))return;let J=lv(Z.scope,{prefix:this.classPrefix});this.span(J)}closeNode(Z){if(!DD(Z))return;this.buffer+=dv}value(){return this.buffer}span(Z){this.buffer+=`<span class="${Z}">`}}var PD=(Z={})=>{let J={children:[]};return Object.assign(J,Z),J};class HW{constructor(){this.rootNode=PD(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(Z){this.top.children.push(Z)}openNode(Z){let J=PD({scope:Z});this.add(J),this.stack.push(J)}closeNode(){if(this.stack.length>1)return this.stack.pop();return}closeAllNodes(){while(this.closeNode());}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(Z){return this.constructor._walk(Z,this.rootNode)}static _walk(Z,J){if(typeof J==="string")Z.addText(J);else if(J.children)Z.openNode(J),J.children.forEach(($)=>this._walk(Z,$)),Z.closeNode(J);return Z}static _collapse(Z){if(typeof Z==="string")return;if(!Z.children)return;if(Z.children.every((J)=>typeof J==="string"))Z.children=[Z.children.join("")];else Z.children.forEach((J)=>{HW._collapse(J)})}}class ID extends HW{constructor(Z){super();this.options=Z}addText(Z){if(Z==="")return;this.add(Z)}startScope(Z){this.openNode(Z)}endScope(){this.closeNode()}__addSublanguage(Z,J){let $=Z.root;if(J)$.scope=`language:${J}`;this.add($)}toHTML(){return new ED(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function EZ(Z){if(!Z)return null;if(typeof Z==="string")return Z;return Z.source}function kD(Z){return $6("(?=",Z,")")}function iv(Z){return $6("(?:",Z,")*")}function rv(Z){return $6("(?:",Z,")?")}function $6(...Z){return Z.map(($)=>EZ($)).join("")}function av(Z){let J=Z[Z.length-1];if(typeof J==="object"&&J.constructor===Object)return Z.splice(Z.length-1,1),J;else return{}}function zW(...Z){return"("+(av(Z).capture?"":"?:")+Z.map((X)=>EZ(X)).join("|")+")"}function RD(Z){return new RegExp(Z.toString()+"|").exec("").length-1}function sv(Z,J){let $=Z&&Z.exec(J);return $&&$.index===0}var nv=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function WW(Z,{joinWith:J}){let $=0;return Z.map((X)=>{$+=1;let Q=$,Y=EZ(X),G="";while(Y.length>0){let H=nv.exec(Y);if(!H){G+=Y;break}if(G+=Y.substring(0,H.index),Y=Y.substring(H.index+H[0].length),H[0][0]==="\\"&&H[1])G+="\\"+String(Number(H[1])+Q);else if(G+=H[0],H[0]==="(")$++}return G}).map((X)=>`(${X})`).join(J)}var ov=/\b\B/,yD="[a-zA-Z]\\w*",KW="[a-zA-Z_]\\w*",bD="\\b\\d+(\\.\\d+)?",xD="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",hD="\\b(0b[01]+)",tv="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ev=(Z={})=>{let J=/^#![ ]*\//;if(Z.binary)Z.begin=$6(J,/.*\b/,Z.binary,/\b.*/);return s7({scope:"meta",begin:J,end:/$/,relevance:0,"on:begin":($,X)=>{if($.index!==0)X.ignoreMatch()}},Z)},IZ={begin:"\\\\[\\s\\S]",relevance:0},Zg={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[IZ]},Jg={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[IZ]},$g={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},iQ=function(Z,J,$={}){let X=s7({scope:"comment",begin:Z,end:J,contains:[]},$);X.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let Q=zW("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return X.contains.push({begin:$6(/[ ]+/,"(",Q,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),X},Xg=iQ("//","$"),Qg=iQ("/\\*","\\*/"),Yg=iQ("#","$"),Gg={scope:"number",begin:bD,relevance:0},Hg={scope:"number",begin:xD,relevance:0},zg={scope:"number",begin:hD,relevance:0},Wg={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[IZ,{begin:/\[/,end:/\]/,relevance:0,contains:[IZ]}]},Kg={scope:"title",begin:yD,relevance:0},Vg={scope:"title",begin:KW,relevance:0},qg={begin:"\\.\\s*"+KW,relevance:0},Ug=function(Z){return Object.assign(Z,{"on:begin":(J,$)=>{$.data._beginMatch=J[1]},"on:end":(J,$)=>{if($.data._beginMatch!==J[1])$.ignoreMatch()}})},dQ=Object.freeze({__proto__:null,APOS_STRING_MODE:Zg,BACKSLASH_ESCAPE:IZ,BINARY_NUMBER_MODE:zg,BINARY_NUMBER_RE:hD,COMMENT:iQ,C_BLOCK_COMMENT_MODE:Qg,C_LINE_COMMENT_MODE:Xg,C_NUMBER_MODE:Hg,C_NUMBER_RE:xD,END_SAME_AS_BEGIN:Ug,HASH_COMMENT_MODE:Yg,IDENT_RE:yD,MATCH_NOTHING_RE:ov,METHOD_GUARD:qg,NUMBER_MODE:Gg,NUMBER_RE:bD,PHRASAL_WORDS_MODE:$g,QUOTE_STRING_MODE:Jg,REGEXP_MODE:Wg,RE_STARTERS_RE:tv,SHEBANG:ev,TITLE_MODE:Kg,UNDERSCORE_IDENT_RE:KW,UNDERSCORE_TITLE_MODE:Vg});function Bg(Z,J){if(Z.input[Z.index-1]===".")J.ignoreMatch()}function Fg(Z,J){if(Z.className!==void 0)Z.scope=Z.className,delete Z.className}function Lg(Z,J){if(!J)return;if(!Z.beginKeywords)return;if(Z.begin="\\b("+Z.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Z.__beforeBegin=Bg,Z.keywords=Z.keywords||Z.beginKeywords,delete Z.beginKeywords,Z.relevance===void 0)Z.relevance=0}function Ng(Z,J){if(!Array.isArray(Z.illegal))return;Z.illegal=zW(...Z.illegal)}function _g(Z,J){if(!Z.match)return;if(Z.begin||Z.end)throw Error("begin & end are not supported with match");Z.begin=Z.match,delete Z.match}function Mg(Z,J){if(Z.relevance===void 0)Z.relevance=1}var Ag=(Z,J)=>{if(!Z.beforeMatch)return;if(Z.starts)throw Error("beforeMatch cannot be used with starts");let $=Object.assign({},Z);Object.keys(Z).forEach((X)=>{delete Z[X]}),Z.keywords=$.keywords,Z.begin=$6($.beforeMatch,kD($.begin)),Z.starts={relevance:0,contains:[Object.assign($,{endsParent:!0})]},Z.relevance=0,delete $.beforeMatch},Dg=["of","and","for","in","not","or","if","then","parent","list","value"],Pg="keyword";function vD(Z,J,$=Pg){let X=Object.create(null);if(typeof Z==="string")Q($,Z.split(" "));else if(Array.isArray(Z))Q($,Z);else Object.keys(Z).forEach(function(Y){Object.assign(X,vD(Z[Y],J,Y))});return X;function Q(Y,G){if(J)G=G.map((H)=>H.toLowerCase());G.forEach(function(H){let z=H.split("|");X[z[0]]=[Y,Og(z[0],z[1])]})}}function Og(Z,J){if(J)return Number(J);return wg(Z)?0:1}function wg(Z){return Dg.includes(Z.toLowerCase())}var OD={},J6=(Z)=>{console.error(Z)},wD=(Z,...J)=>{console.log(`WARN: ${Z}`,...J)},j8=(Z,J)=>{if(OD[`${Z}/${J}`])return;console.log(`Deprecated as of ${Z}. ${J}`),OD[`${Z}/${J}`]=!0},lQ=Error();function gD(Z,J,{key:$}){let X=0,Q=Z[$],Y={},G={};for(let H=1;H<=J.length;H++)G[H+X]=Q[H],Y[H+X]=!0,X+=RD(J[H-1]);Z[$]=G,Z[$]._emit=Y,Z[$]._multi=!0}function jg(Z){if(!Array.isArray(Z.begin))return;if(Z.skip||Z.excludeBegin||Z.returnBegin)throw J6("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),lQ;if(typeof Z.beginScope!=="object"||Z.beginScope===null)throw J6("beginScope must be object"),lQ;gD(Z,Z.begin,{key:"beginScope"}),Z.begin=WW(Z.begin,{joinWith:""})}function Tg(Z){if(!Array.isArray(Z.end))return;if(Z.skip||Z.excludeEnd||Z.returnEnd)throw J6("skip, excludeEnd, returnEnd not compatible with endScope: {}"),lQ;if(typeof Z.endScope!=="object"||Z.endScope===null)throw J6("endScope must be object"),lQ;gD(Z,Z.end,{key:"endScope"}),Z.end=WW(Z.end,{joinWith:""})}function Cg(Z){if(Z.scope&&typeof Z.scope==="object"&&Z.scope!==null)Z.beginScope=Z.scope,delete Z.scope}function Sg(Z){if(Cg(Z),typeof Z.beginScope==="string")Z.beginScope={_wrap:Z.beginScope};if(typeof Z.endScope==="string")Z.endScope={_wrap:Z.endScope};jg(Z),Tg(Z)}function Eg(Z){function J(G,H){return new RegExp(EZ(G),"m"+(Z.case_insensitive?"i":"")+(Z.unicodeRegex?"u":"")+(H?"g":""))}class ${constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(G,H){H.position=this.position++,this.matchIndexes[this.matchAt]=H,this.regexes.push([H,G]),this.matchAt+=RD(G)+1}compile(){if(this.regexes.length===0)this.exec=()=>null;let G=this.regexes.map((H)=>H[1]);this.matcherRe=J(WW(G,{joinWith:"|"}),!0),this.lastIndex=0}exec(G){this.matcherRe.lastIndex=this.lastIndex;let H=this.matcherRe.exec(G);if(!H)return null;let z=H.findIndex((V,K)=>K>0&&V!==void 0),W=this.matchIndexes[z];return H.splice(0,z),Object.assign(H,W)}}class X{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(G){if(this.multiRegexes[G])return this.multiRegexes[G];let H=new $;return this.rules.slice(G).forEach(([z,W])=>H.addRule(z,W)),H.compile(),this.multiRegexes[G]=H,H}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(G,H){if(this.rules.push([G,H]),H.type==="begin")this.count++}exec(G){let H=this.getMatcher(this.regexIndex);H.lastIndex=this.lastIndex;let z=H.exec(G);if(this.resumingScanAtSamePosition())if(z&&z.index===this.lastIndex);else{let W=this.getMatcher(0);W.lastIndex=this.lastIndex+1,z=W.exec(G)}if(z){if(this.regexIndex+=z.position+1,this.regexIndex===this.count)this.considerAll()}return z}}function Q(G){let H=new X;if(G.contains.forEach((z)=>H.addRule(z.begin,{rule:z,type:"begin"})),G.terminatorEnd)H.addRule(G.terminatorEnd,{type:"end"});if(G.illegal)H.addRule(G.illegal,{type:"illegal"});return H}function Y(G,H){let z=G;if(G.isCompiled)return z;[Fg,_g,Sg,Ag].forEach((V)=>V(G,H)),Z.compilerExtensions.forEach((V)=>V(G,H)),G.__beforeBegin=null,[Lg,Ng,Mg].forEach((V)=>V(G,H)),G.isCompiled=!0;let W=null;if(typeof G.keywords==="object"&&G.keywords.$pattern)G.keywords=Object.assign({},G.keywords),W=G.keywords.$pattern,delete G.keywords.$pattern;if(W=W||/\w+/,G.keywords)G.keywords=vD(G.keywords,Z.case_insensitive);if(z.keywordPatternRe=J(W,!0),H){if(!G.begin)G.begin=/\B|\b/;if(z.beginRe=J(z.begin),!G.end&&!G.endsWithParent)G.end=/\B|\b/;if(G.end)z.endRe=J(z.end);if(z.terminatorEnd=EZ(z.end)||"",G.endsWithParent&&H.terminatorEnd)z.terminatorEnd+=(G.end?"|":"")+H.terminatorEnd}if(G.illegal)z.illegalRe=J(G.illegal);if(!G.contains)G.contains=[];if(G.contains=[].concat(...G.contains.map(function(V){return Ig(V==="self"?G:V)})),G.contains.forEach(function(V){Y(V,z)}),G.starts)Y(G.starts,H);return z.matcher=Q(z),z}if(!Z.compilerExtensions)Z.compilerExtensions=[];if(Z.contains&&Z.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Z.classNameAliases=s7(Z.classNameAliases||{}),Y(Z)}function mD(Z){if(!Z)return!1;return Z.endsWithParent||mD(Z.starts)}function Ig(Z){if(Z.variants&&!Z.cachedVariants)Z.cachedVariants=Z.variants.map(function(J){return s7(Z,{variants:null},J)});if(Z.cachedVariants)return Z.cachedVariants;if(mD(Z))return s7(Z,{starts:Z.starts?s7(Z.starts):null});if(Object.isFrozen(Z))return s7(Z);return Z}var kg="11.11.1";class fD extends Error{constructor(Z,J){super(Z);this.name="HTMLInjectionError",this.html=J}}var YW=SD,jD=s7,TD=Symbol("nomatch"),Rg=7,pD=function(Z){let J=Object.create(null),$=Object.create(null),X=[],Q=!0,Y="Could not find the language '{}', did you forget to load/include a language module?",G={disableAutodetect:!0,name:"Plain text",contains:[]},H={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ID};function z(R){return H.noHighlightRe.test(R)}function W(R){let x=R.className+" ";x+=R.parentNode?R.parentNode.className:"";let h=H.languageDetectRe.exec(x);if(h){let d=C(h[1]);if(!d)wD(Y.replace("{}",h[1])),wD("Falling back to no-highlight mode for this block.",R);return d?h[1]:"no-highlight"}return x.split(/\s+/).find((d)=>z(d)||C(d))}function V(R,x,h){let d="",O="";if(typeof x==="object")d=R,h=x.ignoreIllegals,O=x.language;else j8("10.7.0","highlight(lang, code, ...args) has been deprecated."),j8("10.7.0",`Please use highlight(code, options) instead.
|
|
3
3
|
https://github.com/highlightjs/highlight.js/issues/2277`),O=R,d=x;if(h===void 0)h=!0;let K1={code:d,language:O};S("before:highlight",K1);let Z1=K1.result?K1.result:K(K1.language,K1.code,h);return Z1.code=K1.code,S("after:highlight",Z1),Z1}function K(R,x,h,d){let O=Object.create(null);function K1(v,p){return v.keywords[p]}function Z1(){if(!i.keywords){H1.addText(r);return}let v=0;i.keywordPatternRe.lastIndex=0;let p=i.keywordPatternRe.exec(r),s="";while(p){s+=r.substring(v,p.index);let q1=M1.case_insensitive?p[0].toLowerCase():p[0],w1=K1(i,q1);if(w1){let[h1,D0]=w1;if(H1.addText(s),s="",O[q1]=(O[q1]||0)+1,O[q1]<=Rg)c+=D0;if(h1.startsWith("_"))s+=p[0];else{let I0=M1.classNameAliases[h1]||h1;_1(p[0],I0)}}else s+=p[0];v=i.keywordPatternRe.lastIndex,p=i.keywordPatternRe.exec(r)}s+=r.substring(v),H1.addText(s)}function k(){if(r==="")return;let v=null;if(typeof i.subLanguage==="string"){if(!J[i.subLanguage]){H1.addText(r);return}v=K(i.subLanguage,r,!0,t[i.subLanguage]),t[i.subLanguage]=v._top}else v=q(r,i.subLanguage.length?i.subLanguage:null);if(i.relevance>0)c+=v.relevance;H1.__addSublanguage(v._emitter,v.language)}function e(){if(i.subLanguage!=null)k();else Z1();r=""}function _1(v,p){if(v==="")return;H1.startScope(p),H1.addText(v),H1.endScope()}function u(v,p){let s=1,q1=p.length-1;while(s<=q1){if(!v._emit[s]){s++;continue}let w1=M1.classNameAliases[v[s]]||v[s],h1=p[s];if(w1)_1(h1,w1);else r=h1,Z1(),r="";s++}}function z1(v,p){if(v.scope&&typeof v.scope==="string")H1.openNode(M1.classNameAliases[v.scope]||v.scope);if(v.beginScope){if(v.beginScope._wrap)_1(r,M1.classNameAliases[v.beginScope._wrap]||v.beginScope._wrap),r="";else if(v.beginScope._multi)u(v.beginScope,p),r=""}return i=Object.create(v,{parent:{value:i}}),i}function V1(v,p,s){let q1=sv(v.endRe,s);if(q1){if(v["on:end"]){let w1=new GW(v);if(v["on:end"](p,w1),w1.isMatchIgnored)q1=!1}if(q1){while(v.endsParent&&v.parent)v=v.parent;return v}}if(v.endsWithParent)return V1(v.parent,p,s)}function $1(v){if(i.matcher.regexIndex===0)return r+=v[0],1;else return f1=!0,0}function G1(v){let p=v[0],s=v.rule,q1=new GW(s),w1=[s.__beforeBegin,s["on:begin"]];for(let h1 of w1){if(!h1)continue;if(h1(v,q1),q1.isMatchIgnored)return $1(p)}if(s.skip)r+=p;else{if(s.excludeBegin)r+=p;if(e(),!s.returnBegin&&!s.excludeBegin)r=p}return z1(s,v),s.returnBegin?0:p.length}function U1(v){let p=v[0],s=x.substring(v.index),q1=V1(i,v,s);if(!q1)return TD;let w1=i;if(i.endScope&&i.endScope._wrap)e(),_1(p,i.endScope._wrap);else if(i.endScope&&i.endScope._multi)e(),u(i.endScope,v);else if(w1.skip)r+=p;else{if(!(w1.returnEnd||w1.excludeEnd))r+=p;if(e(),w1.excludeEnd)r=p}do{if(i.scope)H1.closeNode();if(!i.skip&&!i.subLanguage)c+=i.relevance;i=i.parent}while(i!==q1.parent);if(q1.starts)z1(q1.starts,v);return w1.returnEnd?0:p.length}function f(){let v=[];for(let p=i;p!==M1;p=p.parent)if(p.scope)v.unshift(p.scope);v.forEach((p)=>H1.openNode(p))}let o={};function n(v,p){let s=p&&p[0];if(r+=v,s==null)return e(),0;if(o.type==="begin"&&p.type==="end"&&o.index===p.index&&s===""){if(r+=x.slice(p.index,p.index+1),!Q){let q1=Error(`0 width match regex (${R})`);throw q1.languageName=R,q1.badRule=o.rule,q1}return 1}if(o=p,p.type==="begin")return G1(p);else if(p.type==="illegal"&&!h){let q1=Error('Illegal lexeme "'+s+'" for mode "'+(i.scope||"<unnamed>")+'"');throw q1.mode=i,q1}else if(p.type==="end"){let q1=U1(p);if(q1!==TD)return q1}if(p.type==="illegal"&&s==="")return r+=`
|
|
4
4
|
`,1;if(I1>1e5&&I1>p.index*3)throw Error("potential infinite loop, way more iterations than matches");return r+=s,s.length}let M1=C(R);if(!M1)throw J6(Y.replace("{}",R)),Error('Unknown language: "'+R+'"');let l=Eg(M1),W1="",i=d||l,t={},H1=new H.__emitter(H);f();let r="",c=0,F1=0,I1=0,f1=!1;try{if(!M1.__emitTokens){i.matcher.considerAll();for(;;){if(I1++,f1)f1=!1;else i.matcher.considerAll();i.matcher.lastIndex=F1;let v=i.matcher.exec(x);if(!v)break;let p=x.substring(F1,v.index),s=n(p,v);F1=v.index+s}n(x.substring(F1))}else M1.__emitTokens(x,H1);return H1.finalize(),W1=H1.toHTML(),{language:R,value:W1,relevance:c,illegal:!1,_emitter:H1,_top:i}}catch(v){if(v.message&&v.message.includes("Illegal"))return{language:R,value:YW(x),illegal:!0,relevance:0,_illegalBy:{message:v.message,index:F1,context:x.slice(F1-100,F1+100),mode:v.mode,resultSoFar:W1},_emitter:H1};else if(Q)return{language:R,value:YW(x),illegal:!1,relevance:0,errorRaised:v,_emitter:H1,_top:i};else throw v}}function U(R){let x={value:YW(R),illegal:!1,relevance:0,_top:G,_emitter:new H.__emitter(H)};return x._emitter.addText(R),x}function q(R,x){x=x||H.languages||Object.keys(J);let h=U(R),d=x.filter(C).filter(j).map((e)=>K(e,R,!1));d.unshift(h);let O=d.sort((e,_1)=>{if(e.relevance!==_1.relevance)return _1.relevance-e.relevance;if(e.language&&_1.language){if(C(e.language).supersetOf===_1.language)return 1;else if(C(_1.language).supersetOf===e.language)return-1}return 0}),[K1,Z1]=O,k=K1;return k.secondBest=Z1,k}function B(R,x,h){let d=x&&$[x]||h;R.classList.add("hljs"),R.classList.add(`language-${d}`)}function F(R){let x=null,h=W(R);if(z(h))return;if(S("before:highlightElement",{el:R,language:h}),R.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",R);return}if(R.children.length>0){if(!H.ignoreUnescapedHTML)console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(R);if(H.throwUnescapedHTML)throw new fD("One of your code blocks includes unescaped HTML.",R.innerHTML)}x=R;let d=x.textContent,O=h?V(d,{language:h,ignoreIllegals:!0}):q(d);if(R.innerHTML=O.value,R.dataset.highlighted="yes",B(R,h,O.language),R.result={language:O.language,re:O.relevance,relevance:O.relevance},O.secondBest)R.secondBest={language:O.secondBest.language,relevance:O.secondBest.relevance};S("after:highlightElement",{el:R,result:O,text:d})}function N(R){H=jD(H,R)}let L=()=>{P(),j8("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function M(){P(),j8("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let A=!1;function P(){function R(){P()}if(document.readyState==="loading"){if(!A)window.addEventListener("DOMContentLoaded",R,!1);A=!0;return}document.querySelectorAll(H.cssSelector).forEach(F)}function D(R,x){let h=null;try{h=x(Z)}catch(d){if(J6("Language definition for '{}' could not be registered.".replace("{}",R)),!Q)throw d;else J6(d);h=G}if(!h.name)h.name=R;if(J[R]=h,h.rawDefinition=x.bind(null,Z),h.aliases)y(h.aliases,{languageName:R})}function _(R){delete J[R];for(let x of Object.keys($))if($[x]===R)delete $[x]}function T(){return Object.keys(J)}function C(R){return R=(R||"").toLowerCase(),J[R]||J[$[R]]}function y(R,{languageName:x}){if(typeof R==="string")R=[R];R.forEach((h)=>{$[h.toLowerCase()]=x})}function j(R){let x=C(R);return x&&!x.disableAutodetect}function g(R){if(R["before:highlightBlock"]&&!R["before:highlightElement"])R["before:highlightElement"]=(x)=>{R["before:highlightBlock"](Object.assign({block:x.el},x))};if(R["after:highlightBlock"]&&!R["after:highlightElement"])R["after:highlightElement"]=(x)=>{R["after:highlightBlock"](Object.assign({block:x.el},x))}}function I(R){g(R),X.push(R)}function E(R){let x=X.indexOf(R);if(x!==-1)X.splice(x,1)}function S(R,x){let h=R;X.forEach(function(d){if(d[h])d[h](x)})}function b(R){return j8("10.7.0","highlightBlock will be removed entirely in v12.0"),j8("10.7.0","Please use highlightElement now."),F(R)}Object.assign(Z,{highlight:V,highlightAuto:q,highlightAll:P,highlightElement:F,highlightBlock:b,configure:N,initHighlighting:L,initHighlightingOnLoad:M,registerLanguage:D,unregisterLanguage:_,listLanguages:T,getLanguage:C,registerAliases:y,autoDetection:j,inherit:jD,addPlugin:I,removePlugin:E}),Z.debugMode=function(){Q=!1},Z.safeMode=function(){Q=!0},Z.versionString=kg,Z.regex={concat:$6,lookahead:kD,either:zW,optional:rv,anyNumberOfTimes:iv};for(let R in dQ)if(typeof dQ[R]==="object")CD(dQ[R]);return Object.assign(Z,dQ),Z},T8=pD({});T8.newInstance=()=>pD({});uD.exports=T8;T8.HighlightJS=T8;T8.default=T8});var dO=d0((VY,cO)=>{(function(Z,J){typeof VY==="object"&&typeof cO<"u"?J(VY):typeof define==="function"&&define.amd?define(["exports"],J):(Z=typeof globalThis<"u"?globalThis:Z||self,J(Z["fast-equals"]={}))})(VY,function(Z){function J(u){return function(V1,$1,G1,U1,f,o,n){return u(V1,$1,n)}}function $(u){return function(V1,$1,G1,U1){if(!V1||!$1||typeof V1!=="object"||typeof $1!=="object")return u(V1,$1,G1,U1);var f=U1.get(V1),o=U1.get($1);if(f&&o)return f===$1&&o===V1;U1.set(V1,$1),U1.set($1,V1);var n=u(V1,$1,G1,U1);return U1.delete(V1),U1.delete($1),n}}function X(u,z1){var V1={};for(var $1 in u)V1[$1]=u[$1];for(var $1 in z1)V1[$1]=z1[$1];return V1}function Q(u){return u.constructor===Object||u.constructor==null}function Y(u){return typeof u.then==="function"}function G(u,z1){return u===z1||u!==u&&z1!==z1}var H="[object Arguments]",z="[object Boolean]",W="[object Date]",V="[object RegExp]",K="[object Map]",U="[object Number]",q="[object Object]",B="[object Set]",F="[object String]",N=Object.prototype.toString;function L(u){var{areArraysEqual:z1,areDatesEqual:V1,areMapsEqual:$1,areObjectsEqual:G1,areRegExpsEqual:U1,areSetsEqual:f,createIsNestedEqual:o}=u,n=o(M1);function M1(l,W1,i){if(l===W1)return!0;if(!l||!W1||typeof l!=="object"||typeof W1!=="object")return l!==l&&W1!==W1;if(Q(l)&&Q(W1))return G1(l,W1,n,i);var t=Array.isArray(l),H1=Array.isArray(W1);if(t||H1)return t===H1&&z1(l,W1,n,i);var r=N.call(l);if(r!==N.call(W1))return!1;if(r===W)return V1(l,W1,n,i);if(r===V)return U1(l,W1,n,i);if(r===K)return $1(l,W1,n,i);if(r===B)return f(l,W1,n,i);if(r===q||r===H)return Y(l)||Y(W1)?!1:G1(l,W1,n,i);if(r===z||r===U||r===F)return G(l.valueOf(),W1.valueOf());return!1}return M1}function M(u,z1,V1,$1){var G1=u.length;if(z1.length!==G1)return!1;while(G1-- >0)if(!V1(u[G1],z1[G1],G1,G1,u,z1,$1))return!1;return!0}var A=$(M);function P(u,z1){return G(u.valueOf(),z1.valueOf())}function D(u,z1,V1,$1){var G1=u.size===z1.size;if(!G1)return!1;if(!u.size)return!0;var U1={},f=0;return u.forEach(function(o,n){if(!G1)return;var M1=!1,l=0;z1.forEach(function(W1,i){if(!M1&&!U1[l]&&(M1=V1(n,i,f,l,u,z1,$1)&&V1(o,W1,n,i,u,z1,$1)))U1[l]=!0;l++}),f++,G1=M1}),G1}var _=$(D),T="_owner",C=Object.prototype.hasOwnProperty;function y(u,z1,V1,$1){var G1=Object.keys(u),U1=G1.length;if(Object.keys(z1).length!==U1)return!1;var f;while(U1-- >0){if(f=G1[U1],f===T){var o=!!u.$$typeof,n=!!z1.$$typeof;if((o||n)&&o!==n)return!1}if(!C.call(z1,f)||!V1(u[f],z1[f],f,f,u,z1,$1))return!1}return!0}var j=$(y);function g(u,z1){return u.source===z1.source&&u.flags===z1.flags}function I(u,z1,V1,$1){var G1=u.size===z1.size;if(!G1)return!1;if(!u.size)return!0;var U1={};return u.forEach(function(f,o){if(!G1)return;var n=!1,M1=0;z1.forEach(function(l,W1){if(!n&&!U1[M1]&&(n=V1(f,l,o,W1,u,z1,$1)))U1[M1]=!0;M1++}),G1=n}),G1}var E=$(I),S=Object.freeze({areArraysEqual:M,areDatesEqual:P,areMapsEqual:D,areObjectsEqual:y,areRegExpsEqual:g,areSetsEqual:I,createIsNestedEqual:J}),b=Object.freeze({areArraysEqual:A,areDatesEqual:P,areMapsEqual:_,areObjectsEqual:j,areRegExpsEqual:g,areSetsEqual:E,createIsNestedEqual:J}),R=L(S);function x(u,z1){return R(u,z1,void 0)}var h=L(X(S,{createIsNestedEqual:function(){return G}}));function d(u,z1){return h(u,z1,void 0)}var O=L(b);function K1(u,z1){return O(u,z1,new WeakMap)}var Z1=L(X(b,{createIsNestedEqual:function(){return G}}));function k(u,z1){return Z1(u,z1,new WeakMap)}function e(u){return L(X(S,u(S)))}function _1(u){var z1=L(X(b,u(b)));return function(V1,$1,G1){if(G1===void 0)G1=new WeakMap;return z1(V1,$1,G1)}}Z.circularDeepEqual=K1,Z.circularShallowEqual=k,Z.createCustomCircularEqual=_1,Z.createCustomEqual=e,Z.deepEqual=x,Z.sameValueZeroEqual=G,Z.shallowEqual=d,Object.defineProperty(Z,"__esModule",{value:!0})})});var iO=d0((uP1,lO)=>{var mf="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";lO.exports=mf});var nO=d0((cP1,sO)=>{var ff=iO();function rO(){}function aO(){}aO.resetWarningCache=rO;sO.exports=function(){function Z(X,Q,Y,G,H,z){if(z===ff)return;var W=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw W.name="Invariant Violation",W}Z.isRequired=Z;function J(){return Z}var $={array:Z,bigint:Z,bool:Z,func:Z,number:Z,object:Z,string:Z,symbol:Z,any:Z,arrayOf:J,element:Z,elementType:Z,instanceOf:J,node:Z,objectOf:J,oneOf:J,oneOfType:J,shape:J,exact:J,checkPropTypes:aO,resetWarningCache:rO};return $.PropTypes=$,$}});var lZ=d0((dP1,oO)=>{oO.exports=nO()();var pf,uf});var Zw=d0((lP1,_K)=>{function eO(Z){var J,$,X="";if(typeof Z=="string"||typeof Z=="number")X+=Z;else if(typeof Z=="object")if(Array.isArray(Z)){var Q=Z.length;for(J=0;J<Q;J++)Z[J]&&($=eO(Z[J]))&&(X&&(X+=" "),X+=$)}else for($ in Z)Z[$]&&(X&&(X+=" "),X+=$);return X}function tO(){for(var Z,J,$=0,X="",Q=arguments.length;$<Q;$++)(Z=arguments[$])&&(J=eO(Z))&&(X&&(X+=" "),X+=J);return X}_K.exports=tO,_K.exports.clsx=tO});var iZ=d0((Jw)=>{Object.defineProperty(Jw,"__esModule",{value:!0});Jw.dontSetMe=af;Jw.findInArray=cf;Jw.int=rf;Jw.isFunction=df;Jw.isNum=lf;function cf(Z,J){for(let $=0,X=Z.length;$<X;$++)if(J.apply(J,[Z[$],$,Z]))return Z[$]}function df(Z){return typeof Z==="function"||Object.prototype.toString.call(Z)==="[object Function]"}function lf(Z){return typeof Z==="number"&&!isNaN(Z)}function rf(Z){return parseInt(Z,10)}function af(Z,J,$){if(Z[J])return Error(`Invalid prop ${J} passed to ${$} - do not set this, set it on the child.`)}});var Gw=d0((Qw)=>{Object.defineProperty(Qw,"__esModule",{value:!0});Qw.browserPrefixToKey=Xw;Qw.browserPrefixToStyle=Zp;Qw.default=void 0;Qw.getPrefix=$w;var MK=["Moz","Webkit","O","ms"];function $w(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";let J=window.document?.documentElement?.style;if(!J)return"";if(Z in J)return"";for(let $=0;$<MK.length;$++)if(Xw(Z,MK[$])in J)return MK[$];return""}function Xw(Z,J){return J?`${J}${Jp(Z)}`:Z}function Zp(Z,J){return J?`-${J.toLowerCase()}-${Z}`:Z}function Jp(Z){let J="",$=!0;for(let X=0;X<Z.length;X++)if($)J+=Z[X].toUpperCase(),$=!1;else if(Z[X]==="-")$=!0;else J+=Z[X];return J}var rP1=Qw.default=$w()});var UY=d0((Uw)=>{Object.defineProperty(Uw,"__esModule",{value:!0});Uw.addClassName=Vw;Uw.addEvent=Gp;Uw.addUserSelectStyles=Np;Uw.createCSSTransform=Up;Uw.createSVGTransform=Bp;Uw.getTouch=Fp;Uw.getTouchIdentifier=Lp;Uw.getTranslation=AK;Uw.innerHeight=Kp;Uw.innerWidth=Vp;Uw.matchesSelector=Kw;Uw.matchesSelectorAndParentsTo=Yp;Uw.offsetXYFromParent=qp;Uw.outerHeight=zp;Uw.outerWidth=Wp;Uw.removeClassName=qw;Uw.removeEvent=Hp;Uw.scheduleRemoveUserSelectStyles=_p;var j2=iZ(),Hw=Ww(Gw());function Ww(Z,J){if(typeof WeakMap=="function")var $=new WeakMap,X=new WeakMap;return(Ww=function(Q,Y){if(!Y&&Q&&Q.__esModule)return Q;var G,H,z={__proto__:null,default:Q};if(Q===null||typeof Q!="object"&&typeof Q!="function")return z;if(G=Y?X:$){if(G.has(Q))return G.get(Q);G.set(Q,z)}for(let W in Q)W!=="default"&&{}.hasOwnProperty.call(Q,W)&&((H=(G=Object.defineProperty)&&Object.getOwnPropertyDescriptor(Q,W))&&(H.get||H.set)?G(z,W,H):z[W]=Q[W]);return z})(Z,J)}var qY="";function Kw(Z,J){if(!qY)qY=(0,j2.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function($){return(0,j2.isFunction)(Z[$])});if(!(0,j2.isFunction)(Z[qY]))return!1;return Z[qY](J)}function Yp(Z,J,$){let X=Z;do{if(Kw(X,J))return!0;if(X===$)return!1;X=X.parentNode}while(X);return!1}function Gp(Z,J,$,X){if(!Z)return;let Q={capture:!0,...X};if(Z.addEventListener)Z.addEventListener(J,$,Q);else if(Z.attachEvent)Z.attachEvent("on"+J,$);else Z["on"+J]=$}function Hp(Z,J,$,X){if(!Z)return;let Q={capture:!0,...X};if(Z.removeEventListener)Z.removeEventListener(J,$,Q);else if(Z.detachEvent)Z.detachEvent("on"+J,$);else Z["on"+J]=null}function zp(Z){let J=Z.clientHeight,$=Z.ownerDocument.defaultView.getComputedStyle(Z);return J+=(0,j2.int)($.borderTopWidth),J+=(0,j2.int)($.borderBottomWidth),J}function Wp(Z){let J=Z.clientWidth,$=Z.ownerDocument.defaultView.getComputedStyle(Z);return J+=(0,j2.int)($.borderLeftWidth),J+=(0,j2.int)($.borderRightWidth),J}function Kp(Z){let J=Z.clientHeight,$=Z.ownerDocument.defaultView.getComputedStyle(Z);return J-=(0,j2.int)($.paddingTop),J-=(0,j2.int)($.paddingBottom),J}function Vp(Z){let J=Z.clientWidth,$=Z.ownerDocument.defaultView.getComputedStyle(Z);return J-=(0,j2.int)($.paddingLeft),J-=(0,j2.int)($.paddingRight),J}function qp(Z,J,$){let Q=J===J.ownerDocument.body?{left:0,top:0}:J.getBoundingClientRect(),Y=(Z.clientX+J.scrollLeft-Q.left)/$,G=(Z.clientY+J.scrollTop-Q.top)/$;return{x:Y,y:G}}function Up(Z,J){let $=AK(Z,J,"px");return{[(0,Hw.browserPrefixToKey)("transform",Hw.default)]:$}}function Bp(Z,J){return AK(Z,J,"")}function AK(Z,J,$){let{x:X,y:Q}=Z,Y=`translate(${X}${$},${Q}${$})`;if(J){let G=`${typeof J.x==="string"?J.x:J.x+$}`,H=`${typeof J.y==="string"?J.y:J.y+$}`;Y=`translate(${G}, ${H})`+Y}return Y}function Fp(Z,J){return Z.targetTouches&&(0,j2.findInArray)(Z.targetTouches,($)=>J===$.identifier)||Z.changedTouches&&(0,j2.findInArray)(Z.changedTouches,($)=>J===$.identifier)}function Lp(Z){if(Z.targetTouches&&Z.targetTouches[0])return Z.targetTouches[0].identifier;if(Z.changedTouches&&Z.changedTouches[0])return Z.changedTouches[0].identifier}function Np(Z){if(!Z)return;let J=Z.getElementById("react-draggable-style-el");if(!J)J=Z.createElement("style"),J.type="text/css",J.id="react-draggable-style-el",J.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
@@ -58,6 +58,6 @@ manually, then import it to moi`,Bk={"claude-code":"By Anthropic",codex:"By Open
|
|
|
58
58
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:U,table:G,tableCell:z,tableRow:H}};function G(q,B,F,N){return W(V(q,F,N),q.align)}function H(q,B,F,N){let L=K(q,F,N),M=W([L]);return M.slice(0,M.indexOf(`
|
|
59
59
|
`))}function z(q,B,F,N){let L=F.enter("tableCell"),M=F.enter("phrasing"),A=F.containerPhrasing(q,{...N,before:Y,after:Y});return M(),L(),A}function W(q,B){return eD(q,{align:B,alignDelimiters:X,padding:$,stringLength:Q})}function V(q,B,F){let N=q.children,L=-1,M=[],A=B.enter("table");while(++L<N.length)M[L]=K(N[L],B,F);return A(),M}function K(q,B,F){let N=q.children,L=-1,M=[],A=B.enter("tableRow");while(++L<N.length)M[L]=z(N[L],q,B,F);return A(),M}function U(q,B,F){let N=kZ.inlineCode(q,B,F);if(F.stack.includes("tableCell"))N=N.replace(/\|/g,"\\$&");return N}}function gW(){return{exit:{taskListCheckValueChecked:OP,taskListCheckValueUnchecked:OP,paragraph:Tm}}}function mW(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Cm}}}function OP(Z){let J=this.stack[this.stack.length-2];K0(J.type==="listItem"),J.checked=Z.type==="taskListCheckValueChecked"}function Tm(Z){let J=this.stack[this.stack.length-2];if(J&&J.type==="listItem"&&typeof J.checked==="boolean"){let $=this.stack[this.stack.length-1];K0($.type==="paragraph");let X=$.children[0];if(X&&X.type==="text"){let Q=J.children,Y=-1,G;while(++Y<Q.length){let H=Q[Y];if(H.type==="paragraph"){G=H;break}}if(G===$){if(X.value=X.value.slice(1),X.value.length===0)$.children.shift();else if($.position&&X.position&&typeof X.position.start.offset==="number")X.position.start.column++,X.position.start.offset++,$.position.start=Object.assign({},X.position.start)}}}this.exit(Z)}function Cm(Z,J,$,X){let Q=Z.children[0],Y=typeof Z.checked==="boolean"&&Q&&Q.type==="paragraph",G="["+(Z.checked?"x":" ")+"] ",H=$.createTracker(X);if(Y)H.move(G);let z=kZ.listItem(Z,J,$,{...X,...H.current()});if(Y)z=z.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,W);return z;function W(V){return V+G}}function fW(){return[_W(),AW(),PW(),hW(),gW()]}function pW(Z){return{extensions:[MW(),DW(Z),OW(),vW(Z),mW()]}}var Sm={tokenize:ym,partial:!0},wP={tokenize:bm,partial:!0},jP={tokenize:xm,partial:!0},TP={tokenize:hm,partial:!0},Em={tokenize:vm,partial:!0},CP={name:"wwwAutolink",tokenize:km,previous:EP},SP={name:"protocolAutolink",tokenize:Rm,previous:IP},Y7={name:"emailAutolink",tokenize:Im,previous:kP},c9={};function cW(){return{text:c9}}var X6=48;while(X6<123)if(c9[X6]=Y7,X6++,X6===58)X6=65;else if(X6===91)X6=97;c9[43]=Y7;c9[45]=Y7;c9[46]=Y7;c9[95]=Y7;c9[72]=[Y7,SP];c9[104]=[Y7,SP];c9[87]=[Y7,CP];c9[119]=[Y7,CP];function Im(Z,J,$){let X=this,Q,Y;return G;function G(K){if(!uW(K)||!kP.call(X,X.previous)||dW(X.events))return $(K);return Z.enter("literalAutolink"),Z.enter("literalAutolinkEmail"),H(K)}function H(K){if(uW(K))return Z.consume(K),H;if(K===64)return Z.consume(K),z;return $(K)}function z(K){if(K===46)return Z.check(Em,V,W)(K);if(K===45||K===95||Q5(K))return Y=!0,Z.consume(K),z;return V(K)}function W(K){return Z.consume(K),Q=!0,z}function V(K){if(Y&&Q&&A5(X.previous))return Z.exit("literalAutolinkEmail"),Z.exit("literalAutolink"),J(K);return $(K)}}function km(Z,J,$){let X=this;return Q;function Q(G){if(G!==87&&G!==119||!EP.call(X,X.previous)||dW(X.events))return $(G);return Z.enter("literalAutolink"),Z.enter("literalAutolinkWww"),Z.check(Sm,Z.attempt(wP,Z.attempt(jP,Y),$),$)(G)}function Y(G){return Z.exit("literalAutolinkWww"),Z.exit("literalAutolink"),J(G)}}function Rm(Z,J,$){let X=this,Q="",Y=!1;return G;function G(K){if((K===72||K===104)&&IP.call(X,X.previous)&&!dW(X.events))return Z.enter("literalAutolink"),Z.enter("literalAutolinkHttp"),Q+=String.fromCodePoint(K),Z.consume(K),H;return $(K)}function H(K){if(A5(K)&&Q.length<5)return Q+=String.fromCodePoint(K),Z.consume(K),H;if(K===58){let U=Q.toLowerCase();if(U==="http"||U==="https")return Z.consume(K),z}return $(K)}function z(K){if(K===47){if(Z.consume(K),Y)return W;return Y=!0,z}return $(K)}function W(K){return K===null||a4(K)||J0(K)||m9(K)||s4(K)?$(K):Z.attempt(wP,Z.attempt(jP,V),$)(K)}function V(K){return Z.exit("literalAutolinkHttp"),Z.exit("literalAutolink"),J(K)}}function ym(Z,J,$){let X=0;return Q;function Q(G){if((G===87||G===119)&&X<3)return X++,Z.consume(G),Q;if(G===46&&X===3)return Z.consume(G),Y;return $(G)}function Y(G){return G===null?$(G):J(G)}}function bm(Z,J,$){let X,Q,Y;return G;function G(W){if(W===46||W===95)return Z.check(TP,z,H)(W);if(W===null||J0(W)||m9(W)||W!==45&&s4(W))return z(W);return Y=!0,Z.consume(W),G}function H(W){if(W===95)X=!0;else Q=X,X=void 0;return Z.consume(W),G}function z(W){if(Q||X||!Y)return $(W);return J(W)}}function xm(Z,J){let $=0,X=0;return Q;function Q(G){if(G===40)return $++,Z.consume(G),Q;if(G===41&&X<$)return Y(G);if(G===33||G===34||G===38||G===39||G===41||G===42||G===44||G===46||G===58||G===59||G===60||G===63||G===93||G===95||G===126)return Z.check(TP,J,Y)(G);if(G===null||J0(G)||m9(G))return J(G);return Z.consume(G),Q}function Y(G){if(G===41)X++;return Z.consume(G),Q}}function hm(Z,J,$){return X;function X(H){if(H===33||H===34||H===39||H===41||H===42||H===44||H===46||H===58||H===59||H===63||H===95||H===126)return Z.consume(H),X;if(H===38)return Z.consume(H),Y;if(H===93)return Z.consume(H),Q;if(H===60||H===null||J0(H)||m9(H))return J(H);return $(H)}function Q(H){if(H===null||H===40||H===91||J0(H)||m9(H))return J(H);return X(H)}function Y(H){return A5(H)?G(H):$(H)}function G(H){if(H===59)return Z.consume(H),X;if(A5(H))return Z.consume(H),G;return $(H)}}function vm(Z,J,$){return X;function X(Y){return Z.consume(Y),Q}function Q(Y){return Q5(Y)?$(Y):J(Y)}}function EP(Z){return Z===null||Z===40||Z===42||Z===95||Z===91||Z===93||Z===126||J0(Z)}function IP(Z){return!A5(Z)}function kP(Z){return!(Z===47||uW(Z))}function uW(Z){return Z===43||Z===45||Z===46||Z===95||Q5(Z)}function dW(Z){let J=Z.length,$=!1;while(J--){let X=Z[J][1];if((X.type==="labelLink"||X.type==="labelImage")&&!X._balanced){$=!0;break}if(X._gfmAutolinkLiteralWalkedInto){$=!1;break}}if(Z.length>0&&!$)Z[Z.length-1][1]._gfmAutolinkLiteralWalkedInto=!0;return $}var gm={tokenize:lm,partial:!0};function lW(){return{document:{[91]:{name:"gfmFootnoteDefinition",tokenize:um,continuation:{tokenize:cm},exit:dm}},text:{[91]:{name:"gfmFootnoteCall",tokenize:pm},[93]:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:mm,resolveTo:fm}}}}function mm(Z,J,$){let X=this,Q=X.events.length,Y=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),G;while(Q--){let z=X.events[Q][1];if(z.type==="labelImage"){G=z;break}if(z.type==="gfmFootnoteCall"||z.type==="labelLink"||z.type==="label"||z.type==="image"||z.type==="link")break}return H;function H(z){if(!G||!G._balanced)return $(z);let W=n5(X.sliceSerialize({start:G.end,end:X.now()}));if(W.codePointAt(0)!==94||!Y.includes(W.slice(1)))return $(z);return Z.enter("gfmFootnoteCallLabelMarker"),Z.consume(z),Z.exit("gfmFootnoteCallLabelMarker"),J(z)}}function fm(Z,J){let $=Z.length,X;while($--)if(Z[$][1].type==="labelImage"&&Z[$][0]==="enter"){X=Z[$][1];break}Z[$+1][1].type="data",Z[$+3][1].type="gfmFootnoteCallLabelMarker";let Q={type:"gfmFootnoteCall",start:Object.assign({},Z[$+3][1].start),end:Object.assign({},Z[Z.length-1][1].end)},Y={type:"gfmFootnoteCallMarker",start:Object.assign({},Z[$+3][1].end),end:Object.assign({},Z[$+3][1].end)};Y.end.column++,Y.end.offset++,Y.end._bufferIndex++;let G={type:"gfmFootnoteCallString",start:Object.assign({},Y.end),end:Object.assign({},Z[Z.length-1][1].start)},H={type:"chunkString",contentType:"string",start:Object.assign({},G.start),end:Object.assign({},G.end)},z=[Z[$+1],Z[$+2],["enter",Q,J],Z[$+3],Z[$+4],["enter",Y,J],["exit",Y,J],["enter",G,J],["enter",H,J],["exit",H,J],["exit",G,J],Z[Z.length-2],Z[Z.length-1],["exit",Q,J]];return Z.splice($,Z.length-$+1,...z),Z}function pm(Z,J,$){let X=this,Q=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),Y=0,G;return H;function H(K){return Z.enter("gfmFootnoteCall"),Z.enter("gfmFootnoteCallLabelMarker"),Z.consume(K),Z.exit("gfmFootnoteCallLabelMarker"),z}function z(K){if(K!==94)return $(K);return Z.enter("gfmFootnoteCallMarker"),Z.consume(K),Z.exit("gfmFootnoteCallMarker"),Z.enter("gfmFootnoteCallString"),Z.enter("chunkString").contentType="string",W}function W(K){if(Y>999||K===93&&!G||K===null||K===91||J0(K))return $(K);if(K===93){Z.exit("chunkString");let U=Z.exit("gfmFootnoteCallString");if(!Q.includes(n5(X.sliceSerialize(U))))return $(K);return Z.enter("gfmFootnoteCallLabelMarker"),Z.consume(K),Z.exit("gfmFootnoteCallLabelMarker"),Z.exit("gfmFootnoteCall"),J}if(!J0(K))G=!0;return Y++,Z.consume(K),K===92?V:W}function V(K){if(K===91||K===92||K===93)return Z.consume(K),Y++,W;return W(K)}}function um(Z,J,$){let X=this,Q=X.parser.gfmFootnotes||(X.parser.gfmFootnotes=[]),Y,G=0,H;return z;function z(B){return Z.enter("gfmFootnoteDefinition")._container=!0,Z.enter("gfmFootnoteDefinitionLabel"),Z.enter("gfmFootnoteDefinitionLabelMarker"),Z.consume(B),Z.exit("gfmFootnoteDefinitionLabelMarker"),W}function W(B){if(B===94)return Z.enter("gfmFootnoteDefinitionMarker"),Z.consume(B),Z.exit("gfmFootnoteDefinitionMarker"),Z.enter("gfmFootnoteDefinitionLabelString"),Z.enter("chunkString").contentType="string",V;return $(B)}function V(B){if(G>999||B===93&&!H||B===null||B===91||J0(B))return $(B);if(B===93){Z.exit("chunkString");let F=Z.exit("gfmFootnoteDefinitionLabelString");return Y=n5(X.sliceSerialize(F)),Z.enter("gfmFootnoteDefinitionLabelMarker"),Z.consume(B),Z.exit("gfmFootnoteDefinitionLabelMarker"),Z.exit("gfmFootnoteDefinitionLabel"),U}if(!J0(B))H=!0;return G++,Z.consume(B),B===92?K:V}function K(B){if(B===91||B===92||B===93)return Z.consume(B),G++,V;return V(B)}function U(B){if(B===58){if(Z.enter("definitionMarker"),Z.consume(B),Z.exit("definitionMarker"),!Q.includes(Y))Q.push(Y);return y1(Z,q,"gfmFootnoteDefinitionWhitespace")}return $(B)}function q(B){return J(B)}}function cm(Z,J,$){return Z.check(f9,J,Z.attempt(gm,J,$))}function dm(Z){Z.exit("gfmFootnoteDefinition")}function lm(Z,J,$){let X=this;return y1(Z,Q,"gfmFootnoteDefinitionIndent",5);function Q(Y){let G=X.events[X.events.length-1];return G&&G[1].type==="gfmFootnoteDefinitionIndent"&&G[2].sliceSerialize(G[1],!0).length===4?J(Y):$(Y)}}function iW(Z){let $=(Z||{}).singleTilde,X={name:"strikethrough",tokenize:Y,resolveAll:Q};if($===null||$===void 0)$=!0;return{text:{[126]:X},insideSpan:{null:[X]},attentionMarkers:{null:[126]}};function Q(G,H){let z=-1;while(++z<G.length)if(G[z][0]==="enter"&&G[z][1].type==="strikethroughSequenceTemporary"&&G[z][1]._close){let W=z;while(W--)if(G[W][0]==="exit"&&G[W][1].type==="strikethroughSequenceTemporary"&&G[W][1]._open&&G[z][1].end.offset-G[z][1].start.offset===G[W][1].end.offset-G[W][1].start.offset){G[z][1].type="strikethroughSequence",G[W][1].type="strikethroughSequence";let V={type:"strikethrough",start:Object.assign({},G[W][1].start),end:Object.assign({},G[z][1].end)},K={type:"strikethroughText",start:Object.assign({},G[W][1].end),end:Object.assign({},G[z][1].start)},U=[["enter",V,H],["enter",G[W][1],H],["exit",G[W][1],H],["enter",K,H]],q=H.parser.constructs.insideSpan.null;if(q)z5(U,U.length,0,r7(q,G.slice(W+1,z),H));z5(U,U.length,0,[["exit",K,H],["enter",G[z][1],H],["exit",G[z][1],H],["exit",V,H]]),z5(G,W-1,z-W+3,U),z=W+U.length-2;break}}z=-1;while(++z<G.length)if(G[z][1].type==="strikethroughSequenceTemporary")G[z][1].type="data";return G}function Y(G,H,z){let W=this.previous,V=this.events,K=0;return U;function U(B){if(W===126&&V[V.length-1][1].type!=="characterEscape")return z(B);return G.enter("strikethroughSequenceTemporary"),q(B)}function q(B){let F=$7(W);if(B===126){if(K>1)return z(B);return G.consume(B),K++,q}if(K<2&&!$)return z(B);let N=G.exit("strikethroughSequenceTemporary"),L=$7(B);return N._open=!L||L===2&&Boolean(F),N._close=!F||F===2&&Boolean(L),H(B)}}}class rW{constructor(){this.map=[]}add(Z,J,$){im(this,Z,J,$)}consume(Z){if(this.map.sort(function(Q,Y){return Q[0]-Y[0]}),this.map.length===0)return;let J=this.map.length,$=[];while(J>0)J-=1,$.push(Z.slice(this.map[J][0]+this.map[J][1]),this.map[J][2]),Z.length=this.map[J][0];$.push(Z.slice()),Z.length=0;let X=$.pop();while(X){for(let Q of X)Z.push(Q);X=$.pop()}this.map.length=0}}function im(Z,J,$,X){let Q=0;if($===0&&X.length===0)return;while(Q<Z.map.length){if(Z.map[Q][0]===J){Z.map[Q][1]+=$,Z.map[Q][2].push(...X);return}Q+=1}Z.map.push([J,$,X])}function RP(Z,J){let $=!1,X=[];while(J<Z.length){let Q=Z[J];if($){if(Q[0]==="enter"){if(Q[1].type==="tableContent")X.push(Z[J+1][1].type==="tableDelimiterMarker"?"left":"none")}else if(Q[1].type==="tableContent"){if(Z[J-1][1].type==="tableDelimiterMarker"){let Y=X.length-1;X[Y]=X[Y]==="left"?"center":"right"}}else if(Q[1].type==="tableDelimiterRow")break}else if(Q[0]==="enter"&&Q[1].type==="tableDelimiterRow")$=!0;J+=1}return X}function aW(){return{flow:{null:{name:"table",tokenize:rm,resolveAll:am}}}}function rm(Z,J,$){let X=this,Q=0,Y=0,G;return H;function H(j){let g=X.events.length-1;while(g>-1){let S=X.events[g][1].type;if(S==="lineEnding"||S==="linePrefix")g--;else break}let I=g>-1?X.events[g][1].type:null,E=I==="tableHead"||I==="tableRow"?_:z;if(E===_&&X.parser.lazy[X.now().line])return $(j);return E(j)}function z(j){return Z.enter("tableHead"),Z.enter("tableRow"),W(j)}function W(j){if(j===124)return V(j);return G=!0,Y+=1,V(j)}function V(j){if(j===null)return $(j);if(O1(j)){if(Y>1)return Y=0,X.interrupt=!0,Z.exit("tableRow"),Z.enter("lineEnding"),Z.consume(j),Z.exit("lineEnding"),q;return $(j)}if(x1(j))return y1(Z,V,"whitespace")(j);if(Y+=1,G)G=!1,Q+=1;if(j===124)return Z.enter("tableCellDivider"),Z.consume(j),Z.exit("tableCellDivider"),G=!0,V;return Z.enter("data"),K(j)}function K(j){if(j===null||j===124||J0(j))return Z.exit("data"),V(j);return Z.consume(j),j===92?U:K}function U(j){if(j===92||j===124)return Z.consume(j),K;return K(j)}function q(j){if(X.interrupt=!1,X.parser.lazy[X.now().line])return $(j);if(Z.enter("tableDelimiterRow"),G=!1,x1(j))return y1(Z,B,"linePrefix",X.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j);return B(j)}function B(j){if(j===45||j===58)return N(j);if(j===124)return G=!0,Z.enter("tableCellDivider"),Z.consume(j),Z.exit("tableCellDivider"),F;return D(j)}function F(j){if(x1(j))return y1(Z,N,"whitespace")(j);return N(j)}function N(j){if(j===58)return Y+=1,G=!0,Z.enter("tableDelimiterMarker"),Z.consume(j),Z.exit("tableDelimiterMarker"),L;if(j===45)return Y+=1,L(j);if(j===null||O1(j))return P(j);return D(j)}function L(j){if(j===45)return Z.enter("tableDelimiterFiller"),M(j);return D(j)}function M(j){if(j===45)return Z.consume(j),M;if(j===58)return G=!0,Z.exit("tableDelimiterFiller"),Z.enter("tableDelimiterMarker"),Z.consume(j),Z.exit("tableDelimiterMarker"),A;return Z.exit("tableDelimiterFiller"),A(j)}function A(j){if(x1(j))return y1(Z,P,"whitespace")(j);return P(j)}function P(j){if(j===124)return B(j);if(j===null||O1(j)){if(!G||Q!==Y)return D(j);return Z.exit("tableDelimiterRow"),Z.exit("tableHead"),J(j)}return D(j)}function D(j){return $(j)}function _(j){return Z.enter("tableRow"),T(j)}function T(j){if(j===124)return Z.enter("tableCellDivider"),Z.consume(j),Z.exit("tableCellDivider"),T;if(j===null||O1(j))return Z.exit("tableRow"),J(j);if(x1(j))return y1(Z,T,"whitespace")(j);return Z.enter("data"),C(j)}function C(j){if(j===null||j===124||J0(j))return Z.exit("data"),T(j);return Z.consume(j),j===92?y:C}function y(j){if(j===92||j===124)return Z.consume(j),C;return C(j)}}function am(Z,J){let $=-1,X=!0,Q=0,Y=[0,0,0,0],G=[0,0,0,0],H=!1,z=0,W,V,K,U=new rW;while(++$<Z.length){let q=Z[$],B=q[1];if(q[0]==="enter"){if(B.type==="tableHead"){if(H=!1,z!==0)yP(U,J,z,W,V),V=void 0,z=0;W={type:"table",start:Object.assign({},B.start),end:Object.assign({},B.end)},U.add($,0,[["enter",W,J]])}else if(B.type==="tableRow"||B.type==="tableDelimiterRow"){if(X=!0,K=void 0,Y=[0,0,0,0],G=[0,$+1,0,0],H)H=!1,V={type:"tableBody",start:Object.assign({},B.start),end:Object.assign({},B.end)},U.add($,0,[["enter",V,J]]);Q=B.type==="tableDelimiterRow"?2:V?3:1}else if(Q&&(B.type==="data"||B.type==="tableDelimiterMarker"||B.type==="tableDelimiterFiller")){if(X=!1,G[2]===0){if(Y[1]!==0)G[0]=G[1],K=sQ(U,J,Y,Q,void 0,K),Y=[0,0,0,0];G[2]=$}}else if(B.type==="tableCellDivider")if(X)X=!1;else{if(Y[1]!==0)G[0]=G[1],K=sQ(U,J,Y,Q,void 0,K);Y=G,G=[Y[1],$,0,0]}}else if(B.type==="tableHead")H=!0,z=$;else if(B.type==="tableRow"||B.type==="tableDelimiterRow"){if(z=$,Y[1]!==0)G[0]=G[1],K=sQ(U,J,Y,Q,$,K);else if(G[1]!==0)K=sQ(U,J,G,Q,$,K);Q=0}else if(Q&&(B.type==="data"||B.type==="tableDelimiterMarker"||B.type==="tableDelimiterFiller"))G[3]=$}if(z!==0)yP(U,J,z,W,V);U.consume(J.events),$=-1;while(++$<J.events.length){let q=J.events[$];if(q[0]==="enter"&&q[1].type==="table")q[1]._align=RP(J.events,$)}return Z}function sQ(Z,J,$,X,Q,Y){let G=X===1?"tableHeader":X===2?"tableDelimiter":"tableData",H="tableContent";if($[0]!==0)Y.end=Object.assign({},I8(J.events,$[0])),Z.add($[0],0,[["exit",Y,J]]);let z=I8(J.events,$[1]);if(Y={type:G,start:Object.assign({},z),end:Object.assign({},z)},Z.add($[1],0,[["enter",Y,J]]),$[2]!==0){let W=I8(J.events,$[2]),V=I8(J.events,$[3]),K={type:"tableContent",start:Object.assign({},W),end:Object.assign({},V)};if(Z.add($[2],0,[["enter",K,J]]),X!==2){let U=J.events[$[2]],q=J.events[$[3]];if(U[1].end=Object.assign({},q[1].end),U[1].type="chunkText",U[1].contentType="text",$[3]>$[2]+1){let B=$[2]+1,F=$[3]-$[2]-1;Z.add(B,F,[])}}Z.add($[3]+1,0,[["exit",K,J]])}if(Q!==void 0)Y.end=Object.assign({},I8(J.events,Q)),Z.add(Q,0,[["exit",Y,J]]),Y=void 0;return Y}function yP(Z,J,$,X,Q){let Y=[],G=I8(J.events,$);if(Q)Q.end=Object.assign({},G),Y.push(["exit",Q,J]);X.end=Object.assign({},G),Y.push(["exit",X,J]),Z.add($+1,0,Y)}function I8(Z,J){let $=Z[J],X=$[0]==="enter"?"start":"end";return $[1][X]}var sm={name:"tasklistCheck",tokenize:nm};function sW(){return{text:{[91]:sm}}}function nm(Z,J,$){let X=this;return Q;function Q(z){if(X.previous!==null||!X._gfmTasklistFirstContentOfListItem)return $(z);return Z.enter("taskListCheck"),Z.enter("taskListCheckMarker"),Z.consume(z),Z.exit("taskListCheckMarker"),Y}function Y(z){if(J0(z))return Z.enter("taskListCheckValueUnchecked"),Z.consume(z),Z.exit("taskListCheckValueUnchecked"),G;if(z===88||z===120)return Z.enter("taskListCheckValueChecked"),Z.consume(z),Z.exit("taskListCheckValueChecked"),G;return $(z)}function G(z){if(z===93)return Z.enter("taskListCheckMarker"),Z.consume(z),Z.exit("taskListCheckMarker"),Z.exit("taskListCheck"),H;return $(z)}function H(z){if(O1(z))return J(z);if(x1(z))return Z.check({tokenize:om},J,$)(z);return $(z)}}function om(Z,J,$){return y1(Z,X,"whitespace");function X(Q){return Q===null?$(Q):J(Q)}}function bP(Z){return VQ([cW(),lW(),iW(Z),aW(),sW()])}var tm={};function nQ(Z){let J=this,$=Z||tm,X=J.data(),Q=X.micromarkExtensions||(X.micromarkExtensions=[]),Y=X.fromMarkdownExtensions||(X.fromMarkdownExtensions=[]),G=X.toMarkdownExtensions||(X.toMarkdownExtensions=[]);Q.push(bP($)),Y.push(fW()),G.push(pW($))}var k8=w(a(),1),em=[nQ],Zf=[rQ],Jf={code({className:Z,children:J,...$}){return k8.jsx("code",{className:N1("rounded-[4px] bg-accent px-1 py-0.5 font-mono font-normal before:content-none after:content-none",Z),...$,children:J})},pre({children:Z}){return k8.jsx("div",{className:"not-prose my-2 rounded-md border border-border bg-muted px-3 py-2.5",children:k8.jsx("pre",{className:"max-h-[300px] overflow-auto font-mono text-xs leading-relaxed whitespace-pre text-foreground [&>code]:rounded-none [&>code]:bg-transparent [&>code]:p-0",children:Z})})}};function xP({size:Z="sm",content:J}){return k8.jsx("div",{className:N1("prose max-w-full min-w-0 wrap-anywhere prose-inherit",Z==="sm"&&"prose-sm"),children:k8.jsx(oz,{remarkPlugins:em,rehypePlugins:Zf,components:Jf,children:J})})}var A0=w(a(),1);function gP(){return A0.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-1.5 text-center",children:[A0.jsx("h2",{className:"font-medium",children:"Every journey starts somewhere"}),A0.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Chat with your agent, create widgets and views, and manage your workspace context from here."})]})}function mP(){return A0.jsx("div",{className:"flex items-center gap-1.5 px-1 py-3",children:[0,1,2].map((Z)=>A0.jsx("span",{className:"block h-1.5 w-1.5 rounded-full bg-ring",style:{animation:"pulse-dot 1.4s ease-in-out infinite",animationDelay:`${Z*0.2}s`}},Z))})}function $f(Z){if(Z.type==="reasoning")return!0;if(Z.type==="tool-call")return!0;return!1}function Xf(Z){let J=[];for(let $ of Z)if($f($)){let X=J[J.length-1];if(X&&X.kind==="run")X.parts.push($);else J.push({kind:"run",parts:[$]})}else J.push({kind:"single",part:$});return J}function Qf({parts:Z,cwd:J,processing:$=!1}){let X=Xf(Z);return A0.jsx("div",{className:"flex flex-col",children:X.map((Q,Y)=>{let G=Y===0?"":"mt-3",H=Y===X.length-1;return A0.jsx("div",{className:G,children:Q.kind==="run"?A0.jsx(nW,{parts:Q.parts,cwd:J,processing:$&&H}):A0.jsx(Yf,{part:Q.part})},Y)})})}var fP=vP.memo(function({turn:J,processing:$=!1}){let X=w0().cwd;if(J.origin.kind==="replay")return null;if(J.origin.kind==="synthetic")return null;if(J.origin.kind==="subagent-prompt")return null;if(J.role==="user"&&J.origin.kind==="user-input"){let Q=J.parts.filter((G)=>G.type==="file"),Y=J.parts.filter((G)=>G.type==="text").map((G)=>G.type==="text"?G.text:"").join(`
|
|
60
60
|
`);if(!Y&&Q.length===0)return null;return A0.jsxs("div",{className:"ml-8 flex min-w-0 flex-col items-end gap-1.5",children:[Q.map((G,H)=>A0.jsx(pP,{mediaType:G.mediaType,url:G.url,filename:G.filename},H)),Y&&A0.jsx("p",{className:"max-w-full min-w-0 rounded-md bg-accent px-4 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-accent-foreground",children:Y})]})}return A0.jsx(Qf,{parts:J.parts,cwd:X,processing:$})});function Yf({part:Z}){switch(Z.type){case"text":return A0.jsx(xP,{content:Z.text});case"tool-call":return A0.jsx(nW,{parts:[Z],cwd:null});case"file":return A0.jsx(pP,{mediaType:Z.mediaType,url:Z.url,filename:Z.filename});case"source-url":return A0.jsx(hP,{url:Z.url,title:Z.title});case"source-document":return A0.jsx(hP,{url:"#",title:Z.title});case"data":return A0.jsx(Gf,{name:Z.name,data:Z.data});case"reasoning":return null}}function pP({mediaType:Z,url:J,filename:$}){if(Z.startsWith("image/")&&J)return A0.jsx("img",{src:J,alt:$??"attachment",className:"max-h-64 max-w-full rounded-md border border-border object-contain"});return A0.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-border bg-accent px-2.5 py-1.5 text-xs text-accent-foreground",children:[A0.jsx(q8,{size:16,stroke:1.75}),A0.jsx("span",{className:"truncate",children:$??Z})]})}function hP({url:Z,title:J}){return A0.jsx("a",{href:Z,target:"_blank",rel:"noreferrer",className:"text-xs underline",children:J??Z})}function Gf({name:Z,data:J}){return A0.jsxs("details",{children:[A0.jsxs("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:["data:",Z]}),A0.jsx("pre",{className:"mt-1 overflow-auto rounded bg-muted p-2 text-xs text-muted-foreground",children:JSON.stringify(J,null,2)})]})}var t0=w(a(),1);function oQ({active:Z=!0,focusRequest:J=0,view:$,previewTurn:X,sessionId:Q,processing:Y,error:G,onDismissError:H,unavailableReason:z,send:W,stop:V,onSwitchThread:K,headerLeft:U,headerRight:q,onClose:B}){let F=G7.useRef(null),N=G7.useRef(null),L=$.turns,M=G7.useMemo(()=>sL(X?[...L,X]:L),[L,X]),{atBottom:A,scrollToBottom:P}=aL(N,Q);G7.useEffect(()=>{if(Z)F.current?.focus()},[Z,J]);let D=G7.useCallback((_)=>{W(_),P()},[W,P]);return t0.jsxs("div",{className:"flex min-h-0 flex-1 flex-col pt-2 pb-3",children:[t0.jsxs("header",{className:"flex items-center justify-between pr-2 pb-2 pl-2",children:[t0.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[U,t0.jsx(W_,{onSwitch:K})]}),t0.jsxs("div",{className:"flex items-center gap-0.5",children:[q,B&&t0.jsx(E1,{variant:"ghost",size:"icon",onClick:B,"aria-label":"Close chat",children:t0.jsx(X9,{stroke:1.5})})]})]}),t0.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[t0.jsx("div",{ref:N,className:"flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-12 [--scroll-fade-reveal:8px]",children:t0.jsxs("div",{className:"mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6",children:[L.length===0&&!Y&&t0.jsx(gP,{}),M.map((_,T)=>t0.jsx(fP,{turn:_,processing:Y&&T===M.length-1},_.id)),Y&&!X&&t0.jsx(mP,{})]})}),!A&&L.length>0&&t0.jsx(E1,{type:"button",variant:"outline",size:"icon",onClick:()=>P("smooth"),"aria-label":"Jump to latest",className:"absolute bottom-3 left-1/2 -translate-x-1/2 animate-in rounded-full fade-in slide-in-from-bottom-1",children:t0.jsx(V8,{stroke:1.5})})]}),t0.jsxs("div",{className:"mx-auto flex w-full flex-col items-center px-3",children:[G&&t0.jsxs("div",{className:"mb-2 flex w-full max-w-(--chat-max-container) items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[t0.jsx("span",{className:"flex-1 wrap-break-word",children:G}),H&&t0.jsx(E1,{type:"button",variant:"ghost",size:"icon-sm",onClick:H,className:"-m-1","aria-label":"Dismiss error",children:t0.jsx(X9,{stroke:1.75})})]}),t0.jsx(z_,{composerRef:F,onSend:D,onStop:V,processing:Y,unavailableReason:z})]})]})}var o7={};D9(o7,{createHandle:()=>qO,Viewport:()=>VO,Trigger:()=>iP,Title:()=>QO,Root:()=>dP,Positioner:()=>nP,Portal:()=>sP,Popup:()=>tP,Handle:()=>$Y,Description:()=>GO,Close:()=>zO,Backdrop:()=>$O,Arrow:()=>ZO});var a2=w(m(),1);var tQ=w(m(),1),oW=tQ.createContext(void 0);function Y5(Z){let J=tQ.useContext(oW);if(J===void 0&&!Z)throw Error(C1(47));return J}var R8=w(m(),1),uP=w(h2(),1);function Hf(){return{...j7(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}var zf={...T7,disabled:T1((Z)=>Z.disabled),instantType:T1((Z)=>Z.instantType),openMethod:T1((Z)=>Z.openMethod),openChangeReason:T1((Z)=>Z.openChangeReason),modal:T1((Z)=>Z.modal),stickIfOpen:T1((Z)=>Z.stickIfOpen),titleElementId:T1((Z)=>Z.titleElementId),descriptionElementId:T1((Z)=>Z.descriptionElementId),openOnHover:T1((Z)=>Z.openOnHover),closeDelay:T1((Z)=>Z.closeDelay),hasViewport:T1((Z)=>Z.hasViewport)};class y8 extends e2{constructor(Z){let J={...Hf(),...Z};if(J.open&&Z?.mounted===void 0)J.mounted=!0;super(J,{popupRef:R8.createRef(),backdropRef:R8.createRef(),internalBackdropRef:R8.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:R8.createRef(),beforeContentFocusGuardRef:R8.createRef(),stickIfOpenTimeout:new k5,triggerElements:new A2},zf)}setOpen=(Z,J)=>{let $=J.reason===X1.triggerHover,X=J.reason===X1.triggerPress&&J.event.detail===0,Q=!Z&&(J.reason===X1.escapeKey||J.reason==null);if(J.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(Z,J),J.isCanceled)return;let Y={open:Z,nativeEvent:J.event,reason:J.reason,nested:this.state.nested,triggerElement:J.trigger};this.state.floatingRootContext.context.events?.emit("openchange",Y);let H=()=>{let z={open:Z,openChangeReason:J.reason},W=J.trigger?.id??null;if(W||Z)z.activeTriggerId=W,z.activeTriggerElement=J.trigger??null;this.update(z)};if($)this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(sX,()=>{this.set("stickIfOpen",!1)}),uP.flushSync(H);else H();if(X||Q)this.set("instantType",X?"click":"dismiss");else if(J.reason===X1.focusOut)this.set("instantType","focus");else this.set("instantType",void 0)};static useStore(Z,J){let $=U0(()=>{return new y8(J)}).current,X=Z??$;return N9($.disposeEffect),X}disposeEffect=()=>{return this.context.stickIfOpenTimeout.disposeEffect()}}var RZ=w(a(),1);function cP({props:Z}){let{children:J,open:$,defaultOpen:X=!1,onOpenChange:Q,onOpenChangeComplete:Y,modal:G=!1,handle:H,triggerId:z,defaultTriggerId:W=null}=Z,V=y8.useStore(H?.store,{modal:G,open:X,openProp:$,activeTriggerId:W,triggerIdProp:z});L7(()=>{if($===void 0&&V.state.open===!1&&X===!0)V.update({open:!0,activeTriggerId:W})}),V.useControlledProp("openProp",$),V.useControlledProp("triggerIdProp",z);let K=V.useState("open"),U=V.useState("positionerElement"),q=V.useState("payload"),B=V.useState("openChangeReason");V.useContextCallback("onOpenChange",Q),V.useContextCallback("onOpenChangeComplete",Y);let{openMethod:F,triggerProps:N,reset:L}=f6(K);O7(V);let{forceUnmount:M}=w7(K,V,()=>{V.update({stickIfOpen:!0,openChangeReason:null}),L()});g6(K&&G===!0&&B!==X1.triggerHover&&F!=="touch",U),a2.useEffect(()=>{if(!K)V.context.stickIfOpenTimeout.clear()},[V,K]);let A=a2.useCallback((b)=>{let R=A1(b);return R.preventUnmountOnClose=()=>{V.set("preventUnmountingOnClose",!0)},R},[V]),P=a2.useCallback(()=>{V.setOpen(!1,A(X1.imperativeAction))},[V,A]);a2.useImperativeHandle(Z.actionsRef,()=>({unmount:M,close:P}),[M,P]);let D=n9({popupStore:V,onOpenChange:V.setOpen}),_=s9(D,{outsidePressEvent:{mouse:G==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),T=j4(D),{getReferenceProps:C,getFloatingProps:y,getTriggerProps:j}=b5([_,T]),g=a2.useMemo(()=>{return C(N)},[C,N]),I=a2.useMemo(()=>{return j(N)},[j,N]),E=a2.useMemo(()=>{return y()},[y]);V.useSyncedValues({modal:G,openMethod:F,activeTriggerProps:g,inactiveTriggerProps:I,popupProps:E,floatingRootContext:D,nested:L5()!=null});let S=a2.useMemo(()=>({store:V}),[V]);return RZ.jsx(oW.Provider,{value:S,children:typeof J==="function"?J({payload:q}):J})}function dP(Z){if(Y5(!0))return RZ.jsx(cP,{props:Z});return RZ.jsx(V3,{children:RZ.jsx(cP,{props:Z})})}var z9=w(m(),1),tW=w(h2(),1);var lP=300;var Q6=w(a(),1),iP=z9.forwardRef(function(J,$){let{render:X,className:Q,disabled:Y=!1,nativeButton:G=!0,handle:H,payload:z,openOnHover:W=!1,delay:V=lP,closeDelay:K=0,id:U,...q}=J,B=Y5(!0),F=H?.store??B?.store;if(!F)throw Error(C1(74));let N=r1(U),L=F.useState("isTriggerActive",N),M=F.useState("floatingRootContext"),A=F.useState("isOpenedByTrigger",N),P=z9.useRef(null),{registerTrigger:D,isMountedByThisTrigger:_}=P7(N,P,F,{payload:z,disabled:Y,openOnHover:W,closeDelay:K}),T=F.useState("openChangeReason"),C=F.useState("stickIfOpen"),y=F.useState("openMethod"),j=o9(M,{enabled:M!=null&&W&&(y!=="touch"||T!==X1.triggerPress),mouseOnly:!0,move:!1,handleClose:t9(),restMs:V,delay:{close:K},triggerElementRef:P,isActiveTrigger:L}),g=a9(M,{enabled:M!=null,stickIfOpen:C}),I=b5([g]),E=F.useState("triggerProps",_),S={disabled:Y,open:A},{getButtonProps:b,buttonRef:R}=h5({disabled:Y,native:G}),x=z9.useMemo(()=>({open(Z1){if(Z1&&T===X1.triggerPress)return D3.open(Z1);return E7.open(Z1)}}),[T]),h=B1("button",J,{state:S,ref:[R,$,D,P],props:[I.getReferenceProps(),j,E,{[j6]:"",id:N},q,b],stateAttributesMapping:x}),d=z9.useRef(null),O=Y1((Z1)=>{tW.flushSync(()=>{F.setOpen(!1,A1(X1.focusOut,Z1.nativeEvent,Z1.currentTarget))}),bJ(d.current)?.focus()}),K1=Y1((Z1)=>{let k=F.select("positionerElement");if(k&&n2(Z1,k))F.context.beforeContentFocusGuardRef.current?.focus();else{tW.flushSync(()=>{F.setOpen(!1,A1(X1.focusOut,Z1.nativeEvent,Z1.currentTarget))});let e=yJ(F.context.triggerFocusTargetRef.current||P.current);while(e!==null&&R1(k,e)){let _1=e;if(e=_7(e),e===_1)break}e?.focus()}});if(L)return Q6.jsxs(z9.Fragment,{children:[Q6.jsx(x2,{ref:d,onFocus:O}),Q6.jsx(z9.Fragment,{children:h},N),Q6.jsx(x2,{ref:F.context.triggerFocusTargetRef,onFocus:K1})]});return Q6.jsx(z9.Fragment,{children:h},N)});var aP=w(m(),1);var eQ=w(m(),1),eW=eQ.createContext(void 0);function rP(){let Z=eQ.useContext(eW);if(Z===void 0)throw Error(C1(45));return Z}var ZK=w(a(),1),sP=aP.forwardRef(function(J,$){let{keepMounted:X=!1,...Q}=J,{store:Y}=Y5();if(!(Y.useState("mounted")||X))return null;return ZK.jsx(eW.Provider,{value:X,children:ZK.jsx(_4,{ref:$,...Q})})});var H7=w(m(),1);var ZY=w(m(),1),JK=ZY.createContext(void 0);function b8(){let Z=ZY.useContext(JK);if(!Z)throw Error(C1(46));return Z}var yZ=w(a(),1),nP=H7.forwardRef(function(J,$){let{render:X,className:Q,anchor:Y,positionMethod:G="absolute",side:H="bottom",align:z="center",sideOffset:W=0,alignOffset:V=0,collisionBoundary:K="clipping-ancestors",collisionPadding:U=5,arrowPadding:q=5,sticky:B=!1,disableAnchorTracking:F=!1,collisionAvoidance:N=R6,...L}=J,{store:M}=Y5(),A=rP(),P=F4(),D=M.useState("floatingRootContext"),_=M.useState("mounted"),T=M.useState("open"),C=M.useState("openChangeReason"),y=M.useState("activeTriggerElement"),j=M.useState("modal"),g=M.useState("positionerElement"),I=M.useState("instantType"),E=M.useState("transitionStatus"),S=M.useState("hasViewport"),b=H7.useRef(null),R=O9(g,!1,!1),x=I6({anchor:Y,floatingRootContext:D,positionMethod:G,mounted:_,side:H,sideOffset:W,align:z,alignOffset:V,arrowPadding:q,collisionBoundary:K,collisionPadding:U,sticky:B,disableAnchorTracking:F,keepMounted:A,nodeId:P,collisionAvoidance:N,adaptiveOrigin:S?z$:void 0}),h=H7.useMemo(()=>{let e={};if(!T)e.pointerEvents="none";return{role:"presentation",hidden:!_,style:{...x.positionerStyles,...e}}},[T,_,x.positionerStyles]),d=H7.useMemo(()=>({props:h,...x}),[h,x]),O=D.useState("domReferenceElement");Q1(()=>{let e=O,_1=b.current;if(e)b.current=e;if(_1&&e&&e!==_1){M.set("instantType",void 0);let u=new AbortController;return R(()=>{M.set("instantType","trigger-change")},u.signal),()=>{u.abort()}}return},[O,R,M]);let K1={open:T,side:d.side,align:d.align,anchorHidden:d.anchorHidden,instant:I},Z1=H7.useCallback((e)=>{M.set("positionerElement",e)},[M]),k=B1("div",J,{state:K1,props:[d.props,m2(E),L],ref:[$,Z1],stateAttributesMapping:O0});return yZ.jsxs(JK.Provider,{value:d,children:[_&&j===!0&&C!==X1.triggerHover&&yZ.jsx(v6,{ref:M.context.internalBackdropRef,inert:k7(!T),cutout:y}),yZ.jsx(K3,{id:P,children:k})]})});var JY=w(m(),1);var oP=w(a(),1),Wf={...O0,...u0},tP=JY.forwardRef(function(J,$){let{className:X,render:Q,initialFocus:Y,finalFocus:G,...H}=J,{store:z}=Y5(),W=b8(),V=yX(!0)!=null,K=z.useState("open"),U=z.useState("openMethod"),q=z.useState("instantType"),B=z.useState("transitionStatus"),F=z.useState("popupProps"),N=z.useState("titleElementId"),L=z.useState("descriptionElementId"),M=z.useState("modal"),A=z.useState("mounted"),P=z.useState("openChangeReason"),D=z.useState("activeTriggerElement"),_=z.useState("floatingRootContext");O5({open:K,ref:z.context.popupRef,onComplete(){if(K)z.context.onOpenChangeComplete?.(!0)}});let T=z.useState("disabled"),C=z.useState("openOnHover"),y=z.useState("closeDelay");P4(_,{enabled:C&&!T,closeDelay:y});function j(b){if(b==="touch")return z.context.popupRef.current;return!0}let g=Y===void 0?j:Y,I={open:K,side:W.side,align:W.align,instant:q,transitionStatus:B},E=JY.useCallback((b)=>{z.set("popupElement",b)},[z]),S=B1("div",J,{state:I,ref:[$,z.context.popupRef,E],props:[F,{"aria-labelledby":N,"aria-describedby":L,onKeyDown(b){if(V&&h6.has(b.key))b.stopPropagation()}},m2(B),H],stateAttributesMapping:Wf});return oP.jsx(M4,{context:_,openInteractionType:U,modal:M==="trap-focus",disabled:!A||P===X1.triggerHover,initialFocus:g,returnFocus:G,restoreFocus:"popup",previousFocusableElement:p0(D)?D:void 0,nextFocusableElement:z.context.triggerFocusTargetRef,beforeContentFocusGuardRef:z.context.beforeContentFocusGuardRef,children:S})});var eP=w(m(),1);var ZO=eP.forwardRef(function(J,$){let{className:X,render:Q,...Y}=J,{store:G}=Y5(),H=G.useState("open"),{arrowRef:z,side:W,align:V,arrowUncentered:K,arrowStyles:U}=b8();return B1("div",J,{state:{open:H,side:W,align:V,uncentered:K},ref:[$,z],props:[{style:U,"aria-hidden":!0},Y],stateAttributesMapping:O0})});var JO=w(m(),1);var Kf={...O0,...u0},$O=JO.forwardRef(function(J,$){let{className:X,render:Q,...Y}=J,{store:G}=Y5(),H=G.useState("open"),z=G.useState("mounted"),W=G.useState("transitionStatus"),V=G.useState("openChangeReason");return B1("div",J,{state:{open:H,transitionStatus:W},ref:[G.context.backdropRef,$],props:[{role:"presentation",hidden:!z,style:{pointerEvents:V===X1.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},Y],stateAttributesMapping:Kf})});var XO=w(m(),1);var QO=XO.forwardRef(function(J,$){let{render:X,className:Q,...Y}=J,{store:G}=Y5(),H=r1(Y.id);return Q1(()=>{return G.set("titleElementId",H),()=>{G.set("titleElementId",void 0)}},[G,H]),B1("h2",J,{ref:$,props:[{id:H},Y]})});var YO=w(m(),1);var GO=YO.forwardRef(function(J,$){let{render:X,className:Q,...Y}=J,{store:G}=Y5(),H=r1(Y.id);return Q1(()=>{return G.set("descriptionElementId",H),()=>{G.set("descriptionElementId",void 0)}},[G,H]),B1("p",J,{ref:$,props:[{id:H},Y]})});var HO=w(m(),1);var zO=HO.forwardRef(function(J,$){let{render:X,className:Q,disabled:Y=!1,nativeButton:G=!0,...H}=J,{buttonRef:z,getButtonProps:W}=h5({disabled:Y,focusableWhenDisabled:!1,native:G}),{store:V}=Y5();return B1("button",J,{ref:[$,z],props:[{onClick(U){V.setOpen(!1,A1(X1.closePress,U.nativeEvent,U.currentTarget))}},H,W]})});var KO=w(m(),1);var WO=function(Z){return Z.popupWidth="--popup-width",Z.popupHeight="--popup-height",Z}({});var Vf={activationDirection:(Z)=>Z?{"data-activation-direction":Z}:null},VO=KO.forwardRef(function(J,$){let{render:X,className:Q,children:Y,...G}=J,{store:H}=Y5(),{side:z}=b8(),W=H.useState("instantType"),{children:V,state:K}=V$({store:H,side:z,cssVars:WO,children:Y}),U={activationDirection:K.activationDirection,transitioning:K.transitioning,instant:W};return B1("div",J,{state:U,ref:$,props:[G,{children:V}],stateAttributesMapping:Vf})});class $Y{constructor(){this.store=new y8}open(Z){let J=Z?this.store.context.triggerElements.getById(Z)??void 0:void 0;if(Z&&!J)throw Error(C1(80,Z));this.store.setOpen(!0,A1(X1.imperativeAction,void 0,J))}close(){this.store.setOpen(!1,A1(X1.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}function qO(){return new $Y}var x8=w(a(),1);function UO({...Z}){return x8.jsx(o7.Root,{"data-slot":"popover",...Z})}function BO({...Z}){return x8.jsx(o7.Trigger,{"data-slot":"popover-trigger",...Z})}function FO({className:Z,align:J="center",alignOffset:$=0,side:X="bottom",sideOffset:Q=4,keepMounted:Y=!1,container:G,...H}){return x8.jsx(o7.Portal,{keepMounted:Y,container:G,children:x8.jsx(o7.Positioner,{align:J,alignOffset:$,side:X,sideOffset:Q,className:"isolate z-50",children:x8.jsx(o7.Popup,{"data-slot":"popover-content",className:N1("z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-md bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",Z),...H})})})}var z7=w(a(),1);function LO({open:Z,onOpenChange:J,onOpenChangeComplete:$,container:X,children:Q}){let Y=()=>J(!1);return z7.jsxs(UO,{open:Z,onOpenChange:J,onOpenChangeComplete:$,children:[z7.jsx(BO,{render:z7.jsx("div",{className:"fixed right-4 bottom-4 sm:right-6 sm:bottom-6",children:z7.jsx(n0.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"},invisible:{opacity:0,scale:1,filter:"blur(4px)"}},initial:"from",animate:Z?"invisible":"to",transition:{type:"spring",duration:0.3,delay:0.2,bounce:0},children:z7.jsx(E1,{variant:"outline",size:"icon-lg",className:"shadow-md hover:shadow-lg","aria-label":"Agent",children:z7.jsx(Y6,{stroke:1.75})})})})}),z7.jsx(FO,{side:"top",sideOffset:-48,align:"end",alignOffset:-8,className:"flex h-[calc(100vh-2rem)] w-[min(440px,calc(100vw-1rem))] flex-col gap-0 rounded-3xl p-0 sm:h-[calc(100vh-8rem)] sm:w-[min(440px,calc(100vw-2rem))] sm:p-1",keepMounted:!0,container:X,children:Q(Y)})]})}var MO=w(m(),1);var bZ=w(a(),1);function XY({title:Z,children:J,ref:$}){return bZ.jsxs(n0.div,{ref:$,className:"absolute inset-x-6 bottom-0 z-20 flex max-h-[60vh] flex-col rounded-t-2xl bg-card p-(--page-pad) text-card-foreground shadow-md",variants:{hidden:{opacity:0,y:40,filter:"blur(4px)"},visible:{opacity:1,y:0,filter:"blur(0px)"}},initial:"hidden",animate:"visible",exit:"hidden",transition:{type:"spring",duration:0.25,bounce:0},children:[bZ.jsx("p",{className:"mb-4 shrink-0 text-sm font-medium text-muted-foreground",children:Z}),bZ.jsx("div",{className:"-my-1 mr-[calc(var(--page-pad)*-1)] ml-[calc(var(--page-pad)*-1)] flex-1 overflow-y-auto px-(--page-pad) py-1",children:J})]})}var h8={default:{label:"Default",sans:"system-ui",mono:"JetBrains Mono",feel:"Native OS, zero load",googleFontsQuery:"JetBrains+Mono:wght@400;500"},serif:{label:"Serif",sans:"Libre Baskerville",mono:"JetBrains Mono",feel:"Classic serif, literary",googleFontsQuery:"Libre+Baskerville:wght@400;700&family=JetBrains+Mono:wght@400;500"},mono:{label:"Mono",sans:"JetBrains Mono",mono:"JetBrains Mono",feel:"Full terminal, hacker",googleFontsQuery:"JetBrains+Mono:wght@400;500;600"},bubbly:{label:"Bubbly",sans:"Fredoka",mono:"Azeret Mono",feel:"Very round, toy-like",googleFontsQuery:"Fredoka:wght@400;500;600&family=Azeret+Mono:wght@400;500"},geometric:{label:"Geometric",sans:"Outfit",mono:"DM Mono",feel:"Swiss design, neutral",googleFontsQuery:"Outfit:wght@400;500;600&family=DM+Mono:wght@400;500"},retro:{label:"Retro",sans:"Courier Prime",mono:"Courier Prime",feel:"Typewriter nostalgia",googleFontsQuery:"Courier+Prime:wght@400;700"}},NO={default:{label:"Default",feel:"System neutral"},paper:{label:"Paper",background:"#faf8f5",foreground:"#2c2825",feel:"Warm off-white"},sand:{label:"Sand",background:"#f5f0e8",foreground:"#3d3529",feel:"Beige earth tones"},rose:{label:"Rose",background:"#fdf2f4",foreground:"#3b1c26",feel:"Soft blush"},lavender:{label:"Lavender",background:"#f4f2fb",foreground:"#2b2640",feel:"Cool violet"},mint:{label:"Mint",background:"#f0faf6",foreground:"#1a3028",feel:"Cool green"},sky:{label:"Sky",background:"#f0f6fc",foreground:"#1a2a3b",feel:"Cool blue"}};var f5=w(a(),1),_O="mei-font-previews",qf=Object.values(h8).map((Z)=>Z.googleFontsQuery).filter(Boolean).join("&family=");function Uf(){MO.useEffect(()=>{if(document.getElementById(_O))return;let Z=document.createElement("link");Z.id=_O,Z.rel="stylesheet",Z.href=`https://fonts.googleapis.com/css2?family=${qf}&display=swap`,document.head.appendChild(Z)},[])}var Bf=Object.entries(h8),Ff=Object.entries(NO);function Lf(Z,J,$){return(Z.background??void 0)===J&&(Z.foreground??void 0)===$}function AO({ref:Z}){Uf();let{layout:J,setLayout:$}=w0(),X=J.theme?.font??"default",Q=J.theme?.background,Y=J.theme?.foreground;function G(H){$({theme:{...J.theme,font:X,...H}})}return f5.jsx(XY,{ref:Z,title:"Customize",children:f5.jsxs("div",{className:"flex flex-col gap-6",children:[f5.jsxs("div",{className:"flex flex-col gap-2",children:[f5.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Font"}),f5.jsx("div",{className:"grid grid-cols-3 gap-2",children:Bf.map(([H,z])=>f5.jsxs("button",{type:"button",onClick:()=>G({font:H}),className:N1("flex flex-col items-start rounded-md px-3 py-2 text-left transition-colors",H===X?"bg-primary/5 ring-2 ring-primary":"border-transparent hover:bg-accent"),style:{fontFamily:z.sans},children:[f5.jsx("span",{className:"text-sm font-medium",children:z.label}),f5.jsx("span",{className:"text-xs text-muted-foreground",children:z.feel})]},H))})]}),f5.jsxs("div",{className:"flex flex-col gap-2",children:[f5.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Colors"}),f5.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ff.map(([H,z])=>{let W=Lf(z,Q,Y);return f5.jsxs("button",{type:"button",onClick:()=>G({background:z.background,foreground:z.foreground}),className:N1("flex items-center gap-2 rounded-md border px-3 py-2 transition-colors",W?"bg-primary/5 ring-2 ring-primary":"border-transparent hover:bg-accent"),children:[f5.jsx("span",{className:"size-5 shrink-0 rounded-full border border-border",style:{backgroundColor:z.background??"oklch(1 0 0)"},children:f5.jsx("span",{className:"flex size-full items-center justify-center text-[9px] leading-none font-bold",style:{color:z.foreground??"oklch(0.145 0 0)"},children:"A"})}),f5.jsx("span",{className:"text-sm",children:z.label})]},H)})})]})]})})}var QY=w(m(),1);var DO=w(m(),1),$K=new Map;function Nf(Z){let J=window.__moiAppletCss?.get(Z)??"",$=$K.get(Z);if(!$){let Y=document.createElement("style");Y.dataset.appletStyle=Z,document.head.appendChild(Y),$={el:Y,refs:0},$K.set(Z,$)}if($.el.textContent!==J)$.el.textContent=J;$.refs++;let X=$,Q=!1;return()=>{if(Q)return;if(Q=!0,X.refs--,X.refs<=0)X.el.remove(),$K.delete(Z)}}function PO(Z,J){DO.useInsertionEffect(()=>Nf(Z),[Z,J])}var OO=w(a(),1);function YY({segment:Z,name:J,version:$,asChild:X,children:Q}){let Y=v5();PO(RL(Z,Y,J),$);let H=`${Z==="widgets"?"widget":"view"}:${J}`;if(X&&QY.isValidElement(Q))return QY.cloneElement(Q,{"data-applet":H});return OO.jsx("div",{"data-applet":H,className:"size-full",children:Q})}var jO=w(m(),1);var v8=w(a(),1);class xZ extends jO.Component{state={error:null};static getDerivedStateFromError(Z){return{error:Z}}componentDidCatch(Z,J){console.error(`[widget:${this.props.name}]`,Z,J.componentStack),T3(this.props.workspaceId,{source:"render",kind:this.props.kind,name:this.props.name,message:Z.message||String(Z),stack:[Z.stack,J.componentStack].filter(Boolean).join(`
|
|
61
|
-
`)})}componentDidUpdate(Z){if(Z.resetKey!==this.props.resetKey&&this.state.error)this.setState({error:null})}render(){if(this.state.error)return v8.jsxs("div",{className:"flex h-full w-full flex-col items-start justify-start gap-1.5 p-4 text-xs",children:[v8.jsxs("div",{className:"flex items-center gap-1.5 font-semibold text-destructive",children:[v8.jsx(wO,{size:16,stroke:1.75}),"Widget crashed"]}),v8.jsx("div",{className:"font-mono break-words text-muted-foreground",children:this.state.error.message})]});return this.props.children}}var i8=w(m(),1);function hZ(Z,J,$,X){let Q=Z.reduce((Y,G)=>Math.max(Y,G.y+G.h),0);for(let Y=0;Y<=Q+$;Y++)for(let G=0;G<=X-J;G++)if(!Z.some((z)=>!(G+J<=z.x||z.x+z.w<=G||Y+$<=z.y||z.y+z.h<=Y)))return{x:G,y:Y};return{x:0,y:Q}}function vZ(Z,J=[],$=4){let X=[];for(let Q of Z){let{x:Y,y:G}=Q.x!==void 0&&Q.y!==void 0?{x:Q.x,y:Q.y}:hZ([...J,...X],Q.w,Q.h,$);X.push({i:Q.id,x:Y,y:G,w:Q.w,h:Q.h})}return X}var t7=w(a(),1);function TO({name:Z}){let J=v5(),$=hL(Z);return t7.jsxs(d9,{mode:"wait",initial:!1,children:[$.status==="ready"&&t7.jsx(n0.div,{className:"absolute inset-0",initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:{duration:0.45,ease:"easeInOut"},children:t7.jsx(xZ,{name:Z,kind:"widget",workspaceId:J,resetKey:$.version,children:t7.jsx(YY,{segment:"widgets",name:Z,version:$.version,children:t7.jsx($.Component,{})})})},$.version),$.status==="error"&&t7.jsx(n0.p,{className:"absolute inset-0 p-4 text-xs text-destructive",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0.45,ease:"easeInOut"},children:$.error},`err-${$.version}`)]})}var CO=w(a(),1);function g8({className:Z,...J}){return CO.jsx("div",{"data-slot":"skeleton",className:N1("animate-pulse rounded-md bg-muted",Z),...J})}var EO=w(m(),1);var e7=w(a(),1);function GY({editing:Z,hidden:J,onRemove:$,children:X}){return e7.jsxs(n0.div,{variants:{idle:{rotate:0},wiggle:{rotate:[0.5,-0.5],transition:{rotate:{repeat:1/0,repeatType:"reverse",duration:0.15,ease:"easeInOut"}}}},animate:Z?"wiggle":"idle",transition:{type:"spring",duration:0.35,bounce:0},className:"group/widget relative size-full",children:[e7.jsx("div",{"data-widget-chrome":!0,className:N1("dark absolute inset-0 overflow-hidden rounded-2xl [corner-shape:superellipse(1.2)]","shadow-[0_1px_2px_-1px_rgba(0,0,0,0.08),0_2px_4px_0_rgba(0,0,0,0.03)]","after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit]","after:content-[''] after:[corner-shape:inherit]","after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]","text-foreground",Z&&"pointer-events-none"),children:X}),Z&&$&&e7.jsx("div",{className:"absolute -top-2 -right-2 opacity-0 transition-opacity group-hover/widget:opacity-100",children:e7.jsx(E1,{size:"icon-sm",variant:"outline",className:"rounded-full",onClick:$,children:J?e7.jsx(a5,{stroke:1.75}):e7.jsx(SO,{stroke:1.75})})})]})}var m8=w(a(),1),_f={0:"col-start-1",1:"col-start-2",2:"col-start-3",3:"col-start-4"},Mf={0:"row-start-1",1:"row-start-2",2:"row-start-3",3:"row-start-4",4:"row-start-5",5:"row-start-6",6:"row-start-7",7:"row-start-8"},Af={1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"},Df={1:"row-span-1",2:"row-span-2",3:"row-span-3",4:"row-span-4"};function IO({items:Z,renderItem:J,onRestore:$,ref:X}){let Q=EO.useMemo(()=>vZ(Z),[Z]);return m8.jsx(XY,{ref:X,title:"Hidden",children:m8.jsx("div",{className:"grid [grid-auto-rows:160px] grid-cols-4 gap-2",children:m8.jsx(d9,{children:Q.map((Y)=>m8.jsx(n0.div,{layoutId:Y.i,className:N1(_f[Y.x],Mf[Y.y],Af[Y.w],Df[Y.h]),transition:{type:"spring",duration:0.35,bounce:0},children:m8.jsx(GY,{editing:!0,onRemove:()=>$(Y.i),hidden:!0,children:J(Y.i)})},Y.i))})})})}var oZ=w(m(),1);function J4(Z){let{margin:J,containerPadding:$,containerWidth:X,cols:Q}=Z;return(X-J[0]*(Q-1)-$[0]*2)/Q}function W9(Z,J,$){if(!Number.isFinite(Z))return Z;return Math.round(J*Z+Math.max(0,Z-1)*$)}function mZ(Z,J,$,X,Q,Y,G){let{margin:H,containerPadding:z,rowHeight:W}=Z,V=J4(Z),K,U,q,B;if(G)K=Math.round(G.width),U=Math.round(G.height);else K=W9(X,V,H[0]),U=W9(Q,W,H[1]);if(Y)q=Math.round(Y.top),B=Math.round(Y.left);else if(G)q=Math.round(G.top),B=Math.round(G.left);else q=Math.round((W+H[1])*$+z[1]),B=Math.round((V+H[0])*J+z[0]);if(!Y&&!G){if(Number.isFinite(X)){let N=Math.round((V+H[0])*(J+X)+z[0])-B-K;if(N!==H[0])K+=N-H[0]}if(Number.isFinite(Q)){let N=Math.round((W+H[1])*($+Q)+z[1])-q-U;if(N!==H[1])U+=N-H[1]}}return{top:q,left:B,width:K,height:U}}function RO(Z,J,$,X,Q){let{margin:Y,containerPadding:G,cols:H,rowHeight:z,maxRows:W}=Z,V=J4(Z),K=Math.round(($-G[0])/(V+Y[0])),U=Math.round((J-G[1])/(z+Y[1]));return K=gZ(K,0,H-X),U=gZ(U,0,W-Q),{x:K,y:U}}function fZ(Z,J,$){let{margin:X,containerPadding:Q,rowHeight:Y}=Z,G=J4(Z),H=Math.round(($-Q[0])/(G+X[0])),z=Math.round((J-Q[1])/(Y+X[1]));return{x:H,y:z}}function yO(Z,J,$){let{margin:X,rowHeight:Q}=Z,Y=J4(Z),G=Math.max(1,Math.round((J+X[0])/(Y+X[0]))),H=Math.max(1,Math.round(($+X[1])/(Q+X[1])));return{w:G,h:H}}function gZ(Z,J,$){return Math.max(Math.min(Z,$),J)}function zY(Z,J){if(Z.i===J.i)return!1;if(Z.x+Z.w<=J.x)return!1;if(Z.x>=J.x+J.w)return!1;if(Z.y+Z.h<=J.y)return!1;if(Z.y>=J.y+J.h)return!1;return!0}function $4(Z,J){for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0&&zY(X,J))return X}return}function XK(Z,J){return Z.filter(($)=>zY($,J))}function Pf(Z,J){if(J==="horizontal")return QK(Z);if(J==="vertical")return HY(Z);if(J==="wrap")return HY(Z);return[...Z]}function HY(Z){return[...Z].sort((J,$)=>{if(J.y!==$.y)return J.y-$.y;return J.x-$.x})}function QK(Z){return[...Z].sort((J,$)=>{if(J.x!==$.x)return J.x-$.x;return J.y-$.y})}function pZ(Z){let J=0;for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0){let Q=X.y+X.h;if(Q>J)J=Q}}return J}function X4(Z,J){for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0&&X.i===J)return X}return}function uZ(Z){return Z.filter((J)=>J.static===!0)}function W7(Z){return{i:Z.i,x:Z.x,y:Z.y,w:Z.w,h:Z.h,minW:Z.minW,maxW:Z.maxW,minH:Z.minH,maxH:Z.maxH,moved:Boolean(Z.moved),static:Boolean(Z.static),isDraggable:Z.isDraggable,isResizable:Z.isResizable,resizeHandles:Z.resizeHandles,constraints:Z.constraints,isBounded:Z.isBounded}}function f8(Z){let J=Array(Z.length);for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0)J[$]=W7(X)}return J}function Of(Z,J){let $=Array(Z.length);for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q!==void 0)if(J.i===Q.i)$[X]=J;else $[X]=Q}return $}function bO(Z,J,$){let X=X4(Z,J);if(!X)return[[...Z],null];return X=$(W7(X)),[Of(Z,X),X]}function YK(Z,J){let $=uZ(Z);for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q===void 0)continue;if(Q.x+Q.w>J.cols)Q.x=J.cols-Q.w;if(Q.x<0)Q.x=0,Q.w=J.cols;if(!Q.static)$.push(Q);else while($4($,Q))Q.y++}return Z}function Z4(Z,J,$,X,Q,Y,G,H,z){if(J.static&&J.isDraggable!==!0)return[...Z];if(J.y===X&&J.x===$)return[...Z];let{x:W,y:V}=J;if(typeof $==="number")J.x=$;if(typeof X==="number")J.y=X;J.moved=!0;let K=Pf(Z,G);if(G==="vertical"&&typeof X==="number"?V>=X:G==="horizontal"&&typeof $==="number"?W>=$:!1)K=K.reverse();let q=XK(K,J),B=q.length>0;if(B&&z)return f8(Z);if(B&&Y)return J.x=W,J.y=V,J.moved=!1,Z;let F=[...Z];for(let N=0;N<q.length;N++){let L=q[N];if(L===void 0)continue;if(L.moved)continue;if(L.static)F=kO(F,L,J,Q,G);else F=kO(F,J,L,Q,G)}return F}function kO(Z,J,$,X,Q,Y){let G=Q==="horizontal",H=Q==="vertical",z=J.static;if(X){X=!1;let K={x:G?Math.max(J.x-$.w,0):$.x,y:H?Math.max(J.y-$.h,0):$.y,w:$.w,h:$.h,i:"-1"},U=$4(Z,K),q=U!==void 0&&U.y+U.h>J.y,B=U!==void 0&&J.x+J.w>U.x;if(!U)return Z4(Z,$,G?K.x:void 0,H?K.y:void 0,X,z,Q);if(q&&H)return Z4(Z,$,void 0,$.y+1,X,z,Q);if(q&&Q===null)return J.y=$.y,$.y=$.y+$.h,[...Z];if(B&&G)return Z4(Z,J,$.x,void 0,X,z,Q)}let W=G?$.x+1:void 0,V=H?$.y+1:void 0;if(W===void 0&&V===void 0)return[...Z];return Z4(Z,$,W,V,X,z,Q)}function p8(Z,J,$){return Math.max(J,Math.min($,Z))}var wf={name:"gridBounds",constrainPosition(Z,J,$,{cols:X,maxRows:Q}){return{x:p8(J,0,Math.max(0,X-Z.w)),y:p8($,0,Math.max(0,Q-Z.h))}},constrainSize(Z,J,$,X,{cols:Q,maxRows:Y}){let G=X==="w"||X==="nw"||X==="sw"?Z.x+Z.w:Q-Z.x,H=X==="n"||X==="nw"||X==="ne"?Z.y+Z.h:Y-Z.y;return{w:p8(J,1,Math.max(1,G)),h:p8($,1,Math.max(1,H))}}},jf={name:"minMaxSize",constrainSize(Z,J,$){return{w:p8(J,Z.minW??1,Z.maxW??1/0),h:p8($,Z.minH??1,Z.maxH??1/0)}}};var GK=[wf,jf];function cZ(Z,J,$,X,Q){let Y={x:$,y:X};for(let G of Z)if(G.constrainPosition)Y=G.constrainPosition(J,Y.x,Y.y,Q);if(J.constraints){for(let G of J.constraints)if(G.constrainPosition)Y=G.constrainPosition(J,Y.x,Y.y,Q)}return Y}function xO(Z,J,$,X,Q,Y){let G={w:$,h:X};for(let H of Z)if(H.constrainSize)G=H.constrainSize(J,G.w,G.h,Q,Y);if(J.constraints){for(let H of J.constraints)if(H.constrainSize)G=H.constrainSize(J,G.w,G.h,Q,Y)}return G}function KY({top:Z,left:J,width:$,height:X}){let Q=`translate(${J}px,${Z}px)`;return{transform:Q,WebkitTransform:Q,MozTransform:Q,msTransform:Q,OTransform:Q,width:`${$}px`,height:`${X}px`,position:"absolute"}}function HK({top:Z,left:J,width:$,height:X}){return{top:`${Z}px`,left:`${J}px`,width:`${$}px`,height:`${X}px`,position:"absolute"}}function zK(Z){return Z*100+"%"}function Tf(Z,J,$,X){return Z+$>X?J:$}function hO(Z,J,$){return Z<0?J:$}function Cf(Z){return Math.max(0,Z)}function WY(Z){return Math.max(0,Z)}var WK=(Z,J,$)=>{let{left:X,height:Q,width:Y}=J,G=Z.top-(Q-Z.height);return{left:X,width:Y,height:hO(G,Z.height,Q),top:WY(G)}},KK=(Z,J,$)=>{let{top:X,left:Q,height:Y,width:G}=J;return{top:X,height:Y,width:Tf(Z.left,Z.width,G,$),left:Cf(Q)}},VK=(Z,J,$)=>{let{top:X,height:Q,width:Y}=J,G=Z.left+Z.width-Y;if(G<0)return{height:Q,width:Z.left+Z.width,top:WY(X),left:0};return{height:Q,width:Y,top:WY(X),left:G}},qK=(Z,J,$)=>{let{top:X,left:Q,height:Y,width:G}=J;return{width:G,left:Q,height:hO(X,Z.height,Y),top:WY(X)}},Sf=(Z,J,$)=>WK(Z,KK(Z,J,$)),Ef=(Z,J,$)=>WK(Z,VK(Z,J)),If=(Z,J,$)=>qK(Z,KK(Z,J,$)),kf=(Z,J,$)=>qK(Z,VK(Z,J)),Rf={n:WK,ne:Sf,e:KK,se:If,s:qK,sw:kf,w:VK,nw:Ef};function vO(Z,J,$,X){let Q=Rf[Z];if(!Q)return $;return Q(J,{...J,...$},X)}var yf={type:"transform",scale:1,calcStyle(Z){return KY(Z)}};var gO=yf,mO={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},fO={enabled:!0,bounded:!1,threshold:3},pO={enabled:!0,handles:["se"]},uO={enabled:!1,defaultItem:{w:1,h:1}};function UK(Z,J,$,X,Q){let Y=X==="x"?"w":"h";J[X]+=1;let G=Z.findIndex((z)=>z.i===J.i),H=Q??uZ(Z).length>0;for(let z=G+1;z<Z.length;z++){let W=Z[z];if(W===void 0)continue;if(W.static)continue;if(!H&&W.y>J.y+J.h)break;if(zY(J,W))UK(Z,W,$+J[Y],X,H)}J[X]=$}function bf(Z,J,$,X){J.x=Math.max(J.x,0),J.y=Math.max(J.y,0),J.y=Math.min(X,J.y);while(J.y>0&&!$4(Z,J))J.y--;let Q;while((Q=$4(Z,J))!==void 0)UK($,J,Q.y+Q.h,"y");return J.y=Math.max(J.y,0),J}function xf(Z,J,$,X){J.x=Math.max(J.x,0),J.y=Math.max(J.y,0);while(J.x>0&&!$4(Z,J))J.x--;let Q;while((Q=$4(Z,J))!==void 0)if(UK(X,J,Q.x+Q.w,"x"),J.x+J.w>$){J.x=$-J.w,J.y++;while(J.x>0&&!$4(Z,J))J.x--}return J.x=Math.max(J.x,0),J}var dZ={type:"vertical",allowOverlap:!1,compact(Z,J){let $=uZ(Z),X=pZ($),Q=HY(Z),Y=Array(Z.length);for(let G=0;G<Q.length;G++){let H=Q[G];if(H===void 0)continue;let z=W7(H);if(!z.static)z=bf($,z,Q,X),X=Math.max(X,z.y+z.h),$.push(z);let W=Z.indexOf(H);Y[W]=z,z.moved=!1}return Y}},BK={type:"horizontal",allowOverlap:!1,compact(Z,J){let $=uZ(Z),X=QK(Z),Q=Array(Z.length);for(let Y=0;Y<X.length;Y++){let G=X[Y];if(G===void 0)continue;let H=W7(G);if(!H.static)H=xf($,H,J,X),$.push(H);let z=Z.indexOf(G);Q[z]=H,H.moved=!1}return Q}},FK={type:null,allowOverlap:!1,compact(Z,J){return f8(Z)}},hf={...dZ,allowOverlap:!0,compact(Z,J){return f8(Z)}},vf={...BK,allowOverlap:!0,compact(Z,J){return f8(Z)}},gf={...FK,allowOverlap:!0};function LK(Z,J=!1,$=!1){let X;if(J)if(Z==="vertical")X=hf;else if(Z==="horizontal")X=vf;else X=gf;else if(Z==="vertical")X=dZ;else if(Z==="horizontal")X=BK;else X=FK;if($)return{...X,preventCollision:$};return X}var K9=w(m(),1);function NK(Z={}){let{measureBeforeMount:J=!1,initialWidth:$=1280}=Z,[X,Q]=K9.useState($),[Y,G]=K9.useState(!J),H=K9.useRef(null),z=K9.useRef(null),W=K9.useCallback(()=>{let V=H.current;if(V){let K=V.offsetWidth;if(Q(K),!Y)G(!0)}},[Y]);return K9.useEffect(()=>{let V=H.current;if(!V)return;if(W(),typeof ResizeObserver<"u"){let K=null;return z.current=new ResizeObserver((U)=>{let q=U[0];if(q){let B=q.contentRect.width;if(K!==null)cancelAnimationFrame(K);K=requestAnimationFrame(()=>{Q(B),K=null})}}),z.current.observe(V),()=>{if(K!==null)cancelAnimationFrame(K);if(z.current)z.current.disconnect(),z.current=null}}return()=>{if(z.current)z.current.disconnect(),z.current=null}},[W]),{width:X,mounted:Y,containerRef:H,measureWidth:W}}var P1=w(m(),1),fw=w(MY(),1),pw=w(vw(),1);var V7=w(a(),1),G6=w(dO(),1);function vK(Z){let{children:J,cols:$,containerWidth:X,margin:Q,containerPadding:Y,rowHeight:G,maxRows:H,isDraggable:z,isResizable:W,isBounded:V,static:K,useCSSTransforms:U=!0,usePercentages:q=!1,transformScale:B=1,positionStrategy:F,dragThreshold:N=0,droppingPosition:L,className:M="",style:A,handle:P="",cancel:D="",x:_,y:T,w:C,h:y,minW:j=1,maxW:g=1/0,minH:I=1,maxH:E=1/0,i:S,resizeHandles:b,resizeHandle:R,constraints:x=GK,layoutItem:h,layout:d=[],onDragStart:O,onDrag:K1,onDragStop:Z1,onResizeStart:k,onResize:e,onResizeStop:_1}=Z,[u,z1]=P1.useState(!1),[V1,$1]=P1.useState(!1),G1=P1.useRef(null),U1=P1.useRef({left:0,top:0}),f=P1.useRef({top:0,left:0,width:0,height:0}),o=P1.useRef(void 0),n=P1.useRef(d);n.current=d;let M1=P1.useRef(null),l=P1.useRef(null),W1=P1.useRef(!1),i=P1.useRef({x:0,y:0}),t=P1.useRef(!1),H1=P1.useMemo(()=>({cols:$,containerPadding:Y,containerWidth:X,margin:Q,maxRows:H,rowHeight:G}),[$,Y,X,Q,H,G]),r=P1.useMemo(()=>({cols:$,maxRows:H,containerWidth:X,containerHeight:0,rowHeight:G,margin:Q,layout:[]}),[$,H,X,G,Q]),c=P1.useCallback(()=>({...r,layout:n.current}),[r]),F1=P1.useMemo(()=>h??{i:S,x:_,y:T,w:C,h:y,minW:j,maxW:g,minH:I,maxH:E},[h,S,_,T,C,y,j,g,I,E]),I1=P1.useCallback((k1)=>{if(F?.calcStyle)return F.calcStyle(k1);if(U)return KY(k1);let v1=HK(k1);if(q)return{...v1,left:zK(k1.left/X),width:zK(k1.width/X)};return v1},[F,U,q,X]),f1=P1.useCallback((k1,{node:v1})=>{if(!O)return;let{offsetParent:s1}=v1;if(!s1)return;let n1=s1.getBoundingClientRect(),G0=v1.getBoundingClientRect(),V0=G0.left/B,T0=n1.left/B,v0=G0.top/B,Y0=n1.top/B,g0;if(F?.calcDragPosition){let u1=k1;g0=F.calcDragPosition(u1.clientX,u1.clientY,u1.clientX-G0.left,u1.clientY-G0.top)}else g0={left:V0-T0+s1.scrollLeft,top:v0-Y0+s1.scrollTop};if(U1.current=g0,N>0){let u1=k1;i.current={x:u1.clientX,y:u1.clientY},W1.current=!0,t.current=!1,z1(!0);return}z1(!0);let G5=fZ(H1,g0.top,g0.left),{x:V5,y:j1}=cZ(x,F1,G5.x,G5.y,c());O(S,V5,j1,{e:k1,node:v1,newPosition:g0})},[O,B,H1,F,N,x,F1,c,S]),v=P1.useCallback((k1,{node:v1,deltaX:s1,deltaY:n1})=>{if(!K1||!u)return;let G0=k1;if(W1.current&&!t.current){let V5=G0.clientX-i.current.x,j1=G0.clientY-i.current.y;if(Math.hypot(V5,j1)<N)return;if(t.current=!0,W1.current=!1,O){let S1=fZ(H1,U1.current.top,U1.current.left),{x:o1,y:z0}=cZ(x,F1,S1.x,S1.y,c());O(S,o1,z0,{e:k1,node:v1,newPosition:U1.current})}}let V0=U1.current.top+n1,T0=U1.current.left+s1;if(V){let{offsetParent:V5}=v1;if(V5){let j1=V5.clientHeight-W9(y,G,Q[1]);V0=gZ(V0,0,j1);let u1=J4(H1),S1=X-W9(C,u1,Q[0]);T0=gZ(T0,0,S1)}}let v0={top:V0,left:T0};U1.current=v0;let Y0=fZ(H1,V0,T0),{x:g0,y:G5}=cZ(x,F1,Y0.x,Y0.y,c());K1(S,g0,G5,{e:k1,node:v1,newPosition:v0})},[K1,O,u,N,V,y,G,Q,H1,X,C,S,x,F1,c]),p=P1.useCallback((k1,{node:v1})=>{if(!Z1||!u)return;let s1=W1.current;if(W1.current=!1,t.current=!1,i.current={x:0,y:0},s1){z1(!1),U1.current={left:0,top:0};return}let{left:n1,top:G0}=U1.current,V0={top:G0,left:n1};z1(!1),U1.current={left:0,top:0};let T0=fZ(H1,G0,n1),{x:v0,y:Y0}=cZ(x,F1,T0.x,T0.y,c());Z1(S,v0,Y0,{e:k1,node:v1,newPosition:V0})},[Z1,u,H1,x,F1,c,S]);M1.current=f1,l.current=v;let s=P1.useCallback((k1,{node:v1,size:s1,handle:n1},G0,V0)=>{let T0=V0==="onResizeStart"?k:V0==="onResize"?e:_1;if(!T0)return;let v0;if(v1)v0=vO(n1,G0,s1,X);else v0={...s1,top:G0.top,left:G0.left};f.current=v0;let Y0=yO(H1,v0.width,v0.height),{w:g0,h:G5}=xO(x,F1,Y0.w,Y0.h,n1,c());T0(S,g0,G5,{e:k1.nativeEvent,node:v1,size:v0,handle:n1})},[k,e,_1,X,H1,S,x,F1,c]),q1=P1.useCallback((k1,v1)=>{$1(!0);let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResizeStart")},[s,H1,_,T,C,y]),w1=P1.useCallback((k1,v1)=>{let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResize")},[s,H1,_,T,C,y]),h1=P1.useCallback((k1,v1)=>{$1(!1),f.current={top:0,left:0,width:0,height:0};let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResizeStop")},[s,H1,_,T,C,y]);P1.useEffect(()=>{if(!L)return;let k1=G1.current;if(!k1)return;let v1=o.current||{left:0,top:0},s1=u&&(L.left!==v1.left||L.top!==v1.top);if(!u){let n1={node:k1,deltaX:L.left,deltaY:L.top,lastX:0,lastY:0,x:L.left,y:L.top};M1.current?.(L.e,n1)}else if(s1){let n1=L.left-U1.current.left,G0=L.top-U1.current.top,V0={node:k1,deltaX:n1,deltaY:G0,lastX:U1.current.left,lastY:U1.current.top,x:L.left,y:L.top};l.current?.(L.e,V0)}o.current=L},[L,u,S]);let D0=mZ(H1,_,T,C,y,u?U1.current:null,V1?f.current:null),I0=P1.default.Children.only(J),g1=J4(H1),l1=[W9(j,g1,Q[0]),W9(I,G,Q[1])],e1=[W9(g,g1,Q[0]),W9(E,G,Q[1])],p1=I0.props,Q0=p1.className,W5=p1.style,k0=P1.default.cloneElement(I0,{ref:G1,className:gK("react-grid-item",Q0,M,{static:K,resizing:V1,"react-draggable":z,"react-draggable-dragging":u,dropping:Boolean(L),cssTransforms:U}),style:{...A,...W5,...I1(D0)}}),K5=R;return k0=V7.jsx(pw.Resizable,{draggableOpts:{disabled:!W},className:W?void 0:"react-resizable-hide",width:D0.width,height:D0.height,minConstraints:l1,maxConstraints:e1,onResizeStart:q1,onResize:w1,onResizeStop:h1,transformScale:B,resizeHandles:b,handle:K5,children:k0}),k0=V7.jsx(fw.DraggableCore,{disabled:!z,onStart:f1,onDrag:v,onStop:p,handle:P,cancel:".react-resizable-handle"+(D?","+D:""),scale:B,nodeRef:G1,children:k0}),k0}var K7=()=>{},gw="react-grid-layout",uw=!1;try{uw=/firefox/i.test(navigator.userAgent)}catch{}function tu(Z,J){let $=P1.default.Children.toArray(Z),X=P1.default.Children.toArray(J);if($.length!==X.length)return!1;for(let Q=0;Q<$.length;Q++){let Y=$[Q],G=X[Q];if(Y?.key!==G?.key)return!1}return!0}function mw(Z,J,$,X){let Q=[],Y=new Set;P1.default.Children.forEach(J,(H)=>{if(!P1.default.isValidElement(H)||H.key===null)return;let z=String(H.key);Y.add(z);let W=Z.find((V)=>V.i===z);if(W)Q.push(W7(W));else{let K=H.props["data-grid"];if(K)Q.push({i:z,x:K.x??0,y:K.y??0,w:K.w??1,h:K.h??1,minW:K.minW,maxW:K.maxW,minH:K.minH,maxH:K.maxH,static:K.static,isDraggable:K.isDraggable,isResizable:K.isResizable,resizeHandles:K.resizeHandles,isBounded:K.isBounded});else Q.push({i:z,x:0,y:pZ(Q),w:1,h:1})}});let G=YK(Q,{cols:$});return X.compact(G,$)}function nZ(Z){let{children:J,width:$,gridConfig:X,dragConfig:Q,resizeConfig:Y,dropConfig:G,positionStrategy:H=gO,compactor:z,constraints:W=GK,layout:V=[],droppingItem:K,autoSize:U=!0,className:q="",style:B={},innerRef:F,onLayoutChange:N=K7,onDragStart:L=K7,onDrag:M=K7,onDragStop:A=K7,onResizeStart:P=K7,onResize:D=K7,onResizeStop:_=K7,onDrop:T=K7,onDropDragOver:C=K7}=Z,y=P1.useMemo(()=>({...mO,...X}),[X]),j=P1.useMemo(()=>({...fO,...Q}),[Q]),g=P1.useMemo(()=>({...pO,...Y}),[Y]),I=P1.useMemo(()=>({...uO,...G}),[G]),{cols:E,rowHeight:S,maxRows:b,margin:R,containerPadding:x}=y,{enabled:h,bounded:d,handle:O,cancel:K1,threshold:Z1}=j,{enabled:k,handles:e,handleComponent:_1}=g,{enabled:u,defaultItem:z1,onDragOver:V1}=I,$1=z??LK("vertical"),G1=$1.type,U1=$1.allowOverlap,f=$1.preventCollision??!1,o=P1.useMemo(()=>K??{i:"__dropping-elem__",...z1},[K,z1]),n=H.type==="transform",M1=H.scale,l=x??R,[W1,i]=P1.useState(!1),[t,H1]=P1.useState(()=>mw(V,J,E,$1)),[r,c]=P1.useState(null),[F1,I1]=P1.useState(!1),[f1,v]=P1.useState(null),[p,s]=P1.useState(),q1=P1.useRef(null),w1=P1.useRef(null),h1=P1.useRef(null),D0=P1.useRef(0),I0=P1.useRef(t),g1=P1.useRef(V),l1=P1.useRef(J),e1=P1.useRef(G1),p1=P1.useRef(t);p1.current=t,P1.useEffect(()=>{if(i(!0),!G6.deepEqual(t,V))N(t)},[]),P1.useEffect(()=>{if(r)return;if(f1)return;let j1=!G6.deepEqual(V,g1.current),u1=!tu(J,l1.current),S1=G1!==e1.current;if(j1||u1||S1){let z0=mw(j1?V:t,J,E,$1);if(!G6.deepEqual(z0,t))H1(z0)}g1.current=V,l1.current=J,e1.current=G1},[V,J,E,G1,$1,r,f1,t]),P1.useEffect(()=>{if(!r&&!G6.deepEqual(t,I0.current)){I0.current=t;let j1=t.filter((u1)=>u1.i!==o.i);N(j1)}},[t,r,N,o.i]);let Q0=P1.useMemo(()=>{if(!U)return;let j1=pZ(t),u1=l[1];return j1*S+(j1-1)*R[1]+u1*2+"px"},[U,t,S,R,l]),W5=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=X4(z0,j1);if(!q0)return;let m0={w:q0.w,h:q0.h,x:q0.x,y:q0.y,i:j1};q1.current=W7(q0),h1.current=z0,c(m0),L(z0,q0,q0,null,o1.e,o1.node)},[L]),k0=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=q1.current,m0=X4(z0,j1);if(!m0)return;let P5={w:m0.w,h:m0.h,x:m0.x,y:m0.y,i:j1},f0=Z4(z0,m0,u1,S1,!0,f,G1,E,U1);M(f0,q0,m0,P5,o1.e,o1.node),H1($1.compact(f0,E)),c(P5)},[f,G1,E,U1,$1,M]),K5=P1.useCallback((j1,u1,S1,o1)=>{if(!r)return;let z0=p1.current,q0=q1.current,m0=X4(z0,j1);if(!m0)return;let P5=Z4(z0,m0,u1,S1,!0,f,G1,E,U1),f0=$1.compact(P5,E);A(f0,q0,m0,null,o1.e,o1.node);let c5=h1.current;if(q1.current=null,h1.current=null,c(null),H1(f0),c5&&!G6.deepEqual(c5,f0))N(f0)},[r,f,G1,E,U1,$1,A,N]),k1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=X4(z0,j1);if(!q0)return;w1.current=W7(q0),h1.current=z0,I1(!0),P(z0,q0,q0,null,o1.e,o1.node)},[P]),v1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=w1.current,{handle:m0}=o1,P5=!1,f0,c5,[$J,i9]=bO(z0,j1,(i0)=>{if(f0=i0.x,c5=i0.y,["sw","w","nw","n","ne"].includes(m0)){if(["sw","nw","w"].includes(m0))f0=i0.x+(i0.w-u1),u1=i0.x!==f0&&f0<0?i0.w:u1,f0=f0<0?0:f0;if(["ne","n","nw"].includes(m0))c5=i0.y+(i0.h-S1),S1=i0.y!==c5&&c5<0?i0.h:S1,c5=c5<0?0:c5;P5=!0}if(f&&!U1){if(XK(z0,{...i0,w:u1,h:S1,x:f0??i0.x,y:c5??i0.y}).filter((QJ)=>QJ.i!==i0.i).length>0)c5=i0.y,S1=i0.h,f0=i0.x,u1=i0.w,P5=!1}return i0.w=u1,i0.h=S1,i0});if(!i9)return;let e8=$J;if(P5&&f0!==void 0&&c5!==void 0)e8=Z4($J,i9,f0,c5,!0,f,G1,E,U1);let XJ={w:i9.w,h:i9.h,x:i9.x,y:i9.y,i:j1,static:!0};D(e8,q0,i9,XJ,o1.e,o1.node),H1($1.compact(e8,E)),c(XJ)},[f,G1,E,U1,$1,D]),s1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=w1.current,m0=X4(z0,j1),P5=$1.compact(z0,E);_(P5,q0,m0??null,null,o1.e,o1.node);let f0=h1.current;if(w1.current=null,h1.current=null,c(null),I1(!1),H1(P5),f0&&!G6.deepEqual(f0,P5))N(P5)},[E,$1,_,N]),n1=P1.useCallback(()=>{let j1=p1.current;if(!j1.some((o1)=>o1.i===o.i)){v(null),c(null),s(void 0);return}let S1=$1.compact(j1.filter((o1)=>o1.i!==o.i),E);H1(S1),v(null),c(null),s(void 0)},[o.i,E,$1]),G0=P1.useCallback((j1)=>{if(j1.preventDefault(),j1.stopPropagation(),uw&&!j1.nativeEvent.target?.classList.contains(gw))return!1;let u1=V1?V1(j1.nativeEvent):C(j1);if(u1===!1){if(f1)n1();return!1}let{dragOffsetX:S1=0,dragOffsetY:o1=0,...z0}=u1??{},q0={...o,...z0},m0=j1.currentTarget.getBoundingClientRect(),P5={cols:E,margin:R,maxRows:b,rowHeight:S,containerWidth:$,containerPadding:l},f0=J4(P5),c5=W9(q0.w,f0,R[0]),$J=W9(q0.h,S,R[1]),i9=c5/2,e8=$J/2,XJ=j1.clientX-m0.left+S1-i9,i0=j1.clientY-m0.top+o1-e8,pY=Math.max(0,XJ),QJ=Math.max(0,i0),YJ={left:pY/M1,top:QJ/M1,e:j1.nativeEvent};if(!f1){let uY=RO(P5,QJ,pY,q0.w,q0.h);v(V7.jsx("div",{},q0.i)),s(YJ);let XS=p1.current.filter((QS)=>QS.i!==q0.i);H1([...XS,{...q0,x:uY.x,y:uY.y,static:!1,isDraggable:!0}])}else if(p){if(p.left!==YJ.left||p.top!==YJ.top)s(YJ)}},[f1,p,o,V1,C,n1,M1,E,R,b,S,$,l]),V0=P1.useCallback((j1)=>{if(j1.preventDefault(),j1.stopPropagation(),D0.current--,D0.current<0)D0.current=0;if(D0.current===0)n1()},[n1]),T0=P1.useCallback((j1)=>{j1.preventDefault(),j1.stopPropagation(),D0.current++},[]),v0=P1.useCallback((j1)=>{j1.preventDefault(),j1.stopPropagation();let u1=p1.current,S1=u1.find((o1)=>o1.i===o.i);D0.current=0,n1(),T(u1,S1,j1.nativeEvent)},[o.i,n1,T]),Y0=P1.useCallback((j1,u1)=>{if(!j1||!j1.key)return null;let S1=X4(t,String(j1.key));if(!S1)return null;let o1=typeof S1.isDraggable==="boolean"?S1.isDraggable:!S1.static&&h,z0=typeof S1.isResizable==="boolean"?S1.isResizable:!S1.static&&k,q0=S1.resizeHandles||[...e],m0=o1&&d&&S1.isBounded!==!1,P5=_1;return V7.jsx(vK,{containerWidth:$,cols:E,margin:R,containerPadding:l,maxRows:b,rowHeight:S,cancel:K1,handle:O,onDragStart:W5,onDrag:k0,onDragStop:K5,onResizeStart:k1,onResize:v1,onResizeStop:s1,isDraggable:o1,isResizable:z0,isBounded:m0,useCSSTransforms:n&&W1,usePercentages:!W1,transformScale:M1,positionStrategy:H,dragThreshold:Z1,w:S1.w,h:S1.h,x:S1.x,y:S1.y,i:S1.i,minH:S1.minH,minW:S1.minW,maxH:S1.maxH,maxW:S1.maxW,static:S1.static,droppingPosition:u1?p:void 0,resizeHandles:q0,resizeHandle:P5,constraints:W,layoutItem:S1,layout:t,children:j1},S1.i)},[t,$,E,R,l,b,S,K1,O,W5,k0,K5,k1,v1,s1,h,k,d,n,W1,M1,H,Z1,p,e,_1,W]),g0=()=>{if(!r)return null;return V7.jsx(vK,{w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,className:`react-grid-placeholder ${F1?"placeholder-resizing":""}`,containerWidth:$,cols:E,margin:R,containerPadding:l,maxRows:b,rowHeight:S,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:n,transformScale:M1,constraints:W,layout:t,children:V7.jsx("div",{})})},G5=gK(gw,q),V5={height:Q0,...B};return V7.jsxs("div",{ref:F,className:G5,style:V5,onDrop:u?v0:void 0,onDragLeave:u?V0:void 0,onDragEnter:u?T0:void 0,onDragOver:u?G0:void 0,children:[P1.default.Children.map(J,(j1)=>{if(!P1.default.isValidElement(j1))return null;return Y0(j1)}),u&&f1&&Y0(f1,!0),g0()]})}var H6=w(a(),1);function mK({items:Z,editing:J,renderItem:$,onLayoutChange:X}){let[Q,Y]=oZ.useState(()=>vZ(Z,[])),[G,H]=oZ.useState(Z),{width:z,containerRef:W,mounted:V}=NK({measureBeforeMount:!0});if(G!==Z)H(Z),Y((U)=>{let q=new Map(U.map((L)=>[L.i,L])),B=Z.filter((L)=>q.has(L.id)).map((L)=>({...q.get(L.id),w:L.w,h:L.h})),F=new Set(B.map((L)=>L.i)),N=vZ(Z.filter((L)=>!F.has(L.id)),B);return[...B,...N]});let K=oZ.useCallback((U)=>{Y(U),X?.(U.map((q)=>({id:q.i,w:q.w,h:q.h,x:q.x,y:q.y})))},[X]);return H6.jsx("div",{ref:W,className:"mx-auto w-full max-w-[var(--column-w)]",children:V&&H6.jsx(nZ,{width:z,layout:Q,gridConfig:{cols:4,rowHeight:160,margin:[8,8],containerPadding:[0,0]},dragConfig:{enabled:!!J},resizeConfig:{enabled:!1},compactor:dZ,onLayoutChange:K,children:Q.map((U)=>H6.jsx("div",{children:H6.jsx(n0.div,{layoutId:U.i,"data-snapshot-widget":U.i,className:"size-full",transition:{type:"spring",duration:0.35,bounce:0},children:$(U.i)})},U.i))})})}function cw({items:Z,editing:J,renderItem:$,onLayoutChange:X,onRemove:Q}){return H6.jsx(mK,{items:Z,editing:J,onLayoutChange:X,renderItem:(Y)=>H6.jsx(GY,{editing:J,onRemove:Q?()=>Q(Y):void 0,children:$(Y)})})}var z6=w(m(),1);function dw(Z){let J=Z0();return r0({mutationFn:({key:$,thumbnails:X})=>Z9(`/api/workspaces/${Z}/thumbnails`,x5("PUT",{key:$,thumbnails:X}),"Failed to save thumbnails"),onMutate:({key:$})=>{J.setQueryData(D1.layout(Z),(X)=>X?{...X,widgetThumbnails:{key:$,at:new Date().toISOString()}}:X)},onSuccess:()=>{J.invalidateQueries({queryKey:D1.preview(Z)})}})}var Zc=(Z)=>Math.min(1,400/Math.max(Z.offsetWidth,Z.offsetHeight)),lw=(Z,J)=>{let $=new Map(J.map((X)=>[X.id,X.tag]));return[...Z].sort().map((X)=>`${X}@${$.get(X)??""}`).join(" ")},Jc=(Z)=>new Promise((J)=>{setTimeout(()=>J(null),Z)});async function iw(Z){let{createContext:J,destroyContext:$,domToDataUrl:X}=await import("/chunk-jen6xcm1.js"),Q=async()=>{let Y=await J(Z,{scale:Zc(Z),type:"image/webp",quality:0.8,backgroundColor:"#ffffff",timeout:1000,onCreateForeignObjectSvg:(G)=>{let H=document.createElement("style");H.textContent="[data-widget-chrome] { border-radius: 0 !important; box-shadow: none !important; }[data-widget-chrome]::after { display: none !important; }",G.append(H)}});try{return await X(Y)}finally{$(Y)}};return Promise.race([Q(),Jc(1e4)])}var $c=5000,Xc=10800000;function rw({containerRef:Z,widgets:J,visibleIds:$,editing:X}){let{layout:Q,workspaceId:Y}=w0(),G=dw(Y),H=z6.useRef(G.mutate);H.current=G.mutate;let z=z6.useRef(!1),[W,V]=z6.useState(0),K=lw($,J),U=Date.parse(Q.widgetThumbnails?.at??""),q=!Number.isFinite(U)||Date.now()-U>Xc,B=K!==""&&(K!==Q.widgetThumbnails?.key||q);z6.useEffect(()=>{if(!B||X)return;if(document.visibilityState!=="visible"){let L=()=>V((M)=>M+1);return document.addEventListener("visibilitychange",L,{once:!0}),()=>document.removeEventListener("visibilitychange",L)}let F=!1,N=setTimeout(async()=>{if(z.current)return;z.current=!0;try{let L={};for(let M of $){if(F)return;let A=Z.current?.querySelector(`[data-snapshot-widget="${CSS.escape(M)}"]`),P=A?await iw(A):null;if(P)L[M]=P}if(F)return;H.current({key:K,thumbnails:L})}finally{z.current=!1,V((L)=>L+1)}},$c);return()=>{F=!0,clearTimeout(N)}},[K,B,X,W])}var $0=w(a(),1);function aw(Z){return $0.jsx(TO,{name:Z})}var Qc=Array.from({length:10},(Z,J)=>({id:`empty-widget-${J}`,w:2,h:1}));function Yc(){return $0.jsx(g8,{className:"size-full animate-none rounded-2xl [corner-shape:superellipse(1.2)]"})}function Gc({onCreateWidget:Z}){return $0.jsxs("div",{className:"relative min-h-0 flex-1 pt-7",children:[$0.jsx("div",{"aria-hidden":"true",children:$0.jsx(mK,{items:Qc,renderItem:Yc})}),$0.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6",children:$0.jsxs("div",{className:"flex h-full w-full max-w-(--column-w) flex-col items-center justify-center gap-4 bg-radial from-background from-50% to-transparent to-75% text-center",children:[$0.jsxs("div",{className:"flex flex-col gap-1.5",children:[$0.jsx("h2",{className:"font-medium",children:"A little empty here"}),$0.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Widgets are small apps that can read data, perform tasks, and show a compact view of the information that matters."})]}),$0.jsxs(E1,{type:"button",variant:"secondary",size:"sm",onClick:Z,children:[$0.jsx(a5,{"data-icon":"inline-start",stroke:1.5}),"Create widget"]})]})})]})}function Hc({editing:Z,onCreateWidget:J,onEditingChange:$}){return $0.jsxs("div",{className:"mx-auto mb-4 flex w-full max-w-(--column-w) shrink-0 items-center justify-end gap-2",children:[Z&&$0.jsxs(E1,{type:"button",variant:"ghost",size:"sm",className:"mr-auto",onClick:J,children:[$0.jsx(a5,{"data-icon":"inline-start",stroke:1.75}),"New widget"]}),$0.jsx(d9,{mode:"popLayout",initial:!1,children:Z?$0.jsx(n0.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"}},initial:"from",animate:"to",exit:"from",transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(E1,{type:"button",size:"sm",onClick:()=>$(!1),children:"Done"})},"done"):$0.jsx(n0.div,{className:"flex items-center gap-1",variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"}},initial:"from",animate:"to",exit:"from",transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(E1,{type:"button",variant:"ghost",size:"sm",className:"text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0",onClick:()=>$(!0),children:"Edit widgets"})},"actions")})]})}function zc(){return $0.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3",children:$0.jsx("p",{className:"text-sm text-muted-foreground",children:"No widgets added yet"})})}function Wc(){let[Z,J]=i8.useState(0);return[i8.useCallback((X)=>{if(!X)return;let Q=new ResizeObserver(([Y])=>{let G=Y.borderBoxSize?.[0];J(G?G.blockSize:Y.contentRect.height)});return Q.observe(X),()=>Q.disconnect()},[]),Z]}function nw({onCreateWidget:Z,editing:J,onEditingChange:$,widgets:X}){let{layout:Q,setLayout:Y}=w0(),G=X.length>0,H=new Set(Q.widgetGrid.map((N)=>N.i)),z=Q.widgetGrid.filter((N)=>X.some((L)=>L.id===N.i)).map((N)=>{let L=X.find((M)=>M.id===N.i);return{id:N.i,w:L.config.colSpan,h:L.config.rowSpan,x:N.x,y:N.y}}),W=X.filter((N)=>!H.has(N.id)).map((N)=>({id:N.id,w:N.config.colSpan,h:N.config.rowSpan})),[V,K]=Wc(),U=J&&W.length>0,q=i8.useRef(null);rw({containerRef:q,widgets:X,visibleIds:z.map((N)=>N.id),editing:J});function B(N){Y({widgetGrid:Q.widgetGrid.filter((L)=>L.i!==N)})}function F(N){let L=X.find((P)=>P.id===N);if(!L)return;let M=Q.widgetGrid.map((P)=>{let D=X.find((_)=>_.id===P.i);return{...P,w:D?.config.colSpan??1,h:D?.config.rowSpan??1}}),A=hZ(M,L.config.colSpan,L.config.rowSpan,4);Y({widgetGrid:[...Q.widgetGrid,{i:N,x:A.x,y:A.y}]})}return $0.jsx("div",{ref:q,className:"group/widgets relative min-h-0 flex-1",children:$0.jsxs(sw,{children:[$0.jsx("div",{className:N1("relative flex h-full flex-col p-4",G?"overflow-y-auto":"overflow-hidden"),children:G?$0.jsxs($0.Fragment,{children:[$0.jsx(Hc,{editing:J,onCreateWidget:Z,onEditingChange:$}),z.length===0?$0.jsx(n0.div,{className:"mx-auto flex min-h-0 w-full max-w-[var(--column-w)] flex-1 flex-col",animate:{paddingBottom:U?K:0},transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(zc,{})}):$0.jsx(n0.div,{animate:{marginBottom:U?K:0},transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(cw,{items:z,editing:J,renderItem:aw,onRemove:B,onLayoutChange:(N)=>Y({widgetGrid:N.map((L)=>({i:L.id,x:L.x??0,y:L.y??0}))})})})]}):$0.jsx(Gc,{onCreateWidget:Z})}),$0.jsx(d9,{children:G&&J&&W.length>0&&$0.jsx(IO,{ref:V,items:W,renderItem:aw,onRestore:F})})]})})}var tw=w(a(),1);function ow({children:Z}){return tw.jsx("header",{className:"@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75 px-3",children:Z})}var nK=w(m(),1);var E5=w(a(),1);function Kc(Z){if(Z==="needs-auth")return"Needs auth";return Z[0].toUpperCase()+Z.slice(1)}function Vc({name:Z,status:J}){let $=Zj(Z),X="size-full rounded-sm ring-2 ring-background";return E5.jsxs("span",{className:"relative size-10 shrink-0",children:[$?E5.jsx("img",{src:$,alt:"",className:"size-full rounded-sm ring-2 ring-background"}):E5.jsx("span",{className:"flex size-full items-center justify-center rounded-sm bg-muted text-muted-foreground ring-2 ring-background",children:E5.jsx($j,{className:"size-5"})}),J!=="connected"&&E5.jsx(ew,{"aria-hidden":"true",size:16,stroke:1.75,className:"absolute -top-1 -right-1 rounded-full bg-card text-amber-400"})]})}function Xj(Z){return[...Z].sort((J,$)=>Number($.status==="connected")-Number(J.status==="connected"))}function Qj({icon:Z,children:J}){return E5.jsxs("div",{className:"flex items-center gap-3 text-card-foreground",children:[Z,E5.jsx("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-0.5",children:J})]})}function Yj({server:Z}){return E5.jsxs(Qj,{icon:E5.jsx(Vc,{name:Z.name,status:Z.status}),children:[E5.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Jj(Z.name)}),E5.jsx("span",{className:"text-sm text-muted-foreground",children:Kc(Z.status)})]})}function Gj(){return E5.jsxs(Qj,{icon:E5.jsx(g8,{className:"size-10 shrink-0 rounded-sm"}),children:[E5.jsx(g8,{className:"h-4 w-36 max-w-full"}),E5.jsx(g8,{className:"h-4 w-20"})]})}function pK({children:Z}){return E5.jsx("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2",children:Z})}function Hj(Z,J){return J5({queryKey:D1.mcp(Z),queryFn:()=>L0(`/api/workspaces/${Z}/mcp`),enabled:J,staleTime:1/0,gcTime:1/0,refetchOnMount:!1,refetchOnWindowFocus:!1})}var L2=w(a(),1);function r8({title:Z,description:J,children:$}){return L2.jsxs("div",{className:"flex flex-col gap-6",children:[L2.jsxs("header",{className:"flex flex-col gap-0.5",children:[L2.jsx("h2",{className:"text-lg font-medium tracking-tight",children:Z}),J&&L2.jsx("p",{className:"text-sm text-muted-foreground",children:J})]}),$]})}function a8({label:Z,children:J}){return L2.jsxs("section",{className:"flex flex-col gap-2",children:[Z&&L2.jsx("p",{className:"px-0.5 text-xs font-medium text-muted-foreground",children:Z}),L2.jsx("div",{className:"flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-lg border border-border bg-card text-card-foreground",children:J})]})}function s8({title:Z,description:J,control:$}){return L2.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-3",children:[L2.jsxs("div",{className:"flex min-w-0 flex-col",children:[L2.jsx("span",{className:"text-sm font-medium",children:Z}),J&&L2.jsx("span",{className:"text-xs text-muted-foreground",children:J})]}),$&&L2.jsx("div",{className:"ml-auto flex shrink-0 items-center pl-3",children:$})]})}var e5=w(a(),1),qc=Array.from({length:4},(Z,J)=>J);function Uc({connectors:Z}){if(Z.isPending)return e5.jsx("div",{role:"status","aria-label":"Loading connectors",children:e5.jsx(pK,{children:qc.map((J)=>e5.jsx(Gj,{},J))})});if(Z.isError)return e5.jsxs(zj,{children:[e5.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not load connectors."}),e5.jsx(E1,{variant:"outline",size:"sm",onClick:()=>Z.refetch(),children:"Retry"})]});if(Z.data.length===0)return e5.jsxs(zj,{children:[e5.jsx(OY,{size:24,stroke:1.5,className:"text-muted-foreground"}),e5.jsx("p",{className:"text-sm text-foreground",children:"No connectors configured."})]});return e5.jsx(pK,{children:Xj(Z.data).map((J)=>e5.jsx(Yj,{server:J},J.name))})}function zj({children:Z}){return e5.jsx("div",{className:"flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center",children:Z})}function Wj(){let{workspaceId:Z}=w0(),J=Hj(Z,!0);return e5.jsx(r8,{title:"Connectors",description:"Connectors available to the agent in this workspace.",children:e5.jsx(Uc,{connectors:J})})}var uK=w(m(),1);function Kj(Z){return J5({queryKey:D1.env(Z),queryFn:()=>L0(`/api/workspaces/${Z}/env`),...h9})}function Vj(Z){let J=Z0();return r0({mutationFn:($)=>L0(`/api/workspaces/${Z}/env`,x5("PUT",$)),onSuccess:($)=>{J.setQueryData(D1.env(Z),$)}})}function qj(Z){let J=Z0();return r0({mutationFn:($)=>Z9(`/api/workspaces/${Z}/config`,x5("PUT",{name:$}),"Failed to save name"),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Uj(Z){let J=Z0();return r0({scope:{id:`workspace-icon:${Z}`},mutationFn:($)=>L0(`/api/workspaces/${Z}/icon`,{method:"PUT",headers:{"Content-Type":$.type||"application/octet-stream"},body:$}),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Bj(Z){let J=Z0();return r0({scope:{id:`workspace-icon:${Z}`},mutationFn:()=>Z9(`/api/workspaces/${Z}/icon`,{method:"DELETE"},"Failed to reset icon"),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Fj(Z){let J=Z0();return Y9(($)=>{if($.type==="env:updated"&&$.workspaceId===Z)J.invalidateQueries({queryKey:D1.env(Z)})}),{env:Kj(Z),update:Vj(Z)}}var e0=w(a(),1),Bc={dotenv:".env",custom:"secret",both:"override"},Fc=/^[A-Za-z_][A-Za-z0-9_]*$/;function Nj(){let{workspaceId:Z}=w0(),{env:J,update:$}=Fj(Z),[X,Q]=uK.useState(""),[Y,G]=uK.useState(""),H=Fc.test(X),z=H&&Y.length>0&&!$.isPending,W=()=>{if(!z)return;$.mutate({set:{[X]:Y}},{onSuccess:()=>{Q(""),G("")}})},V=J.data?.vars??[],K=J.data?.files.reduce((q,B)=>q+B.count,0)??0,U=J.data?.files.length??0;return e0.jsxs(r8,{title:"Environment",description:"Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved.",children:[e0.jsxs(a8,{label:"Variables",children:[J.isLoading?e0.jsx("div",{className:"flex items-center justify-center px-3.5 py-6 text-muted-foreground",children:e0.jsx(Y2,{className:"size-4 animate-spin",stroke:1.75})}):V.length===0?e0.jsx("p",{className:"px-3.5 py-4 text-sm text-muted-foreground",children:"No variables yet."}):V.map((q)=>{let B=q.source!=="dotenv";return e0.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[e0.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:q.key}),e0.jsx("span",{className:"text-xs tracking-widest text-muted-foreground/60 select-none",children:"••••••"}),e0.jsx("span",{className:N1("rounded-sm px-1.5 py-0.5 text-[11px] font-medium",q.source==="dotenv"?"bg-muted text-muted-foreground":"bg-primary/10 text-primary"),children:Bc[q.source]}),!B&&e0.jsx("span",{className:"text-right text-[11px] text-muted-foreground/60",children:"from file"}),e0.jsx(E1,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>$.mutate({remove:[q.key]}),disabled:!B,"aria-label":`Delete ${q.key}`,className:"disabled:invisible",children:e0.jsx(Lj,{stroke:1.75})})]},q.key)}),e0.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5",children:[e0.jsx(y7,{value:X,onChange:(q)=>Q(q.target.value),placeholder:"NEW_KEY","aria-invalid":X.length>0&&!H,className:"h-7 w-40 font-mono text-xs"}),e0.jsx(y7,{value:Y,onChange:(q)=>G(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")W()},type:"password",placeholder:"value",className:"h-7 flex-1 text-xs"}),e0.jsxs(E1,{variant:"outline",size:"sm",onClick:W,disabled:!z,children:[$.isPending?e0.jsx(Y2,{stroke:1.75,className:"animate-spin"}):e0.jsx(a5,{stroke:1.75}),"Add"]})]})]}),e0.jsx(a8,{label:"From .env files",children:e0.jsx(s8,{title:"Inherit .env files",description:U>0?`Discovered ${K} ${K===1?"key":"keys"} across ${U} ${U===1?"file":"files"} in this space.`:"No .env files found in this space.",control:e0.jsx(eX,{checked:J.data?.inheritDotenv??!0,disabled:J.isLoading,onCheckedChange:(q)=>$.mutate({inheritDotenv:q})})})})]})}var _C=w(m(),1);var u5=w(m(),1);var b1=w(m(),1),n8=w(m(),1),S2=w(m(),1),mj=w(a(),1),jY=w(m(),1),TY=w(m(),1),X0=w(a(),1),Lc=Object.defineProperty,Nc=(Z,J)=>{for(var $ in J)Lc(Z,$,{get:J[$],enumerable:!0})},q7={};Nc(q7,{ActiveEmoji:()=>JT,Empty:()=>ZT,List:()=>oj,Loading:()=>ej,Root:()=>dj,Search:()=>lj,SkinTone:()=>$T,SkinToneSelector:()=>tj,Viewport:()=>ij});var yj="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",lK=["none","light","medium-light","medium","medium-dark","dark"];function cK(Z){return Z.charAt(0).toUpperCase()+Z.slice(1)}var q9=2,Z2=null;function _j(Z){try{Z2??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Z2||(queueMicrotask(()=>{Z2&&(Z2=null)}),Z2.canvas.width=q9,Z2.canvas.height=q9,Z2.font=`2px ${yj}`,Z2.textBaseline="middle",Z2.measureText(Z).width>=q9*2))return!1;Z2.fillStyle="#00f",Z2.fillText(Z,0,0);let J=Z2.getImageData(0,0,q9,q9).data;Z2.clearRect(0,0,q9,q9),Z2.fillStyle="#f00",Z2.fillText(Z,0,0);let $=Z2.getImageData(0,0,q9,q9).data;for(let X=0;X<q9*q9*4;X+=4)if(J[X]!==$[X]||J[X+1]!==$[X+1]||J[X+2]!==$[X+2])return!1;return!0}function Mj(Z,J,$){try{let X=Z.getItem(J);if(!X)throw Error(`No value found for "${J}".`);let Q=JSON.parse(X);return $(Q)}catch{return null}}function bj(Z,J,$){Z.setItem(J,JSON.stringify($))}function Aj(Z){return(J)=>J===void 0?void 0:Z(J)}function Dj(Z){return(J)=>J===null?null:Z(J)}function p5(Z){if(typeof Z!="string")throw Error();return Z}function wY(Z){if(typeof Z!="number")throw Error();return Z}function xj(Z){if(typeof Z!="boolean")throw Error();return Z}function G4(Z){return(J)=>{if(typeof J!="object"||J===null)throw Error();let $={};for(let X in Z){let Q=J[X];Q===void 0&&Z[X](void 0),$[X]=Z[X](Q)}return $}}function dK(Z){return(J)=>{if(!Array.isArray(J))throw Error();return J.length>0&&Z(J[0]),J}}var hj=(Z,J)=>`${Z}/${J}/data.json`,vj=(Z,J)=>`${Z}/${J}/messages.json`,_c=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],Pj="en",gj=(Z)=>`frimousse/data/${Z}`,Oj="frimousse/metadata";async function wj(Z,J){try{return(await fetch(Z,{method:"HEAD",signal:J})).headers.get("etag")}catch{return null}}async function Mc(Z,J,$){let[{emojis:X,emojisEtag:Q},{messages:Y,messagesEtag:G}]=await Promise.all([fetch(hj(Z,J),{signal:$}).then(async(H)=>({emojis:await H.json(),emojisEtag:H.headers.get("etag")})),fetch(vj(Z,J),{signal:$}).then(async(H)=>({messages:await H.json(),messagesEtag:H.headers.get("etag")}))]);return{emojis:X,messages:Y,emojisEtag:Q,messagesEtag:G}}async function Ac(Z,J,$){let[X,Q]=await Promise.all([wj(hj(Z,J),$),wj(vj(Z,J),$)]);return{emojisEtag:X,messagesEtag:Q}}function Dc(Z){return Z.skins?Z.skins.filter((J)=>typeof J.tone=="number").reduce((J,$)=>{let X=lK[$.tone];return J[X]=$.emoji,J},{}):void 0}async function jj(Z,J,$){let{emojis:X,emojisEtag:Q,messages:Y,messagesEtag:G}=await Mc(Z,J,$),H=Y.subgroups.find((B)=>B.key==="country-flag"||B.key==="subdivision-flag"),z=Y.groups.filter((B)=>B.key!=="component"),W=X.filter((B)=>("group"in B)),V=z.map((B)=>({index:B.order,label:cK(B.message)})),K=Y.skinTones.reduce((B,F)=>(B[F.key]=cK(F.message),B),{}),U=W.map((B)=>({emoji:B.emoji,category:B.group,version:B.version,label:cK(B.label),tags:B.tags??[],countryFlag:H&&B.subgroup===H.order||void 0,skins:Dc(B)})),q={locale:J,emojis:U,categories:V,skinTones:K};return bj(localStorage,gj(J),{data:q,metadata:{emojisEtag:Q,messagesEtag:G}}),q}function Pc(Z,J){let $=new Map;for(let G of Z)$.has(G.version)||$.set(G.version,G.emoji);let X=[...$.keys()].sort((G,H)=>H-G),Q=X[0]??0,Y=_j("\uD83C\uDDEA\uD83C\uDDFA");if(typeof J=="number")return{emojiVersion:J,countryFlags:Y};for(let G of X){let H=$.get(G);if(_j(H))return{emojiVersion:G,countryFlags:Y}}return{emojiVersion:Q,countryFlags:Y}}var Oc=G4({emojiVersion:wY,countryFlags:xj}),wc=G4({data:G4({locale:p5,emojis:dK(G4({emoji:p5,category:wY,label:p5,version:wY,tags:dK(p5),countryFlag:Aj(xj),skins:Aj(G4({light:p5,"medium-light":p5,medium:p5,"medium-dark":p5,dark:p5}))})),categories:dK(G4({index:wY,label:p5})),skinTones:G4({light:p5,"medium-light":p5,medium:p5,"medium-dark":p5,dark:p5})}),metadata:G4({emojisEtag:Dj(p5),messagesEtag:Dj(p5)})});async function jc({locale:Z,emojiVersion:J,emojibaseUrl:$,signal:X}){let Q=typeof $=="string"?$:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof J=="number"?Math.floor(J):"latest"}`,Y=Mj(sessionStorage,Oj,Oc),G=Mj(localStorage,gj(Z),wc),H;if(!G)H=await jj(Q,Z,X);else if(Y)H=G.data;else try{let{emojisEtag:W,messagesEtag:V}=await Ac(Q,Z,X);H=!W||!V||W!==G.metadata.emojisEtag||V!==G.metadata.messagesEtag?await jj(Q,Z,X):G.data}catch{H=G.data}Y??=Pc(H.emojis,J),bj(sessionStorage,Oj,Y);let z=H.emojis.filter((W)=>{let V=W.version<=Y.emojiVersion;return W.countryFlag?V&&Y.countryFlags:V});return{locale:Z,emojis:z,categories:H.categories,skinTones:H.skinTones}}function Tj(Z){return _c.includes(Z)?Z:(console.warn(`Locale "${Z}" is not supported, using "${Pj}" instead.`),Pj)}function Cj(Z){return lK.includes(Z)?Z:(console.warn(`Skin tone "${Z}" is not valid, using "none" instead.`),"none")}function Tc(Z,J){let $=[];if(J<=0)return $;for(let X=0,Q=Z.length;X<Q;X+=J)$.push(Z.slice(X,X+J));return $}function Cc(Z,J){if(!J)return Z;let $=J.toLowerCase().trim(),X=new WeakMap;return Z.filter((Q)=>{let Y=0;Q.label.toLowerCase().includes($)&&(Y+=10);for(let G of Q.tags)G.toLowerCase().includes($)&&(Y+=1);return Y>0?(X.set(Q,Y),!0):!1}).sort((Q,Y)=>(X.get(Y)??0)-(X.get(Q)??0))}function Sc(Z,J,$,X){let Q=Cc(Z.emojis,X),Y=[],G=[],H=[],z={},W=0,V=0;for(let K of Q)z[K.category]||(z[K.category]=[]),z[K.category].push({emoji:$&&$!=="none"&&K.skins?K.skins[$]:K.emoji,label:K.label});for(let K of Z.categories){let U=z[K.index];if(!U||U.length===0)continue;let q=Tc(Array.from(U),J).map((B)=>({categoryIndex:W,emojis:B}));Y.push(...q),G.push({label:K.label,rowsCount:q.length,startRowIndex:V}),H.push(V),W++,V+=q.length}return{count:Q.length,categories:G,categoriesStartRowIndices:H,rows:Y,skinTones:Z.skinTones}}function Ec(Z){let J={},$=null,X=null,Q=new Set,Y=()=>{if($){J=$,$=null;for(let W of Q)W(J)}X=null},G=()=>$??J,H=(W)=>{$??=J,Object.assign($,typeof W=="function"?W(G()):W),X||(X=requestAnimationFrame(Y))},z=(W)=>(Q.add(W),()=>Q.delete(W));return J=Z(H,G),{get:G,set:H,subscribe:z}}function Ic(Z){let[J]=S2.useState(Z);return J}function kc(Z){let J=S2.createContext(null);return{useStore:()=>{let $=S2.useContext(J);if(!$)throw Error(Z);return $},Provider:({store:$,children:X})=>mj.jsx(J.Provider,{value:$,children:X})}}function C2(Z,J,$=Object.is){let[X,Q]=S2.useState(()=>J(Z.get()));return S2.useEffect(()=>Z.subscribe(()=>{let Y=J(Z.get());Q((G)=>$(G,Y)?G:Y)}),[Z,J,$]),S2.useDebugValue(X),X}function l9(Z,J,$){let X=S2.useCallback((Q)=>Q[J],[J]);return C2(Z,X,$)}var Sj=2;function Rc(Z,J,$,X,Q){let Y=0;return Ec((G,H)=>({locale:J,columns:$,sticky:X,skinTone:Q,onEmojiSelect:Z,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:(z)=>{let W=H(),V=z?.data??W.data,K=z?.categoryHeaderHeight??W.categoryHeaderHeight,U=z?.rowHeight??W.rowHeight,q=z?.viewportHeight??W.viewportHeight;if(!V||V.rows.length===0||!K||!U||!q)return G({...z,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let B=0,F=0;for(let C of V.categories)if(F++*K+C.startRowIndex*U<Y)B+=K;else break;let N=V.categories.length*K+V.rows.length*U,L=Math.floor(Sj*U/2),M=Math.ceil(Sj*U/2),A=Math.min(Y-B-L,N-q),P=A+q+M,D=Math.max(0,Math.floor(A/U)),_=Math.min(V.rows.length-1,Math.ceil(P/U)),T=V.rows[D]?.categoryIndex;return G(T===void 0&&z?z:{...z,viewportStartCategoryIndex:T,viewportStartRowIndex:D,viewportEndRowIndex:_})},onDataChange:(z)=>{H().updateViewportState({data:z,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:(z)=>{G({search:z,interaction:z?"keyboard":"none"})},onActiveEmojiChange:(z,W,V)=>{if(G({interaction:z,activeColumnIndex:W,activeRowIndex:V}),z!=="keyboard")return;let{listRef:K,viewportRef:U,sticky:q,rowHeight:B,viewportHeight:F,categoryHeaderHeight:N}=H(),L=K?.current,M=U?.current;if(!L||!M||!B||!N||!F)return;let A=V;A===0&&M.scrollTo({top:0,behavior:"instant"});let P=L.querySelector(`[aria-rowindex="${A}"]`);if(!(P instanceof HTMLElement))return;let D=P.offsetTop,_=getComputedStyle(P),T=Number.parseFloat(_.scrollMarginTop),C=Number.parseFloat(_.scrollMarginBottom),y=Y+T;q&&D<Y+F/2&&(y+=N);let j=y+F-C;(D<y||D+B>j)&&M.scrollTo({top:Math.max(D<y+N?D-Math.max(q?N:0,T):D-F+B+C,0),behavior:"instant"})},onActiveEmojiReset:()=>{G({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:(z)=>{H().updateViewportState({rowHeight:z})},onCategoryHeaderHeightChange:(z)=>{H().updateViewportState({categoryHeaderHeight:z})},onViewportSizeChange:(z,W)=>{H().updateViewportState({viewportWidth:z,viewportHeight:W})},onViewportScroll:(z)=>{Y=z,H().updateViewportState()}}))}var{useStore:N2,Provider:yc}=kc("EmojiPicker.Root is missing.");function bc(Z){return Z.search}function iK(Z){return Z.interaction==="none"?void 0:Z.data?.rows[Z.activeRowIndex]?.emojis[Z.activeColumnIndex]}function xc(Z){return Z.data===void 0||typeof Z.data?.count=="number"&&Z.data.count===0}function hc(Z){return Z.data===null||Z.viewportHeight===null||Z.rowHeight===null||Z.categoryHeaderHeight===null}function fj(Z){return Z.data?.rows.length}function vc(Z){return Z.data?.categories.length}function gc(Z){return Z.data?.categoriesStartRowIndices}function mc(Z){return Z.data?.skinTones}function pj(Z,J){return Z?.emoji===J?.emoji}function fc(Z,J){return Z?.categoryIndex!==J?.categoryIndex||Z?.emojis.length!==J?.emojis.length?!1:!!Z?.emojis.every(($,X)=>pj($,J?.emojis[X]))}var tZ="",Ej=/\p{Emoji_Modifier_Base}/u,pc=/\uFE0F$/,uc=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,cc={light:"\uD83C\uDFFB","medium-light":"\uD83C\uDFFC",medium:"\uD83C\uDFFD","medium-dark":"\uD83C\uDFFE",dark:"\uD83C\uDFFF"};function dc(Z,J){if(!Z.split(tZ).some((X)=>Ej.test(X)))return Z;let $=Z.split(tZ).map((X)=>X.replace(uc,"")).join(tZ);return J==="none"?$:$.split(tZ).map((X,Q,Y)=>{let G=Y.length>1;return!Ej.test(X)||G&&X==="\uD83E\uDD1D"?X:X.replace(pc,"")+cc[J]}).join(tZ)}function lc(Z){return lK.map((J)=>({skinTone:J,emoji:dc(Z,J)}))}function uj(){let Z=N2(),J=C2(Z,iK,pj);return n8.useDeferredValue(J)}function cj(Z="✋"){let J=N2(),$=l9(J,"skinTone"),X=n8.useMemo(()=>lc(Z),[Z]),Q=n8.useCallback((Y)=>{J.set({skinTone:Y})},[]);return[$,Q,X]}function rK(Z,J){if(Object.is(Z,J))return!0;if(typeof Z!="object"||typeof J!="object"||Z===null||J===null||Array.isArray(Z)!==Array.isArray(J))return!1;let $=Object.keys(Z),X=Object.keys(J);return $.length!==X.length?!1:$.every((Q)=>(Q in J)&&Z[Q]===J[Q])}function ic(...Z){}function rc(Z,J){let $=null;if(typeof window.requestIdleCallback=="function")$=window.requestIdleCallback(Z,J);else{let X=Date.now();$=window.setTimeout(()=>{Z({didTimeout:!1,timeRemaining:()=>Math.max(0,(J?.timeout??50)-(Date.now()-X))})},10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback($):window.clearTimeout($)}}var U9=typeof window<"u"?jY.useLayoutEffect:jY.useEffect;function ac(Z){let J=TY.useRef(Z);return U9(()=>{J.current=Z}),TY.useCallback((...$)=>J.current(...$),[])}function sc({emojiVersion:Z,emojibaseUrl:J}){let[$,X]=b1.useState(void 0),Q=N2(),Y=l9(Q,"locale"),G=l9(Q,"columns"),H=l9(Q,"skinTone"),z=l9(Q,"search");return b1.useEffect(()=>{let W=new AbortController,V=W.signal;return jc({locale:Y,emojiVersion:Z,emojibaseUrl:J,signal:V}).then((K)=>{X(K)}).catch((K)=>{V.aborted||console.error(K)}),()=>{W.abort()}},[Z,J,Y]),b1.useEffect(()=>{if($)return rc(()=>{Q.get().onDataChange(Sc($,G,H,z))},{timeout:100})},[$,G,H,z]),null}var dj=b1.forwardRef(({locale:Z="en",columns:J=9,skinTone:$="none",onEmojiSelect:X=ic,emojiVersion:Q,emojibaseUrl:Y,onFocusCapture:G,onBlurCapture:H,children:z,style:W,sticky:V=!0,...K},U)=>{let q=ac(X),B=Ic(()=>Rc(q,Tj(Z),J,V,Cj($))),[F,N]=b1.useState(!1),L=b1.useRef(null),M=b1.useCallback((D)=>{D&&(L.current=D,B.set({rootRef:L}))},[]);U9(()=>{B.set({locale:Tj(Z)})},[Z]),U9(()=>{B.set({columns:J})},[J]),U9(()=>{B.set({sticky:V})},[V]),U9(()=>{B.set({skinTone:Cj($)})},[$]);let A=b1.useCallback((D)=>{G?.(D);let{searchRef:_,viewportRef:T}=B.get(),C=D.target===_?.current||D.target.hasAttribute("frimousse-search"),y=D.target===T?.current||D.target.hasAttribute("frimousse-viewport");D.isDefaultPrevented()||(N(C||y),D.isDefaultPrevented()||(N(C||y),y?B.get().onActiveEmojiChange("keyboard",0,0):C&&B.get().search===""&&B.set({interaction:"none"})))},[G]),P=b1.useCallback((D)=>{H?.(D),!D.isDefaultPrevented()&&!D.currentTarget.contains(D.relatedTarget)&&N(!1)},[H]);return U9(()=>{F||B.get().onActiveEmojiReset()},[F]),b1.useImperativeHandle(U,()=>L.current),b1.useEffect(()=>{if(!F)return;function D(_){if(_.defaultPrevented||!_.key.startsWith("Arrow")&&_.key!=="Enter")return;let{data:T,onEmojiSelect:C,onActiveEmojiChange:y,interaction:j,activeColumnIndex:g,activeRowIndex:I}=B.get();if(_.key==="Enter"){let E=iK(B.get());E&&(_.preventDefault(),C(E))}if(_.key.startsWith("Arrow")){let E=g,S=I;if(_.preventDefault(),j!=="none"){if(T?.rows&&T.rows.length>0)switch(_.key){case"ArrowLeft":{if(E===0){let b=S-1,R=T.rows[b];R&&(S=b,E=R.emojis.length-1)}else E-=1;break}case"ArrowRight":{if(E===T.rows[S].emojis.length-1){let b=S+1;T.rows[b]&&(S=b,E=0)}else E+=1;break}case"ArrowUp":{let b=T.rows[S-1];b&&(S-=1,b.emojis[E]||(E=b.emojis.length-1));break}case"ArrowDown":{let b=T.rows[S+1];b&&(S+=1,b.emojis[E]||(E=b.emojis.length-1));break}}y("keyboard",E,S)}else y("keyboard",0,0)}}return document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[F]),U9(()=>{let D=null,_=null,T=null,C=null,y=B.subscribe((S)=>{L.current&&(D!==S.viewportWidth&&(D=S.viewportWidth,L.current.style.setProperty("--frimousse-viewport-width",`${S.viewportWidth}px`)),_!==S.viewportHeight&&(_=S.viewportHeight,L.current.style.setProperty("--frimousse-viewport-height",`${S.viewportHeight}px`)),T!==S.rowHeight&&(T=S.rowHeight,L.current.style.setProperty("--frimousse-row-height",`${S.rowHeight}px`)),C!==S.categoryHeaderHeight&&(C=S.categoryHeaderHeight,L.current.style.setProperty("--frimousse-category-header-height",`${S.categoryHeaderHeight}px`)))}),{viewportWidth:j,viewportHeight:g,rowHeight:I,categoryHeaderHeight:E}=B.get();return j&&L.current.style.setProperty("--frimousse-viewport-width",`${j}px`),g&&L.current.style.setProperty("--frimousse-viewport-height",`${g}px`),I&&L.current.style.setProperty("--frimousse-row-height",`${I}px`),E&&L.current.style.setProperty("--frimousse-category-header-height",`${E}px`),y},[]),X0.jsx("div",{"data-focused":F?"":void 0,"frimousse-root":"",onBlurCapture:P,onFocusCapture:A,...K,ref:M,style:{"--frimousse-emoji-font":yj,...W},children:X0.jsxs(yc,{store:B,children:[X0.jsx(sc,{emojiVersion:Q,emojibaseUrl:Y}),z]})})}),lj=b1.forwardRef(({value:Z,defaultValue:J,onChange:$,...X},Q)=>{let Y=N2(),G=b1.useRef(null),H=b1.useCallback((K)=>{K&&(G.current=K,Y.set({searchRef:G}))},[]),z=typeof Z=="string",W=b1.useRef(z);b1.useEffect(()=>{W.current=z},[z]),U9(()=>{Y.set({search:typeof Z=="string"?Z:typeof J=="string"?J:""})},[]),U9(()=>{typeof Z=="string"&&Y.get().onSearchChange(Z)},[Z]);let V=b1.useCallback((K)=>{$?.(K),K.isDefaultPrevented()||Y.get().onSearchChange(K.target.value)},[$]);return b1.useImperativeHandle(Q,()=>G.current),X0.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...X,defaultValue:J,onChange:V,ref:H,value:Z})}),nc=b1.memo(()=>{let Z=uj();return Z?X0.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:Z.label}):null}),ij=b1.forwardRef(({children:Z,onScroll:J,onKeyDown:$,style:X,...Q},Y)=>{let G=N2(),H=b1.useRef(null),z=b1.useCallback((U)=>{U&&(H.current=U,G.set({viewportRef:H}))},[]),W=C2(G,fj),V=C2(G,vc),K=b1.useCallback((U)=>{J?.(U),G.get().onViewportScroll(U.currentTarget.scrollTop)},[J]);return U9(()=>{if(!H.current)return;let U=new ResizeObserver(([q])=>{let B=q?.borderBoxSize[0]?.inlineSize??0,F=q?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:N,viewportHeight:L,viewportWidth:M}=G.get();(L!==F||M!==B)&&N(B,F)});return U.observe(H.current),G.get().onViewportSizeChange(H.current.offsetWidth,H.current.clientHeight),()=>{U.disconnect()}},[]),b1.useImperativeHandle(Y,()=>H.current),X0.jsxs("div",{"frimousse-viewport":"",...Q,onScroll:K,ref:z,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof W=="number"&&typeof V=="number"?`var(--frimousse-viewport-width, auto) calc(${W} * var(--frimousse-row-height) + ${V} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...X},children:[X0.jsx(nc,{}),Z]})});function rj(Z,J,$){return{emoji:{...Z,isActive:$},role:"gridcell","aria-colindex":J,"aria-selected":$||void 0,"aria-label":Z.label,"data-active":$?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function aj(Z,J=!1){return{role:J?void 0:"row","aria-rowindex":J?void 0:Z,"frimousse-row":"",style:{contain:J?void 0:"content",height:J?void 0:"var(--frimousse-row-height)",display:"flex"}}}function sj(Z,J){return{"frimousse-category":"",style:{contain:"content",top:J?`calc(${Z} * var(--frimousse-category-header-height) + ${J.startRowIndex} * var(--frimousse-row-height))`:void 0,height:J?`calc(var(--frimousse-category-header-height) + ${J.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function nj(Z,J=!1,$=!0){return{category:Z,"frimousse-category-header":"",style:{contain:J?void 0:"layout paint",height:J?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:$?"sticky":void 0,top:0}}}function Ij(Z,J,$,X){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${Z} * var(--frimousse-row-height) + ${J} * var(--frimousse-category-header-height))`,paddingTop:`calc(${$} * var(--frimousse-row-height) + ${X} * var(--frimousse-category-header-height))`}}}function kj(Z,J,$){return{"aria-colcount":Z,"aria-rowcount":J,"frimousse-list":"",style:{"--frimousse-list-columns":Z,...$},role:"grid"}}function oc(Z){Z.preventDefault()}var tc=b1.memo(({Emoji:Z,emoji:J,columnIndex:$,rowIndex:X})=>{let Q=N2(),Y=C2(Q,(W)=>iK(W)?.emoji===J.emoji),G=b1.useCallback(()=>{Q.get().onEmojiSelect(J)},[J]),H=b1.useCallback(()=>{Q.get().onActiveEmojiChange("pointer",$,X)},[$,X]),z=b1.useCallback(()=>{Q.get().onActiveEmojiReset()},[]);return X0.jsx(Z,{...rj(J,$,Y),onClick:G,onPointerDown:oc,onPointerEnter:H,onPointerLeave:z})}),ec=b1.memo(({Row:Z,Emoji:J,rowIndex:$})=>{let X=N2(),Q=C2(X,(Y)=>Y.data?.rows[$],fc);return Q?X0.jsx(Z,{...aj($),children:Q.emojis.map((Y,G)=>X0.jsx(tc,{Emoji:J,columnIndex:G,emoji:Y,rowIndex:$},Y.label))}):null}),Zd=b1.memo(({CategoryHeader:Z,categoryIndex:J})=>{let $=N2(),X=C2($,(Y)=>Y.data?.categories[J],rK),Q=l9($,"sticky");return X?X0.jsx("div",{...sj(J,X),children:X0.jsx(Z,{...nj({label:X.label},!1,Q)})}):null}),Rj=b1.memo(({CategoryHeader:Z,Row:J,Emoji:$})=>{let X=b1.useRef(null),Q=N2(),Y=l9(Q,"columns"),G=b1.useMemo(()=>Array(Y).fill({emoji:"\uD83D\uDE42",label:""}),[Y]),H=b1.useMemo(()=>({label:"Category"}),[]),z=b1.useRef(null),W=b1.useRef(null);return U9(()=>{let V=X.current?.parentElement?.parentElement;if(!V||!z.current||!W.current)return;let K=new ResizeObserver((B)=>{for(let F of B){let N=F.contentRect.height,{onRowHeightChange:L,onCategoryHeaderHeightChange:M,rowHeight:A,categoryHeaderHeight:P}=Q.get();F.target===z.current&&A!==N&&L(N),F.target===W.current&&P!==N&&M(N)}});K.observe(V),K.observe(z.current),K.observe(W.current);let{onRowHeightChange:U,onCategoryHeaderHeightChange:q}=Q.get();return U(z.current.clientHeight),q(W.current.clientHeight),()=>{K.disconnect()}},[]),X0.jsxs("div",{"aria-hidden":!0,ref:X,style:{height:0,visibility:"hidden"},children:[X0.jsx("div",{"frimousse-row-sizer":"",ref:z,children:X0.jsx(J,{...aj(-1,!0),children:G.map((V,K)=>X0.jsx($,{...rj(V,K,!1)},K))})}),X0.jsx("div",{...sj(-1),children:X0.jsx("div",{"frimousse-category-header-sizer":"",ref:W,children:X0.jsx(Z,{...nj(H,!0)})})})]})});function Jd({category:Z,...J}){return X0.jsx("div",{...J,children:Z.label})}function $d({emoji:Z,...J}){return X0.jsx("button",{type:"button",...J,children:Z.emoji})}function Xd({...Z}){return X0.jsx("div",{...Z})}var oj=b1.forwardRef(({style:Z,components:J,...$},X)=>{let Q=N2(),Y=b1.useRef(null),G=b1.useCallback((L)=>{L&&(Y.current=L,Q.set({listRef:Y}))},[]),H=J?.CategoryHeader??Jd,z=J?.Emoji??$d,W=J?.Row??Xd,V=l9(Q,"columns"),K=l9(Q,"viewportStartRowIndex"),U=l9(Q,"viewportEndRowIndex"),q=C2(Q,fj),B=C2(Q,gc,rK),F=b1.useMemo(()=>B?.filter((L)=>L<K).length??0,[B,K]),N=B?.length??0;return b1.useImperativeHandle(X,()=>Y.current),!q||!B||N===0?X0.jsx("div",{...kj(V,0,Z),...$,children:X0.jsx("div",{...Ij(0,0,0,0),children:X0.jsx(Rj,{CategoryHeader:H,Emoji:z,Row:W})})}):X0.jsx("div",{...kj(V,q,Z),...$,ref:G,children:X0.jsxs("div",{...Ij(q,N,K,F),children:[X0.jsx(Rj,{CategoryHeader:H,Emoji:z,Row:W}),Array.from({length:U-K+1},(L,M)=>{let A=K+M,P=B.indexOf(A);return X0.jsxs(b1.Fragment,{children:[P>=0&&X0.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),X0.jsx(ec,{Emoji:z,Row:W,rowIndex:A})]},A)}),Array.from({length:N},(L,M)=>X0.jsx(Zd,{CategoryHeader:H,categoryIndex:M},M))]})})}),tj=b1.forwardRef(({emoji:Z,onClick:J,"aria-label":$="Change skin tone",...X},Q)=>{let Y=N2(),G=C2(Y,mc,rK),[H,z,W]=cj(Z),V=b1.useMemo(()=>Math.max(0,W.findIndex((N)=>N.skinTone===H)),[H,W]),K=W[V],U=W[(V+1)%W.length].skinTone,q=H==="none"?void 0:G?.[H],B=U==="none"?void 0:G?.[U],F=b1.useCallback((N)=>{J?.(N),N.isDefaultPrevented()||z(U)},[J,z,U]);return X0.jsx("button",{type:"button",...X,"aria-label":$+(B?` (${B})`:""),"aria-live":"polite","aria-valuetext":q,"frimousse-skin-tone-selector":"",onClick:F,ref:Q,children:K.emoji})});function ej({children:Z,...J}){let $=N2();return C2($,hc)?X0.jsx("span",{"frimousse-loading":"",...J,children:Z}):null}function Qd({children:Z}){let J=N2(),$=C2(J,bc);return Z({search:$})}function ZT({children:Z,...J}){let $=N2();return C2($,xc)?X0.jsx("span",{"frimousse-empty":"",...J,children:typeof Z=="function"?X0.jsx(Qd,{children:Z}):Z}):null}function JT({children:Z}){let J=uj();return Z({emoji:J})}function $T({children:Z,emoji:J}){let[$,X,Q]=cj(J);return Z({skinTone:$,setSkinTone:X,skinToneVariations:Q})}dj.displayName="EmojiPicker.Root";lj.displayName="EmojiPicker.Search";ij.displayName="EmojiPicker.Viewport";oj.displayName="EmojiPicker.List";ej.displayName="EmojiPicker.Loading";ZT.displayName="EmojiPicker.Empty";tj.displayName="EmojiPicker.SkinToneSelector";JT.displayName="EmojiPicker.ActiveEmoji";$T.displayName="EmojiPicker.SkinTone";var ZJ=[{id:"rocket",Icon:lT},{id:"sparkles",Icon:sT},{id:"bolt",Icon:HT},{id:"flame",Icon:TT},{id:"star",Icon:nT},{id:"heart",Icon:kT},{id:"diamond",Icon:wT},{id:"trophy",Icon:JC},{id:"target",Icon:tT},{id:"bulb",Icon:qT},{id:"brain",Icon:WT},{id:"robot",Icon:dT},{id:"wand",Icon:XC},{id:"atom",Icon:YT},{id:"flask",Icon:CT},{id:"cpu",Icon:AT},{id:"code",Icon:_T},{id:"terminal",Icon:eT},{id:"api",Icon:QT},{id:"database",Icon:PT},{id:"cube",Icon:DT},{id:"hexagon",Icon:RT},{id:"plug",Icon:cT},{id:"tool",Icon:ZC},{id:"settings",Icon:eZ},{id:"bug",Icon:VT},{id:"activity",Icon:XT},{id:"chart",Icon:FT},{id:"briefcase",Icon:KT},{id:"folder",Icon:ST},{id:"file",Icon:q8},{id:"book",Icon:zT},{id:"message",Icon:vT},{id:"mail",Icon:xT},{id:"bell",Icon:GT},{id:"paperclip",Icon:$Q},{id:"key",Icon:CY},{id:"shield",Icon:iT},{id:"user",Icon:$C},{id:"home",Icon:yT},{id:"globe",Icon:IT},{id:"world",Icon:QC},{id:"planet",Icon:uT},{id:"compass",Icon:MT},{id:"map",Icon:hT},{id:"calendar",Icon:UT},{id:"cloud",Icon:NT},{id:"sun",Icon:oT},{id:"moon",Icon:gT},{id:"snowflake",Icon:aT},{id:"leaf",Icon:bT},{id:"mountain",Icon:mT},{id:"feather",Icon:jT},{id:"ghost",Icon:Y6},{id:"music",Icon:fT},{id:"camera",Icon:BT},{id:"photo",Icon:pT},{id:"palette",Icon:SY},{id:"gamepad",Icon:OT},{id:"gift",Icon:ET},{id:"cart",Icon:rT},{id:"chef",Icon:LT}],YC=ZJ.map((Z)=>Z.id),Yd=new Map(ZJ.map((Z)=>[Z.id,Z.Icon]));function EY(Z){return Z?Yd.get(Z)??null:null}var sK=[{id:"sunrise",gradient:{angle:140,stops:["#FFE29F","#FFA99F","#FF719A"]}},{id:"ocean",gradient:{angle:135,stops:["#67E8F9","#3B82F6","#4F46E5"]}},{id:"meadow",gradient:{angle:135,stops:["#A7F3D0","#34D399","#059669"]}},{id:"dusk",gradient:{angle:120,stops:["#C471F5","#FA71CD"]}},{id:"midnight",gradient:{angle:135,stops:["#30CFD0","#330867"]}}];function aK(Z,J,$){let X=$*Math.PI/180,Q=J*Math.cos(X),Y=J*Math.sin(X),G=(Z+0.3963377774*Q+0.2158037573*Y)**3,H=(Z-0.1055613458*Q-0.0638541728*Y)**3,z=(Z-0.0894841775*Q-1.291485548*Y)**3;return`#${[4.0767416621*G-3.3077115913*H+0.2309699292*z,-1.2684380046*G+2.6097574011*H-0.3413193965*z,-0.0041960863*G-0.7034186147*H+1.707614701*z].map((V)=>{let K=Math.min(1,Math.max(0,V)),U=K<=0.0031308?12.92*K:1.055*K**0.4166666666666667-0.055;return Math.round(U*255).toString(16).padStart(2,"0")}).join("")}`}function GC(){let Z=Math.random()*360,J=(35+Math.random()*55)*(Math.random()<0.5?-1:1),$=Math.round(115+Math.random()*55),X=aK(0.83+Math.random()*0.06,0.09+Math.random()*0.06,Z),Q=aK(0.5+Math.random()*0.14,0.17+Math.random()*0.07,Z+J);if(Math.random()<0.4){let Y=aK(0.7+Math.random()*0.05,0.15,Z+J/2);return{angle:$,stops:[X,Y,Q]}}return{angle:$,stops:[X,Q]}}var Gd="radial-gradient(120% 100% at 28% 12%, rgba(255,255,255,0.32), rgba(255,255,255,0) 58%)";function IY(Z){return`${Gd}, linear-gradient(${Z.angle}deg, ${Z.stops.join(", ")})`}var D5=256;function HC(Z,J){let $=J.angle*Math.PI/180,X=Math.sin($),Q=-Math.cos($),Y=D5*(Math.abs(X)+Math.abs(Q))/2,G=D5/2,H=Z.createLinearGradient(G-X*Y,G-Q*Y,G+X*Y,G+Q*Y),z=J.stops.length-1;J.stops.forEach((V,K)=>H.addColorStop(z===0?0:K/z,V)),Z.fillStyle=H,Z.fillRect(0,0,D5,D5);let W=Z.createRadialGradient(D5*0.28,D5*0.12,0,D5*0.28,D5*0.12,D5*1.1);W.addColorStop(0,"rgba(255,255,255,0.32)"),W.addColorStop(0.58,"rgba(255,255,255,0)"),Z.fillStyle=W,Z.fillRect(0,0,D5,D5)}function zC(Z){return new Promise((J,$)=>{Z.toBlob((X)=>X?J(X):$(Error("Canvas is empty")),"image/png")})}function WC(){let Z=document.createElement("canvas");Z.width=D5,Z.height=D5;let J=Z.getContext("2d");if(!J)throw Error("2D canvas unavailable");return[Z,J]}var Hd=0.92,zd=0.68;async function KC(Z,J){let[$,X]=WC();if(J)HC(X,J);X.textAlign="center",X.textBaseline="middle";let Q=J?zd:Hd;return X.font=`${Math.round(D5*Q)}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`,X.fillText(Z,D5/2,D5/2+D5*0.04),zC($)}function Wd(Z){return new Promise((J,$)=>{let X=new Image;X.onload=()=>J(X),X.onerror=()=>$(Error("Failed to load SVG")),X.src=Z})}var Kd=0.78,Vd=0.6;async function VC(Z,J){let[$,X]=WC();if(J)HC(X,J);let Q=J?"#ffffff":"#18181b",Y=Z.replace(/currentColor/g,Q),G=await Wd(`data:image/svg+xml;utf8,${encodeURIComponent(Y)}`),H=D5*(J?Vd:Kd),z=(D5-H)/2;return X.drawImage(G,z,z,H,H),zC($)}var qC=["\uD83D\uDE80","✨","\uD83D\uDD25","⚡","\uD83D\uDCA1","\uD83E\uDDE0","\uD83E\uDD16","\uD83E\uDE84","\uD83E\uDDEA","⚙️","\uD83D\uDEE0️","\uD83D\uDCBB","\uD83D\uDCE6","\uD83D\uDCCA","\uD83D\uDCC8","\uD83D\uDCDD","\uD83D\uDCDA","\uD83C\uDFAF","\uD83C\uDFC6","\uD83D\uDC8E","\uD83E\uDE90","\uD83C\uDF0D","\uD83E\uDDED","\uD83C\uDFA8","\uD83C\uDFAE","☕"],kY="font-[Apple_Color_Emoji,Segoe_UI_Emoji,Noto_Color_Emoji,sans-serif]";var m1=w(a(),1);function qd({category:Z,...J}){return m1.jsx("div",{className:"bg-background px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",...J,children:Z.label})}function Ud({children:Z,...J}){return m1.jsx("div",{className:"scroll-my-1 px-1.5",...J,children:Z})}function Bd({emoji:Z,...J}){return m1.jsx("button",{className:N1("flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75 data-[active]:bg-muted",kY),...J,children:Z.emoji})}function NC({icon:Z}){let{workspaceId:J,provider:$}=w0(),{isPending:X,mutateAsync:Q}=Uj(J),{isPending:Y,mutate:G}=Bj(J),[H,z]=u5.useState("emoji"),[W,V]=u5.useState({id:"sunrise",gradient:sK[0].gradient}),[K,U]=u5.useState(null),[q,B]=u5.useState(null),[F,N]=u5.useState(""),[L,M]=u5.useState(null),[A,P]=u5.useState(null),[D,_]=u5.useState(!1),[T,C]=u5.useState(null),y=u5.useRef(null),j=u5.useRef(null),g=u5.useRef(null),I=ZJ.find((O)=>O.id===L),E=W.gradient!==null,S=X||Y,b=()=>{let O=GC();U(O),V({id:"shuffle",gradient:O})},R=(O)=>{C(null),g.current=O,z("upload"),P(URL.createObjectURL(O))};u5.useEffect(()=>{let O=!1,K1=async()=>{let k;if(H==="upload"){if(!g.current)return;k=g.current}else if(H==="emoji"){if(!q)return;k=await KC(q,W.gradient)}else{let e=j.current?.querySelector("svg");if(!e)return;k=await VC(new XMLSerializer().serializeToString(e),W.gradient)}if(!O)await Q(k)};C(null);let Z1=window.setTimeout(()=>{K1().catch((k)=>{if(!O)C(k instanceof Error?k.message:"Failed to save icon")})},150);return()=>{O=!0,window.clearTimeout(Z1)}},[W.gradient,q,H,Q,I,A]),u5.useEffect(()=>{return()=>{if(A)URL.revokeObjectURL(A)}},[A]);let x=()=>{g.current=null,B(null),M(null),P(null),C(null),G()},h=H==="emoji"&&q?"emoji":H==="icon"&&I?"glyph":"image",d=H==="upload"&&A?A:Z??$9[$??"claude-code"];return m1.jsxs("div",{className:"flex gap-6",children:[m1.jsxs("div",{className:"flex w-24 shrink-0 flex-col items-center gap-2.5",children:[m1.jsx("div",{className:N1("flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-border",h!=="image"&&!E&&"bg-[repeating-conic-gradient(#0000000d_0%_25%,transparent_0%_50%)] bg-[length:16px_16px]"),style:h!=="image"&&W.gradient?{background:IY(W.gradient)}:void 0,children:h==="emoji"?m1.jsx("span",{className:N1("leading-none",kY,E?"text-[64px]":"text-[86px]"),children:q}):h==="glyph"&&I?m1.jsx(I.Icon,{stroke:1.5,className:N1(E?"size-14 text-white":"size-18 text-foreground")}):m1.jsx("img",{src:d,alt:"",className:"size-full object-cover"})}),m1.jsx("button",{type:"button",onClick:x,disabled:S,className:"text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Reset to default"})]}),m1.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[m1.jsx("div",{className:"flex gap-1 self-start rounded-lg bg-muted p-0.5",children:["emoji","icon","upload"].map((O)=>m1.jsx("button",{type:"button",onClick:()=>z(O),className:N1("rounded-md px-3.5 py-1 text-xs font-medium capitalize transition-colors",H===O?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:O},O))}),m1.jsxs("div",{className:N1("flex items-center gap-2",H==="upload"&&"pointer-events-none opacity-35"),children:[m1.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Background"}),m1.jsxs("div",{className:"flex items-center gap-2",children:[m1.jsx("button",{type:"button","aria-label":"No background",onClick:()=>V({id:"none",gradient:null}),className:N1("flex size-7 items-center justify-center rounded-full bg-muted ring-offset-2 ring-offset-card transition-shadow",W.id==="none"?"ring-2 ring-primary":"ring-1 ring-border hover:ring-muted-foreground/30"),children:m1.jsx(BC,{size:16,stroke:1.75,className:"text-muted-foreground"})}),sK.map((O)=>m1.jsx("button",{type:"button","aria-label":`${O.id} background`,onClick:()=>V({id:O.id,gradient:O.gradient}),style:{background:IY(O.gradient)},className:N1("size-7 rounded-full ring-offset-2 ring-offset-card transition-shadow",W.id===O.id?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30")},O.id)),m1.jsx("button",{type:"button","aria-label":"Random background",title:"Surprise me",onClick:b,style:K?{background:IY(K)}:void 0,className:N1("flex size-7 items-center justify-center rounded-full ring-offset-2 ring-offset-card transition-shadow",K?"text-white":"bg-muted text-muted-foreground ring-1 ring-border",W.id==="shuffle"?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30"),children:m1.jsx(UC,{size:16,stroke:1.75})})]})]}),H==="emoji"?m1.jsxs(q7.Root,{onEmojiSelect:(O)=>B(O.emoji),emojibaseUrl:"/vendor/emojibase",columns:13,className:"isolate flex h-72 flex-col overflow-hidden rounded-lg border border-border bg-background",children:[m1.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 pb-0",children:[m1.jsx(q7.Search,{placeholder:"Search emoji…",onChange:(O)=>N(O.target.value),className:"h-8 min-w-0 flex-1 appearance-none rounded-md bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"}),m1.jsx(q7.SkinToneSelector,{className:"size-8 shrink-0 rounded-md text-lg hover:bg-accent"})]}),m1.jsxs(q7.Viewport,{className:"relative scrollbar-thin flex-1 overflow-y-auto outline-none",children:[m1.jsxs(q7.Loading,{className:"absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[m1.jsx(Y2,{size:16,stroke:1.75,className:"animate-spin"}),"Loading emoji…"]}),F.trim()===""&&m1.jsxs("div",{className:"border-b border-dashed border-border pb-1.5",children:[m1.jsx("p",{className:"px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",children:"Favorites"}),m1.jsx("div",{className:"grid grid-cols-13 justify-items-start px-1.5",children:qC.map((O)=>m1.jsx("button",{type:"button",onClick:()=>B(O),className:N1("flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75",kY,q===O?"bg-primary/10":"hover:bg-accent"),children:O},O))})]}),m1.jsxs(q7.Empty,{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 text-xs text-muted-foreground",children:[m1.jsx(FC,{size:20,stroke:1.5}),"No emoji found"]}),m1.jsx(q7.List,{className:"pb-1.5 select-none",components:{CategoryHeader:qd,Row:Ud,Emoji:Bd}})]})]}):H==="icon"?m1.jsx("div",{className:"grid scrollbar-thin h-72 grid-cols-[repeat(auto-fill,minmax(2.25rem,1fr))] content-start gap-1 overflow-y-auto rounded-lg border border-border bg-background p-1.5",children:ZJ.map(({id:O,Icon:K1})=>m1.jsx("button",{type:"button","aria-label":O,onClick:()=>M(O),className:N1("flex aspect-square items-center justify-center rounded-lg text-muted-foreground transition-colors [&_svg]:size-5",L===O?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:m1.jsx(K1,{stroke:1.5})},O))}):m1.jsxs("button",{type:"button",onClick:()=>y.current?.click(),onDragOver:(O)=>{O.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:(O)=>{O.preventDefault(),_(!1);let K1=O.dataTransfer.files?.[0];if(K1)R(K1)},className:N1("flex h-72 flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors",D?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[m1.jsx(LC,{size:24,stroke:1.5}),m1.jsx("span",{className:"text-xs font-medium",children:"Click or drop an image"}),m1.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"PNG, JPG, GIF, or WebP"})]}),m1.jsx("div",{className:"min-h-4","aria-live":"polite",children:T?m1.jsx("p",{className:"text-xs text-destructive",children:T}):S?m1.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving…"}):null})]}),m1.jsx("input",{ref:y,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:(O)=>{let K1=O.target.files?.[0];if(K1)R(K1);O.target.value=""}}),m1.jsx("span",{ref:j,"aria-hidden":!0,className:"hidden",children:I&&m1.jsx(I.Icon,{stroke:1.5})})]})}var I5=w(a(),1);function MC(){let{name:Z,icon:J,cwd:$,workspaceId:X}=w0(),[,Q]=y9(),Y=qj(X),G=XB(),[H,z]=_C.useState(Z??"");return I5.jsxs(r8,{title:"General",description:"Basic details for this space.",children:[I5.jsxs(a8,{children:[I5.jsx(s8,{title:"Name",description:"Shown in the sidebar and the workspace header.",control:I5.jsx(y7,{value:H,onChange:(K)=>z(K.target.value),onBlur:()=>{let K=H.trim();if(K===(Z??""))return;Y.mutate(K===""?null:K)},onKeyDown:(K)=>{if(K.key==="Enter")K.currentTarget.blur()},placeholder:"Space name",className:"w-56"})}),I5.jsx(s8,{title:"Path",control:I5.jsx(y7,{value:$??"",readOnly:!0,"aria-label":"Workspace path",title:$??void 0,className:"w-56"})}),I5.jsxs("div",{className:"flex flex-col gap-4 px-3.5 py-3.5",children:[I5.jsxs("div",{className:"flex flex-col",children:[I5.jsx("span",{className:"text-sm font-medium",children:"Icon"}),I5.jsx("span",{className:"text-xs text-muted-foreground",children:"Pick an emoji or a glyph on a generated background, or upload an image."})]}),I5.jsx(NC,{icon:J})]})]}),I5.jsxs(a8,{label:"Danger zone",children:[I5.jsx(s8,{title:"Remove space",description:"Remove this space from moi. Its folder and sessions stay on disk.",control:I5.jsxs(E1,{type:"button",variant:"destructive",size:"sm",onClick:()=>{let U=`Remove "${Z??$??"this space"}" from your workspaces?
|
|
61
|
+
`)})}componentDidUpdate(Z){if(Z.resetKey!==this.props.resetKey&&this.state.error)this.setState({error:null})}render(){if(this.state.error)return v8.jsxs("div",{className:"flex h-full w-full flex-col items-start justify-start gap-1.5 p-4 text-xs",children:[v8.jsxs("div",{className:"flex items-center gap-1.5 font-semibold text-destructive",children:[v8.jsx(wO,{size:16,stroke:1.75}),"Widget crashed"]}),v8.jsx("div",{className:"font-mono break-words text-muted-foreground",children:this.state.error.message})]});return this.props.children}}var i8=w(m(),1);function hZ(Z,J,$,X){let Q=Z.reduce((Y,G)=>Math.max(Y,G.y+G.h),0);for(let Y=0;Y<=Q+$;Y++)for(let G=0;G<=X-J;G++)if(!Z.some((z)=>!(G+J<=z.x||z.x+z.w<=G||Y+$<=z.y||z.y+z.h<=Y)))return{x:G,y:Y};return{x:0,y:Q}}function vZ(Z,J=[],$=4){let X=[];for(let Q of Z){let{x:Y,y:G}=Q.x!==void 0&&Q.y!==void 0?{x:Q.x,y:Q.y}:hZ([...J,...X],Q.w,Q.h,$);X.push({i:Q.id,x:Y,y:G,w:Q.w,h:Q.h})}return X}var t7=w(a(),1);function TO({name:Z}){let J=v5(),$=hL(Z);return t7.jsxs(d9,{mode:"wait",initial:!1,children:[$.status==="ready"&&t7.jsx(n0.div,{className:"absolute inset-0",initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:{duration:0.45,ease:"easeInOut"},children:t7.jsx(xZ,{name:Z,kind:"widget",workspaceId:J,resetKey:$.version,children:t7.jsx(YY,{segment:"widgets",name:Z,version:$.version,children:t7.jsx($.Component,{})})})},$.version),$.status==="error"&&t7.jsx(n0.p,{className:"absolute inset-0 p-4 text-xs text-destructive",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0.45,ease:"easeInOut"},children:$.error},`err-${$.version}`)]})}var CO=w(a(),1);function g8({className:Z,...J}){return CO.jsx("div",{"data-slot":"skeleton",className:N1("animate-pulse rounded-md bg-muted",Z),...J})}var EO=w(m(),1);var e7=w(a(),1);function GY({editing:Z,hidden:J,onRemove:$,children:X}){return e7.jsxs(n0.div,{variants:{idle:{rotate:0},wiggle:{rotate:[0.5,-0.5],transition:{rotate:{repeat:1/0,repeatType:"reverse",duration:0.15,ease:"easeInOut"}}}},animate:Z?"wiggle":"idle",transition:{type:"spring",duration:0.35,bounce:0},className:"group/widget relative size-full",children:[e7.jsx("div",{"data-widget-chrome":!0,className:N1("dark absolute inset-0 overflow-hidden rounded-2xl [corner-shape:superellipse(1.2)]","shadow-[0_1px_2px_-1px_rgba(0,0,0,0.08),0_2px_4px_0_rgba(0,0,0,0.03)]","after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit]","after:content-[''] after:[corner-shape:inherit]","after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]","text-foreground",Z&&"pointer-events-none"),children:X}),Z&&$&&e7.jsx("div",{className:"absolute -top-2 -right-2 opacity-0 transition-opacity group-hover/widget:opacity-100",children:e7.jsx(E1,{size:"icon-sm",variant:"outline",className:"rounded-full",onClick:$,children:J?e7.jsx(a5,{stroke:1.75}):e7.jsx(SO,{stroke:1.75})})})]})}var m8=w(a(),1),_f={0:"col-start-1",1:"col-start-2",2:"col-start-3",3:"col-start-4"},Mf={0:"row-start-1",1:"row-start-2",2:"row-start-3",3:"row-start-4",4:"row-start-5",5:"row-start-6",6:"row-start-7",7:"row-start-8"},Af={1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"},Df={1:"row-span-1",2:"row-span-2",3:"row-span-3",4:"row-span-4"};function IO({items:Z,renderItem:J,onRestore:$,ref:X}){let Q=EO.useMemo(()=>vZ(Z),[Z]);return m8.jsx(XY,{ref:X,title:"Hidden",children:m8.jsx("div",{className:"grid [grid-auto-rows:160px] grid-cols-4 gap-2",children:m8.jsx(d9,{children:Q.map((Y)=>m8.jsx(n0.div,{layoutId:Y.i,className:N1(_f[Y.x],Mf[Y.y],Af[Y.w],Df[Y.h]),transition:{type:"spring",duration:0.35,bounce:0},children:m8.jsx(GY,{editing:!0,onRemove:()=>$(Y.i),hidden:!0,children:J(Y.i)})},Y.i))})})})}var oZ=w(m(),1);function J4(Z){let{margin:J,containerPadding:$,containerWidth:X,cols:Q}=Z;return(X-J[0]*(Q-1)-$[0]*2)/Q}function W9(Z,J,$){if(!Number.isFinite(Z))return Z;return Math.round(J*Z+Math.max(0,Z-1)*$)}function mZ(Z,J,$,X,Q,Y,G){let{margin:H,containerPadding:z,rowHeight:W}=Z,V=J4(Z),K,U,q,B;if(G)K=Math.round(G.width),U=Math.round(G.height);else K=W9(X,V,H[0]),U=W9(Q,W,H[1]);if(Y)q=Math.round(Y.top),B=Math.round(Y.left);else if(G)q=Math.round(G.top),B=Math.round(G.left);else q=Math.round((W+H[1])*$+z[1]),B=Math.round((V+H[0])*J+z[0]);if(!Y&&!G){if(Number.isFinite(X)){let N=Math.round((V+H[0])*(J+X)+z[0])-B-K;if(N!==H[0])K+=N-H[0]}if(Number.isFinite(Q)){let N=Math.round((W+H[1])*($+Q)+z[1])-q-U;if(N!==H[1])U+=N-H[1]}}return{top:q,left:B,width:K,height:U}}function RO(Z,J,$,X,Q){let{margin:Y,containerPadding:G,cols:H,rowHeight:z,maxRows:W}=Z,V=J4(Z),K=Math.round(($-G[0])/(V+Y[0])),U=Math.round((J-G[1])/(z+Y[1]));return K=gZ(K,0,H-X),U=gZ(U,0,W-Q),{x:K,y:U}}function fZ(Z,J,$){let{margin:X,containerPadding:Q,rowHeight:Y}=Z,G=J4(Z),H=Math.round(($-Q[0])/(G+X[0])),z=Math.round((J-Q[1])/(Y+X[1]));return{x:H,y:z}}function yO(Z,J,$){let{margin:X,rowHeight:Q}=Z,Y=J4(Z),G=Math.max(1,Math.round((J+X[0])/(Y+X[0]))),H=Math.max(1,Math.round(($+X[1])/(Q+X[1])));return{w:G,h:H}}function gZ(Z,J,$){return Math.max(Math.min(Z,$),J)}function zY(Z,J){if(Z.i===J.i)return!1;if(Z.x+Z.w<=J.x)return!1;if(Z.x>=J.x+J.w)return!1;if(Z.y+Z.h<=J.y)return!1;if(Z.y>=J.y+J.h)return!1;return!0}function $4(Z,J){for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0&&zY(X,J))return X}return}function XK(Z,J){return Z.filter(($)=>zY($,J))}function Pf(Z,J){if(J==="horizontal")return QK(Z);if(J==="vertical")return HY(Z);if(J==="wrap")return HY(Z);return[...Z]}function HY(Z){return[...Z].sort((J,$)=>{if(J.y!==$.y)return J.y-$.y;return J.x-$.x})}function QK(Z){return[...Z].sort((J,$)=>{if(J.x!==$.x)return J.x-$.x;return J.y-$.y})}function pZ(Z){let J=0;for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0){let Q=X.y+X.h;if(Q>J)J=Q}}return J}function X4(Z,J){for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0&&X.i===J)return X}return}function uZ(Z){return Z.filter((J)=>J.static===!0)}function W7(Z){return{i:Z.i,x:Z.x,y:Z.y,w:Z.w,h:Z.h,minW:Z.minW,maxW:Z.maxW,minH:Z.minH,maxH:Z.maxH,moved:Boolean(Z.moved),static:Boolean(Z.static),isDraggable:Z.isDraggable,isResizable:Z.isResizable,resizeHandles:Z.resizeHandles,constraints:Z.constraints,isBounded:Z.isBounded}}function f8(Z){let J=Array(Z.length);for(let $=0;$<Z.length;$++){let X=Z[$];if(X!==void 0)J[$]=W7(X)}return J}function Of(Z,J){let $=Array(Z.length);for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q!==void 0)if(J.i===Q.i)$[X]=J;else $[X]=Q}return $}function bO(Z,J,$){let X=X4(Z,J);if(!X)return[[...Z],null];return X=$(W7(X)),[Of(Z,X),X]}function YK(Z,J){let $=uZ(Z);for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q===void 0)continue;if(Q.x+Q.w>J.cols)Q.x=J.cols-Q.w;if(Q.x<0)Q.x=0,Q.w=J.cols;if(!Q.static)$.push(Q);else while($4($,Q))Q.y++}return Z}function Z4(Z,J,$,X,Q,Y,G,H,z){if(J.static&&J.isDraggable!==!0)return[...Z];if(J.y===X&&J.x===$)return[...Z];let{x:W,y:V}=J;if(typeof $==="number")J.x=$;if(typeof X==="number")J.y=X;J.moved=!0;let K=Pf(Z,G);if(G==="vertical"&&typeof X==="number"?V>=X:G==="horizontal"&&typeof $==="number"?W>=$:!1)K=K.reverse();let q=XK(K,J),B=q.length>0;if(B&&z)return f8(Z);if(B&&Y)return J.x=W,J.y=V,J.moved=!1,Z;let F=[...Z];for(let N=0;N<q.length;N++){let L=q[N];if(L===void 0)continue;if(L.moved)continue;if(L.static)F=kO(F,L,J,Q,G);else F=kO(F,J,L,Q,G)}return F}function kO(Z,J,$,X,Q,Y){let G=Q==="horizontal",H=Q==="vertical",z=J.static;if(X){X=!1;let K={x:G?Math.max(J.x-$.w,0):$.x,y:H?Math.max(J.y-$.h,0):$.y,w:$.w,h:$.h,i:"-1"},U=$4(Z,K),q=U!==void 0&&U.y+U.h>J.y,B=U!==void 0&&J.x+J.w>U.x;if(!U)return Z4(Z,$,G?K.x:void 0,H?K.y:void 0,X,z,Q);if(q&&H)return Z4(Z,$,void 0,$.y+1,X,z,Q);if(q&&Q===null)return J.y=$.y,$.y=$.y+$.h,[...Z];if(B&&G)return Z4(Z,J,$.x,void 0,X,z,Q)}let W=G?$.x+1:void 0,V=H?$.y+1:void 0;if(W===void 0&&V===void 0)return[...Z];return Z4(Z,$,W,V,X,z,Q)}function p8(Z,J,$){return Math.max(J,Math.min($,Z))}var wf={name:"gridBounds",constrainPosition(Z,J,$,{cols:X,maxRows:Q}){return{x:p8(J,0,Math.max(0,X-Z.w)),y:p8($,0,Math.max(0,Q-Z.h))}},constrainSize(Z,J,$,X,{cols:Q,maxRows:Y}){let G=X==="w"||X==="nw"||X==="sw"?Z.x+Z.w:Q-Z.x,H=X==="n"||X==="nw"||X==="ne"?Z.y+Z.h:Y-Z.y;return{w:p8(J,1,Math.max(1,G)),h:p8($,1,Math.max(1,H))}}},jf={name:"minMaxSize",constrainSize(Z,J,$){return{w:p8(J,Z.minW??1,Z.maxW??1/0),h:p8($,Z.minH??1,Z.maxH??1/0)}}};var GK=[wf,jf];function cZ(Z,J,$,X,Q){let Y={x:$,y:X};for(let G of Z)if(G.constrainPosition)Y=G.constrainPosition(J,Y.x,Y.y,Q);if(J.constraints){for(let G of J.constraints)if(G.constrainPosition)Y=G.constrainPosition(J,Y.x,Y.y,Q)}return Y}function xO(Z,J,$,X,Q,Y){let G={w:$,h:X};for(let H of Z)if(H.constrainSize)G=H.constrainSize(J,G.w,G.h,Q,Y);if(J.constraints){for(let H of J.constraints)if(H.constrainSize)G=H.constrainSize(J,G.w,G.h,Q,Y)}return G}function KY({top:Z,left:J,width:$,height:X}){let Q=`translate(${J}px,${Z}px)`;return{transform:Q,WebkitTransform:Q,MozTransform:Q,msTransform:Q,OTransform:Q,width:`${$}px`,height:`${X}px`,position:"absolute"}}function HK({top:Z,left:J,width:$,height:X}){return{top:`${Z}px`,left:`${J}px`,width:`${$}px`,height:`${X}px`,position:"absolute"}}function zK(Z){return Z*100+"%"}function Tf(Z,J,$,X){return Z+$>X?J:$}function hO(Z,J,$){return Z<0?J:$}function Cf(Z){return Math.max(0,Z)}function WY(Z){return Math.max(0,Z)}var WK=(Z,J,$)=>{let{left:X,height:Q,width:Y}=J,G=Z.top-(Q-Z.height);return{left:X,width:Y,height:hO(G,Z.height,Q),top:WY(G)}},KK=(Z,J,$)=>{let{top:X,left:Q,height:Y,width:G}=J;return{top:X,height:Y,width:Tf(Z.left,Z.width,G,$),left:Cf(Q)}},VK=(Z,J,$)=>{let{top:X,height:Q,width:Y}=J,G=Z.left+Z.width-Y;if(G<0)return{height:Q,width:Z.left+Z.width,top:WY(X),left:0};return{height:Q,width:Y,top:WY(X),left:G}},qK=(Z,J,$)=>{let{top:X,left:Q,height:Y,width:G}=J;return{width:G,left:Q,height:hO(X,Z.height,Y),top:WY(X)}},Sf=(Z,J,$)=>WK(Z,KK(Z,J,$)),Ef=(Z,J,$)=>WK(Z,VK(Z,J)),If=(Z,J,$)=>qK(Z,KK(Z,J,$)),kf=(Z,J,$)=>qK(Z,VK(Z,J)),Rf={n:WK,ne:Sf,e:KK,se:If,s:qK,sw:kf,w:VK,nw:Ef};function vO(Z,J,$,X){let Q=Rf[Z];if(!Q)return $;return Q(J,{...J,...$},X)}var yf={type:"transform",scale:1,calcStyle(Z){return KY(Z)}};var gO=yf,mO={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},fO={enabled:!0,bounded:!1,threshold:3},pO={enabled:!0,handles:["se"]},uO={enabled:!1,defaultItem:{w:1,h:1}};function UK(Z,J,$,X,Q){let Y=X==="x"?"w":"h";J[X]+=1;let G=Z.findIndex((z)=>z.i===J.i),H=Q??uZ(Z).length>0;for(let z=G+1;z<Z.length;z++){let W=Z[z];if(W===void 0)continue;if(W.static)continue;if(!H&&W.y>J.y+J.h)break;if(zY(J,W))UK(Z,W,$+J[Y],X,H)}J[X]=$}function bf(Z,J,$,X){J.x=Math.max(J.x,0),J.y=Math.max(J.y,0),J.y=Math.min(X,J.y);while(J.y>0&&!$4(Z,J))J.y--;let Q;while((Q=$4(Z,J))!==void 0)UK($,J,Q.y+Q.h,"y");return J.y=Math.max(J.y,0),J}function xf(Z,J,$,X){J.x=Math.max(J.x,0),J.y=Math.max(J.y,0);while(J.x>0&&!$4(Z,J))J.x--;let Q;while((Q=$4(Z,J))!==void 0)if(UK(X,J,Q.x+Q.w,"x"),J.x+J.w>$){J.x=$-J.w,J.y++;while(J.x>0&&!$4(Z,J))J.x--}return J.x=Math.max(J.x,0),J}var dZ={type:"vertical",allowOverlap:!1,compact(Z,J){let $=uZ(Z),X=pZ($),Q=HY(Z),Y=Array(Z.length);for(let G=0;G<Q.length;G++){let H=Q[G];if(H===void 0)continue;let z=W7(H);if(!z.static)z=bf($,z,Q,X),X=Math.max(X,z.y+z.h),$.push(z);let W=Z.indexOf(H);Y[W]=z,z.moved=!1}return Y}},BK={type:"horizontal",allowOverlap:!1,compact(Z,J){let $=uZ(Z),X=QK(Z),Q=Array(Z.length);for(let Y=0;Y<X.length;Y++){let G=X[Y];if(G===void 0)continue;let H=W7(G);if(!H.static)H=xf($,H,J,X),$.push(H);let z=Z.indexOf(G);Q[z]=H,H.moved=!1}return Q}},FK={type:null,allowOverlap:!1,compact(Z,J){return f8(Z)}},hf={...dZ,allowOverlap:!0,compact(Z,J){return f8(Z)}},vf={...BK,allowOverlap:!0,compact(Z,J){return f8(Z)}},gf={...FK,allowOverlap:!0};function LK(Z,J=!1,$=!1){let X;if(J)if(Z==="vertical")X=hf;else if(Z==="horizontal")X=vf;else X=gf;else if(Z==="vertical")X=dZ;else if(Z==="horizontal")X=BK;else X=FK;if($)return{...X,preventCollision:$};return X}var K9=w(m(),1);function NK(Z={}){let{measureBeforeMount:J=!1,initialWidth:$=1280}=Z,[X,Q]=K9.useState($),[Y,G]=K9.useState(!J),H=K9.useRef(null),z=K9.useRef(null),W=K9.useCallback(()=>{let V=H.current;if(V){let K=V.offsetWidth;if(Q(K),!Y)G(!0)}},[Y]);return K9.useEffect(()=>{let V=H.current;if(!V)return;if(W(),typeof ResizeObserver<"u"){let K=null;return z.current=new ResizeObserver((U)=>{let q=U[0];if(q){let B=q.contentRect.width;if(K!==null)cancelAnimationFrame(K);K=requestAnimationFrame(()=>{Q(B),K=null})}}),z.current.observe(V),()=>{if(K!==null)cancelAnimationFrame(K);if(z.current)z.current.disconnect(),z.current=null}}return()=>{if(z.current)z.current.disconnect(),z.current=null}},[W]),{width:X,mounted:Y,containerRef:H,measureWidth:W}}var P1=w(m(),1),fw=w(MY(),1),pw=w(vw(),1);var V7=w(a(),1),G6=w(dO(),1);function vK(Z){let{children:J,cols:$,containerWidth:X,margin:Q,containerPadding:Y,rowHeight:G,maxRows:H,isDraggable:z,isResizable:W,isBounded:V,static:K,useCSSTransforms:U=!0,usePercentages:q=!1,transformScale:B=1,positionStrategy:F,dragThreshold:N=0,droppingPosition:L,className:M="",style:A,handle:P="",cancel:D="",x:_,y:T,w:C,h:y,minW:j=1,maxW:g=1/0,minH:I=1,maxH:E=1/0,i:S,resizeHandles:b,resizeHandle:R,constraints:x=GK,layoutItem:h,layout:d=[],onDragStart:O,onDrag:K1,onDragStop:Z1,onResizeStart:k,onResize:e,onResizeStop:_1}=Z,[u,z1]=P1.useState(!1),[V1,$1]=P1.useState(!1),G1=P1.useRef(null),U1=P1.useRef({left:0,top:0}),f=P1.useRef({top:0,left:0,width:0,height:0}),o=P1.useRef(void 0),n=P1.useRef(d);n.current=d;let M1=P1.useRef(null),l=P1.useRef(null),W1=P1.useRef(!1),i=P1.useRef({x:0,y:0}),t=P1.useRef(!1),H1=P1.useMemo(()=>({cols:$,containerPadding:Y,containerWidth:X,margin:Q,maxRows:H,rowHeight:G}),[$,Y,X,Q,H,G]),r=P1.useMemo(()=>({cols:$,maxRows:H,containerWidth:X,containerHeight:0,rowHeight:G,margin:Q,layout:[]}),[$,H,X,G,Q]),c=P1.useCallback(()=>({...r,layout:n.current}),[r]),F1=P1.useMemo(()=>h??{i:S,x:_,y:T,w:C,h:y,minW:j,maxW:g,minH:I,maxH:E},[h,S,_,T,C,y,j,g,I,E]),I1=P1.useCallback((k1)=>{if(F?.calcStyle)return F.calcStyle(k1);if(U)return KY(k1);let v1=HK(k1);if(q)return{...v1,left:zK(k1.left/X),width:zK(k1.width/X)};return v1},[F,U,q,X]),f1=P1.useCallback((k1,{node:v1})=>{if(!O)return;let{offsetParent:s1}=v1;if(!s1)return;let n1=s1.getBoundingClientRect(),G0=v1.getBoundingClientRect(),V0=G0.left/B,T0=n1.left/B,v0=G0.top/B,Y0=n1.top/B,g0;if(F?.calcDragPosition){let u1=k1;g0=F.calcDragPosition(u1.clientX,u1.clientY,u1.clientX-G0.left,u1.clientY-G0.top)}else g0={left:V0-T0+s1.scrollLeft,top:v0-Y0+s1.scrollTop};if(U1.current=g0,N>0){let u1=k1;i.current={x:u1.clientX,y:u1.clientY},W1.current=!0,t.current=!1,z1(!0);return}z1(!0);let G5=fZ(H1,g0.top,g0.left),{x:V5,y:j1}=cZ(x,F1,G5.x,G5.y,c());O(S,V5,j1,{e:k1,node:v1,newPosition:g0})},[O,B,H1,F,N,x,F1,c,S]),v=P1.useCallback((k1,{node:v1,deltaX:s1,deltaY:n1})=>{if(!K1||!u)return;let G0=k1;if(W1.current&&!t.current){let V5=G0.clientX-i.current.x,j1=G0.clientY-i.current.y;if(Math.hypot(V5,j1)<N)return;if(t.current=!0,W1.current=!1,O){let S1=fZ(H1,U1.current.top,U1.current.left),{x:o1,y:z0}=cZ(x,F1,S1.x,S1.y,c());O(S,o1,z0,{e:k1,node:v1,newPosition:U1.current})}}let V0=U1.current.top+n1,T0=U1.current.left+s1;if(V){let{offsetParent:V5}=v1;if(V5){let j1=V5.clientHeight-W9(y,G,Q[1]);V0=gZ(V0,0,j1);let u1=J4(H1),S1=X-W9(C,u1,Q[0]);T0=gZ(T0,0,S1)}}let v0={top:V0,left:T0};U1.current=v0;let Y0=fZ(H1,V0,T0),{x:g0,y:G5}=cZ(x,F1,Y0.x,Y0.y,c());K1(S,g0,G5,{e:k1,node:v1,newPosition:v0})},[K1,O,u,N,V,y,G,Q,H1,X,C,S,x,F1,c]),p=P1.useCallback((k1,{node:v1})=>{if(!Z1||!u)return;let s1=W1.current;if(W1.current=!1,t.current=!1,i.current={x:0,y:0},s1){z1(!1),U1.current={left:0,top:0};return}let{left:n1,top:G0}=U1.current,V0={top:G0,left:n1};z1(!1),U1.current={left:0,top:0};let T0=fZ(H1,G0,n1),{x:v0,y:Y0}=cZ(x,F1,T0.x,T0.y,c());Z1(S,v0,Y0,{e:k1,node:v1,newPosition:V0})},[Z1,u,H1,x,F1,c,S]);M1.current=f1,l.current=v;let s=P1.useCallback((k1,{node:v1,size:s1,handle:n1},G0,V0)=>{let T0=V0==="onResizeStart"?k:V0==="onResize"?e:_1;if(!T0)return;let v0;if(v1)v0=vO(n1,G0,s1,X);else v0={...s1,top:G0.top,left:G0.left};f.current=v0;let Y0=yO(H1,v0.width,v0.height),{w:g0,h:G5}=xO(x,F1,Y0.w,Y0.h,n1,c());T0(S,g0,G5,{e:k1.nativeEvent,node:v1,size:v0,handle:n1})},[k,e,_1,X,H1,S,x,F1,c]),q1=P1.useCallback((k1,v1)=>{$1(!0);let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResizeStart")},[s,H1,_,T,C,y]),w1=P1.useCallback((k1,v1)=>{let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResize")},[s,H1,_,T,C,y]),h1=P1.useCallback((k1,v1)=>{$1(!1),f.current={top:0,left:0,width:0,height:0};let s1=mZ(H1,_,T,C,y),n1={...v1,handle:v1.handle};s(k1,n1,s1,"onResizeStop")},[s,H1,_,T,C,y]);P1.useEffect(()=>{if(!L)return;let k1=G1.current;if(!k1)return;let v1=o.current||{left:0,top:0},s1=u&&(L.left!==v1.left||L.top!==v1.top);if(!u){let n1={node:k1,deltaX:L.left,deltaY:L.top,lastX:0,lastY:0,x:L.left,y:L.top};M1.current?.(L.e,n1)}else if(s1){let n1=L.left-U1.current.left,G0=L.top-U1.current.top,V0={node:k1,deltaX:n1,deltaY:G0,lastX:U1.current.left,lastY:U1.current.top,x:L.left,y:L.top};l.current?.(L.e,V0)}o.current=L},[L,u,S]);let D0=mZ(H1,_,T,C,y,u?U1.current:null,V1?f.current:null),I0=P1.default.Children.only(J),g1=J4(H1),l1=[W9(j,g1,Q[0]),W9(I,G,Q[1])],e1=[W9(g,g1,Q[0]),W9(E,G,Q[1])],p1=I0.props,Q0=p1.className,W5=p1.style,k0=P1.default.cloneElement(I0,{ref:G1,className:gK("react-grid-item",Q0,M,{static:K,resizing:V1,"react-draggable":z,"react-draggable-dragging":u,dropping:Boolean(L),cssTransforms:U}),style:{...A,...W5,...I1(D0)}}),K5=R;return k0=V7.jsx(pw.Resizable,{draggableOpts:{disabled:!W},className:W?void 0:"react-resizable-hide",width:D0.width,height:D0.height,minConstraints:l1,maxConstraints:e1,onResizeStart:q1,onResize:w1,onResizeStop:h1,transformScale:B,resizeHandles:b,handle:K5,children:k0}),k0=V7.jsx(fw.DraggableCore,{disabled:!z,onStart:f1,onDrag:v,onStop:p,handle:P,cancel:".react-resizable-handle"+(D?","+D:""),scale:B,nodeRef:G1,children:k0}),k0}var K7=()=>{},gw="react-grid-layout",uw=!1;try{uw=/firefox/i.test(navigator.userAgent)}catch{}function tu(Z,J){let $=P1.default.Children.toArray(Z),X=P1.default.Children.toArray(J);if($.length!==X.length)return!1;for(let Q=0;Q<$.length;Q++){let Y=$[Q],G=X[Q];if(Y?.key!==G?.key)return!1}return!0}function mw(Z,J,$,X){let Q=[],Y=new Set;P1.default.Children.forEach(J,(H)=>{if(!P1.default.isValidElement(H)||H.key===null)return;let z=String(H.key);Y.add(z);let W=Z.find((V)=>V.i===z);if(W)Q.push(W7(W));else{let K=H.props["data-grid"];if(K)Q.push({i:z,x:K.x??0,y:K.y??0,w:K.w??1,h:K.h??1,minW:K.minW,maxW:K.maxW,minH:K.minH,maxH:K.maxH,static:K.static,isDraggable:K.isDraggable,isResizable:K.isResizable,resizeHandles:K.resizeHandles,isBounded:K.isBounded});else Q.push({i:z,x:0,y:pZ(Q),w:1,h:1})}});let G=YK(Q,{cols:$});return X.compact(G,$)}function nZ(Z){let{children:J,width:$,gridConfig:X,dragConfig:Q,resizeConfig:Y,dropConfig:G,positionStrategy:H=gO,compactor:z,constraints:W=GK,layout:V=[],droppingItem:K,autoSize:U=!0,className:q="",style:B={},innerRef:F,onLayoutChange:N=K7,onDragStart:L=K7,onDrag:M=K7,onDragStop:A=K7,onResizeStart:P=K7,onResize:D=K7,onResizeStop:_=K7,onDrop:T=K7,onDropDragOver:C=K7}=Z,y=P1.useMemo(()=>({...mO,...X}),[X]),j=P1.useMemo(()=>({...fO,...Q}),[Q]),g=P1.useMemo(()=>({...pO,...Y}),[Y]),I=P1.useMemo(()=>({...uO,...G}),[G]),{cols:E,rowHeight:S,maxRows:b,margin:R,containerPadding:x}=y,{enabled:h,bounded:d,handle:O,cancel:K1,threshold:Z1}=j,{enabled:k,handles:e,handleComponent:_1}=g,{enabled:u,defaultItem:z1,onDragOver:V1}=I,$1=z??LK("vertical"),G1=$1.type,U1=$1.allowOverlap,f=$1.preventCollision??!1,o=P1.useMemo(()=>K??{i:"__dropping-elem__",...z1},[K,z1]),n=H.type==="transform",M1=H.scale,l=x??R,[W1,i]=P1.useState(!1),[t,H1]=P1.useState(()=>mw(V,J,E,$1)),[r,c]=P1.useState(null),[F1,I1]=P1.useState(!1),[f1,v]=P1.useState(null),[p,s]=P1.useState(),q1=P1.useRef(null),w1=P1.useRef(null),h1=P1.useRef(null),D0=P1.useRef(0),I0=P1.useRef(t),g1=P1.useRef(V),l1=P1.useRef(J),e1=P1.useRef(G1),p1=P1.useRef(t);p1.current=t,P1.useEffect(()=>{if(i(!0),!G6.deepEqual(t,V))N(t)},[]),P1.useEffect(()=>{if(r)return;if(f1)return;let j1=!G6.deepEqual(V,g1.current),u1=!tu(J,l1.current),S1=G1!==e1.current;if(j1||u1||S1){let z0=mw(j1?V:t,J,E,$1);if(!G6.deepEqual(z0,t))H1(z0)}g1.current=V,l1.current=J,e1.current=G1},[V,J,E,G1,$1,r,f1,t]),P1.useEffect(()=>{if(!r&&!G6.deepEqual(t,I0.current)){I0.current=t;let j1=t.filter((u1)=>u1.i!==o.i);N(j1)}},[t,r,N,o.i]);let Q0=P1.useMemo(()=>{if(!U)return;let j1=pZ(t),u1=l[1];return j1*S+(j1-1)*R[1]+u1*2+"px"},[U,t,S,R,l]),W5=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=X4(z0,j1);if(!q0)return;let m0={w:q0.w,h:q0.h,x:q0.x,y:q0.y,i:j1};q1.current=W7(q0),h1.current=z0,c(m0),L(z0,q0,q0,null,o1.e,o1.node)},[L]),k0=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=q1.current,m0=X4(z0,j1);if(!m0)return;let P5={w:m0.w,h:m0.h,x:m0.x,y:m0.y,i:j1},f0=Z4(z0,m0,u1,S1,!0,f,G1,E,U1);M(f0,q0,m0,P5,o1.e,o1.node),H1($1.compact(f0,E)),c(P5)},[f,G1,E,U1,$1,M]),K5=P1.useCallback((j1,u1,S1,o1)=>{if(!r)return;let z0=p1.current,q0=q1.current,m0=X4(z0,j1);if(!m0)return;let P5=Z4(z0,m0,u1,S1,!0,f,G1,E,U1),f0=$1.compact(P5,E);A(f0,q0,m0,null,o1.e,o1.node);let c5=h1.current;if(q1.current=null,h1.current=null,c(null),H1(f0),c5&&!G6.deepEqual(c5,f0))N(f0)},[r,f,G1,E,U1,$1,A,N]),k1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=X4(z0,j1);if(!q0)return;w1.current=W7(q0),h1.current=z0,I1(!0),P(z0,q0,q0,null,o1.e,o1.node)},[P]),v1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=w1.current,{handle:m0}=o1,P5=!1,f0,c5,[$J,i9]=bO(z0,j1,(i0)=>{if(f0=i0.x,c5=i0.y,["sw","w","nw","n","ne"].includes(m0)){if(["sw","nw","w"].includes(m0))f0=i0.x+(i0.w-u1),u1=i0.x!==f0&&f0<0?i0.w:u1,f0=f0<0?0:f0;if(["ne","n","nw"].includes(m0))c5=i0.y+(i0.h-S1),S1=i0.y!==c5&&c5<0?i0.h:S1,c5=c5<0?0:c5;P5=!0}if(f&&!U1){if(XK(z0,{...i0,w:u1,h:S1,x:f0??i0.x,y:c5??i0.y}).filter((QJ)=>QJ.i!==i0.i).length>0)c5=i0.y,S1=i0.h,f0=i0.x,u1=i0.w,P5=!1}return i0.w=u1,i0.h=S1,i0});if(!i9)return;let e8=$J;if(P5&&f0!==void 0&&c5!==void 0)e8=Z4($J,i9,f0,c5,!0,f,G1,E,U1);let XJ={w:i9.w,h:i9.h,x:i9.x,y:i9.y,i:j1,static:!0};D(e8,q0,i9,XJ,o1.e,o1.node),H1($1.compact(e8,E)),c(XJ)},[f,G1,E,U1,$1,D]),s1=P1.useCallback((j1,u1,S1,o1)=>{let z0=p1.current,q0=w1.current,m0=X4(z0,j1),P5=$1.compact(z0,E);_(P5,q0,m0??null,null,o1.e,o1.node);let f0=h1.current;if(w1.current=null,h1.current=null,c(null),I1(!1),H1(P5),f0&&!G6.deepEqual(f0,P5))N(P5)},[E,$1,_,N]),n1=P1.useCallback(()=>{let j1=p1.current;if(!j1.some((o1)=>o1.i===o.i)){v(null),c(null),s(void 0);return}let S1=$1.compact(j1.filter((o1)=>o1.i!==o.i),E);H1(S1),v(null),c(null),s(void 0)},[o.i,E,$1]),G0=P1.useCallback((j1)=>{if(j1.preventDefault(),j1.stopPropagation(),uw&&!j1.nativeEvent.target?.classList.contains(gw))return!1;let u1=V1?V1(j1.nativeEvent):C(j1);if(u1===!1){if(f1)n1();return!1}let{dragOffsetX:S1=0,dragOffsetY:o1=0,...z0}=u1??{},q0={...o,...z0},m0=j1.currentTarget.getBoundingClientRect(),P5={cols:E,margin:R,maxRows:b,rowHeight:S,containerWidth:$,containerPadding:l},f0=J4(P5),c5=W9(q0.w,f0,R[0]),$J=W9(q0.h,S,R[1]),i9=c5/2,e8=$J/2,XJ=j1.clientX-m0.left+S1-i9,i0=j1.clientY-m0.top+o1-e8,pY=Math.max(0,XJ),QJ=Math.max(0,i0),YJ={left:pY/M1,top:QJ/M1,e:j1.nativeEvent};if(!f1){let uY=RO(P5,QJ,pY,q0.w,q0.h);v(V7.jsx("div",{},q0.i)),s(YJ);let XS=p1.current.filter((QS)=>QS.i!==q0.i);H1([...XS,{...q0,x:uY.x,y:uY.y,static:!1,isDraggable:!0}])}else if(p){if(p.left!==YJ.left||p.top!==YJ.top)s(YJ)}},[f1,p,o,V1,C,n1,M1,E,R,b,S,$,l]),V0=P1.useCallback((j1)=>{if(j1.preventDefault(),j1.stopPropagation(),D0.current--,D0.current<0)D0.current=0;if(D0.current===0)n1()},[n1]),T0=P1.useCallback((j1)=>{j1.preventDefault(),j1.stopPropagation(),D0.current++},[]),v0=P1.useCallback((j1)=>{j1.preventDefault(),j1.stopPropagation();let u1=p1.current,S1=u1.find((o1)=>o1.i===o.i);D0.current=0,n1(),T(u1,S1,j1.nativeEvent)},[o.i,n1,T]),Y0=P1.useCallback((j1,u1)=>{if(!j1||!j1.key)return null;let S1=X4(t,String(j1.key));if(!S1)return null;let o1=typeof S1.isDraggable==="boolean"?S1.isDraggable:!S1.static&&h,z0=typeof S1.isResizable==="boolean"?S1.isResizable:!S1.static&&k,q0=S1.resizeHandles||[...e],m0=o1&&d&&S1.isBounded!==!1,P5=_1;return V7.jsx(vK,{containerWidth:$,cols:E,margin:R,containerPadding:l,maxRows:b,rowHeight:S,cancel:K1,handle:O,onDragStart:W5,onDrag:k0,onDragStop:K5,onResizeStart:k1,onResize:v1,onResizeStop:s1,isDraggable:o1,isResizable:z0,isBounded:m0,useCSSTransforms:n&&W1,usePercentages:!W1,transformScale:M1,positionStrategy:H,dragThreshold:Z1,w:S1.w,h:S1.h,x:S1.x,y:S1.y,i:S1.i,minH:S1.minH,minW:S1.minW,maxH:S1.maxH,maxW:S1.maxW,static:S1.static,droppingPosition:u1?p:void 0,resizeHandles:q0,resizeHandle:P5,constraints:W,layoutItem:S1,layout:t,children:j1},S1.i)},[t,$,E,R,l,b,S,K1,O,W5,k0,K5,k1,v1,s1,h,k,d,n,W1,M1,H,Z1,p,e,_1,W]),g0=()=>{if(!r)return null;return V7.jsx(vK,{w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,className:`react-grid-placeholder ${F1?"placeholder-resizing":""}`,containerWidth:$,cols:E,margin:R,containerPadding:l,maxRows:b,rowHeight:S,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:n,transformScale:M1,constraints:W,layout:t,children:V7.jsx("div",{})})},G5=gK(gw,q),V5={height:Q0,...B};return V7.jsxs("div",{ref:F,className:G5,style:V5,onDrop:u?v0:void 0,onDragLeave:u?V0:void 0,onDragEnter:u?T0:void 0,onDragOver:u?G0:void 0,children:[P1.default.Children.map(J,(j1)=>{if(!P1.default.isValidElement(j1))return null;return Y0(j1)}),u&&f1&&Y0(f1,!0),g0()]})}var H6=w(a(),1);function mK({items:Z,editing:J,renderItem:$,onLayoutChange:X}){let[Q,Y]=oZ.useState(()=>vZ(Z,[])),[G,H]=oZ.useState(Z),{width:z,containerRef:W,mounted:V}=NK({measureBeforeMount:!0});if(G!==Z)H(Z),Y((U)=>{let q=new Map(U.map((L)=>[L.i,L])),B=Z.filter((L)=>q.has(L.id)).map((L)=>({...q.get(L.id),w:L.w,h:L.h})),F=new Set(B.map((L)=>L.i)),N=vZ(Z.filter((L)=>!F.has(L.id)),B);return[...B,...N]});let K=oZ.useCallback((U)=>{Y(U),X?.(U.map((q)=>({id:q.i,w:q.w,h:q.h,x:q.x,y:q.y})))},[X]);return H6.jsx("div",{ref:W,className:"mx-auto w-full max-w-[var(--column-w)]",children:V&&H6.jsx(nZ,{width:z,layout:Q,gridConfig:{cols:4,rowHeight:160,margin:[8,8],containerPadding:[0,0]},dragConfig:{enabled:!!J},resizeConfig:{enabled:!1},compactor:dZ,onLayoutChange:K,children:Q.map((U)=>H6.jsx("div",{children:H6.jsx(n0.div,{layoutId:U.i,"data-snapshot-widget":U.i,className:"size-full",transition:{type:"spring",duration:0.35,bounce:0},children:$(U.i)})},U.i))})})}function cw({items:Z,editing:J,renderItem:$,onLayoutChange:X,onRemove:Q}){return H6.jsx(mK,{items:Z,editing:J,onLayoutChange:X,renderItem:(Y)=>H6.jsx(GY,{editing:J,onRemove:Q?()=>Q(Y):void 0,children:$(Y)})})}var z6=w(m(),1);function dw(Z){let J=Z0();return r0({mutationFn:({key:$,thumbnails:X})=>Z9(`/api/workspaces/${Z}/thumbnails`,x5("PUT",{key:$,thumbnails:X}),"Failed to save thumbnails"),onMutate:({key:$})=>{J.setQueryData(D1.layout(Z),(X)=>X?{...X,widgetThumbnails:{key:$,at:new Date().toISOString()}}:X)},onSuccess:()=>{J.invalidateQueries({queryKey:D1.preview(Z)})}})}var Zc=(Z)=>Math.min(1,400/Math.max(Z.offsetWidth,Z.offsetHeight)),lw=(Z,J)=>{let $=new Map(J.map((X)=>[X.id,X.tag]));return[...Z].sort().map((X)=>`${X}@${$.get(X)??""}`).join(" ")},Jc=(Z)=>new Promise((J)=>{setTimeout(()=>J(null),Z)});async function iw(Z){let{createContext:J,destroyContext:$,domToDataUrl:X}=await import("/chunk-2vaafjp4.js"),Q=async()=>{let Y=await J(Z,{scale:Zc(Z),type:"image/webp",quality:0.8,backgroundColor:"#ffffff",timeout:1000,onCreateForeignObjectSvg:(G)=>{let H=document.createElement("style");H.textContent="[data-widget-chrome] { border-radius: 0 !important; box-shadow: none !important; }[data-widget-chrome]::after { display: none !important; }",G.append(H)}});try{return await X(Y)}finally{$(Y)}};return Promise.race([Q(),Jc(1e4)])}var $c=5000,Xc=10800000;function rw({containerRef:Z,widgets:J,visibleIds:$,editing:X}){let{layout:Q,workspaceId:Y}=w0(),G=dw(Y),H=z6.useRef(G.mutate);H.current=G.mutate;let z=z6.useRef(!1),[W,V]=z6.useState(0),K=lw($,J),U=Date.parse(Q.widgetThumbnails?.at??""),q=!Number.isFinite(U)||Date.now()-U>Xc,B=K!==""&&(K!==Q.widgetThumbnails?.key||q);z6.useEffect(()=>{if(!B||X)return;if(document.visibilityState!=="visible"){let L=()=>V((M)=>M+1);return document.addEventListener("visibilitychange",L,{once:!0}),()=>document.removeEventListener("visibilitychange",L)}let F=!1,N=setTimeout(async()=>{if(z.current)return;z.current=!0;try{let L={};for(let M of $){if(F)return;let A=Z.current?.querySelector(`[data-snapshot-widget="${CSS.escape(M)}"]`),P=A?await iw(A):null;if(P)L[M]=P}if(F)return;H.current({key:K,thumbnails:L})}finally{z.current=!1,V((L)=>L+1)}},$c);return()=>{F=!0,clearTimeout(N)}},[K,B,X,W])}var $0=w(a(),1);function aw(Z){return $0.jsx(TO,{name:Z})}var Qc=Array.from({length:10},(Z,J)=>({id:`empty-widget-${J}`,w:2,h:1}));function Yc(){return $0.jsx(g8,{className:"size-full animate-none rounded-2xl [corner-shape:superellipse(1.2)]"})}function Gc({onCreateWidget:Z}){return $0.jsxs("div",{className:"relative min-h-0 flex-1 pt-7",children:[$0.jsx("div",{"aria-hidden":"true",children:$0.jsx(mK,{items:Qc,renderItem:Yc})}),$0.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6",children:$0.jsxs("div",{className:"flex h-full w-full max-w-(--column-w) flex-col items-center justify-center gap-4 bg-radial from-background from-50% to-transparent to-75% text-center",children:[$0.jsxs("div",{className:"flex flex-col gap-1.5",children:[$0.jsx("h2",{className:"font-medium",children:"A little empty here"}),$0.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Widgets are small apps that can read data, perform tasks, and show a compact view of the information that matters."})]}),$0.jsxs(E1,{type:"button",variant:"secondary",size:"sm",onClick:Z,children:[$0.jsx(a5,{"data-icon":"inline-start",stroke:1.5}),"Create widget"]})]})})]})}function Hc({editing:Z,onCreateWidget:J,onEditingChange:$}){return $0.jsxs("div",{className:"mx-auto mb-4 flex w-full max-w-(--column-w) shrink-0 items-center justify-end gap-2",children:[Z&&$0.jsxs(E1,{type:"button",variant:"ghost",size:"sm",className:"mr-auto",onClick:J,children:[$0.jsx(a5,{"data-icon":"inline-start",stroke:1.75}),"New widget"]}),$0.jsx(d9,{mode:"popLayout",initial:!1,children:Z?$0.jsx(n0.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"}},initial:"from",animate:"to",exit:"from",transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(E1,{type:"button",size:"sm",onClick:()=>$(!1),children:"Done"})},"done"):$0.jsx(n0.div,{className:"flex items-center gap-1",variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"}},initial:"from",animate:"to",exit:"from",transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(E1,{type:"button",variant:"ghost",size:"sm",className:"text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0",onClick:()=>$(!0),children:"Edit widgets"})},"actions")})]})}function zc(){return $0.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3",children:$0.jsx("p",{className:"text-sm text-muted-foreground",children:"No widgets added yet"})})}function Wc(){let[Z,J]=i8.useState(0);return[i8.useCallback((X)=>{if(!X)return;let Q=new ResizeObserver(([Y])=>{let G=Y.borderBoxSize?.[0];J(G?G.blockSize:Y.contentRect.height)});return Q.observe(X),()=>Q.disconnect()},[]),Z]}function nw({onCreateWidget:Z,editing:J,onEditingChange:$,widgets:X}){let{layout:Q,setLayout:Y}=w0(),G=X.length>0,H=new Set(Q.widgetGrid.map((N)=>N.i)),z=Q.widgetGrid.filter((N)=>X.some((L)=>L.id===N.i)).map((N)=>{let L=X.find((M)=>M.id===N.i);return{id:N.i,w:L.config.colSpan,h:L.config.rowSpan,x:N.x,y:N.y}}),W=X.filter((N)=>!H.has(N.id)).map((N)=>({id:N.id,w:N.config.colSpan,h:N.config.rowSpan})),[V,K]=Wc(),U=J&&W.length>0,q=i8.useRef(null);rw({containerRef:q,widgets:X,visibleIds:z.map((N)=>N.id),editing:J});function B(N){Y({widgetGrid:Q.widgetGrid.filter((L)=>L.i!==N)})}function F(N){let L=X.find((P)=>P.id===N);if(!L)return;let M=Q.widgetGrid.map((P)=>{let D=X.find((_)=>_.id===P.i);return{...P,w:D?.config.colSpan??1,h:D?.config.rowSpan??1}}),A=hZ(M,L.config.colSpan,L.config.rowSpan,4);Y({widgetGrid:[...Q.widgetGrid,{i:N,x:A.x,y:A.y}]})}return $0.jsx("div",{ref:q,className:"group/widgets relative min-h-0 flex-1",children:$0.jsxs(sw,{children:[$0.jsx("div",{className:N1("relative flex h-full flex-col p-4",G?"overflow-y-auto":"overflow-hidden"),children:G?$0.jsxs($0.Fragment,{children:[$0.jsx(Hc,{editing:J,onCreateWidget:Z,onEditingChange:$}),z.length===0?$0.jsx(n0.div,{className:"mx-auto flex min-h-0 w-full max-w-[var(--column-w)] flex-1 flex-col",animate:{paddingBottom:U?K:0},transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(zc,{})}):$0.jsx(n0.div,{animate:{marginBottom:U?K:0},transition:{type:"spring",duration:0.3,bounce:0},children:$0.jsx(cw,{items:z,editing:J,renderItem:aw,onRemove:B,onLayoutChange:(N)=>Y({widgetGrid:N.map((L)=>({i:L.id,x:L.x??0,y:L.y??0}))})})})]}):$0.jsx(Gc,{onCreateWidget:Z})}),$0.jsx(d9,{children:G&&J&&W.length>0&&$0.jsx(IO,{ref:V,items:W,renderItem:aw,onRestore:F})})]})})}var tw=w(a(),1);function ow({children:Z}){return tw.jsx("header",{className:"@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75 px-3",children:Z})}var nK=w(m(),1);var E5=w(a(),1);function Kc(Z){if(Z==="needs-auth")return"Needs auth";return Z[0].toUpperCase()+Z.slice(1)}function Vc({name:Z,status:J}){let $=Zj(Z),X="size-full rounded-sm ring-2 ring-background";return E5.jsxs("span",{className:"relative size-10 shrink-0",children:[$?E5.jsx("img",{src:$,alt:"",className:"size-full rounded-sm ring-2 ring-background"}):E5.jsx("span",{className:"flex size-full items-center justify-center rounded-sm bg-muted text-muted-foreground ring-2 ring-background",children:E5.jsx($j,{className:"size-5"})}),J!=="connected"&&E5.jsx(ew,{"aria-hidden":"true",size:16,stroke:1.75,className:"absolute -top-1 -right-1 rounded-full bg-card text-amber-400"})]})}function Xj(Z){return[...Z].sort((J,$)=>Number($.status==="connected")-Number(J.status==="connected"))}function Qj({icon:Z,children:J}){return E5.jsxs("div",{className:"flex items-center gap-3 text-card-foreground",children:[Z,E5.jsx("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-0.5",children:J})]})}function Yj({server:Z}){return E5.jsxs(Qj,{icon:E5.jsx(Vc,{name:Z.name,status:Z.status}),children:[E5.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Jj(Z.name)}),E5.jsx("span",{className:"text-sm text-muted-foreground",children:Kc(Z.status)})]})}function Gj(){return E5.jsxs(Qj,{icon:E5.jsx(g8,{className:"size-10 shrink-0 rounded-sm"}),children:[E5.jsx(g8,{className:"h-4 w-36 max-w-full"}),E5.jsx(g8,{className:"h-4 w-20"})]})}function pK({children:Z}){return E5.jsx("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2",children:Z})}function Hj(Z,J){return J5({queryKey:D1.mcp(Z),queryFn:()=>L0(`/api/workspaces/${Z}/mcp`),enabled:J,staleTime:1/0,gcTime:1/0,refetchOnMount:!1,refetchOnWindowFocus:!1})}var L2=w(a(),1);function r8({title:Z,description:J,children:$}){return L2.jsxs("div",{className:"flex flex-col gap-6",children:[L2.jsxs("header",{className:"flex flex-col gap-0.5",children:[L2.jsx("h2",{className:"text-lg font-medium tracking-tight",children:Z}),J&&L2.jsx("p",{className:"text-sm text-muted-foreground",children:J})]}),$]})}function a8({label:Z,children:J}){return L2.jsxs("section",{className:"flex flex-col gap-2",children:[Z&&L2.jsx("p",{className:"px-0.5 text-xs font-medium text-muted-foreground",children:Z}),L2.jsx("div",{className:"flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-lg border border-border bg-card text-card-foreground",children:J})]})}function s8({title:Z,description:J,control:$}){return L2.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-3",children:[L2.jsxs("div",{className:"flex min-w-0 flex-col",children:[L2.jsx("span",{className:"text-sm font-medium",children:Z}),J&&L2.jsx("span",{className:"text-xs text-muted-foreground",children:J})]}),$&&L2.jsx("div",{className:"ml-auto flex shrink-0 items-center pl-3",children:$})]})}var e5=w(a(),1),qc=Array.from({length:4},(Z,J)=>J);function Uc({connectors:Z}){if(Z.isPending)return e5.jsx("div",{role:"status","aria-label":"Loading connectors",children:e5.jsx(pK,{children:qc.map((J)=>e5.jsx(Gj,{},J))})});if(Z.isError)return e5.jsxs(zj,{children:[e5.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not load connectors."}),e5.jsx(E1,{variant:"outline",size:"sm",onClick:()=>Z.refetch(),children:"Retry"})]});if(Z.data.length===0)return e5.jsxs(zj,{children:[e5.jsx(OY,{size:24,stroke:1.5,className:"text-muted-foreground"}),e5.jsx("p",{className:"text-sm text-foreground",children:"No connectors configured."})]});return e5.jsx(pK,{children:Xj(Z.data).map((J)=>e5.jsx(Yj,{server:J},J.name))})}function zj({children:Z}){return e5.jsx("div",{className:"flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center",children:Z})}function Wj(){let{workspaceId:Z}=w0(),J=Hj(Z,!0);return e5.jsx(r8,{title:"Connectors",description:"Connectors available to the agent in this workspace.",children:e5.jsx(Uc,{connectors:J})})}var uK=w(m(),1);function Kj(Z){return J5({queryKey:D1.env(Z),queryFn:()=>L0(`/api/workspaces/${Z}/env`),...h9})}function Vj(Z){let J=Z0();return r0({mutationFn:($)=>L0(`/api/workspaces/${Z}/env`,x5("PUT",$)),onSuccess:($)=>{J.setQueryData(D1.env(Z),$)}})}function qj(Z){let J=Z0();return r0({mutationFn:($)=>Z9(`/api/workspaces/${Z}/config`,x5("PUT",{name:$}),"Failed to save name"),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Uj(Z){let J=Z0();return r0({scope:{id:`workspace-icon:${Z}`},mutationFn:($)=>L0(`/api/workspaces/${Z}/icon`,{method:"PUT",headers:{"Content-Type":$.type||"application/octet-stream"},body:$}),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Bj(Z){let J=Z0();return r0({scope:{id:`workspace-icon:${Z}`},mutationFn:()=>Z9(`/api/workspaces/${Z}/icon`,{method:"DELETE"},"Failed to reset icon"),onSuccess:()=>{J.invalidateQueries({queryKey:D1.layout(Z)}),J.invalidateQueries({queryKey:D1.all})}})}function Fj(Z){let J=Z0();return Y9(($)=>{if($.type==="env:updated"&&$.workspaceId===Z)J.invalidateQueries({queryKey:D1.env(Z)})}),{env:Kj(Z),update:Vj(Z)}}var e0=w(a(),1),Bc={dotenv:".env",custom:"secret",both:"override"},Fc=/^[A-Za-z_][A-Za-z0-9_]*$/;function Nj(){let{workspaceId:Z}=w0(),{env:J,update:$}=Fj(Z),[X,Q]=uK.useState(""),[Y,G]=uK.useState(""),H=Fc.test(X),z=H&&Y.length>0&&!$.isPending,W=()=>{if(!z)return;$.mutate({set:{[X]:Y}},{onSuccess:()=>{Q(""),G("")}})},V=J.data?.vars??[],K=J.data?.files.reduce((q,B)=>q+B.count,0)??0,U=J.data?.files.length??0;return e0.jsxs(r8,{title:"Environment",description:"Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved.",children:[e0.jsxs(a8,{label:"Variables",children:[J.isLoading?e0.jsx("div",{className:"flex items-center justify-center px-3.5 py-6 text-muted-foreground",children:e0.jsx(Y2,{className:"size-4 animate-spin",stroke:1.75})}):V.length===0?e0.jsx("p",{className:"px-3.5 py-4 text-sm text-muted-foreground",children:"No variables yet."}):V.map((q)=>{let B=q.source!=="dotenv";return e0.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[e0.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:q.key}),e0.jsx("span",{className:"text-xs tracking-widest text-muted-foreground/60 select-none",children:"••••••"}),e0.jsx("span",{className:N1("rounded-sm px-1.5 py-0.5 text-[11px] font-medium",q.source==="dotenv"?"bg-muted text-muted-foreground":"bg-primary/10 text-primary"),children:Bc[q.source]}),!B&&e0.jsx("span",{className:"text-right text-[11px] text-muted-foreground/60",children:"from file"}),e0.jsx(E1,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>$.mutate({remove:[q.key]}),disabled:!B,"aria-label":`Delete ${q.key}`,className:"disabled:invisible",children:e0.jsx(Lj,{stroke:1.75})})]},q.key)}),e0.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5",children:[e0.jsx(y7,{value:X,onChange:(q)=>Q(q.target.value),placeholder:"NEW_KEY","aria-invalid":X.length>0&&!H,className:"h-7 w-40 font-mono text-xs"}),e0.jsx(y7,{value:Y,onChange:(q)=>G(q.target.value),onKeyDown:(q)=>{if(q.key==="Enter")W()},type:"password",placeholder:"value",className:"h-7 flex-1 text-xs"}),e0.jsxs(E1,{variant:"outline",size:"sm",onClick:W,disabled:!z,children:[$.isPending?e0.jsx(Y2,{stroke:1.75,className:"animate-spin"}):e0.jsx(a5,{stroke:1.75}),"Add"]})]})]}),e0.jsx(a8,{label:"From .env files",children:e0.jsx(s8,{title:"Inherit .env files",description:U>0?`Discovered ${K} ${K===1?"key":"keys"} across ${U} ${U===1?"file":"files"} in this space.`:"No .env files found in this space.",control:e0.jsx(eX,{checked:J.data?.inheritDotenv??!0,disabled:J.isLoading,onCheckedChange:(q)=>$.mutate({inheritDotenv:q})})})})]})}var _C=w(m(),1);var u5=w(m(),1);var b1=w(m(),1),n8=w(m(),1),S2=w(m(),1),mj=w(a(),1),jY=w(m(),1),TY=w(m(),1),X0=w(a(),1),Lc=Object.defineProperty,Nc=(Z,J)=>{for(var $ in J)Lc(Z,$,{get:J[$],enumerable:!0})},q7={};Nc(q7,{ActiveEmoji:()=>JT,Empty:()=>ZT,List:()=>oj,Loading:()=>ej,Root:()=>dj,Search:()=>lj,SkinTone:()=>$T,SkinToneSelector:()=>tj,Viewport:()=>ij});var yj="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",lK=["none","light","medium-light","medium","medium-dark","dark"];function cK(Z){return Z.charAt(0).toUpperCase()+Z.slice(1)}var q9=2,Z2=null;function _j(Z){try{Z2??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!Z2||(queueMicrotask(()=>{Z2&&(Z2=null)}),Z2.canvas.width=q9,Z2.canvas.height=q9,Z2.font=`2px ${yj}`,Z2.textBaseline="middle",Z2.measureText(Z).width>=q9*2))return!1;Z2.fillStyle="#00f",Z2.fillText(Z,0,0);let J=Z2.getImageData(0,0,q9,q9).data;Z2.clearRect(0,0,q9,q9),Z2.fillStyle="#f00",Z2.fillText(Z,0,0);let $=Z2.getImageData(0,0,q9,q9).data;for(let X=0;X<q9*q9*4;X+=4)if(J[X]!==$[X]||J[X+1]!==$[X+1]||J[X+2]!==$[X+2])return!1;return!0}function Mj(Z,J,$){try{let X=Z.getItem(J);if(!X)throw Error(`No value found for "${J}".`);let Q=JSON.parse(X);return $(Q)}catch{return null}}function bj(Z,J,$){Z.setItem(J,JSON.stringify($))}function Aj(Z){return(J)=>J===void 0?void 0:Z(J)}function Dj(Z){return(J)=>J===null?null:Z(J)}function p5(Z){if(typeof Z!="string")throw Error();return Z}function wY(Z){if(typeof Z!="number")throw Error();return Z}function xj(Z){if(typeof Z!="boolean")throw Error();return Z}function G4(Z){return(J)=>{if(typeof J!="object"||J===null)throw Error();let $={};for(let X in Z){let Q=J[X];Q===void 0&&Z[X](void 0),$[X]=Z[X](Q)}return $}}function dK(Z){return(J)=>{if(!Array.isArray(J))throw Error();return J.length>0&&Z(J[0]),J}}var hj=(Z,J)=>`${Z}/${J}/data.json`,vj=(Z,J)=>`${Z}/${J}/messages.json`,_c=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],Pj="en",gj=(Z)=>`frimousse/data/${Z}`,Oj="frimousse/metadata";async function wj(Z,J){try{return(await fetch(Z,{method:"HEAD",signal:J})).headers.get("etag")}catch{return null}}async function Mc(Z,J,$){let[{emojis:X,emojisEtag:Q},{messages:Y,messagesEtag:G}]=await Promise.all([fetch(hj(Z,J),{signal:$}).then(async(H)=>({emojis:await H.json(),emojisEtag:H.headers.get("etag")})),fetch(vj(Z,J),{signal:$}).then(async(H)=>({messages:await H.json(),messagesEtag:H.headers.get("etag")}))]);return{emojis:X,messages:Y,emojisEtag:Q,messagesEtag:G}}async function Ac(Z,J,$){let[X,Q]=await Promise.all([wj(hj(Z,J),$),wj(vj(Z,J),$)]);return{emojisEtag:X,messagesEtag:Q}}function Dc(Z){return Z.skins?Z.skins.filter((J)=>typeof J.tone=="number").reduce((J,$)=>{let X=lK[$.tone];return J[X]=$.emoji,J},{}):void 0}async function jj(Z,J,$){let{emojis:X,emojisEtag:Q,messages:Y,messagesEtag:G}=await Mc(Z,J,$),H=Y.subgroups.find((B)=>B.key==="country-flag"||B.key==="subdivision-flag"),z=Y.groups.filter((B)=>B.key!=="component"),W=X.filter((B)=>("group"in B)),V=z.map((B)=>({index:B.order,label:cK(B.message)})),K=Y.skinTones.reduce((B,F)=>(B[F.key]=cK(F.message),B),{}),U=W.map((B)=>({emoji:B.emoji,category:B.group,version:B.version,label:cK(B.label),tags:B.tags??[],countryFlag:H&&B.subgroup===H.order||void 0,skins:Dc(B)})),q={locale:J,emojis:U,categories:V,skinTones:K};return bj(localStorage,gj(J),{data:q,metadata:{emojisEtag:Q,messagesEtag:G}}),q}function Pc(Z,J){let $=new Map;for(let G of Z)$.has(G.version)||$.set(G.version,G.emoji);let X=[...$.keys()].sort((G,H)=>H-G),Q=X[0]??0,Y=_j("\uD83C\uDDEA\uD83C\uDDFA");if(typeof J=="number")return{emojiVersion:J,countryFlags:Y};for(let G of X){let H=$.get(G);if(_j(H))return{emojiVersion:G,countryFlags:Y}}return{emojiVersion:Q,countryFlags:Y}}var Oc=G4({emojiVersion:wY,countryFlags:xj}),wc=G4({data:G4({locale:p5,emojis:dK(G4({emoji:p5,category:wY,label:p5,version:wY,tags:dK(p5),countryFlag:Aj(xj),skins:Aj(G4({light:p5,"medium-light":p5,medium:p5,"medium-dark":p5,dark:p5}))})),categories:dK(G4({index:wY,label:p5})),skinTones:G4({light:p5,"medium-light":p5,medium:p5,"medium-dark":p5,dark:p5})}),metadata:G4({emojisEtag:Dj(p5),messagesEtag:Dj(p5)})});async function jc({locale:Z,emojiVersion:J,emojibaseUrl:$,signal:X}){let Q=typeof $=="string"?$:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof J=="number"?Math.floor(J):"latest"}`,Y=Mj(sessionStorage,Oj,Oc),G=Mj(localStorage,gj(Z),wc),H;if(!G)H=await jj(Q,Z,X);else if(Y)H=G.data;else try{let{emojisEtag:W,messagesEtag:V}=await Ac(Q,Z,X);H=!W||!V||W!==G.metadata.emojisEtag||V!==G.metadata.messagesEtag?await jj(Q,Z,X):G.data}catch{H=G.data}Y??=Pc(H.emojis,J),bj(sessionStorage,Oj,Y);let z=H.emojis.filter((W)=>{let V=W.version<=Y.emojiVersion;return W.countryFlag?V&&Y.countryFlags:V});return{locale:Z,emojis:z,categories:H.categories,skinTones:H.skinTones}}function Tj(Z){return _c.includes(Z)?Z:(console.warn(`Locale "${Z}" is not supported, using "${Pj}" instead.`),Pj)}function Cj(Z){return lK.includes(Z)?Z:(console.warn(`Skin tone "${Z}" is not valid, using "none" instead.`),"none")}function Tc(Z,J){let $=[];if(J<=0)return $;for(let X=0,Q=Z.length;X<Q;X+=J)$.push(Z.slice(X,X+J));return $}function Cc(Z,J){if(!J)return Z;let $=J.toLowerCase().trim(),X=new WeakMap;return Z.filter((Q)=>{let Y=0;Q.label.toLowerCase().includes($)&&(Y+=10);for(let G of Q.tags)G.toLowerCase().includes($)&&(Y+=1);return Y>0?(X.set(Q,Y),!0):!1}).sort((Q,Y)=>(X.get(Y)??0)-(X.get(Q)??0))}function Sc(Z,J,$,X){let Q=Cc(Z.emojis,X),Y=[],G=[],H=[],z={},W=0,V=0;for(let K of Q)z[K.category]||(z[K.category]=[]),z[K.category].push({emoji:$&&$!=="none"&&K.skins?K.skins[$]:K.emoji,label:K.label});for(let K of Z.categories){let U=z[K.index];if(!U||U.length===0)continue;let q=Tc(Array.from(U),J).map((B)=>({categoryIndex:W,emojis:B}));Y.push(...q),G.push({label:K.label,rowsCount:q.length,startRowIndex:V}),H.push(V),W++,V+=q.length}return{count:Q.length,categories:G,categoriesStartRowIndices:H,rows:Y,skinTones:Z.skinTones}}function Ec(Z){let J={},$=null,X=null,Q=new Set,Y=()=>{if($){J=$,$=null;for(let W of Q)W(J)}X=null},G=()=>$??J,H=(W)=>{$??=J,Object.assign($,typeof W=="function"?W(G()):W),X||(X=requestAnimationFrame(Y))},z=(W)=>(Q.add(W),()=>Q.delete(W));return J=Z(H,G),{get:G,set:H,subscribe:z}}function Ic(Z){let[J]=S2.useState(Z);return J}function kc(Z){let J=S2.createContext(null);return{useStore:()=>{let $=S2.useContext(J);if(!$)throw Error(Z);return $},Provider:({store:$,children:X})=>mj.jsx(J.Provider,{value:$,children:X})}}function C2(Z,J,$=Object.is){let[X,Q]=S2.useState(()=>J(Z.get()));return S2.useEffect(()=>Z.subscribe(()=>{let Y=J(Z.get());Q((G)=>$(G,Y)?G:Y)}),[Z,J,$]),S2.useDebugValue(X),X}function l9(Z,J,$){let X=S2.useCallback((Q)=>Q[J],[J]);return C2(Z,X,$)}var Sj=2;function Rc(Z,J,$,X,Q){let Y=0;return Ec((G,H)=>({locale:J,columns:$,sticky:X,skinTone:Q,onEmojiSelect:Z,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:(z)=>{let W=H(),V=z?.data??W.data,K=z?.categoryHeaderHeight??W.categoryHeaderHeight,U=z?.rowHeight??W.rowHeight,q=z?.viewportHeight??W.viewportHeight;if(!V||V.rows.length===0||!K||!U||!q)return G({...z,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let B=0,F=0;for(let C of V.categories)if(F++*K+C.startRowIndex*U<Y)B+=K;else break;let N=V.categories.length*K+V.rows.length*U,L=Math.floor(Sj*U/2),M=Math.ceil(Sj*U/2),A=Math.min(Y-B-L,N-q),P=A+q+M,D=Math.max(0,Math.floor(A/U)),_=Math.min(V.rows.length-1,Math.ceil(P/U)),T=V.rows[D]?.categoryIndex;return G(T===void 0&&z?z:{...z,viewportStartCategoryIndex:T,viewportStartRowIndex:D,viewportEndRowIndex:_})},onDataChange:(z)=>{H().updateViewportState({data:z,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:(z)=>{G({search:z,interaction:z?"keyboard":"none"})},onActiveEmojiChange:(z,W,V)=>{if(G({interaction:z,activeColumnIndex:W,activeRowIndex:V}),z!=="keyboard")return;let{listRef:K,viewportRef:U,sticky:q,rowHeight:B,viewportHeight:F,categoryHeaderHeight:N}=H(),L=K?.current,M=U?.current;if(!L||!M||!B||!N||!F)return;let A=V;A===0&&M.scrollTo({top:0,behavior:"instant"});let P=L.querySelector(`[aria-rowindex="${A}"]`);if(!(P instanceof HTMLElement))return;let D=P.offsetTop,_=getComputedStyle(P),T=Number.parseFloat(_.scrollMarginTop),C=Number.parseFloat(_.scrollMarginBottom),y=Y+T;q&&D<Y+F/2&&(y+=N);let j=y+F-C;(D<y||D+B>j)&&M.scrollTo({top:Math.max(D<y+N?D-Math.max(q?N:0,T):D-F+B+C,0),behavior:"instant"})},onActiveEmojiReset:()=>{G({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:(z)=>{H().updateViewportState({rowHeight:z})},onCategoryHeaderHeightChange:(z)=>{H().updateViewportState({categoryHeaderHeight:z})},onViewportSizeChange:(z,W)=>{H().updateViewportState({viewportWidth:z,viewportHeight:W})},onViewportScroll:(z)=>{Y=z,H().updateViewportState()}}))}var{useStore:N2,Provider:yc}=kc("EmojiPicker.Root is missing.");function bc(Z){return Z.search}function iK(Z){return Z.interaction==="none"?void 0:Z.data?.rows[Z.activeRowIndex]?.emojis[Z.activeColumnIndex]}function xc(Z){return Z.data===void 0||typeof Z.data?.count=="number"&&Z.data.count===0}function hc(Z){return Z.data===null||Z.viewportHeight===null||Z.rowHeight===null||Z.categoryHeaderHeight===null}function fj(Z){return Z.data?.rows.length}function vc(Z){return Z.data?.categories.length}function gc(Z){return Z.data?.categoriesStartRowIndices}function mc(Z){return Z.data?.skinTones}function pj(Z,J){return Z?.emoji===J?.emoji}function fc(Z,J){return Z?.categoryIndex!==J?.categoryIndex||Z?.emojis.length!==J?.emojis.length?!1:!!Z?.emojis.every(($,X)=>pj($,J?.emojis[X]))}var tZ="",Ej=/\p{Emoji_Modifier_Base}/u,pc=/\uFE0F$/,uc=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,cc={light:"\uD83C\uDFFB","medium-light":"\uD83C\uDFFC",medium:"\uD83C\uDFFD","medium-dark":"\uD83C\uDFFE",dark:"\uD83C\uDFFF"};function dc(Z,J){if(!Z.split(tZ).some((X)=>Ej.test(X)))return Z;let $=Z.split(tZ).map((X)=>X.replace(uc,"")).join(tZ);return J==="none"?$:$.split(tZ).map((X,Q,Y)=>{let G=Y.length>1;return!Ej.test(X)||G&&X==="\uD83E\uDD1D"?X:X.replace(pc,"")+cc[J]}).join(tZ)}function lc(Z){return lK.map((J)=>({skinTone:J,emoji:dc(Z,J)}))}function uj(){let Z=N2(),J=C2(Z,iK,pj);return n8.useDeferredValue(J)}function cj(Z="✋"){let J=N2(),$=l9(J,"skinTone"),X=n8.useMemo(()=>lc(Z),[Z]),Q=n8.useCallback((Y)=>{J.set({skinTone:Y})},[]);return[$,Q,X]}function rK(Z,J){if(Object.is(Z,J))return!0;if(typeof Z!="object"||typeof J!="object"||Z===null||J===null||Array.isArray(Z)!==Array.isArray(J))return!1;let $=Object.keys(Z),X=Object.keys(J);return $.length!==X.length?!1:$.every((Q)=>(Q in J)&&Z[Q]===J[Q])}function ic(...Z){}function rc(Z,J){let $=null;if(typeof window.requestIdleCallback=="function")$=window.requestIdleCallback(Z,J);else{let X=Date.now();$=window.setTimeout(()=>{Z({didTimeout:!1,timeRemaining:()=>Math.max(0,(J?.timeout??50)-(Date.now()-X))})},10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback($):window.clearTimeout($)}}var U9=typeof window<"u"?jY.useLayoutEffect:jY.useEffect;function ac(Z){let J=TY.useRef(Z);return U9(()=>{J.current=Z}),TY.useCallback((...$)=>J.current(...$),[])}function sc({emojiVersion:Z,emojibaseUrl:J}){let[$,X]=b1.useState(void 0),Q=N2(),Y=l9(Q,"locale"),G=l9(Q,"columns"),H=l9(Q,"skinTone"),z=l9(Q,"search");return b1.useEffect(()=>{let W=new AbortController,V=W.signal;return jc({locale:Y,emojiVersion:Z,emojibaseUrl:J,signal:V}).then((K)=>{X(K)}).catch((K)=>{V.aborted||console.error(K)}),()=>{W.abort()}},[Z,J,Y]),b1.useEffect(()=>{if($)return rc(()=>{Q.get().onDataChange(Sc($,G,H,z))},{timeout:100})},[$,G,H,z]),null}var dj=b1.forwardRef(({locale:Z="en",columns:J=9,skinTone:$="none",onEmojiSelect:X=ic,emojiVersion:Q,emojibaseUrl:Y,onFocusCapture:G,onBlurCapture:H,children:z,style:W,sticky:V=!0,...K},U)=>{let q=ac(X),B=Ic(()=>Rc(q,Tj(Z),J,V,Cj($))),[F,N]=b1.useState(!1),L=b1.useRef(null),M=b1.useCallback((D)=>{D&&(L.current=D,B.set({rootRef:L}))},[]);U9(()=>{B.set({locale:Tj(Z)})},[Z]),U9(()=>{B.set({columns:J})},[J]),U9(()=>{B.set({sticky:V})},[V]),U9(()=>{B.set({skinTone:Cj($)})},[$]);let A=b1.useCallback((D)=>{G?.(D);let{searchRef:_,viewportRef:T}=B.get(),C=D.target===_?.current||D.target.hasAttribute("frimousse-search"),y=D.target===T?.current||D.target.hasAttribute("frimousse-viewport");D.isDefaultPrevented()||(N(C||y),D.isDefaultPrevented()||(N(C||y),y?B.get().onActiveEmojiChange("keyboard",0,0):C&&B.get().search===""&&B.set({interaction:"none"})))},[G]),P=b1.useCallback((D)=>{H?.(D),!D.isDefaultPrevented()&&!D.currentTarget.contains(D.relatedTarget)&&N(!1)},[H]);return U9(()=>{F||B.get().onActiveEmojiReset()},[F]),b1.useImperativeHandle(U,()=>L.current),b1.useEffect(()=>{if(!F)return;function D(_){if(_.defaultPrevented||!_.key.startsWith("Arrow")&&_.key!=="Enter")return;let{data:T,onEmojiSelect:C,onActiveEmojiChange:y,interaction:j,activeColumnIndex:g,activeRowIndex:I}=B.get();if(_.key==="Enter"){let E=iK(B.get());E&&(_.preventDefault(),C(E))}if(_.key.startsWith("Arrow")){let E=g,S=I;if(_.preventDefault(),j!=="none"){if(T?.rows&&T.rows.length>0)switch(_.key){case"ArrowLeft":{if(E===0){let b=S-1,R=T.rows[b];R&&(S=b,E=R.emojis.length-1)}else E-=1;break}case"ArrowRight":{if(E===T.rows[S].emojis.length-1){let b=S+1;T.rows[b]&&(S=b,E=0)}else E+=1;break}case"ArrowUp":{let b=T.rows[S-1];b&&(S-=1,b.emojis[E]||(E=b.emojis.length-1));break}case"ArrowDown":{let b=T.rows[S+1];b&&(S+=1,b.emojis[E]||(E=b.emojis.length-1));break}}y("keyboard",E,S)}else y("keyboard",0,0)}}return document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}},[F]),U9(()=>{let D=null,_=null,T=null,C=null,y=B.subscribe((S)=>{L.current&&(D!==S.viewportWidth&&(D=S.viewportWidth,L.current.style.setProperty("--frimousse-viewport-width",`${S.viewportWidth}px`)),_!==S.viewportHeight&&(_=S.viewportHeight,L.current.style.setProperty("--frimousse-viewport-height",`${S.viewportHeight}px`)),T!==S.rowHeight&&(T=S.rowHeight,L.current.style.setProperty("--frimousse-row-height",`${S.rowHeight}px`)),C!==S.categoryHeaderHeight&&(C=S.categoryHeaderHeight,L.current.style.setProperty("--frimousse-category-header-height",`${S.categoryHeaderHeight}px`)))}),{viewportWidth:j,viewportHeight:g,rowHeight:I,categoryHeaderHeight:E}=B.get();return j&&L.current.style.setProperty("--frimousse-viewport-width",`${j}px`),g&&L.current.style.setProperty("--frimousse-viewport-height",`${g}px`),I&&L.current.style.setProperty("--frimousse-row-height",`${I}px`),E&&L.current.style.setProperty("--frimousse-category-header-height",`${E}px`),y},[]),X0.jsx("div",{"data-focused":F?"":void 0,"frimousse-root":"",onBlurCapture:P,onFocusCapture:A,...K,ref:M,style:{"--frimousse-emoji-font":yj,...W},children:X0.jsxs(yc,{store:B,children:[X0.jsx(sc,{emojiVersion:Q,emojibaseUrl:Y}),z]})})}),lj=b1.forwardRef(({value:Z,defaultValue:J,onChange:$,...X},Q)=>{let Y=N2(),G=b1.useRef(null),H=b1.useCallback((K)=>{K&&(G.current=K,Y.set({searchRef:G}))},[]),z=typeof Z=="string",W=b1.useRef(z);b1.useEffect(()=>{W.current=z},[z]),U9(()=>{Y.set({search:typeof Z=="string"?Z:typeof J=="string"?J:""})},[]),U9(()=>{typeof Z=="string"&&Y.get().onSearchChange(Z)},[Z]);let V=b1.useCallback((K)=>{$?.(K),K.isDefaultPrevented()||Y.get().onSearchChange(K.target.value)},[$]);return b1.useImperativeHandle(Q,()=>G.current),X0.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...X,defaultValue:J,onChange:V,ref:H,value:Z})}),nc=b1.memo(()=>{let Z=uj();return Z?X0.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:Z.label}):null}),ij=b1.forwardRef(({children:Z,onScroll:J,onKeyDown:$,style:X,...Q},Y)=>{let G=N2(),H=b1.useRef(null),z=b1.useCallback((U)=>{U&&(H.current=U,G.set({viewportRef:H}))},[]),W=C2(G,fj),V=C2(G,vc),K=b1.useCallback((U)=>{J?.(U),G.get().onViewportScroll(U.currentTarget.scrollTop)},[J]);return U9(()=>{if(!H.current)return;let U=new ResizeObserver(([q])=>{let B=q?.borderBoxSize[0]?.inlineSize??0,F=q?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:N,viewportHeight:L,viewportWidth:M}=G.get();(L!==F||M!==B)&&N(B,F)});return U.observe(H.current),G.get().onViewportSizeChange(H.current.offsetWidth,H.current.clientHeight),()=>{U.disconnect()}},[]),b1.useImperativeHandle(Y,()=>H.current),X0.jsxs("div",{"frimousse-viewport":"",...Q,onScroll:K,ref:z,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof W=="number"&&typeof V=="number"?`var(--frimousse-viewport-width, auto) calc(${W} * var(--frimousse-row-height) + ${V} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...X},children:[X0.jsx(nc,{}),Z]})});function rj(Z,J,$){return{emoji:{...Z,isActive:$},role:"gridcell","aria-colindex":J,"aria-selected":$||void 0,"aria-label":Z.label,"data-active":$?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function aj(Z,J=!1){return{role:J?void 0:"row","aria-rowindex":J?void 0:Z,"frimousse-row":"",style:{contain:J?void 0:"content",height:J?void 0:"var(--frimousse-row-height)",display:"flex"}}}function sj(Z,J){return{"frimousse-category":"",style:{contain:"content",top:J?`calc(${Z} * var(--frimousse-category-header-height) + ${J.startRowIndex} * var(--frimousse-row-height))`:void 0,height:J?`calc(var(--frimousse-category-header-height) + ${J.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function nj(Z,J=!1,$=!0){return{category:Z,"frimousse-category-header":"",style:{contain:J?void 0:"layout paint",height:J?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:$?"sticky":void 0,top:0}}}function Ij(Z,J,$,X){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${Z} * var(--frimousse-row-height) + ${J} * var(--frimousse-category-header-height))`,paddingTop:`calc(${$} * var(--frimousse-row-height) + ${X} * var(--frimousse-category-header-height))`}}}function kj(Z,J,$){return{"aria-colcount":Z,"aria-rowcount":J,"frimousse-list":"",style:{"--frimousse-list-columns":Z,...$},role:"grid"}}function oc(Z){Z.preventDefault()}var tc=b1.memo(({Emoji:Z,emoji:J,columnIndex:$,rowIndex:X})=>{let Q=N2(),Y=C2(Q,(W)=>iK(W)?.emoji===J.emoji),G=b1.useCallback(()=>{Q.get().onEmojiSelect(J)},[J]),H=b1.useCallback(()=>{Q.get().onActiveEmojiChange("pointer",$,X)},[$,X]),z=b1.useCallback(()=>{Q.get().onActiveEmojiReset()},[]);return X0.jsx(Z,{...rj(J,$,Y),onClick:G,onPointerDown:oc,onPointerEnter:H,onPointerLeave:z})}),ec=b1.memo(({Row:Z,Emoji:J,rowIndex:$})=>{let X=N2(),Q=C2(X,(Y)=>Y.data?.rows[$],fc);return Q?X0.jsx(Z,{...aj($),children:Q.emojis.map((Y,G)=>X0.jsx(tc,{Emoji:J,columnIndex:G,emoji:Y,rowIndex:$},Y.label))}):null}),Zd=b1.memo(({CategoryHeader:Z,categoryIndex:J})=>{let $=N2(),X=C2($,(Y)=>Y.data?.categories[J],rK),Q=l9($,"sticky");return X?X0.jsx("div",{...sj(J,X),children:X0.jsx(Z,{...nj({label:X.label},!1,Q)})}):null}),Rj=b1.memo(({CategoryHeader:Z,Row:J,Emoji:$})=>{let X=b1.useRef(null),Q=N2(),Y=l9(Q,"columns"),G=b1.useMemo(()=>Array(Y).fill({emoji:"\uD83D\uDE42",label:""}),[Y]),H=b1.useMemo(()=>({label:"Category"}),[]),z=b1.useRef(null),W=b1.useRef(null);return U9(()=>{let V=X.current?.parentElement?.parentElement;if(!V||!z.current||!W.current)return;let K=new ResizeObserver((B)=>{for(let F of B){let N=F.contentRect.height,{onRowHeightChange:L,onCategoryHeaderHeightChange:M,rowHeight:A,categoryHeaderHeight:P}=Q.get();F.target===z.current&&A!==N&&L(N),F.target===W.current&&P!==N&&M(N)}});K.observe(V),K.observe(z.current),K.observe(W.current);let{onRowHeightChange:U,onCategoryHeaderHeightChange:q}=Q.get();return U(z.current.clientHeight),q(W.current.clientHeight),()=>{K.disconnect()}},[]),X0.jsxs("div",{"aria-hidden":!0,ref:X,style:{height:0,visibility:"hidden"},children:[X0.jsx("div",{"frimousse-row-sizer":"",ref:z,children:X0.jsx(J,{...aj(-1,!0),children:G.map((V,K)=>X0.jsx($,{...rj(V,K,!1)},K))})}),X0.jsx("div",{...sj(-1),children:X0.jsx("div",{"frimousse-category-header-sizer":"",ref:W,children:X0.jsx(Z,{...nj(H,!0)})})})]})});function Jd({category:Z,...J}){return X0.jsx("div",{...J,children:Z.label})}function $d({emoji:Z,...J}){return X0.jsx("button",{type:"button",...J,children:Z.emoji})}function Xd({...Z}){return X0.jsx("div",{...Z})}var oj=b1.forwardRef(({style:Z,components:J,...$},X)=>{let Q=N2(),Y=b1.useRef(null),G=b1.useCallback((L)=>{L&&(Y.current=L,Q.set({listRef:Y}))},[]),H=J?.CategoryHeader??Jd,z=J?.Emoji??$d,W=J?.Row??Xd,V=l9(Q,"columns"),K=l9(Q,"viewportStartRowIndex"),U=l9(Q,"viewportEndRowIndex"),q=C2(Q,fj),B=C2(Q,gc,rK),F=b1.useMemo(()=>B?.filter((L)=>L<K).length??0,[B,K]),N=B?.length??0;return b1.useImperativeHandle(X,()=>Y.current),!q||!B||N===0?X0.jsx("div",{...kj(V,0,Z),...$,children:X0.jsx("div",{...Ij(0,0,0,0),children:X0.jsx(Rj,{CategoryHeader:H,Emoji:z,Row:W})})}):X0.jsx("div",{...kj(V,q,Z),...$,ref:G,children:X0.jsxs("div",{...Ij(q,N,K,F),children:[X0.jsx(Rj,{CategoryHeader:H,Emoji:z,Row:W}),Array.from({length:U-K+1},(L,M)=>{let A=K+M,P=B.indexOf(A);return X0.jsxs(b1.Fragment,{children:[P>=0&&X0.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),X0.jsx(ec,{Emoji:z,Row:W,rowIndex:A})]},A)}),Array.from({length:N},(L,M)=>X0.jsx(Zd,{CategoryHeader:H,categoryIndex:M},M))]})})}),tj=b1.forwardRef(({emoji:Z,onClick:J,"aria-label":$="Change skin tone",...X},Q)=>{let Y=N2(),G=C2(Y,mc,rK),[H,z,W]=cj(Z),V=b1.useMemo(()=>Math.max(0,W.findIndex((N)=>N.skinTone===H)),[H,W]),K=W[V],U=W[(V+1)%W.length].skinTone,q=H==="none"?void 0:G?.[H],B=U==="none"?void 0:G?.[U],F=b1.useCallback((N)=>{J?.(N),N.isDefaultPrevented()||z(U)},[J,z,U]);return X0.jsx("button",{type:"button",...X,"aria-label":$+(B?` (${B})`:""),"aria-live":"polite","aria-valuetext":q,"frimousse-skin-tone-selector":"",onClick:F,ref:Q,children:K.emoji})});function ej({children:Z,...J}){let $=N2();return C2($,hc)?X0.jsx("span",{"frimousse-loading":"",...J,children:Z}):null}function Qd({children:Z}){let J=N2(),$=C2(J,bc);return Z({search:$})}function ZT({children:Z,...J}){let $=N2();return C2($,xc)?X0.jsx("span",{"frimousse-empty":"",...J,children:typeof Z=="function"?X0.jsx(Qd,{children:Z}):Z}):null}function JT({children:Z}){let J=uj();return Z({emoji:J})}function $T({children:Z,emoji:J}){let[$,X,Q]=cj(J);return Z({skinTone:$,setSkinTone:X,skinToneVariations:Q})}dj.displayName="EmojiPicker.Root";lj.displayName="EmojiPicker.Search";ij.displayName="EmojiPicker.Viewport";oj.displayName="EmojiPicker.List";ej.displayName="EmojiPicker.Loading";ZT.displayName="EmojiPicker.Empty";tj.displayName="EmojiPicker.SkinToneSelector";JT.displayName="EmojiPicker.ActiveEmoji";$T.displayName="EmojiPicker.SkinTone";var ZJ=[{id:"rocket",Icon:lT},{id:"sparkles",Icon:sT},{id:"bolt",Icon:HT},{id:"flame",Icon:TT},{id:"star",Icon:nT},{id:"heart",Icon:kT},{id:"diamond",Icon:wT},{id:"trophy",Icon:JC},{id:"target",Icon:tT},{id:"bulb",Icon:qT},{id:"brain",Icon:WT},{id:"robot",Icon:dT},{id:"wand",Icon:XC},{id:"atom",Icon:YT},{id:"flask",Icon:CT},{id:"cpu",Icon:AT},{id:"code",Icon:_T},{id:"terminal",Icon:eT},{id:"api",Icon:QT},{id:"database",Icon:PT},{id:"cube",Icon:DT},{id:"hexagon",Icon:RT},{id:"plug",Icon:cT},{id:"tool",Icon:ZC},{id:"settings",Icon:eZ},{id:"bug",Icon:VT},{id:"activity",Icon:XT},{id:"chart",Icon:FT},{id:"briefcase",Icon:KT},{id:"folder",Icon:ST},{id:"file",Icon:q8},{id:"book",Icon:zT},{id:"message",Icon:vT},{id:"mail",Icon:xT},{id:"bell",Icon:GT},{id:"paperclip",Icon:$Q},{id:"key",Icon:CY},{id:"shield",Icon:iT},{id:"user",Icon:$C},{id:"home",Icon:yT},{id:"globe",Icon:IT},{id:"world",Icon:QC},{id:"planet",Icon:uT},{id:"compass",Icon:MT},{id:"map",Icon:hT},{id:"calendar",Icon:UT},{id:"cloud",Icon:NT},{id:"sun",Icon:oT},{id:"moon",Icon:gT},{id:"snowflake",Icon:aT},{id:"leaf",Icon:bT},{id:"mountain",Icon:mT},{id:"feather",Icon:jT},{id:"ghost",Icon:Y6},{id:"music",Icon:fT},{id:"camera",Icon:BT},{id:"photo",Icon:pT},{id:"palette",Icon:SY},{id:"gamepad",Icon:OT},{id:"gift",Icon:ET},{id:"cart",Icon:rT},{id:"chef",Icon:LT}],YC=ZJ.map((Z)=>Z.id),Yd=new Map(ZJ.map((Z)=>[Z.id,Z.Icon]));function EY(Z){return Z?Yd.get(Z)??null:null}var sK=[{id:"sunrise",gradient:{angle:140,stops:["#FFE29F","#FFA99F","#FF719A"]}},{id:"ocean",gradient:{angle:135,stops:["#67E8F9","#3B82F6","#4F46E5"]}},{id:"meadow",gradient:{angle:135,stops:["#A7F3D0","#34D399","#059669"]}},{id:"dusk",gradient:{angle:120,stops:["#C471F5","#FA71CD"]}},{id:"midnight",gradient:{angle:135,stops:["#30CFD0","#330867"]}}];function aK(Z,J,$){let X=$*Math.PI/180,Q=J*Math.cos(X),Y=J*Math.sin(X),G=(Z+0.3963377774*Q+0.2158037573*Y)**3,H=(Z-0.1055613458*Q-0.0638541728*Y)**3,z=(Z-0.0894841775*Q-1.291485548*Y)**3;return`#${[4.0767416621*G-3.3077115913*H+0.2309699292*z,-1.2684380046*G+2.6097574011*H-0.3413193965*z,-0.0041960863*G-0.7034186147*H+1.707614701*z].map((V)=>{let K=Math.min(1,Math.max(0,V)),U=K<=0.0031308?12.92*K:1.055*K**0.4166666666666667-0.055;return Math.round(U*255).toString(16).padStart(2,"0")}).join("")}`}function GC(){let Z=Math.random()*360,J=(35+Math.random()*55)*(Math.random()<0.5?-1:1),$=Math.round(115+Math.random()*55),X=aK(0.83+Math.random()*0.06,0.09+Math.random()*0.06,Z),Q=aK(0.5+Math.random()*0.14,0.17+Math.random()*0.07,Z+J);if(Math.random()<0.4){let Y=aK(0.7+Math.random()*0.05,0.15,Z+J/2);return{angle:$,stops:[X,Y,Q]}}return{angle:$,stops:[X,Q]}}var Gd="radial-gradient(120% 100% at 28% 12%, rgba(255,255,255,0.32), rgba(255,255,255,0) 58%)";function IY(Z){return`${Gd}, linear-gradient(${Z.angle}deg, ${Z.stops.join(", ")})`}var D5=256;function HC(Z,J){let $=J.angle*Math.PI/180,X=Math.sin($),Q=-Math.cos($),Y=D5*(Math.abs(X)+Math.abs(Q))/2,G=D5/2,H=Z.createLinearGradient(G-X*Y,G-Q*Y,G+X*Y,G+Q*Y),z=J.stops.length-1;J.stops.forEach((V,K)=>H.addColorStop(z===0?0:K/z,V)),Z.fillStyle=H,Z.fillRect(0,0,D5,D5);let W=Z.createRadialGradient(D5*0.28,D5*0.12,0,D5*0.28,D5*0.12,D5*1.1);W.addColorStop(0,"rgba(255,255,255,0.32)"),W.addColorStop(0.58,"rgba(255,255,255,0)"),Z.fillStyle=W,Z.fillRect(0,0,D5,D5)}function zC(Z){return new Promise((J,$)=>{Z.toBlob((X)=>X?J(X):$(Error("Canvas is empty")),"image/png")})}function WC(){let Z=document.createElement("canvas");Z.width=D5,Z.height=D5;let J=Z.getContext("2d");if(!J)throw Error("2D canvas unavailable");return[Z,J]}var Hd=0.92,zd=0.68;async function KC(Z,J){let[$,X]=WC();if(J)HC(X,J);X.textAlign="center",X.textBaseline="middle";let Q=J?zd:Hd;return X.font=`${Math.round(D5*Q)}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`,X.fillText(Z,D5/2,D5/2+D5*0.04),zC($)}function Wd(Z){return new Promise((J,$)=>{let X=new Image;X.onload=()=>J(X),X.onerror=()=>$(Error("Failed to load SVG")),X.src=Z})}var Kd=0.78,Vd=0.6;async function VC(Z,J){let[$,X]=WC();if(J)HC(X,J);let Q=J?"#ffffff":"#18181b",Y=Z.replace(/currentColor/g,Q),G=await Wd(`data:image/svg+xml;utf8,${encodeURIComponent(Y)}`),H=D5*(J?Vd:Kd),z=(D5-H)/2;return X.drawImage(G,z,z,H,H),zC($)}var qC=["\uD83D\uDE80","✨","\uD83D\uDD25","⚡","\uD83D\uDCA1","\uD83E\uDDE0","\uD83E\uDD16","\uD83E\uDE84","\uD83E\uDDEA","⚙️","\uD83D\uDEE0️","\uD83D\uDCBB","\uD83D\uDCE6","\uD83D\uDCCA","\uD83D\uDCC8","\uD83D\uDCDD","\uD83D\uDCDA","\uD83C\uDFAF","\uD83C\uDFC6","\uD83D\uDC8E","\uD83E\uDE90","\uD83C\uDF0D","\uD83E\uDDED","\uD83C\uDFA8","\uD83C\uDFAE","☕"],kY="font-[Apple_Color_Emoji,Segoe_UI_Emoji,Noto_Color_Emoji,sans-serif]";var m1=w(a(),1);function qd({category:Z,...J}){return m1.jsx("div",{className:"bg-background px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",...J,children:Z.label})}function Ud({children:Z,...J}){return m1.jsx("div",{className:"scroll-my-1 px-1.5",...J,children:Z})}function Bd({emoji:Z,...J}){return m1.jsx("button",{className:N1("flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75 data-[active]:bg-muted",kY),...J,children:Z.emoji})}function NC({icon:Z}){let{workspaceId:J,provider:$}=w0(),{isPending:X,mutateAsync:Q}=Uj(J),{isPending:Y,mutate:G}=Bj(J),[H,z]=u5.useState("emoji"),[W,V]=u5.useState({id:"sunrise",gradient:sK[0].gradient}),[K,U]=u5.useState(null),[q,B]=u5.useState(null),[F,N]=u5.useState(""),[L,M]=u5.useState(null),[A,P]=u5.useState(null),[D,_]=u5.useState(!1),[T,C]=u5.useState(null),y=u5.useRef(null),j=u5.useRef(null),g=u5.useRef(null),I=ZJ.find((O)=>O.id===L),E=W.gradient!==null,S=X||Y,b=()=>{let O=GC();U(O),V({id:"shuffle",gradient:O})},R=(O)=>{C(null),g.current=O,z("upload"),P(URL.createObjectURL(O))};u5.useEffect(()=>{let O=!1,K1=async()=>{let k;if(H==="upload"){if(!g.current)return;k=g.current}else if(H==="emoji"){if(!q)return;k=await KC(q,W.gradient)}else{let e=j.current?.querySelector("svg");if(!e)return;k=await VC(new XMLSerializer().serializeToString(e),W.gradient)}if(!O)await Q(k)};C(null);let Z1=window.setTimeout(()=>{K1().catch((k)=>{if(!O)C(k instanceof Error?k.message:"Failed to save icon")})},150);return()=>{O=!0,window.clearTimeout(Z1)}},[W.gradient,q,H,Q,I,A]),u5.useEffect(()=>{return()=>{if(A)URL.revokeObjectURL(A)}},[A]);let x=()=>{g.current=null,B(null),M(null),P(null),C(null),G()},h=H==="emoji"&&q?"emoji":H==="icon"&&I?"glyph":"image",d=H==="upload"&&A?A:Z??$9[$??"claude-code"];return m1.jsxs("div",{className:"flex gap-6",children:[m1.jsxs("div",{className:"flex w-24 shrink-0 flex-col items-center gap-2.5",children:[m1.jsx("div",{className:N1("flex size-24 items-center justify-center overflow-hidden rounded-[24px] shadow-sm ring-1 ring-border",h!=="image"&&!E&&"bg-[repeating-conic-gradient(#0000000d_0%_25%,transparent_0%_50%)] bg-[length:16px_16px]"),style:h!=="image"&&W.gradient?{background:IY(W.gradient)}:void 0,children:h==="emoji"?m1.jsx("span",{className:N1("leading-none",kY,E?"text-[64px]":"text-[86px]"),children:q}):h==="glyph"&&I?m1.jsx(I.Icon,{stroke:1.5,className:N1(E?"size-14 text-white":"size-18 text-foreground")}):m1.jsx("img",{src:d,alt:"",className:"size-full object-cover"})}),m1.jsx("button",{type:"button",onClick:x,disabled:S,className:"text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Reset to default"})]}),m1.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[m1.jsx("div",{className:"flex gap-1 self-start rounded-lg bg-muted p-0.5",children:["emoji","icon","upload"].map((O)=>m1.jsx("button",{type:"button",onClick:()=>z(O),className:N1("rounded-md px-3.5 py-1 text-xs font-medium capitalize transition-colors",H===O?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:O},O))}),m1.jsxs("div",{className:N1("flex items-center gap-2",H==="upload"&&"pointer-events-none opacity-35"),children:[m1.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Background"}),m1.jsxs("div",{className:"flex items-center gap-2",children:[m1.jsx("button",{type:"button","aria-label":"No background",onClick:()=>V({id:"none",gradient:null}),className:N1("flex size-7 items-center justify-center rounded-full bg-muted ring-offset-2 ring-offset-card transition-shadow",W.id==="none"?"ring-2 ring-primary":"ring-1 ring-border hover:ring-muted-foreground/30"),children:m1.jsx(BC,{size:16,stroke:1.75,className:"text-muted-foreground"})}),sK.map((O)=>m1.jsx("button",{type:"button","aria-label":`${O.id} background`,onClick:()=>V({id:O.id,gradient:O.gradient}),style:{background:IY(O.gradient)},className:N1("size-7 rounded-full ring-offset-2 ring-offset-card transition-shadow",W.id===O.id?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30")},O.id)),m1.jsx("button",{type:"button","aria-label":"Random background",title:"Surprise me",onClick:b,style:K?{background:IY(K)}:void 0,className:N1("flex size-7 items-center justify-center rounded-full ring-offset-2 ring-offset-card transition-shadow",K?"text-white":"bg-muted text-muted-foreground ring-1 ring-border",W.id==="shuffle"?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30"),children:m1.jsx(UC,{size:16,stroke:1.75})})]})]}),H==="emoji"?m1.jsxs(q7.Root,{onEmojiSelect:(O)=>B(O.emoji),emojibaseUrl:"/vendor/emojibase",columns:13,className:"isolate flex h-72 flex-col overflow-hidden rounded-lg border border-border bg-background",children:[m1.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 pb-0",children:[m1.jsx(q7.Search,{placeholder:"Search emoji…",onChange:(O)=>N(O.target.value),className:"h-8 min-w-0 flex-1 appearance-none rounded-md bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"}),m1.jsx(q7.SkinToneSelector,{className:"size-8 shrink-0 rounded-md text-lg hover:bg-accent"})]}),m1.jsxs(q7.Viewport,{className:"relative scrollbar-thin flex-1 overflow-y-auto outline-none",children:[m1.jsxs(q7.Loading,{className:"absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[m1.jsx(Y2,{size:16,stroke:1.75,className:"animate-spin"}),"Loading emoji…"]}),F.trim()===""&&m1.jsxs("div",{className:"border-b border-dashed border-border pb-1.5",children:[m1.jsx("p",{className:"px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",children:"Favorites"}),m1.jsx("div",{className:"grid grid-cols-13 justify-items-start px-1.5",children:qC.map((O)=>m1.jsx("button",{type:"button",onClick:()=>B(O),className:N1("flex size-9 items-center justify-center rounded-lg text-[22px] transition-colors duration-75",kY,q===O?"bg-primary/10":"hover:bg-accent"),children:O},O))})]}),m1.jsxs(q7.Empty,{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 text-xs text-muted-foreground",children:[m1.jsx(FC,{size:20,stroke:1.5}),"No emoji found"]}),m1.jsx(q7.List,{className:"pb-1.5 select-none",components:{CategoryHeader:qd,Row:Ud,Emoji:Bd}})]})]}):H==="icon"?m1.jsx("div",{className:"grid scrollbar-thin h-72 grid-cols-[repeat(auto-fill,minmax(2.25rem,1fr))] content-start gap-1 overflow-y-auto rounded-lg border border-border bg-background p-1.5",children:ZJ.map(({id:O,Icon:K1})=>m1.jsx("button",{type:"button","aria-label":O,onClick:()=>M(O),className:N1("flex aspect-square items-center justify-center rounded-lg text-muted-foreground transition-colors [&_svg]:size-5",L===O?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:m1.jsx(K1,{stroke:1.5})},O))}):m1.jsxs("button",{type:"button",onClick:()=>y.current?.click(),onDragOver:(O)=>{O.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:(O)=>{O.preventDefault(),_(!1);let K1=O.dataTransfer.files?.[0];if(K1)R(K1)},className:N1("flex h-72 flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors",D?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[m1.jsx(LC,{size:24,stroke:1.5}),m1.jsx("span",{className:"text-xs font-medium",children:"Click or drop an image"}),m1.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"PNG, JPG, GIF, or WebP"})]}),m1.jsx("div",{className:"min-h-4","aria-live":"polite",children:T?m1.jsx("p",{className:"text-xs text-destructive",children:T}):S?m1.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving…"}):null})]}),m1.jsx("input",{ref:y,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:(O)=>{let K1=O.target.files?.[0];if(K1)R(K1);O.target.value=""}}),m1.jsx("span",{ref:j,"aria-hidden":!0,className:"hidden",children:I&&m1.jsx(I.Icon,{stroke:1.5})})]})}var I5=w(a(),1);function MC(){let{name:Z,icon:J,cwd:$,workspaceId:X}=w0(),[,Q]=y9(),Y=qj(X),G=XB(),[H,z]=_C.useState(Z??"");return I5.jsxs(r8,{title:"General",description:"Basic details for this space.",children:[I5.jsxs(a8,{children:[I5.jsx(s8,{title:"Name",description:"Shown in the sidebar and the workspace header.",control:I5.jsx(y7,{value:H,onChange:(K)=>z(K.target.value),onBlur:()=>{let K=H.trim();if(K===(Z??""))return;Y.mutate(K===""?null:K)},onKeyDown:(K)=>{if(K.key==="Enter")K.currentTarget.blur()},placeholder:"Space name",className:"w-56"})}),I5.jsx(s8,{title:"Path",control:I5.jsx(y7,{value:$??"",readOnly:!0,"aria-label":"Workspace path",title:$??void 0,className:"w-56"})}),I5.jsxs("div",{className:"flex flex-col gap-4 px-3.5 py-3.5",children:[I5.jsxs("div",{className:"flex flex-col",children:[I5.jsx("span",{className:"text-sm font-medium",children:"Icon"}),I5.jsx("span",{className:"text-xs text-muted-foreground",children:"Pick an emoji or a glyph on a generated background, or upload an image."})]}),I5.jsx(NC,{icon:J})]})]}),I5.jsxs(a8,{label:"Danger zone",children:[I5.jsx(s8,{title:"Remove space",description:"Remove this space from moi. Its folder and sessions stay on disk.",control:I5.jsxs(E1,{type:"button",variant:"destructive",size:"sm",onClick:()=>{let U=`Remove "${Z??$??"this space"}" from your workspaces?
|
|
62
62
|
|
|
63
|
-
This only removes it from your list. The folder and its sessions stay on disk. You can add it back any time.`;if(!window.confirm(U))return;G.mutate(X,{onSuccess:()=>Q("/")})},disabled:G.isPending,children:[G.isPending&&I5.jsx(Y2,{"data-icon":"inline-start",stroke:1.75,className:"animate-spin"}),"Remove"]})}),G.isError&&I5.jsx("p",{className:"px-3.5 py-3 text-xs text-destructive",children:G.error.message})]})]})}var x0=w(a(),1),Fd=[{id:"general",label:"General",icon:eZ},{id:"connectors",label:"Connectors",icon:OY},{id:"environment",label:"Environment",icon:CY}];function AC(){let[Z,J]=nK.useState(!1),[$,X]=nK.useState("general");return x0.jsxs(x0.Fragment,{children:[x0.jsxs(T9,{children:[x0.jsx(C9,{render:x0.jsx(E1,{variant:"ghost",size:"icon-sm","aria-label":"Space settings",onClick:()=>J(!0),children:x0.jsx(eZ,{stroke:1.75})})}),x0.jsx(S9,{children:"Space settings"})]}),x0.jsx(p6,{open:Z,onOpenChange:J,children:x0.jsxs(S$,{className:"flex h-[min(680px,90vh)] w-[880px] max-w-[94vw]",children:[x0.jsx(u6,{className:"sr-only",children:"Space settings"}),x0.jsxs("nav",{className:"flex w-48 shrink-0 flex-col gap-0.5 border-r border-border bg-muted/30 p-3",children:[x0.jsx("p",{className:"px-2.5 pt-4 pb-2 text-[11px] font-semibold tracking-wider text-muted-foreground/80 uppercase",children:"Settings"}),Fd.map((Q)=>x0.jsxs(E1,{type:"button",variant:$===Q.id?"secondary":"ghost",size:"sm",onClick:()=>X(Q.id),className:"justify-start",children:[x0.jsx(Q.icon,{stroke:1.75}),Q.label]},Q.id))]}),x0.jsxs("div",{className:"relative scrollbar-thin min-w-0 flex-1 overflow-y-auto",children:[x0.jsx(C$,{render:x0.jsx(E1,{variant:"ghost",size:"icon","aria-label":"Close",className:"absolute top-3 right-3 z-10",children:x0.jsx(X9,{stroke:1.5})})}),x0.jsxs("div",{className:"px-8 py-7",children:[$==="general"&&x0.jsx(MC,{}),$==="connectors"&&x0.jsx(Wj,{}),$==="environment"&&x0.jsx(Nj,{})]})]})]})})]})}var W6=w(m(),1);var TC=w(m(),1);function RY(Z,J){let $=Z??[];if($.findIndex((Q)=>Q.id===J.id)===-1)return[...$,J];return $.map((Q)=>Q.id===J.id&&Q.updatedAt<=J.updatedAt?J:Q)}function yY(Z){let J=Z0();return Y9(($)=>{if($.type==="view-builder:updated"&&$.workspaceId===Z)J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$.builder));else if($.type==="view-builder:deleted"&&$.workspaceId===Z)J.setQueryData(D1.viewBuilders(Z),(X)=>(X??[]).filter((Q)=>Q.id!==$.builderId))}),J5({queryKey:D1.viewBuilders(Z),queryFn:async()=>{return(await L0(`/api/workspaces/${Z}/view-builders`)).builders},...h9})}function DC(Z){let J=Z0();return r0({mutationFn:()=>L0(`/api/workspaces/${Z}/view-builders`,x5("POST"),"Failed to create view builder"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function PC(Z){let J=Z0();return r0({mutationFn:({builderId:$,requirements:X})=>L0(`/api/workspaces/${Z}/view-builders/${$}`,x5("PATCH",{input:{requirements:X}}),"Failed to save view requirements"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function OC(Z){let J=Z0();return r0({mutationFn:({builderId:$,requirements:X,...Q})=>L0(`/api/workspaces/${Z}/view-builders/${$}/submit`,x5("POST",{input:{requirements:X},availableIcons:YC,...Q}),"Failed to start view builder"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function wC(Z){let J=Z0();return r0({mutationFn:($)=>Z9(`/api/workspaces/${Z}/view-builders/${$}`,{method:"DELETE"},"Failed to discard view builder"),onSuccess:($,X)=>{J.setQueryData(D1.viewBuilders(Z),(Q)=>(Q??[]).filter((Y)=>Y.id!==X))}})}var jC=new Map;function Ld(Z){let J=jC.get(Z)??[];return jC.delete(Z),J}function Nd(Z,J,$){if(Z.startsWith("view:"))return J?.find((X)=>X.id===Z.slice(5))?.config.title||void 0;if(Z.startsWith("view-builder:"))return $?.find((X)=>X.id===Z.slice(13))?.title||void 0;return}function CC(){let Z=v5(),{layout:J}=w0(),$=_X(Z).data,X=yY(Z).data,Q=J.tabs.active;return TC.useCallback(()=>{let Y=Ld(Z);return{activeTab:Q,tabTitle:Nd(Q,$,X),...Y.length>0?{directives:Y}:{}}},[Z,Q,$,X])}var SC=!0;function bY({queryClient:Z,workspaceId:J,sessionId:$,parts:X}){let Q=`optimistic:${crypto.randomUUID()}`;return Z.setQueryData(D1.events(J,$),(Y)=>E3(Y??S3(),{kind:"turn",turn:{id:Q,role:"user",origin:{kind:"user-input"},parts:X,timestamp:new Date().toISOString()}})),H0.getState().setActivity(J,$,"running"),H0.getState().setError(J,$,null),Q}function xY(Z,J,$){let X=Z?.models,Q=!J||!X||X.some((z)=>z.value===J)?J:void 0,Y=X?.find((z)=>z.value===Q),G=$&&(!Y||(Y.supportedEffortLevels??[]).includes($))?$:void 0,H=SC&&Z?.supportsStreaming?!0:void 0;return{model:Q,effort:G,stream:H}}function _d(Z){return Z.filter((J)=>J.text.length>0).map((J)=>J.kind==="reasoning"?{type:"reasoning",text:J.text}:{type:"text",text:J.text})}function EC(Z){let J=_d(Z?.blocks??[]);if(J.length===0)return null;return{id:"live-preview",role:"assistant",origin:{kind:"user-input"},parts:J}}var Md=S3();function IC(){let Z=v5(),J=Z0(),{layout:$}=w0(),X=Z8(Z).data,Q=CC(),Y=O2((L)=>L.activeByWorkspace[Z]??null),H=O2((L)=>Y?L.activity[`${Z}:${Y}`]??"idle":"idle")==="running",z=O2((L)=>Y?L.errors[`${Z}:${Y}`]??null:null),W=EL(Z,Y).data??Md,V=O2((L)=>L.previews),K=W6.useMemo(()=>EC(uU(V,Z,Y).root),[V,Z,Y]),U=FX(Z,Y).data,q=W6.useCallback((L)=>{let M=L.trim(),P=(H0.getState().attachments[E9(Z,Y)]??[]).filter((S)=>S.status==="ready"&&S.upload);if(!M&&P.length===0)return;let D=Y,_=!1;if(!D)D=crypto.randomUUID(),_=!0,H0.getState().setActive(Z,D);let T=[];for(let S of P)if(S.upload?.kind==="image"&&S.previewUrl)T.push({type:"file",mediaType:S.mediaType,url:S.previewUrl,filename:S.name});else T.push({type:"file",mediaType:S.mediaType,url:"",filename:S.name});if(M)T.push({type:"text",text:M});let C=bY({queryClient:J,workspaceId:Z,sessionId:D,parts:T}),y=U?.model??$.selectedModel,j=U?.effort??$.selectedEffort,{model:g,effort:I,stream:E}=xY(X,y,j);if(L$({type:"chat",workspaceId:Z,content:M,sessionId:D,isNew:_,optimisticId:C,model:g,effort:I,stream:E,context:Q(),...P.length>0?{attachments:P.map((S)=>S.upload.id)}:{}}),_)J.invalidateQueries({queryKey:D1.preview(Z)});H0.getState().clearAttachments(Z,Y)},[Y,Z,J,$.selectedModel,$.selectedEffort,Q,U?.model,U?.effort,X]),B=W6.useCallback(()=>{if(!Y)return;H0.getState().setError(Z,Y,null)},[Y,Z]),F=W6.useCallback(()=>{if(!H||!Y)return;L$({type:"stop",workspaceId:Z,sessionId:Y})},[H,Y,Z]),N=W6.useCallback((L)=>{H0.getState().setActive(Z,L)},[Z]);return{view:W,previewTurn:K,sessionId:Y,processing:H,error:z,send:q,stop:F,switchThread:N,dismissError:B}}var U7=w(m(),1);var h0=w(a(),1);function kC({builder:Z,unavailableReason:J,onSave:$,onSubmit:X,onOpenChat:Q,onDiscard:Y}){let[G,H]=U7.useState(Z.input.requirements),[z,W]=U7.useState(!1),[V,K]=U7.useState(null),U=U7.useRef(null),q=U7.useRef($);q.current=$;let B=G.trim().length>0,F=QZ(B,z,J);U7.useEffect(()=>{if(Z.status!=="draft"||G===Z.input.requirements)return;let L=setTimeout(()=>{q.current(G).then(()=>K(null)).catch((M)=>K(M instanceof Error?M.message:"Could not save requirements"))},500);return()=>clearTimeout(L)},[Z.input.requirements,Z.status,G]);let N=async(L)=>{if(L.preventDefault(),!F)return;W(!0);try{await X(G)}catch(M){K(M instanceof Error?M.message:"Could not start view builder"),W(!1)}};if(Z.status==="draft")return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-3 py-6",children:h0.jsxs("div",{className:"flex w-full max-w-(--chat-max-container) flex-col gap-6",children:[h0.jsxs("div",{className:"flex flex-col gap-1 text-center",children:[h0.jsx("h1",{className:"font-medium",children:"What should this view do?"}),h0.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Describe the content, data, and actions you need."})]}),h0.jsxs(MX,{composerRef:U,onSubmit:N,children:[h0.jsx("label",{className:"sr-only",htmlFor:`view-builder-${Z.id}`,children:"View requirements"}),h0.jsx(AX,{textareaRef:U,id:`view-builder-${Z.id}`,value:G,onChange:(L)=>H(L.target.value),onKeyDown:(L)=>{if(L.key==="Enter"&&(L.metaKey||L.ctrlKey))L.preventDefault(),L.currentTarget.form?.requestSubmit()},placeholder:"Build a customer dashboard with…",rows:1,className:"min-h-16","aria-describedby":V?`view-builder-error-${Z.id}`:void 0,"aria-invalid":Boolean(V),autoFocus:!0}),h0.jsxs(DX,{children:[h0.jsx(JQ,{scope:"workspace"}),h0.jsx(PX,{label:"Build view",hasContent:B,loading:z,unavailableReason:J})]})]}),V&&h0.jsx("p",{id:`view-builder-error-${Z.id}`,role:"alert",className:"text-sm text-destructive",children:V})]})});if(Z.status==="waiting")return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:h0.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[h0.jsxs("div",{className:"flex flex-col gap-1",children:[h0.jsx("h1",{className:"text-lg font-semibold",children:"The view needs your attention"}),h0.jsx("p",{className:"text-sm text-muted-foreground",children:Z.error??"Open its chat to answer or ask the agent to continue."})]}),h0.jsxs("div",{className:"flex gap-2",children:[h0.jsx(E1,{onClick:Q,children:"Open chat"}),h0.jsx(E1,{variant:"secondary",onClick:Y,children:"Discard"})]})]})});return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:h0.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h0.jsx(Y2,{stroke:1.75,className:"animate-spin"}),Z.status==="ready"?"Opening view…":"Building your view…"]})})}function RC(){let Z=Z0(),{workspaceId:J,layout:$}=w0(),X=Z8(J).data,Q=DC(J),Y=PC(J),G=OC(J),H=wC(J);return{create:()=>Q.mutateAsync(),save:(U,q)=>Y.mutateAsync({builderId:U,requirements:q}),submit:async(U,q)=>{let B=q.trim();if(!B)return;let F=bY({queryClient:Z,workspaceId:J,sessionId:U.sessionId,parts:[{type:"text",text:B}]});H0.getState().setActive(J,U.sessionId);let{model:N,effort:L,stream:M}=xY(X,$.selectedModel,$.selectedEffort);try{await G.mutateAsync({builderId:U.id,requirements:B,optimisticId:F,model:N,effort:L,stream:M})}catch(A){throw H0.getState().setActivity(J,U.sessionId,"idle"),H0.getState().setError(J,U.sessionId,A instanceof Error?A.message:"Could not start view builder"),A}},discard:(U)=>H.mutateAsync(U)}}var o8=w(m(),1);function yC(Z){let J=document.documentElement,$=getComputedStyle(J).getPropertyValue(Z).trim(),X=Number.parseFloat($);if(!Number.isFinite(X))return 0;return $.endsWith("rem")?X*Number.parseFloat(getComputedStyle(J).fontSize):X}function bC(){let Z=o8.useRef(null),[J,$]=o8.useState(!1);return o8.useLayoutEffect(()=>{let X=Z.current;if(!X)return;let Q=(G)=>{let H=yC("--column-w"),z=yC("--chat-min");$(G-z>=H)};Q(X.getBoundingClientRect().width);let Y=new ResizeObserver(([G])=>{if(G)Q(G.contentRect.width)});return Y.observe(X),()=>Y.disconnect()},[]),{ref:Z,fits:J}}var hY=w(m(),1);var xC=["background","foreground"],oK="mei-fonts";function hC(Z,J){let $=Z?.font??"default",X=Z?.background,Q=Z?.foreground;hY.useEffect(()=>{let Y=J.current;if(!Y)return;let G=h8[$]??h8.default;Y.style.setProperty("--font-sans",G.sans),Y.style.setProperty("--font-mono",G.mono);let H=document.getElementById(oK);if(!G.googleFontsQuery)H?.remove();else{let z=`https://fonts.googleapis.com/css2?family=${G.googleFontsQuery}&display=swap`;if(H)H.href=z;else{let W=document.createElement("link");W.id=oK,W.rel="stylesheet",W.href=z,document.head.appendChild(W)}}return()=>{Y.style.removeProperty("--font-sans"),Y.style.removeProperty("--font-mono")}},[$,J]),hY.useEffect(()=>{let Y=J.current;if(!Y)return;let G={background:X,foreground:Q};for(let H of xC){let z=G[H];if(z)Y.style.setProperty(`--${H}`,z);else Y.style.removeProperty(`--${H}`)}return()=>{for(let H of xC)Y.style.removeProperty(`--${H}`)}},[X,Q,J]),hY.useEffect(()=>()=>document.getElementById(oK)?.remove(),[])}var l0=w(a(),1),Ad=gC([t3({variant:"ghost",size:"sm"}),"group/tab min-w-0"],{variants:{active:{true:"bg-accent text-accent-foreground"},dragging:{true:"invisible"},preview:{true:"cursor-grabbing ring-1 ring-border"}},compoundVariants:[{preview:!0}]});function Dd({items:Z}){return l0.jsxs(W8,{children:[l0.jsx(K8,{render:l0.jsx(E1,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Create tab",children:l0.jsx(a5,{stroke:1.75})})}),l0.jsx(c4,{align:"start",className:"min-w-48",children:l0.jsx(d4,{children:Z.map(({key:J,Icon:$,label:X,onClick:Q})=>l0.jsxs(HZ,{onClick:Q,className:"font-medium",children:[l0.jsx($,{stroke:2}),X]},J))})})]})}function vC(Z){let{tab:J,active:$}=Z,X=Z.preview===!0;return l0.jsxs("button",{type:"button","aria-hidden":X||void 0,"aria-label":J.label,disabled:X,tabIndex:X?-1:void 0,onClick:Z.preview?void 0:()=>Z.onSelect(J.key),className:Ad({active:$,dragging:Z.preview?!1:Z.state.isDragging,preview:X}),...Z.preview?{}:Z.state.dragHandleProps,children:[l0.jsxs("div",{className:N1("flex items-center gap-1 overflow-hidden",J.closable&&"group-hover/tab:mr-3"),children:[l0.jsx(J.Icon,{"data-icon":"inline-start",stroke:2}),l0.jsx("span",{className:N1("truncate",J.closable&&"group-hover/tab:-mr-3 group-hover/tab:mask-r-from-[calc(100%-24px)] group-hover/tab:mask-r-to-[calc(100%-12px)]"),children:J.label})]}),J.closable&&l0.jsx("div",{"aria-label":`Close ${J.label}`,tabIndex:X?-1:void 0,className:N1("absolute right-2 hidden size-3 items-center justify-center text-muted-foreground group-hover/tab:flex hover:text-foreground",X&&"pointer-events-none"),onClick:Z.preview?void 0:(Q)=>{Q.stopPropagation(),Z.onClose(J.key)},children:l0.jsx(X9,{stroke:1.75})})]})}function mC({tabs:Z,active:J,createItems:$,onSelect:X,onClose:Q,onReorder:Y}){return l0.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[l0.jsx("div",{className:"no-scrollbar min-w-0 scroll-fade-x overflow-x-auto overflow-y-hidden [--scroll-fade-reveal:16px]",children:l0.jsx($X,{items:Z,getId:(G)=>G.key,className:"flex w-max items-center gap-1",onReorder:(G)=>Y(G),renderPlaceholder:()=>l0.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-xs bg-muted"}),renderOverlay:(G)=>l0.jsx(vC,{tab:G,active:J===G.key,preview:!0}),renderItem:(G,H)=>l0.jsx(vC,{tab:G,active:J===G.key,state:H,onSelect:X,onClose:Q})})}),l0.jsx("div",{className:"shrink-0",children:l0.jsx(Dd,{items:$})})]})}var a1=w(a(),1),Pd=J2.lazy(()=>import("/chunk-1dfbr7n2.js").then((Z)=>({default:Z.Scratchpad}))),cC=(Z)=>Z.config.title||Z.id,dC=(Z)=>EY(Z.icon)??eK;function lC(Z,J){let $=J.find((X)=>X.viewId===Z.id);return EY(Z.config.icon)??EY($?.icon)??eK}var gY=hH(),fC=(Z)=>`view:${Z}`,$V=(Z)=>Z.startsWith("view:")?Z.slice(5):null,vY=(Z)=>`view-builder:${Z}`,JJ=(Z)=>Z.startsWith("view-builder:")?Z.slice(13):null;function Od({mode:Z,onToggleMode:J}){return a1.jsx(E1,{variant:"ghost",size:"icon-sm",onClick:J,"aria-label":Z==="fullscreen"?"Switch to split view":"Switch to full-screen view",children:a1.jsx(uC,{stroke:1.75})})}function wd({view:Z}){let J=v5(),$=vL(Z.id);return a1.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:a1.jsxs(d9,{mode:"wait",initial:!1,children:[$.status==="ready"&&a1.jsx(YY,{asChild:!0,segment:"views",name:Z.id,version:$.version,children:a1.jsx(n0.div,{className:"absolute inset-0 overflow-auto",initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:{duration:0.3,ease:"easeInOut"},children:a1.jsx(xZ,{name:Z.id,kind:"view",workspaceId:J,resetKey:$.version,children:a1.jsx($.Component,{})})})},$.version),$.status==="error"&&a1.jsx(n0.p,{className:"absolute inset-0 p-4 text-xs text-destructive",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0.3,ease:"easeInOut"},children:$.error},`err-${$.version}`)]})})}function jd({active:Z,onToggle:J}){return a1.jsxs(T9,{children:[a1.jsx(C9,{render:a1.jsx(E1,{variant:Z?"secondary":"ghost",size:"icon-sm","aria-label":"Customize","aria-pressed":Z,onClick:J,children:a1.jsx(SY,{stroke:1.75})})}),a1.jsx(S9,{children:"Customize"})]})}function Td(Z){if(!Z||!Array.isArray(Z.open))return gY;let J=Z.open.filter(($,X,Q)=>Q.indexOf($)===X);if(J.length===0)return gY;return{open:J,active:J.includes(Z.active)?Z.active:J[0]}}function tK(Z,J,$){if(Z==="agent"||Z==="widgets"||Z==="scratchpad")return!0;let X=JJ(Z);if(X)return $.some((Y)=>Y.id===X);let Q=$V(Z);return Q?J.some((Y)=>Y.id===Q):!1}function Cd(Z,J,$,X){if(Z==="agent")return{key:Z,Icon:Y6,label:"Agent",closable:X};if(Z==="widgets")return{key:Z,Icon:ZV,label:"Widgets",closable:X};if(Z==="scratchpad")return{key:Z,Icon:JV,label:"Scratchpad",closable:X};let Q=JJ(Z),Y=Q?$.find((z)=>z.id===Q):null;if(Y)return{key:Z,Icon:dC(Y),label:Y.title||Y.viewId||"New view",closable:X};let G=$V(Z),H=G?J.find((z)=>z.id===G):null;return H?{key:Z,Icon:lC(H,$),label:cC(H),closable:X}:null}function Sd(Z,J,$){let X=new Set(J),Q=0;return Z.map((Y)=>X.has(Y)?$[Q++]:Y)}function iC({widgets:Z,views:J,builders:$}){let{view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,send:z,stop:W,switchThread:V,dismissError:K}=IC(),{layout:U,setLayout:q,name:B,icon:F,provider:N,workspaceId:L}=w0(),M=fL(L).data,A=M===void 0?void 0:M.available?null:M.reason,P=RC(),{ref:D,fits:_}=bC(),[T,C]=J2.useState("idle"),[y,j]=J2.useState(!1),[g,I]=J2.useState(0),E=J2.useRef(null);hC(U.theme,E);let S=Td(U.tabs),b=J2.useRef(S);b.current=S;let R=S.open.filter((c)=>tK(c,J,$)),x=R.length>0?R:gY.open,h=new Set(S.open),d=x.filter((c)=>c!=="agent"),O=d.length>0,Z1=U.layoutMode==="split"&&O&&_?"split":"fullscreen",k=Z1==="split",e=(c)=>{if(c==="split"&&S.active==="agent"){q({layoutMode:c,tabs:{open:S.open,active:d[0]??S.active}});return}q({layoutMode:c})},_1=k?d:x,u=_1.includes(S.active)?S.active:_1[0]??"agent",z1=x.length>1,V1=_1.map((c)=>Cd(c,J,$,z1||JJ(c)!==null)).filter((c)=>Boolean(c)),$1=$V(u),G1=$1?J.find((c)=>c.id===$1):void 0,U1=JJ(u),f=U1?$.find((c)=>c.id===U1):void 0;J2.useEffect(()=>{let c=S.open.filter((I1)=>tK(I1,J,$));if(c.length===S.open.length)return;let F1=c.length>0?c:gY.open;q({tabs:{open:F1,active:F1.includes(S.active)?S.active:F1[0]}})},[$,q,S.active,S.open,J]),J2.useEffect(()=>{let c=new Map;for(let s of $){if(s.status!=="ready"||!s.viewId)continue;if(!J.some((q1)=>q1.id===s.viewId))continue;c.set(vY(s.id),fC(s.viewId))}if(c.size===0)return;let F1=new Set(c.values()),I1=new Map([...c].map(([s,q1])=>[q1,s])),f1=[],v=!1;for(let s of S.open){let q1=I1.get(s);if(F1.has(s)&&q1&&S.open.includes(q1)){v=!0;continue}let w1=c.get(s),h1=w1??s;if(w1)v=!0;if(!f1.includes(h1))f1.push(h1)}if(!v)return;let p=c.get(S.active)??S.active;q({tabs:{open:f1.length>0?f1:["agent"],active:p}})},[$,q,S.active,S.open,J]),J2.useEffect(()=>{let c=f??$.find((F1)=>F1.viewId===$1);if(c)H0.getState().setActive(L,c.sessionId)},[f,$1,$,L]),J2.useEffect(()=>{if(Z1!=="fullscreen"||u==="agent")j(!1)},[u,Z1]);let o=(c)=>{b.current=c,q({tabs:c})},n=(c)=>{let F1=b.current,I1=F1.open.includes(c)?F1.open:[...F1.open,c];if(o({open:I1,active:c}),c==="agent")j(!1),I((f1)=>f1+1)},M1=(c)=>{let F1=JJ(c),I1=F1?$.find((p)=>p.id===F1):void 0;if(!z1&&!I1||!h.has(c))return;let f1=S.open.filter((p)=>p!==c);if(f1.length===0)f1=["agent"];let v=S.active;if(v===c||!f1.includes(v)){let p=_1.indexOf(c);v=_1[p+1]??_1[p-1]??f1.find((s)=>tK(s,J,$))??"agent"}if(o({open:f1,active:v}),I1?.status==="draft")P.discard(I1.id)},l=(c)=>{let F1=vY(c.id);if(h.has(F1)){let I1=S.open.filter((f1)=>f1!==F1);if(I1.length===0)I1=["agent"];o({open:I1,active:S.active===F1?I1[0]:S.active})}P.discard(c.id)},W1=(c)=>{let F1=Sd(S.open,_1,c);if(F1===S.open)return;o({open:F1,active:S.active})},i=(c)=>{if(c!==void 0)H0.getState().setDraft(L,Y,c);if(Z1==="fullscreen"&&u!=="agent"){if(j(!0),y)I((F1)=>F1+1);return}I((F1)=>F1+1)},t=[...!k&&!h.has("agent")?[{key:"agent",Icon:Y6,label:"Agent",onClick:()=>n("agent")}]:[],...!h.has("widgets")?[{key:"widgets",Icon:ZV,label:"Widgets",onClick:()=>n("widgets")}]:[],...!h.has("scratchpad")?[{key:"scratchpad",Icon:JV,label:"Scratchpad",onClick:()=>n("scratchpad")}]:[],...J.map((c)=>({view:c,tab:fC(c.id)})).filter(({tab:c})=>!h.has(c)).map(({view:c,tab:F1})=>({key:F1,Icon:lC(c,$),label:cC(c),onClick:()=>n(F1)})),...$.filter((c)=>c.status!=="ready").map((c)=>({builder:c,tab:vY(c.id)})).filter(({tab:c})=>!h.has(c)).map(({builder:c,tab:F1})=>({key:F1,Icon:dC(c),label:c.title||c.viewId||"New view",onClick:()=>n(F1)})),{key:"create-view",Icon:pC,label:"New view",onClick:()=>{P.create().then((c)=>n(vY(c.id)))}}],H1=a1.jsx(oQ,{active:Z1==="split",focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V}),r=a1.jsx(oQ,{active:Z1==="fullscreen"&&u==="agent",focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V});return a1.jsxs("div",{ref:E,className:"relative flex h-full min-h-0 flex-col bg-background font-sans text-foreground",children:[a1.jsxs("div",{ref:D,className:"flex min-h-0 flex-1",children:[(Z1==="fullscreen"||O)&&a1.jsxs("div",{className:N1("flex min-h-0 flex-1 flex-col",Z1==="split"&&"min-w-(--column-w)"),children:[a1.jsxs(ow,{children:[a1.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[a1.jsxs("div",{className:"flex items-center gap-2",children:[a1.jsx("img",{src:F??$9[N??"claude-code"],alt:"",className:"size-5 shrink-0 rounded-[4px]"}),B&&a1.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:B})]}),a1.jsx(mC,{tabs:V1,active:u,createItems:t,onSelect:n,onClose:M1,onReorder:W1})]}),a1.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a1.jsx(jd,{active:T==="customizing",onToggle:()=>C(T==="customizing"?"idle":"customizing")}),a1.jsx(AC,{}),O&&_&&a1.jsx(Od,{mode:Z1,onToggleMode:()=>e(Z1==="fullscreen"?"split":"fullscreen")})]})]}),u==="agent"?r:u==="widgets"?a1.jsx(nw,{editing:T==="editing",onEditingChange:(c)=>C(c?"editing":"idle"),widgets:Z,onCreateWidget:()=>i("Create widget")}):u==="scratchpad"?a1.jsx(J2.Suspense,{fallback:null,children:a1.jsx(Pd,{})}):f?a1.jsx(kC,{builder:f,unavailableReason:A,onSave:(c)=>P.save(f.id,c),onSubmit:(c)=>{if(Z1==="fullscreen")j(!0);return P.submit(f,c)},onOpenChat:()=>{H0.getState().setActive(L,f.sessionId),i()},onDiscard:()=>l(f)},f.id):G1?a1.jsx(wd,{view:G1}):null]}),Z1==="split"&&a1.jsx("div",{className:N1("flex min-h-0 min-w-(--chat-min) flex-[0_1_var(--chat-max)] flex-col overflow-hidden border-l border-border"),children:H1})]}),a1.jsx(d9,{children:T==="customizing"&&a1.jsx(AO,{})}),Z1==="fullscreen"&&u!=="agent"&&O&&a1.jsx(LO,{open:y,onOpenChange:j,onOpenChangeComplete:(c)=>{if(c)I((F1)=>F1+1)},container:E,children:(c)=>a1.jsx(oQ,{active:y,focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V,onClose:c})})]})}var mY=w(m(),1);function rC(Z,J,$,X){let Q=mY.useRef(null);mY.useEffect(()=>{if(!J)return;let Y=new Map(J.map((q)=>[q.id,{w:q.config.colSpan,h:q.config.rowSpan}]));if(Q.current?.workspaceId!==Z){Q.current={workspaceId:Z,sizes:Y};return}let G=Q.current.sizes,H=new Set($.widgetGrid.map((q)=>q.i)),z=J.filter((q)=>{if(!G.has(q.id))return!H.has(q.id);if(!H.has(q.id))return!1;let F=G.get(q.id);return F.w!==q.config.colSpan||F.h!==q.config.rowSpan});if(Q.current={workspaceId:Z,sizes:Y},z.length===0)return;let W=new Map(J.map((q)=>[q.id,q.config])),V=$.widgetGrid.filter((q)=>!z.some((B)=>B.id===q.i)&&W.has(q.i)).map((q)=>{let B=W.get(q.i);return{i:q.i,x:q.x,y:q.y,w:B.colSpan,h:B.rowSpan}}),K=V.map(({i:q,x:B,y:F})=>({i:q,x:B,y:F})),U=[...V];for(let q of z){let B=hZ(U,q.config.colSpan,q.config.rowSpan,4);K.push({i:q.id,x:B.x,y:B.y}),U.push({i:q.id,x:B.x,y:B.y,w:q.config.colSpan,h:q.config.rowSpan})}X({widgetGrid:K})},[Z,J,$.widgetGrid,X])}var E2=w(a(),1);function oC({id:Z}){return E2.jsx(sC,{id:Z,children:E2.jsx(iL,{id:Z,children:E2.jsx(Ed,{id:Z})})})}function Ed({id:Z}){let J=Z0(),{layout:$,setLayout:X,isLoading:Q}=w0(),Y=pL(Z),G=_X(Z),H=yY(Z),z=BX(Z);rC(Z,Y.data,$,X),gL(),Y9((V)=>{if(V.type==="theme:updated"||V.type==="workspace:updated")J.invalidateQueries({queryKey:D1.layout(Z)});else if(V.type==="widget-layout:updated"||V.type==="widget:updated")J.invalidateQueries({queryKey:D1.widgets(Z)});else if(V.type==="view-layout:updated")J.invalidateQueries({queryKey:D1.views(Z)})});let W=Q||Y.isLoading||G.isLoading||H.isLoading;return E2.jsxs(E2.Fragment,{children:[E2.jsx(Id,{workspaceId:Z,sessions:z.data}),E2.jsx(XX,{children:W?E2.jsx("div",{className:"flex h-full items-center justify-center",children:E2.jsx(aC,{sprite:"moi",effect:"chaos"})}):E2.jsx(iC,{widgets:Y.data??[],views:G.data??[],builders:H.data??[]})})]})}function Id({workspaceId:Z,sessions:J}){return nC.useEffect(()=>{if(!J)return;let $=H0.getState().activeByWorkspace[Z]??null;if(!($&&J.some((Q)=>Q.sessionId===$)))H0.getState().setActive(Z,J[0]?.sessionId??null)},[Z,J]),null}var B7=w(a(),1),kd=t8.lazy(()=>import("/chunk-qwm5f6qk.js"));function Rd(){return B7.jsx(t8.Suspense,{fallback:null,children:B7.jsx(kd,{})})}function eC(){let[,Z]=y9();return t8.useEffect(()=>{return YH((J)=>Z(`/workspace/${J}`)),()=>YH(null)},[Z]),B7.jsxs(tC,{children:[B7.jsx(fY,{path:"/",component:SL}),B7.jsx(fY,{path:"/dev/*?",component:Rd}),B7.jsx(fY,{path:"/workspace/:id",children:(J)=>B7.jsx(oC,{id:J.id},J.id)})]})}var K6=w(a(),1),$S=new ZG;sU($S);gU();function EC1(Z){function J(){return K6.jsx($G,{client:$S,children:K6.jsxs(bU,{children:[K6.jsx(ZS,{children:K6.jsx(eC,{})}),!1]})})}JS.createRoot(Z).render(K6.jsx(J,{}))}export{EC1 as mount};
|
|
63
|
+
This only removes it from your list. The folder and its sessions stay on disk. You can add it back any time.`;if(!window.confirm(U))return;G.mutate(X,{onSuccess:()=>Q("/")})},disabled:G.isPending,children:[G.isPending&&I5.jsx(Y2,{"data-icon":"inline-start",stroke:1.75,className:"animate-spin"}),"Remove"]})}),G.isError&&I5.jsx("p",{className:"px-3.5 py-3 text-xs text-destructive",children:G.error.message})]})]})}var x0=w(a(),1),Fd=[{id:"general",label:"General",icon:eZ},{id:"connectors",label:"Connectors",icon:OY},{id:"environment",label:"Environment",icon:CY}];function AC(){let[Z,J]=nK.useState(!1),[$,X]=nK.useState("general");return x0.jsxs(x0.Fragment,{children:[x0.jsxs(T9,{children:[x0.jsx(C9,{render:x0.jsx(E1,{variant:"ghost",size:"icon-sm","aria-label":"Space settings",onClick:()=>J(!0),children:x0.jsx(eZ,{stroke:1.75})})}),x0.jsx(S9,{children:"Space settings"})]}),x0.jsx(p6,{open:Z,onOpenChange:J,children:x0.jsxs(S$,{className:"flex h-[min(680px,90vh)] w-[880px] max-w-[94vw]",children:[x0.jsx(u6,{className:"sr-only",children:"Space settings"}),x0.jsxs("nav",{className:"flex w-48 shrink-0 flex-col gap-0.5 border-r border-border bg-muted/30 p-3",children:[x0.jsx("p",{className:"px-2.5 pt-4 pb-2 text-[11px] font-semibold tracking-wider text-muted-foreground/80 uppercase",children:"Settings"}),Fd.map((Q)=>x0.jsxs(E1,{type:"button",variant:$===Q.id?"secondary":"ghost",size:"sm",onClick:()=>X(Q.id),className:"justify-start",children:[x0.jsx(Q.icon,{stroke:1.75}),Q.label]},Q.id))]}),x0.jsxs("div",{className:"relative scrollbar-thin min-w-0 flex-1 overflow-y-auto",children:[x0.jsx(C$,{render:x0.jsx(E1,{variant:"ghost",size:"icon","aria-label":"Close",className:"absolute top-3 right-3 z-10",children:x0.jsx(X9,{stroke:1.5})})}),x0.jsxs("div",{className:"px-8 py-7",children:[$==="general"&&x0.jsx(MC,{}),$==="connectors"&&x0.jsx(Wj,{}),$==="environment"&&x0.jsx(Nj,{})]})]})]})})]})}var W6=w(m(),1);var TC=w(m(),1);function RY(Z,J){let $=Z??[];if($.findIndex((Q)=>Q.id===J.id)===-1)return[...$,J];return $.map((Q)=>Q.id===J.id&&Q.updatedAt<=J.updatedAt?J:Q)}function yY(Z){let J=Z0();return Y9(($)=>{if($.type==="view-builder:updated"&&$.workspaceId===Z)J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$.builder));else if($.type==="view-builder:deleted"&&$.workspaceId===Z)J.setQueryData(D1.viewBuilders(Z),(X)=>(X??[]).filter((Q)=>Q.id!==$.builderId))}),J5({queryKey:D1.viewBuilders(Z),queryFn:async()=>{return(await L0(`/api/workspaces/${Z}/view-builders`)).builders},...h9})}function DC(Z){let J=Z0();return r0({mutationFn:()=>L0(`/api/workspaces/${Z}/view-builders`,x5("POST"),"Failed to create view builder"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function PC(Z){let J=Z0();return r0({mutationFn:({builderId:$,requirements:X})=>L0(`/api/workspaces/${Z}/view-builders/${$}`,x5("PATCH",{input:{requirements:X}}),"Failed to save view requirements"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function OC(Z){let J=Z0();return r0({mutationFn:({builderId:$,requirements:X,...Q})=>L0(`/api/workspaces/${Z}/view-builders/${$}/submit`,x5("POST",{input:{requirements:X},availableIcons:YC,...Q}),"Failed to start view builder"),onSuccess:($)=>{J.setQueryData(D1.viewBuilders(Z),(X)=>RY(X,$))}})}function wC(Z){let J=Z0();return r0({mutationFn:($)=>Z9(`/api/workspaces/${Z}/view-builders/${$}`,{method:"DELETE"},"Failed to discard view builder"),onSuccess:($,X)=>{J.setQueryData(D1.viewBuilders(Z),(Q)=>(Q??[]).filter((Y)=>Y.id!==X))}})}var jC=new Map;function Ld(Z){let J=jC.get(Z)??[];return jC.delete(Z),J}function Nd(Z,J,$){if(Z.startsWith("view:"))return J?.find((X)=>X.id===Z.slice(5))?.config.title||void 0;if(Z.startsWith("view-builder:"))return $?.find((X)=>X.id===Z.slice(13))?.title||void 0;return}function CC(){let Z=v5(),{layout:J}=w0(),$=_X(Z).data,X=yY(Z).data,Q=J.tabs.active;return TC.useCallback(()=>{let Y=Ld(Z);return{activeTab:Q,tabTitle:Nd(Q,$,X),...Y.length>0?{directives:Y}:{}}},[Z,Q,$,X])}var SC=!0;function bY({queryClient:Z,workspaceId:J,sessionId:$,parts:X}){let Q=`optimistic:${crypto.randomUUID()}`;return Z.setQueryData(D1.events(J,$),(Y)=>E3(Y??S3(),{kind:"turn",turn:{id:Q,role:"user",origin:{kind:"user-input"},parts:X,timestamp:new Date().toISOString()}})),H0.getState().setActivity(J,$,"running"),H0.getState().setError(J,$,null),Q}function xY(Z,J,$){let X=Z?.models,Q=!J||!X||X.some((z)=>z.value===J)?J:void 0,Y=X?.find((z)=>z.value===Q),G=$&&(!Y||(Y.supportedEffortLevels??[]).includes($))?$:void 0,H=SC&&Z?.supportsStreaming?!0:void 0;return{model:Q,effort:G,stream:H}}function _d(Z){return Z.filter((J)=>J.text.length>0).map((J)=>J.kind==="reasoning"?{type:"reasoning",text:J.text}:{type:"text",text:J.text})}function EC(Z){let J=_d(Z?.blocks??[]);if(J.length===0)return null;return{id:"live-preview",role:"assistant",origin:{kind:"user-input"},parts:J}}var Md=S3();function IC(){let Z=v5(),J=Z0(),{layout:$}=w0(),X=Z8(Z).data,Q=CC(),Y=O2((L)=>L.activeByWorkspace[Z]??null),H=O2((L)=>Y?L.activity[`${Z}:${Y}`]??"idle":"idle")==="running",z=O2((L)=>Y?L.errors[`${Z}:${Y}`]??null:null),W=EL(Z,Y).data??Md,V=O2((L)=>L.previews),K=W6.useMemo(()=>EC(uU(V,Z,Y).root),[V,Z,Y]),U=FX(Z,Y).data,q=W6.useCallback((L)=>{let M=L.trim(),P=(H0.getState().attachments[E9(Z,Y)]??[]).filter((S)=>S.status==="ready"&&S.upload);if(!M&&P.length===0)return;let D=Y,_=!1;if(!D)D=crypto.randomUUID(),_=!0,H0.getState().setActive(Z,D);let T=[];for(let S of P)if(S.upload?.kind==="image"&&S.previewUrl)T.push({type:"file",mediaType:S.mediaType,url:S.previewUrl,filename:S.name});else T.push({type:"file",mediaType:S.mediaType,url:"",filename:S.name});if(M)T.push({type:"text",text:M});let C=bY({queryClient:J,workspaceId:Z,sessionId:D,parts:T}),y=U?.model??$.selectedModel,j=U?.effort??$.selectedEffort,{model:g,effort:I,stream:E}=xY(X,y,j);if(L$({type:"chat",workspaceId:Z,content:M,sessionId:D,isNew:_,optimisticId:C,model:g,effort:I,stream:E,context:Q(),...P.length>0?{attachments:P.map((S)=>S.upload.id)}:{}}),_)J.invalidateQueries({queryKey:D1.preview(Z)});H0.getState().clearAttachments(Z,Y)},[Y,Z,J,$.selectedModel,$.selectedEffort,Q,U?.model,U?.effort,X]),B=W6.useCallback(()=>{if(!Y)return;H0.getState().setError(Z,Y,null)},[Y,Z]),F=W6.useCallback(()=>{if(!H||!Y)return;L$({type:"stop",workspaceId:Z,sessionId:Y})},[H,Y,Z]),N=W6.useCallback((L)=>{H0.getState().setActive(Z,L)},[Z]);return{view:W,previewTurn:K,sessionId:Y,processing:H,error:z,send:q,stop:F,switchThread:N,dismissError:B}}var U7=w(m(),1);var h0=w(a(),1);function kC({builder:Z,unavailableReason:J,onSave:$,onSubmit:X,onOpenChat:Q,onDiscard:Y}){let[G,H]=U7.useState(Z.input.requirements),[z,W]=U7.useState(!1),[V,K]=U7.useState(null),U=U7.useRef(null),q=U7.useRef($);q.current=$;let B=G.trim().length>0,F=QZ(B,z,J);U7.useEffect(()=>{if(Z.status!=="draft"||G===Z.input.requirements)return;let L=setTimeout(()=>{q.current(G).then(()=>K(null)).catch((M)=>K(M instanceof Error?M.message:"Could not save requirements"))},500);return()=>clearTimeout(L)},[Z.input.requirements,Z.status,G]);let N=async(L)=>{if(L.preventDefault(),!F)return;W(!0);try{await X(G)}catch(M){K(M instanceof Error?M.message:"Could not start view builder"),W(!1)}};if(Z.status==="draft")return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-3 py-6",children:h0.jsxs("div",{className:"flex w-full max-w-(--chat-max-container) flex-col gap-6",children:[h0.jsxs("div",{className:"flex flex-col gap-1 text-center",children:[h0.jsx("h1",{className:"font-medium",children:"What should this view do?"}),h0.jsx("p",{className:"mx-auto max-w-sm text-sm text-muted-foreground",children:"Describe the content, data, and actions you need."})]}),h0.jsxs(MX,{composerRef:U,onSubmit:N,children:[h0.jsx("label",{className:"sr-only",htmlFor:`view-builder-${Z.id}`,children:"View requirements"}),h0.jsx(AX,{textareaRef:U,id:`view-builder-${Z.id}`,value:G,onChange:(L)=>H(L.target.value),onKeyDown:(L)=>{if(L.key==="Enter"&&(L.metaKey||L.ctrlKey))L.preventDefault(),L.currentTarget.form?.requestSubmit()},placeholder:"Build a customer dashboard with…",rows:1,className:"min-h-16","aria-describedby":V?`view-builder-error-${Z.id}`:void 0,"aria-invalid":Boolean(V),autoFocus:!0}),h0.jsxs(DX,{children:[h0.jsx(JQ,{scope:"workspace"}),h0.jsx(PX,{label:"Build view",hasContent:B,loading:z,unavailableReason:J})]})]}),V&&h0.jsx("p",{id:`view-builder-error-${Z.id}`,role:"alert",className:"text-sm text-destructive",children:V})]})});if(Z.status==="waiting")return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:h0.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[h0.jsxs("div",{className:"flex flex-col gap-1",children:[h0.jsx("h1",{className:"text-lg font-semibold",children:"The view needs your attention"}),h0.jsx("p",{className:"text-sm text-muted-foreground",children:Z.error??"Open its chat to answer or ask the agent to continue."})]}),h0.jsxs("div",{className:"flex gap-2",children:[h0.jsx(E1,{onClick:Q,children:"Open chat"}),h0.jsx(E1,{variant:"secondary",onClick:Y,children:"Discard"})]})]})});return h0.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:h0.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[h0.jsx(Y2,{stroke:1.75,className:"animate-spin"}),Z.status==="ready"?"Opening view…":"Building your view…"]})})}function RC(){let Z=Z0(),{workspaceId:J,layout:$}=w0(),X=Z8(J).data,Q=DC(J),Y=PC(J),G=OC(J),H=wC(J);return{create:()=>Q.mutateAsync(),save:(U,q)=>Y.mutateAsync({builderId:U,requirements:q}),submit:async(U,q)=>{let B=q.trim();if(!B)return;let F=bY({queryClient:Z,workspaceId:J,sessionId:U.sessionId,parts:[{type:"text",text:B}]});H0.getState().setActive(J,U.sessionId);let{model:N,effort:L,stream:M}=xY(X,$.selectedModel,$.selectedEffort);try{await G.mutateAsync({builderId:U.id,requirements:B,optimisticId:F,model:N,effort:L,stream:M})}catch(A){throw H0.getState().setActivity(J,U.sessionId,"idle"),H0.getState().setError(J,U.sessionId,A instanceof Error?A.message:"Could not start view builder"),A}},discard:(U)=>H.mutateAsync(U)}}var o8=w(m(),1);function yC(Z){let J=document.documentElement,$=getComputedStyle(J).getPropertyValue(Z).trim(),X=Number.parseFloat($);if(!Number.isFinite(X))return 0;return $.endsWith("rem")?X*Number.parseFloat(getComputedStyle(J).fontSize):X}function bC(){let Z=o8.useRef(null),[J,$]=o8.useState(!1);return o8.useLayoutEffect(()=>{let X=Z.current;if(!X)return;let Q=(G)=>{let H=yC("--column-w"),z=yC("--chat-min");$(G-z>=H)};Q(X.getBoundingClientRect().width);let Y=new ResizeObserver(([G])=>{if(G)Q(G.contentRect.width)});return Y.observe(X),()=>Y.disconnect()},[]),{ref:Z,fits:J}}var hY=w(m(),1);var xC=["background","foreground"],oK="mei-fonts";function hC(Z,J){let $=Z?.font??"default",X=Z?.background,Q=Z?.foreground;hY.useEffect(()=>{let Y=J.current;if(!Y)return;let G=h8[$]??h8.default;Y.style.setProperty("--font-sans",G.sans),Y.style.setProperty("--font-mono",G.mono);let H=document.getElementById(oK);if(!G.googleFontsQuery)H?.remove();else{let z=`https://fonts.googleapis.com/css2?family=${G.googleFontsQuery}&display=swap`;if(H)H.href=z;else{let W=document.createElement("link");W.id=oK,W.rel="stylesheet",W.href=z,document.head.appendChild(W)}}return()=>{Y.style.removeProperty("--font-sans"),Y.style.removeProperty("--font-mono")}},[$,J]),hY.useEffect(()=>{let Y=J.current;if(!Y)return;let G={background:X,foreground:Q};for(let H of xC){let z=G[H];if(z)Y.style.setProperty(`--${H}`,z);else Y.style.removeProperty(`--${H}`)}return()=>{for(let H of xC)Y.style.removeProperty(`--${H}`)}},[X,Q,J]),hY.useEffect(()=>()=>document.getElementById(oK)?.remove(),[])}var l0=w(a(),1),Ad=gC([t3({variant:"ghost",size:"sm"}),"group/tab min-w-0"],{variants:{active:{true:"bg-accent text-accent-foreground"},dragging:{true:"invisible"},preview:{true:"cursor-grabbing ring-1 ring-border"}},compoundVariants:[{preview:!0}]});function Dd({items:Z}){return l0.jsxs(W8,{children:[l0.jsx(K8,{render:l0.jsx(E1,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground","aria-label":"Create tab",children:l0.jsx(a5,{stroke:1.75})})}),l0.jsx(c4,{align:"start",className:"min-w-48",children:l0.jsx(d4,{children:Z.map(({key:J,Icon:$,label:X,onClick:Q})=>l0.jsxs(HZ,{onClick:Q,className:"font-medium",children:[l0.jsx($,{stroke:2}),X]},J))})})]})}function vC(Z){let{tab:J,active:$}=Z,X=Z.preview===!0;return l0.jsxs("button",{type:"button","aria-hidden":X||void 0,"aria-label":J.label,disabled:X,tabIndex:X?-1:void 0,onClick:Z.preview?void 0:()=>Z.onSelect(J.key),className:Ad({active:$,dragging:Z.preview?!1:Z.state.isDragging,preview:X}),...Z.preview?{}:Z.state.dragHandleProps,children:[l0.jsxs("div",{className:N1("flex items-center gap-1 overflow-hidden",J.closable&&"group-hover/tab:mr-3"),children:[l0.jsx(J.Icon,{"data-icon":"inline-start",stroke:2}),l0.jsx("span",{className:N1("truncate",J.closable&&"group-hover/tab:-mr-3 group-hover/tab:mask-r-from-[calc(100%-24px)] group-hover/tab:mask-r-to-[calc(100%-12px)]"),children:J.label})]}),J.closable&&l0.jsx("div",{"aria-label":`Close ${J.label}`,tabIndex:X?-1:void 0,className:N1("absolute right-2 hidden size-3 items-center justify-center text-muted-foreground group-hover/tab:flex hover:text-foreground",X&&"pointer-events-none"),onClick:Z.preview?void 0:(Q)=>{Q.stopPropagation(),Z.onClose(J.key)},children:l0.jsx(X9,{stroke:1.75})})]})}function mC({tabs:Z,active:J,createItems:$,onSelect:X,onClose:Q,onReorder:Y}){return l0.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[l0.jsx("div",{className:"no-scrollbar min-w-0 scroll-fade-x overflow-x-auto overflow-y-hidden [--scroll-fade-reveal:16px]",children:l0.jsx($X,{items:Z,getId:(G)=>G.key,className:"flex w-max items-center gap-1",onReorder:(G)=>Y(G),renderPlaceholder:()=>l0.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-xs bg-muted"}),renderOverlay:(G)=>l0.jsx(vC,{tab:G,active:J===G.key,preview:!0}),renderItem:(G,H)=>l0.jsx(vC,{tab:G,active:J===G.key,state:H,onSelect:X,onClose:Q})})}),l0.jsx("div",{className:"shrink-0",children:l0.jsx(Dd,{items:$})})]})}var a1=w(a(),1),Pd=J2.lazy(()=>import("/chunk-fh2mf6v9.js").then((Z)=>({default:Z.Scratchpad}))),cC=(Z)=>Z.config.title||Z.id,dC=(Z)=>EY(Z.icon)??eK;function lC(Z,J){let $=J.find((X)=>X.viewId===Z.id);return EY(Z.config.icon)??EY($?.icon)??eK}var gY=hH(),fC=(Z)=>`view:${Z}`,$V=(Z)=>Z.startsWith("view:")?Z.slice(5):null,vY=(Z)=>`view-builder:${Z}`,JJ=(Z)=>Z.startsWith("view-builder:")?Z.slice(13):null;function Od({mode:Z,onToggleMode:J}){return a1.jsx(E1,{variant:"ghost",size:"icon-sm",onClick:J,"aria-label":Z==="fullscreen"?"Switch to split view":"Switch to full-screen view",children:a1.jsx(uC,{stroke:1.75})})}function wd({view:Z}){let J=v5(),$=vL(Z.id);return a1.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:a1.jsxs(d9,{mode:"wait",initial:!1,children:[$.status==="ready"&&a1.jsx(YY,{asChild:!0,segment:"views",name:Z.id,version:$.version,children:a1.jsx(n0.div,{className:"absolute inset-0 overflow-auto",initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:{duration:0.3,ease:"easeInOut"},children:a1.jsx(xZ,{name:Z.id,kind:"view",workspaceId:J,resetKey:$.version,children:a1.jsx($.Component,{})})})},$.version),$.status==="error"&&a1.jsx(n0.p,{className:"absolute inset-0 p-4 text-xs text-destructive",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0.3,ease:"easeInOut"},children:$.error},`err-${$.version}`)]})})}function jd({active:Z,onToggle:J}){return a1.jsxs(T9,{children:[a1.jsx(C9,{render:a1.jsx(E1,{variant:Z?"secondary":"ghost",size:"icon-sm","aria-label":"Customize","aria-pressed":Z,onClick:J,children:a1.jsx(SY,{stroke:1.75})})}),a1.jsx(S9,{children:"Customize"})]})}function Td(Z){if(!Z||!Array.isArray(Z.open))return gY;let J=Z.open.filter(($,X,Q)=>Q.indexOf($)===X);if(J.length===0)return gY;return{open:J,active:J.includes(Z.active)?Z.active:J[0]}}function tK(Z,J,$){if(Z==="agent"||Z==="widgets"||Z==="scratchpad")return!0;let X=JJ(Z);if(X)return $.some((Y)=>Y.id===X);let Q=$V(Z);return Q?J.some((Y)=>Y.id===Q):!1}function Cd(Z,J,$,X){if(Z==="agent")return{key:Z,Icon:Y6,label:"Agent",closable:X};if(Z==="widgets")return{key:Z,Icon:ZV,label:"Widgets",closable:X};if(Z==="scratchpad")return{key:Z,Icon:JV,label:"Scratchpad",closable:X};let Q=JJ(Z),Y=Q?$.find((z)=>z.id===Q):null;if(Y)return{key:Z,Icon:dC(Y),label:Y.title||Y.viewId||"New view",closable:X};let G=$V(Z),H=G?J.find((z)=>z.id===G):null;return H?{key:Z,Icon:lC(H,$),label:cC(H),closable:X}:null}function Sd(Z,J,$){let X=new Set(J),Q=0;return Z.map((Y)=>X.has(Y)?$[Q++]:Y)}function iC({widgets:Z,views:J,builders:$}){let{view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,send:z,stop:W,switchThread:V,dismissError:K}=IC(),{layout:U,setLayout:q,name:B,icon:F,provider:N,workspaceId:L}=w0(),M=fL(L).data,A=M===void 0?void 0:M.available?null:M.reason,P=RC(),{ref:D,fits:_}=bC(),[T,C]=J2.useState("idle"),[y,j]=J2.useState(!1),[g,I]=J2.useState(0),E=J2.useRef(null);hC(U.theme,E);let S=Td(U.tabs),b=J2.useRef(S);b.current=S;let R=S.open.filter((c)=>tK(c,J,$)),x=R.length>0?R:gY.open,h=new Set(S.open),d=x.filter((c)=>c!=="agent"),O=d.length>0,Z1=U.layoutMode==="split"&&O&&_?"split":"fullscreen",k=Z1==="split",e=(c)=>{if(c==="split"&&S.active==="agent"){q({layoutMode:c,tabs:{open:S.open,active:d[0]??S.active}});return}q({layoutMode:c})},_1=k?d:x,u=_1.includes(S.active)?S.active:_1[0]??"agent",z1=x.length>1,V1=_1.map((c)=>Cd(c,J,$,z1||JJ(c)!==null)).filter((c)=>Boolean(c)),$1=$V(u),G1=$1?J.find((c)=>c.id===$1):void 0,U1=JJ(u),f=U1?$.find((c)=>c.id===U1):void 0;J2.useEffect(()=>{let c=S.open.filter((I1)=>tK(I1,J,$));if(c.length===S.open.length)return;let F1=c.length>0?c:gY.open;q({tabs:{open:F1,active:F1.includes(S.active)?S.active:F1[0]}})},[$,q,S.active,S.open,J]),J2.useEffect(()=>{let c=new Map;for(let s of $){if(s.status!=="ready"||!s.viewId)continue;if(!J.some((q1)=>q1.id===s.viewId))continue;c.set(vY(s.id),fC(s.viewId))}if(c.size===0)return;let F1=new Set(c.values()),I1=new Map([...c].map(([s,q1])=>[q1,s])),f1=[],v=!1;for(let s of S.open){let q1=I1.get(s);if(F1.has(s)&&q1&&S.open.includes(q1)){v=!0;continue}let w1=c.get(s),h1=w1??s;if(w1)v=!0;if(!f1.includes(h1))f1.push(h1)}if(!v)return;let p=c.get(S.active)??S.active;q({tabs:{open:f1.length>0?f1:["agent"],active:p}})},[$,q,S.active,S.open,J]),J2.useEffect(()=>{let c=f??$.find((F1)=>F1.viewId===$1);if(c)H0.getState().setActive(L,c.sessionId)},[f,$1,$,L]),J2.useEffect(()=>{if(Z1!=="fullscreen"||u==="agent")j(!1)},[u,Z1]);let o=(c)=>{b.current=c,q({tabs:c})},n=(c)=>{let F1=b.current,I1=F1.open.includes(c)?F1.open:[...F1.open,c];if(o({open:I1,active:c}),c==="agent")j(!1),I((f1)=>f1+1)},M1=(c)=>{let F1=JJ(c),I1=F1?$.find((p)=>p.id===F1):void 0;if(!z1&&!I1||!h.has(c))return;let f1=S.open.filter((p)=>p!==c);if(f1.length===0)f1=["agent"];let v=S.active;if(v===c||!f1.includes(v)){let p=_1.indexOf(c);v=_1[p+1]??_1[p-1]??f1.find((s)=>tK(s,J,$))??"agent"}if(o({open:f1,active:v}),I1?.status==="draft")P.discard(I1.id)},l=(c)=>{let F1=vY(c.id);if(h.has(F1)){let I1=S.open.filter((f1)=>f1!==F1);if(I1.length===0)I1=["agent"];o({open:I1,active:S.active===F1?I1[0]:S.active})}P.discard(c.id)},W1=(c)=>{let F1=Sd(S.open,_1,c);if(F1===S.open)return;o({open:F1,active:S.active})},i=(c)=>{if(c!==void 0)H0.getState().setDraft(L,Y,c);if(Z1==="fullscreen"&&u!=="agent"){if(j(!0),y)I((F1)=>F1+1);return}I((F1)=>F1+1)},t=[...!k&&!h.has("agent")?[{key:"agent",Icon:Y6,label:"Agent",onClick:()=>n("agent")}]:[],...!h.has("widgets")?[{key:"widgets",Icon:ZV,label:"Widgets",onClick:()=>n("widgets")}]:[],...!h.has("scratchpad")?[{key:"scratchpad",Icon:JV,label:"Scratchpad",onClick:()=>n("scratchpad")}]:[],...J.map((c)=>({view:c,tab:fC(c.id)})).filter(({tab:c})=>!h.has(c)).map(({view:c,tab:F1})=>({key:F1,Icon:lC(c,$),label:cC(c),onClick:()=>n(F1)})),...$.filter((c)=>c.status!=="ready").map((c)=>({builder:c,tab:vY(c.id)})).filter(({tab:c})=>!h.has(c)).map(({builder:c,tab:F1})=>({key:F1,Icon:dC(c),label:c.title||c.viewId||"New view",onClick:()=>n(F1)})),{key:"create-view",Icon:pC,label:"New view",onClick:()=>{P.create().then((c)=>n(vY(c.id)))}}],H1=a1.jsx(oQ,{active:Z1==="split",focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V}),r=a1.jsx(oQ,{active:Z1==="fullscreen"&&u==="agent",focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V});return a1.jsxs("div",{ref:E,className:"relative flex h-full min-h-0 flex-col bg-background font-sans text-foreground",children:[a1.jsxs("div",{ref:D,className:"flex min-h-0 flex-1",children:[(Z1==="fullscreen"||O)&&a1.jsxs("div",{className:N1("flex min-h-0 flex-1 flex-col",Z1==="split"&&"min-w-(--column-w)"),children:[a1.jsxs(ow,{children:[a1.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-4",children:[a1.jsxs("div",{className:"flex items-center gap-2",children:[a1.jsx("img",{src:F??$9[N??"claude-code"],alt:"",className:"size-5 shrink-0 rounded-[4px]"}),B&&a1.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:B})]}),a1.jsx(mC,{tabs:V1,active:u,createItems:t,onSelect:n,onClose:M1,onReorder:W1})]}),a1.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a1.jsx(jd,{active:T==="customizing",onToggle:()=>C(T==="customizing"?"idle":"customizing")}),a1.jsx(AC,{}),O&&_&&a1.jsx(Od,{mode:Z1,onToggleMode:()=>e(Z1==="fullscreen"?"split":"fullscreen")})]})]}),u==="agent"?r:u==="widgets"?a1.jsx(nw,{editing:T==="editing",onEditingChange:(c)=>C(c?"editing":"idle"),widgets:Z,onCreateWidget:()=>i("Create widget")}):u==="scratchpad"?a1.jsx(J2.Suspense,{fallback:null,children:a1.jsx(Pd,{})}):f?a1.jsx(kC,{builder:f,unavailableReason:A,onSave:(c)=>P.save(f.id,c),onSubmit:(c)=>{if(Z1==="fullscreen")j(!0);return P.submit(f,c)},onOpenChat:()=>{H0.getState().setActive(L,f.sessionId),i()},onDiscard:()=>l(f)},f.id):G1?a1.jsx(wd,{view:G1}):null]}),Z1==="split"&&a1.jsx("div",{className:N1("flex min-h-0 min-w-(--chat-min) flex-[0_1_var(--chat-max)] flex-col overflow-hidden border-l border-border"),children:H1})]}),a1.jsx(d9,{children:T==="customizing"&&a1.jsx(AO,{})}),Z1==="fullscreen"&&u!=="agent"&&O&&a1.jsx(LO,{open:y,onOpenChange:j,onOpenChangeComplete:(c)=>{if(c)I((F1)=>F1+1)},container:E,children:(c)=>a1.jsx(oQ,{active:y,focusRequest:g,view:X,previewTurn:Q,sessionId:Y,processing:G,error:H,onDismissError:K,unavailableReason:A,send:z,stop:W,onSwitchThread:V,onClose:c})})]})}var mY=w(m(),1);function rC(Z,J,$,X){let Q=mY.useRef(null);mY.useEffect(()=>{if(!J)return;let Y=new Map(J.map((q)=>[q.id,{w:q.config.colSpan,h:q.config.rowSpan}]));if(Q.current?.workspaceId!==Z){Q.current={workspaceId:Z,sizes:Y};return}let G=Q.current.sizes,H=new Set($.widgetGrid.map((q)=>q.i)),z=J.filter((q)=>{if(!G.has(q.id))return!H.has(q.id);if(!H.has(q.id))return!1;let F=G.get(q.id);return F.w!==q.config.colSpan||F.h!==q.config.rowSpan});if(Q.current={workspaceId:Z,sizes:Y},z.length===0)return;let W=new Map(J.map((q)=>[q.id,q.config])),V=$.widgetGrid.filter((q)=>!z.some((B)=>B.id===q.i)&&W.has(q.i)).map((q)=>{let B=W.get(q.i);return{i:q.i,x:q.x,y:q.y,w:B.colSpan,h:B.rowSpan}}),K=V.map(({i:q,x:B,y:F})=>({i:q,x:B,y:F})),U=[...V];for(let q of z){let B=hZ(U,q.config.colSpan,q.config.rowSpan,4);K.push({i:q.id,x:B.x,y:B.y}),U.push({i:q.id,x:B.x,y:B.y,w:q.config.colSpan,h:q.config.rowSpan})}X({widgetGrid:K})},[Z,J,$.widgetGrid,X])}var E2=w(a(),1);function oC({id:Z}){return E2.jsx(sC,{id:Z,children:E2.jsx(iL,{id:Z,children:E2.jsx(Ed,{id:Z})})})}function Ed({id:Z}){let J=Z0(),{layout:$,setLayout:X,isLoading:Q}=w0(),Y=pL(Z),G=_X(Z),H=yY(Z),z=BX(Z);rC(Z,Y.data,$,X),gL(),Y9((V)=>{if(V.type==="theme:updated"||V.type==="workspace:updated")J.invalidateQueries({queryKey:D1.layout(Z)});else if(V.type==="widget-layout:updated"||V.type==="widget:updated")J.invalidateQueries({queryKey:D1.widgets(Z)});else if(V.type==="view-layout:updated")J.invalidateQueries({queryKey:D1.views(Z)})});let W=Q||Y.isLoading||G.isLoading||H.isLoading;return E2.jsxs(E2.Fragment,{children:[E2.jsx(Id,{workspaceId:Z,sessions:z.data}),E2.jsx(XX,{children:W?E2.jsx("div",{className:"flex h-full items-center justify-center",children:E2.jsx(aC,{sprite:"moi",effect:"chaos"})}):E2.jsx(iC,{widgets:Y.data??[],views:G.data??[],builders:H.data??[]})})]})}function Id({workspaceId:Z,sessions:J}){return nC.useEffect(()=>{if(!J)return;let $=H0.getState().activeByWorkspace[Z]??null;if(!($&&J.some((Q)=>Q.sessionId===$)))H0.getState().setActive(Z,J[0]?.sessionId??null)},[Z,J]),null}var B7=w(a(),1),kd=t8.lazy(()=>import("/chunk-69nhbjhy.js"));function Rd(){return B7.jsx(t8.Suspense,{fallback:null,children:B7.jsx(kd,{})})}function eC(){let[,Z]=y9();return t8.useEffect(()=>{return YH((J)=>Z(`/workspace/${J}`)),()=>YH(null)},[Z]),B7.jsxs(tC,{children:[B7.jsx(fY,{path:"/",component:SL}),B7.jsx(fY,{path:"/dev/*?",component:Rd}),B7.jsx(fY,{path:"/workspace/:id",children:(J)=>B7.jsx(oC,{id:J.id},J.id)})]})}var K6=w(a(),1),$S=new ZG;sU($S);gU();function IC1(Z){function J(){return K6.jsx($G,{client:$S,children:K6.jsxs(bU,{children:[K6.jsx(ZS,{children:K6.jsx(eC,{})}),!1]})})}JS.createRoot(Z).render(K6.jsx(J,{}))}export{IC1 as mount};
|