@chaibuilder/sdk 1.1.13 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/AddBlocks-AG_J7s2Z.cjs +1 -0
  2. package/dist/{AddBlocks-A7WofxHV.js → AddBlocks-FsdsASNp.js} +51 -51
  3. package/dist/{BrandingOptions-wkFrLFI_.js → BrandingOptions-4qzTYdj5.js} +6 -5
  4. package/dist/BrandingOptions-xBuqDpj0.cjs +1 -0
  5. package/dist/{CanvasArea-kF46NWZK.cjs → CanvasArea-4m1-c1yq.cjs} +7 -7
  6. package/dist/{CanvasArea-chEYQhH8.js → CanvasArea-U3egqewu.js} +7 -7
  7. package/dist/{CurrentPage-Wd7F9Egg.js → CurrentPage-spjJpQSM.js} +10 -10
  8. package/dist/CurrentPage-zxrdTVsG.cjs +1 -0
  9. package/dist/{Layers-qMOMP2Mi.js → Layers-QNAlCI4j.js} +81 -81
  10. package/dist/Layers-YyBChBtg.cjs +1 -0
  11. package/dist/MarkAsGlobalBlock-LXDkmFUr.cjs +1 -0
  12. package/dist/{MarkAsGlobalBlock-Czq45Amf.js → MarkAsGlobalBlock-xOHhiMDl.js} +3 -3
  13. package/dist/{PagesPanel-ay4uk4mg.js → PagesPanel--LI-BoSj.js} +6 -6
  14. package/dist/PagesPanel-BeJrveus.cjs +1 -0
  15. package/dist/ProjectPanel-MjcAymKT.cjs +1 -0
  16. package/dist/{ProjectPanel-eLlbfAtj.js → ProjectPanel-VNj0jXca.js} +10 -10
  17. package/dist/Settings-BrYkhn3H.cjs +1 -0
  18. package/dist/{Settings-lpoxaMDu.js → Settings-LZJwbkO6.js} +433 -432
  19. package/dist/{SidePanels-iRXV69vh.js → SidePanels-4lvmnnlw.js} +36 -36
  20. package/dist/SidePanels-_5oUp-eI.cjs +1 -0
  21. package/dist/{Topbar-dQYhW4iv.js → Topbar-_-1HX-EE.js} +3 -3
  22. package/dist/Topbar-gQxbcPtG.cjs +1 -0
  23. package/dist/UnsplashImages-PNp5fYCc.cjs +1 -0
  24. package/dist/{UnsplashImages-AL1ASAoD.js → UnsplashImages-mqK09h8E.js} +6 -6
  25. package/dist/UploadImages-BoSSsLtD.cjs +1 -0
  26. package/dist/{UploadImages-09wuhk2O.js → UploadImages-IDkkRuhx.js} +3 -3
  27. package/dist/{add-page-modal-TXREEFPZ.js → add-page-modal-fZnKopNf.js} +14 -13
  28. package/dist/add-page-modal-rWhPuGd9.cjs +1 -0
  29. package/dist/confirm-alert-dHRDZrA1.cjs +1 -0
  30. package/dist/{confirm-alert-GkfW9chS.js → confirm-alert-ea5xpncD.js} +3 -3
  31. package/dist/core.cjs +1 -1
  32. package/dist/core.d.ts +5 -15
  33. package/dist/core.js +5 -5
  34. package/dist/delete-page-modal-P_KKu12n.cjs +1 -0
  35. package/dist/{delete-page-modal-LNME2FwD.js → delete-page-modal-fRoXPfhG.js} +5 -5
  36. package/dist/form-6qGAOYI3.cjs +1 -0
  37. package/dist/{form-Fk4CaX1A.js → form-irY39wvJ.js} +29 -29
  38. package/dist/functions-86L6n983.js +23 -0
  39. package/dist/functions-Jr7gX_RX.cjs +1 -0
  40. package/dist/{html-to-json-kGgp07Hv.js → html-to-json-Y5M0N8PH.js} +33 -33
  41. package/dist/html-to-json-aAZkA0f5.cjs +1 -0
  42. package/dist/{index-89A3jPHh.js → index-0OqmBgqo.js} +3 -3
  43. package/dist/{index-61c5wSJn.cjs → index-1Dr-VtaT.cjs} +2 -2
  44. package/dist/{index-Q5q5Y_8a.js → index-CQz6j3ex.js} +6 -6
  45. package/dist/index-d55M5MRz.cjs +1 -0
  46. package/dist/lib.cjs +1 -1
  47. package/dist/lib.js +27 -27
  48. package/dist/lodash-2us0VT8I.cjs +36 -0
  49. package/dist/lodash-3gkdNK5u.js +4538 -0
  50. package/dist/{page-viewer-LPx-OTCC.js → page-viewer-39ZtxLzx.js} +6 -6
  51. package/dist/page-viewer-_lc8vqU4.cjs +1 -0
  52. package/dist/{project-general-setting-sSpFUD_Y.js → project-general-setting-CCVuGyHh.js} +9 -8
  53. package/dist/project-general-setting-LEzDhwoq.cjs +1 -0
  54. package/dist/{project-seo-setting-CGVegBtM.js → project-seo-setting-Wo7E46w7.js} +6 -5
  55. package/dist/project-seo-setting-orwH-Ufg.cjs +1 -0
  56. package/dist/render.cjs +1 -1
  57. package/dist/render.js +46 -46
  58. package/dist/server.cjs +1 -1
  59. package/dist/server.js +11 -11
  60. package/dist/single-page-detail-jkDYF7lW.cjs +1 -0
  61. package/dist/{single-page-detail-32H1_IG4.js → single-page-detail-r1GJF00l.js} +29 -28
  62. package/dist/studio.cjs +1 -1
  63. package/dist/studio.js +5 -5
  64. package/dist/ui.cjs +1 -1
  65. package/dist/ui.js +3 -3
  66. package/dist/useAddBlockByDrop-5QW86HjG.js +20 -0
  67. package/dist/useAddBlockByDrop-Ckzuvu-s.cjs +1 -0
  68. package/dist/utils-37UXq2O5.cjs +1 -0
  69. package/dist/{utils-zWMk4dB2.js → utils-XsPKXMVo.js} +5 -5
  70. package/package.json +2 -2
  71. package/dist/AddBlocks-Yuc4t0Z_.cjs +0 -1
  72. package/dist/BrandingOptions-KkPF1OGn.cjs +0 -1
  73. package/dist/CurrentPage-p9MaXTOB.cjs +0 -1
  74. package/dist/Layers-wQ0Fv9Xc.cjs +0 -1
  75. package/dist/MarkAsGlobalBlock-sb3hMXLq.cjs +0 -1
  76. package/dist/PagesPanel--maZxwX5.cjs +0 -1
  77. package/dist/ProjectPanel-KhIpO7m3.cjs +0 -1
  78. package/dist/Settings-n2DpS5Ta.cjs +0 -1
  79. package/dist/SidePanels-Dud5Xh9L.cjs +0 -1
  80. package/dist/Topbar-vqzjB75a.cjs +0 -1
  81. package/dist/UnsplashImages-3Sh4UZ-7.cjs +0 -1
  82. package/dist/UploadImages-mPzLhMiH.cjs +0 -1
  83. package/dist/add-page-modal-FPnIWwqA.cjs +0 -1
  84. package/dist/confirm-alert-YNyc3WEo.cjs +0 -1
  85. package/dist/delete-page-modal-sTbqZPvk.cjs +0 -1
  86. package/dist/form-OhgCJlVA.cjs +0 -1
  87. package/dist/functions-ZWGlwlQY.cjs +0 -1
  88. package/dist/functions-slns6ONz.js +0 -23
  89. package/dist/html-to-json-po8on2ju.cjs +0 -1
  90. package/dist/index-GNmGzavZ.cjs +0 -1
  91. package/dist/page-viewer-wQO9oV9h.cjs +0 -1
  92. package/dist/project-general-setting-8EwuN5lN.cjs +0 -1
  93. package/dist/project-seo-setting-R77SKM1I.cjs +0 -1
  94. package/dist/single-page-detail-nyBEHLtT.cjs +0 -1
  95. package/dist/useAddBlockByDrop-4VH-SMj7.cjs +0 -1
  96. package/dist/useAddBlockByDrop-_kyR0iI4.js +0 -20
  97. package/dist/utils-tx6hqsHY.cjs +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var lo=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)};var B=(t,e,a)=>(lo(t,e,"read from private field"),a?a.call(t):e.get(t)),z1=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},u1=(t,e,a,r)=>(lo(t,e,"write to private field"),r?r.call(t,a):e.set(t,a),a);var Cr=(t,e,a,r)=>({set _(n){u1(t,e,n,a)},get _(){return B(t,e,r)}}),C1=(t,e,a)=>(lo(t,e,"access private method"),a);const RO=require("i18next"),kO=require("react-i18next"),r1=require("./jsx-runtime-WUGKV8jN.cjs"),d=require("react"),o1=require("./index-GNmGzavZ.cjs"),T2=require("./MODIFIERS-WFzDQfiT.cjs"),Hf=require("clsx"),Vf=require("react-dom"),NO=require("@radix-ui/react-scroll-area"),pt=require("@floating-ui/react-dom"),TO=require("react-textarea-autosize"),be=require("jotai"),jO=require("flagged"),DO=require("react-dnd"),rt=require("lodash"),jh=require("@minoru/react-dnd-treeview"),FO=require("./utils-tx6hqsHY.cjs"),ne=require("react-hotkeys-hook"),wf=require("@chaibuilder/runtime"),P4=require("@radix-ui/react-icons"),F2=require("sonner"),qO=require("./html-to-json-po8on2ju.cjs"),o3=require("lucide-react");function bf(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return e.default=t,Object.freeze(e)}const O=bf(d),Ie=bf(NO),WO="Dark mode",KO="This page has no blocks. Add a block by clicking the + button",UO="This page is empty",ZO="Please select a block to edit settings or styles",GO="Please select a styling block",JO="Drop your block here",YO={dark_mode:WO,tree_view_no_blocks:KO,canvas_empty:UO,no_block_selected_for_styling:ZO,no_styling_block_selected:GO,drop_here_message:JO};RO.use(kO.initReactI18next).init({resources:{en:{translation:YO}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const QO="";var XO=Object.create,yf=Object.defineProperty,_O=Object.getOwnPropertyDescriptor,c3=Object.getOwnPropertyNames,$O=Object.getPrototypeOf,tS=Object.prototype.hasOwnProperty,eS=(t,e)=>function(){return t&&(e=(0,t[c3(t)[0]])(t=0)),e},g1=(t,e)=>function(){return e||(0,t[c3(t)[0]])((e={exports:{}}).exports,e),e.exports},aS=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c3(e))!tS.call(t,n)&&n!==a&&yf(t,n,{get:()=>e[n],enumerable:!(r=_O(e,n))||r.enumerable});return t},na=(t,e,a)=>(a=t!=null?XO($O(t)):{},aS(e||!t||!t.__esModule?yf(a,"default",{value:t,enumerable:!0}):a,t)),j=eS({"react-shim.js"(){"use strict"}});j();j();var rS=(t,e)=>t.size===e.size&&Array.from(t).every(([a,r])=>Object.is(e.get(a),r)),nS=(t,e)=>t.size===e.size&&Array.from(t).every(([a,r])=>{const n=e.get(a);return n&&r.size===n.size&&Array.from(r).every(l=>n.has(l))});function lS({shouldShowPrivateAtoms:t=!1,...e}={}){const a=o1.useStore(e),[r,n]=d.useState(()=>({values:new Map,dependents:new Map})),l=d.useRef(!0);return l.current=!0,d.useLayoutEffect(()=>{l.current=!1}),d.useEffect(()=>{const i=(a==null?void 0:a.dev_subscribe_store)||(a==null?void 0:a.dev_subscribe_state);if(!i)return;let o=new Map,c=new Map;"dev_subscribe_store"in a||console.warn("[DEPRECATION-WARNING]: Your Jotai version is out-of-date and contains deprecated properties that will be removed soon. Please update to the latest version of Jotai.");const v=s=>{var f,z,M;typeof s!="object"&&console.warn("[DEPRECATION-WARNING]: Your Jotai version is out-of-date and contains deprecated properties that will be removed soon. Please update to the latest version of Jotai.");const u=new Map,g=new Map;for(const m of((f=a.dev_get_mounted_atoms)==null?void 0:f.call(a))||[]){if(!t&&m.debugPrivate)continue;const V=(z=a.dev_get_atom_state)==null?void 0:z.call(a,m);V&&"v"in V&&u.set(m,V.v);const b=(M=a.dev_get_mounted)==null?void 0:M.call(a,m);if(b){let w=b.t;t||(w=new Set(Array.from(w.values()).filter(y=>!y.debugPrivate))),g.set(m,w)}}if(rS(o,u)&&nS(c,g))return;o=u,c=g;const p=()=>n({values:u,dependents:g});l.current?Promise.resolve().then(p):p()},h=i==null?void 0:i(v,2);return v({}),h},[a,t]),r}j();function xf(t){const e=o1.useStore(t);return d.useCallback(a=>{e.dev_restore_atoms&&e.dev_restore_atoms(a.values)},[e])}j();j();j();j();j();function iS(t){if(t.sheet)return t.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===t)return document.styleSheets[e]}function oS(t){var e=document.createElement("style");return e.setAttribute("data-emotion",t.key),t.nonce!==void 0&&e.setAttribute("nonce",t.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var cS=function(){function t(a){var r=this;this._insertTag=function(n){var l;r.tags.length===0?r.insertionPoint?l=r.insertionPoint.nextSibling:r.prepend?l=r.container.firstChild:l=r.before:l=r.tags[r.tags.length-1].nextSibling,r.container.insertBefore(n,l),r.tags.push(n)},this.isSpeedy=a.speedy===void 0?process.env.NODE_ENV==="production":a.speedy,this.tags=[],this.ctr=0,this.nonce=a.nonce,this.key=a.key,this.container=a.container,this.prepend=a.prepend,this.insertionPoint=a.insertionPoint,this.before=null}var e=t.prototype;return e.hydrate=function(r){r.forEach(this._insertTag)},e.insert=function(r){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(oS(this));var n=this.tags[this.tags.length-1];if(process.env.NODE_ENV!=="production"){var l=r.charCodeAt(0)===64&&r.charCodeAt(1)===105;l&&this._alreadyInsertedOrderInsensitiveRule&&console.error(`You're attempting to insert the following rule:
1
+ "use strict";var lo=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)};var B=(t,e,a)=>(lo(t,e,"read from private field"),a?a.call(t):e.get(t)),z1=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},u1=(t,e,a,r)=>(lo(t,e,"write to private field"),r?r.call(t,a):e.set(t,a),a);var Cr=(t,e,a,r)=>({set _(n){u1(t,e,n,a)},get _(){return B(t,e,r)}}),C1=(t,e,a)=>(lo(t,e,"access private method"),a);const RO=require("i18next"),kO=require("react-i18next"),r1=require("./jsx-runtime-WUGKV8jN.cjs"),d=require("react"),o1=require("./index-d55M5MRz.cjs"),T2=require("./MODIFIERS-WFzDQfiT.cjs"),Hf=require("clsx"),Vf=require("react-dom"),NO=require("@radix-ui/react-scroll-area"),pt=require("@floating-ui/react-dom"),TO=require("react-textarea-autosize"),be=require("jotai"),jO=require("flagged"),DO=require("react-dnd"),rt=require("./lodash-2us0VT8I.cjs"),jh=require("@minoru/react-dnd-treeview"),FO=require("./utils-37UXq2O5.cjs"),ne=require("react-hotkeys-hook"),wf=require("@chaibuilder/runtime"),P4=require("@radix-ui/react-icons"),F2=require("sonner"),qO=require("./html-to-json-aAZkA0f5.cjs"),o3=require("lucide-react");function bf(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return e.default=t,Object.freeze(e)}const O=bf(d),Ie=bf(NO),WO="Dark mode",KO="This page has no blocks. Add a block by clicking the + button",UO="This page is empty",ZO="Please select a block to edit settings or styles",GO="Please select a styling block",JO="Drop your block here",YO={dark_mode:WO,tree_view_no_blocks:KO,canvas_empty:UO,no_block_selected_for_styling:ZO,no_styling_block_selected:GO,drop_here_message:JO};RO.use(kO.initReactI18next).init({resources:{en:{translation:YO}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const QO="";var XO=Object.create,yf=Object.defineProperty,_O=Object.getOwnPropertyDescriptor,c3=Object.getOwnPropertyNames,$O=Object.getPrototypeOf,tS=Object.prototype.hasOwnProperty,eS=(t,e)=>function(){return t&&(e=(0,t[c3(t)[0]])(t=0)),e},g1=(t,e)=>function(){return e||(0,t[c3(t)[0]])((e={exports:{}}).exports,e),e.exports},aS=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c3(e))!tS.call(t,n)&&n!==a&&yf(t,n,{get:()=>e[n],enumerable:!(r=_O(e,n))||r.enumerable});return t},na=(t,e,a)=>(a=t!=null?XO($O(t)):{},aS(e||!t||!t.__esModule?yf(a,"default",{value:t,enumerable:!0}):a,t)),j=eS({"react-shim.js"(){"use strict"}});j();j();var rS=(t,e)=>t.size===e.size&&Array.from(t).every(([a,r])=>Object.is(e.get(a),r)),nS=(t,e)=>t.size===e.size&&Array.from(t).every(([a,r])=>{const n=e.get(a);return n&&r.size===n.size&&Array.from(r).every(l=>n.has(l))});function lS({shouldShowPrivateAtoms:t=!1,...e}={}){const a=o1.useStore(e),[r,n]=d.useState(()=>({values:new Map,dependents:new Map})),l=d.useRef(!0);return l.current=!0,d.useLayoutEffect(()=>{l.current=!1}),d.useEffect(()=>{const i=(a==null?void 0:a.dev_subscribe_store)||(a==null?void 0:a.dev_subscribe_state);if(!i)return;let o=new Map,c=new Map;"dev_subscribe_store"in a||console.warn("[DEPRECATION-WARNING]: Your Jotai version is out-of-date and contains deprecated properties that will be removed soon. Please update to the latest version of Jotai.");const v=s=>{var f,z,M;typeof s!="object"&&console.warn("[DEPRECATION-WARNING]: Your Jotai version is out-of-date and contains deprecated properties that will be removed soon. Please update to the latest version of Jotai.");const u=new Map,g=new Map;for(const m of((f=a.dev_get_mounted_atoms)==null?void 0:f.call(a))||[]){if(!t&&m.debugPrivate)continue;const V=(z=a.dev_get_atom_state)==null?void 0:z.call(a,m);V&&"v"in V&&u.set(m,V.v);const b=(M=a.dev_get_mounted)==null?void 0:M.call(a,m);if(b){let w=b.t;t||(w=new Set(Array.from(w.values()).filter(y=>!y.debugPrivate))),g.set(m,w)}}if(rS(o,u)&&nS(c,g))return;o=u,c=g;const p=()=>n({values:u,dependents:g});l.current?Promise.resolve().then(p):p()},h=i==null?void 0:i(v,2);return v({}),h},[a,t]),r}j();function xf(t){const e=o1.useStore(t);return d.useCallback(a=>{e.dev_restore_atoms&&e.dev_restore_atoms(a.values)},[e])}j();j();j();j();j();function iS(t){if(t.sheet)return t.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===t)return document.styleSheets[e]}function oS(t){var e=document.createElement("style");return e.setAttribute("data-emotion",t.key),t.nonce!==void 0&&e.setAttribute("nonce",t.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var cS=function(){function t(a){var r=this;this._insertTag=function(n){var l;r.tags.length===0?r.insertionPoint?l=r.insertionPoint.nextSibling:r.prepend?l=r.container.firstChild:l=r.before:l=r.tags[r.tags.length-1].nextSibling,r.container.insertBefore(n,l),r.tags.push(n)},this.isSpeedy=a.speedy===void 0?process.env.NODE_ENV==="production":a.speedy,this.tags=[],this.ctr=0,this.nonce=a.nonce,this.key=a.key,this.container=a.container,this.prepend=a.prepend,this.insertionPoint=a.insertionPoint,this.before=null}var e=t.prototype;return e.hydrate=function(r){r.forEach(this._insertTag)},e.insert=function(r){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(oS(this));var n=this.tags[this.tags.length-1];if(process.env.NODE_ENV!=="production"){var l=r.charCodeAt(0)===64&&r.charCodeAt(1)===105;l&&this._alreadyInsertedOrderInsensitiveRule&&console.error(`You're attempting to insert the following rule:
2
2
  `+r+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!l}if(this.isSpeedy){var i=iS(n);try{i.insertRule(r,i.cssRules.length)}catch(o){process.env.NODE_ENV!=="production"&&!/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(r)&&console.error('There was a problem inserting the following rule: "'+r+'"',o)}}else n.appendChild(document.createTextNode(r));this.ctr++},e.flush=function(){this.tags.forEach(function(r){return r.parentNode&&r.parentNode.removeChild(r)}),this.tags=[],this.ctr=0,process.env.NODE_ENV!=="production"&&(this._alreadyInsertedOrderInsensitiveRule=!1)},t}(),Pt="-ms-",I4="-moz-",j1="-webkit-",h3="comm",s3="rule",v3="decl";var hS="@import";var Lf="@keyframes";var sS="@layer",vS=Math.abs,mi=String.fromCharCode,dS=Object.assign;function uS(t,e){return Lt(t,0)^45?(((e<<2^Lt(t,0))<<2^Lt(t,1))<<2^Lt(t,2))<<2^Lt(t,3):0}function Of(t){return t.trim()}function gS(t,e){return(t=e.exec(t))?t[0]:t}function D1(t,e,a){return t.replace(e,a)}function uc(t,e){return t.indexOf(e)}function Lt(t,e){return t.charCodeAt(e)|0}function F0(t,e,a){return t.slice(e,a)}function R2(t){return t.length}function d3(t){return t.length}function Br(t,e){return e.push(t),t}function fS(t,e){return t.map(e).join("")}var Hi=1,Qa=1,Sf=0,Jt=0,ht=0,n0="";function Vi(t,e,a,r,n,l,i){return{value:t,root:e,parent:a,type:r,props:n,children:l,line:Hi,column:Qa,length:i,return:""}}function u0(t,e){return dS(Vi("",null,null,"",null,null,0),t,{length:-t.length},e)}function pS(){return ht}function zS(){return ht=Jt>0?Lt(n0,--Jt):0,Qa--,ht===10&&(Qa=1,Hi--),ht}function r2(){return ht=Jt<Sf?Lt(n0,Jt++):0,Qa++,ht===10&&(Qa=1,Hi++),ht}function q2(){return Lt(n0,Jt)}function f4(){return Jt}function vr(t,e){return F0(n0,t,e)}function q0(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Cf(t){return Hi=Qa=1,Sf=R2(n0=t),Jt=0,[]}function Bf(t){return n0="",t}function p4(t){return Of(vr(Jt-1,gc(t===91?t+2:t===40?t+1:t)))}function MS(t){for(;(ht=q2())&&ht<33;)r2();return q0(t)>2||q0(ht)>3?"":" "}function mS(t,e){for(;--e&&r2()&&!(ht<48||ht>102||ht>57&&ht<65||ht>70&&ht<97););return vr(t,f4()+(e<6&&q2()==32&&r2()==32))}function gc(t){for(;r2();)switch(ht){case t:return Jt;case 34:case 39:t!==34&&t!==39&&gc(ht);break;case 40:t===41&&gc(t);break;case 92:r2();break}return Jt}function HS(t,e){for(;r2()&&t+ht!==57;)if(t+ht===84&&q2()===47)break;return"/*"+vr(e,Jt-1)+"*"+mi(t===47?t:r2())}function VS(t){for(;!q0(q2());)r2();return vr(t,Jt)}function wS(t){return Bf(z4("",null,null,null,[""],t=Cf(t),0,[0],t))}function z4(t,e,a,r,n,l,i,o,c){for(var v=0,h=0,s=i,u=0,g=0,p=0,f=1,z=1,M=1,m=0,V="",b=n,w=l,y=r,x=V;z;)switch(p=m,m=r2()){case 40:if(p!=108&&Lt(x,s-1)==58){uc(x+=D1(p4(m),"&","&\f"),"&\f")!=-1&&(M=-1);break}case 34:case 39:case 91:x+=p4(m);break;case 9:case 10:case 13:case 32:x+=MS(p);break;case 92:x+=mS(f4()-1,7);continue;case 47:switch(q2()){case 42:case 47:Br(bS(HS(r2(),f4()),e,a),c);break;default:x+="/"}break;case 123*f:o[v++]=R2(x)*M;case 125*f:case 59:case 0:switch(m){case 0:case 125:z=0;case 59+h:M==-1&&(x=D1(x,/\f/g,"")),g>0&&R2(x)-s&&Br(g>32?Fh(x+";",r,a,s-1):Fh(D1(x," ","")+";",r,a,s-2),c);break;case 59:x+=";";default:if(Br(y=Dh(x,e,a,v,h,n,o,V,b=[],w=[],s),l),m===123)if(h===0)z4(x,e,y,y,b,l,s,o,w);else switch(u===99&&Lt(x,3)===110?100:u){case 100:case 108:case 109:case 115:z4(t,y,y,r&&Br(Dh(t,y,y,0,0,n,o,V,n,b=[],s),w),n,w,s,o,r?b:w);break;default:z4(x,y,y,y,[""],w,0,o,w)}}v=h=g=0,f=M=1,V=x="",s=i;break;case 58:s=1+R2(x),g=p;default:if(f<1){if(m==123)--f;else if(m==125&&f++==0&&zS()==125)continue}switch(x+=mi(m),m*f){case 38:M=h>0?1:(x+="\f",-1);break;case 44:o[v++]=(R2(x)-1)*M,M=1;break;case 64:q2()===45&&(x+=p4(r2())),u=q2(),h=s=R2(V=x+=VS(f4())),m++;break;case 45:p===45&&R2(x)==2&&(f=0)}}return l}function Dh(t,e,a,r,n,l,i,o,c,v,h){for(var s=n-1,u=n===0?l:[""],g=d3(u),p=0,f=0,z=0;p<r;++p)for(var M=0,m=F0(t,s+1,s=vS(f=i[p])),V=t;M<g;++M)(V=Of(f>0?u[M]+" "+m:D1(m,/&\f/g,u[M])))&&(c[z++]=V);return Vi(t,e,a,n===0?s3:o,c,v,h)}function bS(t,e,a){return Vi(t,e,a,h3,mi(pS()),F0(t,2,-2),0)}function Fh(t,e,a,r){return Vi(t,e,a,v3,F0(t,0,r),F0(t,r+1,-1),r)}function Aa(t,e){for(var a="",r=d3(t),n=0;n<r;n++)a+=e(t[n],n,t,e)||"";return a}function yS(t,e,a,r){switch(t.type){case sS:if(t.children.length)break;case hS:case v3:return t.return=t.return||t.value;case h3:return"";case Lf:return t.return=t.value+"{"+Aa(t.children,r)+"}";case s3:t.value=t.props.join(",")}return R2(a=Aa(t.children,r))?t.return=t.value+"{"+a+"}":""}function xS(t){var e=d3(t);return function(a,r,n,l){for(var i="",o=0;o<e;o++)i+=t[o](a,r,n,l)||"";return i}}function LS(t){return function(e){e.root||(e=e.return)&&t(e)}}var qh=function(e){var a=new WeakMap;return function(r){if(a.has(r))return a.get(r);var n=e(r);return a.set(r,n),n}};function OS(t){var e=Object.create(null);return function(a){return e[a]===void 0&&(e[a]=t(a)),e[a]}}var SS=function(e,a,r){for(var n=0,l=0;n=l,l=q2(),n===38&&l===12&&(a[r]=1),!q0(l);)r2();return vr(e,Jt)},CS=function(e,a){var r=-1,n=44;do switch(q0(n)){case 0:n===38&&q2()===12&&(a[r]=1),e[r]+=SS(Jt-1,a,r);break;case 2:e[r]+=p4(n);break;case 4:if(n===44){e[++r]=q2()===58?"&\f":"",a[r]=e[r].length;break}default:e[r]+=mi(n)}while(n=r2());return e},BS=function(e,a){return Bf(CS(Cf(e),a))},Wh=new WeakMap,AS=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var a=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;r.type!=="rule";)if(r=r.parent,!r)return;if(!(e.props.length===1&&a.charCodeAt(0)!==58&&!Wh.get(r))&&!n){Wh.set(e,!0);for(var l=[],i=BS(a,l),o=r.props,c=0,v=0;c<i.length;c++)for(var h=0;h<o.length;h++,v++)e.props[v]=l[c]?i[c].replace(/&\f/g,o[h]):o[h]+" "+i[c]}}},ES=function(e){if(e.type==="decl"){var a=e.value;a.charCodeAt(0)===108&&a.charCodeAt(2)===98&&(e.return="",e.value="")}},PS="emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason",IS=function(e){return e.type==="comm"&&e.children.indexOf(PS)>-1},RS=function(e){return function(a,r,n){if(!(a.type!=="rule"||e.compat)){var l=a.value.match(/(:first|:nth|:nth-last)-child/g);if(l){for(var i=!!a.parent,o=i?a.parent.children:n,c=o.length-1;c>=0;c--){var v=o[c];if(v.line<a.line)break;if(v.column<a.column){if(IS(v))return;break}}l.forEach(function(h){console.error('The pseudo class "'+h+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+h.split("-child")[0]+'-of-type".')})}}}},Af=function(e){return e.type.charCodeAt(1)===105&&e.type.charCodeAt(0)===64},kS=function(e,a){for(var r=e-1;r>=0;r--)if(!Af(a[r]))return!0;return!1},Kh=function(e){e.type="",e.value="",e.return="",e.children="",e.props=""},NS=function(e,a,r){Af(e)&&(e.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),Kh(e)):kS(a,r)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),Kh(e)))};function Ef(t,e){switch(uS(t,e)){case 5103:return j1+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return j1+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return j1+t+I4+t+Pt+t+t;case 6828:case 4268:return j1+t+Pt+t+t;case 6165:return j1+t+Pt+"flex-"+t+t;case 5187:return j1+t+D1(t,/(\w+).+(:[^]+)/,j1+"box-$1$2"+Pt+"flex-$1$2")+t;case 5443:return j1+t+Pt+"flex-item-"+D1(t,/flex-|-self/,"")+t;case 4675:return j1+t+Pt+"flex-line-pack"+D1(t,/align-content|flex-|-self/,"")+t;case 5548:return j1+t+Pt+D1(t,"shrink","negative")+t;case 5292:return j1+t+Pt+D1(t,"basis","preferred-size")+t;case 6060:return j1+"box-"+D1(t,"-grow","")+j1+t+Pt+D1(t,"grow","positive")+t;case 4554:return j1+D1(t,/([^-])(transform)/g,"$1"+j1+"$2")+t;case 6187:return D1(D1(D1(t,/(zoom-|grab)/,j1+"$1"),/(image-set)/,j1+"$1"),t,"")+t;case 5495:case 3959:return D1(t,/(image-set\([^]*)/,j1+"$1$`$1");case 4968:return D1(D1(t,/(.+:)(flex-)?(.*)/,j1+"box-pack:$3"+Pt+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+j1+t+t;case 4095:case 3583:case 4068:case 2532:return D1(t,/(.+)-inline(.+)/,j1+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(R2(t)-1-e>6)switch(Lt(t,e+1)){case 109:if(Lt(t,e+4)!==45)break;case 102:return D1(t,/(.+:)(.+)-([^]+)/,"$1"+j1+"$2-$3$1"+I4+(Lt(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~uc(t,"stretch")?Ef(D1(t,"stretch","fill-available"),e)+t:t}break;case 4949:if(Lt(t,e+1)!==115)break;case 6444:switch(Lt(t,R2(t)-3-(~uc(t,"!important")&&10))){case 107:return D1(t,":",":"+j1)+t;case 101:return D1(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+j1+(Lt(t,14)===45?"inline-":"")+"box$3$1"+j1+"$2$3$1"+Pt+"$2box$3")+t}break;case 5936:switch(Lt(t,e+11)){case 114:return j1+t+Pt+D1(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return j1+t+Pt+D1(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return j1+t+Pt+D1(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return j1+t+Pt+t+t}return t}var TS=function(e,a,r,n){if(e.length>-1&&!e.return)switch(e.type){case v3:e.return=Ef(e.value,e.length);break;case Lf:return Aa([u0(e,{value:D1(e.value,"@","@"+j1)})],n);case s3:if(e.length)return fS(e.props,function(l){switch(gS(l,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Aa([u0(e,{props:[D1(l,/:(read-\w+)/,":"+I4+"$1")]})],n);case"::placeholder":return Aa([u0(e,{props:[D1(l,/:(plac\w+)/,":"+j1+"input-$1")]}),u0(e,{props:[D1(l,/:(plac\w+)/,":"+I4+"$1")]}),u0(e,{props:[D1(l,/:(plac\w+)/,Pt+"input-$1")]})],n)}return""})}},jS=[TS],wi=function(e){var a=e.key;if(process.env.NODE_ENV!=="production"&&!a)throw new Error(`You have to configure \`key\` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.
3
3
  If multiple caches share the same key they might "fight" for each other's style elements.`);if(a==="css"){var r=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(r,function(f){var z=f.getAttribute("data-emotion");z.indexOf(" ")!==-1&&(document.head.appendChild(f),f.setAttribute("data-s",""))})}var n=e.stylisPlugins||jS;if(process.env.NODE_ENV!=="production"&&/[^a-z-]/.test(a))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+a+'" was passed');var l={},i,o=[];i=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+a+' "]'),function(f){for(var z=f.getAttribute("data-emotion").split(" "),M=1;M<z.length;M++)l[z[M]]=!0;o.push(f)});var c,v=[AS,ES];process.env.NODE_ENV!=="production"&&v.push(RS({get compat(){return p.compat}}),NS);{var h,s=[yS,process.env.NODE_ENV!=="production"?function(f){f.root||(f.return?h.insert(f.return):f.value&&f.type!==h3&&h.insert(f.value+"{}"))}:LS(function(f){h.insert(f)})],u=xS(v.concat(n,s)),g=function(z){return Aa(wS(z),u)};c=function(z,M,m,V){h=m,process.env.NODE_ENV!=="production"&&M.map!==void 0&&(h={insert:function(w){m.insert(w+M.map)}}),g(z?z+"{"+M.styles+"}":M.styles),V&&(p.inserted[M.name]=!0)}}var p={key:a,sheet:new cS({key:a,container:i,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:l,registered:{},insert:c};return p.sheet.hydrate(o),p};function fc(){return fc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},fc.apply(this,arguments)}var R4={exports:{}},F1={};/** @license React v16.13.1
4
4
  * react-is.production.min.js
@@ -203,4 +203,4 @@ object-assign/index.js:
203
203
  (c) Sindre Sorhus
204
204
  @license MIT
205
205
  *)
206
- */j();var $c1=process.env.NODE_ENV!=="production"?_c1:()=>null;function t31(){return new URLSearchParams(window.location.search).has("dnd")}const e31={dnd:t31()};class dO extends d.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?r1.jsxRuntimeExports.jsxs("div",{className:"bg-red-200 h-full w-full rounded-md text-red-500 p-4",id:"errorBoundary",children:[r1.jsxRuntimeExports.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),r1.jsxRuntimeExports.jsx("p",{children:"Please try again later."})]}):this.props.children}}const a31=()=>{const[t,e]=o1.usePreviewMode(),a=o1.useBuilderProp("previewComponent");return r1.jsxRuntimeExports.jsxs("div",{className:FO.cn$1("fixed inset-0 z-[999] bg-background",t?"block":"hidden"),children:[r1.jsxRuntimeExports.jsx(o1.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>e(!1),children:"Close Preview"}),r1.jsxRuntimeExports.jsx("div",{children:a?r1.jsxRuntimeExports.jsx(d.Suspense,{fallback:r1.jsxRuntimeExports.jsx(o1.Skeleton,{className:"h-96 w-full"}),children:d.createElement(a)}):null})]})},r31=()=>{const[t,e]=o1.useSelectedBlockIds(),[,a]=o1.useCopyBlockIds(),r=o1.useRemoveBlocks(),n=o1.useDuplicateBlocks(),[,l]=o1.useCutBlockIds(),{pasteBlocks:i}=o1.usePasteBlocks(),{undo:o,redo:c}=o1.useCanvasHistory();ne.useHotkeys("esc",()=>e([]),{},[e]),ne.useHotkeys("ctrl+c,command+c",()=>a(t),{},[t,a]),ne.useHotkeys("ctrl+d,command+d",()=>n(t),{preventDefault:!0},[t,n]),ne.useHotkeys("ctrl+x,command+x",()=>l(t),{},[t,l]),ne.useHotkeys("ctrl+v,command+v",()=>t.length===1?i(t[0]):null,{},[t,i]),ne.useHotkeys("ctrl+z,command+z",()=>o(),{},[o]),ne.useHotkeys("ctrl+y,command+y",()=>c(),{},[c]),ne.useHotkeys("del, backspace",v=>{v.preventDefault(),r(t)},{},[t,r])},n31=(t,e)=>{const a=[];let r=rt.find(t,{_id:e}),n=rt.get(r,"_parent","");for(;rt.isString(n)&&!rt.isEmpty(n);)a.push(r==null?void 0:r._parent),r=rt.find(t,{_id:n}),n=r==null?void 0:r._parent;return rt.flatten(a)},uO=be.atom([]),l31=()=>{const[t]=o1.useSelectedBlockIds(),e=be.useAtomValue(o1.presentBlocksAtom),[,a]=be.useAtom(uO);d.useEffect(()=>{let r=[];const n=rt.first(t);rt.isString(n)&&(r=[n,...n31(e,n)]),a(r)},[t,e,a])},i31=()=>be.useAtomValue(uO),gO=()=>be.useAtom(o1.chaiExternalDataAtom),o31=()=>d.useMemo(()=>wf.getChaiDataProviders(),[]),c31=({children:t})=>{const[,e]=gO(),[a]=o1.usePageDataProviders(),r=o31();return d.useEffect(()=>(e({}),rt.each(a,n=>{const l=rt.find(r,{providerKey:n.providerKey});if(l){const i=(l==null?void 0:l.mockFn)||(l==null?void 0:l.dataFn);i&&i(n.args).then(o=>e(c=>({...c,[n.providerKey]:o})))}}),()=>{rt.each(a,n=>{e(l=>(delete l[n.providerKey],l))})}),[r,a,e]),r1.jsxRuntimeExports.jsx(r1.jsxRuntimeExports.Fragment,{children:t})},h31=d.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-Dud5Xh9L.cjs"))),s31=d.lazy(()=>Promise.resolve().then(()=>require("./Topbar-vqzjB75a.cjs"))),v31=d.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-kF46NWZK.cjs"))),d31=d.lazy(()=>Promise.resolve().then(()=>require("./Settings-n2DpS5Ta.cjs"))),u31=()=>{const[t]=be.useAtom(o1.pageSyncStateAtom),e=n=>{o1.isDevelopment()||n.preventDefault()};r31(),l31(),d.useEffect(()=>(t!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[t]);const a=o1.useBuilderProp("editable",!0),r=o1.useBuilderProp("nonEditableComponent",null);return r1.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:r1.jsxRuntimeExports.jsxs(o1.TooltipProvider,{children:[r1.jsxRuntimeExports.jsxs("div",{onContextMenu:e,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[r1.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(s31,{})})}),r1.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-1 flex-row relative",children:[a?null:r1.jsxRuntimeExports.jsx("div",{className:"absolute backdrop-blur-[2px] flex items-center justify-center inset-0 z-[500] h-full w-full",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:d.createElement(r)})}),r1.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border max-h-full",style:{maxHeight:"calc(100vh - 56px)"},children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(h31,{})})}),r1.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(v31,{})})}),r1.jsxRuntimeExports.jsx("div",{className:"flex h-[90%] w-[280px] pb-10 min-w-[280px] border-l border-border",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(d31,{})})})]})]}),r1.jsxRuntimeExports.jsx(a31,{})]})})},_g=be.getDefaultStore();var g31={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};g31.NODE_ENV==="development"&&console.log("Chai Builder:",QO);const f31=t=>r1.jsxRuntimeExports.jsx(r1.jsxRuntimeExports.Fragment,{children:t.children}),p31=t=>{const{dndOptions:e={backend:jh.MultiBackend}}=t,[a]=o1.useSetAllBlocks(),[,r]=o1.useBrandingOptions(),n=o1.useBuilderReset();return d.useEffect(()=>{_g.set(o1.chaiBuilderPropsAtom,rt.omit(t,["blocks","subPages","brandingOptions","dataProviders"]))},[t]),d.useEffect(()=>{_g.set(o1.dataProvidersAtom,t.dataProviders||[])},[t.dataProviders]),d.useEffect(()=>{a(wf.syncBlocksWithDefaults(t.blocks||[])),n()},[t.blocks]),d.useEffect(()=>{r(t.brandingOptions)},[t.brandingOptions,r]),r1.jsxRuntimeExports.jsx(DO.DndProvider,{...e,options:jh.getBackendOptions(),children:r1.jsxRuntimeExports.jsx(f31,{children:r1.jsxRuntimeExports.jsx(u31,{})})})},fO=t=>r1.jsxRuntimeExports.jsxs(dO,{children:[r1.jsxRuntimeExports.jsxs(jO.FlagsProvider,{features:e31,children:[r1.jsxRuntimeExports.jsx($c1,{}),r1.jsxRuntimeExports.jsx(p31,{...t})]}),r1.jsxRuntimeExports.jsx(o1.Toaster,{})]});var s0=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},r0=typeof window>"u"||"Deno"in window;function g2(){}function z31(t,e){return typeof t=="function"?t(e):t}function Jc(t){return typeof t=="number"&&t>=0&&t!==1/0}function pO(t,e){return Math.max(t+(e||0)-Date.now(),0)}function $g(t,e){const{type:a="all",exact:r,fetchStatus:n,predicate:l,queryKey:i,stale:o}=t;if(i){if(r){if(e.queryHash!==Rh(i,e.options))return!1}else if(!_0(e.queryKey,i))return!1}if(a!=="all"){const c=e.isActive();if(a==="active"&&!c||a==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||typeof n<"u"&&n!==e.state.fetchStatus||l&&!l(e))}function tf(t,e){const{exact:a,status:r,predicate:n,mutationKey:l}=t;if(l){if(!e.options.mutationKey)return!1;if(a){if(X0(e.options.mutationKey)!==X0(l))return!1}else if(!_0(e.options.mutationKey,l))return!1}return!(r&&e.state.status!==r||n&&!n(e))}function Rh(t,e){return((e==null?void 0:e.queryKeyHashFn)||X0)(t)}function X0(t){return JSON.stringify(t,(e,a)=>Yc(a)?Object.keys(a).sort().reduce((r,n)=>(r[n]=a[n],r),{}):a)}function _0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(a=>!_0(t[a],e[a])):!1}function zO(t,e){if(t===e)return t;const a=ef(t)&&ef(e);if(a||Yc(t)&&Yc(e)){const r=a?t.length:Object.keys(t).length,n=a?e:Object.keys(e),l=n.length,i=a?[]:{};let o=0;for(let c=0;c<l;c++){const v=a?c:n[c];i[v]=zO(t[v],e[v]),i[v]===t[v]&&o++}return r===l&&o===r?t:i}return e}function fi(t,e){if(t&&!e||e&&!t)return!1;for(const a in t)if(t[a]!==e[a])return!1;return!0}function ef(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Yc(t){if(!af(t))return!1;const e=t.constructor;if(typeof e>"u")return!0;const a=e.prototype;return!(!af(a)||!a.hasOwnProperty("isPrototypeOf"))}function af(t){return Object.prototype.toString.call(t)==="[object Object]"}function MO(t){return new Promise(e=>{setTimeout(e,t)})}function rf(t){MO(0).then(t)}function Qc(t,e,a){return typeof a.structuralSharing=="function"?a.structuralSharing(t,e):a.structuralSharing!==!1?zO(t,e):e}function M31(t,e,a=0){const r=[...t,e];return a&&r.length>a?r.slice(1):r}function m31(t,e,a=0){const r=[e,...t];return a&&r.length>a?r.slice(0,-1):r}var qe,se,Ia,sf,H31=(sf=class extends s0{constructor(){super();z1(this,qe,void 0);z1(this,se,void 0);z1(this,Ia,void 0);u1(this,Ia,e=>{if(!r0&&window.addEventListener){const a=()=>e();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}})}onSubscribe(){B(this,se)||this.setEventListener(B(this,Ia))}onUnsubscribe(){var e;this.hasListeners()||((e=B(this,se))==null||e.call(this),u1(this,se,void 0))}setEventListener(e){var a;u1(this,Ia,e),(a=B(this,se))==null||a.call(this),u1(this,se,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){B(this,qe)!==e&&(u1(this,qe,e),this.onFocus())}onFocus(){this.listeners.forEach(e=>{e()})}isFocused(){var e;return typeof B(this,qe)=="boolean"?B(this,qe):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},qe=new WeakMap,se=new WeakMap,Ia=new WeakMap,sf),pi=new H31,Ra,ve,ka,vf,V31=(vf=class extends s0{constructor(){super();z1(this,Ra,!0);z1(this,ve,void 0);z1(this,ka,void 0);u1(this,ka,e=>{if(!r0&&window.addEventListener){const a=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",r)}}})}onSubscribe(){B(this,ve)||this.setEventListener(B(this,ka))}onUnsubscribe(){var e;this.hasListeners()||((e=B(this,ve))==null||e.call(this),u1(this,ve,void 0))}setEventListener(e){var a;u1(this,ka,e),(a=B(this,ve))==null||a.call(this),u1(this,ve,e(this.setOnline.bind(this)))}setOnline(e){B(this,Ra)!==e&&(u1(this,Ra,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return B(this,Ra)}},Ra=new WeakMap,ve=new WeakMap,ka=new WeakMap,vf),zi=new V31;function w31(t){return Math.min(1e3*2**t,3e4)}function ao(t){return(t??"online")==="online"?zi.isOnline():!0}var mO=class{constructor(t){this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function dc(t){return t instanceof mO}function HO(t){let e=!1,a=0,r=!1,n,l,i;const o=new Promise((z,M)=>{l=z,i=M}),c=z=>{var M;r||(g(new mO(z)),(M=t.abort)==null||M.call(t))},v=()=>{e=!0},h=()=>{e=!1},s=()=>!pi.isFocused()||t.networkMode!=="always"&&!zi.isOnline(),u=z=>{var M;r||(r=!0,(M=t.onSuccess)==null||M.call(t,z),n==null||n(),l(z))},g=z=>{var M;r||(r=!0,(M=t.onError)==null||M.call(t,z),n==null||n(),i(z))},p=()=>new Promise(z=>{var M;n=m=>{const V=r||!s();return V&&z(m),V},(M=t.onPause)==null||M.call(t)}).then(()=>{var z;n=void 0,r||(z=t.onContinue)==null||z.call(t)}),f=()=>{if(r)return;let z;try{z=t.fn()}catch(M){z=Promise.reject(M)}Promise.resolve(z).then(u).catch(M=>{var y;if(r)return;const m=t.retry??(r0?0:3),V=t.retryDelay??w31,b=typeof V=="function"?V(a,M):V,w=m===!0||typeof m=="number"&&a<m||typeof m=="function"&&m(a,M);if(e||!w){g(M);return}a++,(y=t.onFail)==null||y.call(t,a,M),MO(b).then(()=>{if(s())return p()}).then(()=>{e?g(M):f()})})};return ao(t.networkMode)?f():p().then(f),{promise:o,cancel:c,continue:()=>(n==null?void 0:n())?o:Promise.resolve(),cancelRetry:v,continueRetry:h}}function b31(){let t=[],e=0,a=h=>{h()},r=h=>{h()};const n=h=>{let s;e++;try{s=h()}finally{e--,e||o()}return s},l=h=>{e?t.push(h):rf(()=>{a(h)})},i=h=>(...s)=>{l(()=>{h(...s)})},o=()=>{const h=t;t=[],h.length&&rf(()=>{r(()=>{h.forEach(s=>{a(s)})})})};return{batch:n,batchCalls:i,schedule:l,setNotifyFunction:h=>{a=h},setBatchNotifyFunction:h=>{r=h}}}var zt=b31(),We,df,VO=(df=class{constructor(){z1(this,We,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jc(this.gcTime)&&u1(this,We,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(r0?1/0:5*60*1e3))}clearGcTimeout(){B(this,We)&&(clearTimeout(B(this,We)),u1(this,We,void 0))}},We=new WeakMap,df),Na,Ta,s2,de,v2,yt,$0,Ke,ja,A4,V2,G2,uf,y31=(uf=class extends VO{constructor(e){super();z1(this,ja);z1(this,V2);z1(this,Na,void 0);z1(this,Ta,void 0);z1(this,s2,void 0);z1(this,de,void 0);z1(this,v2,void 0);z1(this,yt,void 0);z1(this,$0,void 0);z1(this,Ke,void 0);u1(this,Ke,!1),u1(this,$0,e.defaultOptions),C1(this,ja,A4).call(this,e.options),u1(this,yt,[]),u1(this,s2,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,u1(this,Na,e.state||x31(this.options)),this.state=B(this,Na),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!B(this,yt).length&&this.state.fetchStatus==="idle"&&B(this,s2).remove(this)}setData(e,a){const r=Qc(this.state.data,e,this.options);return C1(this,V2,G2).call(this,{data:r,type:"success",dataUpdatedAt:a==null?void 0:a.updatedAt,manual:a==null?void 0:a.manual}),r}setState(e,a){C1(this,V2,G2).call(this,{type:"setState",state:e,setStateOptions:a})}cancel(e){var r;const a=B(this,de);return(r=B(this,v2))==null||r.cancel(e),a?a.then(g2).catch(g2):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(B(this,Na))}isActive(){return B(this,yt).some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||B(this,yt).some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!pO(this.state.dataUpdatedAt,e)}onFocus(){var a;const e=B(this,yt).find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(a=B(this,v2))==null||a.continue()}onOnline(){var a;const e=B(this,yt).find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(a=B(this,v2))==null||a.continue()}addObserver(e){B(this,yt).includes(e)||(B(this,yt).push(e),this.clearGcTimeout(),B(this,s2).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){B(this,yt).includes(e)&&(u1(this,yt,B(this,yt).filter(a=>a!==e)),B(this,yt).length||(B(this,v2)&&(B(this,Ke)?B(this,v2).cancel({revert:!0}):B(this,v2).cancelRetry()),this.scheduleGc()),B(this,s2).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return B(this,yt).length}invalidate(){this.state.isInvalidated||C1(this,V2,G2).call(this,{type:"invalidate"})}fetch(e,a){var v,h,s,u;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(a!=null&&a.cancelRefetch))this.cancel({silent:!0});else if(B(this,de))return(v=B(this,v2))==null||v.continueRetry(),B(this,de)}if(e&&C1(this,ja,A4).call(this,e),!this.options.queryFn){const g=B(this,yt).find(p=>p.options.queryFn);g&&C1(this,ja,A4).call(this,g.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 r=new AbortController,n={queryKey:this.queryKey,meta:this.meta},l=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(u1(this,Ke,!0),r.signal)})};l(n);const i=()=>this.options.queryFn?(u1(this,Ke,!1),this.options.persister?this.options.persister(this.options.queryFn,n,this):this.options.queryFn(n)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),o={fetchOptions:a,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};l(o),(h=this.options.behavior)==null||h.onFetch(o,this),u1(this,Ta,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((s=o.fetchOptions)==null?void 0:s.meta))&&C1(this,V2,G2).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta});const c=g=>{var p,f,z,M;dc(g)&&g.silent||C1(this,V2,G2).call(this,{type:"error",error:g}),dc(g)||((f=(p=B(this,s2).config).onError)==null||f.call(p,g,this),(M=(z=B(this,s2).config).onSettled)==null||M.call(z,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return u1(this,v2,HO({fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var p,f,z,M;if(typeof g>"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}`),c(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(f=(p=B(this,s2).config).onSuccess)==null||f.call(p,g,this),(M=(z=B(this,s2).config).onSettled)==null||M.call(z,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:c,onFail:(g,p)=>{C1(this,V2,G2).call(this,{type:"failed",failureCount:g,error:p})},onPause:()=>{C1(this,V2,G2).call(this,{type:"pause"})},onContinue:()=>{C1(this,V2,G2).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode})),u1(this,de,B(this,v2).promise),B(this,de)}},Na=new WeakMap,Ta=new WeakMap,s2=new WeakMap,de=new WeakMap,v2=new WeakMap,yt=new WeakMap,$0=new WeakMap,Ke=new WeakMap,ja=new WeakSet,A4=function(e){this.options={...B(this,$0),...e},this.updateGcTime(this.options.gcTime)},V2=new WeakSet,G2=function(e){const a=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:e.meta??null,fetchStatus:ao(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return dc(n)&&n.revert&&B(this,Ta)?{...B(this,Ta),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=a(this.state),zt.batch(()=>{B(this,yt).forEach(r=>{r.onQueryUpdate()}),B(this,s2).notify({query:this,type:"updated",action:e})})},uf);function x31(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,a=typeof e<"u",r=a?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:a?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var A2,gf,L31=(gf=class extends s0{constructor(e={}){super();z1(this,A2,void 0);this.config=e,u1(this,A2,new Map)}build(e,a,r){const n=a.queryKey,l=a.queryHash??Rh(n,a);let i=this.get(l);return i||(i=new y31({cache:this,queryKey:n,queryHash:l,options:e.defaultQueryOptions(a),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){B(this,A2).has(e.queryHash)||(B(this,A2).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const a=B(this,A2).get(e.queryHash);a&&(e.destroy(),a===e&&B(this,A2).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){zt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return B(this,A2).get(e)}getAll(){return[...B(this,A2).values()]}find(e){const a={exact:!0,...e};return this.getAll().find(r=>$g(a,r))}findAll(e={}){const a=this.getAll();return Object.keys(e).length>0?a.filter(r=>$g(e,r)):a}notify(e){zt.batch(()=>{this.listeners.forEach(a=>{a(e)})})}onFocus(){zt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){zt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},A2=new WeakMap,gf),E2,tr,$t,Da,P2,he,ff,O31=(ff=class extends VO{constructor(e){super();z1(this,P2);z1(this,E2,void 0);z1(this,tr,void 0);z1(this,$t,void 0);z1(this,Da,void 0);this.mutationId=e.mutationId,u1(this,tr,e.defaultOptions),u1(this,$t,e.mutationCache),u1(this,E2,[]),this.state=e.state||wO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...B(this,tr),...e},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){B(this,E2).includes(e)||(B(this,E2).push(e),this.clearGcTimeout(),B(this,$t).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){u1(this,E2,B(this,E2).filter(a=>a!==e)),this.scheduleGc(),B(this,$t).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){B(this,E2).length||(this.state.status==="pending"?this.scheduleGc():B(this,$t).remove(this))}continue(){var e;return((e=B(this,Da))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var n,l,i,o,c,v,h,s,u,g,p,f,z,M,m,V,b,w,y,x;const a=()=>(u1(this,Da,HO({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(L,S)=>{C1(this,P2,he).call(this,{type:"failed",failureCount:L,error:S})},onPause:()=>{C1(this,P2,he).call(this,{type:"pause"})},onContinue:()=>{C1(this,P2,he).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),B(this,Da).promise),r=this.state.status==="pending";try{if(!r){C1(this,P2,he).call(this,{type:"pending",variables:e}),await((l=(n=B(this,$t).config).onMutate)==null?void 0:l.call(n,e,this));const S=await((o=(i=this.options).onMutate)==null?void 0:o.call(i,e));S!==this.state.context&&C1(this,P2,he).call(this,{type:"pending",context:S,variables:e})}const L=await a();return await((v=(c=B(this,$t).config).onSuccess)==null?void 0:v.call(c,L,e,this.state.context,this)),await((s=(h=this.options).onSuccess)==null?void 0:s.call(h,L,e,this.state.context)),await((g=(u=B(this,$t).config).onSettled)==null?void 0:g.call(u,L,null,this.state.variables,this.state.context,this)),await((f=(p=this.options).onSettled)==null?void 0:f.call(p,L,null,e,this.state.context)),C1(this,P2,he).call(this,{type:"success",data:L}),L}catch(L){try{throw await((M=(z=B(this,$t).config).onError)==null?void 0:M.call(z,L,e,this.state.context,this)),await((V=(m=this.options).onError)==null?void 0:V.call(m,L,e,this.state.context)),await((w=(b=B(this,$t).config).onSettled)==null?void 0:w.call(b,void 0,L,this.state.variables,this.state.context,this)),await((x=(y=this.options).onSettled)==null?void 0:x.call(y,void 0,L,e,this.state.context)),L}finally{C1(this,P2,he).call(this,{type:"error",error:L})}}}},E2=new WeakMap,tr=new WeakMap,$t=new WeakMap,Da=new WeakMap,P2=new WeakSet,he=function(e){const a=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!ao(this.options.networkMode),status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=a(this.state),zt.batch(()=>{B(this,E2).forEach(r=>{r.onMutationUpdate(e)}),B(this,$t).notify({mutation:this,type:"updated",action:e})})},ff);function wO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var d2,er,Ue,pf,S31=(pf=class extends s0{constructor(e={}){super();z1(this,d2,void 0);z1(this,er,void 0);z1(this,Ue,void 0);this.config=e,u1(this,d2,[]),u1(this,er,0)}build(e,a,r){const n=new O31({mutationCache:this,mutationId:++Cr(this,er)._,options:e.defaultMutationOptions(a),state:r});return this.add(n),n}add(e){B(this,d2).push(e),this.notify({type:"added",mutation:e})}remove(e){u1(this,d2,B(this,d2).filter(a=>a!==e)),this.notify({type:"removed",mutation:e})}clear(){zt.batch(()=>{B(this,d2).forEach(e=>{this.remove(e)})})}getAll(){return B(this,d2)}find(e){const a={exact:!0,...e};return B(this,d2).find(r=>tf(a,r))}findAll(e={}){return B(this,d2).filter(a=>tf(e,a))}notify(e){zt.batch(()=>{this.listeners.forEach(a=>{a(e)})})}resumePausedMutations(){return u1(this,Ue,(B(this,Ue)??Promise.resolve()).then(()=>{const e=B(this,d2).filter(a=>a.state.isPaused);return zt.batch(()=>e.reduce((a,r)=>a.then(()=>r.continue().catch(g2)),Promise.resolve()))}).then(()=>{u1(this,Ue,void 0)})),B(this,Ue)}},d2=new WeakMap,er=new WeakMap,Ue=new WeakMap,pf);function C31(t){return{onFetch:(e,a)=>{const r=async()=>{var p,f,z,M,m;const n=e.options,l=(z=(f=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:z.direction,i=((M=e.state.data)==null?void 0:M.pages)||[],o=((m=e.state.data)==null?void 0:m.pageParams)||[],c={pages:[],pageParams:[]};let v=!1;const h=V=>{Object.defineProperty(V,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},s=e.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${e.options.queryHash}'`))),u=async(V,b,w)=>{if(v)return Promise.reject();if(b==null&&V.pages.length)return Promise.resolve(V);const y={queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};h(y);const x=await s(y),{maxPages:L}=e.options,S=w?m31:M31;return{pages:S(V.pages,x,L),pageParams:S(V.pageParams,b,L)}};let g;if(l&&i.length){const V=l==="backward",b=V?B31:nf,w={pages:i,pageParams:o},y=b(n,w);g=await u(w,y,V)}else{g=await u(c,o[0]??n.initialPageParam);const V=t??i.length;for(let b=1;b<V;b++){const w=nf(n,g);g=await u(g,w)}}return g};e.options.persister?e.fetchFn=()=>{var n,l;return(l=(n=e.options).persister)==null?void 0:l.call(n,r,{queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},a)}:e.fetchFn=r}}}function nf(t,{pages:e,pageParams:a}){const r=e.length-1;return t.getNextPageParam(e[r],e,a[r],a)}function B31(t,{pages:e,pageParams:a}){var r;return(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,a[0],a)}var ft,ue,ge,Fa,qa,fe,Wa,Ka,zf,A31=(zf=class{constructor(t={}){z1(this,ft,void 0);z1(this,ue,void 0);z1(this,ge,void 0);z1(this,Fa,void 0);z1(this,qa,void 0);z1(this,fe,void 0);z1(this,Wa,void 0);z1(this,Ka,void 0);u1(this,ft,t.queryCache||new L31),u1(this,ue,t.mutationCache||new S31),u1(this,ge,t.defaultOptions||{}),u1(this,Fa,new Map),u1(this,qa,new Map),u1(this,fe,0)}mount(){Cr(this,fe)._++,B(this,fe)===1&&(u1(this,Wa,pi.subscribe(()=>{pi.isFocused()&&(this.resumePausedMutations(),B(this,ft).onFocus())})),u1(this,Ka,zi.subscribe(()=>{zi.isOnline()&&(this.resumePausedMutations(),B(this,ft).onOnline())})))}unmount(){var t,e;Cr(this,fe)._--,B(this,fe)===0&&((t=B(this,Wa))==null||t.call(this),u1(this,Wa,void 0),(e=B(this,Ka))==null||e.call(this),u1(this,Ka,void 0))}isFetching(t){return B(this,ft).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return B(this,ue).findAll({...t,status:"pending"}).length}getQueryData(t){var e;return(e=B(this,ft).find({queryKey:t}))==null?void 0:e.state.data}ensureQueryData(t){const e=this.getQueryData(t.queryKey);return e!==void 0?Promise.resolve(e):this.fetchQuery(t)}getQueriesData(t){return this.getQueryCache().findAll(t).map(({queryKey:e,state:a})=>{const r=a.data;return[e,r]})}setQueryData(t,e,a){const r=B(this,ft).find({queryKey:t}),n=r==null?void 0:r.state.data,l=z31(e,n);if(typeof l>"u")return;const i=this.defaultQueryOptions({queryKey:t});return B(this,ft).build(this,i).setData(l,{...a,manual:!0})}setQueriesData(t,e,a){return zt.batch(()=>this.getQueryCache().findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,a)]))}getQueryState(t){var e;return(e=B(this,ft).find({queryKey:t}))==null?void 0:e.state}removeQueries(t){const e=B(this,ft);zt.batch(()=>{e.findAll(t).forEach(a=>{e.remove(a)})})}resetQueries(t,e){const a=B(this,ft),r={type:"active",...t};return zt.batch(()=>(a.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries(r,e)))}cancelQueries(t={},e={}){const a={revert:!0,...e},r=zt.batch(()=>B(this,ft).findAll(t).map(n=>n.cancel(a)));return Promise.all(r).then(g2).catch(g2)}invalidateQueries(t={},e={}){return zt.batch(()=>{if(B(this,ft).findAll(t).forEach(r=>{r.invalidate()}),t.refetchType==="none")return Promise.resolve();const a={...t,type:t.refetchType??t.type??"active"};return this.refetchQueries(a,e)})}refetchQueries(t={},e){const a={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0},r=zt.batch(()=>B(this,ft).findAll(t).filter(n=>!n.isDisabled()).map(n=>{let l=n.fetch(void 0,a);return a.throwOnError||(l=l.catch(g2)),n.state.fetchStatus==="paused"?Promise.resolve():l}));return Promise.all(r).then(g2)}fetchQuery(t){const e=this.defaultQueryOptions(t);typeof e.retry>"u"&&(e.retry=!1);const a=B(this,ft).build(this,e);return a.isStaleByTime(e.staleTime)?a.fetch(e):Promise.resolve(a.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(g2).catch(g2)}fetchInfiniteQuery(t){return t.behavior=C31(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g2).catch(g2)}resumePausedMutations(){return B(this,ue).resumePausedMutations()}getQueryCache(){return B(this,ft)}getMutationCache(){return B(this,ue)}getDefaultOptions(){return B(this,ge)}setDefaultOptions(t){u1(this,ge,t)}setQueryDefaults(t,e){B(this,Fa).set(X0(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...B(this,Fa).values()];let a={};return e.forEach(r=>{_0(t,r.queryKey)&&(a={...a,...r.defaultOptions})}),a}setMutationDefaults(t,e){B(this,qa).set(X0(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...B(this,qa).values()];let a={};return e.forEach(r=>{_0(t,r.mutationKey)&&(a={...a,...r.defaultOptions})}),a}defaultQueryOptions(t){if(t!=null&&t._defaulted)return t;const e={...B(this,ge).queries,...(t==null?void 0:t.queryKey)&&this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Rh(e.queryKey,e)),typeof e.refetchOnReconnect>"u"&&(e.refetchOnReconnect=e.networkMode!=="always"),typeof e.throwOnError>"u"&&(e.throwOnError=!!e.suspense),typeof e.networkMode>"u"&&e.persister&&(e.networkMode="offlineFirst"),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...B(this,ge).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){B(this,ft).clear(),B(this,ue).clear()}},ft=new WeakMap,ue=new WeakMap,ge=new WeakMap,Fa=new WeakMap,qa=new WeakMap,fe=new WeakMap,Wa=new WeakMap,Ka=new WeakMap,zf),Ut,Q1,Ua,It,Ze,Za,I2,ar,Ga,Ja,Ge,Je,pe,Ye,Qe,k0,rr,Xc,nr,_c,lr,$c,ir,t3,or,e3,cr,a3,hr,r3,Mi,bO,Mf,E31=(Mf=class extends s0{constructor(e,a){super();z1(this,Qe);z1(this,rr);z1(this,nr);z1(this,lr);z1(this,ir);z1(this,or);z1(this,cr);z1(this,hr);z1(this,Mi);z1(this,Ut,void 0);z1(this,Q1,void 0);z1(this,Ua,void 0);z1(this,It,void 0);z1(this,Ze,void 0);z1(this,Za,void 0);z1(this,I2,void 0);z1(this,ar,void 0);z1(this,Ga,void 0);z1(this,Ja,void 0);z1(this,Ge,void 0);z1(this,Je,void 0);z1(this,pe,void 0);z1(this,Ye,void 0);u1(this,Q1,void 0),u1(this,Ua,void 0),u1(this,It,void 0),u1(this,Ye,new Set),u1(this,Ut,e),this.options=a,u1(this,I2,null),this.bindMethods(),this.setOptions(a)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(B(this,Q1).addObserver(this),lf(B(this,Q1),this.options)?C1(this,Qe,k0).call(this):this.updateResult(),C1(this,ir,t3).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return n3(B(this,Q1),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return n3(B(this,Q1),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,C1(this,or,e3).call(this),C1(this,cr,a3).call(this),B(this,Q1).removeObserver(this)}setOptions(e,a){const r=this.options,n=B(this,Q1);if(this.options=B(this,Ut).defaultQueryOptions(e),fi(r,this.options)||B(this,Ut).getQueryCache().notify({type:"observerOptionsUpdated",query:B(this,Q1),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=r.queryKey),C1(this,hr,r3).call(this);const l=this.hasListeners();l&&of(B(this,Q1),n,this.options,r)&&C1(this,Qe,k0).call(this),this.updateResult(a),l&&(B(this,Q1)!==n||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&C1(this,rr,Xc).call(this);const i=C1(this,nr,_c).call(this);l&&(B(this,Q1)!==n||this.options.enabled!==r.enabled||i!==B(this,pe))&&C1(this,lr,$c).call(this,i)}getOptimisticResult(e){const a=B(this,Ut).getQueryCache().build(B(this,Ut),e),r=this.createResult(a,e);return I31(this,r)&&(u1(this,It,r),u1(this,Za,this.options),u1(this,Ze,B(this,Q1).state)),r}getCurrentResult(){return B(this,It)}trackResult(e){const a={};return Object.keys(e).forEach(r=>{Object.defineProperty(a,r,{configurable:!1,enumerable:!0,get:()=>(B(this,Ye).add(r),e[r])})}),a}getCurrentQuery(){return B(this,Q1)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const a=B(this,Ut).defaultQueryOptions(e),r=B(this,Ut).getQueryCache().build(B(this,Ut),a);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,a))}fetch(e){return C1(this,Qe,k0).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),B(this,It)))}createResult(e,a){var y;const r=B(this,Q1),n=this.options,l=B(this,It),i=B(this,Ze),o=B(this,Za),v=e!==r?e.state:B(this,Ua),{state:h}=e;let{error:s,errorUpdatedAt:u,fetchStatus:g,status:p}=h,f=!1,z;if(a._optimisticResults){const x=this.hasListeners(),L=!x&&lf(e,a),S=x&&of(e,r,a,n);(L||S)&&(g=ao(e.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(p="pending")),a._optimisticResults==="isRestoring"&&(g="idle")}if(a.select&&typeof h.data<"u")if(l&&h.data===(i==null?void 0:i.data)&&a.select===B(this,ar))z=B(this,Ga);else try{u1(this,ar,a.select),z=a.select(h.data),z=Qc(l==null?void 0:l.data,z,a),u1(this,Ga,z),u1(this,I2,null)}catch(x){u1(this,I2,x)}else z=h.data;if(typeof a.placeholderData<"u"&&typeof z>"u"&&p==="pending"){let x;if(l!=null&&l.isPlaceholderData&&a.placeholderData===(o==null?void 0:o.placeholderData))x=l.data;else if(x=typeof a.placeholderData=="function"?a.placeholderData((y=B(this,Ja))==null?void 0:y.state.data,B(this,Ja)):a.placeholderData,a.select&&typeof x<"u")try{x=a.select(x),u1(this,I2,null)}catch(L){u1(this,I2,L)}typeof x<"u"&&(p="success",z=Qc(l==null?void 0:l.data,x,a),f=!0)}B(this,I2)&&(s=B(this,I2),z=B(this,Ga),u=Date.now(),p="error");const M=g==="fetching",m=p==="pending",V=p==="error",b=m&&M;return{status:p,fetchStatus:g,isPending:m,isSuccess:p==="success",isError:V,isInitialLoading:b,isLoading:b,data:z,dataUpdatedAt:h.dataUpdatedAt,error:s,errorUpdatedAt:u,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>v.dataUpdateCount||h.errorUpdateCount>v.errorUpdateCount,isFetching:M,isRefetching:M&&!m,isLoadingError:V&&h.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:f,isRefetchError:V&&h.dataUpdatedAt!==0,isStale:kh(e,a),refetch:this.refetch}}updateResult(e){const a=B(this,It),r=this.createResult(B(this,Q1),this.options);if(u1(this,Ze,B(this,Q1).state),u1(this,Za,this.options),B(this,Ze).data!==void 0&&u1(this,Ja,B(this,Q1)),fi(r,a))return;u1(this,It,r);const n={},l=()=>{if(!a)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!B(this,Ye).size)return!0;const c=new Set(o??B(this,Ye));return this.options.throwOnError&&c.add("error"),Object.keys(B(this,It)).some(v=>{const h=v;return B(this,It)[h]!==a[h]&&c.has(h)})};(e==null?void 0:e.listeners)!==!1&&l()&&(n.listeners=!0),C1(this,Mi,bO).call(this,{...n,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&C1(this,ir,t3).call(this)}},Ut=new WeakMap,Q1=new WeakMap,Ua=new WeakMap,It=new WeakMap,Ze=new WeakMap,Za=new WeakMap,I2=new WeakMap,ar=new WeakMap,Ga=new WeakMap,Ja=new WeakMap,Ge=new WeakMap,Je=new WeakMap,pe=new WeakMap,Ye=new WeakMap,Qe=new WeakSet,k0=function(e){C1(this,hr,r3).call(this);let a=B(this,Q1).fetch(this.options,e);return e!=null&&e.throwOnError||(a=a.catch(g2)),a},rr=new WeakSet,Xc=function(){if(C1(this,or,e3).call(this),r0||B(this,It).isStale||!Jc(this.options.staleTime))return;const a=pO(B(this,It).dataUpdatedAt,this.options.staleTime)+1;u1(this,Ge,setTimeout(()=>{B(this,It).isStale||this.updateResult()},a))},nr=new WeakSet,_c=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(B(this,Q1)):this.options.refetchInterval)??!1},lr=new WeakSet,$c=function(e){C1(this,cr,a3).call(this),u1(this,pe,e),!(r0||this.options.enabled===!1||!Jc(B(this,pe))||B(this,pe)===0)&&u1(this,Je,setInterval(()=>{(this.options.refetchIntervalInBackground||pi.isFocused())&&C1(this,Qe,k0).call(this)},B(this,pe)))},ir=new WeakSet,t3=function(){C1(this,rr,Xc).call(this),C1(this,lr,$c).call(this,C1(this,nr,_c).call(this))},or=new WeakSet,e3=function(){B(this,Ge)&&(clearTimeout(B(this,Ge)),u1(this,Ge,void 0))},cr=new WeakSet,a3=function(){B(this,Je)&&(clearInterval(B(this,Je)),u1(this,Je,void 0))},hr=new WeakSet,r3=function(){const e=B(this,Ut).getQueryCache().build(B(this,Ut),this.options);if(e===B(this,Q1))return;const a=B(this,Q1);u1(this,Q1,e),u1(this,Ua,e.state),this.hasListeners()&&(a==null||a.removeObserver(this),e.addObserver(this))},Mi=new WeakSet,bO=function(e){zt.batch(()=>{e.listeners&&this.listeners.forEach(a=>{a(B(this,It))}),B(this,Ut).getQueryCache().notify({query:B(this,Q1),type:"observerResultsUpdated"})})},Mf);function P31(t,e){return e.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&e.retryOnMount===!1)}function lf(t,e){return P31(t,e)||t.state.dataUpdatedAt>0&&n3(t,e,e.refetchOnMount)}function n3(t,e,a){if(e.enabled!==!1){const r=typeof a=="function"?a(t):a;return r==="always"||r!==!1&&kh(t,e)}return!1}function of(t,e,a,r){return a.enabled!==!1&&(t!==e||r.enabled===!1)&&(!a.suspense||t.state.status!=="error")&&kh(t,a)}function kh(t,e){return t.isStaleByTime(e.staleTime)}function I31(t,e){return!fi(t.getCurrentResult(),e)}var ze,Dt,u2,Y2,Ya,E4,sr,l3,mf,R31=(mf=class extends s0{constructor(a,r){super();z1(this,Ya);z1(this,sr);z1(this,ze,void 0);z1(this,Dt,void 0);z1(this,u2,void 0);z1(this,Y2,void 0);u1(this,Dt,void 0),u1(this,ze,a),this.setOptions(r),this.bindMethods(),C1(this,Ya,E4).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(a){var n;const r=this.options;this.options=B(this,ze).defaultMutationOptions(a),fi(r,this.options)||B(this,ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:B(this,u2),observer:this}),(n=B(this,u2))==null||n.setOptions(this.options)}onUnsubscribe(){var a;this.hasListeners()||(a=B(this,u2))==null||a.removeObserver(this)}onMutationUpdate(a){C1(this,Ya,E4).call(this),C1(this,sr,l3).call(this,a)}getCurrentResult(){return B(this,Dt)}reset(){u1(this,u2,void 0),C1(this,Ya,E4).call(this),C1(this,sr,l3).call(this)}mutate(a,r){var n;return u1(this,Y2,r),(n=B(this,u2))==null||n.removeObserver(this),u1(this,u2,B(this,ze).getMutationCache().build(B(this,ze),this.options)),B(this,u2).addObserver(this),B(this,u2).execute(a)}},ze=new WeakMap,Dt=new WeakMap,u2=new WeakMap,Y2=new WeakMap,Ya=new WeakSet,E4=function(){var r;const a=((r=B(this,u2))==null?void 0:r.state)??wO();u1(this,Dt,{...a,isPending:a.status==="pending",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset})},sr=new WeakSet,l3=function(a){zt.batch(()=>{var r,n,l,i,o,c,v,h;B(this,Y2)&&this.hasListeners()&&((a==null?void 0:a.type)==="success"?((n=(r=B(this,Y2)).onSuccess)==null||n.call(r,a.data,B(this,Dt).variables,B(this,Dt).context),(i=(l=B(this,Y2)).onSettled)==null||i.call(l,a.data,null,B(this,Dt).variables,B(this,Dt).context)):(a==null?void 0:a.type)==="error"&&((c=(o=B(this,Y2)).onError)==null||c.call(o,a.error,B(this,Dt).variables,B(this,Dt).context),(h=(v=B(this,Y2)).onSettled)==null||h.call(v,void 0,a.error,B(this,Dt).variables,B(this,Dt).context))),this.listeners.forEach(s=>{s(B(this,Dt))})})},mf);var yO=O.createContext(void 0),n2=t=>{const e=O.useContext(yO);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},k31=({client:t,children:e})=>(O.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),O.createElement(yO.Provider,{value:t},e)),xO=O.createContext(!1),N31=()=>O.useContext(xO),Yh1=xO.Provider;function T31(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var j31=O.createContext(T31()),D31=()=>O.useContext(j31);function LO(t,e){return typeof t=="function"?t(...e):!!t}var F31=(t,e)=>{(t.suspense||t.throwOnError)&&(e.isReset()||(t.retryOnMount=!1))},q31=t=>{O.useEffect(()=>{t.clearReset()},[t])},W31=({result:t,errorResetBoundary:e,throwOnError:a,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&LO(a,[t.error,r]);var K31=t=>{t.suspense&&typeof t.staleTime!="number"&&(t.staleTime=1e3)};var U31=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Z31=(t,e,a)=>e.fetchOptimistic(t).catch(()=>{a.clearReset()});function G31(t,e,a){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))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 r=n2(a),n=N31(),l=D31(),i=r.defaultQueryOptions(t);i._optimisticResults=n?"isRestoring":"optimistic",K31(i),F31(i,l),q31(l);const[o]=O.useState(()=>new e(r,i)),c=o.getOptimisticResult(i);if(O.useSyncExternalStore(O.useCallback(v=>{const h=n?()=>{}:o.subscribe(zt.batchCalls(v));return o.updateResult(),h},[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),O.useEffect(()=>{o.setOptions(i,{listeners:!1})},[i,o]),U31(i,c))throw Z31(i,o,l);if(W31({result:c,errorResetBoundary:l,throwOnError:i.throwOnError,query:o.getCurrentQuery()}))throw c.error;return i.notifyOnChangeProps?c:o.trackResult(c)}function Lr(t,e){return G31(t,E31,e)}function S2(t,e){const a=n2(e),[r]=O.useState(()=>new R31(a,t));O.useEffect(()=>{r.setOptions(t)},[r,t]);const n=O.useSyncExternalStore(O.useCallback(i=>r.subscribe(zt.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),l=O.useCallback((i,o)=>{r.mutate(i,o).catch(J31)},[r]);if(n.error&&LO(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:l,mutateAsync:n.mutate}}function J31(){}function Nt(){return n2().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Se=()=>{const{data:t,refetch:e}=Lr({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[t,a=>{a&&(localStorage.setItem("currentPage",a||""),e())}]};let cf="";const Or=()=>(cf=localStorage.getItem("__chai_at"),cf);function Y31(t){const e={method:"GET",headers:{"x-chai-access-token":Or()}};return fetch(t,e)}function Q31(t,e){const a={method:"POST",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}function X31(t,e){const a={method:"PUT",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}function _31(t,e){const a={method:"DELETE",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}const l2={get:Y31,post:Q31,put:X31,delete:_31},Nh=()=>{const[t,e]=Se(),a=Nt();return Lr({queryKey:["project"],queryFn:async()=>{const{data:r}=await l2.get(`${a}/project`).then(n=>n.json());if(!t&&r){const n=localStorage.getItem("currentPage");e(n||(r==null?void 0:r.homepage))}return r}})},Th=()=>{const t=Nt();return Lr({queryKey:["pages"],queryFn:async()=>{const{data:e}=await l2.get(`${t}/pages`).then(a=>a.json());return e||[]}})},OO=()=>{const[t]=Se(),e=Nt();return Lr({queryKey:["page_data",t],queryFn:async()=>{const{data:a}=await l2.get(`${e}/page?uuid=${t}`).then(r=>r.json());return a},enabled:!!t,staleTime:3e3})},i3=()=>r1.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:r1.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[r1.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),r1.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),SO=(t="Project updated successfully.")=>{const e=n2(),a=Nt();return S2({mutationFn:async r=>await l2.put(`${a}/project`,r).then(n=>n.json()),onSuccess:()=>{e.invalidateQueries({queryKey:["project"]}),F2.toast.success(t)}})},CO=()=>{const[t]=["SAVED"],[e,a]=Se(),r=o1.useBuilderReset();return n=>t!=="SAVED"?(F2.toast.error("You have unsaved changes. Please save before changing the page."),!1):e===n.uuid?!1:(r(),setTimeout(()=>{a(n.uuid)},100),!0)},$31=()=>{const t=n2(),e=CO(),a=Nt();return S2({mutationFn:async r=>l2.post(`${a}/pages`,r).then(n=>n.json()),onSuccess:r=>{t.invalidateQueries({queryKey:["pages"]}),e({uuid:r.uuid,slug:r.slug}),F2.toast.success("Page added successfully.")}})},BO=()=>{const t=Nt(),[e]=Se(),a=n2();return S2({mutationFn:async r=>l2.put(`${t}/page`,r).then(n=>n.json()),onSuccess:async r=>{var n;if(r.result==="error"&&((n=r.error)==null?void 0:n.code)=="PAGE_LOCKED"){a.invalidateQueries({queryKey:["page_data",e]});return}F2.toast.success("Page saved successfully.")}})},th1=()=>{const t=Nt(),{data:e}=Th(),[a]=Se(),{data:r}=Nh(),n=n2();return S2({mutationFn:async()=>{const l=e.find(i=>i.uuid===a).slug;return await l2.post(`${t}/publish`,{slug:l,uuid:a,isHomepage:(r==null?void 0:r.homepage)===a}).then(i=>i.json())},onSuccess:async l=>{var i;if(l.result==="error"&&((i=l.error)==null?void 0:i.code)=="PAGE_LOCKED"){n.invalidateQueries({queryKey:["page_data",a]});return}F2.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},eh1=()=>{const t=n2(),e=Nt();return S2({mutationFn:async a=>l2.delete(`${e}/page`,a).then(r=>r.json()),onSuccess:()=>{F2.toast.success("Page deleted successfully."),t.invalidateQueries({queryKey:["pages"]})}})},ah1=()=>{const t=n2(),e=Nt();return S2({mutationFn:async a=>l2.post(`${e}/take-control`,{uuid:a}).then(r=>r.json()),onSuccess:(a,r)=>{t.invalidateQueries({queryKey:["page_data",r]})}})},rh1=()=>{const t=Nt();return S2({mutationFn:async()=>{const{data:e}=await l2.get(`${t}/library`).then(a=>a.json());return rt.sortBy(rt.filter(e,a=>!rt.has(a,"hidden")),"group")}})},nh1=()=>{const t=Nt();return S2({mutationFn:async e=>{if(!e||!e.uuid)return[];try{const{data:a}=await l2.get(`${t}/block?uuid=${e.uuid}&format=${e.format}`).then(async r=>e.format==="html"?qO.getBlocksFromHTML(await r.text()):await r.json());return rt.set(a,"0._name",rt.capitalize(e.group)),a||[]}catch{return[]}}})},lh1=()=>{const t=Nt();return S2({mutationFn:async e=>{const a=new FormData;a.append("file",e);const{data:r}=await fetch(`${t}/upload`,{method:"POST",headers:{"x-chai-access-token":Or()},body:a}).then(n=>n.json());return r}})};var AO={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},hf=d.createContext&&d.createContext(AO),we=function(){return we=Object.assign||function(t){for(var e,a=1,r=arguments.length;a<r;a++){e=arguments[a];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},we.apply(this,arguments)},ih1=function(t,e){var a={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(a[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(a[r[n]]=t[r[n]]);return a};function EO(t){return t&&t.map(function(e,a){return d.createElement(e.tag,we({key:a},e.attr),EO(e.child))})}function PO(t){return function(e){return d.createElement(oh1,we({attr:we({},t.attr)},e),EO(t.child))}}function oh1(t){var e=function(a){var r=t.attr,n=t.size,l=t.title,i=ih1(t,["attr","size","title"]),o=n||a.size||"1em",c;return a.className&&(c=a.className),t.className&&(c=(c?c+" ":"")+t.className),d.createElement("svg",we({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,i,{className:c,style:we(we({color:t.color||a.color},a.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),l&&d.createElement("title",null,l),t.children)};return hf!==void 0?d.createElement(hf.Consumer,null,function(a){return e(a)}):e(AO)}function IO(t){return PO({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"}}]})(t)}function ch1(t){return PO({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}}]})(t)}const hh1=()=>{const{mutate:t,isPending:e}=ah1(),[a]=Se(),{data:r}=OO(),n=rt.get(r,"lockedBy.name",""),l=rt.get(r,"lockedBy.email","");return r1.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[r1.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),r1.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",r1.jsxRuntimeExports.jsx("br",{}),r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[r1.jsxRuntimeExports.jsx(ch1,{className:"w-4 h-4 text-gray-500"})," ",n]}),r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[r1.jsxRuntimeExports.jsx(IO,{className:"w-4 h-4 text-gray-500"})," ",l]})]}),r1.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",n," will be ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),r1.jsxRuntimeExports.jsx(o1.Button,{disabled:e,onClick:()=>t(a),className:`w-36 ${e?"bg-transparent shadow-none hover:bg-transparent":""}`,children:e?r1.jsxRuntimeExports.jsx(o3.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},sh1=()=>{const t=Nt(),e=n2();return S2({mutationFn:async a=>{const r=await fetch(`${t}/login`,{method:"POST",body:JSON.stringify(a)});if(r.ok)return await r.json();throw r.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:a=>{const{data:r}=a;if(!r.accessToken){F2.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",r.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(rt.omit(r,["accessToken"]))),e.invalidateQueries({queryKey:["verify"]}),F2.toast.success("Logged in successfully.")},onError:()=>{F2.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},vh1=()=>{const t=Nt();return Lr({queryKey:["verify"],queryFn:async()=>{const e=await l2.get(`${t}/verify`);return e.ok?(await e.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},dh1=()=>{const t=Nt(),e=n2();return S2({mutationFn:async()=>{const{result:a}=await l2.post(`${t}/logout`).then(r=>r.json());if(a==="success")return localStorage.clear(),e.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},uh1=({children:t})=>{const e=dh1();return r1.jsxRuntimeExports.jsxs(o1.AlertDialog,{children:[r1.jsxRuntimeExports.jsx(o1.AlertDialogTrigger,{asChild:!0,children:t}),r1.jsxRuntimeExports.jsxs(o1.AlertDialogContent,{children:[r1.jsxRuntimeExports.jsxs(o1.AlertDialogHeader,{children:[r1.jsxRuntimeExports.jsxs(o1.AlertDialogTitle,{children:["Are you sure, you want to ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),r1.jsxRuntimeExports.jsx(o1.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),r1.jsxRuntimeExports.jsxs(o1.AlertDialogFooter,{children:[r1.jsxRuntimeExports.jsx(o1.AlertDialogCancel,{disabled:e.isPending,children:"Cancel"}),r1.jsxRuntimeExports.jsxs("button",{disabled:e.isPending,onClick:()=>e.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[e.isPending&&r1.jsxRuntimeExports.jsx(o3.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},gh1=()=>r1.jsxRuntimeExports.jsx(uh1,{children:r1.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:r1.jsxRuntimeExports.jsx(o3.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),fh1=d.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel--maZxwX5.cjs"))),ph1=d.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-KhIpO7m3.cjs"))),zh1=d.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-p9MaXTOB.cjs"))),Mh1=()=>r1.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),mh1=()=>{const{mutate:t}=th1();return o1.useBuilderProp("editable",!0)?r1.jsxRuntimeExports.jsx(o1.Button,{onClick:t,className:"bg-blue-600 text-white",children:"Publish"}):null},Hh1=t=>{const{data:e,isLoading:a}=Nh(),{data:r,isLoading:n}=Th(),{data:l}=OO(),{mutate:i}=SO(),{mutate:o}=BO(),[c]=Se(),v=lh1(),h=rh1(),s=nh1(),u=Nt(),g=d.useCallback(async m=>await v.mutateAsync(m),[v]),p=d.useCallback(async()=>await h.mutateAsync(),[h]),f=d.useCallback(async m=>await s.mutateAsync(m),[s]),z=async(m=20,V=0)=>{const b=`limit=${m}&offset=${V}`,w=await fetch(`${u}/assets?${b}`).then(y=>y.json());return w.result==="success"?w.data:[]},{logo:M=Mh1}=t;return a||!e?r1.jsxRuntimeExports.jsx(i3,{}):n||!r?r1.jsxRuntimeExports.jsx(i3,{}):r1.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:r1.jsxRuntimeExports.jsx(fO,{editable:l!=null&&l.lockedBy?l==null?void 0:l.lockedBy.self:!0,nonEditableComponent:hh1,blocks:(l==null?void 0:l.blocks)||[],brandingOptions:e.brandingOptions,darkMode:t.darkMode||!1,dataProviders:(l==null?void 0:l.providers)||[],onSavePage:async({blocks:m,providers:V})=>(await o({blocks:m,providers:V,uuid:c}),!0),onSaveBrandingOptions:async m=>(await i({brandingOptions:m}),!0),topBarComponents:{left:[M],center:[zh1],right:[mh1]},sideBarComponents:{top:[{icon:P4.FileTextIcon,name:"pages",panel:fh1},{icon:P4.GearIcon,name:"settings",panel:ph1}],bottom:[gh1]},uploadMediaCallback:g,fetchMediaCallback:z,getUILibraryBlocks:p,getExternalPredefinedBlock:f,getPages:()=>r,unsplashAccessKey:t.unsplashAccessKey||""})})},Vh1=({logo:t})=>{const[e,a]=d.useState(!1),[r,n]=d.useState(""),[l,i]=d.useState(""),{mutate:o,isPending:c}=sh1(),v=h=>{h.preventDefault(),o({email:r,password:l})};return r1.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:r1.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:r1.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[r1.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[r1.jsxRuntimeExports.jsx(d.Suspense,{children:t?d.createElement(t):""}),r1.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),r1.jsxRuntimeExports.jsx("div",{className:"mt-8",children:r1.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:v,className:"space-y-5",children:[r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[r1.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r1.jsxRuntimeExports.jsx(IO,{})}),r1.jsxRuntimeExports.jsx("input",{value:r,onChange:h=>n(h.target.value),type:"email",id:"email",placeholder:"Enter email",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"})]})}),r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[r1.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r1.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:r1.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"})})}),r1.jsxRuntimeExports.jsx("input",{value:l,onChange:h=>i(h.target.value),type:e?"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"}),r1.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>a(!e),children:e?r1.jsxRuntimeExports.jsx(P4.EyeClosedIcon,{}):r1.jsxRuntimeExports.jsx(P4.EyeOpenIcon,{})})]})}),r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsx("button",{disabled:c||rt.size(r)<2||rt.size(l)<2,type:"submit",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:c?"Signing in...":"Login"})})]})}),r1.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:r1.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},wh1=t=>{const{data:e,isLoading:a}=vh1(),r=n2();return d.useEffect(()=>{r.setQueryData(["apiBaseUrl"],t.apiBaseUrl||"/api/chaibuilder")},[t.apiBaseUrl,r]),a?r1.jsxRuntimeExports.jsx(i3,{}):e!=null&&e.valid?r1.jsxRuntimeExports.jsx(Hh1,{...t}):r1.jsxRuntimeExports.jsx(Vh1,{logo:t.logo})},bh1=new A31,yh1=t=>r1.jsxRuntimeExports.jsxs(k31,{client:bh1,children:[r1.jsxRuntimeExports.jsx(F2.Toaster,{richColors:!0}),r1.jsxRuntimeExports.jsx(wh1,{...t})]});exports.BlocksExternalDataProvider=c31;exports.ChaiBuilderEditor=fO;exports.ChaiBuilderStudio=yh1;exports.ErrorBoundary=dO;exports.reactIsExports=Pf;exports.useAddPage=$31;exports.useChaiExternalData=gO;exports.useChangePage=CO;exports.useCurrentPage=Se;exports.useDeletePage=eh1;exports.useExpandedIds=i31;exports.usePages=Th;exports.useProject=Nh;exports.useQueryClient=n2;exports.useUpdatePage=BO;exports.useUpdateProject=SO;
206
+ */j();var $c1=process.env.NODE_ENV!=="production"?_c1:()=>null;function t31(){return new URLSearchParams(window.location.search).has("dnd")}const e31={dnd:t31()};class dO extends d.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?r1.jsxRuntimeExports.jsxs("div",{className:"bg-red-200 h-full w-full rounded-md text-red-500 p-4",id:"errorBoundary",children:[r1.jsxRuntimeExports.jsx("p",{className:"font-semibold",children:"Oops! Something went wrong."}),r1.jsxRuntimeExports.jsx("p",{children:"Please try again later."})]}):this.props.children}}const a31=()=>{const[t,e]=o1.usePreviewMode(),a=o1.useBuilderProp("previewComponent");return r1.jsxRuntimeExports.jsxs("div",{className:FO.cn$1("fixed inset-0 z-[999] bg-background",t?"block":"hidden"),children:[r1.jsxRuntimeExports.jsx(o1.Button,{size:"sm",className:"absolute right-0 top-0 m-4",onClick:()=>e(!1),children:"Close Preview"}),r1.jsxRuntimeExports.jsx("div",{children:a?r1.jsxRuntimeExports.jsx(d.Suspense,{fallback:r1.jsxRuntimeExports.jsx(o1.Skeleton,{className:"h-96 w-full"}),children:d.createElement(a)}):null})]})},r31=()=>{const[t,e]=o1.useSelectedBlockIds(),[,a]=o1.useCopyBlockIds(),r=o1.useRemoveBlocks(),n=o1.useDuplicateBlocks(),[,l]=o1.useCutBlockIds(),{pasteBlocks:i}=o1.usePasteBlocks(),{undo:o,redo:c}=o1.useCanvasHistory();ne.useHotkeys("esc",()=>e([]),{},[e]),ne.useHotkeys("ctrl+c,command+c",()=>a(t),{},[t,a]),ne.useHotkeys("ctrl+d,command+d",()=>n(t),{preventDefault:!0},[t,n]),ne.useHotkeys("ctrl+x,command+x",()=>l(t),{},[t,l]),ne.useHotkeys("ctrl+v,command+v",()=>t.length===1?i(t[0]):null,{},[t,i]),ne.useHotkeys("ctrl+z,command+z",()=>o(),{},[o]),ne.useHotkeys("ctrl+y,command+y",()=>c(),{},[c]),ne.useHotkeys("del, backspace",v=>{v.preventDefault(),r(t)},{},[t,r])},n31=(t,e)=>{const a=[];let r=rt.find(t,{_id:e}),n=rt.get(r,"_parent","");for(;rt.isString(n)&&!rt.isEmpty(n);)a.push(r==null?void 0:r._parent),r=rt.find(t,{_id:n}),n=r==null?void 0:r._parent;return rt.flatten(a)},uO=be.atom([]),l31=()=>{const[t]=o1.useSelectedBlockIds(),e=be.useAtomValue(o1.presentBlocksAtom),[,a]=be.useAtom(uO);d.useEffect(()=>{let r=[];const n=rt.head(t);rt.isString(n)&&(r=[n,...n31(e,n)]),a(r)},[t,e,a])},i31=()=>be.useAtomValue(uO),gO=()=>be.useAtom(o1.chaiExternalDataAtom),o31=()=>d.useMemo(()=>wf.getChaiDataProviders(),[]),c31=({children:t})=>{const[,e]=gO(),[a]=o1.usePageDataProviders(),r=o31();return d.useEffect(()=>(e({}),rt.forEach(a,n=>{const l=rt.find(r,{providerKey:n.providerKey});if(l){const i=(l==null?void 0:l.mockFn)||(l==null?void 0:l.dataFn);i&&i(n.args).then(o=>e(c=>({...c,[n.providerKey]:o})))}}),()=>{rt.forEach(a,n=>{e(l=>(delete l[n.providerKey],l))})}),[r,a,e]),r1.jsxRuntimeExports.jsx(r1.jsxRuntimeExports.Fragment,{children:t})},h31=d.lazy(()=>Promise.resolve().then(()=>require("./SidePanels-_5oUp-eI.cjs"))),s31=d.lazy(()=>Promise.resolve().then(()=>require("./Topbar-gQxbcPtG.cjs"))),v31=d.lazy(()=>Promise.resolve().then(()=>require("./CanvasArea-4m1-c1yq.cjs"))),d31=d.lazy(()=>Promise.resolve().then(()=>require("./Settings-BrYkhn3H.cjs"))),u31=()=>{const[t]=be.useAtom(o1.pageSyncStateAtom),e=n=>{o1.isDevelopment()||n.preventDefault()};r31(),l31(),d.useEffect(()=>(t!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[t]);const a=o1.useBuilderProp("editable",!0),r=o1.useBuilderProp("nonEditableComponent",null);return r1.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-background text-foreground",children:r1.jsxRuntimeExports.jsxs(o1.TooltipProvider,{children:[r1.jsxRuntimeExports.jsxs("div",{onContextMenu:e,className:"flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[r1.jsxRuntimeExports.jsx("div",{className:"h-14 w-screen shrink-0 border-b border-border",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(s31,{})})}),r1.jsxRuntimeExports.jsxs("main",{className:"flex h-full flex-1 flex-row relative",children:[a?null:r1.jsxRuntimeExports.jsx("div",{className:"absolute backdrop-blur-[2px] flex items-center justify-center inset-0 z-[500] h-full w-full",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:d.createElement(r)})}),r1.jsxRuntimeExports.jsx("div",{className:"flex h-full w-fit border-border max-h-full",style:{maxHeight:"calc(100vh - 56px)"},children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(h31,{})})}),r1.jsxRuntimeExports.jsx("div",{className:"h-full flex-1 bg-slate-800/20",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(v31,{})})}),r1.jsxRuntimeExports.jsx("div",{className:"flex h-[90%] w-[280px] pb-10 min-w-[280px] border-l border-border",children:r1.jsxRuntimeExports.jsx(d.Suspense,{children:r1.jsxRuntimeExports.jsx(d31,{})})})]})]}),r1.jsxRuntimeExports.jsx(a31,{})]})})},_g=be.getDefaultStore();var g31={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};g31.NODE_ENV==="development"&&console.log("Chai Builder:",QO);const f31=t=>r1.jsxRuntimeExports.jsx(r1.jsxRuntimeExports.Fragment,{children:t.children}),p31=t=>{const{dndOptions:e={backend:jh.MultiBackend}}=t,[a]=o1.useSetAllBlocks(),[,r]=o1.useBrandingOptions(),n=o1.useBuilderReset();return d.useEffect(()=>{_g.set(o1.chaiBuilderPropsAtom,rt.omit(t,["blocks","subPages","brandingOptions","dataProviders"]))},[t]),d.useEffect(()=>{_g.set(o1.dataProvidersAtom,t.dataProviders||[])},[t.dataProviders]),d.useEffect(()=>{a(wf.syncBlocksWithDefaults(t.blocks||[])),n()},[t.blocks]),d.useEffect(()=>{r(t.brandingOptions)},[t.brandingOptions,r]),r1.jsxRuntimeExports.jsx(DO.DndProvider,{...e,options:jh.getBackendOptions(),children:r1.jsxRuntimeExports.jsx(f31,{children:r1.jsxRuntimeExports.jsx(u31,{})})})},fO=t=>r1.jsxRuntimeExports.jsxs(dO,{children:[r1.jsxRuntimeExports.jsxs(jO.FlagsProvider,{features:e31,children:[r1.jsxRuntimeExports.jsx($c1,{}),r1.jsxRuntimeExports.jsx(p31,{...t})]}),r1.jsxRuntimeExports.jsx(o1.Toaster,{})]});var s0=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},r0=typeof window>"u"||"Deno"in window;function g2(){}function z31(t,e){return typeof t=="function"?t(e):t}function Jc(t){return typeof t=="number"&&t>=0&&t!==1/0}function pO(t,e){return Math.max(t+(e||0)-Date.now(),0)}function $g(t,e){const{type:a="all",exact:r,fetchStatus:n,predicate:l,queryKey:i,stale:o}=t;if(i){if(r){if(e.queryHash!==Rh(i,e.options))return!1}else if(!_0(e.queryKey,i))return!1}if(a!=="all"){const c=e.isActive();if(a==="active"&&!c||a==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||typeof n<"u"&&n!==e.state.fetchStatus||l&&!l(e))}function tf(t,e){const{exact:a,status:r,predicate:n,mutationKey:l}=t;if(l){if(!e.options.mutationKey)return!1;if(a){if(X0(e.options.mutationKey)!==X0(l))return!1}else if(!_0(e.options.mutationKey,l))return!1}return!(r&&e.state.status!==r||n&&!n(e))}function Rh(t,e){return((e==null?void 0:e.queryKeyHashFn)||X0)(t)}function X0(t){return JSON.stringify(t,(e,a)=>Yc(a)?Object.keys(a).sort().reduce((r,n)=>(r[n]=a[n],r),{}):a)}function _0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(a=>!_0(t[a],e[a])):!1}function zO(t,e){if(t===e)return t;const a=ef(t)&&ef(e);if(a||Yc(t)&&Yc(e)){const r=a?t.length:Object.keys(t).length,n=a?e:Object.keys(e),l=n.length,i=a?[]:{};let o=0;for(let c=0;c<l;c++){const v=a?c:n[c];i[v]=zO(t[v],e[v]),i[v]===t[v]&&o++}return r===l&&o===r?t:i}return e}function fi(t,e){if(t&&!e||e&&!t)return!1;for(const a in t)if(t[a]!==e[a])return!1;return!0}function ef(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Yc(t){if(!af(t))return!1;const e=t.constructor;if(typeof e>"u")return!0;const a=e.prototype;return!(!af(a)||!a.hasOwnProperty("isPrototypeOf"))}function af(t){return Object.prototype.toString.call(t)==="[object Object]"}function MO(t){return new Promise(e=>{setTimeout(e,t)})}function rf(t){MO(0).then(t)}function Qc(t,e,a){return typeof a.structuralSharing=="function"?a.structuralSharing(t,e):a.structuralSharing!==!1?zO(t,e):e}function M31(t,e,a=0){const r=[...t,e];return a&&r.length>a?r.slice(1):r}function m31(t,e,a=0){const r=[e,...t];return a&&r.length>a?r.slice(0,-1):r}var qe,se,Ia,sf,H31=(sf=class extends s0{constructor(){super();z1(this,qe,void 0);z1(this,se,void 0);z1(this,Ia,void 0);u1(this,Ia,e=>{if(!r0&&window.addEventListener){const a=()=>e();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}})}onSubscribe(){B(this,se)||this.setEventListener(B(this,Ia))}onUnsubscribe(){var e;this.hasListeners()||((e=B(this,se))==null||e.call(this),u1(this,se,void 0))}setEventListener(e){var a;u1(this,Ia,e),(a=B(this,se))==null||a.call(this),u1(this,se,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){B(this,qe)!==e&&(u1(this,qe,e),this.onFocus())}onFocus(){this.listeners.forEach(e=>{e()})}isFocused(){var e;return typeof B(this,qe)=="boolean"?B(this,qe):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},qe=new WeakMap,se=new WeakMap,Ia=new WeakMap,sf),pi=new H31,Ra,ve,ka,vf,V31=(vf=class extends s0{constructor(){super();z1(this,Ra,!0);z1(this,ve,void 0);z1(this,ka,void 0);u1(this,ka,e=>{if(!r0&&window.addEventListener){const a=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",r)}}})}onSubscribe(){B(this,ve)||this.setEventListener(B(this,ka))}onUnsubscribe(){var e;this.hasListeners()||((e=B(this,ve))==null||e.call(this),u1(this,ve,void 0))}setEventListener(e){var a;u1(this,ka,e),(a=B(this,ve))==null||a.call(this),u1(this,ve,e(this.setOnline.bind(this)))}setOnline(e){B(this,Ra)!==e&&(u1(this,Ra,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return B(this,Ra)}},Ra=new WeakMap,ve=new WeakMap,ka=new WeakMap,vf),zi=new V31;function w31(t){return Math.min(1e3*2**t,3e4)}function ao(t){return(t??"online")==="online"?zi.isOnline():!0}var mO=class{constructor(t){this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function dc(t){return t instanceof mO}function HO(t){let e=!1,a=0,r=!1,n,l,i;const o=new Promise((z,M)=>{l=z,i=M}),c=z=>{var M;r||(g(new mO(z)),(M=t.abort)==null||M.call(t))},v=()=>{e=!0},h=()=>{e=!1},s=()=>!pi.isFocused()||t.networkMode!=="always"&&!zi.isOnline(),u=z=>{var M;r||(r=!0,(M=t.onSuccess)==null||M.call(t,z),n==null||n(),l(z))},g=z=>{var M;r||(r=!0,(M=t.onError)==null||M.call(t,z),n==null||n(),i(z))},p=()=>new Promise(z=>{var M;n=m=>{const V=r||!s();return V&&z(m),V},(M=t.onPause)==null||M.call(t)}).then(()=>{var z;n=void 0,r||(z=t.onContinue)==null||z.call(t)}),f=()=>{if(r)return;let z;try{z=t.fn()}catch(M){z=Promise.reject(M)}Promise.resolve(z).then(u).catch(M=>{var y;if(r)return;const m=t.retry??(r0?0:3),V=t.retryDelay??w31,b=typeof V=="function"?V(a,M):V,w=m===!0||typeof m=="number"&&a<m||typeof m=="function"&&m(a,M);if(e||!w){g(M);return}a++,(y=t.onFail)==null||y.call(t,a,M),MO(b).then(()=>{if(s())return p()}).then(()=>{e?g(M):f()})})};return ao(t.networkMode)?f():p().then(f),{promise:o,cancel:c,continue:()=>(n==null?void 0:n())?o:Promise.resolve(),cancelRetry:v,continueRetry:h}}function b31(){let t=[],e=0,a=h=>{h()},r=h=>{h()};const n=h=>{let s;e++;try{s=h()}finally{e--,e||o()}return s},l=h=>{e?t.push(h):rf(()=>{a(h)})},i=h=>(...s)=>{l(()=>{h(...s)})},o=()=>{const h=t;t=[],h.length&&rf(()=>{r(()=>{h.forEach(s=>{a(s)})})})};return{batch:n,batchCalls:i,schedule:l,setNotifyFunction:h=>{a=h},setBatchNotifyFunction:h=>{r=h}}}var zt=b31(),We,df,VO=(df=class{constructor(){z1(this,We,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jc(this.gcTime)&&u1(this,We,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(r0?1/0:5*60*1e3))}clearGcTimeout(){B(this,We)&&(clearTimeout(B(this,We)),u1(this,We,void 0))}},We=new WeakMap,df),Na,Ta,s2,de,v2,yt,$0,Ke,ja,A4,V2,G2,uf,y31=(uf=class extends VO{constructor(e){super();z1(this,ja);z1(this,V2);z1(this,Na,void 0);z1(this,Ta,void 0);z1(this,s2,void 0);z1(this,de,void 0);z1(this,v2,void 0);z1(this,yt,void 0);z1(this,$0,void 0);z1(this,Ke,void 0);u1(this,Ke,!1),u1(this,$0,e.defaultOptions),C1(this,ja,A4).call(this,e.options),u1(this,yt,[]),u1(this,s2,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,u1(this,Na,e.state||x31(this.options)),this.state=B(this,Na),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!B(this,yt).length&&this.state.fetchStatus==="idle"&&B(this,s2).remove(this)}setData(e,a){const r=Qc(this.state.data,e,this.options);return C1(this,V2,G2).call(this,{data:r,type:"success",dataUpdatedAt:a==null?void 0:a.updatedAt,manual:a==null?void 0:a.manual}),r}setState(e,a){C1(this,V2,G2).call(this,{type:"setState",state:e,setStateOptions:a})}cancel(e){var r;const a=B(this,de);return(r=B(this,v2))==null||r.cancel(e),a?a.then(g2).catch(g2):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(B(this,Na))}isActive(){return B(this,yt).some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||B(this,yt).some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!pO(this.state.dataUpdatedAt,e)}onFocus(){var a;const e=B(this,yt).find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(a=B(this,v2))==null||a.continue()}onOnline(){var a;const e=B(this,yt).find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(a=B(this,v2))==null||a.continue()}addObserver(e){B(this,yt).includes(e)||(B(this,yt).push(e),this.clearGcTimeout(),B(this,s2).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){B(this,yt).includes(e)&&(u1(this,yt,B(this,yt).filter(a=>a!==e)),B(this,yt).length||(B(this,v2)&&(B(this,Ke)?B(this,v2).cancel({revert:!0}):B(this,v2).cancelRetry()),this.scheduleGc()),B(this,s2).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return B(this,yt).length}invalidate(){this.state.isInvalidated||C1(this,V2,G2).call(this,{type:"invalidate"})}fetch(e,a){var v,h,s,u;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(a!=null&&a.cancelRefetch))this.cancel({silent:!0});else if(B(this,de))return(v=B(this,v2))==null||v.continueRetry(),B(this,de)}if(e&&C1(this,ja,A4).call(this,e),!this.options.queryFn){const g=B(this,yt).find(p=>p.options.queryFn);g&&C1(this,ja,A4).call(this,g.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 r=new AbortController,n={queryKey:this.queryKey,meta:this.meta},l=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(u1(this,Ke,!0),r.signal)})};l(n);const i=()=>this.options.queryFn?(u1(this,Ke,!1),this.options.persister?this.options.persister(this.options.queryFn,n,this):this.options.queryFn(n)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),o={fetchOptions:a,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};l(o),(h=this.options.behavior)==null||h.onFetch(o,this),u1(this,Ta,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((s=o.fetchOptions)==null?void 0:s.meta))&&C1(this,V2,G2).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta});const c=g=>{var p,f,z,M;dc(g)&&g.silent||C1(this,V2,G2).call(this,{type:"error",error:g}),dc(g)||((f=(p=B(this,s2).config).onError)==null||f.call(p,g,this),(M=(z=B(this,s2).config).onSettled)==null||M.call(z,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return u1(this,v2,HO({fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var p,f,z,M;if(typeof g>"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}`),c(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(f=(p=B(this,s2).config).onSuccess)==null||f.call(p,g,this),(M=(z=B(this,s2).config).onSettled)==null||M.call(z,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:c,onFail:(g,p)=>{C1(this,V2,G2).call(this,{type:"failed",failureCount:g,error:p})},onPause:()=>{C1(this,V2,G2).call(this,{type:"pause"})},onContinue:()=>{C1(this,V2,G2).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode})),u1(this,de,B(this,v2).promise),B(this,de)}},Na=new WeakMap,Ta=new WeakMap,s2=new WeakMap,de=new WeakMap,v2=new WeakMap,yt=new WeakMap,$0=new WeakMap,Ke=new WeakMap,ja=new WeakSet,A4=function(e){this.options={...B(this,$0),...e},this.updateGcTime(this.options.gcTime)},V2=new WeakSet,G2=function(e){const a=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:e.meta??null,fetchStatus:ao(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return dc(n)&&n.revert&&B(this,Ta)?{...B(this,Ta),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=a(this.state),zt.batch(()=>{B(this,yt).forEach(r=>{r.onQueryUpdate()}),B(this,s2).notify({query:this,type:"updated",action:e})})},uf);function x31(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,a=typeof e<"u",r=a?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:a?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var A2,gf,L31=(gf=class extends s0{constructor(e={}){super();z1(this,A2,void 0);this.config=e,u1(this,A2,new Map)}build(e,a,r){const n=a.queryKey,l=a.queryHash??Rh(n,a);let i=this.get(l);return i||(i=new y31({cache:this,queryKey:n,queryHash:l,options:e.defaultQueryOptions(a),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){B(this,A2).has(e.queryHash)||(B(this,A2).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const a=B(this,A2).get(e.queryHash);a&&(e.destroy(),a===e&&B(this,A2).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){zt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return B(this,A2).get(e)}getAll(){return[...B(this,A2).values()]}find(e){const a={exact:!0,...e};return this.getAll().find(r=>$g(a,r))}findAll(e={}){const a=this.getAll();return Object.keys(e).length>0?a.filter(r=>$g(e,r)):a}notify(e){zt.batch(()=>{this.listeners.forEach(a=>{a(e)})})}onFocus(){zt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){zt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},A2=new WeakMap,gf),E2,tr,$t,Da,P2,he,ff,O31=(ff=class extends VO{constructor(e){super();z1(this,P2);z1(this,E2,void 0);z1(this,tr,void 0);z1(this,$t,void 0);z1(this,Da,void 0);this.mutationId=e.mutationId,u1(this,tr,e.defaultOptions),u1(this,$t,e.mutationCache),u1(this,E2,[]),this.state=e.state||wO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options={...B(this,tr),...e},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){B(this,E2).includes(e)||(B(this,E2).push(e),this.clearGcTimeout(),B(this,$t).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){u1(this,E2,B(this,E2).filter(a=>a!==e)),this.scheduleGc(),B(this,$t).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){B(this,E2).length||(this.state.status==="pending"?this.scheduleGc():B(this,$t).remove(this))}continue(){var e;return((e=B(this,Da))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var n,l,i,o,c,v,h,s,u,g,p,f,z,M,m,V,b,w,y,x;const a=()=>(u1(this,Da,HO({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(L,S)=>{C1(this,P2,he).call(this,{type:"failed",failureCount:L,error:S})},onPause:()=>{C1(this,P2,he).call(this,{type:"pause"})},onContinue:()=>{C1(this,P2,he).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),B(this,Da).promise),r=this.state.status==="pending";try{if(!r){C1(this,P2,he).call(this,{type:"pending",variables:e}),await((l=(n=B(this,$t).config).onMutate)==null?void 0:l.call(n,e,this));const S=await((o=(i=this.options).onMutate)==null?void 0:o.call(i,e));S!==this.state.context&&C1(this,P2,he).call(this,{type:"pending",context:S,variables:e})}const L=await a();return await((v=(c=B(this,$t).config).onSuccess)==null?void 0:v.call(c,L,e,this.state.context,this)),await((s=(h=this.options).onSuccess)==null?void 0:s.call(h,L,e,this.state.context)),await((g=(u=B(this,$t).config).onSettled)==null?void 0:g.call(u,L,null,this.state.variables,this.state.context,this)),await((f=(p=this.options).onSettled)==null?void 0:f.call(p,L,null,e,this.state.context)),C1(this,P2,he).call(this,{type:"success",data:L}),L}catch(L){try{throw await((M=(z=B(this,$t).config).onError)==null?void 0:M.call(z,L,e,this.state.context,this)),await((V=(m=this.options).onError)==null?void 0:V.call(m,L,e,this.state.context)),await((w=(b=B(this,$t).config).onSettled)==null?void 0:w.call(b,void 0,L,this.state.variables,this.state.context,this)),await((x=(y=this.options).onSettled)==null?void 0:x.call(y,void 0,L,e,this.state.context)),L}finally{C1(this,P2,he).call(this,{type:"error",error:L})}}}},E2=new WeakMap,tr=new WeakMap,$t=new WeakMap,Da=new WeakMap,P2=new WeakSet,he=function(e){const a=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!ao(this.options.networkMode),status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=a(this.state),zt.batch(()=>{B(this,E2).forEach(r=>{r.onMutationUpdate(e)}),B(this,$t).notify({mutation:this,type:"updated",action:e})})},ff);function wO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var d2,er,Ue,pf,S31=(pf=class extends s0{constructor(e={}){super();z1(this,d2,void 0);z1(this,er,void 0);z1(this,Ue,void 0);this.config=e,u1(this,d2,[]),u1(this,er,0)}build(e,a,r){const n=new O31({mutationCache:this,mutationId:++Cr(this,er)._,options:e.defaultMutationOptions(a),state:r});return this.add(n),n}add(e){B(this,d2).push(e),this.notify({type:"added",mutation:e})}remove(e){u1(this,d2,B(this,d2).filter(a=>a!==e)),this.notify({type:"removed",mutation:e})}clear(){zt.batch(()=>{B(this,d2).forEach(e=>{this.remove(e)})})}getAll(){return B(this,d2)}find(e){const a={exact:!0,...e};return B(this,d2).find(r=>tf(a,r))}findAll(e={}){return B(this,d2).filter(a=>tf(e,a))}notify(e){zt.batch(()=>{this.listeners.forEach(a=>{a(e)})})}resumePausedMutations(){return u1(this,Ue,(B(this,Ue)??Promise.resolve()).then(()=>{const e=B(this,d2).filter(a=>a.state.isPaused);return zt.batch(()=>e.reduce((a,r)=>a.then(()=>r.continue().catch(g2)),Promise.resolve()))}).then(()=>{u1(this,Ue,void 0)})),B(this,Ue)}},d2=new WeakMap,er=new WeakMap,Ue=new WeakMap,pf);function C31(t){return{onFetch:(e,a)=>{const r=async()=>{var p,f,z,M,m;const n=e.options,l=(z=(f=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:z.direction,i=((M=e.state.data)==null?void 0:M.pages)||[],o=((m=e.state.data)==null?void 0:m.pageParams)||[],c={pages:[],pageParams:[]};let v=!1;const h=V=>{Object.defineProperty(V,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},s=e.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${e.options.queryHash}'`))),u=async(V,b,w)=>{if(v)return Promise.reject();if(b==null&&V.pages.length)return Promise.resolve(V);const y={queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};h(y);const x=await s(y),{maxPages:L}=e.options,S=w?m31:M31;return{pages:S(V.pages,x,L),pageParams:S(V.pageParams,b,L)}};let g;if(l&&i.length){const V=l==="backward",b=V?B31:nf,w={pages:i,pageParams:o},y=b(n,w);g=await u(w,y,V)}else{g=await u(c,o[0]??n.initialPageParam);const V=t??i.length;for(let b=1;b<V;b++){const w=nf(n,g);g=await u(g,w)}}return g};e.options.persister?e.fetchFn=()=>{var n,l;return(l=(n=e.options).persister)==null?void 0:l.call(n,r,{queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},a)}:e.fetchFn=r}}}function nf(t,{pages:e,pageParams:a}){const r=e.length-1;return t.getNextPageParam(e[r],e,a[r],a)}function B31(t,{pages:e,pageParams:a}){var r;return(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,a[0],a)}var ft,ue,ge,Fa,qa,fe,Wa,Ka,zf,A31=(zf=class{constructor(t={}){z1(this,ft,void 0);z1(this,ue,void 0);z1(this,ge,void 0);z1(this,Fa,void 0);z1(this,qa,void 0);z1(this,fe,void 0);z1(this,Wa,void 0);z1(this,Ka,void 0);u1(this,ft,t.queryCache||new L31),u1(this,ue,t.mutationCache||new S31),u1(this,ge,t.defaultOptions||{}),u1(this,Fa,new Map),u1(this,qa,new Map),u1(this,fe,0)}mount(){Cr(this,fe)._++,B(this,fe)===1&&(u1(this,Wa,pi.subscribe(()=>{pi.isFocused()&&(this.resumePausedMutations(),B(this,ft).onFocus())})),u1(this,Ka,zi.subscribe(()=>{zi.isOnline()&&(this.resumePausedMutations(),B(this,ft).onOnline())})))}unmount(){var t,e;Cr(this,fe)._--,B(this,fe)===0&&((t=B(this,Wa))==null||t.call(this),u1(this,Wa,void 0),(e=B(this,Ka))==null||e.call(this),u1(this,Ka,void 0))}isFetching(t){return B(this,ft).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return B(this,ue).findAll({...t,status:"pending"}).length}getQueryData(t){var e;return(e=B(this,ft).find({queryKey:t}))==null?void 0:e.state.data}ensureQueryData(t){const e=this.getQueryData(t.queryKey);return e!==void 0?Promise.resolve(e):this.fetchQuery(t)}getQueriesData(t){return this.getQueryCache().findAll(t).map(({queryKey:e,state:a})=>{const r=a.data;return[e,r]})}setQueryData(t,e,a){const r=B(this,ft).find({queryKey:t}),n=r==null?void 0:r.state.data,l=z31(e,n);if(typeof l>"u")return;const i=this.defaultQueryOptions({queryKey:t});return B(this,ft).build(this,i).setData(l,{...a,manual:!0})}setQueriesData(t,e,a){return zt.batch(()=>this.getQueryCache().findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,a)]))}getQueryState(t){var e;return(e=B(this,ft).find({queryKey:t}))==null?void 0:e.state}removeQueries(t){const e=B(this,ft);zt.batch(()=>{e.findAll(t).forEach(a=>{e.remove(a)})})}resetQueries(t,e){const a=B(this,ft),r={type:"active",...t};return zt.batch(()=>(a.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries(r,e)))}cancelQueries(t={},e={}){const a={revert:!0,...e},r=zt.batch(()=>B(this,ft).findAll(t).map(n=>n.cancel(a)));return Promise.all(r).then(g2).catch(g2)}invalidateQueries(t={},e={}){return zt.batch(()=>{if(B(this,ft).findAll(t).forEach(r=>{r.invalidate()}),t.refetchType==="none")return Promise.resolve();const a={...t,type:t.refetchType??t.type??"active"};return this.refetchQueries(a,e)})}refetchQueries(t={},e){const a={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0},r=zt.batch(()=>B(this,ft).findAll(t).filter(n=>!n.isDisabled()).map(n=>{let l=n.fetch(void 0,a);return a.throwOnError||(l=l.catch(g2)),n.state.fetchStatus==="paused"?Promise.resolve():l}));return Promise.all(r).then(g2)}fetchQuery(t){const e=this.defaultQueryOptions(t);typeof e.retry>"u"&&(e.retry=!1);const a=B(this,ft).build(this,e);return a.isStaleByTime(e.staleTime)?a.fetch(e):Promise.resolve(a.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(g2).catch(g2)}fetchInfiniteQuery(t){return t.behavior=C31(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g2).catch(g2)}resumePausedMutations(){return B(this,ue).resumePausedMutations()}getQueryCache(){return B(this,ft)}getMutationCache(){return B(this,ue)}getDefaultOptions(){return B(this,ge)}setDefaultOptions(t){u1(this,ge,t)}setQueryDefaults(t,e){B(this,Fa).set(X0(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...B(this,Fa).values()];let a={};return e.forEach(r=>{_0(t,r.queryKey)&&(a={...a,...r.defaultOptions})}),a}setMutationDefaults(t,e){B(this,qa).set(X0(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...B(this,qa).values()];let a={};return e.forEach(r=>{_0(t,r.mutationKey)&&(a={...a,...r.defaultOptions})}),a}defaultQueryOptions(t){if(t!=null&&t._defaulted)return t;const e={...B(this,ge).queries,...(t==null?void 0:t.queryKey)&&this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Rh(e.queryKey,e)),typeof e.refetchOnReconnect>"u"&&(e.refetchOnReconnect=e.networkMode!=="always"),typeof e.throwOnError>"u"&&(e.throwOnError=!!e.suspense),typeof e.networkMode>"u"&&e.persister&&(e.networkMode="offlineFirst"),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...B(this,ge).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){B(this,ft).clear(),B(this,ue).clear()}},ft=new WeakMap,ue=new WeakMap,ge=new WeakMap,Fa=new WeakMap,qa=new WeakMap,fe=new WeakMap,Wa=new WeakMap,Ka=new WeakMap,zf),Ut,Q1,Ua,It,Ze,Za,I2,ar,Ga,Ja,Ge,Je,pe,Ye,Qe,k0,rr,Xc,nr,_c,lr,$c,ir,t3,or,e3,cr,a3,hr,r3,Mi,bO,Mf,E31=(Mf=class extends s0{constructor(e,a){super();z1(this,Qe);z1(this,rr);z1(this,nr);z1(this,lr);z1(this,ir);z1(this,or);z1(this,cr);z1(this,hr);z1(this,Mi);z1(this,Ut,void 0);z1(this,Q1,void 0);z1(this,Ua,void 0);z1(this,It,void 0);z1(this,Ze,void 0);z1(this,Za,void 0);z1(this,I2,void 0);z1(this,ar,void 0);z1(this,Ga,void 0);z1(this,Ja,void 0);z1(this,Ge,void 0);z1(this,Je,void 0);z1(this,pe,void 0);z1(this,Ye,void 0);u1(this,Q1,void 0),u1(this,Ua,void 0),u1(this,It,void 0),u1(this,Ye,new Set),u1(this,Ut,e),this.options=a,u1(this,I2,null),this.bindMethods(),this.setOptions(a)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(B(this,Q1).addObserver(this),lf(B(this,Q1),this.options)?C1(this,Qe,k0).call(this):this.updateResult(),C1(this,ir,t3).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return n3(B(this,Q1),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return n3(B(this,Q1),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,C1(this,or,e3).call(this),C1(this,cr,a3).call(this),B(this,Q1).removeObserver(this)}setOptions(e,a){const r=this.options,n=B(this,Q1);if(this.options=B(this,Ut).defaultQueryOptions(e),fi(r,this.options)||B(this,Ut).getQueryCache().notify({type:"observerOptionsUpdated",query:B(this,Q1),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=r.queryKey),C1(this,hr,r3).call(this);const l=this.hasListeners();l&&of(B(this,Q1),n,this.options,r)&&C1(this,Qe,k0).call(this),this.updateResult(a),l&&(B(this,Q1)!==n||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&C1(this,rr,Xc).call(this);const i=C1(this,nr,_c).call(this);l&&(B(this,Q1)!==n||this.options.enabled!==r.enabled||i!==B(this,pe))&&C1(this,lr,$c).call(this,i)}getOptimisticResult(e){const a=B(this,Ut).getQueryCache().build(B(this,Ut),e),r=this.createResult(a,e);return I31(this,r)&&(u1(this,It,r),u1(this,Za,this.options),u1(this,Ze,B(this,Q1).state)),r}getCurrentResult(){return B(this,It)}trackResult(e){const a={};return Object.keys(e).forEach(r=>{Object.defineProperty(a,r,{configurable:!1,enumerable:!0,get:()=>(B(this,Ye).add(r),e[r])})}),a}getCurrentQuery(){return B(this,Q1)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const a=B(this,Ut).defaultQueryOptions(e),r=B(this,Ut).getQueryCache().build(B(this,Ut),a);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,a))}fetch(e){return C1(this,Qe,k0).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),B(this,It)))}createResult(e,a){var y;const r=B(this,Q1),n=this.options,l=B(this,It),i=B(this,Ze),o=B(this,Za),v=e!==r?e.state:B(this,Ua),{state:h}=e;let{error:s,errorUpdatedAt:u,fetchStatus:g,status:p}=h,f=!1,z;if(a._optimisticResults){const x=this.hasListeners(),L=!x&&lf(e,a),S=x&&of(e,r,a,n);(L||S)&&(g=ao(e.options.networkMode)?"fetching":"paused",h.dataUpdatedAt||(p="pending")),a._optimisticResults==="isRestoring"&&(g="idle")}if(a.select&&typeof h.data<"u")if(l&&h.data===(i==null?void 0:i.data)&&a.select===B(this,ar))z=B(this,Ga);else try{u1(this,ar,a.select),z=a.select(h.data),z=Qc(l==null?void 0:l.data,z,a),u1(this,Ga,z),u1(this,I2,null)}catch(x){u1(this,I2,x)}else z=h.data;if(typeof a.placeholderData<"u"&&typeof z>"u"&&p==="pending"){let x;if(l!=null&&l.isPlaceholderData&&a.placeholderData===(o==null?void 0:o.placeholderData))x=l.data;else if(x=typeof a.placeholderData=="function"?a.placeholderData((y=B(this,Ja))==null?void 0:y.state.data,B(this,Ja)):a.placeholderData,a.select&&typeof x<"u")try{x=a.select(x),u1(this,I2,null)}catch(L){u1(this,I2,L)}typeof x<"u"&&(p="success",z=Qc(l==null?void 0:l.data,x,a),f=!0)}B(this,I2)&&(s=B(this,I2),z=B(this,Ga),u=Date.now(),p="error");const M=g==="fetching",m=p==="pending",V=p==="error",b=m&&M;return{status:p,fetchStatus:g,isPending:m,isSuccess:p==="success",isError:V,isInitialLoading:b,isLoading:b,data:z,dataUpdatedAt:h.dataUpdatedAt,error:s,errorUpdatedAt:u,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>v.dataUpdateCount||h.errorUpdateCount>v.errorUpdateCount,isFetching:M,isRefetching:M&&!m,isLoadingError:V&&h.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:f,isRefetchError:V&&h.dataUpdatedAt!==0,isStale:kh(e,a),refetch:this.refetch}}updateResult(e){const a=B(this,It),r=this.createResult(B(this,Q1),this.options);if(u1(this,Ze,B(this,Q1).state),u1(this,Za,this.options),B(this,Ze).data!==void 0&&u1(this,Ja,B(this,Q1)),fi(r,a))return;u1(this,It,r);const n={},l=()=>{if(!a)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!B(this,Ye).size)return!0;const c=new Set(o??B(this,Ye));return this.options.throwOnError&&c.add("error"),Object.keys(B(this,It)).some(v=>{const h=v;return B(this,It)[h]!==a[h]&&c.has(h)})};(e==null?void 0:e.listeners)!==!1&&l()&&(n.listeners=!0),C1(this,Mi,bO).call(this,{...n,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&C1(this,ir,t3).call(this)}},Ut=new WeakMap,Q1=new WeakMap,Ua=new WeakMap,It=new WeakMap,Ze=new WeakMap,Za=new WeakMap,I2=new WeakMap,ar=new WeakMap,Ga=new WeakMap,Ja=new WeakMap,Ge=new WeakMap,Je=new WeakMap,pe=new WeakMap,Ye=new WeakMap,Qe=new WeakSet,k0=function(e){C1(this,hr,r3).call(this);let a=B(this,Q1).fetch(this.options,e);return e!=null&&e.throwOnError||(a=a.catch(g2)),a},rr=new WeakSet,Xc=function(){if(C1(this,or,e3).call(this),r0||B(this,It).isStale||!Jc(this.options.staleTime))return;const a=pO(B(this,It).dataUpdatedAt,this.options.staleTime)+1;u1(this,Ge,setTimeout(()=>{B(this,It).isStale||this.updateResult()},a))},nr=new WeakSet,_c=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(B(this,Q1)):this.options.refetchInterval)??!1},lr=new WeakSet,$c=function(e){C1(this,cr,a3).call(this),u1(this,pe,e),!(r0||this.options.enabled===!1||!Jc(B(this,pe))||B(this,pe)===0)&&u1(this,Je,setInterval(()=>{(this.options.refetchIntervalInBackground||pi.isFocused())&&C1(this,Qe,k0).call(this)},B(this,pe)))},ir=new WeakSet,t3=function(){C1(this,rr,Xc).call(this),C1(this,lr,$c).call(this,C1(this,nr,_c).call(this))},or=new WeakSet,e3=function(){B(this,Ge)&&(clearTimeout(B(this,Ge)),u1(this,Ge,void 0))},cr=new WeakSet,a3=function(){B(this,Je)&&(clearInterval(B(this,Je)),u1(this,Je,void 0))},hr=new WeakSet,r3=function(){const e=B(this,Ut).getQueryCache().build(B(this,Ut),this.options);if(e===B(this,Q1))return;const a=B(this,Q1);u1(this,Q1,e),u1(this,Ua,e.state),this.hasListeners()&&(a==null||a.removeObserver(this),e.addObserver(this))},Mi=new WeakSet,bO=function(e){zt.batch(()=>{e.listeners&&this.listeners.forEach(a=>{a(B(this,It))}),B(this,Ut).getQueryCache().notify({query:B(this,Q1),type:"observerResultsUpdated"})})},Mf);function P31(t,e){return e.enabled!==!1&&!t.state.dataUpdatedAt&&!(t.state.status==="error"&&e.retryOnMount===!1)}function lf(t,e){return P31(t,e)||t.state.dataUpdatedAt>0&&n3(t,e,e.refetchOnMount)}function n3(t,e,a){if(e.enabled!==!1){const r=typeof a=="function"?a(t):a;return r==="always"||r!==!1&&kh(t,e)}return!1}function of(t,e,a,r){return a.enabled!==!1&&(t!==e||r.enabled===!1)&&(!a.suspense||t.state.status!=="error")&&kh(t,a)}function kh(t,e){return t.isStaleByTime(e.staleTime)}function I31(t,e){return!fi(t.getCurrentResult(),e)}var ze,Dt,u2,Y2,Ya,E4,sr,l3,mf,R31=(mf=class extends s0{constructor(a,r){super();z1(this,Ya);z1(this,sr);z1(this,ze,void 0);z1(this,Dt,void 0);z1(this,u2,void 0);z1(this,Y2,void 0);u1(this,Dt,void 0),u1(this,ze,a),this.setOptions(r),this.bindMethods(),C1(this,Ya,E4).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(a){var n;const r=this.options;this.options=B(this,ze).defaultMutationOptions(a),fi(r,this.options)||B(this,ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:B(this,u2),observer:this}),(n=B(this,u2))==null||n.setOptions(this.options)}onUnsubscribe(){var a;this.hasListeners()||(a=B(this,u2))==null||a.removeObserver(this)}onMutationUpdate(a){C1(this,Ya,E4).call(this),C1(this,sr,l3).call(this,a)}getCurrentResult(){return B(this,Dt)}reset(){u1(this,u2,void 0),C1(this,Ya,E4).call(this),C1(this,sr,l3).call(this)}mutate(a,r){var n;return u1(this,Y2,r),(n=B(this,u2))==null||n.removeObserver(this),u1(this,u2,B(this,ze).getMutationCache().build(B(this,ze),this.options)),B(this,u2).addObserver(this),B(this,u2).execute(a)}},ze=new WeakMap,Dt=new WeakMap,u2=new WeakMap,Y2=new WeakMap,Ya=new WeakSet,E4=function(){var r;const a=((r=B(this,u2))==null?void 0:r.state)??wO();u1(this,Dt,{...a,isPending:a.status==="pending",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset})},sr=new WeakSet,l3=function(a){zt.batch(()=>{var r,n,l,i,o,c,v,h;B(this,Y2)&&this.hasListeners()&&((a==null?void 0:a.type)==="success"?((n=(r=B(this,Y2)).onSuccess)==null||n.call(r,a.data,B(this,Dt).variables,B(this,Dt).context),(i=(l=B(this,Y2)).onSettled)==null||i.call(l,a.data,null,B(this,Dt).variables,B(this,Dt).context)):(a==null?void 0:a.type)==="error"&&((c=(o=B(this,Y2)).onError)==null||c.call(o,a.error,B(this,Dt).variables,B(this,Dt).context),(h=(v=B(this,Y2)).onSettled)==null||h.call(v,void 0,a.error,B(this,Dt).variables,B(this,Dt).context))),this.listeners.forEach(s=>{s(B(this,Dt))})})},mf);var yO=O.createContext(void 0),n2=t=>{const e=O.useContext(yO);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},k31=({client:t,children:e})=>(O.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),O.createElement(yO.Provider,{value:t},e)),xO=O.createContext(!1),N31=()=>O.useContext(xO),Yh1=xO.Provider;function T31(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var j31=O.createContext(T31()),D31=()=>O.useContext(j31);function LO(t,e){return typeof t=="function"?t(...e):!!t}var F31=(t,e)=>{(t.suspense||t.throwOnError)&&(e.isReset()||(t.retryOnMount=!1))},q31=t=>{O.useEffect(()=>{t.clearReset()},[t])},W31=({result:t,errorResetBoundary:e,throwOnError:a,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&LO(a,[t.error,r]);var K31=t=>{t.suspense&&typeof t.staleTime!="number"&&(t.staleTime=1e3)};var U31=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Z31=(t,e,a)=>e.fetchOptimistic(t).catch(()=>{a.clearReset()});function G31(t,e,a){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))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 r=n2(a),n=N31(),l=D31(),i=r.defaultQueryOptions(t);i._optimisticResults=n?"isRestoring":"optimistic",K31(i),F31(i,l),q31(l);const[o]=O.useState(()=>new e(r,i)),c=o.getOptimisticResult(i);if(O.useSyncExternalStore(O.useCallback(v=>{const h=n?()=>{}:o.subscribe(zt.batchCalls(v));return o.updateResult(),h},[o,n]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),O.useEffect(()=>{o.setOptions(i,{listeners:!1})},[i,o]),U31(i,c))throw Z31(i,o,l);if(W31({result:c,errorResetBoundary:l,throwOnError:i.throwOnError,query:o.getCurrentQuery()}))throw c.error;return i.notifyOnChangeProps?c:o.trackResult(c)}function Lr(t,e){return G31(t,E31,e)}function S2(t,e){const a=n2(e),[r]=O.useState(()=>new R31(a,t));O.useEffect(()=>{r.setOptions(t)},[r,t]);const n=O.useSyncExternalStore(O.useCallback(i=>r.subscribe(zt.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),l=O.useCallback((i,o)=>{r.mutate(i,o).catch(J31)},[r]);if(n.error&&LO(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:l,mutateAsync:n.mutate}}function J31(){}function Nt(){return n2().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const Se=()=>{const{data:t,refetch:e}=Lr({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[t,a=>{a&&(localStorage.setItem("currentPage",a||""),e())}]};let cf="";const Or=()=>(cf=localStorage.getItem("__chai_at"),cf);function Y31(t){const e={method:"GET",headers:{"x-chai-access-token":Or()}};return fetch(t,e)}function Q31(t,e){const a={method:"POST",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}function X31(t,e){const a={method:"PUT",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}function _31(t,e){const a={method:"DELETE",headers:{"x-chai-access-token":Or()},body:JSON.stringify(e)};return fetch(t,a)}const l2={get:Y31,post:Q31,put:X31,delete:_31},Nh=()=>{const[t,e]=Se(),a=Nt();return Lr({queryKey:["project"],queryFn:async()=>{const{data:r}=await l2.get(`${a}/project`).then(n=>n.json());if(!t&&r){const n=localStorage.getItem("currentPage");e(n||(r==null?void 0:r.homepage))}return r}})},Th=()=>{const t=Nt();return Lr({queryKey:["pages"],queryFn:async()=>{const{data:e}=await l2.get(`${t}/pages`).then(a=>a.json());return e||[]}})},OO=()=>{const[t]=Se(),e=Nt();return Lr({queryKey:["page_data",t],queryFn:async()=>{const{data:a}=await l2.get(`${e}/page?uuid=${t}`).then(r=>r.json());return a},enabled:!!t,staleTime:3e3})},i3=()=>r1.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:r1.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[r1.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),r1.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),r1.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),SO=(t="Project updated successfully.")=>{const e=n2(),a=Nt();return S2({mutationFn:async r=>await l2.put(`${a}/project`,r).then(n=>n.json()),onSuccess:()=>{e.invalidateQueries({queryKey:["project"]}),F2.toast.success(t)}})},CO=()=>{const[t]=["SAVED"],[e,a]=Se(),r=o1.useBuilderReset();return n=>t!=="SAVED"?(F2.toast.error("You have unsaved changes. Please save before changing the page."),!1):e===n.uuid?!1:(r(),setTimeout(()=>{a(n.uuid)},100),!0)},$31=()=>{const t=n2(),e=CO(),a=Nt();return S2({mutationFn:async r=>l2.post(`${a}/pages`,r).then(n=>n.json()),onSuccess:r=>{t.invalidateQueries({queryKey:["pages"]}),e({uuid:r.uuid,slug:r.slug}),F2.toast.success("Page added successfully.")}})},BO=()=>{const t=Nt(),[e]=Se(),a=n2();return S2({mutationFn:async r=>l2.put(`${t}/page`,r).then(n=>n.json()),onSuccess:async r=>{var n;if(r.result==="error"&&((n=r.error)==null?void 0:n.code)=="PAGE_LOCKED"){a.invalidateQueries({queryKey:["page_data",e]});return}F2.toast.success("Page saved successfully.")}})},th1=()=>{const t=Nt(),{data:e}=Th(),[a]=Se(),{data:r}=Nh(),n=n2();return S2({mutationFn:async()=>{const l=e.find(i=>i.uuid===a).slug;return await l2.post(`${t}/publish`,{slug:l,uuid:a,isHomepage:(r==null?void 0:r.homepage)===a}).then(i=>i.json())},onSuccess:async l=>{var i;if(l.result==="error"&&((i=l.error)==null?void 0:i.code)=="PAGE_LOCKED"){n.invalidateQueries({queryKey:["page_data",a]});return}F2.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},eh1=()=>{const t=n2(),e=Nt();return S2({mutationFn:async a=>l2.delete(`${e}/page`,a).then(r=>r.json()),onSuccess:()=>{F2.toast.success("Page deleted successfully."),t.invalidateQueries({queryKey:["pages"]})}})},ah1=()=>{const t=n2(),e=Nt();return S2({mutationFn:async a=>l2.post(`${e}/take-control`,{uuid:a}).then(r=>r.json()),onSuccess:(a,r)=>{t.invalidateQueries({queryKey:["page_data",r]})}})},rh1=()=>{const t=Nt();return S2({mutationFn:async()=>{const{data:e}=await l2.get(`${t}/library`).then(a=>a.json());return rt.sortBy(rt.filter(e,a=>!rt.has(a,"hidden")),"group")}})},nh1=()=>{const t=Nt();return S2({mutationFn:async e=>{if(!e||!e.uuid)return[];try{const{data:a}=await l2.get(`${t}/block?uuid=${e.uuid}&format=${e.format}`).then(async r=>e.format==="html"?qO.getBlocksFromHTML(await r.text()):await r.json());return rt.set(a,"0._name",rt.capitalize(e.group)),a||[]}catch{return[]}}})},lh1=()=>{const t=Nt();return S2({mutationFn:async e=>{const a=new FormData;a.append("file",e);const{data:r}=await fetch(`${t}/upload`,{method:"POST",headers:{"x-chai-access-token":Or()},body:a}).then(n=>n.json());return r}})};var AO={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},hf=d.createContext&&d.createContext(AO),we=function(){return we=Object.assign||function(t){for(var e,a=1,r=arguments.length;a<r;a++){e=arguments[a];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},we.apply(this,arguments)},ih1=function(t,e){var a={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(a[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(a[r[n]]=t[r[n]]);return a};function EO(t){return t&&t.map(function(e,a){return d.createElement(e.tag,we({key:a},e.attr),EO(e.child))})}function PO(t){return function(e){return d.createElement(oh1,we({attr:we({},t.attr)},e),EO(t.child))}}function oh1(t){var e=function(a){var r=t.attr,n=t.size,l=t.title,i=ih1(t,["attr","size","title"]),o=n||a.size||"1em",c;return a.className&&(c=a.className),t.className&&(c=(c?c+" ":"")+t.className),d.createElement("svg",we({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,i,{className:c,style:we(we({color:t.color||a.color},a.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),l&&d.createElement("title",null,l),t.children)};return hf!==void 0?d.createElement(hf.Consumer,null,function(a){return e(a)}):e(AO)}function IO(t){return PO({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"}}]})(t)}function ch1(t){return PO({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}}]})(t)}const hh1=()=>{const{mutate:t,isPending:e}=ah1(),[a]=Se(),{data:r}=OO(),n=rt.get(r,"lockedBy.name",""),l=rt.get(r,"lockedBy.email","");return r1.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[r1.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),r1.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",r1.jsxRuntimeExports.jsx("br",{}),r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[r1.jsxRuntimeExports.jsx(ch1,{className:"w-4 h-4 text-gray-500"})," ",n]}),r1.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[r1.jsxRuntimeExports.jsx(IO,{className:"w-4 h-4 text-gray-500"})," ",l]})]}),r1.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",n," will be ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),r1.jsxRuntimeExports.jsx(o1.Button,{disabled:e,onClick:()=>t(a),className:`w-36 ${e?"bg-transparent shadow-none hover:bg-transparent":""}`,children:e?r1.jsxRuntimeExports.jsx(o3.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},sh1=()=>{const t=Nt(),e=n2();return S2({mutationFn:async a=>{const r=await fetch(`${t}/login`,{method:"POST",body:JSON.stringify(a)});if(r.ok)return await r.json();throw r.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:a=>{const{data:r}=a;if(!r.accessToken){F2.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",r.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(rt.omit(r,["accessToken"]))),e.invalidateQueries({queryKey:["verify"]}),F2.toast.success("Logged in successfully.")},onError:()=>{F2.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},vh1=()=>{const t=Nt();return Lr({queryKey:["verify"],queryFn:async()=>{const e=await l2.get(`${t}/verify`);return e.ok?(await e.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},dh1=()=>{const t=Nt(),e=n2();return S2({mutationFn:async()=>{const{result:a}=await l2.post(`${t}/logout`).then(r=>r.json());if(a==="success")return localStorage.clear(),e.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},uh1=({children:t})=>{const e=dh1();return r1.jsxRuntimeExports.jsxs(o1.AlertDialog,{children:[r1.jsxRuntimeExports.jsx(o1.AlertDialogTrigger,{asChild:!0,children:t}),r1.jsxRuntimeExports.jsxs(o1.AlertDialogContent,{children:[r1.jsxRuntimeExports.jsxs(o1.AlertDialogHeader,{children:[r1.jsxRuntimeExports.jsxs(o1.AlertDialogTitle,{children:["Are you sure, you want to ",r1.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),r1.jsxRuntimeExports.jsx(o1.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),r1.jsxRuntimeExports.jsxs(o1.AlertDialogFooter,{children:[r1.jsxRuntimeExports.jsx(o1.AlertDialogCancel,{disabled:e.isPending,children:"Cancel"}),r1.jsxRuntimeExports.jsxs("button",{disabled:e.isPending,onClick:()=>e.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[e.isPending&&r1.jsxRuntimeExports.jsx(o3.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},gh1=()=>r1.jsxRuntimeExports.jsx(uh1,{children:r1.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:r1.jsxRuntimeExports.jsx(o3.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),fh1=d.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-BeJrveus.cjs"))),ph1=d.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-MjcAymKT.cjs"))),zh1=d.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-zxrdTVsG.cjs"))),Mh1=()=>r1.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),mh1=()=>{const{mutate:t}=th1();return o1.useBuilderProp("editable",!0)?r1.jsxRuntimeExports.jsx(o1.Button,{onClick:t,className:"bg-blue-600 text-white",children:"Publish"}):null},Hh1=t=>{const{data:e,isLoading:a}=Nh(),{data:r,isLoading:n}=Th(),{data:l}=OO(),{mutate:i}=SO(),{mutate:o}=BO(),[c]=Se(),v=lh1(),h=rh1(),s=nh1(),u=Nt(),g=d.useCallback(async m=>await v.mutateAsync(m),[v]),p=d.useCallback(async()=>await h.mutateAsync(),[h]),f=d.useCallback(async m=>await s.mutateAsync(m),[s]),z=async(m=20,V=0)=>{const b=`limit=${m}&offset=${V}`,w=await fetch(`${u}/assets?${b}`).then(y=>y.json());return w.result==="success"?w.data:[]},{logo:M=Mh1}=t;return a||!e?r1.jsxRuntimeExports.jsx(i3,{}):n||!r?r1.jsxRuntimeExports.jsx(i3,{}):r1.jsxRuntimeExports.jsx("div",{className:"bg-background text-foreground",children:r1.jsxRuntimeExports.jsx(fO,{editable:l!=null&&l.lockedBy?l==null?void 0:l.lockedBy.self:!0,nonEditableComponent:hh1,blocks:(l==null?void 0:l.blocks)||[],brandingOptions:e.brandingOptions,darkMode:t.darkMode||!1,dataProviders:(l==null?void 0:l.providers)||[],onSavePage:async({blocks:m,providers:V})=>(await o({blocks:m,providers:V,uuid:c}),!0),onSaveBrandingOptions:async m=>(await i({brandingOptions:m}),!0),topBarComponents:{left:[M],center:[zh1],right:[mh1]},sideBarComponents:{top:[{icon:P4.FileTextIcon,name:"pages",panel:fh1},{icon:P4.GearIcon,name:"settings",panel:ph1}],bottom:[gh1]},uploadMediaCallback:g,fetchMediaCallback:z,getUILibraryBlocks:p,getExternalPredefinedBlock:f,getPages:()=>r,unsplashAccessKey:t.unsplashAccessKey||""})})},Vh1=({logo:t})=>{const[e,a]=d.useState(!1),[r,n]=d.useState(""),[l,i]=d.useState(""),{mutate:o,isPending:c}=sh1(),v=h=>{h.preventDefault(),o({email:r,password:l})};return r1.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:r1.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:r1.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[r1.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[r1.jsxRuntimeExports.jsx(d.Suspense,{children:t?d.createElement(t):""}),r1.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),r1.jsxRuntimeExports.jsx("div",{className:"mt-8",children:r1.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:v,className:"space-y-5",children:[r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[r1.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r1.jsxRuntimeExports.jsx(IO,{})}),r1.jsxRuntimeExports.jsx("input",{value:r,onChange:h=>n(h.target.value),type:"email",id:"email",placeholder:"Enter email",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"})]})}),r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[r1.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r1.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:r1.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"})})}),r1.jsxRuntimeExports.jsx("input",{value:l,onChange:h=>i(h.target.value),type:e?"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"}),r1.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>a(!e),children:e?r1.jsxRuntimeExports.jsx(P4.EyeClosedIcon,{}):r1.jsxRuntimeExports.jsx(P4.EyeOpenIcon,{})})]})}),r1.jsxRuntimeExports.jsx("div",{children:r1.jsxRuntimeExports.jsx("button",{disabled:c||rt.size(r)<2||rt.size(l)<2,type:"submit",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:c?"Signing in...":"Login"})})]})}),r1.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:r1.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},wh1=t=>{const{data:e,isLoading:a}=vh1(),r=n2();return d.useEffect(()=>{r.setQueryData(["apiBaseUrl"],t.apiBaseUrl||"/api/chaibuilder")},[t.apiBaseUrl,r]),a?r1.jsxRuntimeExports.jsx(i3,{}):e!=null&&e.valid?r1.jsxRuntimeExports.jsx(Hh1,{...t}):r1.jsxRuntimeExports.jsx(Vh1,{logo:t.logo})},bh1=new A31,yh1=t=>r1.jsxRuntimeExports.jsxs(k31,{client:bh1,children:[r1.jsxRuntimeExports.jsx(F2.Toaster,{richColors:!0}),r1.jsxRuntimeExports.jsx(wh1,{...t})]});exports.BlocksExternalDataProvider=c31;exports.ChaiBuilderEditor=fO;exports.ChaiBuilderStudio=yh1;exports.ErrorBoundary=dO;exports.reactIsExports=Pf;exports.useAddPage=$31;exports.useChaiExternalData=gO;exports.useChangePage=CO;exports.useCurrentPage=Se;exports.useDeletePage=eh1;exports.useExpandedIds=i31;exports.usePages=Th;exports.useProject=Nh;exports.useQueryClient=n2;exports.useUpdatePage=BO;exports.useUpdateProject=SO;
@@ -20,7 +20,7 @@ import { initReactI18next as oS } from "react-i18next";
20
20
  import { j as n1 } from "./jsx-runtime-NV737rRe.js";
21
21
  import * as O from "react";
22
22
  import p, { useState as g1, useRef as z1, useLayoutEffect as L3, useEffect as L1, useCallback as D1, useDebugValue as o91, useContext as Et, forwardRef as Q, createContext as $t, useReducer as cS, useMemo as fa, cloneElement as Ae, Fragment as hS, Children as br, Component as Ff, isValidElement as sS, createElement as G4, memo as vS, Suspense as Ue, lazy as v0 } from "react";
23
- import { u as O3, a as h2, c as qf, b as wt, d as Pe, e as s2, f as d0, g as Wf, h as dS, i as J4, B as S3, S as uS, j as Kf, k as gS, l as fS, m as pS, n as zS, o as MS, p as mS, q as HS, r as VS, s as wS, t as bS, v as yS, T as xS, w as LS, x as OS, y as Uf, z as SS, A as CS, C as BS, D as AS, E as PS, F as ES, G as IS, H as kS, I as NS, J as RS, K as TS } from "./index-89A3jPHh.js";
23
+ import { u as O3, a as h2, c as qf, b as wt, d as Pe, e as s2, f as d0, g as Wf, h as dS, i as J4, B as S3, S as uS, j as Kf, k as gS, l as fS, m as pS, n as zS, o as MS, p as mS, q as HS, r as VS, s as wS, t as bS, v as yS, T as xS, w as LS, x as OS, y as Uf, z as SS, A as CS, C as BS, D as AS, E as PS, F as ES, G as IS, H as kS, I as NS, J as RS, K as TS } from "./index-0OqmBgqo.js";
24
24
  import { g as Ii, c as j0 } from "./MODIFIERS-MLfpKQY1.js";
25
25
  import Zf from "clsx";
26
26
  import { flushSync as DS, createPortal as jS } from "react-dom";
@@ -30,14 +30,14 @@ import US from "react-textarea-autosize";
30
30
  import { useAtom as ki, atom as ZS, useAtomValue as Xf, getDefaultStore as GS } from "jotai";
31
31
  import { FlagsProvider as JS } from "flagged";
32
32
  import { DndProvider as YS } from "react-dnd";
33
- import { find as Bc, get as Ac, isString as _f, isEmpty as QS, flatten as XS, first as _S, each as ls, omit as $f, sortBy as $S, filter as tC, has as eC, set as aC, capitalize as rC, size as is } from "lodash";
33
+ import { j as Bc, g as Ac, i as _f, a as QS, n as XS, h as _S, f as ls, o as $f, q as $S, b as tC, t as eC, s as aC, u as rC, v as is } from "./lodash-3gkdNK5u.js";
34
34
  import { MultiBackend as nC, getBackendOptions as lC } from "@minoru/react-dnd-treeview";
35
- import { d as iC } from "./utils-zWMk4dB2.js";
35
+ import { d as iC } from "./utils-XsPKXMVo.js";
36
36
  import { useHotkeys as se } from "react-hotkeys-hook";
37
37
  import { getChaiDataProviders as oC, syncBlocksWithDefaults as cC } from "@chaibuilder/runtime";
38
38
  import { FileTextIcon as hC, GearIcon as sC, EyeClosedIcon as vC, EyeOpenIcon as dC } from "@radix-ui/react-icons";
39
39
  import { toast as ae, Toaster as uC } from "sonner";
40
- import { g as gC } from "./html-to-json-kGgp07Hv.js";
40
+ import { g as gC } from "./html-to-json-Y5M0N8PH.js";
41
41
  import { Loader as fC, Loader2 as pC, LogOutIcon as zC } from "lucide-react";
42
42
  const MC = "Dark mode", mC = "This page has no blocks. Add a block by clicking the + button", HC = "This page is empty", VC = "Please select a block to edit settings or styles", wC = "Please select a styling block", bC = "Drop your block here", yC = {
43
43
  dark_mode: MC,
@@ -38598,7 +38598,7 @@ const Eh1 = () => {
38598
38598
  e((l) => (delete l[n.providerKey], l));
38599
38599
  });
38600
38600
  }), [r, a, e]), /* @__PURE__ */ n1.jsx(n1.Fragment, { children: t });
38601
- }, Dh1 = v0(() => import("./SidePanels-iRXV69vh.js")), jh1 = v0(() => import("./Topbar-dQYhW4iv.js")), Fh1 = v0(() => import("./CanvasArea-chEYQhH8.js")), qh1 = v0(() => import("./Settings-lpoxaMDu.js")), Wh1 = () => {
38601
+ }, Dh1 = v0(() => import("./SidePanels-4lvmnnlw.js")), jh1 = v0(() => import("./Topbar-_-1HX-EE.js")), Fh1 = v0(() => import("./CanvasArea-U3egqewu.js")), qh1 = v0(() => import("./Settings-LZJwbkO6.js")), Wh1 = () => {
38602
38602
  const [t] = ki(bS), e = (n) => {
38603
38603
  yS() || n.preventDefault();
38604
38604
  };
@@ -40728,7 +40728,7 @@ const Fs1 = () => {
40728
40728
  ] })
40729
40729
  ] })
