@chaibuilder/pages 0.1.0-beta.63 → 0.1.0-beta.64

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.
@@ -27,5 +27,5 @@ Check the top-level render call using <`+w+">.")}return x}}function es(c,x){{if(
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,wn,$e,Ar,$e),ns[$e+wn]=!0}}return c===s?Sr(ue):br(ue),ue}}function wr(c,x,w){return ss(c,x,w,!0)}function Cr(c,x,w){return ss(c,x,w,!1)}var Tr=Cr,jr=wr;Ct.Fragment=s,Ct.jsx=Tr,Ct.jsxs=jr}()),Ct}process.env.NODE_ENV==="production"?Pn.exports=kr():Pn.exports=Lr();var r=Pn.exports,W={context:void 0,registry:void 0,getContextId(){return ls(this.context.count)},getNextContextId(){return ls(this.context.count++)}};function ls(e){const t=String(e),n=t.length-1;return W.context.id+(n?String.fromCharCode(96+n):"")+t}function Tt(e){W.context=e}var Dr=(e,t)=>e===t,en=Symbol("solid-proxy"),Fn=Symbol("solid-track"),tn={equals:Dr},Ss=Ns,Ue=1,nn=2,ws={owned:null,cleanups:null,context:null,owner:null},Cn={},Y=null,Tn=null,Ir=null,ne=null,ye=null,Ge=null,cn=0;function Be(e,t){const n=ne,s=Y,a=e.length===0,i=t===void 0?s:t,o=a?ws:{owned:null,cleanups:null,context:i?i.context:null,owner:i},l=a?e:()=>e(()=>me(()=>dn(o)));Y=o,ne=null;try{return Ie(l,!0)}finally{ne=n,Y=s}}function le(e,t){t=t?Object.assign({},tn,t):tn;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=a=>(typeof a=="function"&&(a=a(n.value)),As(n,a));return[js.bind(n),s]}function _n(e,t,n){const s=un(e,t,!0,Ue);yt(s)}function Fe(e,t,n){const s=un(e,t,!1,Ue);yt(s)}function qn(e,t,n){Ss=zr;const s=un(e,t,!1,Ue);(!n||!n.render)&&(s.user=!0),Ge?Ge.push(s):yt(s)}function Ee(e,t,n){n=n?Object.assign({},tn,n):tn;const s=un(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,yt(s),js.bind(s)}function Or(e){return e&&typeof e=="object"&&"then"in e}function Gr(e,t,n){let s,a,i;arguments.length===2&&typeof t=="object"||arguments.length===1?(s=!0,a=e,i={}):(s=e,a=t,i={});let o=null,l=Cn,u=null,h=!1,y="initialValue"in i,g=typeof s=="function"&&Ee(s);const E=new Set,[j,k]=(i.storage||le)(i.initialValue),[O,S]=le(void 0),[p,b]=le(void 0,{equals:!1}),[A,V]=le(y?"ready":"unresolved");if(W.context){u=W.getNextContextId();let C;i.ssrLoadFrom==="initial"?l=i.initialValue:W.load&&(C=W.load(u))&&(l=C)}function R(C,q,ee,ve){return o===C&&(o=null,ve!==void 0&&(y=!0),(C===l||q===l)&&i.onHydrated&&queueMicrotask(()=>i.onHydrated(ve,{value:q})),l=Cn,Ce(q,ee)),q}function Ce(C,q){Ie(()=>{q===void 0&&k(()=>C),V(q!==void 0?"errored":y?"ready":"unresolved"),S(q);for(const ee of E.keys())ee.decrement();E.clear()},!1)}function ke(){const C=Vr,q=j(),ee=O();if(ee!==void 0&&!o)throw ee;return ne&&!ne.user&&C&&_n(()=>{p(),o&&(C.resolved||E.has(C)||(C.increment(),E.add(C)))}),q}function Te(C=!0){if(C!==!1&&h)return;h=!1;const q=g?g():s;if(q==null||q===!1){R(o,me(j));return}const ee=l!==Cn?l:me(()=>a(q,{value:j(),refetching:C}));return Or(ee)?(o=ee,"value"in ee?(ee.status==="success"?R(o,ee.value,void 0,q):R(o,void 0,kn(ee.value),q),ee):(h=!0,queueMicrotask(()=>h=!1),Ie(()=>{V(y?"refreshing":"pending"),b()},!1),ee.then(ve=>R(ee,ve,void 0,q),ve=>R(ee,void 0,kn(ve),q)))):(R(o,ee,void 0,q),ee)}return Object.defineProperties(ke,{state:{get:()=>A()},error:{get:()=>O()},loading:{get(){const C=A();return C==="pending"||C==="refreshing"}},latest:{get(){if(!y)return ke();const C=O();if(C&&!o)throw C;return j()}}}),g?_n(()=>Te(!1)):Te(!1),[ke,{refetch:Te,mutate:k}]}function Mr(e){return Ie(e,!1)}function me(e){if(ne===null)return e();const t=ne;ne=null;try{return e()}finally{ne=t}}function Ur(e,t,n){const s=Array.isArray(e);let a,i=n&&n.defer;return o=>{let l;if(s){l=Array(e.length);for(let h=0;h<e.length;h++)l[h]=e[h]()}else l=e();if(i)return i=!1,o;const u=me(()=>t(l,a,o));return a=l,u}}function Cs(e){qn(()=>me(e))}function mt(e){return Y===null||(Y.cleanups===null?Y.cleanups=[e]:Y.cleanups.push(e)),e}function cs(){return Y}function Rr(e,t){const n=Y,s=ne;Y=e,ne=null;try{return Ie(t,!0)}catch(a){Wn(a)}finally{Y=n,ne=s}}function Br(e){const t=ne,n=Y;return Promise.resolve().then(()=>{ne=t,Y=n;let s;return Ie(e,!1),ne=Y=null,s?s.done:void 0})}var[Fr,oo]=le(!1);function qr(){return[Fr,Br]}function Wr(e,t){const n=Symbol("context");return{id:n,Provider:Qr(n),defaultValue:e}}function Hr(e){let t;return Y&&Y.context&&(t=Y.context[e.id])!==void 0?t:e.defaultValue}function Ts(e){const t=Ee(e),n=Ee(()=>Ln(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}var Vr;function js(){if(this.sources&&this.state)if(this.state===Ue)yt(this);else{const e=ye;ye=null,Ie(()=>rn(this),!1),ye=e}if(ne){const e=this.observers?this.observers.length:0;ne.sources?(ne.sources.push(this),ne.sourceSlots.push(e)):(ne.sources=[this],ne.sourceSlots=[e]),this.observers?(this.observers.push(ne),this.observerSlots.push(ne.sources.length-1)):(this.observers=[ne],this.observerSlots=[ne.sources.length-1])}return this.value}function As(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&Ie(()=>{for(let a=0;a<e.observers.length;a+=1){const i=e.observers[a],o=Tn&&Tn.running;o&&Tn.disposed.has(i),(o?!i.tState:!i.state)&&(i.pure?ye.push(i):Ge.push(i),i.observers&&Ps(i)),o||(i.state=Ue)}if(ye.length>1e6)throw ye=[],new Error},!1)),t}function yt(e){if(!e.fn)return;dn(e);const t=cn;$r(e,e.value,t)}function $r(e,t,n){let s;const a=Y,i=ne;ne=Y=e;try{s=e.fn(t)}catch(o){return e.pure&&(e.state=Ue,e.owned&&e.owned.forEach(dn),e.owned=null),e.updatedAt=n+1,Wn(o)}finally{ne=i,Y=a}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?As(e,s):e.value=s,e.updatedAt=n)}function un(e,t,n,s=Ue,a){const i={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Y,context:Y?Y.context:null,pure:n};return Y===null||Y!==ws&&(Y.owned?Y.owned.push(i):Y.owned=[i]),i}function sn(e){if(e.state===0)return;if(e.state===nn)return rn(e);if(e.suspense&&me(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<cn);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===Ue)yt(e);else if(e.state===nn){const s=ye;ye=null,Ie(()=>rn(e,t[0]),!1),ye=s}}function Ie(e,t){if(ye)return e();let n=!1;t||(ye=[]),Ge?n=!0:Ge=[],cn++;try{const s=e();return Kr(n),s}catch(s){n||(Ge=null),ye=null,Wn(s)}}function Kr(e){if(ye&&(Ns(ye),ye=null),e)return;const t=Ge;Ge=null,t.length&&Ie(()=>Ss(t),!1)}function Ns(e){for(let t=0;t<e.length;t++)sn(e[t])}function zr(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:sn(s)}if(W.context){if(W.count){W.effects||(W.effects=[]),W.effects.push(...e.slice(0,n));return}else W.effects&&(e=[...W.effects,...e],n+=W.effects.length,delete W.effects);Tt()}for(t=0;t<n;t++)sn(e[t])}function rn(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const a=s.state;a===Ue?s!==t&&(!s.updatedAt||s.updatedAt<cn)&&sn(s):a===nn&&rn(s,t)}}}function Ps(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=nn,n.pure?ye.push(n):Ge.push(n),n.observers&&Ps(n))}}function dn(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),a=n.observers;if(a&&a.length){const i=a.pop(),o=n.observerSlots.pop();s<a.length&&(i.sourceSlots[o]=s,a[s]=i,n.observerSlots[s]=o)}}if(e.owned){for(t=e.owned.length-1;t>=0;t--)dn(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function kn(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Wn(e,t=Y){throw kn(e)}function Ln(e){if(typeof e=="function"&&!e.length)return Ln(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=Ln(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function Qr(e,t){return function(s){let a;return Fe(()=>a=me(()=>(Y.context={...Y.context,[e]:s.value},Ts(()=>s.children))),void 0),a}}var Dn=Symbol("fallback");function an(e){for(let t=0;t<e.length;t++)e[t]()}function Yr(e,t,n={}){let s=[],a=[],i=[],o=0,l=t.length>1?[]:null;return mt(()=>an(i)),()=>{let u=e()||[],h=u.length,y,g;return u[Fn],me(()=>{let j,k,O,S,p,b,A,V,R;if(h===0)o!==0&&(an(i),i=[],s=[],a=[],o=0,l&&(l=[])),n.fallback&&(s=[Dn],a[0]=Be(Ce=>(i[0]=Ce,n.fallback())),o=1);else if(o===0){for(a=new Array(h),g=0;g<h;g++)s[g]=u[g],a[g]=Be(E);o=h}else{for(O=new Array(h),S=new Array(h),l&&(p=new Array(h)),b=0,A=Math.min(o,h);b<A&&s[b]===u[b];b++);for(A=o-1,V=h-1;A>=b&&V>=b&&s[A]===u[V];A--,V--)O[V]=a[A],S[V]=i[A],l&&(p[V]=l[A]);for(j=new Map,k=new Array(V+1),g=V;g>=b;g--)R=u[g],y=j.get(R),k[g]=y===void 0?-1:y,j.set(R,g);for(y=b;y<=A;y++)R=s[y],g=j.get(R),g!==void 0&&g!==-1?(O[g]=a[y],S[g]=i[y],l&&(p[g]=l[y]),g=k[g],j.set(R,g)):i[y]();for(g=b;g<h;g++)g in O?(a[g]=O[g],i[g]=S[g],l&&(l[g]=p[g],l[g](g))):a[g]=Be(E);a=a.slice(0,o=h),s=u.slice(0)}return a});function E(j){if(i[g]=j,l){const[k,O]=le(g);return l[g]=O,t(u[g],k)}return t(u[g])}}}function Xr(e,t,n={}){let s=[],a=[],i=[],o=[],l=0,u;return mt(()=>an(i)),()=>{const h=e()||[],y=h.length;return h[Fn],me(()=>{if(y===0)return l!==0&&(an(i),i=[],s=[],a=[],l=0,o=[]),n.fallback&&(s=[Dn],a[0]=Be(E=>(i[0]=E,n.fallback())),l=1),a;for(s[0]===Dn&&(i[0](),i=[],s=[],a=[],l=0),u=0;u<y;u++)u<s.length&&s[u]!==h[u]?o[u](()=>h[u]):u>=s.length&&(a[u]=Be(g));for(;u<s.length;u++)i[u]();return l=o.length=i.length=y,s=h.slice(0),a=a.slice(0,l)});function g(E){i[u]=E;const[j,k]=le(h[u]);return o[u]=k,t(j,u)}}}function Hn(e,t){return me(()=>e(t||{}))}function Yt(){return!0}var In={get(e,t,n){return t===en?n:e.get(t)},has(e,t){return t===en?!0:e.has(t)},set:Yt,deleteProperty:Yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Yt,deleteProperty:Yt}},ownKeys(e){return e.keys()}};function jn(e){return(e=typeof e=="function"?e():e)?e:{}}function Jr(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function Vn(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&en in l,e[o]=typeof l=="function"?(t=!0,Ee(l)):l}if(t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const u=jn(e[l])[o];if(u!==void 0)return u}},has(o){for(let l=e.length-1;l>=0;l--)if(o in jn(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(jn(e[l])));return[...new Set(o)]}},In);const n={},s=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const u=Object.getOwnPropertyNames(l);for(let h=u.length-1;h>=0;h--){const y=u[h];if(y==="__proto__"||y==="constructor")continue;const g=Object.getOwnPropertyDescriptor(l,y);if(!s[y])s[y]=g.get?{enumerable:!0,configurable:!0,get:Jr.bind(n[y]=[g.get.bind(l)])}:g.value!==void 0?g:void 0;else{const E=n[y];E&&(g.get?E.push(g.get.bind(l)):g.value!==void 0&&E.push(()=>g.value))}}}const a={},i=Object.keys(s);for(let o=i.length-1;o>=0;o--){const l=i[o],u=s[l];u&&u.get?Object.defineProperty(a,l,u):a[l]=u?u.value:void 0}return a}function _s(e,...t){if(en in e){const a=new Set(t.length>1?t.flat():t[0]),i=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},In));return i.push(new Proxy({get(o){return a.has(o)?void 0:e[o]},has(o){return a.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!a.has(o))}},In)),i}const n={},s=t.map(()=>({}));for(const a of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,a),o=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let l=!1,u=0;for(const h of t)h.includes(a)&&(l=!0,o?s[u][a]=i.value:Object.defineProperty(s[u],a,i)),++u;l||(o?n[a]=i.value:Object.defineProperty(n,a,i))}return[...s,n]}function ks(e){let t,n;const s=a=>{const i=W.context;if(i){const[l,u]=le();W.count||(W.count=0),W.count++,(n||(n=e())).then(h=>{Tt(i),W.count--,u(()=>h.default),Tt()}),t=l}else if(!t){const[l]=Gr(()=>(n||(n=e())).then(u=>u.default));t=l}let o;return Ee(()=>(o=t())&&me(()=>{if(!i)return o(a);const l=W.context;Tt(i);const u=o(a);return Tt(l),u}))};return s.preload=()=>n||((n=e()).then(a=>t=()=>a.default),n),s}var Zr=0;function ea(){return W.context?W.getNextContextId():`cl-${Zr++}`}var Ls=e=>`Stale read from <${e}>.`;function ta(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(Yr(()=>e.each,e.children,t||void 0))}function na(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(Xr(()=>e.each,e.children,t||void 0))}function sa(e){const t=e.keyed,n=Ee(()=>e.when,void 0,{equals:(s,a)=>t?s===a:!s==!a});return Ee(()=>{const s=n();if(s){const a=e.children;return typeof a=="function"&&a.length>0?me(()=>a(t?s:()=>{if(!me(n))throw Ls("Show");return e.when})):a}return e.fallback},void 0,void 0)}function ra(e){let t=!1;const n=(i,o)=>(t?i[1]===o[1]:!i[1]==!o[1])&&i[2]===o[2],s=Ts(()=>e.children),a=Ee(()=>{let i=s();Array.isArray(i)||(i=[i]);for(let o=0;o<i.length;o++){const l=i[o].when;if(l)return t=!!i[o].keyed,[o,l,i[o]]}return[-1]},void 0,{equals:n});return Ee(()=>{const[i,o,l]=a();if(i<0)return e.fallback;const u=l.children;return typeof u=="function"&&u.length>0?me(()=>u(t?o:()=>{if(me(a)[0]!==i)throw Ls("Match");return l.when})):u},void 0,void 0)}function aa(e){return e}var ia=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],oa=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...ia]),la=new Set(["innerHTML","textContent","innerText","children"]),ca=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ua=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function da(e,t){const n=ua[e];return typeof n=="object"?n[t]?n.$:void 0:n}var fa=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ha=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),ga={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function ma(e,t,n){let s=n.length,a=t.length,i=s,o=0,l=0,u=t[a-1].nextSibling,h=null;for(;o<a||l<i;){if(t[o]===n[l]){o++,l++;continue}for(;t[a-1]===n[i-1];)a--,i--;if(a===o){const y=i<s?l?n[l-1].nextSibling:n[i-l]:u;for(;l<i;)e.insertBefore(n[l++],y)}else if(i===l)for(;o<a;)(!h||!h.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[i-1]&&n[l]===t[a-1]){const y=t[--a].nextSibling;e.insertBefore(n[l++],t[o++].nextSibling),e.insertBefore(n[--i],y),t[a]=n[i]}else{if(!h){h=new Map;let g=l;for(;g<i;)h.set(n[g],g++)}const y=h.get(t[o]);if(y!=null)if(l<y&&y<i){let g=o,E=1,j;for(;++g<a&&g<i&&!((j=h.get(t[g]))==null||j!==y+E);)E++;if(E>y-l){const k=t[o];for(;l<y;)e.insertBefore(n[l++],k)}else e.replaceChild(n[l++],t[o++])}else o++;else t[o++].remove()}}}var Nt="_$DX_DELEGATE";function Ds(e,t,n,s={}){let a;return Be(i=>{a=i,t===document?e():ln(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{a(),t.textContent=""}}function pa(e,t,n){let s;const a=()=>{const o=document.createElement("template");return o.innerHTML=e,o.content.firstChild},i=()=>(s||(s=a())).cloneNode(!0);return i.cloneNode=i,i}function Is(e,t=window.document){const n=t[Nt]||(t[Nt]=new Set);for(let s=0,a=e.length;s<a;s++){const i=e[s];n.has(i)||(n.add(i),t.addEventListener(i,Rs))}}function ya(e=window.document){if(e[Nt]){for(let t of e[Nt].keys())e.removeEventListener(t,Rs);delete e[Nt]}}function on(e,t,n){W.context&&e.isConnected||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function va(e,t,n,s){W.context&&e.isConnected||(s==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,s))}function Os(e,t){W.context&&e.isConnected||(t==null?e.removeAttribute("class"):e.className=t)}function Gs(e,t,n,s){if(s)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const a=n[0];e.addEventListener(t,n[0]=i=>a.call(e,n[1],i))}else e.addEventListener(t,n)}function xa(e,t,n={}){const s=Object.keys(t||{}),a=Object.keys(n);let i,o;for(i=0,o=a.length;i<o;i++){const l=a[i];!l||l==="undefined"||t[l]||(us(e,l,!1),delete n[l])}for(i=0,o=s.length;i<o;i++){const l=s[i],u=!!t[l];!l||l==="undefined"||n[l]===u||!u||(us(e,l,!0),n[l]=u)}return n}function Ea(e,t,n){if(!t)return n?on(e,"style"):t;const s=e.style;if(typeof t=="string")return s.cssText=t;typeof n=="string"&&(s.cssText=n=void 0),n||(n={}),t||(t={});let a,i;for(i in n)t[i]==null&&s.removeProperty(i),delete n[i];for(i in t)a=t[i],a!==n[i]&&(s.setProperty(i,a),n[i]=a);return n}function Ms(e,t={},n,s){const a={};return s||Fe(()=>a.children=_t(e,t.children,a.children)),Fe(()=>typeof t.ref=="function"&&Us(t.ref,e)),Fe(()=>ba(e,t,n,!0,a,!0)),a}function Us(e,t,n){return me(()=>e(t,n))}function ln(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return _t(e,t,s,n);Fe(a=>_t(e,t(),a,n),s)}function ba(e,t,n,s,a={},i=!1){t||(t={});for(const o in a)if(!(o in t)){if(o==="children")continue;a[o]=ds(e,o,null,a[o],n,i)}for(const o in t){if(o==="children")continue;const l=t[o];a[o]=ds(e,o,l,a[o],n,i)}}function Sa(e){let t,n;return!W.context||!(t=W.registry.get(n=Ca()))?e():(W.completed&&W.completed.add(t),W.registry.delete(n),t)}function wa(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function us(e,t,n){const s=t.trim().split(/\s+/);for(let a=0,i=s.length;a<i;a++)e.classList.toggle(s[a],n)}function ds(e,t,n,s,a,i){let o,l,u,h,y;if(t==="style")return Ea(e,n,s);if(t==="classList")return xa(e,n,s);if(n===s)return s;if(t==="ref")i||n(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);s&&e.removeEventListener(g,s),n&&e.addEventListener(g,n)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);s&&e.removeEventListener(g,s,!0),n&&e.addEventListener(g,n,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=fa.has(g);if(!E&&s){const j=Array.isArray(s)?s[0]:s;e.removeEventListener(g,j)}(E||n)&&(Gs(e,g,n,E),E&&Is([g]))}else if(t.slice(0,5)==="attr:")on(e,t.slice(5),n);else if((y=t.slice(0,5)==="prop:")||(u=la.has(t))||!a&&((h=da(t,e.tagName))||(l=oa.has(t)))||(o=e.nodeName.includes("-"))){if(y)t=t.slice(5),l=!0;else if(W.context&&e.isConnected)return n;t==="class"||t==="className"?Os(e,n):o&&!l&&!u?e[wa(t)]=n:e[h||t]=n}else{const g=a&&t.indexOf(":")>-1&&ga[t.split(":")[0]];g?va(e,g,t,n):on(e,ca[t]||t,n)}return n}function Rs(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),W.registry&&!W.done&&(W.done=_$HY.done=!0);n;){const s=n[t];if(s&&!n.disabled){const a=n[`${t}Data`];if(a!==void 0?s.call(n,a,e):s.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function _t(e,t,n,s,a){const i=!!W.context&&e.isConnected;if(i){!n&&(n=[...e.childNodes]);let u=[];for(let h=0;h<n.length;h++){const y=n[h];y.nodeType===8&&y.data.slice(0,2)==="!$"?y.remove():u.push(y)}n=u}for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,l=s!==void 0;if(e=l&&n[0]&&n[0].parentNode||e,o==="string"||o==="number"){if(i||o==="number"&&(t=t.toString(),t===n))return n;if(l){let u=n[0];u&&u.nodeType===3?u.data!==t&&(u.data=t):u=document.createTextNode(t),n=Je(e,n,s,u)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||o==="boolean"){if(i)return n;n=Je(e,n,s)}else{if(o==="function")return Fe(()=>{let u=t();for(;typeof u=="function";)u=u();n=_t(e,u,n,s)}),()=>n;if(Array.isArray(t)){const u=[],h=n&&Array.isArray(n);if(On(u,t,n,a))return Fe(()=>n=_t(e,u,n,s,!0)),()=>n;if(i){if(!u.length)return n;if(s===void 0)return[...e.childNodes];let y=u[0],g=[y];for(;(y=y.nextSibling)!==s;)g.push(y);return n=g}if(u.length===0){if(n=Je(e,n,s),l)return n}else h?n.length===0?fs(e,u,s):ma(e,n,u):(n&&Je(e),fs(e,u));n=u}else if(t.nodeType){if(i&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=Je(e,n,s,t);Je(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function On(e,t,n,s){let a=!1;for(let i=0,o=t.length;i<o;i++){let l=t[i],u=n&&n[e.length],h;if(!(l==null||l===!0||l===!1))if((h=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))a=On(e,l,u)||a;else if(h==="function")if(s){for(;typeof l=="function";)l=l();a=On(e,Array.isArray(l)?l:[l],Array.isArray(u)?u:[u])||a}else e.push(l),a=!0;else{const y=String(l);u&&u.nodeType===3&&u.data===y?e.push(u):e.push(document.createTextNode(y))}}return a}function fs(e,t,n=null){for(let s=0,a=t.length;s<a;s++)e.insertBefore(t[s],n)}function Je(e,t,n,s){if(n===void 0)return e.textContent="";const a=s||document.createTextNode("");if(t.length){let i=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(a!==l){const u=l.parentNode===e;!i&&!o?u?e.replaceChild(a,l):e.insertBefore(a,n):u&&l.remove()}else i=!0}}else e.insertBefore(a,n);return[a]}function Ca(){return W.getNextContextId()}var Ta="http://www.w3.org/2000/svg";function Bs(e,t=!1){return t?document.createElementNS(Ta,e):document.createElement(e)}function ja(e){const{useShadow:t}=e,n=document.createTextNode(""),s=()=>e.mount||document.body,a=cs();let i,o=!!W.context;return qn(()=>{o&&(cs().user=o=!1),i||(i=Rr(a,()=>Ee(()=>e.children)));const l=s();if(l instanceof HTMLHeadElement){const[u,h]=le(!1),y=()=>h(!0);Be(g=>ln(l,()=>u()?g():i(),null)),mt(y)}else{const u=Bs(e.isSVG?"g":"div",e.isSVG),h=t&&u.attachShadow?u.attachShadow({mode:"open"}):u;Object.defineProperty(u,"_$host",{get(){return n.parentNode},configurable:!0}),ln(h,i),l.appendChild(u),e.ref&&e.ref(u),mt(()=>l.removeChild(u))}},void 0,{render:!o}),n}function Aa(e){const[t,n]=_s(e,["component"]),s=Ee(()=>t.component);return Ee(()=>{const a=s();switch(typeof a){case"function":return me(()=>a(n));case"string":const i=ha.has(a),o=W.context?Sa():Bs(a,i);return Ms(o,n,i),o}})}var Na=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Fs=class{constructor(e){this.generateIdentifier=e,this.kv=new Na}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Pa=class extends Fs{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function _a(e){if("values"in Object)return Object.values(e);const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function ka(e,t){const n=_a(e);if("find"in n)return n.find(t);const s=n;for(let a=0;a<s.length;a++){const i=s[a];if(t(i))return i}}function pt(e,t){Object.entries(e).forEach(([n,s])=>t(s,n))}function Zt(e,t){return e.indexOf(t)!==-1}function hs(e,t){for(let n=0;n<e.length;n++){const s=e[n];if(t(s))return s}}var La=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ka(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Da=e=>Object.prototype.toString.call(e).slice(8,-1),qs=e=>typeof e>"u",Ia=e=>e===null,kt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Gn=e=>kt(e)&&Object.keys(e).length===0,We=e=>Array.isArray(e),Oa=e=>typeof e=="string",Ga=e=>typeof e=="number"&&!isNaN(e),Ma=e=>typeof e=="boolean",Ua=e=>e instanceof RegExp,Lt=e=>e instanceof Map,Dt=e=>e instanceof Set,Ws=e=>Da(e)==="Symbol",Ra=e=>e instanceof Date&&!isNaN(e.valueOf()),Ba=e=>e instanceof Error,gs=e=>typeof e=="number"&&isNaN(e),Fa=e=>Ma(e)||Ia(e)||qs(e)||Ga(e)||Oa(e)||Ws(e),qa=e=>typeof e=="bigint",Wa=e=>e===1/0||e===-1/0,Ha=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Va=e=>e instanceof URL,Hs=e=>e.replace(/\./g,"\\."),An=e=>e.map(String).map(Hs).join("."),Pt=e=>{const t=[];let n="";for(let a=0;a<e.length;a++){let i=e.charAt(a);if(i==="\\"&&e.charAt(a+1)==="."){n+=".",a++;continue}if(i==="."){t.push(n),n="";continue}n+=i}const s=n;return t.push(s),t};function De(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Vs=[De(qs,"undefined",()=>null,()=>{}),De(qa,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),De(Ra,"Date",e=>e.toISOString(),e=>new Date(e)),De(Ba,"Error",(e,t)=>{const n={name:e.name,message:e.message};return t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n},(e,t)=>{const n=new Error(e.message);return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n}),De(Ua,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),n=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,n)}),De(Dt,"set",e=>[...e.values()],e=>new Set(e)),De(Lt,"map",e=>[...e.entries()],e=>new Map(e)),De(e=>gs(e)||Wa(e),"number",e=>gs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),De(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),De(Va,"URL",e=>e.toString(),e=>new URL(e))];function fn(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var $s=fn((e,t)=>Ws(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{const s=n.symbolRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),$a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Ks=fn(Ha,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const n=$a[t[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(e)});function zs(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Qs=fn(zs,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};const s={};return n.forEach(a=>{s[a]=e[a]}),s},(e,t,n)=>{const s=n.classRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(s.prototype),e)}),Ys=fn((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{const s=n.customTransformerRegistry.findByName(t[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(e)}),Ka=[Qs,$s,Ys,Ks],ms=(e,t)=>{const n=hs(Ka,a=>a.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};const s=hs(Vs,a=>a.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation}},Xs={};Vs.forEach(e=>{Xs[e.annotation]=e});var za=(e,t,n)=>{if(We(t))switch(t[0]){case"symbol":return $s.untransform(e,t,n);case"class":return Qs.untransform(e,t,n);case"custom":return Ys.untransform(e,t,n);case"typed-array":return Ks.untransform(e,t,n);default:throw new Error("Unknown transformation: "+t)}else{const s=Xs[t];if(!s)throw new Error("Unknown transformation: "+t);return s.untransform(e,n)}},Ze=(e,t)=>{const n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function Js(e){if(Zt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Zt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Zt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Qa=(e,t)=>{Js(t);for(let n=0;n<t.length;n++){const s=t[n];if(Dt(e))e=Ze(e,+s);else if(Lt(e)){const a=+s,i=+t[++n]==0?"key":"value",o=Ze(e,a);switch(i){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[s]}return e},Mn=(e,t,n)=>{if(Js(t),t.length===0)return n(e);let s=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(We(s)){const l=+o;s=s[l]}else if(kt(s))s=s[o];else if(Dt(s)){const l=+o;s=Ze(s,l)}else if(Lt(s)){if(i===t.length-2)break;const u=+o,h=+t[++i]==0?"key":"value",y=Ze(s,u);switch(h){case"key":s=y;break;case"value":s=s.get(y);break}}}const a=t[t.length-1];if(We(s)?s[+a]=n(s[+a]):kt(s)&&(s[a]=n(s[a])),Dt(s)){const i=Ze(s,+a),o=n(i);i!==o&&(s.delete(i),s.add(o))}if(Lt(s)){const i=+t[t.length-2],o=Ze(s,i);switch(+a==0?"key":"value"){case"key":{const u=n(o);s.set(u,s.get(o)),u!==o&&s.delete(o);break}case"value":{s.set(o,n(s.get(o)));break}}}return e};function Un(e,t,n=[]){if(!e)return;if(!We(e)){pt(e,(i,o)=>Un(i,t,[...n,...Pt(o)]));return}const[s,a]=e;a&&pt(a,(i,o)=>{Un(i,t,[...n,...Pt(o)])}),t(s,n)}function Ya(e,t,n){return Un(t,(s,a)=>{e=Mn(e,a,i=>za(i,s,n))}),e}function Xa(e,t){function n(s,a){const i=Qa(e,Pt(a));s.map(Pt).forEach(o=>{e=Mn(e,o,()=>i)})}if(We(t)){const[s,a]=t;s.forEach(i=>{e=Mn(e,Pt(i),()=>e)}),a&&pt(a,n)}else pt(t,n);return e}var Ja=(e,t)=>kt(e)||We(e)||Lt(e)||Dt(e)||zs(e,t);function Za(e,t,n){const s=n.get(e);s?s.push(t):n.set(e,[t])}function ei(e,t){const n={};let s;return e.forEach(a=>{if(a.length<=1)return;t||(a=a.map(l=>l.map(String)).sort((l,u)=>l.length-u.length));const[i,...o]=a;i.length===0?s=o.map(An):n[An(i)]=o.map(An)}),s?Gn(n)?[s]:[s,n]:Gn(n)?void 0:n}var Zs=(e,t,n,s,a=[],i=[],o=new Map)=>{const l=Fa(e);if(!l){Za(e,a,t);const j=o.get(e);if(j)return s?{transformedValue:null}:j}if(!Ja(e,n)){const j=ms(e,n),k=j?{transformedValue:j.value,annotations:[j.type]}:{transformedValue:e};return l||o.set(e,k),k}if(Zt(i,e))return{transformedValue:null};const u=ms(e,n),h=(u==null?void 0:u.value)??e,y=We(h)?[]:{},g={};pt(h,(j,k)=>{if(k==="__proto__"||k==="constructor"||k==="prototype")throw new Error(`Detected property ${k}. This is a prototype pollution risk, please remove it from your object.`);const O=Zs(j,t,n,s,[...a,k],[...i,e],o);y[k]=O.transformedValue,We(O.annotations)?g[k]=O.annotations:kt(O.annotations)&&pt(O.annotations,(S,p)=>{g[Hs(k)+"."+p]=S})});const E=Gn(g)?{transformedValue:y,annotations:u?[u.type]:void 0}:{transformedValue:y,annotations:u?[u.type,g]:g};return l||o.set(e,E),E};function er(e){return Object.prototype.toString.call(e).slice(8,-1)}function ps(e){return er(e)==="Array"}function ti(e){if(er(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ni(e,t,n,s,a){const i={}.propertyIsEnumerable.call(s,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=n),a&&i==="nonenumerable"&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function Rn(e,t={}){if(ps(e))return e.map(a=>Rn(a,t));if(!ti(e))return e;const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);return[...n,...s].reduce((a,i)=>{if(ps(t.props)&&!t.props.includes(i))return a;const o=e[i],l=Rn(o,t);return ni(a,i,l,e,t.nonenumerable),a},{})}var se=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Pa,this.symbolRegistry=new Fs(t=>t.description??""),this.customTransformerRegistry=new La,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,n=Zs(e,t,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const a=ei(t,this.dedupe);return a&&(s.meta={...s.meta,referentialEqualities:a}),s}deserialize(e){const{json:t,meta:n}=e;let s=Rn(t);return n!=null&&n.values&&(s=Ya(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=Xa(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};se.defaultInstance=new se;se.serialize=se.defaultInstance.serialize.bind(se.defaultInstance);se.deserialize=se.defaultInstance.deserialize.bind(se.defaultInstance);se.stringify=se.defaultInstance.stringify.bind(se.defaultInstance);se.parse=se.defaultInstance.parse.bind(se.defaultInstance);se.registerClass=se.defaultInstance.registerClass.bind(se.defaultInstance);se.registerSymbol=se.defaultInstance.registerSymbol.bind(se.defaultInstance);se.registerCustom=se.defaultInstance.registerCustom.bind(se.defaultInstance);se.allowErrorProps=se.defaultInstance.allowErrorProps.bind(se.defaultInstance);var tr=se.serialize,si=se.stringify;function ri(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function ai(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function ii({queryState:e,observerCount:t,isStale:n}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":n?"yellow":"green":"gray"}function oi({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function li(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var ci=(e,t=!1)=>{const{json:n}=tr(e);return JSON.stringify(n,null,t?2:void 0)},Xt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ui=(e,t)=>e.queryHash.localeCompare(t.queryHash),nr=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,di=(e,t)=>Xt(e)===Xt(t)?nr(e,t):Xt(e)>Xt(t)?1:-1,fi={status:di,"query hash":ui,"last updated":nr},Jt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,sr=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,hi=(e,t)=>Jt(e)===Jt(t)?sr(e,t):Jt(e)>Jt(t)?1:-1,gi={status:hi,"last updated":sr},mi=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),pi=()=>{const[e,t]=le("dark");return Cs(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches?"dark":"light");const s=a=>{t(a.matches?"dark":"light")};n.addEventListener("change",s),mt(()=>n.removeEventListener("change",s))}),e},jt=(e,t,n)=>{if(t.length===0)return n;if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.set(t[0],n),s;const[a,...i]=t;return s.set(a,jt(s.get(a),i,n)),s}if(e instanceof Set){const s=jt(Array.from(e),t,n);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s[t[0]]=n,s;const[a,...i]=t;return s[a]=jt(s[a],i,n),s}if(e instanceof Object){const s={...e};if(t.length===1)return s[t[0]]=n,s;const[a,...i]=t;return s[a]=jt(s[a],i,n),s}return e},At=(e,t)=>{if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.delete(t[0]),n;const[s,...a]=t;return n.set(s,At(n.get(s),a)),n}if(e instanceof Set){const n=At(Array.from(e),t);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n.filter((i,o)=>o.toString()!==t[0]);const[s,...a]=t;return n[s]=At(n[s],a),n}if(e instanceof Object){const n={...e};if(t.length===1)return delete n[t[0]],n;const[s,...a]=t;return n[s]=At(n[s],a),n}return e},rr=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const s=document.createElement("style"),a=document.createTextNode("");s.appendChild(a),s.id="_goober",s.setAttribute("nonce",e),t?t.appendChild(s):document.head.appendChild(s)},et,It,Ot,Gt,Ke,Mt,tt,nt,st,rt,at,it,Ut,vs,yi=(vs=class{constructor(e){te(this,et);te(this,It);te(this,Ot);te(this,Gt);te(this,Ke,!1);te(this,Mt);te(this,tt);te(this,nt);te(this,st);te(this,rt);te(this,at);te(this,it);te(this,Ut);const{client:t,queryFlavor:n,version:s,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:h,shadowDOMTarget:y}=e;Z(this,et,le(t)),Z(this,Ot,n),Z(this,Gt,s),Z(this,It,a),Z(this,Mt,h),Z(this,tt,y),Z(this,nt,le(i)),Z(this,st,le(o)),Z(this,rt,le(l)),Z(this,at,le(u))}setButtonPosition(e){I(this,nt)[1](e)}setPosition(e){I(this,st)[1](e)}setInitialIsOpen(e){I(this,rt)[1](e)}setErrorTypes(e){I(this,at)[1](e)}setClient(e){I(this,et)[1](e)}mount(e){if(I(this,Ke))throw new Error("Devtools is already mounted");const t=Ds(()=>{const n=this,[s]=I(this,nt),[a]=I(this,st),[i]=I(this,rt),[o]=I(this,at),[l]=I(this,et);let u;return I(this,it)?u=I(this,it):(u=ks(()=>Promise.resolve().then(()=>require("./BMGNQTAT-BUbmy15L.cjs"))),Z(this,it,u)),rr(I(this,Mt),I(this,tt)),Hn(u,Vn({get queryFlavor(){return I(n,Ot)},get version(){return I(n,Gt)},get onlineManager(){return I(n,It)},get shadowDOMTarget(){return I(n,tt)}},{get client(){return l()},get buttonPosition(){return s()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()}}))},e);Z(this,Ke,!0),Z(this,Ut,t)}unmount(){var e;if(!I(this,Ke))throw new Error("Devtools is not mounted");(e=I(this,Ut))==null||e.call(this),Z(this,Ke,!1)}},et=new WeakMap,It=new WeakMap,Ot=new WeakMap,Gt=new WeakMap,Ke=new WeakMap,Mt=new WeakMap,tt=new WeakMap,nt=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,it=new WeakMap,Ut=new WeakMap,vs),ot,Rt,Bt,Ft,ze,qt,lt,ct,ut,dt,ft,ht,gt,Wt,xs,vi=(xs=class{constructor(e){te(this,ot);te(this,Rt);te(this,Bt);te(this,Ft);te(this,ze,!1);te(this,qt);te(this,lt);te(this,ct);te(this,ut);te(this,dt);te(this,ft);te(this,ht);te(this,gt);te(this,Wt);const{client:t,queryFlavor:n,version:s,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:h,shadowDOMTarget:y,onClose:g}=e;Z(this,ot,le(t)),Z(this,Bt,n),Z(this,Ft,s),Z(this,Rt,a),Z(this,qt,h),Z(this,lt,y),Z(this,ct,le(i)),Z(this,ut,le(o)),Z(this,dt,le(l)),Z(this,ft,le(u)),Z(this,ht,le(g))}setButtonPosition(e){I(this,ct)[1](e)}setPosition(e){I(this,ut)[1](e)}setInitialIsOpen(e){I(this,dt)[1](e)}setErrorTypes(e){I(this,ft)[1](e)}setClient(e){I(this,ot)[1](e)}setOnClose(e){I(this,ht)[1](()=>e)}mount(e){if(I(this,ze))throw new Error("Devtools is already mounted");const t=Ds(()=>{const n=this,[s]=I(this,ct),[a]=I(this,ut),[i]=I(this,dt),[o]=I(this,ft),[l]=I(this,ot),[u]=I(this,ht);let h;return I(this,gt)?h=I(this,gt):(h=ks(()=>Promise.resolve().then(()=>require("./UODQIBEW-RuV8_29G.cjs"))),Z(this,gt,h)),rr(I(this,qt),I(this,lt)),Hn(h,Vn({get queryFlavor(){return I(n,Bt)},get version(){return I(n,Ft)},get onlineManager(){return I(n,Rt)},get shadowDOMTarget(){return I(n,lt)}},{get client(){return l()},get buttonPosition(){return s()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()},get onClose(){return u()}}))},e);Z(this,ze,!0),Z(this,Wt,t)}unmount(){var e;if(!I(this,ze))throw new Error("Devtools is not mounted");(e=I(this,Wt))==null||e.call(this),Z(this,ze,!1)}},ot=new WeakMap,Rt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,ze=new WeakMap,qt=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,gt=new WeakMap,Wt=new WeakMap,xs);function xi(e){const t=Q.useQueryClient(e.client),n=we.useRef(null),{buttonPosition:s,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}=e,[h]=we.useState(new yi({client:t,queryFlavor:"React Query",version:"5",onlineManager:Q.onlineManager,buttonPosition:s,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}));return we.useEffect(()=>{h.setClient(t)},[t,h]),we.useEffect(()=>{s&&h.setButtonPosition(s)},[s,h]),we.useEffect(()=>{a&&h.setPosition(a)},[a,h]),we.useEffect(()=>{h.setInitialIsOpen(i||!1)},[i,h]),we.useEffect(()=>{h.setErrorTypes(o||[])},[o,h]),we.useEffect(()=>(n.current&&h.mount(n.current),()=>{h.unmount()}),[h]),r.jsx("div",{className:"tsqd-parent-container",ref:n})}function Ei(e){const t=Q.useQueryClient(e.client),n=we.useRef(null),{errorTypes:s,styleNonce:a,shadowDOMTarget:i}=e,[o]=we.useState(new vi({client:t,queryFlavor:"React Query",version:"5",onlineManager:Q.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:s,styleNonce:a,shadowDOMTarget:i,onClose:e.onClose}));return we.useEffect(()=>{o.setClient(t)},[t,o]),we.useEffect(()=>{o.setOnClose(e.onClose??(()=>{}))},[e.onClose,o]),we.useEffect(()=>{o.setErrorTypes(s||[])},[s,o]),we.useEffect(()=>(n.current&&o.mount(n.current),()=>{o.unmount()}),[o]),r.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:n})}var bi=process.env.NODE_ENV!=="development"?function(){return null}:xi;process.env.NODE_ENV;const Si=Es.atom({}),ar=()=>Es.useAtom(Si),Ht=(e,t)=>{const[n]=ar();return v.get(n,e,t)},he=()=>Ht("apiUrl","/chai/api"),U={ASK_AI:"ASK_AI",GET_PAGE:"GET_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_SETTINGS:"GET_WEBSITE_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA"},$n=()=>{const e=Q.useQueryClient(),{data:t}=Q.useQuery({queryKey:[U.AI_CONTEXT],initialData:"",queryFn:()=>""});return{setAiContext:T.useCallback(s=>{e.setQueryData([U.AI_CONTEXT],s)},[]),aiContext:t}},ge=async(e,t)=>{const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await n.json();if(s!=null&&s.error||n.status===400||!n.ok)throw new Error((s==null?void 0:s.error)||"Something went wrong.");return s},wi=()=>{const e=he(),{aiContext:t}=$n();return T.useCallback(async(n,s,a,i)=>ge(e,{action:U.ASK_AI,data:{type:n,prompt:s,blocks:a,context:t,lang:i}}),[e,t])},Ci=()=>{const e=he();return{getUILibraryBlock:async(a,i)=>{const u=(await(await fetch(a.url+(i.path?"/blocks/"+i.path:"/"+i.uuid+".html"))).text()).replace(/---([\s\S]*?)---/g,"");return Me.getBlocksFromHTML(`${u}`)},getUILibraryBlocks:async a=>{try{return(await(await fetch(a.url+"/blocks.json")).json()).map(l=>({...l,preview:a.url.replace("chaiblocks","")+l.preview}))}catch(i){return console.error(i),[]}},onSave:async({page:a,blocks:i})=>{try{return await ge(e,{action:"UPDATE_PAGE",data:{id:a,blocks:i}})}catch{return new Error("Failed to save blocks")}}}};function Qe(){const[e,t]=T.useState(new URLSearchParams(window.location.search));return T.useEffect(()=>{const n=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[]),[e,t]}const hn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>ge(e,{action:U.GET_WEBSITE_PAGES})||[]})},Re=()=>{const[e]=Qe(),t=e.get("page"),{data:n,isFetching:s}=hn();return{data:T.useMemo(()=>v.find(n,{id:t})||{},[n,t]),isFetching:s}},Ti=()=>Q.useQuery({queryKey:["uiLibraries"],initialData:[],queryFn:async()=>[{uuid:"chaiblocks",name:"UI Blocks",url:"https://chaibuilder.com/chaiblocks"}]}),ji=()=>{const[e]=Qe(),t=e.get("page"),n=he(),{setAiContext:s}=$n();return Q.useQuery({queryKey:[U.GET_PAGE,t],initialData:[],queryFn:async()=>{const i=(await ge(n,{action:U.GET_PAGE,data:{id:t,draft:!0}})).blocks??[],o=v.find(i,{_type:"@chai/ai-context"});return s(v.get(o,"_value","")||""),i},enabled:!!t})},Ai=(e,t)=>t.map(n=>{if(v.has(e,n._type)){const s=bs.getDefaultBlockProps(n._type);return{...s,...v.pick(n,[...v.keys(s),"_type","_id","_name","_parent","_bindings"]),...v.pickBy(n,(a,i)=>v.endsWith(i,"_attrs"))}}return n}),Ni=e=>{const t=bs.useRegisteredChaiBlocks();return T.useMemo(()=>{if(!e||v.isEmpty(e))return{blocks:[]};const n=v.filter(e,s=>!v.includes(s==null?void 0:s._type,"@chai/"));return{blocks:Ai(t,n)}},[e,t])},Kn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_SETTINGS],initialData:{theme:{},fallbackLang:"en",languages:[]},queryFn:async()=>ge(e,{action:U.GET_WEBSITE_SETTINGS,data:{draft:!0}})})},Pi=()=>{const{data:e}=hn(),t=he();return{getGlobalBlocks:async()=>{const n={};for(const s of e??[])v.isEmpty(s==null?void 0:s.slug)&&(n[s.id]={name:v.startCase(s.name??s.slug),description:""});return n},getGlobalBlockBlocks:async n=>n?(await ge(t,{action:"GET_PAGE",data:{id:n,draft:!0}})).blocks:[]}},_i=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_WEBSITE_SETTINGS,data:s}),onSuccess:(s,a)=>{var i;t.invalidateQueries({queryKey:[U.GET_WEBSITE_SETTINGS]}),(i=a==null?void 0:a.settings)!=null&&i.theme||n({title:"Website settings updated successfully."})},onError:s=>{n({variant:"destructive",title:"Failed to update website settings",description:s.message})}})},ki=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_WEBSITE_DATA,data:s}),onSuccess:()=>{t.invalidateQueries({queryKey:[U.GET_WEBSITE_DATA]}),n({title:"Website data updated successfully."})},onError:s=>{n({variant:"destructive",title:"Failed to update website data",description:s.message})}})},gn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_PAGE_TYPES],initialData:[],queryFn:async()=>ge(e,{action:U.GET_PAGE_TYPES})})},Li=()=>{const e=he();return Q.useMutation({mutationFn:async({collection:t,query:n})=>{try{return ge(e,{action:U.SEARCH_PAGES,data:{collection:t,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(s){return console.error(s),[]}}})},qe={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},Di={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},_={PREVIEW:"Preview",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add New language",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},ir=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.CREATE_PAGE,data:s}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_ADD_SUCCESS:_.PAGE_ADD_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to add new ${a.collection==="global"?"global block":"page"}.`,description:v.get(Di,s.message,s.message)})}})},or=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_PAGE,data:s}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage||a!=null&&a.seo)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),a!=null&&a.seo?n({title:_.SEO_SETTINGS_UPDATE_SUCCESS}):n({title:a.collection==="global"?_.GLOBAL_BLOCK_UPDATE_SUCCESS:_.PAGE_UPDATE_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to update ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},Ii=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.DELETE_PAGE,data:{id:s==null?void 0:s.id}}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_DELETE_SUCCESS:_.PAGE_DELETE_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to delete ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},Oi=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.TAKE_OFFLINE,data:{id:s==null?void 0:s.id}}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_UNPUBLISH_SUCCESS:_.PAGE_UNPUBLISH_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to take offline ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},lr=()=>{const e=he(),{toast:t}=f.useToast(),n=Q.useQueryClient(),{data:s}=Re();return Q.useMutation({mutationFn:async({ids:a})=>ge(e,{action:U.PUBLISH_CHANGES,data:{ids:a}}),onSuccess:()=>{n.invalidateQueries({queryKey:[U.GET_CHANGES]}),n.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,s==null?void 0:s.id]})},onError:()=>{t({title:"Failed to publish pages.",variant:"destructive"})}})},Gi=()=>{const e=he(),{toast:t}=f.useToast(),n=Q.useQueryClient();return Q.useMutation({mutationFn:async({id:s,slug:a})=>ge(e,{action:U.CHANGE_SLUG,data:{id:s,slug:a}}),onSuccess:(s,{primaryPage:a})=>{t({title:_.SLUG_CHANGE_SUCCESS}),a?n.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a]}):n.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]})},onError:()=>{t({title:"Failed to change slug",variant:"destructive"})}})},zn=()=>{const e=he(),[t]=Qe(),n=t.get("page");return Q.useQuery({queryKey:[U.GET_LANGUAGE_PAGES,n],initialData:[],queryFn:async()=>{if(!n)return null;const s=await ge(e,{action:U.GET_LANGUAGE_PAGES,data:{id:n}});return v.reverse(v.sortBy(s,"primaryPage"))}})},Mi=()=>{const{selectedLang:e}=Me.useLanguages(),{data:t,isFetching:n}=zn();return{data:T.useMemo(()=>v.find(t,{lang:e||""})||{},[t,e]),isFetching:n}},cr=()=>{const{data:e,isFetching:t}=Mi(),n=e==null?void 0:e.seo,[s,a]=T.useState({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...n}),i=T.useRef({initial:s,updated:s}),{selectedLang:o,fallbackLang:l,languages:u}=Me.useLanguages(),h=o.length?o:l,{mutate:y,isPending:g}=or(),E=g;T.useEffect(()=>{!t&&n&&a({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...n})},[t,n]);const j=async()=>{y({id:e==null?void 0:e.id,seo:s}),i.current.initial=s,i.current.updated=s},k=()=>{a({...s,ogTitle:s.title,ogDescription:s.description})},O=()=>{a({...s,searchTitle:s.ogTitle,searchDescription:s.ogDescription})},S=p=>{const b={...s,[p.target.name]:p.target.name==="noIndex"||p.target.name==="noFollow"?p.target.checked:p.target.value};a(b),i.current.updated=b};return r.jsxs("div",{className:"relative pb-40",children:[r.jsxs("div",{className:"text-xs bg-gray-100 p-2 rounded-md text-left",children:["Slug: ",e==null?void 0:e.slug,"  ",u.length>0&&r.jsxs("span",{className:"text-blue-500 font-semibold",children:["(",v.get(qe,h,h),")"]})]}),r.jsx("form",{className:"space-y-8",children:r.jsxs(f.Accordion,{type:"multiple",defaultValue:["page"],children:[r.jsxs(f.AccordionItem,{value:"page",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-semibold",children:"SEO"}),r.jsx(f.AccordionContent,{className:"pt-2",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"title",children:"SEO Title"}),r.jsxs(r.Fragment,{children:[r.jsx(f.Input,{type:"text",id:"title",name:"title",value:s.title,onChange:S,disabled:E,placeholder:"Enter SEO title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The title should be between 10 and 60 characters."})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"description",children:"SEO Description"}),r.jsx(f.Textarea,{id:"description",name:"description",value:s.description,onChange:S,disabled:E,placeholder:"Enter SEO description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The description should be between 50 and 160 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"title",children:"Canonical URL"}),r.jsx(f.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:s.canonicalUrl,onChange:S,disabled:E,placeholder:"Enter Canonical URL"})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(f.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:s.noIndex,onChange:S,disabled:E,className:"h-4 w-4"}),r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"noIndex",children:"No Index"})]}),r.jsx("p",{className:"mt-0 text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to index this page."})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(f.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:s.noFollow,onChange:S,disabled:E,className:"h-4 w-4"}),r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"noIndex",children:"No Follow"})]}),r.jsx("p",{className:"text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to follow links on this page."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"og",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"OG"}),r.jsx(f.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(f.Button,{type:"button",variant:"outline",size:"sm",onClick:k,children:"Copy from SEO Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"ogTitle",children:"OG Title"}),r.jsx(f.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:s.ogTitle,onChange:S,disabled:E,placeholder:"Enter OG title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The OG title should be between 10 and 60 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"ogDescription",children:"OG Description"}),r.jsx(f.Textarea,{id:"ogDescription",name:"ogDescription",value:s.ogDescription,onChange:S,disabled:E,placeholder:"Enter OG description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The OG description should be between 50 and 160 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"ogImage",children:"OG Image URL"}),r.jsx(f.Input,{type:"text",id:"ogImage",name:"ogImage",value:s.ogImage,onChange:S,disabled:E,placeholder:"Enter OG image URL"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"Enter a valid URL for the OG image."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"search",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"SEARCH"}),r.jsx(f.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(f.Button,{type:"button",variant:"outline",size:"sm",onClick:O,children:"Copy from OG Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"searchTitle",children:"Search Title"}),r.jsx(f.Input,{type:"text",id:"searchTitle",name:"searchTitle",value:s.searchTitle,onChange:S,disabled:E,placeholder:"Enter search title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The search title should be between 10 and 60 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"searchDescription",children:"Search Description"}),r.jsx(f.Textarea,{id:"searchDescription",name:"searchDescription",value:s.searchDescription,onChange:S,placeholder:"Enter search description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The search description should be between 50 and 160 characters."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"jsonLD",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"JSON-LD"}),r.jsx(f.AccordionContent,{children:r.jsx("div",{className:"space-y-4",children:r.jsx("div",{children:r.jsx(f.Textarea,{id:"jsonLD",name:"jsonLD",rows:3,value:s.jsonLD,onChange:S,placeholder:"Enter JSON-LD"})})})})]})]})}),r.jsx("div",{className:"w-full flex items-center justify-end mt-4",children:r.jsx(f.Button,{size:"lg",variant:"default",onClick:j,disabled:v.isEqual(i.current.initial,s)||E,children:g?"Saving...":"Save"})})]})};cr.displayName="SeoPanel";const ur=({page:e,onClose:t})=>{const[n,s]=T.useState(e.slug||""),{mutate:a,isPending:i}=Gi(),{data:o}=gn(),l=v.find(o,{key:e==null?void 0:e.collection}),u=y=>{y.preventDefault(),a({...e,slug:n},{onSuccess:t})},h=(e==null?void 0:e.lang)||"";return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Change Slug"}),r.jsx(f.DialogDescription,{className:"text-xs",children:r.jsxs(f.Alert,{variant:"destructive",className:"mt-2",children:[r.jsx(H.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),r.jsxs("form",{onSubmit:u,children:[r.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{children:[r.jsx("span",{children:"Type:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(l==null?void 0:l.name)||(e==null?void 0:e.collection)]})]}),r.jsxs("div",{children:[r.jsx("span",{children:"Name:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",e.name]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs(f.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",r.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",h]})]}),r.jsx(f.Input,{id:"slug",value:n,onChange:y=>{const g=y.target.value;v.startsWith(g,`/${h}`)&&s(g)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),r.jsx(f.DialogFooter,{children:r.jsx(f.Button,{type:"submit",disabled:i||!v.startsWith(n,`/${h}`)||v.isEqual(e==null?void 0:e.slug,n),children:i?"Changing...":"Change Slug"})})]})]})})};function dr({page:e,onClose:t}){const[,n]=Qe(),{mutate:s,isPending:a}=Ii(),i=()=>{s(e,{onSuccess:()=>{e!=null&&e.primaryPage||(window.history.replaceState(null,"","/"),n(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate"))),t()}})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Confirm Deletion"}),r.jsxs(f.DialogDescription,{className:"py-4 text-slate-500",children:[r.jsxs("div",{children:["Are you sure you want to remove ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",(e==null?void 0:e.collection)==="global"?"global block?":`page? ${e!=null&&e.primaryPage?"":"This will also delete all associated language pages."}`]}),e.lang&&r.jsxs("div",{className:"py-2 text-sm",children:["Language:"," ",r.jsx("span",{className:"font-medium text-gray-500",children:v.get(qe,e.lang,e.lang)})]})]})]}),r.jsxs(f.DialogFooter,{children:[r.jsx(f.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(f.Button,{variant:"destructive",disabled:a,onClick:i,children:a?"Deleting...":"Delete"})]})]})})}const Qn=({page:e,onClose:t})=>{const{mutate:n,isPending:s}=Oi(),a=async()=>{n(e,{onSuccess:t})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Confirm action"}),r.jsxs(f.DialogDescription,{children:[_.UNPUBLISH_MSG," ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)}),"?"]})]}),r.jsxs(f.DialogFooter,{children:[r.jsx(f.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(f.Button,{variant:"destructive",disabled:s,onClick:a,children:s?_.UPDATING:_.UNPUBLISH})]})]})})},fr=({langProps:e,onClose:t,languages:n})=>{const{data:s}=Re(),[a,i]=T.useState(e.name||""),[o,l]=T.useState(e.edit?e.lang:""),[u,h]=T.useState(e.edit?e.slug:""),{mutate:y,isPending:g}=ir(),{mutate:E,isPending:j}=or(),k=(e==null?void 0:e.collection)==="global",O=g||j,S=p=>{p.preventDefault();const b={name:a,lang:o,primaryPage:s==null?void 0:s.id,slug:u,collection:s==null?void 0:s.collection};b.collection=e.collection,e.edit&&(b.id=e==null?void 0:e.id),e.edit?E(b,{onSuccess:t}):y(b,{onSuccess:t})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{className:"sm:max-w-[425px] text-slate-600",children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:e.edit?_.EDIT_LANGUAGE:_.ADD_NEW_LANGUAGE}),r.jsx(f.DialogDescription,{className:"font-light",children:_.ENTER_LANGUAGE_DETAILS})]}),r.jsxs("form",{onSubmit:S,children:[r.jsxs("div",{className:"grid gap-4 py-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{htmlFor:"lang",className:"text-right",children:_.LANGUAGE}),r.jsxs("select",{value:o,disabled:e.edit||v.isEmpty(n),onChange:p=>{const b=p.target.value;l(b),!k&&h(`/${b}`)},className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 col-span-3",children:[r.jsx("option",{value:"",disabled:!0,selected:!0,children:e.edit?v.get(qe,e.lang,e.lang):v.isEmpty(n)?_.ALL_AVAILABLE_LANGUAGE_PAGE:_.CHOOSE_LANGUAGE}),v.map(n,p=>r.jsx("option",{value:p,children:v.get(qe,p,p)},p))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{htmlFor:"slug",className:"text-right",children:_.PAGE_NAME}),r.jsx(f.Input,{id:"name",value:a,onChange:p=>i(p.target.value),className:"col-span-3",required:!0,placeholder:_.ENTER_PAGE_NAME})]}),!k&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs(f.Label,{htmlFor:"slug",className:"text-right",children:[_.SLUG," ",r.jsx("small",{className:"font-light",children:e.edit?_.TO_UPDATE_SLUG:_.SLUG_SHOULD_START_WITH})]}),r.jsx(f.Input,{id:"slug",value:u,onChange:p=>{const b=p.target.value;v.startsWith(b,`/${o}`)&&h(v.toLower(v.trim(b)))},className:"col-span-3",required:!0,pattern:"^/.*",disabled:v.isEmpty(o)||(e==null?void 0:e.edit),title:_.SLUG_MUST_START_WITH,placeholder:v.isEmpty(o)?_.CHOOSE_LANGUAGE_TO_ADD_SLUG:_.ENTER_PAGE_SLUG})]})]}),r.jsx(f.DialogFooter,{children:r.jsx(f.Button,{type:"submit",disabled:O||!a||!o||!k&&!v.startsWith(u,`/${o}`),children:O?e.edit?_.UPDATING:_.ADDING:e.edit?_.UPDATE:_.ADD_NEW_LANGUAGE})})]})]})})},Ui=()=>{const[e,t]=T.useState(null),{selectedLang:n,fallbackLang:s,setSelectedLang:a}=Me.useLanguages(),{data:i,isFetching:o}=zn(),{data:l}=Re(),[u,h]=T.useState(null),[y,g]=T.useState(null),[E,j]=T.useState(null),{data:k}=Kn(),O=v.filter(v.get(k,"languages")||["en"],S=>!v.find(i,{lang:S})&&S!==v.get(k,"fallbackLang"));return r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsx("ul",{className:"space-y-2 mt-4",children:o?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):v.map(i,S=>{const p=S.lang,b=S.slug,A=!S.primaryPage,V=p===n;return r.jsxs(r.Fragment,{children:[r.jsxs("li",{className:`text-slate-500 w-full p-2 rounded cursor-pointer flex items-center justify-between ${V?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>a(p),children:[r.jsxs("div",{className:" flex-1 gap-x-3",children:[r.jsxs("div",{className:"text-[13px] text-slate-800 flex items-center gap-x-2",children:[r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${S.online?"bg-green-300":"bg-gray-300"}`}),v.get(qe,A?s:p,p)]}),r.jsxs("div",{children:[b&&r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Slug: ",r.jsx("b",{className:"font-medium",children:b})]}),r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Name:",r.jsxs("b",{className:"font-medium",children:[" ",S.name," "]})]})]})]}),A?r.jsxs("div",{className:"flex items-center text-[11px] text-orange-500 gap-x-1",children:[r.jsx(H.StarIcon,{fill:"orange",className:"w-3 h-3"}),r.jsx("b",{children:" Primary"})]}):r.jsx("div",{className:"flex items-center gap-x-3",children:r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,onClick:R=>R.stopPropagation(),children:r.jsx(f.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:r.jsx(H.MoreHorizontal,{className:"h-4 w-4"})})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),t({...S,edit:!0})},children:[r.jsx(H.PencilIcon,{className:"size-3"}),_.EDIT]}),(S==null?void 0:S.online)&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),g(S)},children:[r.jsx(H.Power,{className:"size-3"}),_.UNPUBLISH]}),(S==null?void 0:S.collection)!=="global"&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),j(S)},children:[r.jsx(H.Link,{className:"size-3"}),_.CHANGE_SLUG]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),h(S)},children:[r.jsx(H.TrashIcon,{className:"size-3"}),_.DELETE]})]})]})})]},S.id),r.jsx("div",{className:"h-1 w-full border-b"})]})})}),r.jsx("div",{className:"flex justify-center w-full",children:r.jsx(f.Button,{variant:"default",size:"sm",disabled:v.isEmpty(O),onClick:()=>{t({name:l==null?void 0:l.name,collection:l==null?void 0:l.collection,lang:"",slug:"",edit:!1})},children:_.ADD_NEW_LANGUAGE})}),e&&r.jsx(fr,{languages:O,langProps:e,onClose:()=>t(null)}),u&&r.jsx(dr,{page:u,onClose:()=>h(null)}),y&&r.jsx(Qn,{page:y,onClose:()=>g(null)}),E&&r.jsx(ur,{page:E,onClose:()=>j(null)})]})},Ri=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_CHANGES],queryFn:async()=>ge(e,{action:U.GET_CHANGES})})};var Yn={};(function e(t,n,s,a){var i=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o=typeof Path2D=="function"&&typeof DOMMatrix=="function",l=function(){if(!t.OffscreenCanvas)return!1;var m=new OffscreenCanvas(1,1),d=m.getContext("2d");d.fillRect(0,0,1,1);var N=m.transferToImageBitmap();try{d.createPattern(N,"no-repeat")}catch{return!1}return!0}();function u(){}function h(m){var d=n.exports.Promise,N=d!==void 0?d:t.Promise;return typeof N=="function"?new N(m):(m(u,u),null)}var y=function(m,d){return{transform:function(N){if(m)return N;if(d.has(N))return d.get(N);var L=new OffscreenCanvas(N.width,N.height),G=L.getContext("2d");return G.drawImage(N,0,0),d.set(N,L),L},clear:function(){d.clear()}}}(l,new Map),g=function(){var m=Math.floor(16.666666666666668),d,N,L={},G=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(d=function(B){var F=Math.random();return L[F]=requestAnimationFrame(function P(M){G===M||G+m-1<M?(G=M,delete L[F],B()):L[F]=requestAnimationFrame(P)}),F},N=function(B){L[B]&&cancelAnimationFrame(L[B])}):(d=function(B){return setTimeout(B,m)},N=function(B){return clearTimeout(B)}),{frame:d,cancel:N}}(),E=function(){var m,d,N={};function L(G){function B(F,P){G.postMessage({options:F||{},callback:P})}G.init=function(P){var M=P.transferControlToOffscreen();G.postMessage({canvas:M},[M])},G.fire=function(P,M,X){if(d)return B(P,null),d;var re=Math.random().toString(36).slice(2);return d=h(function(ae){function oe(de){de.data.callback===re&&(delete N[re],G.removeEventListener("message",oe),d=null,y.clear(),X(),ae())}G.addEventListener("message",oe),B(P,re),N[re]=oe.bind(null,{data:{callback:re}})}),d},G.reset=function(){G.postMessage({reset:!0});for(var P in N)N[P](),delete N[P]}}return function(){if(m)return m;if(!s&&i){var G=["var CONFETTI, SIZE = {}, module = {};","("+e.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {"," if (msg.data.options) {"," CONFETTI(msg.data.options).then(function () {"," if (msg.data.callback) {"," postMessage({ callback: msg.data.callback });"," }"," });"," } else if (msg.data.reset) {"," CONFETTI && CONFETTI.reset();"," } else if (msg.data.resize) {"," SIZE.width = msg.data.resize.width;"," SIZE.height = msg.data.resize.height;"," } else if (msg.data.canvas) {"," SIZE.width = msg.data.canvas.width;"," SIZE.height = msg.data.canvas.height;"," CONFETTI = module.exports.create(msg.data.canvas);"," }","}"].join(`
31
- `);try{m=new Worker(URL.createObjectURL(new Blob([G])))}catch(B){return typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",B),null}L(m)}return m}}(),j={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function k(m,d){return d?d(m):m}function O(m){return m!=null}function S(m,d,N){return k(m&&O(m[d])?m[d]:j[d],N)}function p(m){return m<0?0:Math.floor(m)}function b(m,d){return Math.floor(Math.random()*(d-m))+m}function A(m){return parseInt(m,16)}function V(m){return m.map(R)}function R(m){var d=String(m).replace(/[^0-9a-f]/gi,"");return d.length<6&&(d=d[0]+d[0]+d[1]+d[1]+d[2]+d[2]),{r:A(d.substring(0,2)),g:A(d.substring(2,4)),b:A(d.substring(4,6))}}function Ce(m){var d=S(m,"origin",Object);return d.x=S(d,"x",Number),d.y=S(d,"y",Number),d}function ke(m){m.width=document.documentElement.clientWidth,m.height=document.documentElement.clientHeight}function Te(m){var d=m.getBoundingClientRect();m.width=d.width,m.height=d.height}function C(m){var d=document.createElement("canvas");return d.style.position="fixed",d.style.top="0px",d.style.left="0px",d.style.pointerEvents="none",d.style.zIndex=m,d}function q(m,d,N,L,G,B,F,P,M){m.save(),m.translate(d,N),m.rotate(B),m.scale(L,G),m.arc(0,0,1,F,P,M),m.restore()}function ee(m){var d=m.angle*(Math.PI/180),N=m.spread*(Math.PI/180);return{x:m.x,y:m.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:m.startVelocity*.5+Math.random()*m.startVelocity,angle2D:-d+(.5*N-Math.random()*N),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:m.color,shape:m.shape,tick:0,totalTicks:m.ticks,decay:m.decay,drift:m.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:m.gravity*3,ovalScalar:.6,scalar:m.scalar,flat:m.flat}}function ve(m,d){d.x+=Math.cos(d.angle2D)*d.velocity+d.drift,d.y+=Math.sin(d.angle2D)*d.velocity+d.gravity,d.velocity*=d.decay,d.flat?(d.wobble=0,d.wobbleX=d.x+10*d.scalar,d.wobbleY=d.y+10*d.scalar,d.tiltSin=0,d.tiltCos=0,d.random=1):(d.wobble+=d.wobbleSpeed,d.wobbleX=d.x+10*d.scalar*Math.cos(d.wobble),d.wobbleY=d.y+10*d.scalar*Math.sin(d.wobble),d.tiltAngle+=.1,d.tiltSin=Math.sin(d.tiltAngle),d.tiltCos=Math.cos(d.tiltAngle),d.random=Math.random()+2);var N=d.tick++/d.totalTicks,L=d.x+d.random*d.tiltCos,G=d.y+d.random*d.tiltSin,B=d.wobbleX+d.random*d.tiltCos,F=d.wobbleY+d.random*d.tiltSin;if(m.fillStyle="rgba("+d.color.r+", "+d.color.g+", "+d.color.b+", "+(1-N)+")",m.beginPath(),o&&d.shape.type==="path"&&typeof d.shape.path=="string"&&Array.isArray(d.shape.matrix))m.fill(Vt(d.shape.path,d.shape.matrix,d.x,d.y,Math.abs(B-L)*.1,Math.abs(F-G)*.1,Math.PI/10*d.wobble));else if(d.shape.type==="bitmap"){var P=Math.PI/10*d.wobble,M=Math.abs(B-L)*.1,X=Math.abs(F-G)*.1,re=d.shape.bitmap.width*d.scalar,ae=d.shape.bitmap.height*d.scalar,oe=new DOMMatrix([Math.cos(P)*M,Math.sin(P)*M,-Math.sin(P)*X,Math.cos(P)*X,d.x,d.y]);oe.multiplySelf(new DOMMatrix(d.shape.matrix));var de=m.createPattern(y.transform(d.shape.bitmap),"no-repeat");de.setTransform(oe),m.globalAlpha=1-N,m.fillStyle=de,m.fillRect(d.x-re/2,d.y-ae/2,re,ae),m.globalAlpha=1}else if(d.shape==="circle")m.ellipse?m.ellipse(d.x,d.y,Math.abs(B-L)*d.ovalScalar,Math.abs(F-G)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI):q(m,d.x,d.y,Math.abs(B-L)*d.ovalScalar,Math.abs(F-G)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI);else if(d.shape==="star")for(var K=Math.PI/2*3,fe=4*d.scalar,pe=8*d.scalar,be=d.x,Ae=d.y,Ne=5,Pe=Math.PI/Ne;Ne--;)be=d.x+Math.cos(K)*pe,Ae=d.y+Math.sin(K)*pe,m.lineTo(be,Ae),K+=Pe,be=d.x+Math.cos(K)*fe,Ae=d.y+Math.sin(K)*fe,m.lineTo(be,Ae),K+=Pe;else m.moveTo(Math.floor(d.x),Math.floor(d.y)),m.lineTo(Math.floor(d.wobbleX),Math.floor(G)),m.lineTo(Math.floor(B),Math.floor(F)),m.lineTo(Math.floor(L),Math.floor(d.wobbleY));return m.closePath(),m.fill(),d.tick<d.totalTicks}function je(m,d,N,L,G){var B=d.slice(),F=m.getContext("2d"),P,M,X=h(function(re){function ae(){P=M=null,F.clearRect(0,0,L.width,L.height),y.clear(),G(),re()}function oe(){s&&!(L.width===a.width&&L.height===a.height)&&(L.width=m.width=a.width,L.height=m.height=a.height),!L.width&&!L.height&&(N(m),L.width=m.width,L.height=m.height),F.clearRect(0,0,L.width,L.height),B=B.filter(function(de){return ve(F,de)}),B.length?P=g.frame(oe):ae()}P=g.frame(oe),M=ae});return{addFettis:function(re){return B=B.concat(re),X},canvas:m,promise:X,reset:function(){P&&g.cancel(P),M&&M()}}}function Le(m,d){var N=!m,L=!!S(d||{},"resize"),G=!1,B=S(d,"disableForReducedMotion",Boolean),F=i&&!!S(d||{},"useWorker"),P=F?E():null,M=N?ke:Te,X=m&&P?!!m.__confetti_initialized:!1,re=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,ae;function oe(K,fe,pe){for(var be=S(K,"particleCount",p),Ae=S(K,"angle",Number),Ne=S(K,"spread",Number),Pe=S(K,"startVelocity",Number),mn=S(K,"decay",Number),xt=S(K,"gravity",Number),pn=S(K,"drift",Number),zt=S(K,"colors",V),Qt=S(K,"ticks",Number),Et=S(K,"shapes"),He=S(K,"scalar"),yn=!!S(K,"flat"),bt=Ce(K),St=be,Ve=[],vn=m.width*bt.x,xn=m.height*bt.y;St--;)Ve.push(ee({x:vn,y:xn,angle:Ae,spread:Ne,startVelocity:Pe,color:zt[St%zt.length],shape:Et[b(0,Et.length)],ticks:Qt,decay:mn,gravity:xt,drift:pn,scalar:He,flat:yn}));return ae?ae.addFettis(Ve):(ae=je(m,Ve,M,fe,pe),ae.promise)}function de(K){var fe=B||S(K,"disableForReducedMotion",Boolean),pe=S(K,"zIndex",Number);if(fe&&re)return h(function(Pe){Pe()});N&&ae?m=ae.canvas:N&&!m&&(m=C(pe),document.body.appendChild(m)),L&&!X&&M(m);var be={width:m.width,height:m.height};P&&!X&&P.init(m),X=!0,P&&(m.__confetti_initialized=!0);function Ae(){if(P){var Pe={getBoundingClientRect:function(){if(!N)return m.getBoundingClientRect()}};M(Pe),P.postMessage({resize:{width:Pe.width,height:Pe.height}});return}be.width=be.height=null}function Ne(){ae=null,L&&(G=!1,t.removeEventListener("resize",Ae)),N&&m&&(document.body.contains(m)&&document.body.removeChild(m),m=null,X=!1)}return L&&!G&&(G=!0,t.addEventListener("resize",Ae,!1)),P?P.fire(K,be,Ne):oe(K,be,Ne)}return de.reset=function(){P&&P.reset(),ae&&ae.reset()},de}var Oe;function vt(){return Oe||(Oe=Le(null,{useWorker:!0,resize:!0})),Oe}function Vt(m,d,N,L,G,B,F){var P=new Path2D(m),M=new Path2D;M.addPath(P,new DOMMatrix(d));var X=new Path2D;return X.addPath(M,new DOMMatrix([Math.cos(F)*G,Math.sin(F)*G,-Math.sin(F)*B,Math.cos(F)*B,N,L])),X}function $t(m){if(!o)throw new Error("path confetti are not supported in this browser");var d,N;typeof m=="string"?d=m:(d=m.path,N=m.matrix);var L=new Path2D(d),G=document.createElement("canvas"),B=G.getContext("2d");if(!N){for(var F=1e3,P=F,M=F,X=0,re=0,ae,oe,de=0;de<F;de+=2)for(var K=0;K<F;K+=2)B.isPointInPath(L,de,K,"nonzero")&&(P=Math.min(P,de),M=Math.min(M,K),X=Math.max(X,de),re=Math.max(re,K));ae=X-P,oe=re-M;var fe=10,pe=Math.min(fe/ae,fe/oe);N=[pe,0,0,pe,-Math.round(ae/2+P)*pe,-Math.round(oe/2+M)*pe]}return{type:"path",path:d,matrix:N}}function Kt(m){var d,N=1,L="#000000",G='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof m=="string"?d=m:(d=m.text,N="scalar"in m?m.scalar:N,G="fontFamily"in m?m.fontFamily:G,L="color"in m?m.color:L);var B=10*N,F=""+B+"px "+G,P=new OffscreenCanvas(B,B),M=P.getContext("2d");M.font=F;var X=M.measureText(d),re=Math.ceil(X.actualBoundingBoxRight+X.actualBoundingBoxLeft),ae=Math.ceil(X.actualBoundingBoxAscent+X.actualBoundingBoxDescent),oe=2,de=X.actualBoundingBoxLeft+oe,K=X.actualBoundingBoxAscent+oe;re+=oe+oe,ae+=oe+oe,P=new OffscreenCanvas(re,ae),M=P.getContext("2d"),M.font=F,M.fillStyle=L,M.fillText(d,de,K);var fe=1/N;return{type:"bitmap",bitmap:P.transferToImageBitmap(),matrix:[fe,0,0,fe,-re*fe/2,-ae*fe/2]}}n.exports=function(){return vt().apply(this,arguments)},n.exports.reset=function(){vt().reset()},n.exports.create=Le,n.exports.shapeFromPath=$t,n.exports.shapeFromText=Kt})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),Yn,!1);const ys=Yn.exports;Yn.exports.create;const Bn=e=>{ys(e==="TOP_RIGHT"?{particleCount:200,angle:225,spread:120,origin:{x:.9,y:0}}:{particleCount:350,spread:120,origin:{y:.6},angle:90})};function Bi({onClose:e=()=>console.log("Cancelled")}){const[t,n]=T.useState([]),{data:s,isFetching:a}=Ri(),{data:i}=gn(),o=T.useMemo(()=>v.filter(s,p=>p.collection!=="global"),[s]),l=T.useMemo(()=>v.filter(s,{collection:"global"}),[s]),u=T.useMemo(()=>v.find(s,{collection:"theme",id:"THEME"}),[s]),{mutate:h,isPending:y}=lr();T.useEffect(()=>{const p=v.map(v.filter(s,{online:!0}),"id");u&&p.push(u==null?void 0:u.id),n(p)},[s,u]);const g=t.length===(s==null?void 0:s.length),E=p=>{n(b=>v.includes(b,p)?v.filter(b,A=>A!==p):v.concat(b,p))},j=()=>{n(g?[]:v.map(s,"id"))},k=()=>{h({ids:v.uniq(t)},{onSuccess:()=>{e(),Bn("CENTER_CENTER")}})},O=p=>{if(p==="global")return"Global Block";if(p==="theme")return"Theme";const b=v.find(i,{key:p});return b?b==null?void 0:b.name:p},S=T.useMemo(()=>{const p=[{label:"Updated Pages & Global Blocks",top:"pt-2"},...v.orderBy(v.filter(o,{online:!0}),"collection"),...v.orderBy(v.filter(l,{online:!0}),"collection")].filter(V=>V.collection!=="theme"),b=[{label:"Offline Pages & Global Blocks",top:"pt-6"},...v.orderBy(v.filter(o,{online:!1}),"collection"),...v.orderBy(v.filter(l,{online:!1}),"collection")],A=u?[{label:"Theme",top:"pt-6"},u]:[];return[...p,...A,...b]},[o,l,u]);return r.jsx(f.Dialog,{open:!0,onOpenChange:y?()=>{}:e,children:r.jsxs(f.DialogContent,{className:"max-w-4xl max-h-[80%] flex flex-col",children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Publish changes"}),r.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),r.jsx("div",{className:"relative -mx-4 h-full overflow-y-auto max-h-full no-scrollbar",children:a?r.jsxs("div",{className:"space-y-2 px-1",children:[r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse mt-2"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"})]}):r.jsxs("table",{className:"w-full text-xs text-left rtl:text-right text-gray-500 dark:text-gray-400",children:[r.jsx("thead",{className:"text-gray-700 border-b bg-gray-50 dark:bg-gray-700 dark:text-gray-400",children:r.jsxs("tr",{children:[r.jsxs("th",{scope:"col",className:"px-6 py-3 flex items-center gap-x-2 w-[1 50px]",children:[r.jsx("input",{checked:g,onClick:p=>{p.stopPropagation(),j()},type:"checkbox",className:"rounded focus:outline-none focus:ring-0 mt-1 cursor-pointer"}),"Name"]}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Language"}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Type"}),r.jsx("th",{scope:"col",className:"px-4 py-3 w-[150px] text-right",children:"Status"})]})}),r.jsx("tbody",{children:v.map(S,p=>p.label?r.jsx("tr",{children:r.jsxs("td",{colSpan:4,className:`px-6 py-2 text-xs font-medium text-gray-800 relative ${p.top}`,children:[r.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:r.jsx("div",{className:"w-full order-gray-300"})}),r.jsx("div",{className:"relative flex justify-start",children:r.jsx("span",{className:"bg-gray-50 pr-2",children:p.label})})]})},"separator"):r.jsxs("tr",{className:"hover:bg-gray-50 border-b last:border-b-0",children:[r.jsxs("td",{scope:"row",className:"px-6 py-2 text-gray-900 whitespace-nowrap dark:text-white flex items-center gap-x-1",children:[r.jsx("input",{checked:v.includes(t,p==null?void 0:p.id),onClick:b=>{b.stopPropagation(),E(p==null?void 0:p.id)},type:"checkbox",className:"rounded focus:outline-none focus:ring-0 cursor-pointer"})," ",p.collection==="global"?r.jsx(H.GlobeIcon,{className:"h-4 w-4"}):r.jsx(H.File,{className:"h-4 w-4"}),p.name,p.slug&&r.jsxs("span",{className:"text-xs text-gray-500",children:["(",p.slug,")"]})]}),r.jsx("td",{className:"px-2",children:p.lang}),r.jsx("td",{className:"px-2",children:O(p==null?void 0:p.collection)}),r.jsx("td",{className:"px-4 text-right",children:v.first(p.changes)||""})]},p==null?void 0:p.id))})]})}),r.jsxs(f.DialogFooter,{className:"mt-10",children:[r.jsx(f.Button,{disabled:y,variant:"outline",onClick:e,children:"Cancel"}),r.jsx(f.Button,{disabled:y||a||v.isEmpty(s),onClick:k,children:y?"Publishing...":"Publish"})]})]})})}const Fi=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_DATA],staleTime:1e3*60*5,queryFn:async()=>ge(e,{action:U.GET_WEBSITE_DATA,data:{draft:!0}})})};function qi({onClose:e}){const{data:t,isFetching:n}=Fi(),{mutateAsync:s,isPending:a}=ki(),i=Ht("settingComponent",null),o=v.debounce(async l=>(await s({data:l}),!0),300);return i?r.jsx(f.Dialog,{open:!0,onOpenChange:e,children:r.jsxs(f.DialogContent,{className:"w-full",children:[r.jsx(f.DialogHeader,{children:r.jsx(f.DialogTitle,{children:"Website Settings"})}),n?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):r.jsx("div",{children:T.createElement(i,{data:t||{},onSave:a?()=>{}:o,cancel:a?()=>{}:e})})]})}):null}function hr({children:e,content:t}){return r.jsx(f.TooltipProvider,{children:r.jsxs(f.Tooltip,{children:[r.jsx(f.TooltipTrigger,{asChild:!0,children:e}),r.jsx(f.TooltipContent,{side:"bottom",sideOffset:10,children:r.jsx("p",{children:t})})]})})}const Wi=()=>{const e=Ht("getPreviewUrl",async o=>o),[t,n]=T.useState(""),{data:s,isFetching:a}=Re(),i=T.useMemo(()=>s==null?void 0:s.slug,[s==null?void 0:s.slug]);return T.useEffect(()=>{(async()=>{if(i&&typeof e=="function"){const o=await e(i||"");n(o)}else n("")})()},[e,i]),!t||(s==null?void 0:s.collection)==="global"||a?null:r.jsx(r.Fragment,{children:r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:r.jsxs(f.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(H.Eye,{className:"w-4 h-4"})," ",_.PREVIEW]})})})},Hi=()=>{const[e,t]=Me.useRightPanel();return r.jsxs(r.Fragment,{children:[r.jsx(hr,{content:_.THEME,children:r.jsx(f.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:r.jsx(H.Palette,{className:"w-4 h-4"})})}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]})},Vi=()=>{const[e,t]=T.useState(!1),{savePage:n,saveState:s}=Me.useSavePage();T.useEffect(()=>{const h=y=>{s==="UNSAVED"&&(y.preventDefault(),y.returnValue=!1)};return s==="UNSAVED"&&window.addEventListener("beforeunload",h),()=>{window.removeEventListener("beforeunload",h)}},[s]);const a=T.useCallback(async()=>{t(!0),await n(!1)},[n]);T.useEffect(()=>{s==="SAVED"&&t(!1)},[s]);const i=T.useMemo(()=>{if(s==="SAVED"||s==="UNSAVED")return s;if(s==="SAVING")return e?s:"SAVED"},[e,s]),{buttonIcon:o,buttonClass:l,tooltipContent:u}=T.useMemo(()=>{switch(i){case"UNSAVED":return{tooltipContent:_.SAVEDRAFT,buttonIcon:r.jsx(H.Save,{className:"w-4 h-4"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVING":return{tooltipContent:_.SAVING,buttonIcon:r.jsx(H.Loader,{className:"w-4 h-4 animate-spin"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVED":return{tooltipContent:_.SAVED,buttonIcon:r.jsx(H.CheckCircle,{className:"w-4 h-4"}),buttonClass:"text-green-500 flex items-center gap-x-1 leading-tight"}}},[i]);return r.jsxs(f.Button,{size:"sm",variant:"ghost",onClick:a,className:l,children:[o," ",u]})},$i=()=>{const[e,t]=T.useState(!1),[n,s]=T.useState(!1),[a,i]=T.useState(null),{data:o}=Re(),{mutate:l,isPending:u}=lr(),{buttonText:h,buttonClassName:y,isPublished:g}=T.useMemo(()=>{const E=o&&(o==null?void 0:o.online);return{buttonClassName:E?"hover:bg-green-600 bg-green-500":"",isPublished:E,buttonText:E?_.PUBLISHED:_.PUBLISH}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex",children:[r.jsxs(f.Button,{size:"sm",disabled:u||!(o!=null&&o.id),onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>Bn("TOP_RIGHT")}),className:`relative overflow-hidden transition-all duration-300 ease-in-out text-white flex items-center gap-1 rounded-r-none ${y}`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${n?"-translate-y-10":""}`,children:g?r.jsx(H.Send,{className:"w-4 h-4"}):r.jsx(H.Rocket,{className:"w-4 h-4"})}),r.jsx("span",{className:`absolute inset-0 flex items-center left-3 transition-transform duration-300 ease-in-out ${n?"":"translate-y-10"}`,children:g?r.jsx(H.Rocket,{className:"w-4 h-4"}):r.jsx(H.Send,{className:"w-4 h-4"})}),r.jsx("span",{children:h})]}),r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,children:r.jsx(f.Button,{size:"sm",disabled:u||!(o!=null&&o.id),className:`px-2 text-white border-l border-white/50 rounded-l-none ${y}`,children:r.jsx(H.ChevronDown,{className:"h-4 w-4"})})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"w-36",children:[!g&&r.jsxs(f.DropdownMenuItem,{disabled:u,className:"text-xs cursor-pointer",onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>Bn("TOP_RIGHT")}),children:[_.PUBLISH," page"]}),r.jsxs(f.DropdownMenuItem,{onClick:()=>t(!0),className:"text-xs cursor-pointer",children:[_.OPEN," publish menu"]}),g&&r.jsxs(f.DropdownMenuItem,{onClick:()=>i(o),className:"text-xs cursor-pointer",children:[_.UNPUBLISH," page"]})]})]})]}),e&&r.jsx(Bi,{onClose:()=>t(!1)}),a&&r.jsx(Qn,{page:a,onClose:()=>i(null)})]})},Ki=()=>{const e=Ht("settingComponent",null),[t,n]=T.useState(!1);return e?r.jsxs(r.Fragment,{children:[r.jsx(hr,{content:_.WEBSITEDATA,children:r.jsx(f.Button,{variant:"ghost",size:"icon",className:"gap-2",onClick:()=>n(!0),children:r.jsx(H.Settings,{className:"w-4 h-4"})})}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"}),t&&r.jsx(qi,{onClose:()=>n(!1)})]}):null},zi=()=>{const{data:e}=Re(),t=e&&(e==null?void 0:e.online);return r.jsxs(f.Button,{onClick:()=>t&&window.open(`${window.location.origin}${e.slug}`,"_blank"),disabled:!t,variant:"ghost",size:"sm",className:"flex items-center gap-1",children:[r.jsx(H.ExternalLink,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:_.OPEN})]})};function Qi(){return r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Hi,{}),r.jsx(Ki,{}),r.jsx(Wi,{}),r.jsx(Vi,{}),r.jsx($i,{}),r.jsx(zi,{})]})}function Yi({additionalPageTypes:e=[],close:t}){const{data:n}=hn(),{mutate:s,isPending:a}=ir(),[i,o]=T.useState("page"),[l,u]=T.useState(""),[h,y]=T.useState(""),[g,E]=T.useState(""),j=p=>{o(p),u(""),E("")},k=p=>{if(u(p),p&&p!=="none"){const b=n==null?void 0:n.find(R=>R.id===p),A=(b==null?void 0:b.slug)||"",V=g.split("/").pop();E(`${A}${V?`/${V}`:""}`)}else{const b=g.split("/").pop();E(b?`/${b}`:"")}},O=T.useCallback(p=>{if(l&&l!=="none"){const b=n==null?void 0:n.find(R=>R.id===l),A=(b==null?void 0:b.slug)||"",V=p.split("/").pop()||"";E(`${A}/${V}`)}else{const b=p.startsWith("/")?p:`/${p}`;E(b)}},[l,n]),S=p=>{if(p.preventDefault(),!h.trim()){f.toast({title:"Error",description:"Name is required",variant:"destructive"});return}if(i==="global"){s({pageType:"global",name:h,slug:""},{onSuccess:()=>{f.toast({title:"Success",description:"Global Block created successfully"}),t()}});return}if(l&&l!=="none"&&!g){f.toast({title:"Error",description:"Slug is required when a parent page is selected",variant:"destructive"});return}if(i!=="page"&&g===""){f.toast({title:"Error",description:"Slug is required for non-home pages",variant:"destructive"});return}const b={pageType:i,name:h,slug:g===""?"/":g,...l&&l!=="none"&&{parent:l}};s(b,{onSuccess:()=>{f.toast({title:"Success",description:"Page created successfully"}),t()}})};return i==="global"?r.jsxs("form",{onSubmit:S,className:"space-y-4 w-full max-w-md mx-auto",children:[r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"pageType",children:"Page Type"}),r.jsx("select",{id:"pageType",value:i,onChange:p=>j(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:e.map(p=>r.jsx("option",{value:p.key,children:p.name},p.key))})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"name",children:"Name"}),r.jsx(f.Input,{id:"name",value:h,onChange:p=>y(p.target.value),required:!0,"aria-required":"true"})]}),r.jsx(f.Button,{disabled:a,type:"submit",className:"w-full",children:a?"Creating...":"Create Global Block"})]}):r.jsxs("form",{onSubmit:S,className:"space-y-4 w-full max-w-md mx-auto",children:[r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"pageType",children:"Page Type"}),r.jsx("select",{id:"pageType",value:i,onChange:p=>j(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:e.map(p=>r.jsx("option",{value:p.key,children:p.name},p.key))})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"parentPage",children:"Parent"}),r.jsxs("select",{id:"parentPage",value:l,onChange:p=>k(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:[r.jsx("option",{value:"none",children:"None"}),n==null?void 0:n.filter(p=>p.pageType!=="global"&&p.slug!=="/").map(p=>r.jsxs("option",{value:p.id,children:[p.name," (",p.slug,")"]},p.id))]})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"name",children:"Name"}),r.jsx(f.Input,{id:"name",value:h,onChange:p=>y(p.target.value),required:!0,"aria-required":"true"})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"slug",children:"Slug"}),r.jsx(f.Input,{id:"slug",value:g,onChange:p=>O(p.target.value),placeholder:l&&l!=="none"?"Required - e.g. /your-slug":i==="page"?"Leave empty for home page":"Required - e.g. /your-slug"})]}),r.jsx(f.Button,{disabled:a,type:"submit",className:"w-full",children:a?"Creating...":"Create Page"})]})}const Xi=({addEditPage:e,setAddEditPage:t})=>{const{data:n}=gn();return r.jsx(f.Dialog,{open:!!e,onOpenChange:()=>t(void 0),children:r.jsxs(f.DialogContent,{className:"sm:max-w-[425px]",children:[r.jsxs(f.DialogHeader,{children:[r.jsxs(f.DialogTitle,{children:["Add"," "]}),r.jsx(f.DialogDescription,{children:"Add details"})]}),r.jsx(Yi,{close:()=>t(void 0),additionalPageTypes:n??[]})]})})},Nn=({parentSlug:e,page:t,active:n,changeActivePage:s,setUnpublishPage:a,setChangeSlugPage:i,setDeletePage:o,setAddEditPage:l})=>r.jsxs("div",{onClick:()=>s(v.get(t,"id")),className:`rounded flex p-1.5 items-center justify-between leading-none duration-300 cursor-pointer px-3 py-1.5 ${n?"bg-gray-200":"hover:bg-gray-100"}`,children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(H.File,{className:"w-4 h-4 text-slate-500 stroke-[1]"}),r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.jsx("span",{className:"leading-none text-slate-800 font-light",children:v.startCase(t.name)??""}),t.pageType!=="global"?r.jsx(f.Badge,{variant:"outline",className:"ml-2 font-bold text-xs rounded-full leading-none text-slate-500",children:v.get(t,"slug").replace(e,"")||"/"}):r.jsx(f.Badge,{variant:"outline",className:"ml-2 font-bold text-xs rounded-full leading-none text-slate-500",children:"Global Block"})]}),r.jsx("div",{className:"flex items-center space-x-4",children:r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:r.jsx(H.MoreHorizontal,{className:"h-4 w-4 hover:stroke-[3]"})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),l({...t,global:t.pageType==="global"})},children:[r.jsx(H.Pencil,{className:"size-3"}),"Edit"]}),(t==null?void 0:t.online)&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),a(t)},children:[r.jsx(H.Power,{className:"size-3"}),_.UNPUBLISH]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),i(t)},children:[r.jsx(H.Link,{className:"size-3"}),_.CHANGE_SLUG]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),o(t)},children:[r.jsx(H.Trash,{className:"size-3"}),_.DELETE]})]})]})})]}),Ji=({close:e})=>{const[,t]=T.useState([]),[n,s]=T.useState(""),[a,i]=T.useState(null),[o,l]=T.useState(null),[u,h]=T.useState(null),[y,g]=T.useState(null),{data:E,isFetching:j}=hn(),[k,O]=Qe(),S=k.get("page"),p=T.useCallback(A=>{window.history.pushState({},"",`?page=${A}`),O(new URLSearchParams({page:A})),window.dispatchEvent(new PopStateEvent("popstate")),e()},[e,O]);T.useEffect(()=>{if(S&&!j){const A=v.find(E,{id:S});A&&(A!=null&&A.pageType)?t(V=>[...V,A==null?void 0:A.pageType]):(window.history.replaceState(null,"","/"),O(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate")))}},[E,S,j,O]);const b=T.useMemo(()=>{const A=v.filter(E,C=>v.isEmpty(n)?!0:v.includes(v.toLower(C==null?void 0:C.name),v.toLower(n))||v.includes(v.toLower(C==null?void 0:C.slug),v.toLower(n))),V=new Map;A.forEach(C=>{V.set(C.id,{...C,children:[]})});const R=[],Ce=[];V.forEach(C=>{if(C.parent){const q=V.get(C.parent);q?q.children.push(C):R.push(C)}else Ce.push(C)}),R.sort((C,q)=>C.name.localeCompare(q.name)),R.forEach(C=>{C.children.sort((q,ee)=>q.name.localeCompare(ee.name))});const ke=v.filter(Ce,C=>C.pageType==="global"),Te=v.filter(Ce,C=>C.pageType!=="global").sort((C,q)=>C.name.localeCompare(q.name));return v.compact([...Te,...ke,...R])},[E,n]);return console.log(b),r.jsxs("div",{className:"h-full flex flex-col justify-between",children:[r.jsxs("div",{className:"space-y-6 flex flex-col h-full",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"rounded-md bg-primary p-2 text-primary-foreground",children:r.jsx(H.File,{className:"h-6 w-6"})}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Manage your site structure"})]})]}),r.jsxs("div",{className:"relative flex item-center gap-x-4",children:[r.jsx(H.Search,{strokeWidth:2.5,className:"absolute left-3 top-2.5 h-4 w-4 text-gray-400"}),r.jsx(f.Input,{placeholder:"Search pages...",className:"pl-9 text-xs font-medium placeholder:text-gray-400 leading-none text-gray-700",value:n,onChange:A=>s(A.target.value)})]}),j?r.jsx("div",{className:"space-y-2",children:v.map([...Array(5).keys()],A=>r.jsx("div",{className:"h-9 w-full rounded bg-gray-200 animate-pulse"},A))}):v.isEmpty(b)?r.jsxs("div",{className:"h-[70vh] flex flex-col gap-y-1 items-center justify-center text-slate-500 text-sm font-medium",children:[r.jsx(H.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",r.jsx("span",{className:"font-light",children:"Add new page to start"})]}):r.jsx("div",{className:"text-sm text-slate-700 space-y-2 h-[70vh] overflow-y-auto",children:v.map(b,A=>A.children.length>0?r.jsxs("div",{className:"border-0",children:[r.jsx(Nn,{changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:S===A.id,page:A}),r.jsx("div",{className:"bg-white pl-6 pt-2",children:v.map(v.get(A,"children",[]),V=>{const R=S===v.get(V,"id");return r.jsx(Nn,{parentSlug:A.slug,changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:R,page:V})})})]},A.key):r.jsx(Nn,{changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:S===A.id,page:A}))})]}),r.jsxs(f.Button,{className:"text-sm flex gap-x-2",onClick:()=>{g({slug:"",name:"",collection:"page",pageType:"page"})},children:[r.jsx(H.Plus,{className:"w-4 h-4"})," Add New"]}),y&&r.jsx(Xi,{editPage:p,addEditPage:y,setAddEditPage:g}),a&&r.jsx(dr,{page:a,onClose:()=>i(null)}),o&&r.jsx(Qn,{page:o,onClose:()=>l(null)}),u&&r.jsx(ur,{page:u,onClose:()=>h(null)})]})},Zi=()=>{const e=Ht("logo",null);return e?r.jsx("div",{className:"w-full max-h-9 overflow-hidden pr-2",children:T.createElement(e,{})}):null},eo=()=>{const[e]=Qe(),t=e.get("page"),{data:n,isFetching:s}=Re(),[a,i]=T.useState(!1),o=!!t&&!v.isEmpty(n),l=!t||!s&&v.isEmpty(n)||a;return r.jsxs(r.Fragment,{children:[r.jsxs(f.Button,{variant:"secondary",className:"flex items-center w-full space-x-2 py-1",onClick:()=>i(!0),children:[r.jsx("div",{children:r.jsx(H.Logs,{className:"h-4 w-4"})}),r.jsxs("span",{className:"truncate leading-tight flex items-center max-w-[200px]",children:[r.jsx("span",{className:"text-slate-600 pr-1 font-light",children:"Editing:"}),s?r.jsx(H.Loader,{className:"h-4 w-4 animate-spin text-slate-400 ml-2"}):v.startCase(v.get(n,"name"))??""]})]},"template-viewer"),r.jsx(f.Sheet,{open:l,onOpenChange:u=>!u&&o&&i(!1),children:r.jsx(f.SheetContent,{side:"left",className:`!max-w-screen-sm border-border w-full ${o?"":"sheet-hide-close-btn"}`,children:r.jsx(Ji,{close:()=>i(!1)})})})]})},to=()=>{const{fallbackLang:e,languages:t,selectedLang:n,setSelectedLang:s}=Me.useLanguages(),a=v.isEmpty(n)?e:n,[i,o]=T.useState(null),{data:l}=Re(),{data:u}=Kn(),{data:h,isFetching:y}=zn(),g=T.useMemo(()=>{const E=v.compact(v.map(v.get(u,"languages"),j=>{const k=v.find(h,{lang:j});return{key:j,value:v.get(qe,j,j),isLangPageAdded:!!k}})).filter(Boolean);return[{key:e,value:v.get(qe,e),isLangPageAdded:!0},...E]},[h,u]);return v.isEmpty(t)||y?null:r.jsxs(r.Fragment,{children:[r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:r.jsxs(f.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(H.Languages,{className:"w-4 h-4"}),v.get(qe,a,a),r.jsx(H.ChevronDown,{className:"w-4 h-4"})]})}),r.jsxs(f.DropdownMenuContent,{className:"border-border space-y-1",children:[v.map(g.filter(E=>E.isLangPageAdded),E=>r.jsxs(f.DropdownMenuItem,{className:Me.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",E.key===a&&"!bg-gray-200 text-gray-700"),onClick:()=>s(E.key),children:[r.jsx("div",{className:"text-slate-600",children:E.value}),E.key===e&&r.jsxs("small",{className:"text-[9px] flex items-center gap-x-1 text-orange-500 leading-none",children:[r.jsx(H.Star,{fill:"orange",className:"w-2 h-2"}),"Primary"]})]},E.value)),!v.isEmpty(g.filter(E=>!E.isLangPageAdded))&&r.jsxs(r.Fragment,{children:[r.jsx(f.Separator,{}),r.jsxs(f.Button,{size:"sm",variant:"ghost",onClick:()=>{o({name:l==null?void 0:l.name,collection:l==null?void 0:l.collection,lang:"",slug:"",edit:!1})},className:"hover:bg-slate-300 duration-200 font-normal text-xs hover:text-slate-800",children:[r.jsx(H.Plus,{className:"w-3 h-3 mr-1"})," Add Langauge"]})]})]})]}),i&&r.jsx(fr,{languages:t,langProps:i,onClose:()=>o(null)})]})};function no(){return r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Zi,{}),r.jsx(eo,{}),r.jsx(to,{})]})}Pr.loadWebBlocks();const so=e=>{const t=T.useRef([]),[n]=Qe(),s=n.get("page"),{data:a}=Re(),{data:i}=Ti(),{data:o,isFetching:l}=ji(),{blocks:u}=Ni(o),{data:h}=Kn(),{data:y}=gn(),{mutateAsync:g}=_i(),E=wi(),{getUILibraryBlock:j,getUILibraryBlocks:k,onSave:O}=Ci(),{getGlobalBlocks:S,getGlobalBlockBlocks:p}=Pi(),{aiContext:b,setAiContext:A}=$n(),{mutateAsync:V}=Li();t.current=u;const R=T.useMemo(()=>{const C={};return e.mediaManagerComponent&&(C.mediaManagerComponent=e.mediaManagerComponent),C},[e.mediaManagerComponent]),Ce=T.useMemo(()=>Array.isArray(e==null?void 0:e.uiLibraries)?[...i,...e==null?void 0:e.uiLibraries]:i,[i,e==null?void 0:e.uiLibraries]),ke=T.useCallback(async(C,q)=>await V({collection:C,query:q}),[V]),Te=T.useMemo(()=>v.cloneDeep(v.get(h,"theme",{}))||{},[h]);return r.jsx(r.Fragment,{children:r.jsx(Me.ChaiBuilderEditor,{addBlocksDialogTabs:e.addBlocksDialogTabs||[],loading:l,fallbackLang:h.fallbackLang||"en",languages:(h==null?void 0:h.languages)||[],brandingOptions:(h==null?void 0:h.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSaveSupport:e.autoSaveSupport||!0,autoSaveInterval:e.autoSaveInterval||25,onError:e.onError||console.error,getGlobalBlockBlocks:p,getGlobalBlocks:S,blocks:u,theme:Te,getUILibraryBlock:j,getUILibraryBlocks:k,uiLibraries:Ce,collections:y,searchCollectionItems:ke,saveAiContextCallback:async C=>{if(!s)return!0;const q=t.current,ee={_type:"@chai/ai-context",_value:v.isString(C)?C:""},ve=[...q,ee];return await O({page:s,blocks:ve}),A(C),!0},aiContext:b,askAiCallBack:E,onSave:async({blocks:C,theme:q})=>{if(!s)return!0;t.current=C;const ee={_type:"@chai/ai-context",_value:v.isString(b)?b:""},ve=[...C,ee];return await O({page:s,blocks:ve}),t.current=C,v.isEqual(q,Te)||await g({settings:{theme:q}}),!0},topBarComponents:{left:[no],right:[Qi]},sideBarComponents:{top:[...(a==null?void 0:a.collection)!=="global"?[{label:"SEO Setting",component:cr,icon:r.jsx(r.Fragment,{children:r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 21 21",fill:"currentColor",width:"21",height:"21",children:[r.jsx("path",{d:"M9.931 6.818c-1.238 0-2.136.925-2.136 2.2 0 1.279.898 2.207 2.136 2.207.664 0 1.257-.246 1.67-.694a.15.15 0 0 0-.009-.213l-.311-.286a.15.15 0 0 0-.213.009c-.273.297-.677.46-1.137.46-.699 0-1.233-.444-1.375-1.12h3.295a.15.15 0 0 0 .151-.151v-.211c0-1.295-.852-2.2-2.072-2.2m0 .724c.697 0 1.188.422 1.315 1.113h-2.69c.142-.673.676-1.113 1.374-1.113m4.332-.724c-1.246 0-2.15.925-2.15 2.2 0 1.279.904 2.207 2.15 2.207.596 0 1.143-.223 1.538-.628s.612-.965.612-1.579c0-1.275-.904-2.2-2.15-2.2m0 3.683c-.826 0-1.426-.624-1.426-1.483 0-.855.6-1.475 1.426-1.475s1.426.621 1.426 1.476c0 .423-.144.804-.406 1.073-.258.264-.62.41-1.019.41M6.318 8.71c-.665-.206-.902-.335-.902-.645 0-.47.564-.521.806-.521.29 0 .552.07.801.215a.15.15 0 0 0 .206-.055l.212-.366a.15.15 0 0 0-.055-.206 2.27 2.27 0 0 0-1.165-.312c-.915 0-1.53.501-1.53 1.245 0 .899.816 1.152 1.411 1.336.655.203.812.307.804.53-.016.398-.567.429-.735.429-.386 0-.722-.129-.972-.374q-.043-.042-.107-.043a.15.15 0 0 0-.106.045l-.295.302a.15.15 0 0 0 .002.213c.383.374.908.58 1.478.58.859 0 1.432-.441 1.459-1.125.031-.833-.746-1.074-1.313-1.249"}),r.jsx("path",{d:"M20.396 2.049H.604A.604.604 0 0 0 0 2.653v12.7c0 .333.27.604.604.604h6.941c-.266 1.296-.881 1.966-.886 1.971a.604.604 0 0 0 .434 1.024h6.815a.604.604 0 0 0 .434-1.024c-.007-.007-.621-.675-.886-1.971h6.941c.333 0 .604-.27.604-.604V2.652a.604.604 0 0 0-.604-.604m-.604 12.701h-.985v-.17a.604.604 0 0 0-1.208 0v.17h-.63v-.17a.604.604 0 0 0-1.208 0v.17H1.207V3.256h18.585z"})]})})}]:[],...v.isEmpty(h==null?void 0:h.languages)?[]:[{label:`Language ${(a==null?void 0:a.collection)==="global"?"":"page"}`,component:Ui,icon:r.jsx(H.Languages,{className:"w-5 h-5 stroke-[2]"})}]]},...R})})},ro=new Q.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),ao=e=>{const[,t]=ar();return T.useEffect(()=>{t(v.pick(e,["apiUrl","getPreviewUrl","logo","settingComponent"]))},[e,t]),r.jsxs(Q.QueryClientProvider,{client:ro,children:[r.jsx(so,{...e}),r.jsx(bi,{})]})};exports.$TRACK=Fn;exports.ChaiBuilderForge=ao;exports.Dynamic=Aa;exports.For=ta;exports.Index=na;exports.Match=aa;exports.Portal=ja;exports.Show=sa;exports.Switch=ra;exports.addEventListener=Gs;exports.batch=Mr;exports.className=Os;exports.clearDelegatedEvents=ya;exports.convertRemToPixels=mi;exports.createComponent=Hn;exports.createComputed=_n;exports.createContext=Wr;exports.createEffect=qn;exports.createMemo=Ee;exports.createRenderEffect=Fe;exports.createRoot=Be;exports.createSignal=le;exports.createUniqueId=ea;exports.delegateEvents=Is;exports.deleteNestedDataByPath=At;exports.displayValue=ci;exports.getMutationStatusColor=oi;exports.getPreferredColorScheme=pi;exports.getQueryStatusColor=ii;exports.getQueryStatusColorByLabel=li;exports.getQueryStatusLabel=ri;exports.getSidedProp=ai;exports.insert=ln;exports.mergeProps=Vn;exports.mutationSortFns=gi;exports.on=Ur;exports.onCleanup=mt;exports.onMount=Cs;exports.serialize=tr;exports.setAttribute=on;exports.sortFns=fi;exports.splitProps=_s;exports.spread=Ms;exports.stringify=si;exports.template=pa;exports.untrack=me;exports.updateNestedDataByPath=jt;exports.use=Us;exports.useContext=Hr;exports.useTransition=qr;
30
+ <%s key={someKey} {...props} />`,wn,$e,Ar,$e),ns[$e+wn]=!0}}return c===s?Sr(ue):br(ue),ue}}function wr(c,x,w){return ss(c,x,w,!0)}function Cr(c,x,w){return ss(c,x,w,!1)}var Tr=Cr,jr=wr;Ct.Fragment=s,Ct.jsx=Tr,Ct.jsxs=jr}()),Ct}process.env.NODE_ENV==="production"?Pn.exports=kr():Pn.exports=Lr();var r=Pn.exports,W={context:void 0,registry:void 0,getContextId(){return ls(this.context.count)},getNextContextId(){return ls(this.context.count++)}};function ls(e){const t=String(e),n=t.length-1;return W.context.id+(n?String.fromCharCode(96+n):"")+t}function Tt(e){W.context=e}var Dr=(e,t)=>e===t,en=Symbol("solid-proxy"),Fn=Symbol("solid-track"),tn={equals:Dr},Ss=Ns,Ue=1,nn=2,ws={owned:null,cleanups:null,context:null,owner:null},Cn={},Y=null,Tn=null,Ir=null,ne=null,ye=null,Ge=null,cn=0;function Be(e,t){const n=ne,s=Y,a=e.length===0,i=t===void 0?s:t,o=a?ws:{owned:null,cleanups:null,context:i?i.context:null,owner:i},l=a?e:()=>e(()=>me(()=>dn(o)));Y=o,ne=null;try{return Ie(l,!0)}finally{ne=n,Y=s}}function le(e,t){t=t?Object.assign({},tn,t):tn;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=a=>(typeof a=="function"&&(a=a(n.value)),As(n,a));return[js.bind(n),s]}function _n(e,t,n){const s=un(e,t,!0,Ue);yt(s)}function Fe(e,t,n){const s=un(e,t,!1,Ue);yt(s)}function qn(e,t,n){Ss=zr;const s=un(e,t,!1,Ue);(!n||!n.render)&&(s.user=!0),Ge?Ge.push(s):yt(s)}function Ee(e,t,n){n=n?Object.assign({},tn,n):tn;const s=un(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,yt(s),js.bind(s)}function Or(e){return e&&typeof e=="object"&&"then"in e}function Gr(e,t,n){let s,a,i;arguments.length===2&&typeof t=="object"||arguments.length===1?(s=!0,a=e,i={}):(s=e,a=t,i={});let o=null,l=Cn,u=null,h=!1,y="initialValue"in i,g=typeof s=="function"&&Ee(s);const E=new Set,[j,k]=(i.storage||le)(i.initialValue),[O,S]=le(void 0),[p,b]=le(void 0,{equals:!1}),[A,V]=le(y?"ready":"unresolved");if(W.context){u=W.getNextContextId();let C;i.ssrLoadFrom==="initial"?l=i.initialValue:W.load&&(C=W.load(u))&&(l=C)}function R(C,q,ee,ve){return o===C&&(o=null,ve!==void 0&&(y=!0),(C===l||q===l)&&i.onHydrated&&queueMicrotask(()=>i.onHydrated(ve,{value:q})),l=Cn,Ce(q,ee)),q}function Ce(C,q){Ie(()=>{q===void 0&&k(()=>C),V(q!==void 0?"errored":y?"ready":"unresolved"),S(q);for(const ee of E.keys())ee.decrement();E.clear()},!1)}function ke(){const C=Vr,q=j(),ee=O();if(ee!==void 0&&!o)throw ee;return ne&&!ne.user&&C&&_n(()=>{p(),o&&(C.resolved||E.has(C)||(C.increment(),E.add(C)))}),q}function Te(C=!0){if(C!==!1&&h)return;h=!1;const q=g?g():s;if(q==null||q===!1){R(o,me(j));return}const ee=l!==Cn?l:me(()=>a(q,{value:j(),refetching:C}));return Or(ee)?(o=ee,"value"in ee?(ee.status==="success"?R(o,ee.value,void 0,q):R(o,void 0,kn(ee.value),q),ee):(h=!0,queueMicrotask(()=>h=!1),Ie(()=>{V(y?"refreshing":"pending"),b()},!1),ee.then(ve=>R(ee,ve,void 0,q),ve=>R(ee,void 0,kn(ve),q)))):(R(o,ee,void 0,q),ee)}return Object.defineProperties(ke,{state:{get:()=>A()},error:{get:()=>O()},loading:{get(){const C=A();return C==="pending"||C==="refreshing"}},latest:{get(){if(!y)return ke();const C=O();if(C&&!o)throw C;return j()}}}),g?_n(()=>Te(!1)):Te(!1),[ke,{refetch:Te,mutate:k}]}function Mr(e){return Ie(e,!1)}function me(e){if(ne===null)return e();const t=ne;ne=null;try{return e()}finally{ne=t}}function Ur(e,t,n){const s=Array.isArray(e);let a,i=n&&n.defer;return o=>{let l;if(s){l=Array(e.length);for(let h=0;h<e.length;h++)l[h]=e[h]()}else l=e();if(i)return i=!1,o;const u=me(()=>t(l,a,o));return a=l,u}}function Cs(e){qn(()=>me(e))}function mt(e){return Y===null||(Y.cleanups===null?Y.cleanups=[e]:Y.cleanups.push(e)),e}function cs(){return Y}function Rr(e,t){const n=Y,s=ne;Y=e,ne=null;try{return Ie(t,!0)}catch(a){Wn(a)}finally{Y=n,ne=s}}function Br(e){const t=ne,n=Y;return Promise.resolve().then(()=>{ne=t,Y=n;let s;return Ie(e,!1),ne=Y=null,s?s.done:void 0})}var[Fr,oo]=le(!1);function qr(){return[Fr,Br]}function Wr(e,t){const n=Symbol("context");return{id:n,Provider:Qr(n),defaultValue:e}}function Hr(e){let t;return Y&&Y.context&&(t=Y.context[e.id])!==void 0?t:e.defaultValue}function Ts(e){const t=Ee(e),n=Ee(()=>Ln(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}var Vr;function js(){if(this.sources&&this.state)if(this.state===Ue)yt(this);else{const e=ye;ye=null,Ie(()=>rn(this),!1),ye=e}if(ne){const e=this.observers?this.observers.length:0;ne.sources?(ne.sources.push(this),ne.sourceSlots.push(e)):(ne.sources=[this],ne.sourceSlots=[e]),this.observers?(this.observers.push(ne),this.observerSlots.push(ne.sources.length-1)):(this.observers=[ne],this.observerSlots=[ne.sources.length-1])}return this.value}function As(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&Ie(()=>{for(let a=0;a<e.observers.length;a+=1){const i=e.observers[a],o=Tn&&Tn.running;o&&Tn.disposed.has(i),(o?!i.tState:!i.state)&&(i.pure?ye.push(i):Ge.push(i),i.observers&&Ps(i)),o||(i.state=Ue)}if(ye.length>1e6)throw ye=[],new Error},!1)),t}function yt(e){if(!e.fn)return;dn(e);const t=cn;$r(e,e.value,t)}function $r(e,t,n){let s;const a=Y,i=ne;ne=Y=e;try{s=e.fn(t)}catch(o){return e.pure&&(e.state=Ue,e.owned&&e.owned.forEach(dn),e.owned=null),e.updatedAt=n+1,Wn(o)}finally{ne=i,Y=a}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?As(e,s):e.value=s,e.updatedAt=n)}function un(e,t,n,s=Ue,a){const i={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:Y,context:Y?Y.context:null,pure:n};return Y===null||Y!==ws&&(Y.owned?Y.owned.push(i):Y.owned=[i]),i}function sn(e){if(e.state===0)return;if(e.state===nn)return rn(e);if(e.suspense&&me(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<cn);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===Ue)yt(e);else if(e.state===nn){const s=ye;ye=null,Ie(()=>rn(e,t[0]),!1),ye=s}}function Ie(e,t){if(ye)return e();let n=!1;t||(ye=[]),Ge?n=!0:Ge=[],cn++;try{const s=e();return Kr(n),s}catch(s){n||(Ge=null),ye=null,Wn(s)}}function Kr(e){if(ye&&(Ns(ye),ye=null),e)return;const t=Ge;Ge=null,t.length&&Ie(()=>Ss(t),!1)}function Ns(e){for(let t=0;t<e.length;t++)sn(e[t])}function zr(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:sn(s)}if(W.context){if(W.count){W.effects||(W.effects=[]),W.effects.push(...e.slice(0,n));return}else W.effects&&(e=[...W.effects,...e],n+=W.effects.length,delete W.effects);Tt()}for(t=0;t<n;t++)sn(e[t])}function rn(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const a=s.state;a===Ue?s!==t&&(!s.updatedAt||s.updatedAt<cn)&&sn(s):a===nn&&rn(s,t)}}}function Ps(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=nn,n.pure?ye.push(n):Ge.push(n),n.observers&&Ps(n))}}function dn(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),a=n.observers;if(a&&a.length){const i=a.pop(),o=n.observerSlots.pop();s<a.length&&(i.sourceSlots[o]=s,a[s]=i,n.observerSlots[s]=o)}}if(e.owned){for(t=e.owned.length-1;t>=0;t--)dn(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function kn(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Wn(e,t=Y){throw kn(e)}function Ln(e){if(typeof e=="function"&&!e.length)return Ln(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=Ln(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function Qr(e,t){return function(s){let a;return Fe(()=>a=me(()=>(Y.context={...Y.context,[e]:s.value},Ts(()=>s.children))),void 0),a}}var Dn=Symbol("fallback");function an(e){for(let t=0;t<e.length;t++)e[t]()}function Yr(e,t,n={}){let s=[],a=[],i=[],o=0,l=t.length>1?[]:null;return mt(()=>an(i)),()=>{let u=e()||[],h=u.length,y,g;return u[Fn],me(()=>{let j,k,O,S,p,b,A,V,R;if(h===0)o!==0&&(an(i),i=[],s=[],a=[],o=0,l&&(l=[])),n.fallback&&(s=[Dn],a[0]=Be(Ce=>(i[0]=Ce,n.fallback())),o=1);else if(o===0){for(a=new Array(h),g=0;g<h;g++)s[g]=u[g],a[g]=Be(E);o=h}else{for(O=new Array(h),S=new Array(h),l&&(p=new Array(h)),b=0,A=Math.min(o,h);b<A&&s[b]===u[b];b++);for(A=o-1,V=h-1;A>=b&&V>=b&&s[A]===u[V];A--,V--)O[V]=a[A],S[V]=i[A],l&&(p[V]=l[A]);for(j=new Map,k=new Array(V+1),g=V;g>=b;g--)R=u[g],y=j.get(R),k[g]=y===void 0?-1:y,j.set(R,g);for(y=b;y<=A;y++)R=s[y],g=j.get(R),g!==void 0&&g!==-1?(O[g]=a[y],S[g]=i[y],l&&(p[g]=l[y]),g=k[g],j.set(R,g)):i[y]();for(g=b;g<h;g++)g in O?(a[g]=O[g],i[g]=S[g],l&&(l[g]=p[g],l[g](g))):a[g]=Be(E);a=a.slice(0,o=h),s=u.slice(0)}return a});function E(j){if(i[g]=j,l){const[k,O]=le(g);return l[g]=O,t(u[g],k)}return t(u[g])}}}function Xr(e,t,n={}){let s=[],a=[],i=[],o=[],l=0,u;return mt(()=>an(i)),()=>{const h=e()||[],y=h.length;return h[Fn],me(()=>{if(y===0)return l!==0&&(an(i),i=[],s=[],a=[],l=0,o=[]),n.fallback&&(s=[Dn],a[0]=Be(E=>(i[0]=E,n.fallback())),l=1),a;for(s[0]===Dn&&(i[0](),i=[],s=[],a=[],l=0),u=0;u<y;u++)u<s.length&&s[u]!==h[u]?o[u](()=>h[u]):u>=s.length&&(a[u]=Be(g));for(;u<s.length;u++)i[u]();return l=o.length=i.length=y,s=h.slice(0),a=a.slice(0,l)});function g(E){i[u]=E;const[j,k]=le(h[u]);return o[u]=k,t(j,u)}}}function Hn(e,t){return me(()=>e(t||{}))}function Yt(){return!0}var In={get(e,t,n){return t===en?n:e.get(t)},has(e,t){return t===en?!0:e.has(t)},set:Yt,deleteProperty:Yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Yt,deleteProperty:Yt}},ownKeys(e){return e.keys()}};function jn(e){return(e=typeof e=="function"?e():e)?e:{}}function Jr(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function Vn(...e){let t=!1;for(let o=0;o<e.length;o++){const l=e[o];t=t||!!l&&en in l,e[o]=typeof l=="function"?(t=!0,Ee(l)):l}if(t)return new Proxy({get(o){for(let l=e.length-1;l>=0;l--){const u=jn(e[l])[o];if(u!==void 0)return u}},has(o){for(let l=e.length-1;l>=0;l--)if(o in jn(e[l]))return!0;return!1},keys(){const o=[];for(let l=0;l<e.length;l++)o.push(...Object.keys(jn(e[l])));return[...new Set(o)]}},In);const n={},s=Object.create(null);for(let o=e.length-1;o>=0;o--){const l=e[o];if(!l)continue;const u=Object.getOwnPropertyNames(l);for(let h=u.length-1;h>=0;h--){const y=u[h];if(y==="__proto__"||y==="constructor")continue;const g=Object.getOwnPropertyDescriptor(l,y);if(!s[y])s[y]=g.get?{enumerable:!0,configurable:!0,get:Jr.bind(n[y]=[g.get.bind(l)])}:g.value!==void 0?g:void 0;else{const E=n[y];E&&(g.get?E.push(g.get.bind(l)):g.value!==void 0&&E.push(()=>g.value))}}}const a={},i=Object.keys(s);for(let o=i.length-1;o>=0;o--){const l=i[o],u=s[l];u&&u.get?Object.defineProperty(a,l,u):a[l]=u?u.value:void 0}return a}function _s(e,...t){if(en in e){const a=new Set(t.length>1?t.flat():t[0]),i=t.map(o=>new Proxy({get(l){return o.includes(l)?e[l]:void 0},has(l){return o.includes(l)&&l in e},keys(){return o.filter(l=>l in e)}},In));return i.push(new Proxy({get(o){return a.has(o)?void 0:e[o]},has(o){return a.has(o)?!1:o in e},keys(){return Object.keys(e).filter(o=>!a.has(o))}},In)),i}const n={},s=t.map(()=>({}));for(const a of Object.getOwnPropertyNames(e)){const i=Object.getOwnPropertyDescriptor(e,a),o=!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable;let l=!1,u=0;for(const h of t)h.includes(a)&&(l=!0,o?s[u][a]=i.value:Object.defineProperty(s[u],a,i)),++u;l||(o?n[a]=i.value:Object.defineProperty(n,a,i))}return[...s,n]}function ks(e){let t,n;const s=a=>{const i=W.context;if(i){const[l,u]=le();W.count||(W.count=0),W.count++,(n||(n=e())).then(h=>{Tt(i),W.count--,u(()=>h.default),Tt()}),t=l}else if(!t){const[l]=Gr(()=>(n||(n=e())).then(u=>u.default));t=l}let o;return Ee(()=>(o=t())&&me(()=>{if(!i)return o(a);const l=W.context;Tt(i);const u=o(a);return Tt(l),u}))};return s.preload=()=>n||((n=e()).then(a=>t=()=>a.default),n),s}var Zr=0;function ea(){return W.context?W.getNextContextId():`cl-${Zr++}`}var Ls=e=>`Stale read from <${e}>.`;function ta(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(Yr(()=>e.each,e.children,t||void 0))}function na(e){const t="fallback"in e&&{fallback:()=>e.fallback};return Ee(Xr(()=>e.each,e.children,t||void 0))}function sa(e){const t=e.keyed,n=Ee(()=>e.when,void 0,{equals:(s,a)=>t?s===a:!s==!a});return Ee(()=>{const s=n();if(s){const a=e.children;return typeof a=="function"&&a.length>0?me(()=>a(t?s:()=>{if(!me(n))throw Ls("Show");return e.when})):a}return e.fallback},void 0,void 0)}function ra(e){let t=!1;const n=(i,o)=>(t?i[1]===o[1]:!i[1]==!o[1])&&i[2]===o[2],s=Ts(()=>e.children),a=Ee(()=>{let i=s();Array.isArray(i)||(i=[i]);for(let o=0;o<i.length;o++){const l=i[o].when;if(l)return t=!!i[o].keyed,[o,l,i[o]]}return[-1]},void 0,{equals:n});return Ee(()=>{const[i,o,l]=a();if(i<0)return e.fallback;const u=l.children;return typeof u=="function"&&u.length>0?me(()=>u(t?o:()=>{if(me(a)[0]!==i)throw Ls("Match");return l.when})):u},void 0,void 0)}function aa(e){return e}var ia=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],oa=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...ia]),la=new Set(["innerHTML","textContent","innerText","children"]),ca=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ua=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function da(e,t){const n=ua[e];return typeof n=="object"?n[t]?n.$:void 0:n}var fa=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ha=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),ga={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function ma(e,t,n){let s=n.length,a=t.length,i=s,o=0,l=0,u=t[a-1].nextSibling,h=null;for(;o<a||l<i;){if(t[o]===n[l]){o++,l++;continue}for(;t[a-1]===n[i-1];)a--,i--;if(a===o){const y=i<s?l?n[l-1].nextSibling:n[i-l]:u;for(;l<i;)e.insertBefore(n[l++],y)}else if(i===l)for(;o<a;)(!h||!h.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[i-1]&&n[l]===t[a-1]){const y=t[--a].nextSibling;e.insertBefore(n[l++],t[o++].nextSibling),e.insertBefore(n[--i],y),t[a]=n[i]}else{if(!h){h=new Map;let g=l;for(;g<i;)h.set(n[g],g++)}const y=h.get(t[o]);if(y!=null)if(l<y&&y<i){let g=o,E=1,j;for(;++g<a&&g<i&&!((j=h.get(t[g]))==null||j!==y+E);)E++;if(E>y-l){const k=t[o];for(;l<y;)e.insertBefore(n[l++],k)}else e.replaceChild(n[l++],t[o++])}else o++;else t[o++].remove()}}}var Nt="_$DX_DELEGATE";function Ds(e,t,n,s={}){let a;return Be(i=>{a=i,t===document?e():ln(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{a(),t.textContent=""}}function pa(e,t,n){let s;const a=()=>{const o=document.createElement("template");return o.innerHTML=e,o.content.firstChild},i=()=>(s||(s=a())).cloneNode(!0);return i.cloneNode=i,i}function Is(e,t=window.document){const n=t[Nt]||(t[Nt]=new Set);for(let s=0,a=e.length;s<a;s++){const i=e[s];n.has(i)||(n.add(i),t.addEventListener(i,Rs))}}function ya(e=window.document){if(e[Nt]){for(let t of e[Nt].keys())e.removeEventListener(t,Rs);delete e[Nt]}}function on(e,t,n){W.context&&e.isConnected||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function va(e,t,n,s){W.context&&e.isConnected||(s==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,s))}function Os(e,t){W.context&&e.isConnected||(t==null?e.removeAttribute("class"):e.className=t)}function Gs(e,t,n,s){if(s)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const a=n[0];e.addEventListener(t,n[0]=i=>a.call(e,n[1],i))}else e.addEventListener(t,n)}function xa(e,t,n={}){const s=Object.keys(t||{}),a=Object.keys(n);let i,o;for(i=0,o=a.length;i<o;i++){const l=a[i];!l||l==="undefined"||t[l]||(us(e,l,!1),delete n[l])}for(i=0,o=s.length;i<o;i++){const l=s[i],u=!!t[l];!l||l==="undefined"||n[l]===u||!u||(us(e,l,!0),n[l]=u)}return n}function Ea(e,t,n){if(!t)return n?on(e,"style"):t;const s=e.style;if(typeof t=="string")return s.cssText=t;typeof n=="string"&&(s.cssText=n=void 0),n||(n={}),t||(t={});let a,i;for(i in n)t[i]==null&&s.removeProperty(i),delete n[i];for(i in t)a=t[i],a!==n[i]&&(s.setProperty(i,a),n[i]=a);return n}function Ms(e,t={},n,s){const a={};return s||Fe(()=>a.children=_t(e,t.children,a.children)),Fe(()=>typeof t.ref=="function"&&Us(t.ref,e)),Fe(()=>ba(e,t,n,!0,a,!0)),a}function Us(e,t,n){return me(()=>e(t,n))}function ln(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return _t(e,t,s,n);Fe(a=>_t(e,t(),a,n),s)}function ba(e,t,n,s,a={},i=!1){t||(t={});for(const o in a)if(!(o in t)){if(o==="children")continue;a[o]=ds(e,o,null,a[o],n,i)}for(const o in t){if(o==="children")continue;const l=t[o];a[o]=ds(e,o,l,a[o],n,i)}}function Sa(e){let t,n;return!W.context||!(t=W.registry.get(n=Ca()))?e():(W.completed&&W.completed.add(t),W.registry.delete(n),t)}function wa(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function us(e,t,n){const s=t.trim().split(/\s+/);for(let a=0,i=s.length;a<i;a++)e.classList.toggle(s[a],n)}function ds(e,t,n,s,a,i){let o,l,u,h,y;if(t==="style")return Ea(e,n,s);if(t==="classList")return xa(e,n,s);if(n===s)return s;if(t==="ref")i||n(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);s&&e.removeEventListener(g,s),n&&e.addEventListener(g,n)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);s&&e.removeEventListener(g,s,!0),n&&e.addEventListener(g,n,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=fa.has(g);if(!E&&s){const j=Array.isArray(s)?s[0]:s;e.removeEventListener(g,j)}(E||n)&&(Gs(e,g,n,E),E&&Is([g]))}else if(t.slice(0,5)==="attr:")on(e,t.slice(5),n);else if((y=t.slice(0,5)==="prop:")||(u=la.has(t))||!a&&((h=da(t,e.tagName))||(l=oa.has(t)))||(o=e.nodeName.includes("-"))){if(y)t=t.slice(5),l=!0;else if(W.context&&e.isConnected)return n;t==="class"||t==="className"?Os(e,n):o&&!l&&!u?e[wa(t)]=n:e[h||t]=n}else{const g=a&&t.indexOf(":")>-1&&ga[t.split(":")[0]];g?va(e,g,t,n):on(e,ca[t]||t,n)}return n}function Rs(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),W.registry&&!W.done&&(W.done=_$HY.done=!0);n;){const s=n[t];if(s&&!n.disabled){const a=n[`${t}Data`];if(a!==void 0?s.call(n,a,e):s.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function _t(e,t,n,s,a){const i=!!W.context&&e.isConnected;if(i){!n&&(n=[...e.childNodes]);let u=[];for(let h=0;h<n.length;h++){const y=n[h];y.nodeType===8&&y.data.slice(0,2)==="!$"?y.remove():u.push(y)}n=u}for(;typeof n=="function";)n=n();if(t===n)return n;const o=typeof t,l=s!==void 0;if(e=l&&n[0]&&n[0].parentNode||e,o==="string"||o==="number"){if(i||o==="number"&&(t=t.toString(),t===n))return n;if(l){let u=n[0];u&&u.nodeType===3?u.data!==t&&(u.data=t):u=document.createTextNode(t),n=Je(e,n,s,u)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||o==="boolean"){if(i)return n;n=Je(e,n,s)}else{if(o==="function")return Fe(()=>{let u=t();for(;typeof u=="function";)u=u();n=_t(e,u,n,s)}),()=>n;if(Array.isArray(t)){const u=[],h=n&&Array.isArray(n);if(On(u,t,n,a))return Fe(()=>n=_t(e,u,n,s,!0)),()=>n;if(i){if(!u.length)return n;if(s===void 0)return[...e.childNodes];let y=u[0],g=[y];for(;(y=y.nextSibling)!==s;)g.push(y);return n=g}if(u.length===0){if(n=Je(e,n,s),l)return n}else h?n.length===0?fs(e,u,s):ma(e,n,u):(n&&Je(e),fs(e,u));n=u}else if(t.nodeType){if(i&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=Je(e,n,s,t);Je(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function On(e,t,n,s){let a=!1;for(let i=0,o=t.length;i<o;i++){let l=t[i],u=n&&n[e.length],h;if(!(l==null||l===!0||l===!1))if((h=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))a=On(e,l,u)||a;else if(h==="function")if(s){for(;typeof l=="function";)l=l();a=On(e,Array.isArray(l)?l:[l],Array.isArray(u)?u:[u])||a}else e.push(l),a=!0;else{const y=String(l);u&&u.nodeType===3&&u.data===y?e.push(u):e.push(document.createTextNode(y))}}return a}function fs(e,t,n=null){for(let s=0,a=t.length;s<a;s++)e.insertBefore(t[s],n)}function Je(e,t,n,s){if(n===void 0)return e.textContent="";const a=s||document.createTextNode("");if(t.length){let i=!1;for(let o=t.length-1;o>=0;o--){const l=t[o];if(a!==l){const u=l.parentNode===e;!i&&!o?u?e.replaceChild(a,l):e.insertBefore(a,n):u&&l.remove()}else i=!0}}else e.insertBefore(a,n);return[a]}function Ca(){return W.getNextContextId()}var Ta="http://www.w3.org/2000/svg";function Bs(e,t=!1){return t?document.createElementNS(Ta,e):document.createElement(e)}function ja(e){const{useShadow:t}=e,n=document.createTextNode(""),s=()=>e.mount||document.body,a=cs();let i,o=!!W.context;return qn(()=>{o&&(cs().user=o=!1),i||(i=Rr(a,()=>Ee(()=>e.children)));const l=s();if(l instanceof HTMLHeadElement){const[u,h]=le(!1),y=()=>h(!0);Be(g=>ln(l,()=>u()?g():i(),null)),mt(y)}else{const u=Bs(e.isSVG?"g":"div",e.isSVG),h=t&&u.attachShadow?u.attachShadow({mode:"open"}):u;Object.defineProperty(u,"_$host",{get(){return n.parentNode},configurable:!0}),ln(h,i),l.appendChild(u),e.ref&&e.ref(u),mt(()=>l.removeChild(u))}},void 0,{render:!o}),n}function Aa(e){const[t,n]=_s(e,["component"]),s=Ee(()=>t.component);return Ee(()=>{const a=s();switch(typeof a){case"function":return me(()=>a(n));case"string":const i=ha.has(a),o=W.context?Sa():Bs(a,i);return Ms(o,n,i),o}})}var Na=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Fs=class{constructor(e){this.generateIdentifier=e,this.kv=new Na}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Pa=class extends Fs{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function _a(e){if("values"in Object)return Object.values(e);const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function ka(e,t){const n=_a(e);if("find"in n)return n.find(t);const s=n;for(let a=0;a<s.length;a++){const i=s[a];if(t(i))return i}}function pt(e,t){Object.entries(e).forEach(([n,s])=>t(s,n))}function Zt(e,t){return e.indexOf(t)!==-1}function hs(e,t){for(let n=0;n<e.length;n++){const s=e[n];if(t(s))return s}}var La=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ka(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Da=e=>Object.prototype.toString.call(e).slice(8,-1),qs=e=>typeof e>"u",Ia=e=>e===null,kt=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Gn=e=>kt(e)&&Object.keys(e).length===0,We=e=>Array.isArray(e),Oa=e=>typeof e=="string",Ga=e=>typeof e=="number"&&!isNaN(e),Ma=e=>typeof e=="boolean",Ua=e=>e instanceof RegExp,Lt=e=>e instanceof Map,Dt=e=>e instanceof Set,Ws=e=>Da(e)==="Symbol",Ra=e=>e instanceof Date&&!isNaN(e.valueOf()),Ba=e=>e instanceof Error,gs=e=>typeof e=="number"&&isNaN(e),Fa=e=>Ma(e)||Ia(e)||qs(e)||Ga(e)||Oa(e)||Ws(e),qa=e=>typeof e=="bigint",Wa=e=>e===1/0||e===-1/0,Ha=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Va=e=>e instanceof URL,Hs=e=>e.replace(/\./g,"\\."),An=e=>e.map(String).map(Hs).join("."),Pt=e=>{const t=[];let n="";for(let a=0;a<e.length;a++){let i=e.charAt(a);if(i==="\\"&&e.charAt(a+1)==="."){n+=".",a++;continue}if(i==="."){t.push(n),n="";continue}n+=i}const s=n;return t.push(s),t};function De(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var Vs=[De(qs,"undefined",()=>null,()=>{}),De(qa,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),De(Ra,"Date",e=>e.toISOString(),e=>new Date(e)),De(Ba,"Error",(e,t)=>{const n={name:e.name,message:e.message};return t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n},(e,t)=>{const n=new Error(e.message);return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(s=>{n[s]=e[s]}),n}),De(Ua,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),n=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,n)}),De(Dt,"set",e=>[...e.values()],e=>new Set(e)),De(Lt,"map",e=>[...e.entries()],e=>new Map(e)),De(e=>gs(e)||Wa(e),"number",e=>gs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),De(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),De(Va,"URL",e=>e.toString(),e=>new URL(e))];function fn(e,t,n,s){return{isApplicable:e,annotation:t,transform:n,untransform:s}}var $s=fn((e,t)=>Ws(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{const s=n.symbolRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown symbol");return s}),$a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Ks=fn(Ha,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const n=$a[t[1]];if(!n)throw new Error("Trying to deserialize unknown typed array");return new n(e)});function zs(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Qs=fn(zs,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};const s={};return n.forEach(a=>{s[a]=e[a]}),s},(e,t,n)=>{const s=n.classRegistry.getValue(t[1]);if(!s)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(s.prototype),e)}),Ys=fn((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{const s=n.customTransformerRegistry.findByName(t[1]);if(!s)throw new Error("Trying to deserialize unknown custom value");return s.deserialize(e)}),Ka=[Qs,$s,Ys,Ks],ms=(e,t)=>{const n=hs(Ka,a=>a.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};const s=hs(Vs,a=>a.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation}},Xs={};Vs.forEach(e=>{Xs[e.annotation]=e});var za=(e,t,n)=>{if(We(t))switch(t[0]){case"symbol":return $s.untransform(e,t,n);case"class":return Qs.untransform(e,t,n);case"custom":return Ys.untransform(e,t,n);case"typed-array":return Ks.untransform(e,t,n);default:throw new Error("Unknown transformation: "+t)}else{const s=Xs[t];if(!s)throw new Error("Unknown transformation: "+t);return s.untransform(e,n)}},Ze=(e,t)=>{const n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function Js(e){if(Zt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Zt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Zt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Qa=(e,t)=>{Js(t);for(let n=0;n<t.length;n++){const s=t[n];if(Dt(e))e=Ze(e,+s);else if(Lt(e)){const a=+s,i=+t[++n]==0?"key":"value",o=Ze(e,a);switch(i){case"key":e=o;break;case"value":e=e.get(o);break}}else e=e[s]}return e},Mn=(e,t,n)=>{if(Js(t),t.length===0)return n(e);let s=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(We(s)){const l=+o;s=s[l]}else if(kt(s))s=s[o];else if(Dt(s)){const l=+o;s=Ze(s,l)}else if(Lt(s)){if(i===t.length-2)break;const u=+o,h=+t[++i]==0?"key":"value",y=Ze(s,u);switch(h){case"key":s=y;break;case"value":s=s.get(y);break}}}const a=t[t.length-1];if(We(s)?s[+a]=n(s[+a]):kt(s)&&(s[a]=n(s[a])),Dt(s)){const i=Ze(s,+a),o=n(i);i!==o&&(s.delete(i),s.add(o))}if(Lt(s)){const i=+t[t.length-2],o=Ze(s,i);switch(+a==0?"key":"value"){case"key":{const u=n(o);s.set(u,s.get(o)),u!==o&&s.delete(o);break}case"value":{s.set(o,n(s.get(o)));break}}}return e};function Un(e,t,n=[]){if(!e)return;if(!We(e)){pt(e,(i,o)=>Un(i,t,[...n,...Pt(o)]));return}const[s,a]=e;a&&pt(a,(i,o)=>{Un(i,t,[...n,...Pt(o)])}),t(s,n)}function Ya(e,t,n){return Un(t,(s,a)=>{e=Mn(e,a,i=>za(i,s,n))}),e}function Xa(e,t){function n(s,a){const i=Qa(e,Pt(a));s.map(Pt).forEach(o=>{e=Mn(e,o,()=>i)})}if(We(t)){const[s,a]=t;s.forEach(i=>{e=Mn(e,Pt(i),()=>e)}),a&&pt(a,n)}else pt(t,n);return e}var Ja=(e,t)=>kt(e)||We(e)||Lt(e)||Dt(e)||zs(e,t);function Za(e,t,n){const s=n.get(e);s?s.push(t):n.set(e,[t])}function ei(e,t){const n={};let s;return e.forEach(a=>{if(a.length<=1)return;t||(a=a.map(l=>l.map(String)).sort((l,u)=>l.length-u.length));const[i,...o]=a;i.length===0?s=o.map(An):n[An(i)]=o.map(An)}),s?Gn(n)?[s]:[s,n]:Gn(n)?void 0:n}var Zs=(e,t,n,s,a=[],i=[],o=new Map)=>{const l=Fa(e);if(!l){Za(e,a,t);const j=o.get(e);if(j)return s?{transformedValue:null}:j}if(!Ja(e,n)){const j=ms(e,n),k=j?{transformedValue:j.value,annotations:[j.type]}:{transformedValue:e};return l||o.set(e,k),k}if(Zt(i,e))return{transformedValue:null};const u=ms(e,n),h=(u==null?void 0:u.value)??e,y=We(h)?[]:{},g={};pt(h,(j,k)=>{if(k==="__proto__"||k==="constructor"||k==="prototype")throw new Error(`Detected property ${k}. This is a prototype pollution risk, please remove it from your object.`);const O=Zs(j,t,n,s,[...a,k],[...i,e],o);y[k]=O.transformedValue,We(O.annotations)?g[k]=O.annotations:kt(O.annotations)&&pt(O.annotations,(S,p)=>{g[Hs(k)+"."+p]=S})});const E=Gn(g)?{transformedValue:y,annotations:u?[u.type]:void 0}:{transformedValue:y,annotations:u?[u.type,g]:g};return l||o.set(e,E),E};function er(e){return Object.prototype.toString.call(e).slice(8,-1)}function ps(e){return er(e)==="Array"}function ti(e){if(er(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ni(e,t,n,s,a){const i={}.propertyIsEnumerable.call(s,t)?"enumerable":"nonenumerable";i==="enumerable"&&(e[t]=n),a&&i==="nonenumerable"&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function Rn(e,t={}){if(ps(e))return e.map(a=>Rn(a,t));if(!ti(e))return e;const n=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);return[...n,...s].reduce((a,i)=>{if(ps(t.props)&&!t.props.includes(i))return a;const o=e[i],l=Rn(o,t);return ni(a,i,l,e,t.nonenumerable),a},{})}var se=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Pa,this.symbolRegistry=new Fs(t=>t.description??""),this.customTransformerRegistry=new La,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,n=Zs(e,t,this,this.dedupe),s={json:n.transformedValue};n.annotations&&(s.meta={...s.meta,values:n.annotations});const a=ei(t,this.dedupe);return a&&(s.meta={...s.meta,referentialEqualities:a}),s}deserialize(e){const{json:t,meta:n}=e;let s=Rn(t);return n!=null&&n.values&&(s=Ya(s,n.values,this)),n!=null&&n.referentialEqualities&&(s=Xa(s,n.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};se.defaultInstance=new se;se.serialize=se.defaultInstance.serialize.bind(se.defaultInstance);se.deserialize=se.defaultInstance.deserialize.bind(se.defaultInstance);se.stringify=se.defaultInstance.stringify.bind(se.defaultInstance);se.parse=se.defaultInstance.parse.bind(se.defaultInstance);se.registerClass=se.defaultInstance.registerClass.bind(se.defaultInstance);se.registerSymbol=se.defaultInstance.registerSymbol.bind(se.defaultInstance);se.registerCustom=se.defaultInstance.registerCustom.bind(se.defaultInstance);se.allowErrorProps=se.defaultInstance.allowErrorProps.bind(se.defaultInstance);var tr=se.serialize,si=se.stringify;function ri(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function ai(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function ii({queryState:e,observerCount:t,isStale:n}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":n?"yellow":"green":"gray"}function oi({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function li(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var ci=(e,t=!1)=>{const{json:n}=tr(e);return JSON.stringify(n,null,t?2:void 0)},Xt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ui=(e,t)=>e.queryHash.localeCompare(t.queryHash),nr=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,di=(e,t)=>Xt(e)===Xt(t)?nr(e,t):Xt(e)>Xt(t)?1:-1,fi={status:di,"query hash":ui,"last updated":nr},Jt=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,sr=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,hi=(e,t)=>Jt(e)===Jt(t)?sr(e,t):Jt(e)>Jt(t)?1:-1,gi={status:hi,"last updated":sr},mi=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),pi=()=>{const[e,t]=le("dark");return Cs(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches?"dark":"light");const s=a=>{t(a.matches?"dark":"light")};n.addEventListener("change",s),mt(()=>n.removeEventListener("change",s))}),e},jt=(e,t,n)=>{if(t.length===0)return n;if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.set(t[0],n),s;const[a,...i]=t;return s.set(a,jt(s.get(a),i,n)),s}if(e instanceof Set){const s=jt(Array.from(e),t,n);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s[t[0]]=n,s;const[a,...i]=t;return s[a]=jt(s[a],i,n),s}if(e instanceof Object){const s={...e};if(t.length===1)return s[t[0]]=n,s;const[a,...i]=t;return s[a]=jt(s[a],i,n),s}return e},At=(e,t)=>{if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.delete(t[0]),n;const[s,...a]=t;return n.set(s,At(n.get(s),a)),n}if(e instanceof Set){const n=At(Array.from(e),t);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n.filter((i,o)=>o.toString()!==t[0]);const[s,...a]=t;return n[s]=At(n[s],a),n}if(e instanceof Object){const n={...e};if(t.length===1)return delete n[t[0]],n;const[s,...a]=t;return n[s]=At(n[s],a),n}return e},rr=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const s=document.createElement("style"),a=document.createTextNode("");s.appendChild(a),s.id="_goober",s.setAttribute("nonce",e),t?t.appendChild(s):document.head.appendChild(s)},et,It,Ot,Gt,Ke,Mt,tt,nt,st,rt,at,it,Ut,vs,yi=(vs=class{constructor(e){te(this,et);te(this,It);te(this,Ot);te(this,Gt);te(this,Ke,!1);te(this,Mt);te(this,tt);te(this,nt);te(this,st);te(this,rt);te(this,at);te(this,it);te(this,Ut);const{client:t,queryFlavor:n,version:s,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:h,shadowDOMTarget:y}=e;Z(this,et,le(t)),Z(this,Ot,n),Z(this,Gt,s),Z(this,It,a),Z(this,Mt,h),Z(this,tt,y),Z(this,nt,le(i)),Z(this,st,le(o)),Z(this,rt,le(l)),Z(this,at,le(u))}setButtonPosition(e){I(this,nt)[1](e)}setPosition(e){I(this,st)[1](e)}setInitialIsOpen(e){I(this,rt)[1](e)}setErrorTypes(e){I(this,at)[1](e)}setClient(e){I(this,et)[1](e)}mount(e){if(I(this,Ke))throw new Error("Devtools is already mounted");const t=Ds(()=>{const n=this,[s]=I(this,nt),[a]=I(this,st),[i]=I(this,rt),[o]=I(this,at),[l]=I(this,et);let u;return I(this,it)?u=I(this,it):(u=ks(()=>Promise.resolve().then(()=>require("./BMGNQTAT-D-iYXryz.cjs"))),Z(this,it,u)),rr(I(this,Mt),I(this,tt)),Hn(u,Vn({get queryFlavor(){return I(n,Ot)},get version(){return I(n,Gt)},get onlineManager(){return I(n,It)},get shadowDOMTarget(){return I(n,tt)}},{get client(){return l()},get buttonPosition(){return s()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()}}))},e);Z(this,Ke,!0),Z(this,Ut,t)}unmount(){var e;if(!I(this,Ke))throw new Error("Devtools is not mounted");(e=I(this,Ut))==null||e.call(this),Z(this,Ke,!1)}},et=new WeakMap,It=new WeakMap,Ot=new WeakMap,Gt=new WeakMap,Ke=new WeakMap,Mt=new WeakMap,tt=new WeakMap,nt=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,it=new WeakMap,Ut=new WeakMap,vs),ot,Rt,Bt,Ft,ze,qt,lt,ct,ut,dt,ft,ht,gt,Wt,xs,vi=(xs=class{constructor(e){te(this,ot);te(this,Rt);te(this,Bt);te(this,Ft);te(this,ze,!1);te(this,qt);te(this,lt);te(this,ct);te(this,ut);te(this,dt);te(this,ft);te(this,ht);te(this,gt);te(this,Wt);const{client:t,queryFlavor:n,version:s,onlineManager:a,buttonPosition:i,position:o,initialIsOpen:l,errorTypes:u,styleNonce:h,shadowDOMTarget:y,onClose:g}=e;Z(this,ot,le(t)),Z(this,Bt,n),Z(this,Ft,s),Z(this,Rt,a),Z(this,qt,h),Z(this,lt,y),Z(this,ct,le(i)),Z(this,ut,le(o)),Z(this,dt,le(l)),Z(this,ft,le(u)),Z(this,ht,le(g))}setButtonPosition(e){I(this,ct)[1](e)}setPosition(e){I(this,ut)[1](e)}setInitialIsOpen(e){I(this,dt)[1](e)}setErrorTypes(e){I(this,ft)[1](e)}setClient(e){I(this,ot)[1](e)}setOnClose(e){I(this,ht)[1](()=>e)}mount(e){if(I(this,ze))throw new Error("Devtools is already mounted");const t=Ds(()=>{const n=this,[s]=I(this,ct),[a]=I(this,ut),[i]=I(this,dt),[o]=I(this,ft),[l]=I(this,ot),[u]=I(this,ht);let h;return I(this,gt)?h=I(this,gt):(h=ks(()=>Promise.resolve().then(()=>require("./UODQIBEW-YKB5mcNR.cjs"))),Z(this,gt,h)),rr(I(this,qt),I(this,lt)),Hn(h,Vn({get queryFlavor(){return I(n,Bt)},get version(){return I(n,Ft)},get onlineManager(){return I(n,Rt)},get shadowDOMTarget(){return I(n,lt)}},{get client(){return l()},get buttonPosition(){return s()},get position(){return a()},get initialIsOpen(){return i()},get errorTypes(){return o()},get onClose(){return u()}}))},e);Z(this,ze,!0),Z(this,Wt,t)}unmount(){var e;if(!I(this,ze))throw new Error("Devtools is not mounted");(e=I(this,Wt))==null||e.call(this),Z(this,ze,!1)}},ot=new WeakMap,Rt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,ze=new WeakMap,qt=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,gt=new WeakMap,Wt=new WeakMap,xs);function xi(e){const t=Q.useQueryClient(e.client),n=we.useRef(null),{buttonPosition:s,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}=e,[h]=we.useState(new yi({client:t,queryFlavor:"React Query",version:"5",onlineManager:Q.onlineManager,buttonPosition:s,position:a,initialIsOpen:i,errorTypes:o,styleNonce:l,shadowDOMTarget:u}));return we.useEffect(()=>{h.setClient(t)},[t,h]),we.useEffect(()=>{s&&h.setButtonPosition(s)},[s,h]),we.useEffect(()=>{a&&h.setPosition(a)},[a,h]),we.useEffect(()=>{h.setInitialIsOpen(i||!1)},[i,h]),we.useEffect(()=>{h.setErrorTypes(o||[])},[o,h]),we.useEffect(()=>(n.current&&h.mount(n.current),()=>{h.unmount()}),[h]),r.jsx("div",{className:"tsqd-parent-container",ref:n})}function Ei(e){const t=Q.useQueryClient(e.client),n=we.useRef(null),{errorTypes:s,styleNonce:a,shadowDOMTarget:i}=e,[o]=we.useState(new vi({client:t,queryFlavor:"React Query",version:"5",onlineManager:Q.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:s,styleNonce:a,shadowDOMTarget:i,onClose:e.onClose}));return we.useEffect(()=>{o.setClient(t)},[t,o]),we.useEffect(()=>{o.setOnClose(e.onClose??(()=>{}))},[e.onClose,o]),we.useEffect(()=>{o.setErrorTypes(s||[])},[s,o]),we.useEffect(()=>(n.current&&o.mount(n.current),()=>{o.unmount()}),[o]),r.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:n})}var bi=process.env.NODE_ENV!=="development"?function(){return null}:xi;process.env.NODE_ENV;const Si=Es.atom({}),ar=()=>Es.useAtom(Si),Ht=(e,t)=>{const[n]=ar();return v.get(n,e,t)},he=()=>Ht("apiUrl","/chai/api"),U={ASK_AI:"ASK_AI",GET_PAGE:"GET_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_SETTINGS:"GET_WEBSITE_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA"},$n=()=>{const e=Q.useQueryClient(),{data:t}=Q.useQuery({queryKey:[U.AI_CONTEXT],initialData:"",queryFn:()=>""});return{setAiContext:T.useCallback(s=>{e.setQueryData([U.AI_CONTEXT],s)},[]),aiContext:t}},ge=async(e,t)=>{const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await n.json();if(s!=null&&s.error||n.status===400||!n.ok)throw new Error((s==null?void 0:s.error)||"Something went wrong.");return s},wi=()=>{const e=he(),{aiContext:t}=$n();return T.useCallback(async(n,s,a,i)=>ge(e,{action:U.ASK_AI,data:{type:n,prompt:s,blocks:a,context:t,lang:i}}),[e,t])},Ci=()=>{const e=he();return{getUILibraryBlock:async(a,i)=>{const u=(await(await fetch(a.url+(i.path?"/blocks/"+i.path:"/"+i.uuid+".html"))).text()).replace(/---([\s\S]*?)---/g,"");return Me.getBlocksFromHTML(`${u}`)},getUILibraryBlocks:async a=>{try{return(await(await fetch(a.url+"/blocks.json")).json()).map(l=>({...l,preview:a.url.replace("chaiblocks","")+l.preview}))}catch(i){return console.error(i),[]}},onSave:async({page:a,blocks:i})=>{try{return await ge(e,{action:"UPDATE_PAGE",data:{id:a,blocks:i}})}catch{return new Error("Failed to save blocks")}}}};function Qe(){const[e,t]=T.useState(new URLSearchParams(window.location.search));return T.useEffect(()=>{const n=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[]),[e,t]}const hn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>ge(e,{action:U.GET_WEBSITE_PAGES})||[]})},Re=()=>{const[e]=Qe(),t=e.get("page"),{data:n,isFetching:s}=hn();return{data:T.useMemo(()=>v.find(n,{id:t})||{},[n,t]),isFetching:s}},Ti=()=>Q.useQuery({queryKey:["uiLibraries"],initialData:[],queryFn:async()=>[{uuid:"chaiblocks",name:"UI Blocks",url:"https://chaibuilder.com/chaiblocks"}]}),ji=()=>{const[e]=Qe(),t=e.get("page"),n=he(),{setAiContext:s}=$n();return Q.useQuery({queryKey:[U.GET_PAGE,t],initialData:[],queryFn:async()=>{const i=(await ge(n,{action:U.GET_PAGE,data:{id:t,draft:!0}})).blocks??[],o=v.find(i,{_type:"@chai/ai-context"});return s(v.get(o,"_value","")||""),i},enabled:!!t})},Ai=(e,t)=>t.map(n=>{if(v.has(e,n._type)){const s=bs.getDefaultBlockProps(n._type);return{...s,...v.pick(n,[...v.keys(s),"_type","_id","_name","_parent","_bindings"]),...v.pickBy(n,(a,i)=>v.endsWith(i,"_attrs"))}}return n}),Ni=e=>{const t=bs.useRegisteredChaiBlocks();return T.useMemo(()=>{if(!e||v.isEmpty(e))return{blocks:[]};const n=v.filter(e,s=>!v.includes(s==null?void 0:s._type,"@chai/"));return{blocks:Ai(t,n)}},[e,t])},Kn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_SETTINGS],initialData:{theme:{},fallbackLang:"en",languages:[]},queryFn:async()=>ge(e,{action:U.GET_WEBSITE_SETTINGS,data:{draft:!0}})})},Pi=()=>{const{data:e}=hn(),t=he();return{getGlobalBlocks:async()=>{const n={};for(const s of e??[])v.isEmpty(s==null?void 0:s.slug)&&(n[s.id]={name:v.startCase(s.name??s.slug),description:""});return n},getGlobalBlockBlocks:async n=>n?(await ge(t,{action:"GET_PAGE",data:{id:n,draft:!0}})).blocks:[]}},_i=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_WEBSITE_SETTINGS,data:s}),onSuccess:(s,a)=>{var i;t.invalidateQueries({queryKey:[U.GET_WEBSITE_SETTINGS]}),(i=a==null?void 0:a.settings)!=null&&i.theme||n({title:"Website settings updated successfully."})},onError:s=>{n({variant:"destructive",title:"Failed to update website settings",description:s.message})}})},ki=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_WEBSITE_DATA,data:s}),onSuccess:()=>{t.invalidateQueries({queryKey:[U.GET_WEBSITE_DATA]}),n({title:"Website data updated successfully."})},onError:s=>{n({variant:"destructive",title:"Failed to update website data",description:s.message})}})},gn=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_PAGE_TYPES],initialData:[],queryFn:async()=>ge(e,{action:U.GET_PAGE_TYPES})})},Li=()=>{const e=he();return Q.useMutation({mutationFn:async({collection:t,query:n})=>{try{return ge(e,{action:U.SEARCH_PAGES,data:{collection:t,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(s){return console.error(s),[]}}})},qe={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"},Di={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},_={PREVIEW:"Preview",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add New language",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},ir=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.CREATE_PAGE,data:s}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_ADD_SUCCESS:_.PAGE_ADD_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to add new ${a.collection==="global"?"global block":"page"}.`,description:v.get(Di,s.message,s.message)})}})},or=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.UPDATE_PAGE,data:s}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage||a!=null&&a.seo)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),a!=null&&a.seo?n({title:_.SEO_SETTINGS_UPDATE_SUCCESS}):n({title:a.collection==="global"?_.GLOBAL_BLOCK_UPDATE_SUCCESS:_.PAGE_UPDATE_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to update ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},Ii=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.DELETE_PAGE,data:{id:s==null?void 0:s.id}}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_DELETE_SUCCESS:_.PAGE_DELETE_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to delete ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},Oi=()=>{const e=he(),t=Q.useQueryClient(),{toast:n}=f.useToast();return Q.useMutation({mutationFn:async s=>ge(e,{action:U.TAKE_OFFLINE,data:{id:s==null?void 0:s.id}}),onSuccess:(s,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n({title:a.collection==="global"?_.GLOBAL_BLOCK_UNPUBLISH_SUCCESS:_.PAGE_UNPUBLISH_SUCCESS})},onError:(s,a)=>{n({variant:"destructive",title:`Failed to take offline ${a.collection==="global"?"global block":"page"}.`,description:s.message})}})},lr=()=>{const e=he(),{toast:t}=f.useToast(),n=Q.useQueryClient(),{data:s}=Re();return Q.useMutation({mutationFn:async({ids:a})=>ge(e,{action:U.PUBLISH_CHANGES,data:{ids:a}}),onSuccess:()=>{n.invalidateQueries({queryKey:[U.GET_CHANGES]}),n.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]}),n.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,s==null?void 0:s.id]})},onError:()=>{t({title:"Failed to publish pages.",variant:"destructive"})}})},Gi=()=>{const e=he(),{toast:t}=f.useToast(),n=Q.useQueryClient();return Q.useMutation({mutationFn:async({id:s,slug:a})=>ge(e,{action:U.CHANGE_SLUG,data:{id:s,slug:a}}),onSuccess:(s,{primaryPage:a})=>{t({title:_.SLUG_CHANGE_SUCCESS}),a?n.invalidateQueries({queryKey:[U.GET_LANGUAGE_PAGES,a]}):n.invalidateQueries({queryKey:[U.GET_WEBSITE_PAGES]})},onError:()=>{t({title:"Failed to change slug",variant:"destructive"})}})},zn=()=>{const e=he(),[t]=Qe(),n=t.get("page");return Q.useQuery({queryKey:[U.GET_LANGUAGE_PAGES,n],initialData:[],queryFn:async()=>{if(!n)return null;const s=await ge(e,{action:U.GET_LANGUAGE_PAGES,data:{id:n}});return v.reverse(v.sortBy(s,"primaryPage"))}})},Mi=()=>{const{selectedLang:e}=Me.useLanguages(),{data:t,isFetching:n}=zn();return{data:T.useMemo(()=>v.find(t,{lang:e||""})||{},[t,e]),isFetching:n}},cr=()=>{const{data:e,isFetching:t}=Mi(),n=e==null?void 0:e.seo,[s,a]=T.useState({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...n}),i=T.useRef({initial:s,updated:s}),{selectedLang:o,fallbackLang:l,languages:u}=Me.useLanguages(),h=o.length?o:l,{mutate:y,isPending:g}=or(),E=g;T.useEffect(()=>{!t&&n&&a({title:"",description:"",cononicalUrl:"",noIndex:!1,noFollow:"",ogTitle:"",ogDescription:"",ogImage:"",searchTitle:"",searchDescription:"",jsonLD:"",...n})},[t,n]);const j=async()=>{y({id:e==null?void 0:e.id,seo:s}),i.current.initial=s,i.current.updated=s},k=()=>{a({...s,ogTitle:s.title,ogDescription:s.description})},O=()=>{a({...s,searchTitle:s.ogTitle,searchDescription:s.ogDescription})},S=p=>{const b={...s,[p.target.name]:p.target.name==="noIndex"||p.target.name==="noFollow"?p.target.checked:p.target.value};a(b),i.current.updated=b};return r.jsxs("div",{className:"relative pb-40",children:[r.jsxs("div",{className:"text-xs bg-gray-100 p-2 rounded-md text-left",children:["Slug: ",e==null?void 0:e.slug,"  ",u.length>0&&r.jsxs("span",{className:"text-blue-500 font-semibold",children:["(",v.get(qe,h,h),")"]})]}),r.jsx("form",{className:"space-y-8",children:r.jsxs(f.Accordion,{type:"multiple",defaultValue:["page"],children:[r.jsxs(f.AccordionItem,{value:"page",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-semibold",children:"SEO"}),r.jsx(f.AccordionContent,{className:"pt-2",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"title",children:"SEO Title"}),r.jsxs(r.Fragment,{children:[r.jsx(f.Input,{type:"text",id:"title",name:"title",value:s.title,onChange:S,disabled:E,placeholder:"Enter SEO title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The title should be between 10 and 60 characters."})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"description",children:"SEO Description"}),r.jsx(f.Textarea,{id:"description",name:"description",value:s.description,onChange:S,disabled:E,placeholder:"Enter SEO description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The description should be between 50 and 160 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"title",children:"Canonical URL"}),r.jsx(f.Input,{type:"text",id:"canonicalUrl",name:"canonicalUrl",value:s.canonicalUrl,onChange:S,disabled:E,placeholder:"Enter Canonical URL"})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(f.Input,{type:"checkbox",id:"noIndex",name:"noIndex",checked:s.noIndex,onChange:S,disabled:E,className:"h-4 w-4"}),r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"noIndex",children:"No Index"})]}),r.jsx("p",{className:"mt-0 text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to index this page."})]}),r.jsxs("div",{className:"",children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsx(f.Input,{type:"checkbox",id:"noFollow",name:"noFollow",checked:s.noFollow,onChange:S,disabled:E,className:"h-4 w-4"}),r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"noIndex",children:"No Follow"})]}),r.jsx("p",{className:"text-[10px] font-light text-gray-400 leading-4",children:"Check this if you don't want search engines to follow links on this page."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"og",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"OG"}),r.jsx(f.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(f.Button,{type:"button",variant:"outline",size:"sm",onClick:k,children:"Copy from SEO Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"ogTitle",children:"OG Title"}),r.jsx(f.Input,{type:"text",id:"ogTitle",name:"ogTitle",value:s.ogTitle,onChange:S,disabled:E,placeholder:"Enter OG title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The OG title should be between 10 and 60 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"ogDescription",children:"OG Description"}),r.jsx(f.Textarea,{id:"ogDescription",name:"ogDescription",value:s.ogDescription,onChange:S,disabled:E,placeholder:"Enter OG description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The OG description should be between 50 and 160 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs pb-1",htmlFor:"ogImage",children:"OG Image URL"}),r.jsx(f.Input,{type:"text",id:"ogImage",name:"ogImage",value:s.ogImage,onChange:S,disabled:E,placeholder:"Enter OG image URL"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"Enter a valid URL for the OG image."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"search",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"SEARCH"}),r.jsx(f.AccordionContent,{children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(f.Button,{type:"button",variant:"outline",size:"sm",onClick:O,children:"Copy from OG Settings"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"searchTitle",children:"Search Title"}),r.jsx(f.Input,{type:"text",id:"searchTitle",name:"searchTitle",value:s.searchTitle,onChange:S,disabled:E,placeholder:"Enter search title"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The search title should be between 10 and 60 characters."})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{className:"text-xs",htmlFor:"searchDescription",children:"Search Description"}),r.jsx(f.Textarea,{id:"searchDescription",name:"searchDescription",value:s.searchDescription,onChange:S,placeholder:"Enter search description"}),r.jsx("p",{className:"mt-1 text-[10px] font-light text-gray-400 leading-4",children:"The search description should be between 50 and 160 characters."})]})]})})]}),r.jsxs(f.AccordionItem,{value:"jsonLD",children:[r.jsx(f.AccordionTrigger,{className:"text-slate-700 font-bold",children:"JSON-LD"}),r.jsx(f.AccordionContent,{children:r.jsx("div",{className:"space-y-4",children:r.jsx("div",{children:r.jsx(f.Textarea,{id:"jsonLD",name:"jsonLD",rows:3,value:s.jsonLD,onChange:S,placeholder:"Enter JSON-LD"})})})})]})]})}),r.jsx("div",{className:"w-full flex items-center justify-end mt-4",children:r.jsx(f.Button,{size:"lg",variant:"default",onClick:j,disabled:v.isEqual(i.current.initial,s)||E,children:g?"Saving...":"Save"})})]})};cr.displayName="SeoPanel";const ur=({page:e,onClose:t})=>{const[n,s]=T.useState(e.slug||""),{mutate:a,isPending:i}=Gi(),{data:o}=gn(),l=v.find(o,{key:e==null?void 0:e.collection}),u=y=>{y.preventDefault(),a({...e,slug:n},{onSuccess:t})},h=(e==null?void 0:e.lang)||"";return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Change Slug"}),r.jsx(f.DialogDescription,{className:"text-xs",children:r.jsxs(f.Alert,{variant:"destructive",className:"mt-2",children:[r.jsx(H.AlertCircle,{className:"h-4 w-4"}),"Changing the slug may have impact on your SEO. Please proceed with caution."]})})]}),r.jsxs("form",{onSubmit:u,children:[r.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{children:[r.jsx("span",{children:"Type:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(l==null?void 0:l.name)||(e==null?void 0:e.collection)]})]}),r.jsxs("div",{children:[r.jsx("span",{children:"Name:"}),r.jsxs("span",{className:"font-medium text-gray-600",children:[" ",e.name]})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs(f.Label,{htmlFor:"slug",className:"text-right",children:["Slug"," ",r.jsxs("small",{className:"font-light text-gray-500",children:["Slug should start with /",h]})]}),r.jsx(f.Input,{id:"slug",value:n,onChange:y=>{const g=y.target.value;v.startsWith(g,`/${h}`)&&s(g)},className:"col-span-3",required:!0,pattern:"^/.*",title:"Slug must start with /",placeholder:"Enter page slug"})]})]}),r.jsx(f.DialogFooter,{children:r.jsx(f.Button,{type:"submit",disabled:i||!v.startsWith(n,`/${h}`)||v.isEqual(e==null?void 0:e.slug,n),children:i?"Changing...":"Change Slug"})})]})]})})};function dr({page:e,onClose:t}){const[,n]=Qe(),{mutate:s,isPending:a}=Ii(),i=()=>{s(e,{onSuccess:()=>{e!=null&&e.primaryPage||(window.history.replaceState(null,"","/"),n(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate"))),t()}})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Confirm Deletion"}),r.jsxs(f.DialogDescription,{className:"py-4 text-slate-500",children:[r.jsxs("div",{children:["Are you sure you want to remove ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",(e==null?void 0:e.collection)==="global"?"global block?":`page? ${e!=null&&e.primaryPage?"":"This will also delete all associated language pages."}`]}),e.lang&&r.jsxs("div",{className:"py-2 text-sm",children:["Language:"," ",r.jsx("span",{className:"font-medium text-gray-500",children:v.get(qe,e.lang,e.lang)})]})]})]}),r.jsxs(f.DialogFooter,{children:[r.jsx(f.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(f.Button,{variant:"destructive",disabled:a,onClick:i,children:a?"Deleting...":"Delete"})]})]})})}const Qn=({page:e,onClose:t})=>{const{mutate:n,isPending:s}=Oi(),a=async()=>{n(e,{onSuccess:t})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Confirm action"}),r.jsxs(f.DialogDescription,{children:[_.UNPUBLISH_MSG," ",r.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)}),"?"]})]}),r.jsxs(f.DialogFooter,{children:[r.jsx(f.Button,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(f.Button,{variant:"destructive",disabled:s,onClick:a,children:s?_.UPDATING:_.UNPUBLISH})]})]})})},fr=({langProps:e,onClose:t,languages:n})=>{const{data:s}=Re(),[a,i]=T.useState(e.name||""),[o,l]=T.useState(e.edit?e.lang:""),[u,h]=T.useState(e.edit?e.slug:""),{mutate:y,isPending:g}=ir(),{mutate:E,isPending:j}=or(),k=(e==null?void 0:e.collection)==="global",O=g||j,S=p=>{p.preventDefault();const b={name:a,lang:o,primaryPage:s==null?void 0:s.id,slug:u,collection:s==null?void 0:s.collection};b.collection=e.collection,e.edit&&(b.id=e==null?void 0:e.id),e.edit?E(b,{onSuccess:t}):y(b,{onSuccess:t})};return r.jsx(f.Dialog,{open:!!e,onOpenChange:t,children:r.jsxs(f.DialogContent,{className:"sm:max-w-[425px] text-slate-600",children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:e.edit?_.EDIT_LANGUAGE:_.ADD_NEW_LANGUAGE}),r.jsx(f.DialogDescription,{className:"font-light",children:_.ENTER_LANGUAGE_DETAILS})]}),r.jsxs("form",{onSubmit:S,children:[r.jsxs("div",{className:"grid gap-4 py-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{htmlFor:"lang",className:"text-right",children:_.LANGUAGE}),r.jsxs("select",{value:o,disabled:e.edit||v.isEmpty(n),onChange:p=>{const b=p.target.value;l(b),!k&&h(`/${b}`)},className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 col-span-3",children:[r.jsx("option",{value:"",disabled:!0,selected:!0,children:e.edit?v.get(qe,e.lang,e.lang):v.isEmpty(n)?_.ALL_AVAILABLE_LANGUAGE_PAGE:_.CHOOSE_LANGUAGE}),v.map(n,p=>r.jsx("option",{value:p,children:v.get(qe,p,p)},p))]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(f.Label,{htmlFor:"slug",className:"text-right",children:_.PAGE_NAME}),r.jsx(f.Input,{id:"name",value:a,onChange:p=>i(p.target.value),className:"col-span-3",required:!0,placeholder:_.ENTER_PAGE_NAME})]}),!k&&r.jsxs("div",{className:"space-y-1",children:[r.jsxs(f.Label,{htmlFor:"slug",className:"text-right",children:[_.SLUG," ",r.jsx("small",{className:"font-light",children:e.edit?_.TO_UPDATE_SLUG:_.SLUG_SHOULD_START_WITH})]}),r.jsx(f.Input,{id:"slug",value:u,onChange:p=>{const b=p.target.value;v.startsWith(b,`/${o}`)&&h(v.toLower(v.trim(b)))},className:"col-span-3",required:!0,pattern:"^/.*",disabled:v.isEmpty(o)||(e==null?void 0:e.edit),title:_.SLUG_MUST_START_WITH,placeholder:v.isEmpty(o)?_.CHOOSE_LANGUAGE_TO_ADD_SLUG:_.ENTER_PAGE_SLUG})]})]}),r.jsx(f.DialogFooter,{children:r.jsx(f.Button,{type:"submit",disabled:O||!a||!o||!k&&!v.startsWith(u,`/${o}`),children:O?e.edit?_.UPDATING:_.ADDING:e.edit?_.UPDATE:_.ADD_NEW_LANGUAGE})})]})]})})},Ui=()=>{const[e,t]=T.useState(null),{selectedLang:n,fallbackLang:s,setSelectedLang:a}=Me.useLanguages(),{data:i,isFetching:o}=zn(),{data:l}=Re(),[u,h]=T.useState(null),[y,g]=T.useState(null),[E,j]=T.useState(null),{data:k}=Kn(),O=v.filter(v.get(k,"languages")||["en"],S=>!v.find(i,{lang:S})&&S!==v.get(k,"fallbackLang"));return r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsx("ul",{className:"space-y-2 mt-4",children:o?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):v.map(i,S=>{const p=S.lang,b=S.slug,A=!S.primaryPage,V=p===n;return r.jsxs(r.Fragment,{children:[r.jsxs("li",{className:`text-slate-500 w-full p-2 rounded cursor-pointer flex items-center justify-between ${V?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>a(p),children:[r.jsxs("div",{className:" flex-1 gap-x-3",children:[r.jsxs("div",{className:"text-[13px] text-slate-800 flex items-center gap-x-2",children:[r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${S.online?"bg-green-300":"bg-gray-300"}`}),v.get(qe,A?s:p,p)]}),r.jsxs("div",{children:[b&&r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Slug: ",r.jsx("b",{className:"font-medium",children:b})]}),r.jsxs("div",{className:"text-[11px] text-slate-600 font-light",children:["Name:",r.jsxs("b",{className:"font-medium",children:[" ",S.name," "]})]})]})]}),A?r.jsxs("div",{className:"flex items-center text-[11px] text-orange-500 gap-x-1",children:[r.jsx(H.StarIcon,{fill:"orange",className:"w-3 h-3"}),r.jsx("b",{children:" Primary"})]}):r.jsx("div",{className:"flex items-center gap-x-3",children:r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,onClick:R=>R.stopPropagation(),children:r.jsx(f.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:r.jsx(H.MoreHorizontal,{className:"h-4 w-4"})})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),t({...S,edit:!0})},children:[r.jsx(H.PencilIcon,{className:"size-3"}),_.EDIT]}),(S==null?void 0:S.online)&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),g(S)},children:[r.jsx(H.Power,{className:"size-3"}),_.UNPUBLISH]}),(S==null?void 0:S.collection)!=="global"&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),j(S)},children:[r.jsx(H.Link,{className:"size-3"}),_.CHANGE_SLUG]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:R=>{R.stopPropagation(),h(S)},children:[r.jsx(H.TrashIcon,{className:"size-3"}),_.DELETE]})]})]})})]},S.id),r.jsx("div",{className:"h-1 w-full border-b"})]})})}),r.jsx("div",{className:"flex justify-center w-full",children:r.jsx(f.Button,{variant:"default",size:"sm",disabled:v.isEmpty(O),onClick:()=>{t({name:l==null?void 0:l.name,collection:l==null?void 0:l.collection,lang:"",slug:"",edit:!1})},children:_.ADD_NEW_LANGUAGE})}),e&&r.jsx(fr,{languages:O,langProps:e,onClose:()=>t(null)}),u&&r.jsx(dr,{page:u,onClose:()=>h(null)}),y&&r.jsx(Qn,{page:y,onClose:()=>g(null)}),E&&r.jsx(ur,{page:E,onClose:()=>j(null)})]})},Ri=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_CHANGES],queryFn:async()=>ge(e,{action:U.GET_CHANGES})})};var Yn={};(function e(t,n,s,a){var i=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o=typeof Path2D=="function"&&typeof DOMMatrix=="function",l=function(){if(!t.OffscreenCanvas)return!1;var m=new OffscreenCanvas(1,1),d=m.getContext("2d");d.fillRect(0,0,1,1);var N=m.transferToImageBitmap();try{d.createPattern(N,"no-repeat")}catch{return!1}return!0}();function u(){}function h(m){var d=n.exports.Promise,N=d!==void 0?d:t.Promise;return typeof N=="function"?new N(m):(m(u,u),null)}var y=function(m,d){return{transform:function(N){if(m)return N;if(d.has(N))return d.get(N);var L=new OffscreenCanvas(N.width,N.height),G=L.getContext("2d");return G.drawImage(N,0,0),d.set(N,L),L},clear:function(){d.clear()}}}(l,new Map),g=function(){var m=Math.floor(16.666666666666668),d,N,L={},G=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(d=function(B){var F=Math.random();return L[F]=requestAnimationFrame(function P(M){G===M||G+m-1<M?(G=M,delete L[F],B()):L[F]=requestAnimationFrame(P)}),F},N=function(B){L[B]&&cancelAnimationFrame(L[B])}):(d=function(B){return setTimeout(B,m)},N=function(B){return clearTimeout(B)}),{frame:d,cancel:N}}(),E=function(){var m,d,N={};function L(G){function B(F,P){G.postMessage({options:F||{},callback:P})}G.init=function(P){var M=P.transferControlToOffscreen();G.postMessage({canvas:M},[M])},G.fire=function(P,M,X){if(d)return B(P,null),d;var re=Math.random().toString(36).slice(2);return d=h(function(ae){function oe(de){de.data.callback===re&&(delete N[re],G.removeEventListener("message",oe),d=null,y.clear(),X(),ae())}G.addEventListener("message",oe),B(P,re),N[re]=oe.bind(null,{data:{callback:re}})}),d},G.reset=function(){G.postMessage({reset:!0});for(var P in N)N[P](),delete N[P]}}return function(){if(m)return m;if(!s&&i){var G=["var CONFETTI, SIZE = {}, module = {};","("+e.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {"," if (msg.data.options) {"," CONFETTI(msg.data.options).then(function () {"," if (msg.data.callback) {"," postMessage({ callback: msg.data.callback });"," }"," });"," } else if (msg.data.reset) {"," CONFETTI && CONFETTI.reset();"," } else if (msg.data.resize) {"," SIZE.width = msg.data.resize.width;"," SIZE.height = msg.data.resize.height;"," } else if (msg.data.canvas) {"," SIZE.width = msg.data.canvas.width;"," SIZE.height = msg.data.canvas.height;"," CONFETTI = module.exports.create(msg.data.canvas);"," }","}"].join(`
31
+ `);try{m=new Worker(URL.createObjectURL(new Blob([G])))}catch(B){return typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",B),null}L(m)}return m}}(),j={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function k(m,d){return d?d(m):m}function O(m){return m!=null}function S(m,d,N){return k(m&&O(m[d])?m[d]:j[d],N)}function p(m){return m<0?0:Math.floor(m)}function b(m,d){return Math.floor(Math.random()*(d-m))+m}function A(m){return parseInt(m,16)}function V(m){return m.map(R)}function R(m){var d=String(m).replace(/[^0-9a-f]/gi,"");return d.length<6&&(d=d[0]+d[0]+d[1]+d[1]+d[2]+d[2]),{r:A(d.substring(0,2)),g:A(d.substring(2,4)),b:A(d.substring(4,6))}}function Ce(m){var d=S(m,"origin",Object);return d.x=S(d,"x",Number),d.y=S(d,"y",Number),d}function ke(m){m.width=document.documentElement.clientWidth,m.height=document.documentElement.clientHeight}function Te(m){var d=m.getBoundingClientRect();m.width=d.width,m.height=d.height}function C(m){var d=document.createElement("canvas");return d.style.position="fixed",d.style.top="0px",d.style.left="0px",d.style.pointerEvents="none",d.style.zIndex=m,d}function q(m,d,N,L,G,B,F,P,M){m.save(),m.translate(d,N),m.rotate(B),m.scale(L,G),m.arc(0,0,1,F,P,M),m.restore()}function ee(m){var d=m.angle*(Math.PI/180),N=m.spread*(Math.PI/180);return{x:m.x,y:m.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:m.startVelocity*.5+Math.random()*m.startVelocity,angle2D:-d+(.5*N-Math.random()*N),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:m.color,shape:m.shape,tick:0,totalTicks:m.ticks,decay:m.decay,drift:m.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:m.gravity*3,ovalScalar:.6,scalar:m.scalar,flat:m.flat}}function ve(m,d){d.x+=Math.cos(d.angle2D)*d.velocity+d.drift,d.y+=Math.sin(d.angle2D)*d.velocity+d.gravity,d.velocity*=d.decay,d.flat?(d.wobble=0,d.wobbleX=d.x+10*d.scalar,d.wobbleY=d.y+10*d.scalar,d.tiltSin=0,d.tiltCos=0,d.random=1):(d.wobble+=d.wobbleSpeed,d.wobbleX=d.x+10*d.scalar*Math.cos(d.wobble),d.wobbleY=d.y+10*d.scalar*Math.sin(d.wobble),d.tiltAngle+=.1,d.tiltSin=Math.sin(d.tiltAngle),d.tiltCos=Math.cos(d.tiltAngle),d.random=Math.random()+2);var N=d.tick++/d.totalTicks,L=d.x+d.random*d.tiltCos,G=d.y+d.random*d.tiltSin,B=d.wobbleX+d.random*d.tiltCos,F=d.wobbleY+d.random*d.tiltSin;if(m.fillStyle="rgba("+d.color.r+", "+d.color.g+", "+d.color.b+", "+(1-N)+")",m.beginPath(),o&&d.shape.type==="path"&&typeof d.shape.path=="string"&&Array.isArray(d.shape.matrix))m.fill(Vt(d.shape.path,d.shape.matrix,d.x,d.y,Math.abs(B-L)*.1,Math.abs(F-G)*.1,Math.PI/10*d.wobble));else if(d.shape.type==="bitmap"){var P=Math.PI/10*d.wobble,M=Math.abs(B-L)*.1,X=Math.abs(F-G)*.1,re=d.shape.bitmap.width*d.scalar,ae=d.shape.bitmap.height*d.scalar,oe=new DOMMatrix([Math.cos(P)*M,Math.sin(P)*M,-Math.sin(P)*X,Math.cos(P)*X,d.x,d.y]);oe.multiplySelf(new DOMMatrix(d.shape.matrix));var de=m.createPattern(y.transform(d.shape.bitmap),"no-repeat");de.setTransform(oe),m.globalAlpha=1-N,m.fillStyle=de,m.fillRect(d.x-re/2,d.y-ae/2,re,ae),m.globalAlpha=1}else if(d.shape==="circle")m.ellipse?m.ellipse(d.x,d.y,Math.abs(B-L)*d.ovalScalar,Math.abs(F-G)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI):q(m,d.x,d.y,Math.abs(B-L)*d.ovalScalar,Math.abs(F-G)*d.ovalScalar,Math.PI/10*d.wobble,0,2*Math.PI);else if(d.shape==="star")for(var K=Math.PI/2*3,fe=4*d.scalar,pe=8*d.scalar,be=d.x,Ae=d.y,Ne=5,Pe=Math.PI/Ne;Ne--;)be=d.x+Math.cos(K)*pe,Ae=d.y+Math.sin(K)*pe,m.lineTo(be,Ae),K+=Pe,be=d.x+Math.cos(K)*fe,Ae=d.y+Math.sin(K)*fe,m.lineTo(be,Ae),K+=Pe;else m.moveTo(Math.floor(d.x),Math.floor(d.y)),m.lineTo(Math.floor(d.wobbleX),Math.floor(G)),m.lineTo(Math.floor(B),Math.floor(F)),m.lineTo(Math.floor(L),Math.floor(d.wobbleY));return m.closePath(),m.fill(),d.tick<d.totalTicks}function je(m,d,N,L,G){var B=d.slice(),F=m.getContext("2d"),P,M,X=h(function(re){function ae(){P=M=null,F.clearRect(0,0,L.width,L.height),y.clear(),G(),re()}function oe(){s&&!(L.width===a.width&&L.height===a.height)&&(L.width=m.width=a.width,L.height=m.height=a.height),!L.width&&!L.height&&(N(m),L.width=m.width,L.height=m.height),F.clearRect(0,0,L.width,L.height),B=B.filter(function(de){return ve(F,de)}),B.length?P=g.frame(oe):ae()}P=g.frame(oe),M=ae});return{addFettis:function(re){return B=B.concat(re),X},canvas:m,promise:X,reset:function(){P&&g.cancel(P),M&&M()}}}function Le(m,d){var N=!m,L=!!S(d||{},"resize"),G=!1,B=S(d,"disableForReducedMotion",Boolean),F=i&&!!S(d||{},"useWorker"),P=F?E():null,M=N?ke:Te,X=m&&P?!!m.__confetti_initialized:!1,re=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,ae;function oe(K,fe,pe){for(var be=S(K,"particleCount",p),Ae=S(K,"angle",Number),Ne=S(K,"spread",Number),Pe=S(K,"startVelocity",Number),mn=S(K,"decay",Number),xt=S(K,"gravity",Number),pn=S(K,"drift",Number),zt=S(K,"colors",V),Qt=S(K,"ticks",Number),Et=S(K,"shapes"),He=S(K,"scalar"),yn=!!S(K,"flat"),bt=Ce(K),St=be,Ve=[],vn=m.width*bt.x,xn=m.height*bt.y;St--;)Ve.push(ee({x:vn,y:xn,angle:Ae,spread:Ne,startVelocity:Pe,color:zt[St%zt.length],shape:Et[b(0,Et.length)],ticks:Qt,decay:mn,gravity:xt,drift:pn,scalar:He,flat:yn}));return ae?ae.addFettis(Ve):(ae=je(m,Ve,M,fe,pe),ae.promise)}function de(K){var fe=B||S(K,"disableForReducedMotion",Boolean),pe=S(K,"zIndex",Number);if(fe&&re)return h(function(Pe){Pe()});N&&ae?m=ae.canvas:N&&!m&&(m=C(pe),document.body.appendChild(m)),L&&!X&&M(m);var be={width:m.width,height:m.height};P&&!X&&P.init(m),X=!0,P&&(m.__confetti_initialized=!0);function Ae(){if(P){var Pe={getBoundingClientRect:function(){if(!N)return m.getBoundingClientRect()}};M(Pe),P.postMessage({resize:{width:Pe.width,height:Pe.height}});return}be.width=be.height=null}function Ne(){ae=null,L&&(G=!1,t.removeEventListener("resize",Ae)),N&&m&&(document.body.contains(m)&&document.body.removeChild(m),m=null,X=!1)}return L&&!G&&(G=!0,t.addEventListener("resize",Ae,!1)),P?P.fire(K,be,Ne):oe(K,be,Ne)}return de.reset=function(){P&&P.reset(),ae&&ae.reset()},de}var Oe;function vt(){return Oe||(Oe=Le(null,{useWorker:!0,resize:!0})),Oe}function Vt(m,d,N,L,G,B,F){var P=new Path2D(m),M=new Path2D;M.addPath(P,new DOMMatrix(d));var X=new Path2D;return X.addPath(M,new DOMMatrix([Math.cos(F)*G,Math.sin(F)*G,-Math.sin(F)*B,Math.cos(F)*B,N,L])),X}function $t(m){if(!o)throw new Error("path confetti are not supported in this browser");var d,N;typeof m=="string"?d=m:(d=m.path,N=m.matrix);var L=new Path2D(d),G=document.createElement("canvas"),B=G.getContext("2d");if(!N){for(var F=1e3,P=F,M=F,X=0,re=0,ae,oe,de=0;de<F;de+=2)for(var K=0;K<F;K+=2)B.isPointInPath(L,de,K,"nonzero")&&(P=Math.min(P,de),M=Math.min(M,K),X=Math.max(X,de),re=Math.max(re,K));ae=X-P,oe=re-M;var fe=10,pe=Math.min(fe/ae,fe/oe);N=[pe,0,0,pe,-Math.round(ae/2+P)*pe,-Math.round(oe/2+M)*pe]}return{type:"path",path:d,matrix:N}}function Kt(m){var d,N=1,L="#000000",G='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof m=="string"?d=m:(d=m.text,N="scalar"in m?m.scalar:N,G="fontFamily"in m?m.fontFamily:G,L="color"in m?m.color:L);var B=10*N,F=""+B+"px "+G,P=new OffscreenCanvas(B,B),M=P.getContext("2d");M.font=F;var X=M.measureText(d),re=Math.ceil(X.actualBoundingBoxRight+X.actualBoundingBoxLeft),ae=Math.ceil(X.actualBoundingBoxAscent+X.actualBoundingBoxDescent),oe=2,de=X.actualBoundingBoxLeft+oe,K=X.actualBoundingBoxAscent+oe;re+=oe+oe,ae+=oe+oe,P=new OffscreenCanvas(re,ae),M=P.getContext("2d"),M.font=F,M.fillStyle=L,M.fillText(d,de,K);var fe=1/N;return{type:"bitmap",bitmap:P.transferToImageBitmap(),matrix:[fe,0,0,fe,-re*fe/2,-ae*fe/2]}}n.exports=function(){return vt().apply(this,arguments)},n.exports.reset=function(){vt().reset()},n.exports.create=Le,n.exports.shapeFromPath=$t,n.exports.shapeFromText=Kt})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),Yn,!1);const ys=Yn.exports;Yn.exports.create;const Bn=e=>{ys(e==="TOP_RIGHT"?{particleCount:200,angle:225,spread:120,origin:{x:.9,y:0}}:{particleCount:350,spread:120,origin:{y:.6},angle:90})};function Bi({onClose:e=()=>console.log("Cancelled")}){const[t,n]=T.useState([]),{data:s,isFetching:a}=Ri(),{data:i}=gn(),o=T.useMemo(()=>v.filter(s,p=>p.collection!=="global"),[s]),l=T.useMemo(()=>v.filter(s,{collection:"global"}),[s]),u=T.useMemo(()=>v.find(s,{collection:"theme",id:"THEME"}),[s]),{mutate:h,isPending:y}=lr();T.useEffect(()=>{const p=v.map(v.filter(s,{online:!0}),"id");u&&p.push(u==null?void 0:u.id),n(p)},[s,u]);const g=t.length===(s==null?void 0:s.length),E=p=>{n(b=>v.includes(b,p)?v.filter(b,A=>A!==p):v.concat(b,p))},j=()=>{n(g?[]:v.map(s,"id"))},k=()=>{h({ids:v.uniq(t)},{onSuccess:()=>{e(),Bn("CENTER_CENTER")}})},O=p=>{if(p==="global")return"Global Block";if(p==="theme")return"Theme";const b=v.find(i,{key:p});return b?b==null?void 0:b.name:p},S=T.useMemo(()=>{const p=[{label:"Updated Pages & Global Blocks",top:"pt-2"},...v.orderBy(v.filter(o,{online:!0}),"collection"),...v.orderBy(v.filter(l,{online:!0}),"collection")].filter(V=>V.collection!=="theme"),b=[{label:"Offline Pages & Global Blocks",top:"pt-6"},...v.orderBy(v.filter(o,{online:!1}),"collection"),...v.orderBy(v.filter(l,{online:!1}),"collection")],A=u?[{label:"Theme",top:"pt-6"},u]:[];return[...p,...A,...b]},[o,l,u]);return r.jsx(f.Dialog,{open:!0,onOpenChange:y?()=>{}:e,children:r.jsxs(f.DialogContent,{className:"max-w-4xl max-h-[80%] flex flex-col",children:[r.jsxs(f.DialogHeader,{children:[r.jsx(f.DialogTitle,{children:"Publish changes"}),r.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),r.jsx("div",{className:"relative -mx-4 h-full overflow-y-auto max-h-full no-scrollbar",children:a?r.jsxs("div",{className:"space-y-2 px-1",children:[r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse mt-2"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"}),r.jsx("div",{className:"bg-gray-200 h-6 w-full rounded animate-pulse"})]}):r.jsxs("table",{className:"w-full text-xs text-left rtl:text-right text-gray-500 dark:text-gray-400",children:[r.jsx("thead",{className:"text-gray-700 border-b bg-gray-50 dark:bg-gray-700 dark:text-gray-400",children:r.jsxs("tr",{children:[r.jsxs("th",{scope:"col",className:"px-6 py-3 flex items-center gap-x-2 w-[1 50px]",children:[r.jsx("input",{checked:g,onClick:p=>{p.stopPropagation(),j()},type:"checkbox",className:"rounded focus:outline-none focus:ring-0 mt-1 cursor-pointer"}),"Name"]}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Language"}),r.jsx("th",{scope:"col",className:"px-2 py-3 w-[100px]",children:"Type"}),r.jsx("th",{scope:"col",className:"px-4 py-3 w-[150px] text-right",children:"Status"})]})}),r.jsx("tbody",{children:v.map(S,p=>p.label?r.jsx("tr",{children:r.jsxs("td",{colSpan:4,className:`px-6 py-2 text-xs font-medium text-gray-800 relative ${p.top}`,children:[r.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:r.jsx("div",{className:"w-full order-gray-300"})}),r.jsx("div",{className:"relative flex justify-start",children:r.jsx("span",{className:"bg-gray-50 pr-2",children:p.label})})]})},"separator"):r.jsxs("tr",{className:"hover:bg-gray-50 border-b last:border-b-0",children:[r.jsxs("td",{scope:"row",className:"px-6 py-2 text-gray-900 whitespace-nowrap dark:text-white flex items-center gap-x-1",children:[r.jsx("input",{checked:v.includes(t,p==null?void 0:p.id),onClick:b=>{b.stopPropagation(),E(p==null?void 0:p.id)},type:"checkbox",className:"rounded focus:outline-none focus:ring-0 cursor-pointer"})," ",p.collection==="global"?r.jsx(H.GlobeIcon,{className:"h-4 w-4"}):r.jsx(H.File,{className:"h-4 w-4"}),p.name,p.slug&&r.jsxs("span",{className:"text-xs text-gray-500",children:["(",p.slug,")"]})]}),r.jsx("td",{className:"px-2",children:p.lang}),r.jsx("td",{className:"px-2",children:O(p==null?void 0:p.collection)}),r.jsx("td",{className:"px-4 text-right",children:v.first(p.changes)||""})]},p==null?void 0:p.id))})]})}),r.jsxs(f.DialogFooter,{className:"mt-10",children:[r.jsx(f.Button,{disabled:y,variant:"outline",onClick:e,children:"Cancel"}),r.jsx(f.Button,{disabled:y||a||v.isEmpty(s),onClick:k,children:y?"Publishing...":"Publish"})]})]})})}const Fi=()=>{const e=he();return Q.useQuery({queryKey:[U.GET_WEBSITE_DATA],staleTime:1e3*60*5,queryFn:async()=>ge(e,{action:U.GET_WEBSITE_DATA,data:{draft:!0}})})};function qi({onClose:e}){const{data:t,isFetching:n}=Fi(),{mutateAsync:s,isPending:a}=ki(),i=Ht("settingComponent",null),o=v.debounce(async l=>(await s({data:l}),!0),300);return i?r.jsx(f.Dialog,{open:!0,onOpenChange:e,children:r.jsxs(f.DialogContent,{className:"w-full",children:[r.jsx(f.DialogHeader,{children:r.jsx(f.DialogTitle,{children:"Website Settings"})}),n?r.jsxs("div",{className:"w-full space-y-3 py-4",children:[r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"}),r.jsx("div",{className:"w-full h-8 rounded bg-gray-300 animate-pulse"})]}):r.jsx("div",{children:T.createElement(i,{data:t||{},onSave:a?()=>{}:o,cancel:a?()=>{}:e})})]})}):null}function hr({children:e,content:t}){return r.jsx(f.TooltipProvider,{children:r.jsxs(f.Tooltip,{children:[r.jsx(f.TooltipTrigger,{asChild:!0,children:e}),r.jsx(f.TooltipContent,{side:"bottom",sideOffset:10,children:r.jsx("p",{children:t})})]})})}const Wi=()=>{const e=Ht("getPreviewUrl",async o=>o),[t,n]=T.useState(""),{data:s,isFetching:a}=Re(),i=T.useMemo(()=>s==null?void 0:s.slug,[s==null?void 0:s.slug]);return T.useEffect(()=>{(async()=>{if(i&&typeof e=="function"){const o=await e(i||"");n(o)}else n("")})()},[e,i]),!t||(s==null?void 0:s.collection)==="global"||a?null:r.jsx(r.Fragment,{children:r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:r.jsxs(f.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(H.Eye,{className:"w-4 h-4"})," ",_.PREVIEW]})})})},Hi=()=>{const[e,t]=Me.useRightPanel();return r.jsxs(r.Fragment,{children:[r.jsx(hr,{content:_.THEME,children:r.jsx(f.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:r.jsx(H.Palette,{className:"w-4 h-4"})})}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"})]})},Vi=()=>{const[e,t]=T.useState(!1),{savePage:n,saveState:s}=Me.useSavePage();T.useEffect(()=>{const h=y=>{s==="UNSAVED"&&(y.preventDefault(),y.returnValue=!1)};return s==="UNSAVED"&&window.addEventListener("beforeunload",h),()=>{window.removeEventListener("beforeunload",h)}},[s]);const a=T.useCallback(async()=>{t(!0),await n(!1)},[n]);T.useEffect(()=>{s==="SAVED"&&t(!1)},[s]);const i=T.useMemo(()=>{if(s==="SAVED"||s==="UNSAVED")return s;if(s==="SAVING")return e?s:"SAVED"},[e,s]),{buttonIcon:o,buttonClass:l,tooltipContent:u}=T.useMemo(()=>{switch(i){case"UNSAVED":return{tooltipContent:_.SAVEDRAFT,buttonIcon:r.jsx(H.Save,{className:"w-4 h-4"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVING":return{tooltipContent:_.SAVING,buttonIcon:r.jsx(H.Loader,{className:"w-4 h-4 animate-spin"}),buttonClass:"flex items-center gap-x-1 leading-tight"};case"SAVED":return{tooltipContent:_.SAVED,buttonIcon:r.jsx(H.CheckCircle,{className:"w-4 h-4"}),buttonClass:"text-green-500 flex items-center gap-x-1 leading-tight"}}},[i]);return r.jsxs(f.Button,{size:"sm",variant:"ghost",onClick:a,className:l,children:[o," ",u]})},$i=()=>{const[e,t]=T.useState(!1),[n,s]=T.useState(!1),[a,i]=T.useState(null),{data:o}=Re(),{mutate:l,isPending:u}=lr(),{buttonText:h,buttonClassName:y,isPublished:g}=T.useMemo(()=>{const E=o&&(o==null?void 0:o.online);return{buttonClassName:E?"hover:bg-green-600 bg-green-500":"",isPublished:E,buttonText:E?_.PUBLISHED:_.PUBLISH}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex",children:[r.jsxs(f.Button,{size:"sm",disabled:u||!(o!=null&&o.id),onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>Bn("TOP_RIGHT")}),className:`relative overflow-hidden transition-all duration-300 ease-in-out text-white flex items-center gap-1 rounded-r-none ${y}`,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${n?"-translate-y-10":""}`,children:g?r.jsx(H.Send,{className:"w-4 h-4"}):r.jsx(H.Rocket,{className:"w-4 h-4"})}),r.jsx("span",{className:`absolute inset-0 flex items-center left-3 transition-transform duration-300 ease-in-out ${n?"":"translate-y-10"}`,children:g?r.jsx(H.Rocket,{className:"w-4 h-4"}):r.jsx(H.Send,{className:"w-4 h-4"})}),r.jsx("span",{children:h})]}),r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,children:r.jsx(f.Button,{size:"sm",disabled:u||!(o!=null&&o.id),className:`px-2 text-white border-l border-white/50 rounded-l-none ${y}`,children:r.jsx(H.ChevronDown,{className:"h-4 w-4"})})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"w-36",children:[!g&&r.jsxs(f.DropdownMenuItem,{disabled:u,className:"text-xs cursor-pointer",onClick:()=>l({ids:[o==null?void 0:o.id]},{onSuccess:()=>Bn("TOP_RIGHT")}),children:[_.PUBLISH," page"]}),r.jsxs(f.DropdownMenuItem,{onClick:()=>t(!0),className:"text-xs cursor-pointer",children:[_.OPEN," publish menu"]}),g&&r.jsxs(f.DropdownMenuItem,{onClick:()=>i(o),className:"text-xs cursor-pointer",children:[_.UNPUBLISH," page"]})]})]})]}),e&&r.jsx(Bi,{onClose:()=>t(!1)}),a&&r.jsx(Qn,{page:a,onClose:()=>i(null)})]})},Ki=()=>{const e=Ht("settingComponent",null),[t,n]=T.useState(!1);return e?r.jsxs(r.Fragment,{children:[r.jsx(hr,{content:_.WEBSITEDATA,children:r.jsx(f.Button,{variant:"ghost",size:"icon",className:"gap-2",onClick:()=>n(!0),children:r.jsx(H.Settings,{className:"w-4 h-4"})})}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700"}),t&&r.jsx(qi,{onClose:()=>n(!1)})]}):null},zi=()=>{const{data:e}=Re(),t=e&&(e==null?void 0:e.online);return r.jsxs(f.Button,{onClick:()=>t&&window.open(`${window.location.origin}${e.slug}`,"_blank"),disabled:!t,variant:"ghost",size:"sm",className:"flex items-center gap-1",children:[r.jsx(H.ExternalLink,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:_.OPEN})]})};function Qi(){return r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Hi,{}),r.jsx(Ki,{}),r.jsx(Wi,{}),r.jsx(Vi,{}),r.jsx($i,{}),r.jsx(zi,{})]})}function Yi({additionalPageTypes:e=[],close:t}){const{data:n}=hn(),{mutate:s,isPending:a}=ir(),[i,o]=T.useState("page"),[l,u]=T.useState(""),[h,y]=T.useState(""),[g,E]=T.useState(""),j=p=>{o(p),u(""),E("")},k=p=>{if(u(p),p&&p!=="none"){const b=n==null?void 0:n.find(R=>R.id===p),A=(b==null?void 0:b.slug)||"",V=g.split("/").pop();E(`${A}${V?`/${V}`:""}`)}else{const b=g.split("/").pop();E(b?`/${b}`:"")}},O=T.useCallback(p=>{if(l&&l!=="none"){const b=n==null?void 0:n.find(R=>R.id===l),A=(b==null?void 0:b.slug)||"",V=p.split("/").pop()||"";E(`${A}/${V}`)}else{const b=p.startsWith("/")?p:`/${p}`;E(b)}},[l,n]),S=p=>{if(p.preventDefault(),!h.trim()){f.toast({title:"Error",description:"Name is required",variant:"destructive"});return}if(i==="global"){s({pageType:"global",name:h,slug:""},{onSuccess:()=>{f.toast({title:"Success",description:"Global Block created successfully"}),t()}});return}if(l&&l!=="none"&&!g){f.toast({title:"Error",description:"Slug is required when a parent page is selected",variant:"destructive"});return}if(i!=="page"&&g===""){f.toast({title:"Error",description:"Slug is required for non-home pages",variant:"destructive"});return}const b={pageType:i,name:h,slug:g===""?"/":g,...l&&l!=="none"&&{parent:l}};s(b,{onSuccess:()=>{f.toast({title:"Success",description:"Page created successfully"}),t()}})};return i==="global"?r.jsxs("form",{onSubmit:S,className:"space-y-4 w-full max-w-md mx-auto",children:[r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"pageType",children:"Page Type"}),r.jsx("select",{id:"pageType",value:i,onChange:p=>j(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:e.map(p=>r.jsx("option",{value:p.key,children:p.name},p.key))})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"name",children:"Name"}),r.jsx(f.Input,{id:"name",value:h,onChange:p=>y(p.target.value),required:!0,"aria-required":"true"})]}),r.jsx(f.Button,{disabled:a,type:"submit",className:"w-full",children:a?"Creating...":"Create Global Block"})]}):r.jsxs("form",{onSubmit:S,className:"space-y-4 w-full max-w-md mx-auto",children:[r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"pageType",children:"Page Type"}),r.jsx("select",{id:"pageType",value:i,onChange:p=>j(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:e.map(p=>r.jsx("option",{value:p.key,children:p.name},p.key))})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"parentPage",children:"Parent"}),r.jsxs("select",{id:"parentPage",value:l,onChange:p=>k(p.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2",children:[r.jsx("option",{value:"none",children:"None"}),n==null?void 0:n.filter(p=>p.pageType!=="global"&&p.slug!=="/").map(p=>r.jsxs("option",{value:p.id,children:[p.name," (",p.slug,")"]},p.id))]})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"name",children:"Name"}),r.jsx(f.Input,{id:"name",value:h,onChange:p=>y(p.target.value),required:!0,"aria-required":"true"})]}),r.jsxs("div",{children:[r.jsx(f.Label,{htmlFor:"slug",children:"Slug"}),r.jsx(f.Input,{id:"slug",value:g,onChange:p=>O(p.target.value),placeholder:l&&l!=="none"?"Required - e.g. /your-slug":i==="page"?"Leave empty for home page":"Required - e.g. /your-slug"})]}),r.jsx(f.Button,{disabled:a,type:"submit",className:"w-full",children:a?"Creating...":"Create Page"})]})}const Xi=({addEditPage:e,setAddEditPage:t})=>{const{data:n}=gn();return r.jsx(f.Dialog,{open:!!e,onOpenChange:()=>t(void 0),children:r.jsxs(f.DialogContent,{className:"sm:max-w-[425px]",children:[r.jsxs(f.DialogHeader,{children:[r.jsxs(f.DialogTitle,{children:["Add New"," "]}),r.jsx(f.DialogDescription,{children:"Enter details to create a new page"})]}),r.jsx(Yi,{close:()=>t(void 0),additionalPageTypes:n??[]})]})})},Nn=({parentSlug:e,page:t,active:n,changeActivePage:s,setUnpublishPage:a,setChangeSlugPage:i,setDeletePage:o,setAddEditPage:l})=>r.jsxs("div",{onClick:()=>s(v.get(t,"id")),className:`rounded flex p-1.5 items-center justify-between leading-none duration-300 cursor-pointer px-3 py-1.5 ${n?"bg-gray-200":"hover:bg-gray-100"}`,children:[r.jsxs("div",{className:"flex items-center gap-x-2",children:[t.pageType==="global"?r.jsx(H.Globe,{className:"w-4 h-4 text-slate-500 stroke-[1]"}):r.jsx(H.File,{className:"w-4 h-4 text-slate-500 stroke-[1]"}),r.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.jsx("span",{className:"leading-none text-slate-800 font-light",children:v.startCase(t.name)??""}),t.pageType!=="global"?r.jsx(f.Badge,{variant:"outline",className:"ml-2 font-bold text-xs rounded-full leading-none text-slate-500",children:v.get(t,"slug").replace(e,"")||"/"}):r.jsx(f.Badge,{variant:"outline",className:"ml-2 font-bold text-xs rounded-full leading-none text-slate-500",children:"Global Block"})]}),r.jsx("div",{className:"flex items-center space-x-4",children:r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:r.jsx(H.MoreHorizontal,{className:"h-4 w-4 hover:stroke-[3]"})}),r.jsxs(f.DropdownMenuContent,{align:"end",className:"text-sm",children:[r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),l({...t,global:t.pageType==="global"})},children:[r.jsx(H.Pencil,{className:"size-3"}),"Edit"]}),(t==null?void 0:t.online)&&r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),a(t)},children:[r.jsx(H.Power,{className:"size-3"}),_.UNPUBLISH]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),i(t)},children:[r.jsx(H.Link,{className:"size-3"}),_.CHANGE_SLUG]}),r.jsxs(f.DropdownMenuItem,{className:"flex items-center gap-2 cursor-pointer",onClick:u=>{u.stopPropagation(),o(t)},children:[r.jsx(H.Trash,{className:"size-3"}),_.DELETE]})]})]})})]}),Ji=({close:e})=>{const[,t]=T.useState([]),[n,s]=T.useState(""),[a,i]=T.useState(null),[o,l]=T.useState(null),[u,h]=T.useState(null),[y,g]=T.useState(null),{data:E,isFetching:j}=hn(),[k,O]=Qe(),S=k.get("page"),p=T.useCallback(A=>{window.history.pushState({},"",`?page=${A}`),O(new URLSearchParams({page:A})),window.dispatchEvent(new PopStateEvent("popstate")),e()},[e,O]);T.useEffect(()=>{if(S&&!j){const A=v.find(E,{id:S});A&&(A!=null&&A.pageType)?t(V=>[...V,A==null?void 0:A.pageType]):(window.history.replaceState(null,"","/"),O(new URLSearchParams({})),window.dispatchEvent(new PopStateEvent("popstate")))}},[E,S,j,O]);const b=T.useMemo(()=>{const A=v.filter(E,C=>v.isEmpty(n)?!0:v.includes(v.toLower(C==null?void 0:C.name),v.toLower(n))||v.includes(v.toLower(C==null?void 0:C.slug),v.toLower(n))),V=new Map;A.forEach(C=>{V.set(C.id,{...C,children:[]})});const R=[],Ce=[];V.forEach(C=>{if(C.parent){const q=V.get(C.parent);q?q.children.push(C):R.push(C)}else Ce.push(C)}),R.sort((C,q)=>C.name.localeCompare(q.name)),R.forEach(C=>{C.children.sort((q,ee)=>q.name.localeCompare(ee.name))});const ke=v.filter(Ce,C=>C.pageType==="global"),Te=v.filter(Ce,C=>C.pageType!=="global").sort((C,q)=>C.name.localeCompare(q.name));return v.compact([...Te,...ke,...R])},[E,n]);return console.log(b),r.jsxs("div",{className:"h-full flex flex-col justify-between",children:[r.jsxs("div",{className:"space-y-6 flex flex-col h-full",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"rounded-md bg-primary p-2 text-primary-foreground",children:r.jsx(H.File,{className:"h-6 w-6"})}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Manage your site structure"})]})]}),r.jsxs("div",{className:"relative flex item-center gap-x-4",children:[r.jsx(H.Search,{strokeWidth:2.5,className:"absolute left-3 top-2.5 h-4 w-4 text-gray-400"}),r.jsx(f.Input,{placeholder:"Search pages...",className:"pl-9 text-xs font-medium placeholder:text-gray-400 leading-none text-gray-700",value:n,onChange:A=>s(A.target.value)})]}),j?r.jsx("div",{className:"space-y-2",children:v.map([...Array(5).keys()],A=>r.jsx("div",{className:"h-9 w-full rounded bg-gray-200 animate-pulse"},A))}):v.isEmpty(b)?r.jsxs("div",{className:"h-[70vh] flex flex-col gap-y-1 items-center justify-center text-slate-500 text-sm font-medium",children:[r.jsx(H.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",r.jsx("span",{className:"font-light",children:"Add new page to start"})]}):r.jsx("div",{className:"text-sm text-slate-700 space-y-2 h-[70vh] overflow-y-auto",children:v.map(b,A=>A.children.length>0?r.jsxs("div",{className:"border-0",children:[r.jsx(Nn,{changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:S===A.id,page:A}),r.jsx("div",{className:"bg-white pl-6 pt-2",children:v.map(v.get(A,"children",[]),V=>{const R=S===v.get(V,"id");return r.jsx(Nn,{parentSlug:A.slug,changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:R,page:V})})})]},A.key):r.jsx(Nn,{changeActivePage:p,setUnpublishPage:l,setChangeSlugPage:h,setDeletePage:i,setAddEditPage:g,active:S===A.id,page:A}))})]}),r.jsxs(f.Button,{className:"text-sm flex gap-x-2",onClick:()=>{g({slug:"",name:"",collection:"page",pageType:"page"})},children:[r.jsx(H.Plus,{className:"w-4 h-4"})," Add New"]}),y&&r.jsx(Xi,{editPage:p,addEditPage:y,setAddEditPage:g}),a&&r.jsx(dr,{page:a,onClose:()=>i(null)}),o&&r.jsx(Qn,{page:o,onClose:()=>l(null)}),u&&r.jsx(ur,{page:u,onClose:()=>h(null)})]})},Zi=()=>{const e=Ht("logo",null);return e?r.jsx("div",{className:"w-full max-h-9 overflow-hidden pr-2",children:T.createElement(e,{})}):null},eo=()=>{const[e]=Qe(),t=e.get("page"),{data:n,isFetching:s}=Re(),[a,i]=T.useState(!1),o=!!t&&!v.isEmpty(n),l=!t||!s&&v.isEmpty(n)||a;return r.jsxs(r.Fragment,{children:[r.jsxs(f.Button,{variant:"secondary",className:"flex items-center w-full space-x-2 py-1",onClick:()=>i(!0),children:[r.jsx("div",{children:r.jsx(H.Logs,{className:"h-4 w-4"})}),r.jsxs("span",{className:"truncate leading-tight flex items-center max-w-[200px]",children:[r.jsx("span",{className:"text-slate-600 pr-1 font-light",children:"Editing:"}),s?r.jsx(H.Loader,{className:"h-4 w-4 animate-spin text-slate-400 ml-2"}):v.startCase(v.get(n,"name"))??""]})]},"template-viewer"),r.jsx(f.Sheet,{open:l,onOpenChange:u=>!u&&o&&i(!1),children:r.jsx(f.SheetContent,{side:"left",className:`!max-w-screen-sm border-border w-full ${o?"":"sheet-hide-close-btn"}`,children:r.jsx(Ji,{close:()=>i(!1)})})})]})},to=()=>{const{fallbackLang:e,languages:t,selectedLang:n,setSelectedLang:s}=Me.useLanguages(),a=v.isEmpty(n)?e:n,[i,o]=T.useState(null),{data:l}=Re(),{data:u}=Kn(),{data:h,isFetching:y}=zn(),g=T.useMemo(()=>{const E=v.compact(v.map(v.get(u,"languages"),j=>{const k=v.find(h,{lang:j});return{key:j,value:v.get(qe,j,j),isLangPageAdded:!!k}})).filter(Boolean);return[{key:e,value:v.get(qe,e),isLangPageAdded:!0},...E]},[h,u]);return v.isEmpty(t)||y?null:r.jsxs(r.Fragment,{children:[r.jsxs(f.DropdownMenu,{children:[r.jsx(f.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:r.jsxs(f.Button,{variant:"ghost",size:"sm",className:"gap-2",children:[r.jsx(H.Languages,{className:"w-4 h-4"}),v.get(qe,a,a),r.jsx(H.ChevronDown,{className:"w-4 h-4"})]})}),r.jsxs(f.DropdownMenuContent,{className:"border-border space-y-1",children:[v.map(g.filter(E=>E.isLangPageAdded),E=>r.jsxs(f.DropdownMenuItem,{className:Me.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",E.key===a&&"!bg-gray-200 text-gray-700"),onClick:()=>s(E.key),children:[r.jsx("div",{className:"text-slate-600",children:E.value}),E.key===e&&r.jsxs("small",{className:"text-[9px] flex items-center gap-x-1 text-orange-500 leading-none",children:[r.jsx(H.Star,{fill:"orange",className:"w-2 h-2"}),"Primary"]})]},E.value)),!v.isEmpty(g.filter(E=>!E.isLangPageAdded))&&r.jsxs(r.Fragment,{children:[r.jsx(f.Separator,{}),r.jsxs(f.Button,{size:"sm",variant:"ghost",onClick:()=>{o({name:l==null?void 0:l.name,collection:l==null?void 0:l.collection,lang:"",slug:"",edit:!1})},className:"hover:bg-slate-300 duration-200 font-normal text-xs hover:text-slate-800",children:[r.jsx(H.Plus,{className:"w-3 h-3 mr-1"})," Add Langauge"]})]})]})]}),i&&r.jsx(fr,{languages:t,langProps:i,onClose:()=>o(null)})]})};function no(){return r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(Zi,{}),r.jsx(eo,{}),r.jsx(to,{})]})}Pr.loadWebBlocks();const so=e=>{const t=T.useRef([]),[n]=Qe(),s=n.get("page"),{data:a}=Re(),{data:i}=Ti(),{data:o,isFetching:l}=ji(),{blocks:u}=Ni(o),{data:h}=Kn(),{data:y}=gn(),{mutateAsync:g}=_i(),E=wi(),{getUILibraryBlock:j,getUILibraryBlocks:k,onSave:O}=Ci(),{getGlobalBlocks:S,getGlobalBlockBlocks:p}=Pi(),{aiContext:b,setAiContext:A}=$n(),{mutateAsync:V}=Li();t.current=u;const R=T.useMemo(()=>{const C={};return e.mediaManagerComponent&&(C.mediaManagerComponent=e.mediaManagerComponent),C},[e.mediaManagerComponent]),Ce=T.useMemo(()=>Array.isArray(e==null?void 0:e.uiLibraries)?[...i,...e==null?void 0:e.uiLibraries]:i,[i,e==null?void 0:e.uiLibraries]),ke=T.useCallback(async(C,q)=>await V({collection:C,query:q}),[V]),Te=T.useMemo(()=>v.cloneDeep(v.get(h,"theme",{}))||{},[h]);return r.jsx(r.Fragment,{children:r.jsx(Me.ChaiBuilderEditor,{addBlocksDialogTabs:e.addBlocksDialogTabs||[],loading:l,fallbackLang:h.fallbackLang||"en",languages:(h==null?void 0:h.languages)||[],brandingOptions:(h==null?void 0:h.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSaveSupport:e.autoSaveSupport||!0,autoSaveInterval:e.autoSaveInterval||25,onError:e.onError||console.error,getGlobalBlockBlocks:p,getGlobalBlocks:S,blocks:u,theme:Te,getUILibraryBlock:j,getUILibraryBlocks:k,uiLibraries:Ce,collections:y,searchCollectionItems:ke,saveAiContextCallback:async C=>{if(!s)return!0;const q=t.current,ee={_type:"@chai/ai-context",_value:v.isString(C)?C:""},ve=[...q,ee];return await O({page:s,blocks:ve}),A(C),!0},aiContext:b,askAiCallBack:E,onSave:async({blocks:C,theme:q})=>{if(!s)return!0;t.current=C;const ee={_type:"@chai/ai-context",_value:v.isString(b)?b:""},ve=[...C,ee];return await O({page:s,blocks:ve}),t.current=C,v.isEqual(q,Te)||await g({settings:{theme:q}}),!0},topBarComponents:{left:[no],right:[Qi]},sideBarComponents:{top:[...(a==null?void 0:a.collection)!=="global"?[{label:"SEO Setting",component:cr,icon:r.jsx(r.Fragment,{children:r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 21 21",fill:"currentColor",width:"21",height:"21",children:[r.jsx("path",{d:"M9.931 6.818c-1.238 0-2.136.925-2.136 2.2 0 1.279.898 2.207 2.136 2.207.664 0 1.257-.246 1.67-.694a.15.15 0 0 0-.009-.213l-.311-.286a.15.15 0 0 0-.213.009c-.273.297-.677.46-1.137.46-.699 0-1.233-.444-1.375-1.12h3.295a.15.15 0 0 0 .151-.151v-.211c0-1.295-.852-2.2-2.072-2.2m0 .724c.697 0 1.188.422 1.315 1.113h-2.69c.142-.673.676-1.113 1.374-1.113m4.332-.724c-1.246 0-2.15.925-2.15 2.2 0 1.279.904 2.207 2.15 2.207.596 0 1.143-.223 1.538-.628s.612-.965.612-1.579c0-1.275-.904-2.2-2.15-2.2m0 3.683c-.826 0-1.426-.624-1.426-1.483 0-.855.6-1.475 1.426-1.475s1.426.621 1.426 1.476c0 .423-.144.804-.406 1.073-.258.264-.62.41-1.019.41M6.318 8.71c-.665-.206-.902-.335-.902-.645 0-.47.564-.521.806-.521.29 0 .552.07.801.215a.15.15 0 0 0 .206-.055l.212-.366a.15.15 0 0 0-.055-.206 2.27 2.27 0 0 0-1.165-.312c-.915 0-1.53.501-1.53 1.245 0 .899.816 1.152 1.411 1.336.655.203.812.307.804.53-.016.398-.567.429-.735.429-.386 0-.722-.129-.972-.374q-.043-.042-.107-.043a.15.15 0 0 0-.106.045l-.295.302a.15.15 0 0 0 .002.213c.383.374.908.58 1.478.58.859 0 1.432-.441 1.459-1.125.031-.833-.746-1.074-1.313-1.249"}),r.jsx("path",{d:"M20.396 2.049H.604A.604.604 0 0 0 0 2.653v12.7c0 .333.27.604.604.604h6.941c-.266 1.296-.881 1.966-.886 1.971a.604.604 0 0 0 .434 1.024h6.815a.604.604 0 0 0 .434-1.024c-.007-.007-.621-.675-.886-1.971h6.941c.333 0 .604-.27.604-.604V2.652a.604.604 0 0 0-.604-.604m-.604 12.701h-.985v-.17a.604.604 0 0 0-1.208 0v.17h-.63v-.17a.604.604 0 0 0-1.208 0v.17H1.207V3.256h18.585z"})]})})}]:[],...v.isEmpty(h==null?void 0:h.languages)?[]:[{label:`Language ${(a==null?void 0:a.collection)==="global"?"":"page"}`,component:Ui,icon:r.jsx(H.Languages,{className:"w-5 h-5 stroke-[2]"})}]]},...R})})},ro=new Q.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),ao=e=>{const[,t]=ar();return T.useEffect(()=>{t(v.pick(e,["apiUrl","getPreviewUrl","logo","settingComponent"]))},[e,t]),r.jsxs(Q.QueryClientProvider,{client:ro,children:[r.jsx(so,{...e}),r.jsx(bi,{})]})};exports.$TRACK=Fn;exports.ChaiBuilderForge=ao;exports.Dynamic=Aa;exports.For=ta;exports.Index=na;exports.Match=aa;exports.Portal=ja;exports.Show=sa;exports.Switch=ra;exports.addEventListener=Gs;exports.batch=Mr;exports.className=Os;exports.clearDelegatedEvents=ya;exports.convertRemToPixels=mi;exports.createComponent=Hn;exports.createComputed=_n;exports.createContext=Wr;exports.createEffect=qn;exports.createMemo=Ee;exports.createRenderEffect=Fe;exports.createRoot=Be;exports.createSignal=le;exports.createUniqueId=ea;exports.delegateEvents=Is;exports.deleteNestedDataByPath=At;exports.displayValue=ci;exports.getMutationStatusColor=oi;exports.getPreferredColorScheme=pi;exports.getQueryStatusColor=ii;exports.getQueryStatusColorByLabel=li;exports.getQueryStatusLabel=ri;exports.getSidedProp=ai;exports.insert=ln;exports.mergeProps=Vn;exports.mutationSortFns=gi;exports.on=Ur;exports.onCleanup=mt;exports.onMount=Cs;exports.serialize=tr;exports.setAttribute=on;exports.sortFns=fi;exports.splitProps=_s;exports.spread=Ms;exports.stringify=si;exports.template=pa;exports.untrack=me;exports.updateNestedDataByPath=jt;exports.use=Us;exports.useContext=Hr;exports.useTransition=qr;