@chaibuilder/sdk 0.1.21 → 0.1.22
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/dist/{AddBlocks-b2d43d6c.js → AddBlocks-254892c5.js} +1 -1
- package/dist/{AddBlocks-b510ac3a.cjs → AddBlocks-a86eec32.cjs} +1 -1
- package/dist/{BrandingOptions-6fbe4b26.cjs → BrandingOptions-10c05f85.cjs} +1 -1
- package/dist/{BrandingOptions-7f66e02c.js → BrandingOptions-81fb41d9.js} +1 -1
- package/dist/{CanvasArea-68841a13.js → CanvasArea-7e09f98e.js} +2 -2
- package/dist/{CanvasArea-a8d28eb3.cjs → CanvasArea-a261378b.cjs} +2 -2
- package/dist/{CurrentPage-c10e6c89.cjs → CurrentPage-b67bee36.cjs} +1 -1
- package/dist/{CurrentPage-6655ce50.js → CurrentPage-ce5a51fa.js} +1 -1
- package/dist/{Layers-595cc98e.cjs → Layers-4e859d15.cjs} +1 -1
- package/dist/{Layers-99bdc689.js → Layers-b3a452cc.js} +2 -2
- package/dist/{MarkAsGlobalBlock-ea769ea4.cjs → MarkAsGlobalBlock-1a1039f8.cjs} +1 -1
- package/dist/{MarkAsGlobalBlock-522e170a.js → MarkAsGlobalBlock-7d9f5e11.js} +1 -1
- package/dist/{PagesPanel-e176d7e8.cjs → PagesPanel-163b7771.cjs} +1 -1
- package/dist/{PagesPanel-b0debeed.js → PagesPanel-2559ea9e.js} +2 -2
- package/dist/{ProjectPanel-d0f33df2.cjs → ProjectPanel-e78931cd.cjs} +1 -1
- package/dist/{ProjectPanel-9cec967c.js → ProjectPanel-fab32a4f.js} +2 -2
- package/dist/{Settings-fd1e3b5d.js → Settings-a2638a6e.js} +1 -1
- package/dist/{Settings-208ab051.cjs → Settings-d9df3548.cjs} +1 -1
- package/dist/{SidePanels-40966390.cjs → SidePanels-1439e695.cjs} +1 -1
- package/dist/{SidePanels-ca294b35.js → SidePanels-aa583e71.js} +2 -2
- package/dist/{Topbar-75c99c88.cjs → Topbar-c131ef83.cjs} +1 -1
- package/dist/{Topbar-1edef1b2.js → Topbar-ef648e78.js} +1 -1
- package/dist/{add-page-modal-18f134c0.cjs → add-page-modal-7d645bf7.cjs} +1 -1
- package/dist/{add-page-modal-9985b5ce.js → add-page-modal-8c9dad17.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +4 -1
- package/dist/core.js +1 -1
- package/dist/{delete-page-modal-393697d7.cjs → delete-page-modal-19001f8d.cjs} +1 -1
- package/dist/{delete-page-modal-98272bf5.js → delete-page-modal-ec091c19.js} +1 -1
- package/dist/{index-c3a98a78.cjs → index-2f61b040.cjs} +2 -2
- package/dist/{index-436bba3e.js → index-e6e838ec.js} +4 -4
- package/dist/{page-viewer-32261f49.cjs → page-viewer-65e2ca1a.cjs} +1 -1
- package/dist/{page-viewer-a3ac057a.js → page-viewer-dec9a6d2.js} +2 -2
- package/dist/{project-general-setting-21e324a9.js → project-general-setting-067afe22.js} +1 -1
- package/dist/{project-general-setting-75a8e94b.cjs → project-general-setting-c7d95cc0.cjs} +1 -1
- package/dist/{single-page-detail-649b1379.cjs → single-page-detail-14e7a650.cjs} +1 -1
- package/dist/{single-page-detail-0e881b82.js → single-page-detail-f110be66.js} +2 -2
- package/package.json +1 -1
|
@@ -160,5 +160,5 @@ object-assign/index.js:
|
|
|
160
160
|
(c) Sindre Sorhus
|
|
161
161
|
@license MIT
|
|
162
162
|
*)
|
|
163
|
-
*/F();var tB=process.env.NODE_ENV!=="production"?eB:()=>null;const rB={};class eS extends g.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return console.error(t),{hasError:!0}}render(){return this.state.hasError?ie.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const nB=e=>{const t=e.replace(je.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},aB=new eg({children:"blockNodes"}),tS=(e,t=null)=>B.flatten(e.map(r=>{if(r=t!==null?{...r,parent:t}:r,r.children&&r.children.length){const n=[...r.children];return delete r.children,B.flatten([r,...tS(n,r._id)])}return r}));function rS(e,t,r){const n=B.filter(e,o=>o._parent===t),a=[];for(let o=0;o<n.length;o++){const s=nS(n[o]);if(Object.keys(s).length>0&&Object.keys(s).forEach(i=>{n[o][i]=`slot:${mt.generateUUID()}`}),B.filter(e,{_parent:n[o]._id}).length>0){const i=mt.generateUUID();a.push({...n[o],oldId:n[o]._id,_id:i,_parent:r}),a.push(B.flatten(rS(e,n[o]._id,i)))}else a.push({...n[o],oldId:n[o]._id,_id:mt.generateUUID(),_parent:r})}return B.flatten(a)}function oB(e){let t=aB.convert(e.map(r=>B.omit(r,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:B.isEmpty(t)?[]:[t],t}const nS=e=>{const t={};return Object.keys(e).forEach(r=>{B.isString(e[r])&&e[r].startsWith("slot")&&(t[r]=e[r].replace("slot:",""))}),t},sB=(e,t,r=null)=>{let n=B.find(e,{_id:t});n={...n,oldId:n._id,_id:mt.generateUUID()},r&&(n={...n,_parent:r});const a=[n];B.filter(e,{_parent:t}).length>0&&a.push(B.flatten(rS(e,t,n._id)));const o=B.flatten(a);return B.map(o,s=>{const i=s,l=nS(i);return Object.keys(l).length>0&&Object.keys(l).forEach(u=>{const c=B.find(o,{oldId:l[u].replace("slot:","")});i[u]=`slot:${c._id}`}),B.omit(i,["global","oldId"])})},iB=Ha((e=[],t)=>{switch(t.type){case"add_new_blocks":case"add_duplicate_blocks":return[...e,...t.payload];case"create_snapshot":return[...e];case"set_blocks":case"set_page_blocks":return[...t.payload];case"update_props":case"update_props_realtime":const{payload:r}=t;return e.map(n=>(r.ids.includes(n._id)&&!B.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(a=>{B.set(n,a,t.payload.props[a])}),n));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Ha.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),Ql=GT({past:[],present:[],future:[]},iB);Ql.debugLabel="pageBlocksAtom";const Vt=G.atom(e=>{var t;return(t=e(Ql))==null?void 0:t.present});Vt.debugLabel="presentBlocksAtom";const Xf=_T(Vt);Xf.debugLabel="pageBlocksAtomsAtom";const aS=G.atom(e=>oB(e(Vt)));aS.debugLabel="pageBlocksTreeAtom";const lB=G.atom("");lB.debugLabel="builderActivePageAtom";const cB=G.atom(-1);cB.debugLabel="destinationDropIndexAtom";const oS=G.atom(!1);oS.debugLabel="addBlocksModalAtom";const Lt=()=>{const[,e]=G.useAtom(Ql);return e},uB=()=>{const e=Lt(),t=G.useAtomValue(aS),r=g.useCallback(n=>{const a=tS(n);e({type:"set_page_blocks",payload:a})},[e]);return[t,r]},sS=()=>{const e=Lt();return[g.useCallback(r=>{e({type:"set_page_blocks",payload:r})},[e])]},ku=e=>["Box","Slot","Form","DataProvider","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),fB=e=>!["Slot"].includes(e),dB=e=>!["Slot"].includes(e);function pB(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:ku(t)}const hB=(e,{dragSource:t,dropTarget:r})=>{const n=B.get(t,"data._type",""),a=B.get(r,"data._type","");return n==="Slot"||B.get(t,"id")&&B.get(t,"id")===B.get(r,"id")?!1:B.isEmpty(a)?!0:pB(n,a)},_f=G.atom([]);_f.debugLabel="selectedBlockIdsAtom";const $f=G.atom(e=>{const t=e(Vt),r=e(_f);return B.map(B.filter(t,({_id:n})=>B.includes(r,n)),n=>({...n}))});$f.debugLabel="selectedBlocksAtom";const ed=G.atom(e=>{const t=e($f);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:B.map(t,"id")}});ed.debugLabel="selectedBlockAtom";const bB=e=>B.get(e,"parent",null),mB=G.atom(e=>{const t=e($f),r=B.map(t,bB);return B.filter(e(Vt),n=>B.includes(r,n._id))});mB.debugLabel="selectedBlocksParentsAtom";const iS=G.atom(()=>!1);iS.debugLabel="selectedBlockFlexChildAtom";const lS=G.atom(()=>!1);lS.debugLabel="selectedBlockGridChildAtom";const td=G.atom("");td.debugLabel="styleStateAtom";const cS=wt("styleBreakpoint","xs");cS.debugLabel="styleBreakpointAtom";const gB=()=>({flexChild:G.useAtomValue(iS),gridChild:G.useAtomValue(lS)}),vB=()=>G.useAtomValue(ed),Wr=()=>{const[e,t]=G.useAtom(_f),r=g.useCallback(n=>{t(a=>B.includes(a,n)?B.without(a,n):[...a,n])},[t]);return[e,t,r]},Pu=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:r}=e,n={};return Object.keys(r).forEach(s=>{const i=r[s];if(B.includes(["slot","styles"],i.type))return;const l=B.get(i,"i18n",!1)?`${s}-${t}`:s;n[l]=Pu(i,t)}),n;case"list":const{itemProperties:a}=e,o={items:{}};return Object.keys(a).forEach(s=>{const i=a[s];if(B.includes(["slot","styles"],i.type))return;const l=B.get(i,"i18n",!1)?`${s}-${t}`:s;o.items[l]=Pu(i,t)}),o;default:return{}}},xu=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:r,title:n}=e,a={title:n,type:"object",properties:{}};return Object.keys(r).forEach(l=>{const u=r[l];if(B.includes(["slot","styles"],u.type))return;const c=B.get(u,"i18n",!1)?`${l}-${t}`:l;a.properties[c]=xu(u,t)}),a;case"list":const{itemProperties:o,title:s}=e,i={title:s,type:"array",items:{type:"object",properties:{}}};return Object.keys(o).forEach(l=>{const u=o[l];if(B.includes(["slot","styles"],u.type))return;const c=B.get(u,"i18n",!1)?`${l}-${t}`:l;i.items.properties[c]=xu(u,t),B.set(i.items,"title",B.get(u,"itemTitle",`${s} item`))}),i;default:return{}}},uS=e=>{const t={};return Object.keys(e).forEach(r=>{t[r]=wB(e[r])}),t},yB=e=>{if(B.isEmpty(e.default))return[];const{itemProperties:t}=e;return B.map(e.default,r=>{const n={...r};return B.forIn(r,(a,o)=>{B.has(t,o)&&B.get(t[o],"i18n",!1)&&(n[o]=je.I18N_KEY)}),n})},wB=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${je.SLOT_KEY}${mt.generateUUID()}`;case"singular":const{i18n:t,schema:r}=e;return t?je.I18N_KEY:B.get(r,"default","");case"model":return uS(e.properties);case"list":return yB(e);default:return""}},fS=()=>G.useAtomValue(Vt);function nm(e,t,r,n,a){if(t===null)return[...e,...n];if(r!==null){const l=B.findIndex(e,{_parent:t}),u=(l===-1?0:l)+r;return e.splice(u,0,...n),e}if(!a){const u=B.findIndex(e,{_id:t})+1;return e.splice(u,0,...n),e}let o=B.findIndex(e,{_id:t});const s=B.filter(e,{_parent:t});B.isEmpty(s)||(o=B.findIndex(e,{_id:B.last(s)._id}));const i=o+1;return e.splice(i,0,...n),e}const SB=()=>{const e=Lt(),t=fS(),[,r]=Wr(),n=g.useCallback((o,s,i)=>{var c;for(let f=0;f<o.length;f++){const{_id:d}=o[f];o[f]._id=mt.generateUUID();const p=B.filter(o,{_parent:d});for(let b=0;b<p.length;b++)p[b]._parent=o[f]._id}let l;s&&(l=B.find(t,{_id:s}),o[0]._parent=s);const u=l?ku(l._type):!0;return!u&&l&&(o[0]._parent=l._parent),e({type:"set_blocks",payload:nm(t,s||null,i||null,o,u)}),r([(c=B.first(o))==null?void 0:c._id]),B.first(o)},[t,e,r]);return{addCoreBlock:g.useCallback((o,s,i)=>{if(B.has(o,"blocks")){const h=o.blocks;return n(h,s,i)}const l=mt.generateUUID(),u=uS(o.props),c=[];B.forIn(u,(h,m)=>{if(B.startsWith(h,je.SLOT_KEY)){const v=h.replace(je.SLOT_KEY,"");c.push({_id:v,_type:"Slot",_parent:l,_name:o.props[m].name,_styles:o.props[m].styles,_emptyStyles:o.props[m].emptyStyles})}});const f={_type:o.type,_id:l,...u};let d;s&&(d=B.find(t,{_id:s}),f._parent=s);const p=d?ku(d._type):!0;!p&&d&&(f._parent=d._parent);const b=[f,...c];return e({type:"set_blocks",payload:nm(t,s||null,i||null,b,p)}),r([f._id]),f},[n,t,e,r]),addPredefinedBlock:n}},am={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},om=["xs","sm","md","lg","xl","2xl"];function AB(e,t){if(t===null)return"baseClasses";const r=t.mq;if(r==="xs"||t.dark||t.mod!=="")return"classes";let n="baseClasses",a=om.indexOf(r);for(;a>0;){const o=om[a-1];if(B.find(e,{mq:o,property:t.property})){n="classes";break}a--}return n}const sm=[];function EB(e="",t="",r=[]){e=e.trim().replace(/ +/g,"");let n=B.filter(B.map(e.split(" "),mt.constructClassObject),u=>!B.isNull(u)),a=B.filter(B.map(t.split(" "),mt.constructClassObject),u=>!B.isNull(u));a=B.filter(a,u=>!B.includes(sm,u.property));const o=[],s=[];B.each(r,u=>{const c=mt.constructClassObject(u),f=B.find(n,B.pick(c,["dark","mq","mod","property"]));if(f&&(n=B.filter(n,d=>d.fullCls!==(f==null?void 0:f.fullCls))),o.push(c),c.mq==="xs"&&!c.dark&&c.mod===""&&(a=B.filter(a,d=>d.property!==c.property)),AB(n,c)==="baseClasses"&&!B.includes(sm,c.property)){const d=B.find(a,B.pick(c,["property"]));f&&(a=B.filter(a,p=>p.fullCls!==(d==null?void 0:d.fullCls))),s.push({...c,fullCls:c.cls,mq:"xs"})}});const i=B.map(B.sortBy([...n,...o],u=>am[u.mq]),"fullCls").join(" ");return`${B.map(B.sortBy([...a,...s],u=>am[u.mq]),"fullCls").join(" ").trim()},${i.trim()}`.trim().replace(/ +/g,"")}const Vo=G.atom([]);Vo.debugLabel="selectedStylingBlocksAtom";const rd=()=>G.useAtom(Vo),OB=e=>{const t=e.replace(je.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},CB=G.atom(null,(e,t,{blockIds:r,newClasses:n,dispatch:a})=>{const o=B.filter(e(Xf),i=>r.includes(e(i)._id)),s=B.first(e(Vo));B.each(o,i=>{const l=e(i),u=B.get(l,s.prop,`${je.STYLES_KEY},`),{baseClasses:c,classes:f}=OB(u);a({type:"update_props_realtime",payload:{ids:[l._id],props:{[s.prop]:`${je.STYLES_KEY}${EB(f,c,n)}`}}})})}),IB=()=>{const e=Lt(),t=G.useSetAtom(CB);return g.useCallback((r,n,a)=>{t({blockIds:r,newClasses:n,dispatch:e}),a&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},dS=G.atom([]);dS.debugLabel="buildingBlocksAtom";const kB=G.atom(e=>{const t=e(dS);return B.filter(t,r=>B.has(r,"blockId"))}),PB=()=>{},pS=()=>{const e=tg.useChaiBlocks(),t=G.useAtomValue(kB),r=()=>{},n=g.useCallback(()=>PB(),[]);return[e,t,r,n]},xB=G.atom(!1),nd=()=>{const[e,t]=G.useAtom(xB);return[e,t]},RB=G.atom(je.BRANDING_OPTIONS_DEFAULTS),ad=()=>{const[e,t]=G.useAtom(RB);return[B.isObject(e)?{...je.BRANDING_OPTIONS_DEFAULTS,...e}:je.BRANDING_OPTIONS_DEFAULTS,t]},MB=G.atom(null),hS=()=>({currentPage:G.useAtomValue(MB)}),bS=new eg({});function NB(e){let t=bS.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:B.isEmpty(t)?[]:[t],t}const od=(e,t)=>B.flatten(e.map(r=>{if(r=t?{...r,parent:t}:{...r},r.children){const n=[...r.children];return delete r.children,B.flatten([r,...od(n,r._id)])}return r}));function sd(e,t=!1){for(let r=0;r<e.length;r++){const n=e[r];n.global&&!t?e[r]={type:"GlobalBlock",_parent:B.get(n,"parent",null),blockId:n.blockId,_id:n._id}:n.children&&n.children.length&&sd(n.children)}}function mS(e){let t=[],r=B.filter(e,{type:"GlobalBlock"});return r.length>0&&(r=B.map(r,gS),B.each(r,n=>{t=[...t,...TB(n)]})),t}function TB(e){let t=[];const r=B.get(B.first(e),"parent",null);B.set(B.first(e),"parent",null);const n=[bS.convert(vS(e))];sd(n,!0);let a=od(n,e[0]._id);return a=B.set(a,"0.parent",r),t=[...t,a,...mS(a)],t}function gS(e){const t=B.find(Ru,{_id:e._id});if(!t)return[];const r=[t],n=B.filter(Ru,{_parent:e._id});return n.length?B.flatten([...r,...B.flatten(B.map(n,gS))]):B.flatten(r)}const vS=e=>JSON.parse(JSON.stringify(e));let Ru=[];function jB(e){Ru=e;const t=NB(vS(e));sd(t);const r=od(t,null),n=mS(r),a={};return B.each(n,o=>B.set(a,B.first(o).blockId,o)),[r,a]}const id=()=>{const[e]=ad(),{currentPage:t}=hS(),r=G.useAtomValue(Vt);return g.useCallback(()=>{const n=B.map(r,s=>B.omit(s,["expanded","order","title","siblings","tempClasses"])),[a=[],o=[]]=jB(n);return{currentPage:t,blocks:a,globalBlocks:o}},[e,t,r])};wt("blockStylingActiveTab",1);G.atom([]);const yS=G.atom(!1);yS.debugLabel="readOnlyModeAtom";const wS=G.atom(!1);wS.debugLabel="inlineEditingActiveAtom";const SS=G.atom(!1);SS.debugLabel="advanceStylingOpenAtom";const AS=G.atom("online");AS.debugLabel="networkModeAtom";wt("currentUiLibrary","");const zB=G.atom(!1);zB.debugLabel="codeEditorOpenAtom";const ES=G.atom(!1);ES.debugLabel="editLayerNameAtom";const FB=G.atom("");FB.debugLabel="activeLanguageAtom";const qB=G.atom("");qB.debugLabel="primaryLanguageAtom";const OS=G.atom(null);OS.debugLabel="canvasIframeAtom";const CS=G.atom("layers");CS.debugLabel="activePanelAtom";const IS=G.atom(!1);IS.debugLabel="addBlockOffCanvasAtom";const kS=G.atom("");kS.debugLabel="showPredefinedBlockCategoryAtom";const Xl=G.atom({undoCount:0,redoCount:0});Xl.debugLabel="historyStatesAtom";const ld=G.atom([]);ld.debugLabel="dataProvidersAtom";const PS=()=>G.useAtom(ld),Lo=G.atom("SAVED");Lo.debugLabel="pageSyncStateAtom";const DB=()=>{const[e,t]=G.useAtom(Lo),r=xt.useBuilderProp("onSaveBlocks",async()=>{}),n=xt.useBuilderProp("onSavePage",async()=>{}),a=xt.useBuilderProp("onSyncStatusChange",()=>{}),o=id(),s=G.useSetAtom(Xl),{undoCount:i,redoCount:l}=Ko(),[u]=PS();return{savePage:TA.useThrottledCallback(async()=>{t("SAVING"),a("SAVING");const f=o();return await Promise.all([r({blocks:f.blocks,providers:[],identifier:"pageData.id"}),n({blocks:f.blocks,providers:u})]),setTimeout(()=>{s({undoCount:i,redoCount:l}),t("SAVED"),a("SAVED")},100),!0},[o,t,a,r],5e3),syncState:e,setSyncState:t}},Ko=()=>{const e=G.useAtomValue(Ql),[{undoCount:t,redoCount:r}]=G.useAtom(Xl),n=Lt(),[a]=nd(),[,o]=Wr(),[,s]=rd(),[i,l]=G.useAtom(Lo),u=xt.useBuilderProp("onSyncStatusChange",()=>{}),c=g.useCallback(()=>{n({type:"create_snapshot"})},[n]);return g.useEffect(()=>{(i==="SAVED"&&t!==(e==null?void 0:e.past.length)||r!==(e==null?void 0:e.future.length))&&(l("UNSAVED"),u("UNSAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,r,u,l,i]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:g.useCallback(()=>{a||(n(Ha.ActionCreators.undo()),setTimeout(()=>{s([]),o([])},200))},[n,a,o,s]),redo:g.useCallback(()=>{a||(n(Ha.ActionCreators.redo()),setTimeout(()=>{s([]),o([])},200))},[a,n,s,o]),clear:()=>{n(Ha.ActionCreators.clearHistory())},createSnapshot:c}},xS=()=>G.useAtom(cS),RS=wt("canvasWidth",800),MS=G.atom(e=>{const t=e(RS);return mt.getBreakpointValue(t).toLowerCase()}),BB=()=>{const[e,t]=G.useAtom(RS),r=G.useAtomValue(MS),[n,a]=xS();return g.useEffect(()=>{n!=="xs"&&a(r)},[r,n,a]),[e,r,t]},VB=wt("canvasZoom",100),LB=()=>G.useAtom(VB),NS=G.atom([]),cd=()=>{const[e,t]=G.useAtom(NS),r=G.useSetAtom(ud),n=g.useCallback(a=>{t(a),r([])},[t,r]);return[e,n]},ud=G.atom([]),TS=()=>{const[e,t]=G.useAtom(ud),r=G.useSetAtom(NS),n=g.useCallback(a=>{t(a),r([])},[t,r]);return[e,n]},jS=wt("darkMode",!1),KB=()=>{const[e,t]=G.useAtom(jS);return[e,t]},WB=G.atom(!1),UB=()=>{const[e,t]=G.useAtom(WB);return[e,t]},fd=()=>{const e=Lt(),t=G.useAtomValue(Vt),[,r]=Wr();return g.useCallback((n,a=null)=>{const o=[];B.each(n,s=>{const l=sB(t,s,a===s?null:a);o.push(B.get(l,"0._id","")),e({type:"add_duplicate_blocks",payload:l})}),r(o),e({type:"create_snapshot"})},[t,r,e])},ZB=G.atom([]),JB=()=>{const[e,t]=G.useAtom(ZB),r=g.useCallback(n=>{t(a=>B.includes(a,n)?B.without(a,n):[...a,n])},[t]);return[e,t,r]},GB=G.atom(""),zS=()=>G.useAtom(GB),YB=()=>{const e=G.useAtomValue(Vt),t=Lt(),r=id(),[,,n]=pS();return g.useCallback(async(a,o)=>{const s=mt.generateUUID(16),i=B.map(e,l=>(l._id===a&&(l._globalBlockId=s,l._name=o),l));t({type:"set_page_blocks",payload:i}),n()},[e,t,r,n])},HB=()=>({}),QB=()=>{const e=G.useAtomValue(Vt),t=Lt();return g.useCallback((r,n)=>{const a=B.map(e,o=>(B.includes(r,B.get(o,"_id"))&&B.set(o,"_parent",n),o));t({type:"set_blocks",payload:a})},[e,t])},FS=()=>{const e=G.useAtomValue(ud),[t,r]=cd(),n=fd(),a=QB();return{canPaste:g.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:g.useCallback(s=>{B.isEmpty(e)?a(t,s):n(e,s),r(()=>[])},[t,e,n,a,r])}},XB=G.atom(""),_B=()=>{const e=G.useAtomValue(XB),t=g.useCallback(()=>{},[]),r=g.useCallback(()=>{},[]),n=g.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:r}},qS=(e,t)=>{const r=[],n=B.filter(e,a=>B.includes(t,a._id)||B.includes(t,a._parent)?(r.push(a._id),!1):!0);return B.isEmpty(r)?n:qS(n,r)},DS=()=>{const e=Lt(),t=G.useAtomValue(Vt),[r,n]=Wr();return g.useCallback(a=>{var i;const o=((i=B.find(t,{_id:a[0]}))==null?void 0:i._parent)||null,s=qS(t,a);e({type:"set_blocks",payload:s}),n(o?[o]:[])},[t,n,e,r])},$B=G.atom(null,(e,t,{blockIds:r,fullClasses:n,dispatch:a})=>{const o=B.first(e(Vo)),s=B.filter(e(Xf),i=>r.includes(e(i)._id));B.each(s,i=>{const l=e(i),u=n;let{classes:c,baseClasses:f}=nB(B.get(l,o.prop,"styles:,"));B.each(u,d=>{const p=new RegExp(`(^| )${d.replace("[","\\[").replace("]","\\]")}($| )`,"g");c=c.replace(p," ").replace(/ +/g," ").trim();const b=B.first(d.split(":"));B.includes(["2xl","xl","lg","md","sm"],b)&&u.push(d.split(":").pop().trim())}),B.each(u,d=>{const p=new RegExp(`(^| )${d.replace("[","\\[").replace("]","\\]")}($| )`,"g");f=f.replace(p," ").replace(/ +/g," ").trim()}),a({type:"update_props_realtime",payload:{ids:[l._id],props:{[o.prop]:`${je.STYLES_KEY}${f},${c}`}}})})}),eV=()=>{const e=Lt(),t=G.useSetAtom($B);return g.useCallback((r,n)=>{t({blockIds:r,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},BS=G.atom(e=>{const t=B.first(e(Vo)),r=e(ed);if(!t||t.blockId!==B.get(r,"_id",null))return[];const a=B.get(r,t.prop,`${je.STYLES_KEY},`).replace(je.STYLES_KEY,"").split(",").join(" ");return B.filter(B.map(a.trim().split(" "),mt.constructClassObject),o=>!B.isNull(o))}),tV=()=>G.useAtomValue(BS),im={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},rV=G.atom(e=>{const t=e(MS),r=e(td),n=e(jS),a=nV(t);let o=B.filter(e(BS),{mod:r});return B.startsWith(r,"_")||(o=B.filter(o,s=>a.includes(s.mq))),o=o.sort((s,i)=>im[s.mq]-im[i.mq]),n||(o=B.filter(o,{dark:!1})),o}),nV=e=>{let t=[];switch(e){case"xs":t=["xs"];break;case"sm":t=["xs","sm"];break;case"md":t=["xs","sm","md"];break;case"lg":t=["xs","sm","md","lg"];break;case"xl":t=["xs","sm","md","lg","xl"];break;case"2xl":t=["xs","sm","md","lg","xl","2xl"];break;default:t=["xs"];break}return t},aV=()=>G.useAtomValue(rV),oV=()=>G.useAtom(td),VS=G.atom(null,(e,t,{blockIds:r,props:n,dispatch:a})=>{a({type:"update_props_realtime",payload:{ids:r,props:n}})}),sV=()=>{const{createSnapshot:e}=Ko(),t=Lt(),r=G.useSetAtom(VS);return g.useCallback((n,a)=>{r({blockIds:n,props:a,dispatch:t}),e()},[e,t,r])},iV=()=>{const e=Lt(),t=G.useSetAtom(VS);return g.useCallback((r,n)=>{t({blockIds:r,props:n,dispatch:e})},[e,t])},LS={name:"",props:{},modalProps:{},backdropClose:!0},lV=G.atom(LS),cV=()=>{const[e,t]=G.useAtom(lV),r=g.useCallback((a,o={},s={})=>{t({name:a,props:o,modalProps:s})},[t]),n=g.useCallback((...a)=>{B.get(e,"props.onClose",()=>{})(...a),t(LS)},[t,e]);return{activeModal:e,openModal:r,closeModal:n}},uV=()=>G.useAtomValue(yS),fV=G.atom(""),dV=G.atom(null),pV=()=>G.useAtom(fV),hV=()=>G.useAtom(dV),bV=wt("selectedBreakpoints",["XS","MD","XL"]),mV=()=>{const[e,t]=G.useAtom(bV);return[e,t]},dd=()=>{const e=G.useSetAtom(Xl),{clear:t}=Ko(),[,r]=Wr(),[,n]=zS(),[,a]=rd();return()=>{r([]),a([]),n(""),t(),e({undoCount:0,redoCount:0})}},gV=G.atom({en:{}}),vV=()=>{const[e,t]=G.useAtom(gV),r=g.useCallback((n,a,o)=>{B.set(e,`${n}.${a}`,o),t(e)},[e,t]);return[e,r]},yV=(e,t)=>{const[r]=G.useAtom(xt.chaiBuilderPropsAtom);return B.get(r,e,t)},wV=G.atom([]),SV=()=>{const[e,t]=g.useState(!1),[r,n]=G.useAtom(wV),a=xt.useBuilderProp("getUILibraryBlocks",()=>[]);return g.useEffect(()=>{(async()=>r.length>0||(t(!0),n(await a()),t(!1)))()},[]),{data:r,isLoading:e}},AV=G.atom("en"),EV=G.atom("en"),OV=G.atom(["en"]),KS=()=>G.useAtom(AV),CV=()=>G.useAtom(EV),IV=()=>G.useAtom(OV),kV=(e,t)=>{const[r]=KS(),n=`${e}${r?`-${r}`:""}`;return{content:B.get(t,n,B.get(t,e,"")),propKey:e}},PV=()=>{const[e,t]=nd(),r=xt.useBuilderProp("previewComponent");return ie.jsxRuntimeExports.jsxs("div",{className:NA.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[ie.jsxRuntimeExports.jsx(xt.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),ie.jsxRuntimeExports.jsx("div",{children:r?ie.jsxRuntimeExports.jsx(g.Suspense,{fallback:ie.jsxRuntimeExports.jsx(xt.Skeleton,{className:"h-96 w-full"}),children:g.createElement(r)}):null})]})},xV=()=>{const[e,t]=Wr(),[,r]=TS(),n=DS(),a=fd(),[,o]=cd(),{pasteBlocks:s}=FS(),{undo:i,redo:l}=Ko();Sr.useHotkeys("esc",()=>t([]),{},[t]),Sr.useHotkeys("ctrl+c,command+c",()=>r(e),{},[e,r]),Sr.useHotkeys("ctrl+d,command+d",()=>a(e),{preventDefault:!0},[e,a]),Sr.useHotkeys("ctrl+x,command+x",()=>o(e),{},[e,o]),Sr.useHotkeys("ctrl+v,command+v",()=>e.length===1?s(e[0]):null,{},[e,s]),Sr.useHotkeys("ctrl+z,command+z",()=>i(),{},[i]),Sr.useHotkeys("ctrl+y,command+y",()=>l(),{},[l]),Sr.useHotkeys("del, backspace",u=>{u.preventDefault(),n(e)},{},[e,n])},RV=(e,t)=>{const r=[];let n=B.find(e,{_id:t}),a=B.get(n,"_parent","");for(;B.isString(a)&&!B.isEmpty(a);)r.push(n==null?void 0:n._parent),n=B.find(e,{_id:a}),a=n==null?void 0:n._parent;return B.flatten(r)},WS=G.atom([]),MV=()=>{const[e]=Wr(),t=G.useAtomValue(Vt),[,r]=G.useAtom(WS);g.useEffect(()=>{let n=[];const a=B.first(e);B.isString(a)&&(n=[a,...RV(t,a)]),r(n)},[e,t,r])},NV=()=>G.useAtomValue(WS),TV=g.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-40966390.cjs"))),jV=g.lazy(()=>Promise.resolve().then(()=>require("./Topbar-75c99c88.cjs"))),zV=g.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-a8d28eb3.cjs"))),FV=g.lazy(()=>Promise.resolve().then(()=>require("./Settings-208ab051.cjs"))),qV=()=>{const[e]=G.useAtom(Lo),t=r=>{r.preventDefault()};return xV(),MV(),g.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),ie.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:ie.jsxRuntimeExports.jsxs(xt.TooltipProvider,{children:[ie.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[ie.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(jV,{})})}),ie.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[ie.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(TV,{})})}),ie.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(zV,{})})}),ie.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(FV,{})})})]})]}),ie.jsxRuntimeExports.jsx(PV,{})]})})},lm=G.getDefaultStore();G.atom({});function cm(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var Cs="undefined",um="object",US="any",ZS="*",gn="__",hl=typeof process<"u"?process:{};hl.env&&hl.env.NODE_ENV;var Yt=typeof document<"u";hl.versions!=null&&hl.versions.node!=null;typeof Deno<"u"&&Deno.core;Yt&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function JS(e,t){return t.charAt(0)[e]()+t.slice(1)}var DV=JS.bind(null,"toUpperCase"),BV=JS.bind(null,"toLowerCase");function VV(e){return GS(e)?DV("null"):typeof e=="object"?ZV(e):Object.prototype.toString.call(e).slice(8,-1)}function bl(e,t){t===void 0&&(t=!0);var r=VV(e);return t?BV(r):r}function Wo(e,t){return typeof t===e}var nr=Wo.bind(null,"function"),Zn=Wo.bind(null,"string"),Vn=Wo.bind(null,"undefined"),LV=Wo.bind(null,"boolean");Wo.bind(null,"symbol");function GS(e){return e===null}function KV(e){return bl(e)==="number"&&!isNaN(e)}function WV(e){return bl(e)==="array"}function Ct(e){if(!UV(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function UV(e){return e&&(typeof e=="object"||e!==null)}function ZV(e){return nr(e.constructor)?e.constructor.name:null}function JV(e){return e instanceof Error||Zn(e.message)&&e.constructor&&KV(e.constructor.stackTraceLimit)}function YS(e,t){if(typeof t!="object"||GS(t))return!1;if(t instanceof e)return!0;var r=bl(new e(""));if(JV(t))for(;t;){if(bl(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}YS.bind(null,TypeError);YS.bind(null,SyntaxError);function _l(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?GV(e,t):r}function GV(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function $l(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}$l(_l,"form");$l(_l,"button");$l(_l,"input");$l(_l,"select");function fm(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function YV(){if(Yt){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function HV(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function QV(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var o=fm(r[1]),s=fm(r[2]);o.substring(o.length-2)==="[]"?(n[o=o.substring(0,o.length-2)]||(n[o]=[])).push(s):n[o]=s===""||s}for(var i in n){var l=i.split("[");l.length>1&&(XV(n,l.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),n[i]),delete n[i])}return n}(function(t){if(t){var r=t.match(/\?(.*)/);return r&&r[1]?r[1].split("#")[0]:""}return Yt&&window.location.search.substring(1)}(e))}function XV(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var o=t[a];if(o==="__proto__"||o==="constructor")break;o in e||(e[o]={}),e=e[o]}e[t[n]]=r}function ec(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}var ro="global",wa=gn+"global"+gn,Sa=typeof self===um&&self.self===self&&self||typeof global===um&&global.global===global&&global||void 0;function vn(e){return Sa[wa][e]}function yn(e,t){return Sa[wa][e]=t}function xa(e){delete Sa[wa][e]}function Ra(e,t,r){var n;try{if(pd(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Sa[wa]||(Sa[wa]={});var Is={};function pd(e){if(typeof Is[e]!==Cs)return Is[e];try{var t=window[e];t.setItem(Cs,Cs),t.removeItem(Cs)}catch{return Is[e]=!1}return Is[e]=!0}function ye(){return ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ye.apply(this,arguments)}var kr="function",hr="undefined",_V="@@redux/"+Math.random().toString(36),dm=function(){return typeof Symbol===kr&&Symbol.observable||"@@observable"}(),ks=" != "+kr;function HS(e,t,r){var n;if(typeof t===kr&&typeof r===hr&&(r=t,t=void 0),typeof r!==hr){if(typeof r!==kr)throw new Error("enhancer"+ks);return r(HS)(e,t)}if(typeof e!==kr)throw new Error("reducer"+ks);var a=e,o=t,s=[],i=s,l=!1;function u(){i===s&&(i=s.slice())}function c(){return o}function f(p){if(typeof p!==kr)throw new Error("Listener"+ks);var b=!0;return u(),i.push(p),function(){if(b){b=!1,u();var h=i.indexOf(p);i.splice(h,1)}}}function d(p){if(!Ct(p))throw new Error("Act != obj");if(typeof p.type===hr)throw new Error("ActType "+hr);if(l)throw new Error("Dispatch in reducer");try{l=!0,o=a(o,p)}finally{l=!1}for(var b=s=i,h=0;h<b.length;h++)(0,b[h])();return p}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:f,getState:c,replaceReducer:function(p){if(typeof p!==kr)throw new Error("next reducer"+ks);a=p,d({type:"@@redux/INIT"})}})[dm]=function(){var p,b=f;return(p={subscribe:function(h){if(typeof h!="object")throw new TypeError("Observer != obj");function m(){h.next&&h.next(c())}return m(),{unsubscribe:b(m)}}})[dm]=function(){return this},p},n}function $V(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+hr}function Aa(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function eL(){var e=arguments;return function(t){return function(r,n,a){var o,s=t(r,n,a),i=s.dispatch,l={getState:s.getState,dispatch:function(u){return i(u)}};return o=[].slice.call(e).map(function(u){return u(l)}),ye({},s,{dispatch:i=Aa.apply(void 0,o)(s.dispatch)})}}}var Br=gn+"anon_id",pn=gn+"user_id",Jn=gn+"user_traits",Ir="userId",Ln="anonymousId",Bs=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Mu=["name","EVENTS","config","loaded"],ve=Bs.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),pm=/^utm_/,hm=/^an_prop_/,bm=/^an_trait_/;function tL(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===ve.bootstrap){var o=a.params,s=a.user,i=a.persistedUser,l=a.initialUser,u=i.userId===s.userId;i.anonymousId!==s.anonymousId&&t(Br,s.anonymousId),u||t(pn,s.userId),l.traits&&t(Jn,ye({},u&&i.traits?i.traits:{},l.traits));var c=Object.keys(a.params);if(c.length){var f=o.an_uid,d=o.an_event,p=c.reduce(function(b,h){if(h.match(pm)||h.match(/^(d|g)clid/)){var m=h.replace(pm,"");b.campaign[m==="campaign"?"name":m]=o[h]}return h.match(hm)&&(b.props[h.replace(hm,"")]=o[h]),h.match(bm)&&(b.traits[h.replace(bm,"")]=o[h]),b},{campaign:{},props:{},traits:{}});r.dispatch(ye({type:ve.params,raw:o},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&r.dispatch({type:ve.campaign,campaign:p.campaign})}}return n(a)}}}}function rL(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===ve.setItemEnd){if(r.key===Br)return ye({},t,{anonymousId:r.value});if(r.key===pn)return ye({},t,{userId:r.value})}switch(r.type){case ve.identify:return Object.assign({},t,{userId:r.userId,traits:ye({},t.traits,r.traits)});case ve.reset:return[pn,Br,Jn].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function mm(e){return{userId:e.getItem(pn),anonymousId:e.getItem(Br),traits:e.getItem(Jn)}}var Nu=function(e){return gn+"TEMP"+gn+e};function nL(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(o){return function(s){return function(i){var l=i.userId,u=i.traits,c=i.options;if(i.type===ve.reset&&([pn,Jn,Br].forEach(function(p){n(p)}),[Ir,Ln,"traits"].forEach(function(p){xa(Nu(p))})),i.type===ve.identify){a(Br)||r(Br,ec());var f=a(pn),d=a(Jn)||{};f&&f!==l&&o.dispatch({type:ve.userIdChanged,old:{userId:f,traits:d},new:{userId:l,traits:u},options:c}),l&&r(pn,l),u&&r(Jn,ye({},d,u))}return s(i)}}}}var Ga={};function gm(e,t){Ga[e]&&nr(Ga[e])&&(Ga[e](t),delete Ga[e])}function QS(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(ye({},e,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return QS(e,t,r-10).then(n,a)})})}function XS(e,t,r){var n=t(),a=e.getState(),o=a.plugins,s=a.queue,i=a.user;if(!a.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(c,f,d){return o[f.plugin].loaded?(c.process.push(f),c.processIndex.push(d)):(c.requeue.push(f),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(c){var f=s.actions[c],d=f.plugin,p=f.payload.type,b=n[d][p];if(b&&nr(b)){var h=function(v,y){return v===void 0&&(v={}),y===void 0&&(y={}),[Ir,Ln].reduce(function(w,A){return v.hasOwnProperty(A)&&y[A]&&y[A]!==v[A]&&(w[A]=y[A]),w},v)}(f.payload,i);b({payload:h,config:o[d].config,instance:r});var m=p+":"+d;e.dispatch(ye({},h,{type:m,_:{called:m,from:"queueDrain"}}))}});var u=s.actions.filter(function(c,f){return!~l.processIndex.indexOf(f)});s.actions=u}}}var Yc=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,o=e.allPlugins,s=e.allMatches,i=e.store,l=e.EVENTS;try{var u=a.plugins,c=a.context,f=r.type,d=f.match(Gn),p=t.exact.map(function(m){return m.pluginName});d&&(p=s.during.map(function(m){return m.pluginName}));var b=function(m,v){return function(y,w,A){var S=w.config,E=w.name,C=E+"."+y.type;A&&(C=A.event);var P=y.type.match(Gn)?function(I,T,z,M,W){return function(q,V){var _=M?M.name:I,U=V&&ho(V)?V:z;if(M&&(!(U=V&&ho(V)?V:[I]).includes(I)||U.length!==1))throw new Error("Method "+T+" can only abort "+I+" plugin. "+JSON.stringify(U)+" input valid");return ye({},W,{abort:{reason:q,plugins:U,caller:T,_}})}}(E,C,v,A,y):function(I,T){return function(){throw new Error(I.type+" action not cancellable. Remove abort in "+T)}}(y,C);return{payload:aL(y),instance:m,config:S||{},abort:P}}}(n,p),h=t.exact.reduce(function(m,v){var y=v.pluginName,w=v.methodName,A=!1;return w.match(/^initialize/)||w.match(/^reset/)||(A=!u[y].loaded),c.offline&&w.match(/^(page|track|identify)/)&&(A=!0),m[""+y]=A,m},{});return Promise.resolve(t.exact.reduce(function(m,v,y){try{var w=v.pluginName;return Promise.resolve(m).then(function(A){function S(){return Promise.resolve(A)}var E=function(){if(t.namespaced&&t.namespaced[w])return Promise.resolve(t.namespaced[w].reduce(function(C,P,I){try{return Promise.resolve(C).then(function(T){return P.method&&nr(P.method)?(function(q,V){var _=Om(q);if(_&&_.name===V){var U=Om(_.method);throw new Error([V+" plugin is calling method "+q,"Plugins cant call self","Use "+_.method+" "+(U?"or "+U.method:"")+" in "+V+" plugin insteadof "+q].join(`
|
|
164
|
-
`))}}(P.methodName,P.pluginName),Promise.resolve(P.method({payload:T,instance:n,abort:(z=T,M=w,W=P.pluginName,function(q,V){return ye({},z,{abort:{reason:q,plugins:V||[M],caller:f,from:W||M}})}),config:wm(P.pluginName,u,o),plugins:u})).then(function(q){var V=Ct(q)?q:{};return Promise.resolve(ye({},T,V))})):T;var z,M,W})}catch(T){return Promise.reject(T)}},Promise.resolve(r))).then(function(C){A[w]=C});A[w]=r}();return E&&E.then?E.then(S):S()})}catch(A){return Promise.reject(A)}},Promise.resolve({}))).then(function(m){return Promise.resolve(t.exact.reduce(function(v,y,w){try{var A=t.exact.length===w+1,S=y.pluginName,E=o[S];return Promise.resolve(v).then(function(C){var P=m[S]?m[S]:{};if(d&&(P=C),Qc(P,S))return Hc({data:P,method:f,instance:n,pluginName:S,store:i}),Promise.resolve(C);if(Qc(C,S))return A&&Hc({data:C,method:f,instance:n,store:i}),Promise.resolve(C);if(h.hasOwnProperty(S)&&h[S]===!0)return i.dispatch({type:"queue",plugin:S,payload:P,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(C);var I=b(m[S],o[S]);return Promise.resolve(E[f]({abort:I.abort,payload:P,instance:n,config:wm(S,u,o),plugins:u})).then(function(T){var z=Ct(T)?T:{},M=ye({},C,z),W=m[S];if(Qc(W,S))Hc({data:W,method:f,instance:n,pluginName:S,store:i});else{var q=f+":"+S;(q.match(/:/g)||[]).length<2&&!f.match(vm)&&!f.match(ym)&&n.dispatch(ye({},d?M:P,{type:q,_:{called:q,from:"submethod"}}))}return Promise.resolve(M)})})}catch(C){return Promise.reject(C)}},Promise.resolve(r))).then(function(v){if(!(f.match(Gn)||f.match(/^registerPlugin/)||f.match(ym)||f.match(vm)||f.match(/^params/)||f.match(/^userIdChanged/))){if(l.plugins.includes(f),v._&&v._.originalAction===f)return v;var y=ye({},v,{_:{originalAction:v.type,called:v.type,from:"engineEnd"}});_S(v,t.exact.length)&&!f.match(/End$/)&&(y=ye({},y,{type:v.type+"Aborted"})),i.dispatch(y)}return v})})}catch(m){return Promise.reject(m)}},Gn=/Start$/,vm=/^bootstrap/,ym=/^ready/;function Hc(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(ye({},e.data,{type:r,_:{called:r,from:"abort"}}))}function wm(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function Sm(e,t){return t.reduce(function(r,n){return n[e]?r.concat({methodName:e,pluginName:n.name,method:n[e]}):r},[])}function Am(e,t){var r=e.replace(Gn,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function Qc(e,t){var r=e.abort;return!!r&&(r===!0||Em(r,t)||r&&Em(r.plugins,t))}function _S(e,t){var r=e.abort;if(!r)return!1;if(r===!0||Zn(r))return!0;var n=r.plugins;return ho(r)&&r.length===t||ho(n)&&n.length===t}function ho(e){return Array.isArray(e)}function Em(e,t){return!(!e||!ho(e))&&e.includes(t)}function Om(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function aL(e){return Object.keys(e).reduce(function(t,r){return r==="type"||(t[r]=Ct(e[r])?Object.assign({},e[r]):e[r]),t},{})}function oL(e,t,r){var n={};return function(a){return function(o){return function(s){try{var i,l=function(A){return i?A:o(f)},u=s.type,c=s.plugins,f=s;if(s.abort)return Promise.resolve(o(s));if(u===ve.enablePlugin&&a.dispatch({type:ve.initializeStart,plugins:c,disabled:[],fromEnable:!0,meta:s.meta}),u===ve.disablePlugin&&setTimeout(function(){return gm(s.meta.rid,{payload:s})},0),u===ve.initializeEnd){var d=t(),p=Object.keys(d),b=p.filter(function(A){return c.includes(A)}).map(function(A){return d[A]}),h=[],m=[],v=s.disabled,y=b.map(function(A){var S=A.loaded,E=A.name,C=A.config;return QS(A,function(){return S({config:C})},1e4).then(function(P){return n[E]||(a.dispatch({type:ve.pluginReadyType(E),name:E,events:Object.keys(A).filter(function(I){return!Mu.includes(I)})}),n[E]=!0),h=h.concat(E),A}).catch(function(P){if(P instanceof Error)throw new Error(P);return m=m.concat(P.name),P})});Promise.all(y).then(function(A){var S={plugins:h,failed:m,disabled:v};setTimeout(function(){p.length===y.length+v.length&&a.dispatch(ye({},{type:ve.ready},S))},0)})}var w=function(){if(u!==ve.bootstrap)return/^ready:([^:]*)$/.test(u)&&setTimeout(function(){return XS(a,t,e)},0),Promise.resolve(function(A,S,E,C,P){try{var I=nr(S)?S():S,T=A.type,z=T.replace(Gn,"");if(A._&&A._.called)return Promise.resolve(A);var M=E.getState(),W=(_=I,(U=M.plugins)===void 0&&(U={}),(Z=A.options)===void 0&&(Z={}),Object.keys(_).filter(function(O){var R=Z.plugins||{};return LV(R[O])?R[O]:R.all!==!1&&(!U[O]||U[O].enabled!==!1)}).map(function(O){return _[O]}));T===ve.initializeStart&&A.fromEnable&&(W=Object.keys(M.plugins).filter(function(O){var R=M.plugins[O];return A.plugins.includes(O)&&!R.initialized}).map(function(O){return I[O]}));var q=W.map(function(O){return O.name}),V=function(O,R,J){var D=Am(O).map(function(K){return Sm(K,R)});return R.reduce(function(K,$){var re=$.name,X=Am(O,re).map(function(ue){return Sm(ue,R)}),oe=X[0],ee=X[1],ne=X[2];return oe.length&&(K.beforeNS[re]=oe),ee.length&&(K.duringNS[re]=ee),ne.length&&(K.afterNS[re]=ne),K},{before:D[0],beforeNS:{},during:D[1],duringNS:{},after:D[2],afterNS:{}})}(T,W);return Promise.resolve(Yc({action:A,data:{exact:V.before,namespaced:V.beforeNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function(O){function R(){var K=function(){if(T.match(Gn))return Promise.resolve(Yc({action:ye({},J,{type:z+"End"}),data:{exact:V.after,namespaced:V.afterNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function($){$.meta&&$.meta.hasCallback&&gm($.meta.rid,{payload:$})})}();return K&&K.then?K.then(function(){return O}):O}if(_S(O,q.length))return O;var J,D=function(){if(T!==z)return Promise.resolve(Yc({action:ye({},O,{type:z}),data:{exact:V.during,namespaced:V.duringNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function(K){J=K});J=O}();return D&&D.then?D.then(R):R()})}catch(O){return Promise.reject(O)}var _,U,Z}(s,t,e,a,r)).then(function(A){return i=1,o(A)})}();return Promise.resolve(w&&w.then?w.then(l):l(w))}catch(A){return Promise.reject(A)}}}}}function sL(e){return function(t){return function(r){return function(n){var a=n.type,o=n.key,s=n.value,i=n.options;if(a===ve.setItem||a===ve.removeItem){if(n.abort)return r(n);a===ve.setItem?e.setItem(o,s,i):e.removeItem(o,i)}return r(n)}}}}var iL=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex(function(a){return a===t});n!==-1&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(a){var o={getState:r.getState,dispatch:function(i){return r.dispatch(i)}},s=e[t].map(function(i){return i(o)});return Aa.apply(void 0,s)(n)(a)}}}}};function lL(e){return function(t,r){t===void 0&&(t={});var n={};if(r.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=Cm(r.type,"registerPlugin"),o=e()[a];if(!o||!a)return t;var s=r.enabled,i=o.config;return n[a]={enabled:s,initialized:!!s&&!o.initialize,loaded:!!s&&!!o.loaded({config:i}),config:i},ye({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Cm(r.type,ve.initialize),u=e()[l];return u&&l?(n[l]=ye({},t[l],{initialized:!0,loaded:!!u.loaded({config:u.config})}),ye({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=ye({},t[r.name],{loaded:!0}),ye({},t,n);switch(r.type){case ve.disablePlugin:return ye({},t,Im(r.plugins,!1,t));case ve.enablePlugin:return ye({},t,Im(r.plugins,!0,t));default:return t}}}function Cm(e,t){return e.substring(t.length+1,e.length)}function Im(e,t,r){return e.reduce(function(n,a){return n[a]=ye({},r[a],{enabled:t}),n},r)}function $S(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var cL={last:{},history:[]};function uL(e,t){e===void 0&&(e=cL);var r=t.options,n=t.meta;if(t.type===ve.track){var a=$S(ye({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return ye({},e,{last:a,history:e.history.concat(a)})}return e}var fL={actions:[]};function dL(e,t){e===void 0&&(e=fL);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===ve.identify?[t].concat(e.actions):e.actions.concat(t),ye({},e,{actions:n});case"dequeue":return[];default:return e}}var eA=/#.*$/;function pL(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(eA,""):"")}var tA,rA,nA,aA,hL=function(e){if(e===void 0&&(e={}),!Yt)return e;var t=document,r=t.title,n=t.referrer,a=window,o=a.location,s=a.innerWidth,i=a.innerHeight,l=o.hash,u=o.search,c=function(d){var p=function(){if(Yt){for(var b,h=document.getElementsByTagName("link"),m=0;b=h[m];m++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return p?p.match(/\?/)?p:p+d:window.location.href.replace(eA,"")}(u),f={title:r,url:c,path:pL(c),hash:l,search:u,width:s,height:i};return n&&n!==""&&(f.referrer=n),ye({},f,e)},bL={last:{},history:[]};function mL(e,t){e===void 0&&(e=bL);var r=t.options;if(t.type===ve.page){var n=$S(ye({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return ye({},e,{last:n,history:e.history.concat(n)})}return e}tA=function(){if(!Yt)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),rA=Yt?document.referrer:null,nA=YV(),aA=HV();var km={initialized:!1,sessionId:ec(),app:null,version:null,debug:!1,offline:!!Yt&&!navigator.onLine,os:{name:tA},userAgent:Yt?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:aA,locale:nA,campaign:{},referrer:rA};function gL(e,t){e===void 0&&(e=km);var r=e.initialized,n=t.campaign;switch(t.type){case ve.campaign:return ye({},e,{campaign:n});case ve.offline:return ye({},e,{offline:!0});case ve.online:return ye({},e,{offline:!1});default:return r?e:ye({},km,e,{initialized:!0})}}var vL=["plugins","reducers","storage"];function yL(e,t,r){if(Yt){var n=window[(r?"add":"remove")+"EventListener"];e.split(" ").forEach(function(a){n(a,t)})}}function wL(e){var t=yL.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(r){return t(!1)}}function oA(){return yn("analytics",[]),function(e){return function(t,r,n){var a=e(t,r,n),o=a.dispatch;return Object.assign(a,{dispatch:function(s){return Sa[wa].analytics.push(s.action||s),o(s)}})}}}function Pm(e){return function(){return Aa(Aa.apply(null,arguments),oA())}}function Xc(e){return e?WV(e)?e:[e]:[]}function xm(e,t,r){e===void 0&&(e={});var n,a,o=ec();return t&&(Ga[o]=(n=t,a=function(s){for(var i,l=s||Array.prototype.slice.call(arguments),u=0;u<l.length;u++)if(nr(l[u])){i=l[u];break}return i}(r),function(s){a&&a(s),n(s)})),ye({},e,{rid:o,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function SL(e){e===void 0&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce(function(O,R){if(nr(R))return O.middlewares=O.middlewares.concat(R),O;if(R.NAMESPACE&&(R.name=R.NAMESPACE),!R.name)throw new Error("https://lytics.dev/errors/1");R.config||(R.config={});var J=R.EVENTS?Object.keys(R.EVENTS).map(function($){return R.EVENTS[$]}):[];O.pluginEnabled[R.name]=!(R.enabled===!1||R.config.enabled===!1),delete R.enabled,R.methods&&(O.methods[R.name]=Object.keys(R.methods).reduce(function($,re){var X;return $[re]=(X=R.methods[re],function(){for(var oe=Array.prototype.slice.call(arguments),ee=new Array(X.length),ne=0;ne<oe.length;ne++)ee[ne]=oe[ne];return ee[ee.length]=S,X.apply({instance:S},ee)}),$},{}),delete R.methods);var D=Object.keys(R).concat(J),K=new Set(O.events.concat(D));if(O.events=Array.from(K),O.pluginsArray=O.pluginsArray.concat(R),O.plugins[R.name])throw new Error(R.name+"AlreadyLoaded");return O.plugins[R.name]=R,O.plugins[R.name].loaded||(O.plugins[R.name].loaded=function(){return!0}),O},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=e.storage?e.storage:{getItem:vn,setItem:yn,removeItem:xa},o=function(O){return function(R,J,D){return J.getState("user")[R]||(D&&Ct(D)&&D[R]?D[R]:mm(O)[R]||vn(Nu(R))||null)}}(a),s=n.plugins,i=n.events.filter(function(O){return!Mu.includes(O)}).sort(),l=new Set(i.concat(Bs).filter(function(O){return!Mu.includes(O)})),u=Array.from(l).sort(),c=function(){return s},f=new iL,d=f.addMiddleware,p=f.removeMiddleware,b=f.dynamicMiddlewares,h=function(){throw new Error("Abort disabled inListener")},m=QV(),v=mm(a),y=ye({},v,r,m.an_uid?{userId:m.an_uid}:{},m.an_aid?{anonymousId:m.an_aid}:{});y.anonymousId||(y.anonymousId=ec());var w=ye({enable:function(O,R){return new Promise(function(J){V.dispatch({type:ve.enablePlugin,plugins:Xc(O),_:{originalAction:ve.enablePlugin}},J,[R])})},disable:function(O,R){return new Promise(function(J){V.dispatch({type:ve.disablePlugin,plugins:Xc(O),_:{originalAction:ve.disablePlugin}},J,[R])})}},n.methods),A=!1,S={identify:function(O,R,J,D){try{var K=Zn(O)?O:null,$=Ct(O)?O:R,re=J||{},X=S.user();yn(Nu(Ir),K);var oe=K||$.userId||o(Ir,S,$);return Promise.resolve(new Promise(function(ee){V.dispatch(ye({type:ve.identifyStart,userId:oe,traits:$||{},options:re,anonymousId:X.anonymousId},X.id&&X.id!==K&&{previousId:X.id}),ee,[R,J,D])}))}catch(ee){return Promise.reject(ee)}},track:function(O,R,J,D){try{var K=Ct(O)?O.event:O;if(!K||!Zn(K))throw new Error("EventMissing");var $=Ct(O)?O:R||{},re=Ct(J)?J:{};return Promise.resolve(new Promise(function(X){V.dispatch({type:ve.trackStart,event:K,properties:$,options:re,userId:o(Ir,S,R),anonymousId:o(Ln,S,R)},X,[R,J,D])}))}catch(X){return Promise.reject(X)}},page:function(O,R,J){try{var D=Ct(O)?O:{},K=Ct(R)?R:{};return Promise.resolve(new Promise(function($){V.dispatch({type:ve.pageStart,properties:hL(D),options:K,userId:o(Ir,S,D),anonymousId:o(Ln,S,D)},$,[O,R,J])}))}catch($){return Promise.reject($)}},user:function(O){if(O===Ir||O==="id")return o(Ir,S);if(O===Ln||O==="anonId")return o(Ln,S);var R=S.getState("user");return O?cm(R,O):R},reset:function(O){return new Promise(function(R){V.dispatch({type:ve.resetStart},R,O)})},ready:function(O){return A&&O({plugins:w,instance:S}),S.on(ve.ready,function(R){O(R),A=!0})},on:function(O,R){if(!O||!nr(R))return!1;if(O===ve.bootstrap)throw new Error(".on disabled for "+O);var J=/Start$|Start:/;if(O==="*"){var D=function(X){return function(oe){return function(ee){return ee.type.match(J)&&R({payload:ee,instance:S,plugins:s}),oe(ee)}}},K=function(X){return function(oe){return function(ee){return ee.type.match(J)||R({payload:ee,instance:S,plugins:s}),oe(ee)}}};return d(D,Ps),d(K,xs),function(){p(D,Ps),p(K,xs)}}var $=O.match(J)?Ps:xs,re=function(X){return function(oe){return function(ee){return ee.type===O&&R({payload:ee,instance:S,plugins:s,abort:h}),oe(ee)}}};return d(re,$),function(){return p(re,$)}},once:function(O,R){if(!O||!nr(R))return!1;if(O===ve.bootstrap)throw new Error(".once disabled for "+O);var J=S.on(O,function(D){R({payload:D.payload,instance:S,plugins:s,abort:h}),J()});return J},getState:function(O){var R=V.getState();return O?cm(R,O):Object.assign({},R)},dispatch:function(O){var R=Zn(O)?{type:O}:O;if(Bs.includes(R.type))throw new Error("reserved action "+R.type);var J=ye({},R,{_:ye({originalAction:R.type},O._||{})});V.dispatch(J)},enablePlugin:w.enable,disablePlugin:w.disable,plugins:w,storage:{getItem:a.getItem,setItem:function(O,R,J){V.dispatch({type:ve.setItemStart,key:O,value:R,options:J})},removeItem:function(O,R){V.dispatch({type:ve.removeItemStart,key:O,options:R})}},setAnonymousId:function(O,R){S.storage.setItem(Br,O,R)},events:{core:Bs,plugins:i}},E=n.middlewares.concat([function(O){return function(R){return function(J){return J.meta||(J.meta=xm()),R(J)}}},b(Ps),oL(S,c,{all:u,plugins:i}),sL(a),tL(S),nL(S),b(xs)]),C={context:gL,user:rL(a),page:mL,track:uL,plugins:lL(c),queue:dL},P=Aa,I=Aa;if(Yt&&e.debug){var T=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;T&&(P=T({trace:!0,traceLimit:25})),I=function(){return arguments.length===0?oA():Ct(typeof arguments[0])?Pm():Pm().apply(null,arguments)}}var z,M=function(O){return Object.keys(O).reduce(function(R,J){return vL.includes(J)||(R[J]=O[J]),R},{})}(e),W=n.pluginsArray.reduce(function(O,R){var J=R.name,D=R.config,K=R.loaded,$=n.pluginEnabled[J];return O[J]={enabled:$,initialized:!!$&&!R.initialize,loaded:!!K({config:D}),config:D},O},{}),q={context:M,user:y,plugins:W},V=HS(function(O){for(var R=Object.keys(O),J={},D=0;D<R.length;D++){var K=R[D];typeof O[K]===kr&&(J[K]=O[K])}var $,re=Object.keys(J);try{(function(X){Object.keys(X).forEach(function(oe){var ee=X[oe];if(typeof ee(void 0,{type:"@@redux/INIT"})===hr||typeof ee(void 0,{type:_V})===hr)throw new Error("reducer "+oe+" "+hr)})})(J)}catch(X){$=X}return function(X,oe){if(X===void 0&&(X={}),$)throw $;for(var ee=!1,ne={},ue=0;ue<re.length;ue++){var de=re[ue],H=X[de],Q=(0,J[de])(H,oe);if(typeof Q===hr){var ge=$V(de,oe);throw new Error(ge)}ne[de]=Q,ee=ee||Q!==H}return ee?ne:X}}(ye({},C,t)),q,I(P(eL.apply(void 0,E))));V.dispatch=(z=V.dispatch,function(O,R,J){var D=ye({},O,{meta:xm(O.meta,R,Xc(J))});return z.apply(null,[D])});var _=Object.keys(s);V.dispatch({type:ve.bootstrap,plugins:_,config:M,params:m,user:y,initialUser:r,persistedUser:v});var U=_.filter(function(O){return n.pluginEnabled[O]}),Z=_.filter(function(O){return!n.pluginEnabled[O]});return V.dispatch({type:ve.registerPlugins,plugins:_,enabled:n.pluginEnabled}),n.pluginsArray.map(function(O,R){var J=O.bootstrap,D=O.config,K=O.name;J&&nr(J)&&J({instance:S,config:D,payload:O}),V.dispatch({type:ve.registerPluginType(K),name:K,enabled:n.pluginEnabled[K],plugin:O}),n.pluginsArray.length===R+1&&V.dispatch({type:ve.initializeStart,plugins:U,disabled:Z})}),wL(function(O){V.dispatch({type:O?ve.offline:ve.online})}),function(O,R,J){setInterval(function(){return XS(O,R,J)},3e3)}(V,c,S),S}var Ps="before",xs="after",no="cookie",_r=lA(),sA=tc,AL=tc;function iA(e){return _r?tc(e,"",-1):xa(e)}function lA(){if(_r!==void 0)return _r;var e="cookiecookie";try{tc(e,e),_r=document.cookie.indexOf(e)!==-1,iA(e)}catch{_r=!1}return _r}function tc(e,t,r,n,a,o){if(typeof window<"u"){var s=arguments.length>1;return _r===!1&&(s?yn(e,t):vn(e)),s?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var ao="localStorage",EL=pd.bind(null,"localStorage");Ra("localStorage","getItem",vn);Ra("localStorage","setItem",yn);Ra("localStorage","removeItem",xa);var oo="sessionStorage",OL=pd.bind(null,"sessionStorage");Ra("sessionStorage","getItem",vn);Ra("sessionStorage","setItem",yn);Ra("sessionStorage","removeItem",xa);function Yn(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(Ct(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var CL=EL(),IL=OL(),kL=lA();function cA(e,t){if(e){var r=hd(t),n=!vd(r),a=bd(r)?Yn(localStorage.getItem(e)):void 0;if(n&&!Vn(a))return a;var o=md(r)?Yn(sA(e)):void 0;if(n&&o)return o;var s=gd(r)?Yn(sessionStorage.getItem(e)):void 0;if(n&&s)return s;var i=vn(e);return n?i:{localStorage:a,sessionStorage:s,cookie:o,global:i}}}function PL(e,t,r){if(e&&!Vn(t)){var n={},a=hd(r),o=JSON.stringify(t),s=!vd(a);return bd(a)&&(n[ao]=Rs(ao,t,Yn(localStorage.getItem(e))),localStorage.setItem(e,o),s)?n[ao]:md(a)&&(n[no]=Rs(no,t,Yn(sA(e))),AL(e,o),s)?n[no]:gd(a)&&(n[oo]=Rs(oo,t,Yn(sessionStorage.getItem(e))),sessionStorage.setItem(e,o),s)?n[oo]:(n[ro]=Rs(ro,t,vn(e)),yn(e,t),s?n[ro]:n)}}function xL(e,t){if(e){var r=hd(t),n=cA(e,ZS),a={};return!Vn(n.localStorage)&&bd(r)&&(localStorage.removeItem(e),a[ao]=n.localStorage),!Vn(n.cookie)&&md(r)&&(iA(e),a[no]=n.cookie),!Vn(n.sessionStorage)&&gd(r)&&(sessionStorage.removeItem(e),a[oo]=n.sessionStorage),!Vn(n.global)&&rc(r,ro)&&(xa(e),a[ro]=n.global),a}}function hd(e){return e?Zn(e)?e:e.storage:US}function bd(e){return CL&&rc(e,ao)}function md(e){return kL&&rc(e,no)}function gd(e){return IL&&rc(e,oo)}function vd(e){return e===ZS||e==="all"}function rc(e,t){return e===US||e===t||vd(e)}function Rs(e,t,r){return{location:e,current:t,previous:r}}var RL={setItem:PL,getItem:cA,removeItem:xL};function ML(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Rm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Mm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rm(Object(r),!0).forEach(function(n){ML(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function NL(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:RL};return SL(Mm(Mm({},t),e))}const TL="@chaibuilder/sdk",jL="0.1.21",zL="module",FL=["dist"],qL="dist/core.js",DL=!1,BL={".":{import:"./dist/core.js",require:"./dist/core.cjs",types:"./dist/core.d.ts"},"./render":{import:"./dist/render.js",require:"./dist/render.cjs",types:"./dist/render.d.ts"},"./ui":{import:"./dist/ui.js",require:"./dist/ui.cjs",types:"./dist/ui.d.ts"},"./lib":{import:"./dist/lib.js",require:"./dist/lib.cjs",types:"./dist/lib.d.ts"},"./server":{import:"./dist/server.js",require:"./dist/server.cjs",types:"./dist/server.d.ts"},"./styles":{import:"./dist/style.css",require:"./dist/style.css"}},VL={dev:"vite",build:"tsc && vite build",lint:"eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",preview:"vite preview",test:"jest --colors","test:watch":"jest --watch --colors","test:coverage":"jest --coverage --colors",e2e:"playwright test","e2e:report":"playwright show-report","e2e:ui":"playwright test --ui",docs:"jsdoc -c jsdoc.conf.json"},LL={"@bobthered/tailwindcss-palette-generator":"3.1.1","@chaibuilder/blocks":"0.1.21","@floating-ui/dom":"1.4.5","@floating-ui/react-dom":"2.0.1","@mhsdesign/jit-browser-tailwindcss":"0.3.0","@minoru/react-dnd-treeview":"3.4.4","@radix-ui/react-accordion":"^1.1.2","@radix-ui/react-alert-dialog":"^1.0.4","@radix-ui/react-context-menu":"^2.1.4","@radix-ui/react-dialog":"^1.0.4","@radix-ui/react-dropdown-menu":"^2.0.5","@radix-ui/react-hover-card":"^1.0.6","@radix-ui/react-icons":"^1.3.0","@radix-ui/react-label":"^2.0.2","@radix-ui/react-menubar":"^1.0.3","@radix-ui/react-navigation-menu":"^1.1.3","@radix-ui/react-popover":"^1.0.6","@radix-ui/react-scroll-area":"^1.0.4","@radix-ui/react-select":"^1.2.2","@radix-ui/react-separator":"^1.0.3","@radix-ui/react-slot":"^1.0.2","@radix-ui/react-switch":"^1.0.3","@radix-ui/react-tabs":"^1.0.4","@radix-ui/react-toast":"^1.1.4","@radix-ui/react-toggle":"^1.0.3","@radix-ui/react-tooltip":"^1.0.6","@react-hookz/web":"23.1.0","@rjsf/core":"5.11.2","@rjsf/utils":"5.11.2","@rjsf/validator-ajv8":"5.11.2","@tailwindcss/aspect-ratio":"0.4.2","@tailwindcss/forms":"^0.5.6","@tailwindcss/line-clamp":"^0.4.4","@tailwindcss/typography":"^0.5.10","@tanstack/react-query":"^5.8.4",analytics:"^0.8.9","class-variance-authority":"0.6.1",clsx:"1.2.1",cmdk:"0.2.0","date-fns":"^2.30.0",flagged:"2.0.9","flat-to-nested":"1.1.1","focus-trap-react":"^10.2.1","forgiving-xml-parser":"1.4.0","framer-motion":"^10.12.18","fuse.js":"6.6.2","gray-matter":"^4.0.3",himalaya:"^1.1.0","html-formatter":"0.1.9",i18next:"^23.2.8",jotai:"2.2.2",lodash:"4.17.21","lucide-react":"^0.244.0",nanoid:"^4.0.2","post-robot":"10.0.46",react:"^18.2.0","react-autosuggest":"10.1.0","react-colorful":"5.6.1","react-dnd":"16.0.1","react-dnd-html5-backend":"16.0.1","react-dom":"^18.2.0","react-hotkeys-hook":"4.4.1","react-i18next":"13.0.1","react-icons":"^4.10.1","react-icons-picker":"^1.0.9","react-json-view":"^1.21.3","react-quill":"^2.0.0","react-textarea-autosize":"^8.5.2","react-wrap-balancer":"^1.0.0","redux-undo":"1.1.0",sonner:"^1.2.0","tailwind-merge":"1.13.2","tailwindcss-animate":"1.0.6","tippy.js":"^6.3.7","unist-util-visit":"^4.1.2","unsplash-js":"^7.0.18"},KL={"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@emotion/react":"^11.11.1","@faker-js/faker":"^8.3.1","@nozbe/watermelondb":"^0.27.1","@playwright/test":"^1.39.0","@tanstack/eslint-plugin-query":"^5.8.4","@testing-library/react-hooks":"^8.0.1","@types/better-sqlite3":"^7.6.7","@types/jest":"^29.5.7","@types/lodash":"^4.14.200","@types/node":"^20.8.10","@types/react":"^18.2.15","@types/react-dom":"^18.2.7","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","@vitejs/plugin-react-swc":"^3.3.2",autoprefixer:"^10.4.16","better-docs":"^2.7.2","better-sqlite3":"^9.1.1","drizzle-kit":"^0.20.4","drizzle-orm":"^0.29.0",eslint:"^8.45.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0","jotai-devtools":"^0.7.1",jsdoc:"^4.0.2",msw:"^2.0.8",postcss:"^8.4.31",prettier:"^3.0.3","prettier-plugin-tailwindcss":"^0.5.6","prop-types":"^15.8.1","react-router-dom":"^6.19.0",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},WL={workerDirectory:"public"},UL={name:TL,private:!1,version:jL,type:zL,files:FL,main:qL,sideEffects:DL,exports:BL,scripts:VL,dependencies:LL,devDependencies:KL,msw:WL},Nm="https://api.chaibuilder.com",Tm=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function ZL(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(Tm())return;const{payload:t}=e;fetch(`${Nm}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(r=>r.json())},track:({payload:e})=>{if(typeof window>"u")return!1;Tm()||fetch(`${Nm}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const JL=NL({app:"chaibuilder",version:UL.version,plugins:[ZL()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",KA);const GL=e=>ie.jsxRuntimeExports.jsx(ie.jsxRuntimeExports.Fragment,{children:e.children}),YL=e=>{const{dndOptions:t={backend:Od.MultiBackend}}=e,[r]=sS(),[,n]=ad(),a=dd();return g.useEffect(()=>{lm.set(xt.chaiBuilderPropsAtom,B.omit(e,["blocks","subPages","brandingOptions","dataProvidersAtom"]))},[e]),g.useEffect(()=>{lm.set(ld,e.dataProviders||[])},[e.dataProviders]),g.useEffect(()=>{r(tg.syncBlocksWithDefaults(e.blocks||[])),a()},[e.blocks]),g.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions,n]),g.useEffect(()=>{JL.page()},[]),ie.jsxRuntimeExports.jsx(MA.DndProvider,{...t,options:Od.getBackendOptions(),children:ie.jsxRuntimeExports.jsx(GL,{children:ie.jsxRuntimeExports.jsx(qV,{})})})},uA=e=>ie.jsxRuntimeExports.jsxs(eS,{children:[ie.jsxRuntimeExports.jsxs(RA.FlagsProvider,{features:rB,children:[ie.jsxRuntimeExports.jsx(tB,{}),ie.jsxRuntimeExports.jsx(YL,{...e})]}),ie.jsxRuntimeExports.jsx(xt.Toaster,{})]});var Ma=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ea=typeof window>"u"||"Deno"in window;function Dt(){}function HL(e,t){return typeof e=="function"?e(t):e}function Tu(e){return typeof e=="number"&&e>=0&&e!==1/0}function fA(e,t){return Math.max(e+(t||0)-Date.now(),0)}function jm(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:s,stale:i}=e;if(s){if(n){if(t.queryHash!==yd(s,t.options))return!1}else if(!mo(t.queryKey,s))return!1}if(r!=="all"){const l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||typeof a<"u"&&a!==t.state.fetchStatus||o&&!o(t))}function zm(e,t){const{exact:r,status:n,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(bo(t.options.mutationKey)!==bo(o))return!1}else if(!mo(t.options.mutationKey,o))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function yd(e,t){return((t==null?void 0:t.queryKeyHashFn)||bo)(e)}function bo(e){return JSON.stringify(e,(t,r)=>ju(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function mo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!mo(e[r],t[r])):!1}function dA(e,t){if(e===t)return e;const r=Fm(e)&&Fm(t);if(r||ju(e)&&ju(t)){const n=r?e.length:Object.keys(e).length,a=r?t:Object.keys(t),o=a.length,s=r?[]:{};let i=0;for(let l=0;l<o;l++){const u=r?l:a[l];s[u]=dA(e[u],t[u]),s[u]===e[u]&&i++}return n===o&&i===n?e:s}return t}function ml(e,t){if(e&&!t||t&&!e)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Fm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ju(e){if(!qm(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const r=t.prototype;return!(!qm(r)||!r.hasOwnProperty("isPrototypeOf"))}function qm(e){return Object.prototype.toString.call(e)==="[object Object]"}function pA(e){return new Promise(t=>{setTimeout(t,e)})}function Dm(e){pA(0).then(e)}function zu(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?dA(e,t):t}function QL(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function XL(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var tn,Pr,Hn,Km,_L=(Km=class extends Ma{constructor(){super();fe(this,tn,void 0);fe(this,Pr,void 0);fe(this,Hn,void 0);se(this,Hn,t=>{if(!Ea&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){x(this,Pr)||this.setEventListener(x(this,Hn))}onUnsubscribe(){var t;this.hasListeners()||((t=x(this,Pr))==null||t.call(this),se(this,Pr,void 0))}setEventListener(t){var r;se(this,Hn,t),(r=x(this,Pr))==null||r.call(this),se(this,Pr,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){x(this,tn)!==t&&(se(this,tn,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof x(this,tn)=="boolean"?x(this,tn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},tn=new WeakMap,Pr=new WeakMap,Hn=new WeakMap,Km),gl=new _L,Qn,xr,Xn,Wm,$L=(Wm=class extends Ma{constructor(){super();fe(this,Qn,!0);fe(this,xr,void 0);fe(this,Xn,void 0);se(this,Xn,t=>{if(!Ea&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){x(this,xr)||this.setEventListener(x(this,Xn))}onUnsubscribe(){var t;this.hasListeners()||((t=x(this,xr))==null||t.call(this),se(this,xr,void 0))}setEventListener(t){var r;se(this,Xn,t),(r=x(this,xr))==null||r.call(this),se(this,xr,t(this.setOnline.bind(this)))}setOnline(t){x(this,Qn)!==t&&(se(this,Qn,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return x(this,Qn)}},Qn=new WeakMap,xr=new WeakMap,Xn=new WeakMap,Wm),vl=new $L;function eK(e){return Math.min(1e3*2**e,3e4)}function nc(e){return(e??"online")==="online"?vl.isOnline():!0}var hA=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function _c(e){return e instanceof hA}function bA(e){let t=!1,r=0,n=!1,a,o,s;const i=new Promise((m,v)=>{o=m,s=v}),l=m=>{var v;n||(p(new hA(m)),(v=e.abort)==null||v.call(e))},u=()=>{t=!0},c=()=>{t=!1},f=()=>!gl.isFocused()||e.networkMode!=="always"&&!vl.isOnline(),d=m=>{var v;n||(n=!0,(v=e.onSuccess)==null||v.call(e,m),a==null||a(),o(m))},p=m=>{var v;n||(n=!0,(v=e.onError)==null||v.call(e,m),a==null||a(),s(m))},b=()=>new Promise(m=>{var v;a=y=>{const w=n||!f();return w&&m(y),w},(v=e.onPause)==null||v.call(e)}).then(()=>{var m;a=void 0,n||(m=e.onContinue)==null||m.call(e)}),h=()=>{if(n)return;let m;try{m=e.fn()}catch(v){m=Promise.reject(v)}Promise.resolve(m).then(d).catch(v=>{var E;if(n)return;const y=e.retry??(Ea?0:3),w=e.retryDelay??eK,A=typeof w=="function"?w(r,v):w,S=y===!0||typeof y=="number"&&r<y||typeof y=="function"&&y(r,v);if(t||!S){p(v);return}r++,(E=e.onFail)==null||E.call(e,r,v),pA(A).then(()=>{if(f())return b()}).then(()=>{t?p(v):h()})})};return nc(e.networkMode)?h():b().then(h),{promise:i,cancel:l,continue:()=>(a==null?void 0:a())?i:Promise.resolve(),cancelRetry:u,continueRetry:c}}function tK(){let e=[],t=0,r=c=>{c()},n=c=>{c()};const a=c=>{let f;t++;try{f=c()}finally{t--,t||i()}return f},o=c=>{t?e.push(c):Dm(()=>{r(c)})},s=c=>(...f)=>{o(()=>{c(...f)})},i=()=>{const c=e;e=[],c.length&&Dm(()=>{n(()=>{c.forEach(f=>{r(f)})})})};return{batch:a,batchCalls:s,schedule:o,setNotifyFunction:c=>{r=c},setBatchNotifyFunction:c=>{n=c}}}var Qe=tK(),rn,Um,mA=(Um=class{constructor(){fe(this,rn,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Tu(this.gcTime)&&se(this,rn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ea?1/0:5*60*1e3))}clearGcTimeout(){x(this,rn)&&(clearTimeout(x(this,rn)),se(this,rn,void 0))}},rn=new WeakMap,Um),_n,$n,jt,Rr,zt,_e,go,nn,ea,Vs,Jt,ur,Zm,rK=(Zm=class extends mA{constructor(t){super();fe(this,ea);fe(this,Jt);fe(this,_n,void 0);fe(this,$n,void 0);fe(this,jt,void 0);fe(this,Rr,void 0);fe(this,zt,void 0);fe(this,_e,void 0);fe(this,go,void 0);fe(this,nn,void 0);se(this,nn,!1),se(this,go,t.defaultOptions),Se(this,ea,Vs).call(this,t.options),se(this,_e,[]),se(this,jt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,se(this,_n,t.state||nK(this.options)),this.state=x(this,_n),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!x(this,_e).length&&this.state.fetchStatus==="idle"&&x(this,jt).remove(this)}setData(t,r){const n=zu(this.state.data,t,this.options);return Se(this,Jt,ur).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Se(this,Jt,ur).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n;const r=x(this,Rr);return(n=x(this,zt))==null||n.cancel(t),r?r.then(Dt).catch(Dt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(x(this,_n))}isActive(){return x(this,_e).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||x(this,_e).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!fA(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=x(this,_e).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=x(this,zt))==null||r.continue()}onOnline(){var r;const t=x(this,_e).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=x(this,zt))==null||r.continue()}addObserver(t){x(this,_e).includes(t)||(x(this,_e).push(t),this.clearGcTimeout(),x(this,jt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){x(this,_e).includes(t)&&(se(this,_e,x(this,_e).filter(r=>r!==t)),x(this,_e).length||(x(this,zt)&&(x(this,nn)?x(this,zt).cancel({revert:!0}):x(this,zt).cancelRetry()),this.scheduleGc()),x(this,jt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return x(this,_e).length}invalidate(){this.state.isInvalidated||Se(this,Jt,ur).call(this,{type:"invalidate"})}fetch(t,r){var u,c,f,d;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(x(this,Rr))return(u=x(this,zt))==null||u.continueRetry(),x(this,Rr)}if(t&&Se(this,ea,Vs).call(this,t),!this.options.queryFn){const p=x(this,_e).find(b=>b.options.queryFn);p&&Se(this,ea,Vs).call(this,p.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,a={queryKey:this.queryKey,meta:this.meta},o=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(se(this,nn,!0),n.signal)})};o(a);const s=()=>this.options.queryFn?(se(this,nn,!1),this.options.persister?this.options.persister(this.options.queryFn,a,this):this.options.queryFn(a)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),i={fetchOptions:r,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};o(i),(c=this.options.behavior)==null||c.onFetch(i,this),se(this,$n,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=i.fetchOptions)==null?void 0:f.meta))&&Se(this,Jt,ur).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta});const l=p=>{var b,h,m,v;_c(p)&&p.silent||Se(this,Jt,ur).call(this,{type:"error",error:p}),_c(p)||((h=(b=x(this,jt).config).onError)==null||h.call(b,p,this),(v=(m=x(this,jt).config).onSettled)==null||v.call(m,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return se(this,zt,bA({fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:p=>{var b,h,m,v;if(typeof p>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(p),(h=(b=x(this,jt).config).onSuccess)==null||h.call(b,p,this),(v=(m=x(this,jt).config).onSettled)==null||v.call(m,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,b)=>{Se(this,Jt,ur).call(this,{type:"failed",failureCount:p,error:b})},onPause:()=>{Se(this,Jt,ur).call(this,{type:"pause"})},onContinue:()=>{Se(this,Jt,ur).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode})),se(this,Rr,x(this,zt).promise),x(this,Rr)}},_n=new WeakMap,$n=new WeakMap,jt=new WeakMap,Rr=new WeakMap,zt=new WeakMap,_e=new WeakMap,go=new WeakMap,nn=new WeakMap,ea=new WeakSet,Vs=function(t){this.options={...x(this,go),...t},this.updateGcTime(this.options.gcTime)},Jt=new WeakSet,ur=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:nc(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return _c(a)&&a.revert&&x(this,$n)?{...x(this,$n),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),Qe.batch(()=>{x(this,_e).forEach(n=>{n.onQueryUpdate()}),x(this,jt).notify({query:this,type:"updated",action:t})})},Zm);function nK(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=typeof t<"u",n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Qt,Jm,aK=(Jm=class extends Ma{constructor(t={}){super();fe(this,Qt,void 0);this.config=t,se(this,Qt,new Map)}build(t,r,n){const a=r.queryKey,o=r.queryHash??yd(a,r);let s=this.get(o);return s||(s=new rK({cache:this,queryKey:a,queryHash:o,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(s)),s}add(t){x(this,Qt).has(t.queryHash)||(x(this,Qt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=x(this,Qt).get(t.queryHash);r&&(t.destroy(),r===t&&x(this,Qt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Qe.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return x(this,Qt).get(t)}getAll(){return[...x(this,Qt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>jm(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>jm(t,n)):r}notify(t){Qe.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qt=new WeakMap,Jm),Xt,vo,Ot,ta,_t,Cr,Gm,oK=(Gm=class extends mA{constructor(t){super();fe(this,_t);fe(this,Xt,void 0);fe(this,vo,void 0);fe(this,Ot,void 0);fe(this,ta,void 0);this.mutationId=t.mutationId,se(this,vo,t.defaultOptions),se(this,Ot,t.mutationCache),se(this,Xt,[]),this.state=t.state||gA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...x(this,vo),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){x(this,Xt).includes(t)||(x(this,Xt).push(t),this.clearGcTimeout(),x(this,Ot).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){se(this,Xt,x(this,Xt).filter(r=>r!==t)),this.scheduleGc(),x(this,Ot).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){x(this,Xt).length||(this.state.status==="pending"?this.scheduleGc():x(this,Ot).remove(this))}continue(){var t;return((t=x(this,ta))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,o,s,i,l,u,c,f,d,p,b,h,m,v,y,w,A,S,E,C;const r=()=>(se(this,ta,bA({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,I)=>{Se(this,_t,Cr).call(this,{type:"failed",failureCount:P,error:I})},onPause:()=>{Se(this,_t,Cr).call(this,{type:"pause"})},onContinue:()=>{Se(this,_t,Cr).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),x(this,ta).promise),n=this.state.status==="pending";try{if(!n){Se(this,_t,Cr).call(this,{type:"pending",variables:t}),await((o=(a=x(this,Ot).config).onMutate)==null?void 0:o.call(a,t,this));const I=await((i=(s=this.options).onMutate)==null?void 0:i.call(s,t));I!==this.state.context&&Se(this,_t,Cr).call(this,{type:"pending",context:I,variables:t})}const P=await r();return await((u=(l=x(this,Ot).config).onSuccess)==null?void 0:u.call(l,P,t,this.state.context,this)),await((f=(c=this.options).onSuccess)==null?void 0:f.call(c,P,t,this.state.context)),await((p=(d=x(this,Ot).config).onSettled)==null?void 0:p.call(d,P,null,this.state.variables,this.state.context,this)),await((h=(b=this.options).onSettled)==null?void 0:h.call(b,P,null,t,this.state.context)),Se(this,_t,Cr).call(this,{type:"success",data:P}),P}catch(P){try{throw await((v=(m=x(this,Ot).config).onError)==null?void 0:v.call(m,P,t,this.state.context,this)),await((w=(y=this.options).onError)==null?void 0:w.call(y,P,t,this.state.context)),await((S=(A=x(this,Ot).config).onSettled)==null?void 0:S.call(A,void 0,P,this.state.variables,this.state.context,this)),await((C=(E=this.options).onSettled)==null?void 0:C.call(E,void 0,P,t,this.state.context)),P}finally{Se(this,_t,Cr).call(this,{type:"error",error:P})}}}},Xt=new WeakMap,vo=new WeakMap,Ot=new WeakMap,ta=new WeakMap,_t=new WeakSet,Cr=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!nc(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Qe.batch(()=>{x(this,Xt).forEach(n=>{n.onMutationUpdate(t)}),x(this,Ot).notify({mutation:this,type:"updated",action:t})})},Gm);function gA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,yo,an,Ym,sK=(Ym=class extends Ma{constructor(t={}){super();fe(this,Ft,void 0);fe(this,yo,void 0);fe(this,an,void 0);this.config=t,se(this,Ft,[]),se(this,yo,0)}build(t,r,n){const a=new oK({mutationCache:this,mutationId:++es(this,yo)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){x(this,Ft).push(t),this.notify({type:"added",mutation:t})}remove(t){se(this,Ft,x(this,Ft).filter(r=>r!==t)),this.notify({type:"removed",mutation:t})}clear(){Qe.batch(()=>{x(this,Ft).forEach(t=>{this.remove(t)})})}getAll(){return x(this,Ft)}find(t){const r={exact:!0,...t};return x(this,Ft).find(n=>zm(r,n))}findAll(t={}){return x(this,Ft).filter(r=>zm(t,r))}notify(t){Qe.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){return se(this,an,(x(this,an)??Promise.resolve()).then(()=>{const t=x(this,Ft).filter(r=>r.state.isPaused);return Qe.batch(()=>t.reduce((r,n)=>r.then(()=>n.continue().catch(Dt)),Promise.resolve()))}).then(()=>{se(this,an,void 0)})),x(this,an)}},Ft=new WeakMap,yo=new WeakMap,an=new WeakMap,Ym);function iK(e){return{onFetch:(t,r)=>{const n=async()=>{var b,h,m,v,y;const a=t.options,o=(m=(h=(b=t.fetchOptions)==null?void 0:b.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,s=((v=t.state.data)==null?void 0:v.pages)||[],i=((y=t.state.data)==null?void 0:y.pageParams)||[],l={pages:[],pageParams:[]};let u=!1;const c=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),d=async(w,A,S)=>{if(u)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const E={queryKey:t.queryKey,pageParam:A,direction:S?"backward":"forward",meta:t.options.meta};c(E);const C=await f(E),{maxPages:P}=t.options,I=S?XL:QL;return{pages:I(w.pages,C,P),pageParams:I(w.pageParams,A,P)}};let p;if(o&&s.length){const w=o==="backward",A=w?lK:Bm,S={pages:s,pageParams:i},E=A(a,S);p=await d(S,E,w)}else{p=await d(l,i[0]??a.initialPageParam);const w=e??s.length;for(let A=1;A<w;A++){const S=Bm(a,p);p=await d(p,S)}}return p};t.options.persister?t.fetchFn=()=>{var a,o;return(o=(a=t.options).persister)==null?void 0:o.call(a,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=n}}}function Bm(e,{pages:t,pageParams:r}){const n=t.length-1;return e.getNextPageParam(t[n],t,r[n],r)}function lK(e,{pages:t,pageParams:r}){var n;return(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r)}var Ge,Mr,Nr,ra,na,Tr,aa,oa,Hm,cK=(Hm=class{constructor(e={}){fe(this,Ge,void 0);fe(this,Mr,void 0);fe(this,Nr,void 0);fe(this,ra,void 0);fe(this,na,void 0);fe(this,Tr,void 0);fe(this,aa,void 0);fe(this,oa,void 0);se(this,Ge,e.queryCache||new aK),se(this,Mr,e.mutationCache||new sK),se(this,Nr,e.defaultOptions||{}),se(this,ra,new Map),se(this,na,new Map),se(this,Tr,0)}mount(){es(this,Tr)._++,x(this,Tr)===1&&(se(this,aa,gl.subscribe(()=>{gl.isFocused()&&(this.resumePausedMutations(),x(this,Ge).onFocus())})),se(this,oa,vl.subscribe(()=>{vl.isOnline()&&(this.resumePausedMutations(),x(this,Ge).onOnline())})))}unmount(){var e,t;es(this,Tr)._--,x(this,Tr)===0&&((e=x(this,aa))==null||e.call(this),se(this,aa,void 0),(t=x(this,oa))==null||t.call(this),se(this,oa,void 0))}isFetching(e){return x(this,Ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return x(this,Mr).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=x(this,Ge).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=x(this,Ge).find({queryKey:e}),a=n==null?void 0:n.state.data,o=HL(t,a);if(typeof o>"u")return;const s=this.defaultQueryOptions({queryKey:e});return x(this,Ge).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Qe.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var t;return(t=x(this,Ge).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=x(this,Ge);Qe.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=x(this,Ge),n={type:"active",...e};return Qe.batch(()=>(r.findAll(e).forEach(a=>{a.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const r={revert:!0,...t},n=Qe.batch(()=>x(this,Ge).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Dt).catch(Dt)}invalidateQueries(e={},t={}){return Qe.batch(()=>{if(x(this,Ge).findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const r={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e={},t){const r={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=Qe.batch(()=>x(this,Ge).findAll(e).filter(a=>!a.isDisabled()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Dt)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Dt)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const r=x(this,Ge).build(this,t);return r.isStaleByTime(t.staleTime)?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Dt).catch(Dt)}fetchInfiniteQuery(e){return e.behavior=iK(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Dt).catch(Dt)}resumePausedMutations(){return x(this,Mr).resumePausedMutations()}getQueryCache(){return x(this,Ge)}getMutationCache(){return x(this,Mr)}getDefaultOptions(){return x(this,Nr)}setDefaultOptions(e){se(this,Nr,e)}setQueryDefaults(e,t){x(this,ra).set(bo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...x(this,ra).values()];let r={};return t.forEach(n=>{mo(e,n.queryKey)&&(r={...r,...n.defaultOptions})}),r}setMutationDefaults(e,t){x(this,na).set(bo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...x(this,na).values()];let r={};return t.forEach(n=>{mo(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...x(this,Nr).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=yd(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...x(this,Nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){x(this,Ge).clear(),x(this,Mr).clear()}},Ge=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,ra=new WeakMap,na=new WeakMap,Tr=new WeakMap,aa=new WeakMap,oa=new WeakMap,Hm),ht,Ne,sa,at,on,ia,$t,wo,la,ca,sn,ln,jr,cn,un,Ya,So,Fu,Ao,qu,Eo,Du,Oo,Bu,Co,Vu,Io,Lu,ko,Ku,yl,vA,Qm,uK=(Qm=class extends Ma{constructor(t,r){super();fe(this,un);fe(this,So);fe(this,Ao);fe(this,Eo);fe(this,Oo);fe(this,Co);fe(this,Io);fe(this,ko);fe(this,yl);fe(this,ht,void 0);fe(this,Ne,void 0);fe(this,sa,void 0);fe(this,at,void 0);fe(this,on,void 0);fe(this,ia,void 0);fe(this,$t,void 0);fe(this,wo,void 0);fe(this,la,void 0);fe(this,ca,void 0);fe(this,sn,void 0);fe(this,ln,void 0);fe(this,jr,void 0);fe(this,cn,void 0);se(this,Ne,void 0),se(this,sa,void 0),se(this,at,void 0),se(this,cn,new Set),se(this,ht,t),this.options=r,se(this,$t,null),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(x(this,Ne).addObserver(this),Vm(x(this,Ne),this.options)?Se(this,un,Ya).call(this):this.updateResult(),Se(this,Oo,Bu).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wu(x(this,Ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wu(x(this,Ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,Co,Vu).call(this),Se(this,Io,Lu).call(this),x(this,Ne).removeObserver(this)}setOptions(t,r){const n=this.options,a=x(this,Ne);if(this.options=x(this,ht).defaultQueryOptions(t),ml(n,this.options)||x(this,ht).getQueryCache().notify({type:"observerOptionsUpdated",query:x(this,Ne),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),Se(this,ko,Ku).call(this);const o=this.hasListeners();o&&Lm(x(this,Ne),a,this.options,n)&&Se(this,un,Ya).call(this),this.updateResult(r),o&&(x(this,Ne)!==a||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&Se(this,So,Fu).call(this);const s=Se(this,Ao,qu).call(this);o&&(x(this,Ne)!==a||this.options.enabled!==n.enabled||s!==x(this,jr))&&Se(this,Eo,Du).call(this,s)}getOptimisticResult(t){const r=x(this,ht).getQueryCache().build(x(this,ht),t),n=this.createResult(r,t);return dK(this,n)&&(se(this,at,n),se(this,ia,this.options),se(this,on,x(this,Ne).state)),n}getCurrentResult(){return x(this,at)}trackResult(t){const r={};return Object.keys(t).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(x(this,cn).add(n),t[n])})}),r}getCurrentQuery(){return x(this,Ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=x(this,ht).defaultQueryOptions(t),n=x(this,ht).getQueryCache().build(x(this,ht),r);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,un,Ya).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),x(this,at)))}createResult(t,r){var E;const n=x(this,Ne),a=this.options,o=x(this,at),s=x(this,on),i=x(this,ia),u=t!==n?t.state:x(this,sa),{state:c}=t;let{error:f,errorUpdatedAt:d,fetchStatus:p,status:b}=c,h=!1,m;if(r._optimisticResults){const C=this.hasListeners(),P=!C&&Vm(t,r),I=C&&Lm(t,n,r,a);(P||I)&&(p=nc(t.options.networkMode)?"fetching":"paused",c.dataUpdatedAt||(b="pending")),r._optimisticResults==="isRestoring"&&(p="idle")}if(r.select&&typeof c.data<"u")if(o&&c.data===(s==null?void 0:s.data)&&r.select===x(this,wo))m=x(this,la);else try{se(this,wo,r.select),m=r.select(c.data),m=zu(o==null?void 0:o.data,m,r),se(this,la,m),se(this,$t,null)}catch(C){se(this,$t,C)}else m=c.data;if(typeof r.placeholderData<"u"&&typeof m>"u"&&b==="pending"){let C;if(o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData))C=o.data;else if(C=typeof r.placeholderData=="function"?r.placeholderData((E=x(this,ca))==null?void 0:E.state.data,x(this,ca)):r.placeholderData,r.select&&typeof C<"u")try{C=r.select(C),se(this,$t,null)}catch(P){se(this,$t,P)}typeof C<"u"&&(b="success",m=zu(o==null?void 0:o.data,C,r),h=!0)}x(this,$t)&&(f=x(this,$t),m=x(this,la),d=Date.now(),b="error");const v=p==="fetching",y=b==="pending",w=b==="error",A=y&&v;return{status:b,fetchStatus:p,isPending:y,isSuccess:b==="success",isError:w,isInitialLoading:A,isLoading:A,data:m,dataUpdatedAt:c.dataUpdatedAt,error:f,errorUpdatedAt:d,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>u.dataUpdateCount||c.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:w&&c.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:h,isRefetchError:w&&c.dataUpdatedAt!==0,isStale:wd(t,r),refetch:this.refetch}}updateResult(t){const r=x(this,at),n=this.createResult(x(this,Ne),this.options);if(se(this,on,x(this,Ne).state),se(this,ia,this.options),x(this,on).data!==void 0&&se(this,ca,x(this,Ne)),ml(n,r))return;se(this,at,n);const a={},o=()=>{if(!r)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!x(this,cn).size)return!0;const l=new Set(i??x(this,cn));return this.options.throwOnError&&l.add("error"),Object.keys(x(this,at)).some(u=>{const c=u;return x(this,at)[c]!==r[c]&&l.has(c)})};(t==null?void 0:t.listeners)!==!1&&o()&&(a.listeners=!0),Se(this,yl,vA).call(this,{...a,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,Oo,Bu).call(this)}},ht=new WeakMap,Ne=new WeakMap,sa=new WeakMap,at=new WeakMap,on=new WeakMap,ia=new WeakMap,$t=new WeakMap,wo=new WeakMap,la=new WeakMap,ca=new WeakMap,sn=new WeakMap,ln=new WeakMap,jr=new WeakMap,cn=new WeakMap,un=new WeakSet,Ya=function(t){Se(this,ko,Ku).call(this);let r=x(this,Ne).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Dt)),r},So=new WeakSet,Fu=function(){if(Se(this,Co,Vu).call(this),Ea||x(this,at).isStale||!Tu(this.options.staleTime))return;const r=fA(x(this,at).dataUpdatedAt,this.options.staleTime)+1;se(this,sn,setTimeout(()=>{x(this,at).isStale||this.updateResult()},r))},Ao=new WeakSet,qu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(x(this,Ne)):this.options.refetchInterval)??!1},Eo=new WeakSet,Du=function(t){Se(this,Io,Lu).call(this),se(this,jr,t),!(Ea||this.options.enabled===!1||!Tu(x(this,jr))||x(this,jr)===0)&&se(this,ln,setInterval(()=>{(this.options.refetchIntervalInBackground||gl.isFocused())&&Se(this,un,Ya).call(this)},x(this,jr)))},Oo=new WeakSet,Bu=function(){Se(this,So,Fu).call(this),Se(this,Eo,Du).call(this,Se(this,Ao,qu).call(this))},Co=new WeakSet,Vu=function(){x(this,sn)&&(clearTimeout(x(this,sn)),se(this,sn,void 0))},Io=new WeakSet,Lu=function(){x(this,ln)&&(clearInterval(x(this,ln)),se(this,ln,void 0))},ko=new WeakSet,Ku=function(){const t=x(this,ht).getQueryCache().build(x(this,ht),this.options);if(t===x(this,Ne))return;const r=x(this,Ne);se(this,Ne,t),se(this,sa,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},yl=new WeakSet,vA=function(t){Qe.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(x(this,at))}),x(this,ht).getQueryCache().notify({query:x(this,Ne),type:"observerResultsUpdated"})})},Qm);function fK(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Vm(e,t){return fK(e,t)||e.state.dataUpdatedAt>0&&Wu(e,t,t.refetchOnMount)}function Wu(e,t,r){if(t.enabled!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&wd(e,t)}return!1}function Lm(e,t,r,n){return r.enabled!==!1&&(e!==t||n.enabled===!1)&&(!r.suspense||e.state.status!=="error")&&wd(e,r)}function wd(e,t){return e.isStaleByTime(t.staleTime)}function dK(e,t){return!ml(e.getCurrentResult(),t)}var zr,st,qt,dr,ua,Ls,Po,Uu,Xm,pK=(Xm=class extends Ma{constructor(t,r){super();fe(this,ua);fe(this,Po);fe(this,zr,void 0);fe(this,st,void 0);fe(this,qt,void 0);fe(this,dr,void 0);se(this,st,void 0),se(this,zr,t),this.setOptions(r),this.bindMethods(),Se(this,ua,Ls).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=x(this,zr).defaultMutationOptions(t),ml(r,this.options)||x(this,zr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:x(this,qt),observer:this}),(n=x(this,qt))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=x(this,qt))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,ua,Ls).call(this),Se(this,Po,Uu).call(this,t)}getCurrentResult(){return x(this,st)}reset(){se(this,qt,void 0),Se(this,ua,Ls).call(this),Se(this,Po,Uu).call(this)}mutate(t,r){var n;return se(this,dr,r),(n=x(this,qt))==null||n.removeObserver(this),se(this,qt,x(this,zr).getMutationCache().build(x(this,zr),this.options)),x(this,qt).addObserver(this),x(this,qt).execute(t)}},zr=new WeakMap,st=new WeakMap,qt=new WeakMap,dr=new WeakMap,ua=new WeakSet,Ls=function(){var r;const t=((r=x(this,qt))==null?void 0:r.state)??gA();se(this,st,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Po=new WeakSet,Uu=function(t){Qe.batch(()=>{var r,n,a,o,s,i,l,u;x(this,dr)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(r=x(this,dr)).onSuccess)==null||n.call(r,t.data,x(this,st).variables,x(this,st).context),(o=(a=x(this,dr)).onSettled)==null||o.call(a,t.data,null,x(this,st).variables,x(this,st).context)):(t==null?void 0:t.type)==="error"&&((i=(s=x(this,dr)).onError)==null||i.call(s,t.error,x(this,st).variables,x(this,st).context),(u=(l=x(this,dr)).onSettled)==null||u.call(l,void 0,t.error,x(this,st).variables,x(this,st).context))),this.listeners.forEach(c=>{c(x(this,st))})})},Xm),yA=k.createContext(void 0),ir=e=>{const t=k.useContext(yA);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},hK=({client:e,children:t})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),k.createElement(yA.Provider,{value:e},t)),wA=k.createContext(!1),bK=()=>k.useContext(wA);wA.Provider;function mK(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var gK=k.createContext(mK()),vK=()=>k.useContext(gK);function SA(e,t){return typeof e=="function"?e(...t):!!e}var yK=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},wK=e=>{k.useEffect(()=>{e.clearReset()},[e])},SK=({result:e,errorResetBoundary:t,throwOnError:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&SA(r,[e.error,n]),AK=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},EK=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,OK=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function CK(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=ir(r),a=bK(),o=vK(),s=n.defaultQueryOptions(e);s._optimisticResults=a?"isRestoring":"optimistic",AK(s),yK(s,o),wK(o);const[i]=k.useState(()=>new t(n,s)),l=i.getOptimisticResult(s);if(k.useSyncExternalStore(k.useCallback(u=>{const c=a?()=>{}:i.subscribe(Qe.batchCalls(u));return i.updateResult(),c},[i,a]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),k.useEffect(()=>{i.setOptions(s,{listeners:!1})},[s,i]),EK(s,l))throw OK(s,i,o);if(SK({result:l,errorResetBoundary:o,throwOnError:s.throwOnError,query:i.getCurrentQuery()}))throw l.error;return s.notifyOnChangeProps?l:i.trackResult(l)}function Uo(e,t){return CK(e,uK,t)}function gr(e,t){const r=ir(t),[n]=k.useState(()=>new pK(r,e));k.useEffect(()=>{n.setOptions(e)},[n,e]);const a=k.useSyncExternalStore(k.useCallback(s=>n.subscribe(Qe.batchCalls(s)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((s,i)=>{n.mutate(s,i).catch(IK)},[n]);if(a.error&&SA(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function IK(){}function St(){return ir().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Na=()=>{const{data:e,refetch:t}=Uo({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[e,r=>{r&&(localStorage.setItem("currentPage",r||""),t())}]},ac=()=>{const[e,t]=Na(),r=St();return Uo({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${r}/project`).then(a=>a.json());if(!e&&n){const a=localStorage.getItem("currentPage");t(a||(n==null?void 0:n.homepage))}return n}})},Sd=()=>{const e=St();return Uo({queryKey:["pages"],queryFn:async()=>await fetch(`${e}/pages`).then(r=>r.json())||[]})},kK=()=>{const[e,t]=Na(),{data:r}=ac(),n=St();return Uo({queryKey:["page_data",e],queryFn:async()=>{const a=await fetch(`${n}/page?uuid=${e}`);return a.ok?a.json():(t(r.homepage),null)},enabled:!!e,staleTime:3e3})},Zu=()=>ie.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:ie.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[ie.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),ie.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),AA=(e="Project updated successfully.")=>{const t=ir(),r=St();return gr({mutationFn:async n=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),ar.toast.success(e)}})},EA=()=>{const[e]=["SAVED"],[t,r]=Na(),n=dd();return a=>e!=="SAVED"?(ar.toast.error("You have unsaved changes. Please save before changing the page."),!1):t===a.uuid?!1:(n(),setTimeout(()=>{r(a.uuid)},100),!0)},PK=()=>{const e=ir(),t=EA(),r=St();return gr({mutationFn:async n=>fetch(`${r}/pages`,{method:"POST",body:JSON.stringify(n)}).then(a=>a.json()),onSuccess:n=>{e.invalidateQueries({queryKey:["pages"]}),t({uuid:n.uuid,slug:n.slug}),ar.toast.success("Page added successfully.")}})},OA=()=>{const e=St();return gr({mutationFn:async t=>fetch(`${e}/page`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{ar.toast.success("Page saved successfully.")}})},xK=()=>{const e=St(),{data:t}=Sd(),[r]=Na(),{data:n}=ac();return gr({mutationFn:async()=>{const a=t.find(o=>o.uuid===r).slug;await fetch(`${e}/publish`,{method:"POST",body:JSON.stringify({slug:a,uuid:r,isHomepage:(n==null?void 0:n.homepage)===r})})},onSuccess:()=>{ar.toast.success("Page published successfully.",{position:"top-right",duration:2e3})}})},RK=()=>{const e=ir(),t=St();return gr({mutationFn:async r=>fetch(`${t}/page`,{method:"DELETE",body:JSON.stringify(r)}),onSuccess:()=>{ar.toast.success("Page deleted successfully."),e.invalidateQueries({queryKey:["pages"]})}})},MK=()=>{const e=St();return gr({mutationFn:async()=>{const t=await fetch(`${e}/library`).then(r=>r.json());return B.sortBy(B.filter(t,r=>!B.has(r,"hidden")),"group")}})},NK=()=>{const e=St();return gr({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const r=await fetch(`${e}/block?uuid=${t.uuid}&format=${t.format}`).then(async n=>t.format==="html"?mt.getBlocksFromHTML(await n.text()):await n.json());debugger;return B.set(r,"0._name",B.capitalize(t.group)),r||[]}catch{return[]}}})},TK=()=>{const e=St();return gr({mutationFn:async t=>{const r=new FormData;return r.append("file",t),await(await fetch(`${e}/upload`,{method:"POST",body:r})).json()}})},jK=g.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-e176d7e8.cjs"))),zK=g.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-d0f33df2.cjs"))),FK=g.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-c10e6c89.cjs"))),qK=()=>ie.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),DK=()=>{const e=ir();return ie.jsxRuntimeExports.jsx("div",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:ie.jsxRuntimeExports.jsx(jA.LogOutIcon,{className:"w-4 h-4 text-red-500",onClick:()=>{localStorage.removeItem("__anon_token"),e.invalidateQueries({queryKey:["verify"]})}})})},BK=()=>{const{mutate:e}=xK();return ie.jsxRuntimeExports.jsx(xt.Button,{onClick:e,className:"bg-blue-600 text-white",children:"Publish"})},VK=e=>{const{data:t,isLoading:r}=ac(),{data:n,isLoading:a}=Sd(),{data:o}=kK(),{mutate:s}=AA(),{mutate:i}=OA(),[l]=Na(),u=TK(),c=MK(),f=NK(),d=St(),p=g.useCallback(async y=>await u.mutateAsync(y),[u]),b=g.useCallback(async()=>await c.mutateAsync(),[c]),h=g.useCallback(async y=>await f.mutateAsync(y),[f]),m=async(y=20,w=0)=>{const A=`limit=${y}&offset=${w}`;return await fetch(`${d}/assets?${A}`).then(S=>S.json())},{logo:v=qK}=e;return r||!t?ie.jsxRuntimeExports.jsx(Zu,{}):a||!n?ie.jsxRuntimeExports.jsx(Zu,{}):ie.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:ie.jsxRuntimeExports.jsx(uA,{blocks:(o==null?void 0:o.blocks)||[],brandingOptions:t.brandingOptions,darkMode:e.darkMode||!1,dataProviders:[{providerKey:"hero",args:{}}],onSavePage:async({blocks:y,providers:w})=>(console.log({blocks:y,providers:w}),i({blocks:y,providers:w,uuid:l}),!0),onSaveBrandingOptions:async y=>(s({brandingOptions:y}),!0),topBarComponents:{left:[v],center:[FK],right:[BK]},sideBarComponents:{top:[{icon:Ks.FileTextIcon,name:"pages",panel:jK},{icon:Ks.GearIcon,name:"settings",panel:zK}],bottom:[DK]},uploadMediaCallback:p,fetchMediaCallback:m,getUILibraryBlocks:b,getExternalPredefinedBlock:h,getPages:()=>n,unsplashAccessKey:e.unsplashAccessKey||""})})},LK=()=>{const e=St(),t=ir();return gr({mutationFn:async r=>{const n=await fetch(`${e}/authenticate`,{method:"POST",body:JSON.stringify(r)});if(n.ok)return await n.json();throw new Error("INvalid")},onSuccess:r=>{if(!r.token){ar.toast.error("Something went wrong. Please try again.");return}localStorage.setItem("__anon_token",r.token),t.invalidateQueries({queryKey:["verify"]}),ar.toast.success("Authenticated successfully.")},onError:()=>{ar.toast.error("Incorrect password. Please try again.")}})},KK=()=>{const e=St();return Uo({queryKey:["verify"],queryFn:async()=>{const t=localStorage.getItem("__anon_token");if(!t)return{valid:!1};const r=await fetch(`${e}/verify?token=`+t,{method:"GET"});return r.ok?(await r.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__anon_token"),{valid:!1}):(localStorage.removeItem("__anon_token"),{valid:!0})}})},WK=({logo:e})=>{const[t,r]=g.useState(!1),[n,a]=g.useState(""),{mutate:o,isPending:s}=LK(),i=()=>{o({password:n})};return ie.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:ie.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:ie.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[ie.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[ie.jsxRuntimeExports.jsx(g.Suspense,{children:e?g.createElement(e):""}),ie.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your app password to continue"})]}),ie.jsxRuntimeExports.jsx("div",{className:"mt-8",children:ie.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[ie.jsxRuntimeExports.jsx("div",{children:ie.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[ie.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:ie.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ie.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),ie.jsxRuntimeExports.jsx("input",{value:n,onChange:l=>a(l.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),ie.jsxRuntimeExports.jsx("button",{className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>r(!t),children:t?ie.jsxRuntimeExports.jsx(Ks.EyeClosedIcon,{}):ie.jsxRuntimeExports.jsx(Ks.EyeOpenIcon,{})})]})}),ie.jsxRuntimeExports.jsx("div",{children:ie.jsxRuntimeExports.jsx("button",{disabled:s||B.isEmpty(n)||n.length<3,onClick:i,type:"button",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Authenticating...":"Authenticate"})})]})})]})})})},UK=e=>{const{data:t,isLoading:r}=KK(),n=ir();return g.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),r?ie.jsxRuntimeExports.jsx(Zu,{}):t!=null&&t.valid?ie.jsxRuntimeExports.jsx(VK,{...e}):ie.jsxRuntimeExports.jsx(WK,{logo:e.logo})},ZK=new cK,JK=e=>ie.jsxRuntimeExports.jsxs(hK,{client:ZK,children:[ie.jsxRuntimeExports.jsx(ar.Toaster,{richColors:!0}),ie.jsxRuntimeExports.jsx(UK,{...e})]});exports.ChaiBuilderEditor=uA;exports.ChaiBuilderStudio=JK;exports.ErrorBoundary=eS;exports.activePanelAtom=CS;exports.addBlockOffCanvasAtom=IS;exports.addBlocksModalAtom=oS;exports.advanceStylingOpenAtom=SS;exports.canDeleteBlock=dB;exports.canDropBlock=hB;exports.canDuplicateBlock=fB;exports.canvasIframeAtom=OS;exports.editLayerNameAtom=ES;exports.getBlockJSONFromSchemas=xu;exports.getBlockJSONFromUISchemas=Pu;exports.inlineEditingActiveAtom=wS;exports.networkModeAtom=AS;exports.pageSyncStateAtom=Lo;exports.reactIsExports=dg;exports.showPredefinedBlockCategoryAtom=kS;exports.useActiveLanguage=KS;exports.useActiveModal=cV;exports.useActivePanel=pV;exports.useAddBlock=SB;exports.useAddBlockParent=hV;exports.useAddClassesToBlocks=IB;exports.useAddPage=PK;exports.useAllBlocks=fS;exports.useBlockContentByLanguage=kV;exports.useBrandingOptions=ad;exports.useBuilderReset=dd;exports.useBuildingBlocks=pS;exports.useCanvasHistory=Ko;exports.useCanvasWidth=BB;exports.useCanvasZoom=LB;exports.useChangePage=EA;exports.useCopyBlockIds=TS;exports.useCurrentPage=Na;exports.useCurrentPage$1=hS;exports.useCutBlockIds=cd;exports.useDarkMode=KB;exports.useDeletePage=RK;exports.useDeveloperPreviewMode=UB;exports.useDuplicateBlocks=fd;exports.useExpandedIds=NV;exports.useFeatureSupport=yV;exports.useGetPageData=id;exports.useHiddenBlockIds=JB;exports.useHighlightBlockId=zS;exports.useLanguages=IV;exports.useMarkAsGlobalBlock=YB;exports.useMoveBlocks=HB;exports.usePageDataProviders=PS;exports.usePages=Sd;exports.usePasteBlocks=FS;exports.usePreviewMode=nd;exports.usePrimaryLanguage=CV;exports.useProject=ac;exports.useProject$1=_B;exports.useQueryClient=ir;exports.useReadOnlyMode=uV;exports.useRemoveBlocks=DS;exports.useRemoveClassesFromBlocks=eV;exports.useSavePage=DB;exports.useSelectedBlock=vB;exports.useSelectedBlockAllClasses=tV;exports.useSelectedBlockCurrentClasses=aV;exports.useSelectedBlockIds=Wr;exports.useSelectedBlocksDisplayChild=gB;exports.useSelectedBreakpoints=mV;exports.useSelectedStylingBlocks=rd;exports.useSetAllBlocks=sS;exports.useStylingBreakpoint=xS;exports.useStylingState=oV;exports.useTranslations=vV;exports.useTreeData=uB;exports.useUILibraryBlocks=SV;exports.useUpdateBlocksProps=sV;exports.useUpdateBlocksPropsRealtime=iV;exports.useUpdatePage=OA;exports.useUpdateProject=AA;
|
|
163
|
+
*/F();var tB=process.env.NODE_ENV!=="production"?eB:()=>null;const rB={};class eS extends g.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return console.error(t),{hasError:!0}}render(){return this.state.hasError?ie.jsxRuntimeExports.jsx("h1",{children:"Something went wrong."}):this.props.children}}const nB=e=>{const t=e.replace(je.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},aB=new eg({children:"blockNodes"}),tS=(e,t=null)=>B.flatten(e.map(r=>{if(r=t!==null?{...r,parent:t}:r,r.children&&r.children.length){const n=[...r.children];return delete r.children,B.flatten([r,...tS(n,r._id)])}return r}));function rS(e,t,r){const n=B.filter(e,o=>o._parent===t),a=[];for(let o=0;o<n.length;o++){const s=nS(n[o]);if(Object.keys(s).length>0&&Object.keys(s).forEach(i=>{n[o][i]=`slot:${mt.generateUUID()}`}),B.filter(e,{_parent:n[o]._id}).length>0){const i=mt.generateUUID();a.push({...n[o],oldId:n[o]._id,_id:i,_parent:r}),a.push(B.flatten(rS(e,n[o]._id,i)))}else a.push({...n[o],oldId:n[o]._id,_id:mt.generateUUID(),_parent:r})}return B.flatten(a)}function oB(e){let t=aB.convert(e.map(r=>B.omit(r,["settings"])));return t=!t.type&&t.blockNodes?t.blockNodes:B.isEmpty(t)?[]:[t],t}const nS=e=>{const t={};return Object.keys(e).forEach(r=>{B.isString(e[r])&&e[r].startsWith("slot")&&(t[r]=e[r].replace("slot:",""))}),t},sB=(e,t,r=null)=>{let n=B.find(e,{_id:t});n={...n,oldId:n._id,_id:mt.generateUUID()},r&&(n={...n,_parent:r});const a=[n];B.filter(e,{_parent:t}).length>0&&a.push(B.flatten(rS(e,t,n._id)));const o=B.flatten(a);return B.map(o,s=>{const i=s,l=nS(i);return Object.keys(l).length>0&&Object.keys(l).forEach(u=>{const c=B.find(o,{oldId:l[u].replace("slot:","")});i[u]=`slot:${c._id}`}),B.omit(i,["global","oldId"])})},iB=Ha((e=[],t)=>{switch(t.type){case"add_new_blocks":case"add_duplicate_blocks":return[...e,...t.payload];case"create_snapshot":return[...e];case"set_blocks":case"set_page_blocks":return[...t.payload];case"update_props":case"update_props_realtime":const{payload:r}=t;return e.map(n=>(r.ids.includes(n._id)&&!B.isEmpty(t.payload.props)&&Object.keys(t.payload.props).forEach(a=>{B.set(n,a,t.payload.props[a])}),n));default:return e}},{debug:!1,ignoreInitialState:!1,limit:30,filter:Ha.excludeAction(["update_props_realtime","add_duplicate_blocks","set_page_blocks"])}),Ql=GT({past:[],present:[],future:[]},iB);Ql.debugLabel="pageBlocksAtom";const Vt=G.atom(e=>{var t;return(t=e(Ql))==null?void 0:t.present});Vt.debugLabel="presentBlocksAtom";const Xf=_T(Vt);Xf.debugLabel="pageBlocksAtomsAtom";const aS=G.atom(e=>oB(e(Vt)));aS.debugLabel="pageBlocksTreeAtom";const lB=G.atom("");lB.debugLabel="builderActivePageAtom";const cB=G.atom(-1);cB.debugLabel="destinationDropIndexAtom";const oS=G.atom(!1);oS.debugLabel="addBlocksModalAtom";const Lt=()=>{const[,e]=G.useAtom(Ql);return e},uB=()=>{const e=Lt(),t=G.useAtomValue(aS),r=g.useCallback(n=>{const a=tS(n);e({type:"set_page_blocks",payload:a})},[e]);return[t,r]},sS=()=>{const e=Lt();return[g.useCallback(r=>{e({type:"set_page_blocks",payload:r})},[e])]},ku=e=>["Box","Slot","Form","DataProvider","Link","List","ListItem","Row","Column","Table","TableCell"].includes(e),fB=e=>!["Slot"].includes(e),dB=e=>!["Slot"].includes(e);function pB(e,t){return e==="Slot"||t==="List"&&e!=="ListItem"||t==="Row"&&e!=="Column"?!1:ku(t)}const hB=(e,{dragSource:t,dropTarget:r})=>{const n=B.get(t,"data._type",""),a=B.get(r,"data._type","");return n==="Slot"||B.get(t,"id")&&B.get(t,"id")===B.get(r,"id")?!1:B.isEmpty(a)?!0:pB(n,a)},_f=G.atom([]);_f.debugLabel="selectedBlockIdsAtom";const $f=G.atom(e=>{const t=e(Vt),r=e(_f);return B.map(B.filter(t,({_id:n})=>B.includes(r,n)),n=>({...n}))});$f.debugLabel="selectedBlocksAtom";const ed=G.atom(e=>{const t=e($f);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:B.map(t,"id")}});ed.debugLabel="selectedBlockAtom";const bB=e=>B.get(e,"parent",null),mB=G.atom(e=>{const t=e($f),r=B.map(t,bB);return B.filter(e(Vt),n=>B.includes(r,n._id))});mB.debugLabel="selectedBlocksParentsAtom";const iS=G.atom(()=>!1);iS.debugLabel="selectedBlockFlexChildAtom";const lS=G.atom(()=>!1);lS.debugLabel="selectedBlockGridChildAtom";const td=G.atom("");td.debugLabel="styleStateAtom";const cS=wt("styleBreakpoint","xs");cS.debugLabel="styleBreakpointAtom";const gB=()=>({flexChild:G.useAtomValue(iS),gridChild:G.useAtomValue(lS)}),vB=()=>G.useAtomValue(ed),Wr=()=>{const[e,t]=G.useAtom(_f),r=g.useCallback(n=>{t(a=>B.includes(a,n)?B.without(a,n):[...a,n])},[t]);return[e,t,r]},Pu=(e,t="")=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:r}=e,n={};return Object.keys(r).forEach(s=>{const i=r[s];if(B.includes(["slot","styles"],i.type))return;const l=B.get(i,"i18n",!1)?`${s}-${t}`:s;n[l]=Pu(i,t)}),n;case"list":const{itemProperties:a}=e,o={items:{}};return Object.keys(a).forEach(s=>{const i=a[s];if(B.includes(["slot","styles"],i.type))return;const l=B.get(i,"i18n",!1)?`${s}-${t}`:s;o.items[l]=Pu(i,t)}),o;default:return{}}},xu=(e,t="")=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:r,title:n}=e,a={title:n,type:"object",properties:{}};return Object.keys(r).forEach(l=>{const u=r[l];if(B.includes(["slot","styles"],u.type))return;const c=B.get(u,"i18n",!1)?`${l}-${t}`:l;a.properties[c]=xu(u,t)}),a;case"list":const{itemProperties:o,title:s}=e,i={title:s,type:"array",items:{type:"object",properties:{}}};return Object.keys(o).forEach(l=>{const u=o[l];if(B.includes(["slot","styles"],u.type))return;const c=B.get(u,"i18n",!1)?`${l}-${t}`:l;i.items.properties[c]=xu(u,t),B.set(i.items,"title",B.get(u,"itemTitle",`${s} item`))}),i;default:return{}}},uS=e=>{const t={};return Object.keys(e).forEach(r=>{t[r]=wB(e[r])}),t},yB=e=>{if(B.isEmpty(e.default))return[];const{itemProperties:t}=e;return B.map(e.default,r=>{const n={...r};return B.forIn(r,(a,o)=>{B.has(t,o)&&B.get(t[o],"i18n",!1)&&(n[o]=je.I18N_KEY)}),n})},wB=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${je.SLOT_KEY}${mt.generateUUID()}`;case"singular":const{i18n:t,schema:r}=e;return t?je.I18N_KEY:B.get(r,"default","");case"model":return uS(e.properties);case"list":return yB(e);default:return""}},fS=()=>G.useAtomValue(Vt);function nm(e,t,r,n,a){if(t===null)return[...e,...n];if(r!==null){const l=B.findIndex(e,{_parent:t}),u=(l===-1?0:l)+r;return e.splice(u,0,...n),e}if(!a){const u=B.findIndex(e,{_id:t})+1;return e.splice(u,0,...n),e}let o=B.findIndex(e,{_id:t});const s=B.filter(e,{_parent:t});B.isEmpty(s)||(o=B.findIndex(e,{_id:B.last(s)._id}));const i=o+1;return e.splice(i,0,...n),e}const SB=()=>{const e=Lt(),t=fS(),[,r]=Wr(),n=g.useCallback((o,s,i)=>{var c;for(let f=0;f<o.length;f++){const{_id:d}=o[f];o[f]._id=mt.generateUUID();const p=B.filter(o,{_parent:d});for(let b=0;b<p.length;b++)p[b]._parent=o[f]._id}let l;s&&(l=B.find(t,{_id:s}),o[0]._parent=s);const u=l?ku(l._type):!0;return!u&&l&&(o[0]._parent=l._parent),e({type:"set_blocks",payload:nm(t,s||null,i||null,o,u)}),r([(c=B.first(o))==null?void 0:c._id]),B.first(o)},[t,e,r]);return{addCoreBlock:g.useCallback((o,s,i)=>{if(B.has(o,"blocks")){const h=o.blocks;return n(h,s,i)}const l=mt.generateUUID(),u=uS(o.props),c=[];B.forIn(u,(h,m)=>{if(B.startsWith(h,je.SLOT_KEY)){const v=h.replace(je.SLOT_KEY,"");c.push({_id:v,_type:"Slot",_parent:l,_name:o.props[m].name,_styles:o.props[m].styles,_emptyStyles:o.props[m].emptyStyles})}});const f={_type:o.type,_id:l,...u};let d;s&&(d=B.find(t,{_id:s}),f._parent=s);const p=d?ku(d._type):!0;!p&&d&&(f._parent=d._parent);const b=[f,...c];return e({type:"set_blocks",payload:nm(t,s||null,i||null,b,p)}),r([f._id]),f},[n,t,e,r]),addPredefinedBlock:n}},am={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},om=["xs","sm","md","lg","xl","2xl"];function AB(e,t){if(t===null)return"baseClasses";const r=t.mq;if(r==="xs"||t.dark||t.mod!=="")return"classes";let n="baseClasses",a=om.indexOf(r);for(;a>0;){const o=om[a-1];if(B.find(e,{mq:o,property:t.property})){n="classes";break}a--}return n}const sm=[];function EB(e="",t="",r=[]){e=e.trim().replace(/ +/g,"");let n=B.filter(B.map(e.split(" "),mt.constructClassObject),u=>!B.isNull(u)),a=B.filter(B.map(t.split(" "),mt.constructClassObject),u=>!B.isNull(u));a=B.filter(a,u=>!B.includes(sm,u.property));const o=[],s=[];B.each(r,u=>{const c=mt.constructClassObject(u),f=B.find(n,B.pick(c,["dark","mq","mod","property"]));if(f&&(n=B.filter(n,d=>d.fullCls!==(f==null?void 0:f.fullCls))),o.push(c),c.mq==="xs"&&!c.dark&&c.mod===""&&(a=B.filter(a,d=>d.property!==c.property)),AB(n,c)==="baseClasses"&&!B.includes(sm,c.property)){const d=B.find(a,B.pick(c,["property"]));f&&(a=B.filter(a,p=>p.fullCls!==(d==null?void 0:d.fullCls))),s.push({...c,fullCls:c.cls,mq:"xs"})}});const i=B.map(B.sortBy([...n,...o],u=>am[u.mq]),"fullCls").join(" ");return`${B.map(B.sortBy([...a,...s],u=>am[u.mq]),"fullCls").join(" ").trim()},${i.trim()}`.trim().replace(/ +/g,"")}const Vo=G.atom([]);Vo.debugLabel="selectedStylingBlocksAtom";const rd=()=>G.useAtom(Vo),OB=e=>{const t=e.replace(je.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},CB=G.atom(null,(e,t,{blockIds:r,newClasses:n,dispatch:a})=>{const o=B.filter(e(Xf),i=>r.includes(e(i)._id)),s=B.first(e(Vo));B.each(o,i=>{const l=e(i),u=B.get(l,s.prop,`${je.STYLES_KEY},`),{baseClasses:c,classes:f}=OB(u);a({type:"update_props_realtime",payload:{ids:[l._id],props:{[s.prop]:`${je.STYLES_KEY}${EB(f,c,n)}`}}})})}),IB=()=>{const e=Lt(),t=G.useSetAtom(CB);return g.useCallback((r,n,a)=>{t({blockIds:r,newClasses:n,dispatch:e}),a&&setTimeout(()=>e({type:"create_snapshot"}),500)},[e,t])},dS=G.atom([]);dS.debugLabel="buildingBlocksAtom";const kB=G.atom(e=>{const t=e(dS);return B.filter(t,r=>B.has(r,"blockId"))}),PB=()=>{},pS=()=>{const e=tg.useChaiBlocks(),t=G.useAtomValue(kB),r=()=>{},n=g.useCallback(()=>PB(),[]);return[e,t,r,n]},xB=G.atom(!1),nd=()=>{const[e,t]=G.useAtom(xB);return[e,t]},RB=G.atom(je.BRANDING_OPTIONS_DEFAULTS),ad=()=>{const[e,t]=G.useAtom(RB);return[B.isObject(e)?{...je.BRANDING_OPTIONS_DEFAULTS,...e}:je.BRANDING_OPTIONS_DEFAULTS,t]},MB=G.atom(null),hS=()=>({currentPage:G.useAtomValue(MB)}),bS=new eg({});function NB(e){let t=bS.convert(e);return t=!t.type&&t.children&&t.children.length?t.children:B.isEmpty(t)?[]:[t],t}const od=(e,t)=>B.flatten(e.map(r=>{if(r=t?{...r,parent:t}:{...r},r.children){const n=[...r.children];return delete r.children,B.flatten([r,...od(n,r._id)])}return r}));function sd(e,t=!1){for(let r=0;r<e.length;r++){const n=e[r];n.global&&!t?e[r]={type:"GlobalBlock",_parent:B.get(n,"parent",null),blockId:n.blockId,_id:n._id}:n.children&&n.children.length&&sd(n.children)}}function mS(e){let t=[],r=B.filter(e,{type:"GlobalBlock"});return r.length>0&&(r=B.map(r,gS),B.each(r,n=>{t=[...t,...TB(n)]})),t}function TB(e){let t=[];const r=B.get(B.first(e),"parent",null);B.set(B.first(e),"parent",null);const n=[bS.convert(vS(e))];sd(n,!0);let a=od(n,e[0]._id);return a=B.set(a,"0.parent",r),t=[...t,a,...mS(a)],t}function gS(e){const t=B.find(Ru,{_id:e._id});if(!t)return[];const r=[t],n=B.filter(Ru,{_parent:e._id});return n.length?B.flatten([...r,...B.flatten(B.map(n,gS))]):B.flatten(r)}const vS=e=>JSON.parse(JSON.stringify(e));let Ru=[];function jB(e){Ru=e;const t=NB(vS(e));sd(t);const r=od(t,null),n=mS(r),a={};return B.each(n,o=>B.set(a,B.first(o).blockId,o)),[r,a]}const id=()=>{const[e]=ad(),{currentPage:t}=hS(),r=G.useAtomValue(Vt);return g.useCallback(()=>{const n=B.map(r,s=>B.omit(s,["expanded","order","title","siblings","tempClasses"])),[a=[],o=[]]=jB(n);return{currentPage:t,blocks:a,globalBlocks:o}},[e,t,r])};wt("blockStylingActiveTab",1);G.atom([]);const yS=G.atom(!1);yS.debugLabel="readOnlyModeAtom";const wS=G.atom(!1);wS.debugLabel="inlineEditingActiveAtom";const SS=G.atom(!1);SS.debugLabel="advanceStylingOpenAtom";const AS=G.atom("online");AS.debugLabel="networkModeAtom";wt("currentUiLibrary","");const zB=G.atom(!1);zB.debugLabel="codeEditorOpenAtom";const ES=G.atom(!1);ES.debugLabel="editLayerNameAtom";const FB=G.atom("");FB.debugLabel="activeLanguageAtom";const qB=G.atom("");qB.debugLabel="primaryLanguageAtom";const OS=G.atom(null);OS.debugLabel="canvasIframeAtom";const CS=G.atom("layers");CS.debugLabel="activePanelAtom";const IS=G.atom(!1);IS.debugLabel="addBlockOffCanvasAtom";const kS=G.atom("");kS.debugLabel="showPredefinedBlockCategoryAtom";const Xl=G.atom({undoCount:0,redoCount:0});Xl.debugLabel="historyStatesAtom";const ld=G.atom([]);ld.debugLabel="dataProvidersAtom";const PS=()=>G.useAtom(ld),Lo=G.atom("SAVED");Lo.debugLabel="pageSyncStateAtom";const DB=()=>{const[e,t]=G.useAtom(Lo),r=xt.useBuilderProp("onSaveBlocks",async()=>{}),n=xt.useBuilderProp("onSavePage",async()=>{}),a=xt.useBuilderProp("onSyncStatusChange",()=>{}),o=id(),s=G.useSetAtom(Xl),{undoCount:i,redoCount:l}=Ko(),[u]=PS();return{savePage:TA.useThrottledCallback(async()=>{t("SAVING"),a("SAVING");const f=o();return await Promise.all([r({blocks:f.blocks,providers:[],identifier:"pageData.id"}),n({blocks:f.blocks,providers:u})]),setTimeout(()=>{s({undoCount:i,redoCount:l}),t("SAVED"),a("SAVED")},100),!0},[o,t,a,r],5e3),syncState:e,setSyncState:t}},Ko=()=>{const e=G.useAtomValue(Ql),[{undoCount:t,redoCount:r}]=G.useAtom(Xl),n=Lt(),[a]=nd(),[,o]=Wr(),[,s]=rd(),[i,l]=G.useAtom(Lo),u=xt.useBuilderProp("onSyncStatusChange",()=>{}),c=g.useCallback(()=>{n({type:"create_snapshot"})},[n]);return g.useEffect(()=>{(i==="SAVED"&&t!==(e==null?void 0:e.past.length)||r!==(e==null?void 0:e.future.length))&&(l("UNSAVED"),u("UNSAVED"))},[e==null?void 0:e.past.length,e==null?void 0:e.future.length,t,r,u,l,i]),{undoCount:e==null?void 0:e.past.length,redoCount:e==null?void 0:e.future.length,undo:g.useCallback(()=>{a||(n(Ha.ActionCreators.undo()),setTimeout(()=>{s([]),o([])},200))},[n,a,o,s]),redo:g.useCallback(()=>{a||(n(Ha.ActionCreators.redo()),setTimeout(()=>{s([]),o([])},200))},[a,n,s,o]),clear:()=>{n(Ha.ActionCreators.clearHistory())},createSnapshot:c}},xS=()=>G.useAtom(cS),RS=wt("canvasWidth",800),MS=G.atom(e=>{const t=e(RS);return mt.getBreakpointValue(t).toLowerCase()}),BB=()=>{const[e,t]=G.useAtom(RS),r=G.useAtomValue(MS),[n,a]=xS();return g.useEffect(()=>{n!=="xs"&&a(r)},[r,n,a]),[e,r,t]},VB=wt("canvasZoom",100),LB=()=>G.useAtom(VB),NS=G.atom([]),cd=()=>{const[e,t]=G.useAtom(NS),r=G.useSetAtom(ud),n=g.useCallback(a=>{t(a),r([])},[t,r]);return[e,n]},ud=G.atom([]),TS=()=>{const[e,t]=G.useAtom(ud),r=G.useSetAtom(NS),n=g.useCallback(a=>{t(a),r([])},[t,r]);return[e,n]},jS=wt("darkMode",!1),KB=()=>{const[e,t]=G.useAtom(jS);return[e,t]},WB=G.atom(!1),UB=()=>{const[e,t]=G.useAtom(WB);return[e,t]},fd=()=>{const e=Lt(),t=G.useAtomValue(Vt),[,r]=Wr();return g.useCallback((n,a=null)=>{const o=[];B.each(n,s=>{const l=sB(t,s,a===s?null:a);o.push(B.get(l,"0._id","")),e({type:"add_duplicate_blocks",payload:l})}),r(o),e({type:"create_snapshot"})},[t,r,e])},ZB=G.atom([]),JB=()=>{const[e,t]=G.useAtom(ZB),r=g.useCallback(n=>{t(a=>B.includes(a,n)?B.without(a,n):[...a,n])},[t]);return[e,t,r]},GB=G.atom(""),zS=()=>G.useAtom(GB),YB=()=>{const e=G.useAtomValue(Vt),t=Lt(),r=id(),[,,n]=pS();return g.useCallback(async(a,o)=>{const s=mt.generateUUID(16),i=B.map(e,l=>(l._id===a&&(l._globalBlockId=s,l._name=o),l));t({type:"set_page_blocks",payload:i}),n()},[e,t,r,n])},HB=()=>({}),QB=()=>{const e=G.useAtomValue(Vt),t=Lt();return g.useCallback((r,n)=>{const a=B.map(e,o=>(B.includes(r,B.get(o,"_id"))&&B.set(o,"_parent",n),o));t({type:"set_blocks",payload:a})},[e,t])},FS=()=>{const e=G.useAtomValue(ud),[t,r]=cd(),n=fd(),a=QB();return{canPaste:g.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:g.useCallback(s=>{B.isEmpty(e)?a(t,s):n(e,s),r(()=>[])},[t,e,n,a,r])}},XB=G.atom(""),_B=()=>{const e=G.useAtomValue(XB),t=g.useCallback(()=>{},[]),r=g.useCallback(()=>{},[]),n=g.useCallback(()=>{},[]);return{currentProject:e,createProject:n,deleteProject:t,updateProject:r}},qS=(e,t)=>{const r=[],n=B.filter(e,a=>B.includes(t,a._id)||B.includes(t,a._parent)?(r.push(a._id),!1):!0);return B.isEmpty(r)?n:qS(n,r)},DS=()=>{const e=Lt(),t=G.useAtomValue(Vt),[r,n]=Wr();return g.useCallback(a=>{var i;const o=((i=B.find(t,{_id:a[0]}))==null?void 0:i._parent)||null,s=qS(t,a);e({type:"set_blocks",payload:s}),n(o?[o]:[])},[t,n,e,r])},$B=G.atom(null,(e,t,{blockIds:r,fullClasses:n,dispatch:a})=>{const o=B.first(e(Vo)),s=B.filter(e(Xf),i=>r.includes(e(i)._id));B.each(s,i=>{const l=e(i),u=n;let{classes:c,baseClasses:f}=nB(B.get(l,o.prop,"styles:,"));B.each(u,d=>{const p=new RegExp(`(^| )${d.replace("[","\\[").replace("]","\\]")}($| )`,"g");c=c.replace(p," ").replace(/ +/g," ").trim();const b=B.first(d.split(":"));B.includes(["2xl","xl","lg","md","sm"],b)&&u.push(d.split(":").pop().trim())}),B.each(u,d=>{const p=new RegExp(`(^| )${d.replace("[","\\[").replace("]","\\]")}($| )`,"g");f=f.replace(p," ").replace(/ +/g," ").trim()}),a({type:"update_props_realtime",payload:{ids:[l._id],props:{[o.prop]:`${je.STYLES_KEY}${f},${c}`}}})})}),eV=()=>{const e=Lt(),t=G.useSetAtom($B);return g.useCallback((r,n)=>{t({blockIds:r,fullClasses:n,dispatch:e}),setTimeout(()=>e({type:"create_snapshot"}))},[e,t])},BS=G.atom(e=>{const t=B.first(e(Vo)),r=e(ed);if(!t||t.blockId!==B.get(r,"_id",null))return[];const a=B.get(r,t.prop,`${je.STYLES_KEY},`).replace(je.STYLES_KEY,"").split(",").join(" ");return B.filter(B.map(a.trim().split(" "),mt.constructClassObject),o=>!B.isNull(o))}),tV=()=>G.useAtomValue(BS),im={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},rV=G.atom(e=>{const t=e(MS),r=e(td),n=e(jS),a=nV(t);let o=B.filter(e(BS),{mod:r});return B.startsWith(r,"_")||(o=B.filter(o,s=>a.includes(s.mq))),o=o.sort((s,i)=>im[s.mq]-im[i.mq]),n||(o=B.filter(o,{dark:!1})),o}),nV=e=>{let t=[];switch(e){case"xs":t=["xs"];break;case"sm":t=["xs","sm"];break;case"md":t=["xs","sm","md"];break;case"lg":t=["xs","sm","md","lg"];break;case"xl":t=["xs","sm","md","lg","xl"];break;case"2xl":t=["xs","sm","md","lg","xl","2xl"];break;default:t=["xs"];break}return t},aV=()=>G.useAtomValue(rV),oV=()=>G.useAtom(td),VS=G.atom(null,(e,t,{blockIds:r,props:n,dispatch:a})=>{a({type:"update_props_realtime",payload:{ids:r,props:n}})}),sV=()=>{const{createSnapshot:e}=Ko(),t=Lt(),r=G.useSetAtom(VS);return g.useCallback((n,a)=>{r({blockIds:n,props:a,dispatch:t}),e()},[e,t,r])},iV=()=>{const e=Lt(),t=G.useSetAtom(VS);return g.useCallback((r,n)=>{t({blockIds:r,props:n,dispatch:e})},[e,t])},LS={name:"",props:{},modalProps:{},backdropClose:!0},lV=G.atom(LS),cV=()=>{const[e,t]=G.useAtom(lV),r=g.useCallback((a,o={},s={})=>{t({name:a,props:o,modalProps:s})},[t]),n=g.useCallback((...a)=>{B.get(e,"props.onClose",()=>{})(...a),t(LS)},[t,e]);return{activeModal:e,openModal:r,closeModal:n}},uV=()=>G.useAtomValue(yS),fV=G.atom(""),dV=G.atom(null),pV=()=>G.useAtom(fV),hV=()=>G.useAtom(dV),bV=wt("selectedBreakpoints",["XS","MD","XL"]),mV=()=>{const[e,t]=G.useAtom(bV);return[e,t]},dd=()=>{const e=G.useSetAtom(Xl),{clear:t}=Ko(),[,r]=Wr(),[,n]=zS(),[,a]=rd();return()=>{r([]),a([]),n(""),t(),e({undoCount:0,redoCount:0})}},gV=G.atom({en:{}}),vV=()=>{const[e,t]=G.useAtom(gV),r=g.useCallback((n,a,o)=>{B.set(e,`${n}.${a}`,o),t(e)},[e,t]);return[e,r]},yV=(e,t)=>{const[r]=G.useAtom(xt.chaiBuilderPropsAtom);return B.get(r,e,t)},wV=G.atom([]),SV=()=>{const[e,t]=g.useState(!1),[r,n]=G.useAtom(wV),a=xt.useBuilderProp("getUILibraryBlocks",()=>[]);return g.useEffect(()=>{(async()=>r.length>0||(t(!0),n(await a()),t(!1)))()},[]),{data:r,isLoading:e}},AV=G.atom("en"),EV=G.atom("en"),OV=G.atom(["en"]),KS=()=>G.useAtom(AV),CV=()=>G.useAtom(EV),IV=()=>G.useAtom(OV),kV=(e,t)=>{const[r]=KS(),n=`${e}${r?`-${r}`:""}`;return{content:B.get(t,n,B.get(t,e,"")),propKey:e}},PV=()=>{const[e,t]=nd(),r=xt.useBuilderProp("previewComponent");return ie.jsxRuntimeExports.jsxs("div",{className:NA.cn("fixed inset-0 z-[999] bg-background",e?"block":"hidden"),children:[ie.jsxRuntimeExports.jsx(xt.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>t(!1),children:"Close Preview"}),ie.jsxRuntimeExports.jsx("div",{children:r?ie.jsxRuntimeExports.jsx(g.Suspense,{fallback:ie.jsxRuntimeExports.jsx(xt.Skeleton,{className:"h-96 w-full"}),children:g.createElement(r)}):null})]})},xV=()=>{const[e,t]=Wr(),[,r]=TS(),n=DS(),a=fd(),[,o]=cd(),{pasteBlocks:s}=FS(),{undo:i,redo:l}=Ko();Sr.useHotkeys("esc",()=>t([]),{},[t]),Sr.useHotkeys("ctrl+c,command+c",()=>r(e),{},[e,r]),Sr.useHotkeys("ctrl+d,command+d",()=>a(e),{preventDefault:!0},[e,a]),Sr.useHotkeys("ctrl+x,command+x",()=>o(e),{},[e,o]),Sr.useHotkeys("ctrl+v,command+v",()=>e.length===1?s(e[0]):null,{},[e,s]),Sr.useHotkeys("ctrl+z,command+z",()=>i(),{},[i]),Sr.useHotkeys("ctrl+y,command+y",()=>l(),{},[l]),Sr.useHotkeys("del, backspace",u=>{u.preventDefault(),n(e)},{},[e,n])},RV=(e,t)=>{const r=[];let n=B.find(e,{_id:t}),a=B.get(n,"_parent","");for(;B.isString(a)&&!B.isEmpty(a);)r.push(n==null?void 0:n._parent),n=B.find(e,{_id:a}),a=n==null?void 0:n._parent;return B.flatten(r)},WS=G.atom([]),MV=()=>{const[e]=Wr(),t=G.useAtomValue(Vt),[,r]=G.useAtom(WS);g.useEffect(()=>{let n=[];const a=B.first(e);B.isString(a)&&(n=[a,...RV(t,a)]),r(n)},[e,t,r])},NV=()=>G.useAtomValue(WS),TV=g.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-1439e695.cjs"))),jV=g.lazy(()=>Promise.resolve().then(()=>require("./Topbar-c131ef83.cjs"))),zV=g.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-a261378b.cjs"))),FV=g.lazy(()=>Promise.resolve().then(()=>require("./Settings-d9df3548.cjs"))),qV=()=>{const[e]=G.useAtom(Lo),t=r=>{r.preventDefault()};return xV(),MV(),g.useEffect(()=>(e!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[e]),ie.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:ie.jsxRuntimeExports.jsxs(xt.TooltipProvider,{children:[ie.jsxRuntimeExports.jsxs("div",{onContextMenu:t,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[ie.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(jV,{})})}),ie.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-row",children:[ie.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(TV,{})})}),ie.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(zV,{})})}),ie.jsxRuntimeExports.jsx("div",{className:"flex h-full w-[280px] min-w-[280px] border-l border-border",children:ie.jsxRuntimeExports.jsx(g.Suspense,{children:ie.jsxRuntimeExports.jsx(FV,{})})})]})]}),ie.jsxRuntimeExports.jsx(PV,{})]})})},lm=G.getDefaultStore();G.atom({});function cm(e,t,r,n,a){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:a;return e===a?r:e}var Cs="undefined",um="object",US="any",ZS="*",gn="__",hl=typeof process<"u"?process:{};hl.env&&hl.env.NODE_ENV;var Yt=typeof document<"u";hl.versions!=null&&hl.versions.node!=null;typeof Deno<"u"&&Deno.core;Yt&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function JS(e,t){return t.charAt(0)[e]()+t.slice(1)}var DV=JS.bind(null,"toUpperCase"),BV=JS.bind(null,"toLowerCase");function VV(e){return GS(e)?DV("null"):typeof e=="object"?ZV(e):Object.prototype.toString.call(e).slice(8,-1)}function bl(e,t){t===void 0&&(t=!0);var r=VV(e);return t?BV(r):r}function Wo(e,t){return typeof t===e}var nr=Wo.bind(null,"function"),Zn=Wo.bind(null,"string"),Vn=Wo.bind(null,"undefined"),LV=Wo.bind(null,"boolean");Wo.bind(null,"symbol");function GS(e){return e===null}function KV(e){return bl(e)==="number"&&!isNaN(e)}function WV(e){return bl(e)==="array"}function Ct(e){if(!UV(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function UV(e){return e&&(typeof e=="object"||e!==null)}function ZV(e){return nr(e.constructor)?e.constructor.name:null}function JV(e){return e instanceof Error||Zn(e.message)&&e.constructor&&KV(e.constructor.stackTraceLimit)}function YS(e,t){if(typeof t!="object"||GS(t))return!1;if(t instanceof e)return!0;var r=bl(new e(""));if(JV(t))for(;t;){if(bl(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}YS.bind(null,TypeError);YS.bind(null,SyntaxError);function _l(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?GV(e,t):r}function GV(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function $l(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}$l(_l,"form");$l(_l,"button");$l(_l,"input");$l(_l,"select");function fm(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function YV(){if(Yt){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function HV(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function QV(e){return function(t){for(var r,n=Object.create(null),a=/([^&=]+)=?([^&]*)/g;r=a.exec(t);){var o=fm(r[1]),s=fm(r[2]);o.substring(o.length-2)==="[]"?(n[o=o.substring(0,o.length-2)]||(n[o]=[])).push(s):n[o]=s===""||s}for(var i in n){var l=i.split("[");l.length>1&&(XV(n,l.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),n[i]),delete n[i])}return n}(function(t){if(t){var r=t.match(/\?(.*)/);return r&&r[1]?r[1].split("#")[0]:""}return Yt&&window.location.search.substring(1)}(e))}function XV(e,t,r){for(var n=t.length-1,a=0;a<n;++a){var o=t[a];if(o==="__proto__"||o==="constructor")break;o in e||(e[o]={}),e=e[o]}e[t[n]]=r}function ec(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],a=15&r;e+=n=="-"||n=="4"?n:(n=="x"?a:3&a|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}var ro="global",wa=gn+"global"+gn,Sa=typeof self===um&&self.self===self&&self||typeof global===um&&global.global===global&&global||void 0;function vn(e){return Sa[wa][e]}function yn(e,t){return Sa[wa][e]=t}function xa(e){delete Sa[wa][e]}function Ra(e,t,r){var n;try{if(pd(e)){var a=window[e];n=a[t].bind(a)}}catch{}return n||r}Sa[wa]||(Sa[wa]={});var Is={};function pd(e){if(typeof Is[e]!==Cs)return Is[e];try{var t=window[e];t.setItem(Cs,Cs),t.removeItem(Cs)}catch{return Is[e]=!1}return Is[e]=!0}function ye(){return ye=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ye.apply(this,arguments)}var kr="function",hr="undefined",_V="@@redux/"+Math.random().toString(36),dm=function(){return typeof Symbol===kr&&Symbol.observable||"@@observable"}(),ks=" != "+kr;function HS(e,t,r){var n;if(typeof t===kr&&typeof r===hr&&(r=t,t=void 0),typeof r!==hr){if(typeof r!==kr)throw new Error("enhancer"+ks);return r(HS)(e,t)}if(typeof e!==kr)throw new Error("reducer"+ks);var a=e,o=t,s=[],i=s,l=!1;function u(){i===s&&(i=s.slice())}function c(){return o}function f(p){if(typeof p!==kr)throw new Error("Listener"+ks);var b=!0;return u(),i.push(p),function(){if(b){b=!1,u();var h=i.indexOf(p);i.splice(h,1)}}}function d(p){if(!Ct(p))throw new Error("Act != obj");if(typeof p.type===hr)throw new Error("ActType "+hr);if(l)throw new Error("Dispatch in reducer");try{l=!0,o=a(o,p)}finally{l=!1}for(var b=s=i,h=0;h<b.length;h++)(0,b[h])();return p}return d({type:"@@redux/INIT"}),(n={dispatch:d,subscribe:f,getState:c,replaceReducer:function(p){if(typeof p!==kr)throw new Error("next reducer"+ks);a=p,d({type:"@@redux/INIT"})}})[dm]=function(){var p,b=f;return(p={subscribe:function(h){if(typeof h!="object")throw new TypeError("Observer != obj");function m(){h.next&&h.next(c())}return m(),{unsubscribe:b(m)}}})[dm]=function(){return this},p},n}function $V(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+hr}function Aa(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,r){return function(){return t(r.apply(void 0,[].slice.call(arguments)))}})}function eL(){var e=arguments;return function(t){return function(r,n,a){var o,s=t(r,n,a),i=s.dispatch,l={getState:s.getState,dispatch:function(u){return i(u)}};return o=[].slice.call(e).map(function(u){return u(l)}),ye({},s,{dispatch:i=Aa.apply(void 0,o)(s.dispatch)})}}}var Br=gn+"anon_id",pn=gn+"user_id",Jn=gn+"user_traits",Ir="userId",Ln="anonymousId",Bs=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Mu=["name","EVENTS","config","loaded"],ve=Bs.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),pm=/^utm_/,hm=/^an_prop_/,bm=/^an_trait_/;function tL(e){var t=e.storage.setItem;return function(r){return function(n){return function(a){if(a.type===ve.bootstrap){var o=a.params,s=a.user,i=a.persistedUser,l=a.initialUser,u=i.userId===s.userId;i.anonymousId!==s.anonymousId&&t(Br,s.anonymousId),u||t(pn,s.userId),l.traits&&t(Jn,ye({},u&&i.traits?i.traits:{},l.traits));var c=Object.keys(a.params);if(c.length){var f=o.an_uid,d=o.an_event,p=c.reduce(function(b,h){if(h.match(pm)||h.match(/^(d|g)clid/)){var m=h.replace(pm,"");b.campaign[m==="campaign"?"name":m]=o[h]}return h.match(hm)&&(b.props[h.replace(hm,"")]=o[h]),h.match(bm)&&(b.traits[h.replace(bm,"")]=o[h]),b},{campaign:{},props:{},traits:{}});r.dispatch(ye({type:ve.params,raw:o},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&r.dispatch({type:ve.campaign,campaign:p.campaign})}}return n(a)}}}}function rL(e){return function(t,r){if(t===void 0&&(t={}),r===void 0&&(r={}),r.type===ve.setItemEnd){if(r.key===Br)return ye({},t,{anonymousId:r.value});if(r.key===pn)return ye({},t,{userId:r.value})}switch(r.type){case ve.identify:return Object.assign({},t,{userId:r.userId,traits:ye({},t.traits,r.traits)});case ve.reset:return[pn,Br,Jn].forEach(function(n){e.removeItem(n)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function mm(e){return{userId:e.getItem(pn),anonymousId:e.getItem(Br),traits:e.getItem(Jn)}}var Nu=function(e){return gn+"TEMP"+gn+e};function nL(e){var t=e.storage,r=t.setItem,n=t.removeItem,a=t.getItem;return function(o){return function(s){return function(i){var l=i.userId,u=i.traits,c=i.options;if(i.type===ve.reset&&([pn,Jn,Br].forEach(function(p){n(p)}),[Ir,Ln,"traits"].forEach(function(p){xa(Nu(p))})),i.type===ve.identify){a(Br)||r(Br,ec());var f=a(pn),d=a(Jn)||{};f&&f!==l&&o.dispatch({type:ve.userIdChanged,old:{userId:f,traits:d},new:{userId:l,traits:u},options:c}),l&&r(pn,l),u&&r(Jn,ye({},d,u))}return s(i)}}}}var Ga={};function gm(e,t){Ga[e]&&nr(Ga[e])&&(Ga[e](t),delete Ga[e])}function QS(e,t,r){return new Promise(function(n,a){return t()?n(e):r<1?a(ye({},e,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return QS(e,t,r-10).then(n,a)})})}function XS(e,t,r){var n=t(),a=e.getState(),o=a.plugins,s=a.queue,i=a.user;if(!a.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(c,f,d){return o[f.plugin].loaded?(c.process.push(f),c.processIndex.push(d)):(c.requeue.push(f),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(c){var f=s.actions[c],d=f.plugin,p=f.payload.type,b=n[d][p];if(b&&nr(b)){var h=function(v,y){return v===void 0&&(v={}),y===void 0&&(y={}),[Ir,Ln].reduce(function(w,A){return v.hasOwnProperty(A)&&y[A]&&y[A]!==v[A]&&(w[A]=y[A]),w},v)}(f.payload,i);b({payload:h,config:o[d].config,instance:r});var m=p+":"+d;e.dispatch(ye({},h,{type:m,_:{called:m,from:"queueDrain"}}))}});var u=s.actions.filter(function(c,f){return!~l.processIndex.indexOf(f)});s.actions=u}}}var Yc=function(e){var t=e.data,r=e.action,n=e.instance,a=e.state,o=e.allPlugins,s=e.allMatches,i=e.store,l=e.EVENTS;try{var u=a.plugins,c=a.context,f=r.type,d=f.match(Gn),p=t.exact.map(function(m){return m.pluginName});d&&(p=s.during.map(function(m){return m.pluginName}));var b=function(m,v){return function(y,w,A){var S=w.config,E=w.name,C=E+"."+y.type;A&&(C=A.event);var P=y.type.match(Gn)?function(I,T,z,M,W){return function(q,V){var _=M?M.name:I,U=V&&ho(V)?V:z;if(M&&(!(U=V&&ho(V)?V:[I]).includes(I)||U.length!==1))throw new Error("Method "+T+" can only abort "+I+" plugin. "+JSON.stringify(U)+" input valid");return ye({},W,{abort:{reason:q,plugins:U,caller:T,_}})}}(E,C,v,A,y):function(I,T){return function(){throw new Error(I.type+" action not cancellable. Remove abort in "+T)}}(y,C);return{payload:aL(y),instance:m,config:S||{},abort:P}}}(n,p),h=t.exact.reduce(function(m,v){var y=v.pluginName,w=v.methodName,A=!1;return w.match(/^initialize/)||w.match(/^reset/)||(A=!u[y].loaded),c.offline&&w.match(/^(page|track|identify)/)&&(A=!0),m[""+y]=A,m},{});return Promise.resolve(t.exact.reduce(function(m,v,y){try{var w=v.pluginName;return Promise.resolve(m).then(function(A){function S(){return Promise.resolve(A)}var E=function(){if(t.namespaced&&t.namespaced[w])return Promise.resolve(t.namespaced[w].reduce(function(C,P,I){try{return Promise.resolve(C).then(function(T){return P.method&&nr(P.method)?(function(q,V){var _=Om(q);if(_&&_.name===V){var U=Om(_.method);throw new Error([V+" plugin is calling method "+q,"Plugins cant call self","Use "+_.method+" "+(U?"or "+U.method:"")+" in "+V+" plugin insteadof "+q].join(`
|
|
164
|
+
`))}}(P.methodName,P.pluginName),Promise.resolve(P.method({payload:T,instance:n,abort:(z=T,M=w,W=P.pluginName,function(q,V){return ye({},z,{abort:{reason:q,plugins:V||[M],caller:f,from:W||M}})}),config:wm(P.pluginName,u,o),plugins:u})).then(function(q){var V=Ct(q)?q:{};return Promise.resolve(ye({},T,V))})):T;var z,M,W})}catch(T){return Promise.reject(T)}},Promise.resolve(r))).then(function(C){A[w]=C});A[w]=r}();return E&&E.then?E.then(S):S()})}catch(A){return Promise.reject(A)}},Promise.resolve({}))).then(function(m){return Promise.resolve(t.exact.reduce(function(v,y,w){try{var A=t.exact.length===w+1,S=y.pluginName,E=o[S];return Promise.resolve(v).then(function(C){var P=m[S]?m[S]:{};if(d&&(P=C),Qc(P,S))return Hc({data:P,method:f,instance:n,pluginName:S,store:i}),Promise.resolve(C);if(Qc(C,S))return A&&Hc({data:C,method:f,instance:n,store:i}),Promise.resolve(C);if(h.hasOwnProperty(S)&&h[S]===!0)return i.dispatch({type:"queue",plugin:S,payload:P,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(C);var I=b(m[S],o[S]);return Promise.resolve(E[f]({abort:I.abort,payload:P,instance:n,config:wm(S,u,o),plugins:u})).then(function(T){var z=Ct(T)?T:{},M=ye({},C,z),W=m[S];if(Qc(W,S))Hc({data:W,method:f,instance:n,pluginName:S,store:i});else{var q=f+":"+S;(q.match(/:/g)||[]).length<2&&!f.match(vm)&&!f.match(ym)&&n.dispatch(ye({},d?M:P,{type:q,_:{called:q,from:"submethod"}}))}return Promise.resolve(M)})})}catch(C){return Promise.reject(C)}},Promise.resolve(r))).then(function(v){if(!(f.match(Gn)||f.match(/^registerPlugin/)||f.match(ym)||f.match(vm)||f.match(/^params/)||f.match(/^userIdChanged/))){if(l.plugins.includes(f),v._&&v._.originalAction===f)return v;var y=ye({},v,{_:{originalAction:v.type,called:v.type,from:"engineEnd"}});_S(v,t.exact.length)&&!f.match(/End$/)&&(y=ye({},y,{type:v.type+"Aborted"})),i.dispatch(y)}return v})})}catch(m){return Promise.reject(m)}},Gn=/Start$/,vm=/^bootstrap/,ym=/^ready/;function Hc(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(ye({},e.data,{type:r,_:{called:r,from:"abort"}}))}function wm(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function Sm(e,t){return t.reduce(function(r,n){return n[e]?r.concat({methodName:e,pluginName:n.name,method:n[e]}):r},[])}function Am(e,t){var r=e.replace(Gn,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function Qc(e,t){var r=e.abort;return!!r&&(r===!0||Em(r,t)||r&&Em(r.plugins,t))}function _S(e,t){var r=e.abort;if(!r)return!1;if(r===!0||Zn(r))return!0;var n=r.plugins;return ho(r)&&r.length===t||ho(n)&&n.length===t}function ho(e){return Array.isArray(e)}function Em(e,t){return!(!e||!ho(e))&&e.includes(t)}function Om(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function aL(e){return Object.keys(e).reduce(function(t,r){return r==="type"||(t[r]=Ct(e[r])?Object.assign({},e[r]):e[r]),t},{})}function oL(e,t,r){var n={};return function(a){return function(o){return function(s){try{var i,l=function(A){return i?A:o(f)},u=s.type,c=s.plugins,f=s;if(s.abort)return Promise.resolve(o(s));if(u===ve.enablePlugin&&a.dispatch({type:ve.initializeStart,plugins:c,disabled:[],fromEnable:!0,meta:s.meta}),u===ve.disablePlugin&&setTimeout(function(){return gm(s.meta.rid,{payload:s})},0),u===ve.initializeEnd){var d=t(),p=Object.keys(d),b=p.filter(function(A){return c.includes(A)}).map(function(A){return d[A]}),h=[],m=[],v=s.disabled,y=b.map(function(A){var S=A.loaded,E=A.name,C=A.config;return QS(A,function(){return S({config:C})},1e4).then(function(P){return n[E]||(a.dispatch({type:ve.pluginReadyType(E),name:E,events:Object.keys(A).filter(function(I){return!Mu.includes(I)})}),n[E]=!0),h=h.concat(E),A}).catch(function(P){if(P instanceof Error)throw new Error(P);return m=m.concat(P.name),P})});Promise.all(y).then(function(A){var S={plugins:h,failed:m,disabled:v};setTimeout(function(){p.length===y.length+v.length&&a.dispatch(ye({},{type:ve.ready},S))},0)})}var w=function(){if(u!==ve.bootstrap)return/^ready:([^:]*)$/.test(u)&&setTimeout(function(){return XS(a,t,e)},0),Promise.resolve(function(A,S,E,C,P){try{var I=nr(S)?S():S,T=A.type,z=T.replace(Gn,"");if(A._&&A._.called)return Promise.resolve(A);var M=E.getState(),W=(_=I,(U=M.plugins)===void 0&&(U={}),(Z=A.options)===void 0&&(Z={}),Object.keys(_).filter(function(O){var R=Z.plugins||{};return LV(R[O])?R[O]:R.all!==!1&&(!U[O]||U[O].enabled!==!1)}).map(function(O){return _[O]}));T===ve.initializeStart&&A.fromEnable&&(W=Object.keys(M.plugins).filter(function(O){var R=M.plugins[O];return A.plugins.includes(O)&&!R.initialized}).map(function(O){return I[O]}));var q=W.map(function(O){return O.name}),V=function(O,R,J){var D=Am(O).map(function(K){return Sm(K,R)});return R.reduce(function(K,$){var re=$.name,X=Am(O,re).map(function(ue){return Sm(ue,R)}),oe=X[0],ee=X[1],ne=X[2];return oe.length&&(K.beforeNS[re]=oe),ee.length&&(K.duringNS[re]=ee),ne.length&&(K.afterNS[re]=ne),K},{before:D[0],beforeNS:{},during:D[1],duringNS:{},after:D[2],afterNS:{}})}(T,W);return Promise.resolve(Yc({action:A,data:{exact:V.before,namespaced:V.beforeNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function(O){function R(){var K=function(){if(T.match(Gn))return Promise.resolve(Yc({action:ye({},J,{type:z+"End"}),data:{exact:V.after,namespaced:V.afterNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function($){$.meta&&$.meta.hasCallback&&gm($.meta.rid,{payload:$})})}();return K&&K.then?K.then(function(){return O}):O}if(_S(O,q.length))return O;var J,D=function(){if(T!==z)return Promise.resolve(Yc({action:ye({},O,{type:z}),data:{exact:V.during,namespaced:V.duringNS},state:M,allPlugins:I,allMatches:V,instance:E,store:C,EVENTS:P})).then(function(K){J=K});J=O}();return D&&D.then?D.then(R):R()})}catch(O){return Promise.reject(O)}var _,U,Z}(s,t,e,a,r)).then(function(A){return i=1,o(A)})}();return Promise.resolve(w&&w.then?w.then(l):l(w))}catch(A){return Promise.reject(A)}}}}}function sL(e){return function(t){return function(r){return function(n){var a=n.type,o=n.key,s=n.value,i=n.options;if(a===ve.setItem||a===ve.removeItem){if(n.abort)return r(n);a===ve.setItem?e.setItem(o,s,i):e.removeItem(o,i)}return r(n)}}}}var iL=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex(function(a){return a===t});n!==-1&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(a){var o={getState:r.getState,dispatch:function(i){return r.dispatch(i)}},s=e[t].map(function(i){return i(o)});return Aa.apply(void 0,s)(n)(a)}}}}};function lL(e){return function(t,r){t===void 0&&(t={});var n={};if(r.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var a=Cm(r.type,"registerPlugin"),o=e()[a];if(!o||!a)return t;var s=r.enabled,i=o.config;return n[a]={enabled:s,initialized:!!s&&!o.initialize,loaded:!!s&&!!o.loaded({config:i}),config:i},ye({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var l=Cm(r.type,ve.initialize),u=e()[l];return u&&l?(n[l]=ye({},t[l],{initialized:!0,loaded:!!u.loaded({config:u.config})}),ye({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=ye({},t[r.name],{loaded:!0}),ye({},t,n);switch(r.type){case ve.disablePlugin:return ye({},t,Im(r.plugins,!1,t));case ve.enablePlugin:return ye({},t,Im(r.plugins,!0,t));default:return t}}}function Cm(e,t){return e.substring(t.length+1,e.length)}function Im(e,t,r){return e.reduce(function(n,a){return n[a]=ye({},r[a],{enabled:t}),n},r)}function $S(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var cL={last:{},history:[]};function uL(e,t){e===void 0&&(e=cL);var r=t.options,n=t.meta;if(t.type===ve.track){var a=$S(ye({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return ye({},e,{last:a,history:e.history.concat(a)})}return e}var fL={actions:[]};function dL(e,t){e===void 0&&(e=fL);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===ve.identify?[t].concat(e.actions):e.actions.concat(t),ye({},e,{actions:n});case"dequeue":return[];default:return e}}var eA=/#.*$/;function pL(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(eA,""):"")}var tA,rA,nA,aA,hL=function(e){if(e===void 0&&(e={}),!Yt)return e;var t=document,r=t.title,n=t.referrer,a=window,o=a.location,s=a.innerWidth,i=a.innerHeight,l=o.hash,u=o.search,c=function(d){var p=function(){if(Yt){for(var b,h=document.getElementsByTagName("link"),m=0;b=h[m];m++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return p?p.match(/\?/)?p:p+d:window.location.href.replace(eA,"")}(u),f={title:r,url:c,path:pL(c),hash:l,search:u,width:s,height:i};return n&&n!==""&&(f.referrer=n),ye({},f,e)},bL={last:{},history:[]};function mL(e,t){e===void 0&&(e=bL);var r=t.options;if(t.type===ve.page){var n=$S(ye({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return ye({},e,{last:n,history:e.history.concat(n)})}return e}tA=function(){if(!Yt)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),rA=Yt?document.referrer:null,nA=YV(),aA=HV();var km={initialized:!1,sessionId:ec(),app:null,version:null,debug:!1,offline:!!Yt&&!navigator.onLine,os:{name:tA},userAgent:Yt?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:aA,locale:nA,campaign:{},referrer:rA};function gL(e,t){e===void 0&&(e=km);var r=e.initialized,n=t.campaign;switch(t.type){case ve.campaign:return ye({},e,{campaign:n});case ve.offline:return ye({},e,{offline:!0});case ve.online:return ye({},e,{offline:!1});default:return r?e:ye({},km,e,{initialized:!0})}}var vL=["plugins","reducers","storage"];function yL(e,t,r){if(Yt){var n=window[(r?"add":"remove")+"EventListener"];e.split(" ").forEach(function(a){n(a,t)})}}function wL(e){var t=yL.bind(null,"online offline",function(r){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(r){return t(!1)}}function oA(){return yn("analytics",[]),function(e){return function(t,r,n){var a=e(t,r,n),o=a.dispatch;return Object.assign(a,{dispatch:function(s){return Sa[wa].analytics.push(s.action||s),o(s)}})}}}function Pm(e){return function(){return Aa(Aa.apply(null,arguments),oA())}}function Xc(e){return e?WV(e)?e:[e]:[]}function xm(e,t,r){e===void 0&&(e={});var n,a,o=ec();return t&&(Ga[o]=(n=t,a=function(s){for(var i,l=s||Array.prototype.slice.call(arguments),u=0;u<l.length;u++)if(nr(l[u])){i=l[u];break}return i}(r),function(s){a&&a(s),n(s)})),ye({},e,{rid:o,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function SL(e){e===void 0&&(e={});var t=e.reducers||{},r=e.initialUser||{},n=(e.plugins||[]).reduce(function(O,R){if(nr(R))return O.middlewares=O.middlewares.concat(R),O;if(R.NAMESPACE&&(R.name=R.NAMESPACE),!R.name)throw new Error("https://lytics.dev/errors/1");R.config||(R.config={});var J=R.EVENTS?Object.keys(R.EVENTS).map(function($){return R.EVENTS[$]}):[];O.pluginEnabled[R.name]=!(R.enabled===!1||R.config.enabled===!1),delete R.enabled,R.methods&&(O.methods[R.name]=Object.keys(R.methods).reduce(function($,re){var X;return $[re]=(X=R.methods[re],function(){for(var oe=Array.prototype.slice.call(arguments),ee=new Array(X.length),ne=0;ne<oe.length;ne++)ee[ne]=oe[ne];return ee[ee.length]=S,X.apply({instance:S},ee)}),$},{}),delete R.methods);var D=Object.keys(R).concat(J),K=new Set(O.events.concat(D));if(O.events=Array.from(K),O.pluginsArray=O.pluginsArray.concat(R),O.plugins[R.name])throw new Error(R.name+"AlreadyLoaded");return O.plugins[R.name]=R,O.plugins[R.name].loaded||(O.plugins[R.name].loaded=function(){return!0}),O},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),a=e.storage?e.storage:{getItem:vn,setItem:yn,removeItem:xa},o=function(O){return function(R,J,D){return J.getState("user")[R]||(D&&Ct(D)&&D[R]?D[R]:mm(O)[R]||vn(Nu(R))||null)}}(a),s=n.plugins,i=n.events.filter(function(O){return!Mu.includes(O)}).sort(),l=new Set(i.concat(Bs).filter(function(O){return!Mu.includes(O)})),u=Array.from(l).sort(),c=function(){return s},f=new iL,d=f.addMiddleware,p=f.removeMiddleware,b=f.dynamicMiddlewares,h=function(){throw new Error("Abort disabled inListener")},m=QV(),v=mm(a),y=ye({},v,r,m.an_uid?{userId:m.an_uid}:{},m.an_aid?{anonymousId:m.an_aid}:{});y.anonymousId||(y.anonymousId=ec());var w=ye({enable:function(O,R){return new Promise(function(J){V.dispatch({type:ve.enablePlugin,plugins:Xc(O),_:{originalAction:ve.enablePlugin}},J,[R])})},disable:function(O,R){return new Promise(function(J){V.dispatch({type:ve.disablePlugin,plugins:Xc(O),_:{originalAction:ve.disablePlugin}},J,[R])})}},n.methods),A=!1,S={identify:function(O,R,J,D){try{var K=Zn(O)?O:null,$=Ct(O)?O:R,re=J||{},X=S.user();yn(Nu(Ir),K);var oe=K||$.userId||o(Ir,S,$);return Promise.resolve(new Promise(function(ee){V.dispatch(ye({type:ve.identifyStart,userId:oe,traits:$||{},options:re,anonymousId:X.anonymousId},X.id&&X.id!==K&&{previousId:X.id}),ee,[R,J,D])}))}catch(ee){return Promise.reject(ee)}},track:function(O,R,J,D){try{var K=Ct(O)?O.event:O;if(!K||!Zn(K))throw new Error("EventMissing");var $=Ct(O)?O:R||{},re=Ct(J)?J:{};return Promise.resolve(new Promise(function(X){V.dispatch({type:ve.trackStart,event:K,properties:$,options:re,userId:o(Ir,S,R),anonymousId:o(Ln,S,R)},X,[R,J,D])}))}catch(X){return Promise.reject(X)}},page:function(O,R,J){try{var D=Ct(O)?O:{},K=Ct(R)?R:{};return Promise.resolve(new Promise(function($){V.dispatch({type:ve.pageStart,properties:hL(D),options:K,userId:o(Ir,S,D),anonymousId:o(Ln,S,D)},$,[O,R,J])}))}catch($){return Promise.reject($)}},user:function(O){if(O===Ir||O==="id")return o(Ir,S);if(O===Ln||O==="anonId")return o(Ln,S);var R=S.getState("user");return O?cm(R,O):R},reset:function(O){return new Promise(function(R){V.dispatch({type:ve.resetStart},R,O)})},ready:function(O){return A&&O({plugins:w,instance:S}),S.on(ve.ready,function(R){O(R),A=!0})},on:function(O,R){if(!O||!nr(R))return!1;if(O===ve.bootstrap)throw new Error(".on disabled for "+O);var J=/Start$|Start:/;if(O==="*"){var D=function(X){return function(oe){return function(ee){return ee.type.match(J)&&R({payload:ee,instance:S,plugins:s}),oe(ee)}}},K=function(X){return function(oe){return function(ee){return ee.type.match(J)||R({payload:ee,instance:S,plugins:s}),oe(ee)}}};return d(D,Ps),d(K,xs),function(){p(D,Ps),p(K,xs)}}var $=O.match(J)?Ps:xs,re=function(X){return function(oe){return function(ee){return ee.type===O&&R({payload:ee,instance:S,plugins:s,abort:h}),oe(ee)}}};return d(re,$),function(){return p(re,$)}},once:function(O,R){if(!O||!nr(R))return!1;if(O===ve.bootstrap)throw new Error(".once disabled for "+O);var J=S.on(O,function(D){R({payload:D.payload,instance:S,plugins:s,abort:h}),J()});return J},getState:function(O){var R=V.getState();return O?cm(R,O):Object.assign({},R)},dispatch:function(O){var R=Zn(O)?{type:O}:O;if(Bs.includes(R.type))throw new Error("reserved action "+R.type);var J=ye({},R,{_:ye({originalAction:R.type},O._||{})});V.dispatch(J)},enablePlugin:w.enable,disablePlugin:w.disable,plugins:w,storage:{getItem:a.getItem,setItem:function(O,R,J){V.dispatch({type:ve.setItemStart,key:O,value:R,options:J})},removeItem:function(O,R){V.dispatch({type:ve.removeItemStart,key:O,options:R})}},setAnonymousId:function(O,R){S.storage.setItem(Br,O,R)},events:{core:Bs,plugins:i}},E=n.middlewares.concat([function(O){return function(R){return function(J){return J.meta||(J.meta=xm()),R(J)}}},b(Ps),oL(S,c,{all:u,plugins:i}),sL(a),tL(S),nL(S),b(xs)]),C={context:gL,user:rL(a),page:mL,track:uL,plugins:lL(c),queue:dL},P=Aa,I=Aa;if(Yt&&e.debug){var T=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;T&&(P=T({trace:!0,traceLimit:25})),I=function(){return arguments.length===0?oA():Ct(typeof arguments[0])?Pm():Pm().apply(null,arguments)}}var z,M=function(O){return Object.keys(O).reduce(function(R,J){return vL.includes(J)||(R[J]=O[J]),R},{})}(e),W=n.pluginsArray.reduce(function(O,R){var J=R.name,D=R.config,K=R.loaded,$=n.pluginEnabled[J];return O[J]={enabled:$,initialized:!!$&&!R.initialize,loaded:!!K({config:D}),config:D},O},{}),q={context:M,user:y,plugins:W},V=HS(function(O){for(var R=Object.keys(O),J={},D=0;D<R.length;D++){var K=R[D];typeof O[K]===kr&&(J[K]=O[K])}var $,re=Object.keys(J);try{(function(X){Object.keys(X).forEach(function(oe){var ee=X[oe];if(typeof ee(void 0,{type:"@@redux/INIT"})===hr||typeof ee(void 0,{type:_V})===hr)throw new Error("reducer "+oe+" "+hr)})})(J)}catch(X){$=X}return function(X,oe){if(X===void 0&&(X={}),$)throw $;for(var ee=!1,ne={},ue=0;ue<re.length;ue++){var de=re[ue],H=X[de],Q=(0,J[de])(H,oe);if(typeof Q===hr){var ge=$V(de,oe);throw new Error(ge)}ne[de]=Q,ee=ee||Q!==H}return ee?ne:X}}(ye({},C,t)),q,I(P(eL.apply(void 0,E))));V.dispatch=(z=V.dispatch,function(O,R,J){var D=ye({},O,{meta:xm(O.meta,R,Xc(J))});return z.apply(null,[D])});var _=Object.keys(s);V.dispatch({type:ve.bootstrap,plugins:_,config:M,params:m,user:y,initialUser:r,persistedUser:v});var U=_.filter(function(O){return n.pluginEnabled[O]}),Z=_.filter(function(O){return!n.pluginEnabled[O]});return V.dispatch({type:ve.registerPlugins,plugins:_,enabled:n.pluginEnabled}),n.pluginsArray.map(function(O,R){var J=O.bootstrap,D=O.config,K=O.name;J&&nr(J)&&J({instance:S,config:D,payload:O}),V.dispatch({type:ve.registerPluginType(K),name:K,enabled:n.pluginEnabled[K],plugin:O}),n.pluginsArray.length===R+1&&V.dispatch({type:ve.initializeStart,plugins:U,disabled:Z})}),wL(function(O){V.dispatch({type:O?ve.offline:ve.online})}),function(O,R,J){setInterval(function(){return XS(O,R,J)},3e3)}(V,c,S),S}var Ps="before",xs="after",no="cookie",_r=lA(),sA=tc,AL=tc;function iA(e){return _r?tc(e,"",-1):xa(e)}function lA(){if(_r!==void 0)return _r;var e="cookiecookie";try{tc(e,e),_r=document.cookie.indexOf(e)!==-1,iA(e)}catch{_r=!1}return _r}function tc(e,t,r,n,a,o){if(typeof window<"u"){var s=arguments.length>1;return _r===!1&&(s?yn(e,t):vn(e)),s?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(a?"; domain="+a:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var ao="localStorage",EL=pd.bind(null,"localStorage");Ra("localStorage","getItem",vn);Ra("localStorage","setItem",yn);Ra("localStorage","removeItem",xa);var oo="sessionStorage",OL=pd.bind(null,"sessionStorage");Ra("sessionStorage","getItem",vn);Ra("sessionStorage","setItem",yn);Ra("sessionStorage","removeItem",xa);function Yn(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(Ct(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var CL=EL(),IL=OL(),kL=lA();function cA(e,t){if(e){var r=hd(t),n=!vd(r),a=bd(r)?Yn(localStorage.getItem(e)):void 0;if(n&&!Vn(a))return a;var o=md(r)?Yn(sA(e)):void 0;if(n&&o)return o;var s=gd(r)?Yn(sessionStorage.getItem(e)):void 0;if(n&&s)return s;var i=vn(e);return n?i:{localStorage:a,sessionStorage:s,cookie:o,global:i}}}function PL(e,t,r){if(e&&!Vn(t)){var n={},a=hd(r),o=JSON.stringify(t),s=!vd(a);return bd(a)&&(n[ao]=Rs(ao,t,Yn(localStorage.getItem(e))),localStorage.setItem(e,o),s)?n[ao]:md(a)&&(n[no]=Rs(no,t,Yn(sA(e))),AL(e,o),s)?n[no]:gd(a)&&(n[oo]=Rs(oo,t,Yn(sessionStorage.getItem(e))),sessionStorage.setItem(e,o),s)?n[oo]:(n[ro]=Rs(ro,t,vn(e)),yn(e,t),s?n[ro]:n)}}function xL(e,t){if(e){var r=hd(t),n=cA(e,ZS),a={};return!Vn(n.localStorage)&&bd(r)&&(localStorage.removeItem(e),a[ao]=n.localStorage),!Vn(n.cookie)&&md(r)&&(iA(e),a[no]=n.cookie),!Vn(n.sessionStorage)&&gd(r)&&(sessionStorage.removeItem(e),a[oo]=n.sessionStorage),!Vn(n.global)&&rc(r,ro)&&(xa(e),a[ro]=n.global),a}}function hd(e){return e?Zn(e)?e:e.storage:US}function bd(e){return CL&&rc(e,ao)}function md(e){return kL&&rc(e,no)}function gd(e){return IL&&rc(e,oo)}function vd(e){return e===ZS||e==="all"}function rc(e,t){return e===US||e===t||vd(e)}function Rs(e,t,r){return{location:e,current:t,previous:r}}var RL={setItem:PL,getItem:cA,removeItem:xL};function ML(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Rm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Mm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rm(Object(r),!0).forEach(function(n){ML(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function NL(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:RL};return SL(Mm(Mm({},t),e))}const TL="@chaibuilder/sdk",jL="0.1.22",zL="module",FL=["dist"],qL="dist/core.js",DL=!1,BL={".":{import:"./dist/core.js",require:"./dist/core.cjs",types:"./dist/core.d.ts"},"./render":{import:"./dist/render.js",require:"./dist/render.cjs",types:"./dist/render.d.ts"},"./ui":{import:"./dist/ui.js",require:"./dist/ui.cjs",types:"./dist/ui.d.ts"},"./lib":{import:"./dist/lib.js",require:"./dist/lib.cjs",types:"./dist/lib.d.ts"},"./server":{import:"./dist/server.js",require:"./dist/server.cjs",types:"./dist/server.d.ts"},"./styles":{import:"./dist/style.css",require:"./dist/style.css"}},VL={dev:"vite",build:"tsc && vite build",lint:"eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",preview:"vite preview",test:"jest --colors","test:watch":"jest --watch --colors","test:coverage":"jest --coverage --colors",e2e:"playwright test","e2e:report":"playwright show-report","e2e:ui":"playwright test --ui",docs:"jsdoc -c jsdoc.conf.json"},LL={"@bobthered/tailwindcss-palette-generator":"3.1.1","@chaibuilder/blocks":"0.1.21","@floating-ui/dom":"1.4.5","@floating-ui/react-dom":"2.0.1","@mhsdesign/jit-browser-tailwindcss":"0.3.0","@minoru/react-dnd-treeview":"3.4.4","@radix-ui/react-accordion":"^1.1.2","@radix-ui/react-alert-dialog":"^1.0.4","@radix-ui/react-context-menu":"^2.1.4","@radix-ui/react-dialog":"^1.0.4","@radix-ui/react-dropdown-menu":"^2.0.5","@radix-ui/react-hover-card":"^1.0.6","@radix-ui/react-icons":"^1.3.0","@radix-ui/react-label":"^2.0.2","@radix-ui/react-menubar":"^1.0.3","@radix-ui/react-navigation-menu":"^1.1.3","@radix-ui/react-popover":"^1.0.6","@radix-ui/react-scroll-area":"^1.0.4","@radix-ui/react-select":"^1.2.2","@radix-ui/react-separator":"^1.0.3","@radix-ui/react-slot":"^1.0.2","@radix-ui/react-switch":"^1.0.3","@radix-ui/react-tabs":"^1.0.4","@radix-ui/react-toast":"^1.1.4","@radix-ui/react-toggle":"^1.0.3","@radix-ui/react-tooltip":"^1.0.6","@react-hookz/web":"23.1.0","@rjsf/core":"5.11.2","@rjsf/utils":"5.11.2","@rjsf/validator-ajv8":"5.11.2","@tailwindcss/aspect-ratio":"0.4.2","@tailwindcss/forms":"^0.5.6","@tailwindcss/line-clamp":"^0.4.4","@tailwindcss/typography":"^0.5.10","@tanstack/react-query":"^5.8.4",analytics:"^0.8.9","class-variance-authority":"0.6.1",clsx:"1.2.1",cmdk:"0.2.0","date-fns":"^2.30.0",flagged:"2.0.9","flat-to-nested":"1.1.1","focus-trap-react":"^10.2.1","forgiving-xml-parser":"1.4.0","framer-motion":"^10.12.18","fuse.js":"6.6.2","gray-matter":"^4.0.3",himalaya:"^1.1.0","html-formatter":"0.1.9",i18next:"^23.2.8",jotai:"2.2.2",lodash:"4.17.21","lucide-react":"^0.244.0",nanoid:"^4.0.2","post-robot":"10.0.46",react:"^18.2.0","react-autosuggest":"10.1.0","react-colorful":"5.6.1","react-dnd":"16.0.1","react-dnd-html5-backend":"16.0.1","react-dom":"^18.2.0","react-hotkeys-hook":"4.4.1","react-i18next":"13.0.1","react-icons":"^4.10.1","react-icons-picker":"^1.0.9","react-json-view":"^1.21.3","react-quill":"^2.0.0","react-textarea-autosize":"^8.5.2","react-wrap-balancer":"^1.0.0","redux-undo":"1.1.0",sonner:"^1.2.0","tailwind-merge":"1.13.2","tailwindcss-animate":"1.0.6","tippy.js":"^6.3.7","unist-util-visit":"^4.1.2","unsplash-js":"^7.0.18"},KL={"@commitlint/cli":"17.7.1","@commitlint/config-conventional":"17.7.0","@emotion/react":"^11.11.1","@faker-js/faker":"^8.3.1","@nozbe/watermelondb":"^0.27.1","@playwright/test":"^1.39.0","@tanstack/eslint-plugin-query":"^5.8.4","@testing-library/react-hooks":"^8.0.1","@types/better-sqlite3":"^7.6.7","@types/jest":"^29.5.7","@types/lodash":"^4.14.200","@types/node":"^20.8.10","@types/react":"^18.2.15","@types/react-dom":"^18.2.7","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","@vitejs/plugin-react-swc":"^3.3.2",autoprefixer:"^10.4.16","better-docs":"^2.7.2","better-sqlite3":"^9.1.1","drizzle-kit":"^0.20.4","drizzle-orm":"^0.29.0",eslint:"^8.45.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3",jest:"^29.7.0","jest-environment-jsdom":"^29.7.0","jotai-devtools":"^0.7.1",jsdoc:"^4.0.2",msw:"^2.0.8",postcss:"^8.4.31",prettier:"^3.0.3","prettier-plugin-tailwindcss":"^0.5.6","prop-types":"^15.8.1","react-router-dom":"^6.19.0",tailwindcss:"^3.3.5","ts-jest":"^29.1.1",typescript:"^5.0.2",vite:"^4.4.5","vite-plugin-dts":"^3.6.3"},WL={workerDirectory:"public"},UL={name:TL,private:!1,version:jL,type:zL,files:FL,main:qL,sideEffects:DL,exports:BL,scripts:VL,dependencies:LL,devDependencies:KL,msw:WL},Nm="https://api.chaibuilder.com",Tm=()=>typeof window>"u"?!1:window.location.href.includes("localhost");function ZL(){return{name:"chaibuilder-analytics",config:{},initialize:()=>{if(typeof window>"u")return!1;window.chaibuilderAnalyticsLoaded=!0},page:e=>{if(typeof window>"u")return!1;if(Tm())return;const{payload:t}=e;fetch(`${Nm}/v1/log`,{method:"post",body:JSON.stringify(t)}).then(r=>r.json())},track:({payload:e})=>{if(typeof window>"u")return!1;Tm()||fetch(`${Nm}/v1/log`,{method:"post",body:JSON.stringify(e)})},loaded:()=>typeof window>"u"?!0:!!window.chaibuilderAnalyticsLoaded}}const JL=NL({app:"chaibuilder",version:UL.version,plugins:[ZL()]});({}).NODE_ENV==="development"&&console.log("Chai Builder:",KA);const GL=e=>ie.jsxRuntimeExports.jsx(ie.jsxRuntimeExports.Fragment,{children:e.children}),YL=e=>{const{dndOptions:t={backend:Od.MultiBackend}}=e,[r]=sS(),[,n]=ad(),a=dd();return g.useEffect(()=>{lm.set(xt.chaiBuilderPropsAtom,B.omit(e,["blocks","subPages","brandingOptions","dataProvidersAtom"]))},[e]),g.useEffect(()=>{lm.set(ld,e.dataProviders||[])},[e.dataProviders]),g.useEffect(()=>{r(tg.syncBlocksWithDefaults(e.blocks||[])),a()},[e.blocks]),g.useEffect(()=>{n(e.brandingOptions)},[e.brandingOptions,n]),g.useEffect(()=>{JL.page()},[]),ie.jsxRuntimeExports.jsx(MA.DndProvider,{...t,options:Od.getBackendOptions(),children:ie.jsxRuntimeExports.jsx(GL,{children:ie.jsxRuntimeExports.jsx(qV,{})})})},uA=e=>ie.jsxRuntimeExports.jsxs(eS,{children:[ie.jsxRuntimeExports.jsxs(RA.FlagsProvider,{features:rB,children:[ie.jsxRuntimeExports.jsx(tB,{}),ie.jsxRuntimeExports.jsx(YL,{...e})]}),ie.jsxRuntimeExports.jsx(xt.Toaster,{})]});var Ma=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ea=typeof window>"u"||"Deno"in window;function Dt(){}function HL(e,t){return typeof e=="function"?e(t):e}function Tu(e){return typeof e=="number"&&e>=0&&e!==1/0}function fA(e,t){return Math.max(e+(t||0)-Date.now(),0)}function jm(e,t){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:s,stale:i}=e;if(s){if(n){if(t.queryHash!==yd(s,t.options))return!1}else if(!mo(t.queryKey,s))return!1}if(r!=="all"){const l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||typeof a<"u"&&a!==t.state.fetchStatus||o&&!o(t))}function zm(e,t){const{exact:r,status:n,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(r){if(bo(t.options.mutationKey)!==bo(o))return!1}else if(!mo(t.options.mutationKey,o))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function yd(e,t){return((t==null?void 0:t.queryKeyHashFn)||bo)(e)}function bo(e){return JSON.stringify(e,(t,r)=>ju(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function mo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!mo(e[r],t[r])):!1}function dA(e,t){if(e===t)return e;const r=Fm(e)&&Fm(t);if(r||ju(e)&&ju(t)){const n=r?e.length:Object.keys(e).length,a=r?t:Object.keys(t),o=a.length,s=r?[]:{};let i=0;for(let l=0;l<o;l++){const u=r?l:a[l];s[u]=dA(e[u],t[u]),s[u]===e[u]&&i++}return n===o&&i===n?e:s}return t}function ml(e,t){if(e&&!t||t&&!e)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Fm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ju(e){if(!qm(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const r=t.prototype;return!(!qm(r)||!r.hasOwnProperty("isPrototypeOf"))}function qm(e){return Object.prototype.toString.call(e)==="[object Object]"}function pA(e){return new Promise(t=>{setTimeout(t,e)})}function Dm(e){pA(0).then(e)}function zu(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?dA(e,t):t}function QL(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function XL(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var tn,Pr,Hn,Km,_L=(Km=class extends Ma{constructor(){super();fe(this,tn,void 0);fe(this,Pr,void 0);fe(this,Hn,void 0);se(this,Hn,t=>{if(!Ea&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){x(this,Pr)||this.setEventListener(x(this,Hn))}onUnsubscribe(){var t;this.hasListeners()||((t=x(this,Pr))==null||t.call(this),se(this,Pr,void 0))}setEventListener(t){var r;se(this,Hn,t),(r=x(this,Pr))==null||r.call(this),se(this,Pr,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){x(this,tn)!==t&&(se(this,tn,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof x(this,tn)=="boolean"?x(this,tn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},tn=new WeakMap,Pr=new WeakMap,Hn=new WeakMap,Km),gl=new _L,Qn,xr,Xn,Wm,$L=(Wm=class extends Ma{constructor(){super();fe(this,Qn,!0);fe(this,xr,void 0);fe(this,Xn,void 0);se(this,Xn,t=>{if(!Ea&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){x(this,xr)||this.setEventListener(x(this,Xn))}onUnsubscribe(){var t;this.hasListeners()||((t=x(this,xr))==null||t.call(this),se(this,xr,void 0))}setEventListener(t){var r;se(this,Xn,t),(r=x(this,xr))==null||r.call(this),se(this,xr,t(this.setOnline.bind(this)))}setOnline(t){x(this,Qn)!==t&&(se(this,Qn,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return x(this,Qn)}},Qn=new WeakMap,xr=new WeakMap,Xn=new WeakMap,Wm),vl=new $L;function eK(e){return Math.min(1e3*2**e,3e4)}function nc(e){return(e??"online")==="online"?vl.isOnline():!0}var hA=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function _c(e){return e instanceof hA}function bA(e){let t=!1,r=0,n=!1,a,o,s;const i=new Promise((m,v)=>{o=m,s=v}),l=m=>{var v;n||(p(new hA(m)),(v=e.abort)==null||v.call(e))},u=()=>{t=!0},c=()=>{t=!1},f=()=>!gl.isFocused()||e.networkMode!=="always"&&!vl.isOnline(),d=m=>{var v;n||(n=!0,(v=e.onSuccess)==null||v.call(e,m),a==null||a(),o(m))},p=m=>{var v;n||(n=!0,(v=e.onError)==null||v.call(e,m),a==null||a(),s(m))},b=()=>new Promise(m=>{var v;a=y=>{const w=n||!f();return w&&m(y),w},(v=e.onPause)==null||v.call(e)}).then(()=>{var m;a=void 0,n||(m=e.onContinue)==null||m.call(e)}),h=()=>{if(n)return;let m;try{m=e.fn()}catch(v){m=Promise.reject(v)}Promise.resolve(m).then(d).catch(v=>{var E;if(n)return;const y=e.retry??(Ea?0:3),w=e.retryDelay??eK,A=typeof w=="function"?w(r,v):w,S=y===!0||typeof y=="number"&&r<y||typeof y=="function"&&y(r,v);if(t||!S){p(v);return}r++,(E=e.onFail)==null||E.call(e,r,v),pA(A).then(()=>{if(f())return b()}).then(()=>{t?p(v):h()})})};return nc(e.networkMode)?h():b().then(h),{promise:i,cancel:l,continue:()=>(a==null?void 0:a())?i:Promise.resolve(),cancelRetry:u,continueRetry:c}}function tK(){let e=[],t=0,r=c=>{c()},n=c=>{c()};const a=c=>{let f;t++;try{f=c()}finally{t--,t||i()}return f},o=c=>{t?e.push(c):Dm(()=>{r(c)})},s=c=>(...f)=>{o(()=>{c(...f)})},i=()=>{const c=e;e=[],c.length&&Dm(()=>{n(()=>{c.forEach(f=>{r(f)})})})};return{batch:a,batchCalls:s,schedule:o,setNotifyFunction:c=>{r=c},setBatchNotifyFunction:c=>{n=c}}}var Qe=tK(),rn,Um,mA=(Um=class{constructor(){fe(this,rn,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Tu(this.gcTime)&&se(this,rn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ea?1/0:5*60*1e3))}clearGcTimeout(){x(this,rn)&&(clearTimeout(x(this,rn)),se(this,rn,void 0))}},rn=new WeakMap,Um),_n,$n,jt,Rr,zt,_e,go,nn,ea,Vs,Jt,ur,Zm,rK=(Zm=class extends mA{constructor(t){super();fe(this,ea);fe(this,Jt);fe(this,_n,void 0);fe(this,$n,void 0);fe(this,jt,void 0);fe(this,Rr,void 0);fe(this,zt,void 0);fe(this,_e,void 0);fe(this,go,void 0);fe(this,nn,void 0);se(this,nn,!1),se(this,go,t.defaultOptions),Se(this,ea,Vs).call(this,t.options),se(this,_e,[]),se(this,jt,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,se(this,_n,t.state||nK(this.options)),this.state=x(this,_n),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!x(this,_e).length&&this.state.fetchStatus==="idle"&&x(this,jt).remove(this)}setData(t,r){const n=zu(this.state.data,t,this.options);return Se(this,Jt,ur).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Se(this,Jt,ur).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n;const r=x(this,Rr);return(n=x(this,zt))==null||n.cancel(t),r?r.then(Dt).catch(Dt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(x(this,_n))}isActive(){return x(this,_e).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||x(this,_e).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!fA(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=x(this,_e).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=x(this,zt))==null||r.continue()}onOnline(){var r;const t=x(this,_e).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=x(this,zt))==null||r.continue()}addObserver(t){x(this,_e).includes(t)||(x(this,_e).push(t),this.clearGcTimeout(),x(this,jt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){x(this,_e).includes(t)&&(se(this,_e,x(this,_e).filter(r=>r!==t)),x(this,_e).length||(x(this,zt)&&(x(this,nn)?x(this,zt).cancel({revert:!0}):x(this,zt).cancelRetry()),this.scheduleGc()),x(this,jt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return x(this,_e).length}invalidate(){this.state.isInvalidated||Se(this,Jt,ur).call(this,{type:"invalidate"})}fetch(t,r){var u,c,f,d;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(x(this,Rr))return(u=x(this,zt))==null||u.continueRetry(),x(this,Rr)}if(t&&Se(this,ea,Vs).call(this,t),!this.options.queryFn){const p=x(this,_e).find(b=>b.options.queryFn);p&&Se(this,ea,Vs).call(this,p.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,a={queryKey:this.queryKey,meta:this.meta},o=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(se(this,nn,!0),n.signal)})};o(a);const s=()=>this.options.queryFn?(se(this,nn,!1),this.options.persister?this.options.persister(this.options.queryFn,a,this):this.options.queryFn(a)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),i={fetchOptions:r,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};o(i),(c=this.options.behavior)==null||c.onFetch(i,this),se(this,$n,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=i.fetchOptions)==null?void 0:f.meta))&&Se(this,Jt,ur).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta});const l=p=>{var b,h,m,v;_c(p)&&p.silent||Se(this,Jt,ur).call(this,{type:"error",error:p}),_c(p)||((h=(b=x(this,jt).config).onError)==null||h.call(b,p,this),(v=(m=x(this,jt).config).onSettled)==null||v.call(m,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return se(this,zt,bA({fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:p=>{var b,h,m,v;if(typeof p>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(p),(h=(b=x(this,jt).config).onSuccess)==null||h.call(b,p,this),(v=(m=x(this,jt).config).onSettled)==null||v.call(m,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,b)=>{Se(this,Jt,ur).call(this,{type:"failed",failureCount:p,error:b})},onPause:()=>{Se(this,Jt,ur).call(this,{type:"pause"})},onContinue:()=>{Se(this,Jt,ur).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode})),se(this,Rr,x(this,zt).promise),x(this,Rr)}},_n=new WeakMap,$n=new WeakMap,jt=new WeakMap,Rr=new WeakMap,zt=new WeakMap,_e=new WeakMap,go=new WeakMap,nn=new WeakMap,ea=new WeakSet,Vs=function(t){this.options={...x(this,go),...t},this.updateGcTime(this.options.gcTime)},Jt=new WeakSet,ur=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:nc(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return _c(a)&&a.revert&&x(this,$n)?{...x(this,$n),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),Qe.batch(()=>{x(this,_e).forEach(n=>{n.onQueryUpdate()}),x(this,jt).notify({query:this,type:"updated",action:t})})},Zm);function nK(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=typeof t<"u",n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Qt,Jm,aK=(Jm=class extends Ma{constructor(t={}){super();fe(this,Qt,void 0);this.config=t,se(this,Qt,new Map)}build(t,r,n){const a=r.queryKey,o=r.queryHash??yd(a,r);let s=this.get(o);return s||(s=new rK({cache:this,queryKey:a,queryHash:o,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(s)),s}add(t){x(this,Qt).has(t.queryHash)||(x(this,Qt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=x(this,Qt).get(t.queryHash);r&&(t.destroy(),r===t&&x(this,Qt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Qe.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return x(this,Qt).get(t)}getAll(){return[...x(this,Qt).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>jm(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>jm(t,n)):r}notify(t){Qe.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Qe.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qt=new WeakMap,Jm),Xt,vo,Ot,ta,_t,Cr,Gm,oK=(Gm=class extends mA{constructor(t){super();fe(this,_t);fe(this,Xt,void 0);fe(this,vo,void 0);fe(this,Ot,void 0);fe(this,ta,void 0);this.mutationId=t.mutationId,se(this,vo,t.defaultOptions),se(this,Ot,t.mutationCache),se(this,Xt,[]),this.state=t.state||gA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...x(this,vo),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){x(this,Xt).includes(t)||(x(this,Xt).push(t),this.clearGcTimeout(),x(this,Ot).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){se(this,Xt,x(this,Xt).filter(r=>r!==t)),this.scheduleGc(),x(this,Ot).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){x(this,Xt).length||(this.state.status==="pending"?this.scheduleGc():x(this,Ot).remove(this))}continue(){var t;return((t=x(this,ta))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,o,s,i,l,u,c,f,d,p,b,h,m,v,y,w,A,S,E,C;const r=()=>(se(this,ta,bA({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,I)=>{Se(this,_t,Cr).call(this,{type:"failed",failureCount:P,error:I})},onPause:()=>{Se(this,_t,Cr).call(this,{type:"pause"})},onContinue:()=>{Se(this,_t,Cr).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),x(this,ta).promise),n=this.state.status==="pending";try{if(!n){Se(this,_t,Cr).call(this,{type:"pending",variables:t}),await((o=(a=x(this,Ot).config).onMutate)==null?void 0:o.call(a,t,this));const I=await((i=(s=this.options).onMutate)==null?void 0:i.call(s,t));I!==this.state.context&&Se(this,_t,Cr).call(this,{type:"pending",context:I,variables:t})}const P=await r();return await((u=(l=x(this,Ot).config).onSuccess)==null?void 0:u.call(l,P,t,this.state.context,this)),await((f=(c=this.options).onSuccess)==null?void 0:f.call(c,P,t,this.state.context)),await((p=(d=x(this,Ot).config).onSettled)==null?void 0:p.call(d,P,null,this.state.variables,this.state.context,this)),await((h=(b=this.options).onSettled)==null?void 0:h.call(b,P,null,t,this.state.context)),Se(this,_t,Cr).call(this,{type:"success",data:P}),P}catch(P){try{throw await((v=(m=x(this,Ot).config).onError)==null?void 0:v.call(m,P,t,this.state.context,this)),await((w=(y=this.options).onError)==null?void 0:w.call(y,P,t,this.state.context)),await((S=(A=x(this,Ot).config).onSettled)==null?void 0:S.call(A,void 0,P,this.state.variables,this.state.context,this)),await((C=(E=this.options).onSettled)==null?void 0:C.call(E,void 0,P,t,this.state.context)),P}finally{Se(this,_t,Cr).call(this,{type:"error",error:P})}}}},Xt=new WeakMap,vo=new WeakMap,Ot=new WeakMap,ta=new WeakMap,_t=new WeakSet,Cr=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!nc(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Qe.batch(()=>{x(this,Xt).forEach(n=>{n.onMutationUpdate(t)}),x(this,Ot).notify({mutation:this,type:"updated",action:t})})},Gm);function gA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,yo,an,Ym,sK=(Ym=class extends Ma{constructor(t={}){super();fe(this,Ft,void 0);fe(this,yo,void 0);fe(this,an,void 0);this.config=t,se(this,Ft,[]),se(this,yo,0)}build(t,r,n){const a=new oK({mutationCache:this,mutationId:++es(this,yo)._,options:t.defaultMutationOptions(r),state:n});return this.add(a),a}add(t){x(this,Ft).push(t),this.notify({type:"added",mutation:t})}remove(t){se(this,Ft,x(this,Ft).filter(r=>r!==t)),this.notify({type:"removed",mutation:t})}clear(){Qe.batch(()=>{x(this,Ft).forEach(t=>{this.remove(t)})})}getAll(){return x(this,Ft)}find(t){const r={exact:!0,...t};return x(this,Ft).find(n=>zm(r,n))}findAll(t={}){return x(this,Ft).filter(r=>zm(t,r))}notify(t){Qe.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){return se(this,an,(x(this,an)??Promise.resolve()).then(()=>{const t=x(this,Ft).filter(r=>r.state.isPaused);return Qe.batch(()=>t.reduce((r,n)=>r.then(()=>n.continue().catch(Dt)),Promise.resolve()))}).then(()=>{se(this,an,void 0)})),x(this,an)}},Ft=new WeakMap,yo=new WeakMap,an=new WeakMap,Ym);function iK(e){return{onFetch:(t,r)=>{const n=async()=>{var b,h,m,v,y;const a=t.options,o=(m=(h=(b=t.fetchOptions)==null?void 0:b.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,s=((v=t.state.data)==null?void 0:v.pages)||[],i=((y=t.state.data)==null?void 0:y.pageParams)||[],l={pages:[],pageParams:[]};let u=!1;const c=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),d=async(w,A,S)=>{if(u)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const E={queryKey:t.queryKey,pageParam:A,direction:S?"backward":"forward",meta:t.options.meta};c(E);const C=await f(E),{maxPages:P}=t.options,I=S?XL:QL;return{pages:I(w.pages,C,P),pageParams:I(w.pageParams,A,P)}};let p;if(o&&s.length){const w=o==="backward",A=w?lK:Bm,S={pages:s,pageParams:i},E=A(a,S);p=await d(S,E,w)}else{p=await d(l,i[0]??a.initialPageParam);const w=e??s.length;for(let A=1;A<w;A++){const S=Bm(a,p);p=await d(p,S)}}return p};t.options.persister?t.fetchFn=()=>{var a,o;return(o=(a=t.options).persister)==null?void 0:o.call(a,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=n}}}function Bm(e,{pages:t,pageParams:r}){const n=t.length-1;return e.getNextPageParam(t[n],t,r[n],r)}function lK(e,{pages:t,pageParams:r}){var n;return(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r)}var Ge,Mr,Nr,ra,na,Tr,aa,oa,Hm,cK=(Hm=class{constructor(e={}){fe(this,Ge,void 0);fe(this,Mr,void 0);fe(this,Nr,void 0);fe(this,ra,void 0);fe(this,na,void 0);fe(this,Tr,void 0);fe(this,aa,void 0);fe(this,oa,void 0);se(this,Ge,e.queryCache||new aK),se(this,Mr,e.mutationCache||new sK),se(this,Nr,e.defaultOptions||{}),se(this,ra,new Map),se(this,na,new Map),se(this,Tr,0)}mount(){es(this,Tr)._++,x(this,Tr)===1&&(se(this,aa,gl.subscribe(()=>{gl.isFocused()&&(this.resumePausedMutations(),x(this,Ge).onFocus())})),se(this,oa,vl.subscribe(()=>{vl.isOnline()&&(this.resumePausedMutations(),x(this,Ge).onOnline())})))}unmount(){var e,t;es(this,Tr)._--,x(this,Tr)===0&&((e=x(this,aa))==null||e.call(this),se(this,aa,void 0),(t=x(this,oa))==null||t.call(this),se(this,oa,void 0))}isFetching(e){return x(this,Ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return x(this,Mr).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=x(this,Ge).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=x(this,Ge).find({queryKey:e}),a=n==null?void 0:n.state.data,o=HL(t,a);if(typeof o>"u")return;const s=this.defaultQueryOptions({queryKey:e});return x(this,Ge).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return Qe.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var t;return(t=x(this,Ge).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=x(this,Ge);Qe.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=x(this,Ge),n={type:"active",...e};return Qe.batch(()=>(r.findAll(e).forEach(a=>{a.reset()}),this.refetchQueries(n,t)))}cancelQueries(e={},t={}){const r={revert:!0,...t},n=Qe.batch(()=>x(this,Ge).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Dt).catch(Dt)}invalidateQueries(e={},t={}){return Qe.batch(()=>{if(x(this,Ge).findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const r={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e={},t){const r={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=Qe.batch(()=>x(this,Ge).findAll(e).filter(a=>!a.isDisabled()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Dt)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Dt)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const r=x(this,Ge).build(this,t);return r.isStaleByTime(t.staleTime)?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Dt).catch(Dt)}fetchInfiniteQuery(e){return e.behavior=iK(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Dt).catch(Dt)}resumePausedMutations(){return x(this,Mr).resumePausedMutations()}getQueryCache(){return x(this,Ge)}getMutationCache(){return x(this,Mr)}getDefaultOptions(){return x(this,Nr)}setDefaultOptions(e){se(this,Nr,e)}setQueryDefaults(e,t){x(this,ra).set(bo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...x(this,ra).values()];let r={};return t.forEach(n=>{mo(e,n.queryKey)&&(r={...r,...n.defaultOptions})}),r}setMutationDefaults(e,t){x(this,na).set(bo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...x(this,na).values()];let r={};return t.forEach(n=>{mo(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...x(this,Nr).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=yd(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...x(this,Nr).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){x(this,Ge).clear(),x(this,Mr).clear()}},Ge=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,ra=new WeakMap,na=new WeakMap,Tr=new WeakMap,aa=new WeakMap,oa=new WeakMap,Hm),ht,Ne,sa,at,on,ia,$t,wo,la,ca,sn,ln,jr,cn,un,Ya,So,Fu,Ao,qu,Eo,Du,Oo,Bu,Co,Vu,Io,Lu,ko,Ku,yl,vA,Qm,uK=(Qm=class extends Ma{constructor(t,r){super();fe(this,un);fe(this,So);fe(this,Ao);fe(this,Eo);fe(this,Oo);fe(this,Co);fe(this,Io);fe(this,ko);fe(this,yl);fe(this,ht,void 0);fe(this,Ne,void 0);fe(this,sa,void 0);fe(this,at,void 0);fe(this,on,void 0);fe(this,ia,void 0);fe(this,$t,void 0);fe(this,wo,void 0);fe(this,la,void 0);fe(this,ca,void 0);fe(this,sn,void 0);fe(this,ln,void 0);fe(this,jr,void 0);fe(this,cn,void 0);se(this,Ne,void 0),se(this,sa,void 0),se(this,at,void 0),se(this,cn,new Set),se(this,ht,t),this.options=r,se(this,$t,null),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(x(this,Ne).addObserver(this),Vm(x(this,Ne),this.options)?Se(this,un,Ya).call(this):this.updateResult(),Se(this,Oo,Bu).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wu(x(this,Ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wu(x(this,Ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,Co,Vu).call(this),Se(this,Io,Lu).call(this),x(this,Ne).removeObserver(this)}setOptions(t,r){const n=this.options,a=x(this,Ne);if(this.options=x(this,ht).defaultQueryOptions(t),ml(n,this.options)||x(this,ht).getQueryCache().notify({type:"observerOptionsUpdated",query:x(this,Ne),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),Se(this,ko,Ku).call(this);const o=this.hasListeners();o&&Lm(x(this,Ne),a,this.options,n)&&Se(this,un,Ya).call(this),this.updateResult(r),o&&(x(this,Ne)!==a||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&Se(this,So,Fu).call(this);const s=Se(this,Ao,qu).call(this);o&&(x(this,Ne)!==a||this.options.enabled!==n.enabled||s!==x(this,jr))&&Se(this,Eo,Du).call(this,s)}getOptimisticResult(t){const r=x(this,ht).getQueryCache().build(x(this,ht),t),n=this.createResult(r,t);return dK(this,n)&&(se(this,at,n),se(this,ia,this.options),se(this,on,x(this,Ne).state)),n}getCurrentResult(){return x(this,at)}trackResult(t){const r={};return Object.keys(t).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(x(this,cn).add(n),t[n])})}),r}getCurrentQuery(){return x(this,Ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=x(this,ht).defaultQueryOptions(t),n=x(this,ht).getQueryCache().build(x(this,ht),r);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,un,Ya).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),x(this,at)))}createResult(t,r){var E;const n=x(this,Ne),a=this.options,o=x(this,at),s=x(this,on),i=x(this,ia),u=t!==n?t.state:x(this,sa),{state:c}=t;let{error:f,errorUpdatedAt:d,fetchStatus:p,status:b}=c,h=!1,m;if(r._optimisticResults){const C=this.hasListeners(),P=!C&&Vm(t,r),I=C&&Lm(t,n,r,a);(P||I)&&(p=nc(t.options.networkMode)?"fetching":"paused",c.dataUpdatedAt||(b="pending")),r._optimisticResults==="isRestoring"&&(p="idle")}if(r.select&&typeof c.data<"u")if(o&&c.data===(s==null?void 0:s.data)&&r.select===x(this,wo))m=x(this,la);else try{se(this,wo,r.select),m=r.select(c.data),m=zu(o==null?void 0:o.data,m,r),se(this,la,m),se(this,$t,null)}catch(C){se(this,$t,C)}else m=c.data;if(typeof r.placeholderData<"u"&&typeof m>"u"&&b==="pending"){let C;if(o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData))C=o.data;else if(C=typeof r.placeholderData=="function"?r.placeholderData((E=x(this,ca))==null?void 0:E.state.data,x(this,ca)):r.placeholderData,r.select&&typeof C<"u")try{C=r.select(C),se(this,$t,null)}catch(P){se(this,$t,P)}typeof C<"u"&&(b="success",m=zu(o==null?void 0:o.data,C,r),h=!0)}x(this,$t)&&(f=x(this,$t),m=x(this,la),d=Date.now(),b="error");const v=p==="fetching",y=b==="pending",w=b==="error",A=y&&v;return{status:b,fetchStatus:p,isPending:y,isSuccess:b==="success",isError:w,isInitialLoading:A,isLoading:A,data:m,dataUpdatedAt:c.dataUpdatedAt,error:f,errorUpdatedAt:d,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>u.dataUpdateCount||c.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:w&&c.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:h,isRefetchError:w&&c.dataUpdatedAt!==0,isStale:wd(t,r),refetch:this.refetch}}updateResult(t){const r=x(this,at),n=this.createResult(x(this,Ne),this.options);if(se(this,on,x(this,Ne).state),se(this,ia,this.options),x(this,on).data!==void 0&&se(this,ca,x(this,Ne)),ml(n,r))return;se(this,at,n);const a={},o=()=>{if(!r)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!x(this,cn).size)return!0;const l=new Set(i??x(this,cn));return this.options.throwOnError&&l.add("error"),Object.keys(x(this,at)).some(u=>{const c=u;return x(this,at)[c]!==r[c]&&l.has(c)})};(t==null?void 0:t.listeners)!==!1&&o()&&(a.listeners=!0),Se(this,yl,vA).call(this,{...a,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,Oo,Bu).call(this)}},ht=new WeakMap,Ne=new WeakMap,sa=new WeakMap,at=new WeakMap,on=new WeakMap,ia=new WeakMap,$t=new WeakMap,wo=new WeakMap,la=new WeakMap,ca=new WeakMap,sn=new WeakMap,ln=new WeakMap,jr=new WeakMap,cn=new WeakMap,un=new WeakSet,Ya=function(t){Se(this,ko,Ku).call(this);let r=x(this,Ne).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Dt)),r},So=new WeakSet,Fu=function(){if(Se(this,Co,Vu).call(this),Ea||x(this,at).isStale||!Tu(this.options.staleTime))return;const r=fA(x(this,at).dataUpdatedAt,this.options.staleTime)+1;se(this,sn,setTimeout(()=>{x(this,at).isStale||this.updateResult()},r))},Ao=new WeakSet,qu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(x(this,Ne)):this.options.refetchInterval)??!1},Eo=new WeakSet,Du=function(t){Se(this,Io,Lu).call(this),se(this,jr,t),!(Ea||this.options.enabled===!1||!Tu(x(this,jr))||x(this,jr)===0)&&se(this,ln,setInterval(()=>{(this.options.refetchIntervalInBackground||gl.isFocused())&&Se(this,un,Ya).call(this)},x(this,jr)))},Oo=new WeakSet,Bu=function(){Se(this,So,Fu).call(this),Se(this,Eo,Du).call(this,Se(this,Ao,qu).call(this))},Co=new WeakSet,Vu=function(){x(this,sn)&&(clearTimeout(x(this,sn)),se(this,sn,void 0))},Io=new WeakSet,Lu=function(){x(this,ln)&&(clearInterval(x(this,ln)),se(this,ln,void 0))},ko=new WeakSet,Ku=function(){const t=x(this,ht).getQueryCache().build(x(this,ht),this.options);if(t===x(this,Ne))return;const r=x(this,Ne);se(this,Ne,t),se(this,sa,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},yl=new WeakSet,vA=function(t){Qe.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(x(this,at))}),x(this,ht).getQueryCache().notify({query:x(this,Ne),type:"observerResultsUpdated"})})},Qm);function fK(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Vm(e,t){return fK(e,t)||e.state.dataUpdatedAt>0&&Wu(e,t,t.refetchOnMount)}function Wu(e,t,r){if(t.enabled!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&wd(e,t)}return!1}function Lm(e,t,r,n){return r.enabled!==!1&&(e!==t||n.enabled===!1)&&(!r.suspense||e.state.status!=="error")&&wd(e,r)}function wd(e,t){return e.isStaleByTime(t.staleTime)}function dK(e,t){return!ml(e.getCurrentResult(),t)}var zr,st,qt,dr,ua,Ls,Po,Uu,Xm,pK=(Xm=class extends Ma{constructor(t,r){super();fe(this,ua);fe(this,Po);fe(this,zr,void 0);fe(this,st,void 0);fe(this,qt,void 0);fe(this,dr,void 0);se(this,st,void 0),se(this,zr,t),this.setOptions(r),this.bindMethods(),Se(this,ua,Ls).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=x(this,zr).defaultMutationOptions(t),ml(r,this.options)||x(this,zr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:x(this,qt),observer:this}),(n=x(this,qt))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=x(this,qt))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,ua,Ls).call(this),Se(this,Po,Uu).call(this,t)}getCurrentResult(){return x(this,st)}reset(){se(this,qt,void 0),Se(this,ua,Ls).call(this),Se(this,Po,Uu).call(this)}mutate(t,r){var n;return se(this,dr,r),(n=x(this,qt))==null||n.removeObserver(this),se(this,qt,x(this,zr).getMutationCache().build(x(this,zr),this.options)),x(this,qt).addObserver(this),x(this,qt).execute(t)}},zr=new WeakMap,st=new WeakMap,qt=new WeakMap,dr=new WeakMap,ua=new WeakSet,Ls=function(){var r;const t=((r=x(this,qt))==null?void 0:r.state)??gA();se(this,st,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Po=new WeakSet,Uu=function(t){Qe.batch(()=>{var r,n,a,o,s,i,l,u;x(this,dr)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(r=x(this,dr)).onSuccess)==null||n.call(r,t.data,x(this,st).variables,x(this,st).context),(o=(a=x(this,dr)).onSettled)==null||o.call(a,t.data,null,x(this,st).variables,x(this,st).context)):(t==null?void 0:t.type)==="error"&&((i=(s=x(this,dr)).onError)==null||i.call(s,t.error,x(this,st).variables,x(this,st).context),(u=(l=x(this,dr)).onSettled)==null||u.call(l,void 0,t.error,x(this,st).variables,x(this,st).context))),this.listeners.forEach(c=>{c(x(this,st))})})},Xm),yA=k.createContext(void 0),ir=e=>{const t=k.useContext(yA);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},hK=({client:e,children:t})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),k.createElement(yA.Provider,{value:e},t)),wA=k.createContext(!1),bK=()=>k.useContext(wA);wA.Provider;function mK(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var gK=k.createContext(mK()),vK=()=>k.useContext(gK);function SA(e,t){return typeof e=="function"?e(...t):!!e}var yK=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},wK=e=>{k.useEffect(()=>{e.clearReset()},[e])},SK=({result:e,errorResetBoundary:t,throwOnError:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&SA(r,[e.error,n]),AK=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},EK=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,OK=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function CK(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=ir(r),a=bK(),o=vK(),s=n.defaultQueryOptions(e);s._optimisticResults=a?"isRestoring":"optimistic",AK(s),yK(s,o),wK(o);const[i]=k.useState(()=>new t(n,s)),l=i.getOptimisticResult(s);if(k.useSyncExternalStore(k.useCallback(u=>{const c=a?()=>{}:i.subscribe(Qe.batchCalls(u));return i.updateResult(),c},[i,a]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),k.useEffect(()=>{i.setOptions(s,{listeners:!1})},[s,i]),EK(s,l))throw OK(s,i,o);if(SK({result:l,errorResetBoundary:o,throwOnError:s.throwOnError,query:i.getCurrentQuery()}))throw l.error;return s.notifyOnChangeProps?l:i.trackResult(l)}function Uo(e,t){return CK(e,uK,t)}function gr(e,t){const r=ir(t),[n]=k.useState(()=>new pK(r,e));k.useEffect(()=>{n.setOptions(e)},[n,e]);const a=k.useSyncExternalStore(k.useCallback(s=>n.subscribe(Qe.batchCalls(s)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((s,i)=>{n.mutate(s,i).catch(IK)},[n]);if(a.error&&SA(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function IK(){}function St(){return ir().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Na=()=>{const{data:e,refetch:t}=Uo({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[e,r=>{r&&(localStorage.setItem("currentPage",r||""),t())}]},ac=()=>{const[e,t]=Na(),r=St();return Uo({queryKey:["project"],queryFn:async()=>{const n=await fetch(`${r}/project`).then(a=>a.json());if(!e&&n){const a=localStorage.getItem("currentPage");t(a||(n==null?void 0:n.homepage))}return n}})},Sd=()=>{const e=St();return Uo({queryKey:["pages"],queryFn:async()=>await fetch(`${e}/pages`).then(r=>r.json())||[]})},kK=()=>{const[e,t]=Na(),{data:r}=ac(),n=St();return Uo({queryKey:["page_data",e],queryFn:async()=>{const a=await fetch(`${n}/page?uuid=${e}`);return a.ok?a.json():(t(r.homepage),null)},enabled:!!e,staleTime:3e3})},Zu=()=>ie.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:ie.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[ie.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),ie.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),ie.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),AA=(e="Project updated successfully.")=>{const t=ir(),r=St();return gr({mutationFn:async n=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),ar.toast.success(e)}})},EA=()=>{const[e]=["SAVED"],[t,r]=Na(),n=dd();return a=>e!=="SAVED"?(ar.toast.error("You have unsaved changes. Please save before changing the page."),!1):t===a.uuid?!1:(n(),setTimeout(()=>{r(a.uuid)},100),!0)},PK=()=>{const e=ir(),t=EA(),r=St();return gr({mutationFn:async n=>fetch(`${r}/pages`,{method:"POST",body:JSON.stringify(n)}).then(a=>a.json()),onSuccess:n=>{e.invalidateQueries({queryKey:["pages"]}),t({uuid:n.uuid,slug:n.slug}),ar.toast.success("Page added successfully.")}})},OA=()=>{const e=St();return gr({mutationFn:async t=>fetch(`${e}/page`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{ar.toast.success("Page saved successfully.")}})},xK=()=>{const e=St(),{data:t}=Sd(),[r]=Na(),{data:n}=ac();return gr({mutationFn:async()=>{const a=t.find(o=>o.uuid===r).slug;await fetch(`${e}/publish`,{method:"POST",body:JSON.stringify({slug:a,uuid:r,isHomepage:(n==null?void 0:n.homepage)===r})})},onSuccess:()=>{ar.toast.success("Page published successfully.",{position:"top-right",duration:2e3})}})},RK=()=>{const e=ir(),t=St();return gr({mutationFn:async r=>fetch(`${t}/page`,{method:"DELETE",body:JSON.stringify(r)}),onSuccess:()=>{ar.toast.success("Page deleted successfully."),e.invalidateQueries({queryKey:["pages"]})}})},MK=()=>{const e=St();return gr({mutationFn:async()=>{const t=await fetch(`${e}/library`).then(r=>r.json());return B.sortBy(B.filter(t,r=>!B.has(r,"hidden")),"group")}})},NK=()=>{const e=St();return gr({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const r=await fetch(`${e}/block?uuid=${t.uuid}&format=${t.format}`).then(async n=>t.format==="html"?mt.getBlocksFromHTML(await n.text()):await n.json());debugger;return B.set(r,"0._name",B.capitalize(t.group)),r||[]}catch{return[]}}})},TK=()=>{const e=St();return gr({mutationFn:async t=>{const r=new FormData;return r.append("file",t),await(await fetch(`${e}/upload`,{method:"POST",body:r})).json()}})},jK=g.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-163b7771.cjs"))),zK=g.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-e78931cd.cjs"))),FK=g.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-b67bee36.cjs"))),qK=()=>ie.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),DK=()=>{const e=ir();return ie.jsxRuntimeExports.jsx("div",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:ie.jsxRuntimeExports.jsx(jA.LogOutIcon,{className:"w-4 h-4 text-red-500",onClick:()=>{localStorage.removeItem("__anon_token"),e.invalidateQueries({queryKey:["verify"]})}})})},BK=()=>{const{mutate:e}=xK();return ie.jsxRuntimeExports.jsx(xt.Button,{onClick:e,className:"bg-blue-600 text-white",children:"Publish"})},VK=e=>{const{data:t,isLoading:r}=ac(),{data:n,isLoading:a}=Sd(),{data:o}=kK(),{mutate:s}=AA(),{mutate:i}=OA(),[l]=Na(),u=TK(),c=MK(),f=NK(),d=St(),p=g.useCallback(async y=>await u.mutateAsync(y),[u]),b=g.useCallback(async()=>await c.mutateAsync(),[c]),h=g.useCallback(async y=>await f.mutateAsync(y),[f]),m=async(y=20,w=0)=>{const A=`limit=${y}&offset=${w}`;return await fetch(`${d}/assets?${A}`).then(S=>S.json())},{logo:v=qK}=e;return r||!t?ie.jsxRuntimeExports.jsx(Zu,{}):a||!n?ie.jsxRuntimeExports.jsx(Zu,{}):ie.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:ie.jsxRuntimeExports.jsx(uA,{blocks:(o==null?void 0:o.blocks)||[],brandingOptions:t.brandingOptions,darkMode:e.darkMode||!1,dataProviders:t.dataProviders||[],onSavePage:async({blocks:y,providers:w})=>(console.log({blocks:y,providers:w}),i({blocks:y,providers:w,uuid:l}),!0),onSaveBrandingOptions:async y=>(s({brandingOptions:y}),!0),topBarComponents:{left:[v],center:[FK],right:[BK]},sideBarComponents:{top:[{icon:Ks.FileTextIcon,name:"pages",panel:jK},{icon:Ks.GearIcon,name:"settings",panel:zK}],bottom:[DK]},uploadMediaCallback:p,fetchMediaCallback:m,getUILibraryBlocks:b,getExternalPredefinedBlock:h,getPages:()=>n,unsplashAccessKey:e.unsplashAccessKey||""})})},LK=()=>{const e=St(),t=ir();return gr({mutationFn:async r=>{const n=await fetch(`${e}/authenticate`,{method:"POST",body:JSON.stringify(r)});if(n.ok)return await n.json();throw new Error("INvalid")},onSuccess:r=>{if(!r.token){ar.toast.error("Something went wrong. Please try again.");return}localStorage.setItem("__anon_token",r.token),t.invalidateQueries({queryKey:["verify"]}),ar.toast.success("Authenticated successfully.")},onError:()=>{ar.toast.error("Incorrect password. Please try again.")}})},KK=()=>{const e=St();return Uo({queryKey:["verify"],queryFn:async()=>{const t=localStorage.getItem("__anon_token");if(!t)return{valid:!1};const r=await fetch(`${e}/verify?token=`+t,{method:"GET"});return r.ok?(await r.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__anon_token"),{valid:!1}):(localStorage.removeItem("__anon_token"),{valid:!0})}})},WK=({logo:e})=>{const[t,r]=g.useState(!1),[n,a]=g.useState(""),{mutate:o,isPending:s}=LK(),i=()=>{o({password:n})};return ie.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:ie.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:ie.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[ie.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[ie.jsxRuntimeExports.jsx(g.Suspense,{children:e?g.createElement(e):""}),ie.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your app password to continue"})]}),ie.jsxRuntimeExports.jsx("div",{className:"mt-8",children:ie.jsxRuntimeExports.jsxs("div",{className:"space-y-5",children:[ie.jsxRuntimeExports.jsx("div",{children:ie.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[ie.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:ie.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ie.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),ie.jsxRuntimeExports.jsx("input",{value:n,onChange:l=>a(l.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),ie.jsxRuntimeExports.jsx("button",{className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>r(!t),children:t?ie.jsxRuntimeExports.jsx(Ks.EyeClosedIcon,{}):ie.jsxRuntimeExports.jsx(Ks.EyeOpenIcon,{})})]})}),ie.jsxRuntimeExports.jsx("div",{children:ie.jsxRuntimeExports.jsx("button",{disabled:s||B.isEmpty(n)||n.length<3,onClick:i,type:"button",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Authenticating...":"Authenticate"})})]})})]})})})},UK=e=>{const{data:t,isLoading:r}=KK(),n=ir();return g.useEffect(()=>{n.setQueryData(["apiBaseUrl"],e.apiBaseUrl||"/api/chaibuilder")},[e.apiBaseUrl,n]),r?ie.jsxRuntimeExports.jsx(Zu,{}):t!=null&&t.valid?ie.jsxRuntimeExports.jsx(VK,{...e}):ie.jsxRuntimeExports.jsx(WK,{logo:e.logo})},ZK=new cK,JK=e=>ie.jsxRuntimeExports.jsxs(hK,{client:ZK,children:[ie.jsxRuntimeExports.jsx(ar.Toaster,{richColors:!0}),ie.jsxRuntimeExports.jsx(UK,{...e})]});exports.ChaiBuilderEditor=uA;exports.ChaiBuilderStudio=JK;exports.ErrorBoundary=eS;exports.activePanelAtom=CS;exports.addBlockOffCanvasAtom=IS;exports.addBlocksModalAtom=oS;exports.advanceStylingOpenAtom=SS;exports.canDeleteBlock=dB;exports.canDropBlock=hB;exports.canDuplicateBlock=fB;exports.canvasIframeAtom=OS;exports.editLayerNameAtom=ES;exports.getBlockJSONFromSchemas=xu;exports.getBlockJSONFromUISchemas=Pu;exports.inlineEditingActiveAtom=wS;exports.networkModeAtom=AS;exports.pageSyncStateAtom=Lo;exports.reactIsExports=dg;exports.showPredefinedBlockCategoryAtom=kS;exports.useActiveLanguage=KS;exports.useActiveModal=cV;exports.useActivePanel=pV;exports.useAddBlock=SB;exports.useAddBlockParent=hV;exports.useAddClassesToBlocks=IB;exports.useAddPage=PK;exports.useAllBlocks=fS;exports.useBlockContentByLanguage=kV;exports.useBrandingOptions=ad;exports.useBuilderReset=dd;exports.useBuildingBlocks=pS;exports.useCanvasHistory=Ko;exports.useCanvasWidth=BB;exports.useCanvasZoom=LB;exports.useChangePage=EA;exports.useCopyBlockIds=TS;exports.useCurrentPage=Na;exports.useCurrentPage$1=hS;exports.useCutBlockIds=cd;exports.useDarkMode=KB;exports.useDeletePage=RK;exports.useDeveloperPreviewMode=UB;exports.useDuplicateBlocks=fd;exports.useExpandedIds=NV;exports.useFeatureSupport=yV;exports.useGetPageData=id;exports.useHiddenBlockIds=JB;exports.useHighlightBlockId=zS;exports.useLanguages=IV;exports.useMarkAsGlobalBlock=YB;exports.useMoveBlocks=HB;exports.usePageDataProviders=PS;exports.usePages=Sd;exports.usePasteBlocks=FS;exports.usePreviewMode=nd;exports.usePrimaryLanguage=CV;exports.useProject=ac;exports.useProject$1=_B;exports.useQueryClient=ir;exports.useReadOnlyMode=uV;exports.useRemoveBlocks=DS;exports.useRemoveClassesFromBlocks=eV;exports.useSavePage=DB;exports.useSelectedBlock=vB;exports.useSelectedBlockAllClasses=tV;exports.useSelectedBlockCurrentClasses=aV;exports.useSelectedBlockIds=Wr;exports.useSelectedBlocksDisplayChild=gB;exports.useSelectedBreakpoints=mV;exports.useSelectedStylingBlocks=rd;exports.useSetAllBlocks=sS;exports.useStylingBreakpoint=xS;exports.useStylingState=oV;exports.useTranslations=vV;exports.useTreeData=uB;exports.useUILibraryBlocks=SV;exports.useUpdateBlocksProps=sV;exports.useUpdateBlocksPropsRealtime=iV;exports.useUpdatePage=OA;exports.useUpdateProject=AA;
|