40730
40730
  ] });
40731
- }, Zs1 = () => /* @__PURE__ */ n1.jsx(Us1, { children: /* @__PURE__ */ n1.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ n1.jsx(zC, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), Gs1 = v0(() => import("./PagesPanel-ay4uk4mg.js")), Js1 = v0(() => import("./ProjectPanel-eLlbfAtj.js")), Ys1 = v0(() => import("./CurrentPage-Wd7F9Egg.js")), Qs1 = () => /* @__PURE__ */ n1.jsx("h2", { children: "Your Logo" }), Xs1 = () => {
40731
+ }, Zs1 = () => /* @__PURE__ */ n1.jsx(Us1, { children: /* @__PURE__ */ n1.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ n1.jsx(zC, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), Gs1 = v0(() => import("./PagesPanel--LI-BoSj.js")), Js1 = v0(() => import("./ProjectPanel-VNj0jXca.js")), Ys1 = v0(() => import("./CurrentPage-spjJpQSM.js")), Qs1 = () => /* @__PURE__ */ n1.jsx("h2", { children: "Your Logo" }), Xs1 = () => {
40732
40732
  const { mutate: t } = Es1();
40733
40733
  return J4("editable", !0) ? /* @__PURE__ */ n1.jsx(S3, { onClick: t, className: "bg-blue-600 text-white", children: "Publish" }) : null;
40734
40734
  }, _s1 = (t) => {