@pramen/cms-editor 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -12,6 +12,6 @@
12
12
  </head>
13
13
  <body>
14
14
  <div id="app"></div>
15
- <script type="module" src="/main.9qvpgp32.js"></script>
15
+ <script type="module" src="/main.22t99khc.js"></script>
16
16
  </body>
17
17
  </html>
@@ -248,4 +248,4 @@ You might need to use a local HTTP server (instead of file://): https://react.de
248
248
  <%s {...props} />
249
249
  React keys must be passed directly to JSX without using spread:
250
250
  let props = %s;
251
- <%s key={someKey} {...props} />`,VZ,IZ,YX,IZ),p[IZ+VZ]=!0)}if(IZ=null,AZ!==void 0&&(z(AZ),IZ=""+AZ),A(o)&&(z(o.key),IZ=""+o.key),"key"in o){AZ={};for(var TX in o)TX!=="key"&&(AZ[TX]=o[TX])}else AZ=o;return IZ&&L(AZ,typeof w==="function"?w.displayName||w.name||"Unknown":w),I(w,IZ,AZ,W(),vZ,JX)}function M(w){R(w)?w._store&&(w._store.validated=1):typeof w==="object"&&w!==null&&w.$$typeof===l&&(w._payload.status==="fulfilled"?R(w._payload.value)&&w._payload.value._store&&(w._payload.value._store.validated=1):w._store&&(w._store.validated=1))}function R(w){return typeof w==="object"&&w!==null&&w.$$typeof===j}var j=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),t=Symbol.for("react.consumer"),qZ=Symbol.for("react.context"),QZ=Symbol.for("react.forward_ref"),LZ=Symbol.for("react.suspense"),kZ=Symbol.for("react.suspense_list"),JZ=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),OZ=Symbol.for("react.activity"),n=Symbol.for("react.client.reference"),wZ=vz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,WZ=Object.prototype.hasOwnProperty,HZ=Array.isArray,v=console.createTask?console.createTask:function(){return null};vz={react_stack_bottom_frame:function(w){return w()}};var m,E={},g=vz.react_stack_bottom_frame.bind(vz,K)(),e=v(_(K)),p={};_v.Fragment=d,_v.jsxDEV=function(w,o,AZ,VZ){var vZ=1e4>wZ.recentlyCreatedOwnerStacks++;return N(w,o,AZ,VZ,vZ?Error("react-stack-top-frame"):g,vZ?v(_(w)):e)}})()});var $W,Wv,xY=({label:Q,description:q,errorMessage:z,placeholder:_,size:W,...K})=>$W.jsxDEV(YB,{...K,className:"flex w-full flex-col gap-2",children:[$W.jsxDEV(Bz,{className:"text-heading5 font-medium text-fg",children:Q},void 0,!1,void 0,this),$W.jsxDEV(Wv,{placeholder:_,fieldSize:W},void 0,!1,void 0,this),q?$W.jsxDEV(ZG,{slot:"description",className:"text-xs text-fg-muted",children:q},void 0,!1,void 0,this):null,$W.jsxDEV(LW,{className:"text-xs text-danger",children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var yC=C(()=>{zJ();FY();$W=f($Z(),1),Wv=mZ(RO,{displayName:"InputControl",baseClass:"w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none transition-colors duration-200 placeholder:text-fg-muted data-[hovered]:border-fg-subtle data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring data-[invalid]:border-danger data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none",variants:{fieldSize:{sm:"h-8",md:"h-10",lg:"h-12"}},defaultVariants:{fieldSize:"md"}})});var SW,Uv,ZF=({label:Q,description:q,errorMessage:z,placeholder:_,rows:W,...K})=>SW.jsxDEV(YB,{...K,className:"flex w-full flex-col gap-2",children:[SW.jsxDEV(Bz,{className:"text-sm font-medium text-fg",children:Q},void 0,!1,void 0,this),SW.jsxDEV(Uv,{placeholder:_,rows:W},void 0,!1,void 0,this),q?SW.jsxDEV(ZG,{slot:"description",className:"text-xs text-fg-muted",children:q},void 0,!1,void 0,this):null,SW.jsxDEV(LW,{className:"text-xs text-danger",children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var vC=C(()=>{zJ();FY();SW=f($Z(),1),Uv=mZ(y5,{displayName:"TextAreaControl",baseClass:"min-h-[120px] w-full resize-y rounded-lg border border-border bg-surface-card px-4 py-3 text-sm text-fg outline-none transition-colors duration-200 placeholder:text-fg-muted data-[hovered]:border-fg-subtle data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring data-[invalid]:border-danger data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"})});var hC;var bC=C(()=>{hC=f($Z(),1)});var Kv;var gC=C(()=>{Kv=f($Z(),1)});var Bv;var mC=C(()=>{Bv=f($Z(),1)});var Lv,hYZ,bYZ;var fC=C(()=>{zJ();FY();Lv=f($Z(),1),hYZ=mZ(Rz,{displayName:"SelectTrigger",baseClass:"flex min-h-[58px] w-full items-center justify-between gap-2.5 rounded-lg bg-surface-card p-5 text-sm text-fg outline-none transition-colors data-[hovered]:bg-surface-muted data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),bYZ=mZ(tK,{displayName:"SelectItem",baseClass:"flex cursor-pointer select-none items-center rounded-md px-5 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[selected]:font-medium data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"})});var uC,pYZ,lYZ;var dC=C(()=>{zJ();FY();uC=f($Z(),1),pYZ=mZ(rO,{displayName:"DialogOverlay",baseClass:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[rgba(179,179,179,0.5)] backdrop-blur-[2px] data-[entering]:animate-in data-[exiting]:animate-out"}),lYZ=mZ(R5,{displayName:"DialogModal",baseClass:"rounded-lg bg-surface p-5 outline-none shadow-[0px_2px_8px_0px_rgba(0,0,0,0.06)]"})});var Ov,aYZ,oYZ;var cC=C(()=>{zJ();FY();Ov=f($Z(),1),aYZ=mZ(kz,{displayName:"DropdownMenuItem",baseClass:"flex cursor-pointer select-none items-center gap-2.5 rounded-md px-4 py-3 text-sm text-fg outline-none data-[focused]:bg-surface-card data-[hovered]:bg-surface-card data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50",variants:{destructive:{true:"text-danger data-[focused]:text-danger data-[hovered]:text-danger"}}}),oYZ=mZ(H6,{displayName:"DropdownMenuSeparator",baseClass:"my-2 h-px border-0 bg-border"})});var XF,pC,ZQZ;var lC=C(()=>{zJ();FY();XF=f(ZZ(),1),pC=f($Z(),1),ZQZ=mZ(kz,{displayName:"ContextMenuItem",baseClass:"flex min-h-[34px] cursor-pointer select-none items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-compact text-white outline-none data-[focused]:bg-[#2f2f2f] data-[focused]:font-medium data-[hovered]:bg-[#2f2f2f] data-[hovered]:font-medium data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45",variants:{destructive:{true:"text-[#ffb5b5] data-[focused]:text-[#ffb5b5]"}}})});var Fv;var m5=C(()=>{Fv=f($Z(),1)});var iC,HQZ;var nC=C(()=>{zJ();iC=f($Z(),1),HQZ=new QB({maxVisibleToasts:5})});var UQZ,KQZ;var sC=C(()=>{zJ();FY();UQZ=mZ(M5,{displayName:"Disclosure"}),KQZ=mZ(N5,{displayName:"DisclosurePanel"})});var OQZ,FQZ,MQZ;var aC=C(()=>{zJ();FY();OQZ=mZ(E5,{displayName:"TabList",baseClass:"flex gap-2 border-b border-border"}),FQZ=mZ(k5,{displayName:"Tab",baseClass:"cursor-pointer select-none border-b-2 border-transparent px-4 py-3 text-sm font-medium text-fg-muted outline-none transition-colors data-[hovered]:text-fg data-[selected]:border-brand-primary data-[selected]:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),MQZ=mZ(x5,{displayName:"TabPanel",baseClass:"py-4 text-sm text-fg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"})});var Mv;var oC=C(()=>{b5();Mv=f($Z(),1)});var Nv;var rC=C(()=>{Nv=f($Z(),1)});var RQZ,jQZ;var tC=C(()=>{FY();RQZ=mZ("span",{displayName:"Text",baseClass:"text-fg",variants:{size:{micro:"text-micro",caption:"text-caption",label:"text-label",compact:"text-compact",callout:"text-callout",body:"text-body",subtitle:"text-subtitle",title:"text-title",headline:"text-headline",display:"text-display"},weight:{regular:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},tone:{default:"text-fg",muted:"text-fg-muted",subtle:"text-fg-subtle",inverted:"text-fg-inverted"}},defaultVariants:{size:"body",weight:"regular",tone:"default"}}),jQZ=mZ("h2",{displayName:"Heading",baseClass:"font-medium tracking-tight text-fg",variants:{level:{"1":"text-heading1","2":"text-heading2","3":"text-heading3","4":"text-heading4","5":"text-heading5"}},defaultVariants:{level:"2"}})});var Iv;var eC=C(()=>{m5();Iv=f($Z(),1)});var kQZ;var ZP=C(()=>{FY();kQZ=mZ("div",{displayName:"Card",baseClass:"relative rounded-lg bg-surface-card",variants:{variant:{plain:"",outlined:"border border-border",elevated:"shadow-md"},padding:{none:"p-0",sm:"p-4",md:"p-6",lg:"p-8"}},defaultVariants:{variant:"plain",padding:"md"}})});var vQZ;var XP=C(()=>{FY();vQZ=mZ("section",{displayName:"Section",baseClass:"w-full",variants:{padding:{none:"py-0",sm:"py-4",md:"py-6 sm:py-8",lg:"py-8 sm:py-12",xl:"py-12 sm:py-16"}},defaultVariants:{padding:"md"}})});var gQZ;var YP=C(()=>{FY();gQZ=mZ("div",{displayName:"PageContainer",baseClass:"w-full",variants:{size:{sm:"max-w-screen-sm mx-auto",md:"max-w-screen-md mx-auto",lg:"max-w-screen-lg mx-auto",xl:"max-w-screen-xl ml-0 mr-0 min-[1200px]:max-w-full","2xl":"max-w-screen-2xl mx-auto min-[1600px]:max-w-full min-[1600px]:mx-0",full:"max-w-full"}}})});var QP,Tv,uQZ,dQZ,cQZ;var JP=C(()=>{FY();QP=f(ZZ(),1),Tv=f($Z(),1),uQZ=mZ("div",{displayName:"AppShell",baseClass:"grid h-screen w-full overflow-hidden bg-surface grid-rows-[100%] grid-cols-[1fr] md:grid-cols-[auto_1fr]"}),dQZ=mZ("aside",{displayName:"AppShell.Sidebar",baseClass:"h-full w-64 shrink-0 overflow-y-auto border-r border-border bg-surface"}),cQZ=mZ("main",{displayName:"AppShell.Main",baseClass:"min-w-0 flex-1 bg-surface px-6 pb-6 pt-6"})});var qP,wv,Vv,Rv,jv=(Q)=>qP.jsxDEV(Rv,{...Q},void 0,!1,void 0,this),Cv,Pv,sQZ,aQZ,oQZ;var GP=C(()=>{zJ();FY();qP=f($Z(),1),wv=mZ("header",{displayName:"Topbar",baseClass:"flex h-14 w-full items-center gap-5 border-b border-border"}),Vv=mZ("div",{displayName:"Topbar.Brand",baseClass:"flex min-w-0 items-center gap-3 text-compact leading-4 font-medium tracking-tight text-fg"}),Rv=mZ("nav",{displayName:"Topbar.Nav",baseClass:"ml-auto flex min-w-0 items-center gap-2 overflow-x-auto"}),Cv=mZ("div",{displayName:"Topbar.Actions",baseClass:"ml-auto flex items-center gap-4"}),Pv=mZ("a",{displayName:"Topbar.NavLink",baseClass:"inline-flex items-center rounded-sm px-[13px] py-[6px] text-compact leading-4 whitespace-nowrap text-fg no-underline transition-colors hover:bg-surface-muted hover:text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring data-[active]:bg-surface-muted data-[active]:text-fg",variants:{active:{true:"",false:""}},variantsAsDataAttrs:["active"]}),sQZ=mZ(tK,{displayName:"WorkspaceSwitcher.Item",baseClass:"flex cursor-pointer select-none items-center rounded-sm px-3 py-2 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[selected]:font-medium"}),aQZ=mZ(kz,{displayName:"UserMenu.Item",baseClass:"flex cursor-pointer select-none items-center rounded-sm px-3 py-2 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),oQZ=Object.assign(wv,{Brand:Vv,Nav:jv,NavLink:Pv,Actions:Cv})});var Dv,$v,eQZ;var HP=C(()=>{FY();Dv=f(ZZ(),1),$v=f($Z(),1),eQZ=mZ("header",{displayName:"PersistentPageShell.Header",baseClass:"flex w-full flex-col gap-6 bg-surface",variants:{sticky:{true:"sticky top-0 z-[1]",false:""}},defaultVariants:{sticky:!1}})});var WH=C(()=>{FY();b5();yC();vC();bC();gC();mC();fC();dC();cC();lC();m5();nC();sC();aC();oC();rC();tC();eC();ZP();XP();YP();JP();GP();HP()});function YF(Q){try{let q=String(Q).split(".")[1];if(!q)return!1;let z=JSON.parse(atob(q.replace(/-/g,"+").replace(/_/g,"/")));return typeof z.exp==="number"&&Date.now()>=z.exp*1000}catch{return!1}}function zP(){try{let Q=localStorage.getItem(f5);if(Q)return JSON.parse(Q)}catch{}return{baseUrl:"http://localhost:8787",token:"",tenant:"main"}}function _P(Q){localStorage.setItem(f5,JSON.stringify(Q))}function WP(){try{localStorage.removeItem(f5)}catch{}}class u5{cfg;onExpired;constructor(Q,q){this.cfg=Q;this.onExpired=q}setConfig(Q){this.cfg=Q}base(){return this.cfg.baseUrl.replace(/\/+$/,"")}async call(Q,q){if(this.onExpired&&this.cfg.token&&YF(this.cfg.token))return this.onExpired(),new Promise(()=>{});let z=await fetch(`${this.base()}/rpc/${Q}`,{method:"POST",headers:{"content-type":"application/json","x-pramen-tenant":this.cfg.tenant||"main",...this.cfg.token?{authorization:`Bearer ${this.cfg.token}`}:{}},body:JSON.stringify(q??{})}),_;try{_=await z.json()}catch{throw new EW(`non-JSON response (HTTP ${z.status})`,"bad_response",z.status)}if(_.ok!==!0){let W=_.error??`request failed (HTTP ${z.status})`,K=z.status===403?" — check your token has an editor/reviewer role":"";throw new EW(W+K,_.code??"error",z.status)}return _.result}async put(Q,q,z){let _=Q.startsWith("http")?Q:`${this.base()}${Q}`,W=await fetch(_,{method:"PUT",headers:{"content-type":z},body:q});if(!W.ok)throw new EW(`upload failed (HTTP ${W.status})`,"upload_failed",W.status)}resolve(Q){return Q.startsWith("http")?Q:`${this.base()}${Q}`}listBlockTypes=()=>this.call("listBlockTypes");listContentTypes=()=>this.call("listContentTypes");getContentType=(Q)=>this.call("getContentType",{id:Q});listPages=()=>this.call("listPages");getPagePreview=(Q,q)=>this.call("getPage",{slug:Q,locale:q,preview:!0});listPageAudit=(Q)=>this.call("listPageAudit",{pageId:Q});listMedia=(Q=50,q=0)=>this.call("listMedia",{limit:Q,offset:q});getMedia=(Q)=>this.call("getMedia",{id:Q});updateMedia=(Q,q)=>this.call("updateMedia",{id:Q,alt:q});deleteMedia=(Q)=>this.call("deleteMedia",{id:Q});async uploadMedia(Q){let q=Q.type||"application/octet-stream",z=await this.call("signMediaUpload",{contentType:q,filename:Q.name});return await this.put(z.url,await Q.arrayBuffer(),q),this.call("createMedia",{ref:z.ref,alt:Q.name})}}var EW,f5="pramen.cmsEditor";var d5=C(()=>{EW=class EW extends Error{code;status;constructor(Q,q,z){super(Q);this.code=q;this.status=z;this.name="ApiError"}}});function c5(){WP(),location.replace(JB)}function _J(){let Q=KQ.use(UP);if(!Q)throw Error("useApp must be used within <AppProvider>");return Q}function KP({children:Q}){let[q,z]=KQ.useState(zP()),[_,W]=KQ.useState(null),[K,A]=KQ.useState(""),L=Boolean(q.baseUrl&&q.token)&&!YF(q.token),O=KQ.useMemo(()=>new u5(q,JB?c5:void 0),[q]);if(KQ.useEffect(()=>{if(!JB)return;let N=()=>{if(!q.token||YF(q.token))c5()};N();let M=()=>{if(!document.hidden)N()},R=window.setInterval(N,30000);return window.addEventListener("visibilitychange",M),window.addEventListener("focus",N),()=>{window.clearInterval(R),window.removeEventListener("visibilitychange",M),window.removeEventListener("focus",N)}},[q.token]),KQ.useEffect(()=>{if(!L)return;O.call("me").then(W).catch(()=>W({}))},[O,L]),!L)return JB?null:UQ.jsxDEV(Sv,{cfg:q,onSave:(N)=>{_P(N),z(N)}},void 0,!1,void 0,this);let I={api:O,cfg:q,me:_,isAdmin:(_?.roles??[]).includes("admin"),error:K,setError:A,reconfigure:()=>{if(JB){c5();return}W(null),A(""),z({...q,token:""})}};return UQ.jsxDEV(UP,{value:I,children:Q},void 0,!1,void 0,this)}function Sv({cfg:Q,onSave:q}){let[z,_]=KQ.useState(Q);return UQ.jsxDEV("div",{className:"mx-auto mt-[14vh] w-full max-w-[520px] px-6",children:UQ.jsxDEV("div",{className:"rounded-panel border border-border bg-surface-card px-10 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.08)]",children:[UQ.jsxDEV("h1",{className:"mb-4 text-display text-fg",children:["pramen ",UQ.jsxDEV("span",{className:"text-fg-subtle",children:"· cms editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),UQ.jsxDEV("p",{className:"mb-6 text-sm text-fg-muted",children:["Point at your Worker and paste an editor/reviewer JWT. CORS must allow this origin (",UQ.jsxDEV("code",{children:"CORS_ORIGINS"},void 0,!1,void 0,this),")."]},void 0,!0,void 0,this),UQ.jsxDEV("div",{className:"flex flex-col gap-4",children:[UQ.jsxDEV(xY,{label:"Worker base URL",value:z.baseUrl,onChange:(W)=>_({...z,baseUrl:W}),placeholder:"https://your-worker.workers.dev"},void 0,!1,void 0,this),UQ.jsxDEV(xY,{label:"Tenant",value:z.tenant,onChange:(W)=>_({...z,tenant:W}),placeholder:"main"},void 0,!1,void 0,this),UQ.jsxDEV(xY,{label:"Bearer token (editor or reviewer)",value:z.token,onChange:(W)=>_({...z,token:W}),placeholder:"eyJ…"},void 0,!1,void 0,this),UQ.jsxDEV(yZ,{className:"mt-2 w-full",onPress:()=>q(z),isDisabled:!z.baseUrl||!z.token,children:"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var KQ,UQ,JB,UP;var UH=C(()=>{WH();d5();KQ=f(ZZ(),1),UQ=f($Z(),1),JB=typeof window<"u"&&!new URLSearchParams(window.location.search).has("setup")?window.PRAMEN_CMS_EDITOR?.signInUrl:void 0;UP=KQ.createContext(null)});function kW({label:Q,children:q}){return MZ.jsxDEV("label",{className:"flex w-full flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:Q},void 0,!1,void 0,this),q]},void 0,!0,void 0,this)}function QF({schema:Q,value:q,onChange:z,api:_}){let W=(K,A)=>z({...q,[K]:A});return MZ.jsxDEV("div",{className:"flex flex-col gap-4",children:Q.map((K)=>MZ.jsxDEV(Ev,{def:K,value:q[K.name],onChange:(A)=>W(K.name,A),api:_},K.name,!1,void 0,this))},void 0,!1,void 0,this)}function Ev({def:Q,value:q,onChange:z,api:_}){let W=MZ.jsxDEV(MZ.Fragment,{children:[Q.label??Q.name," ",Q.required?MZ.jsxDEV("span",{className:"text-danger",children:"*"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);switch(Q.type){case"text":case"url":return MZ.jsxDEV(xY,{label:W,value:q??"",onChange:z,placeholder:Q.type==="url"?"https://…":""},void 0,!1,void 0,this);case"textarea":return MZ.jsxDEV(ZF,{label:W,value:typeof q==="string"?q:q==null?"":JSON.stringify(q),onChange:z},void 0,!1,void 0,this);case"richtext":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(yv,{value:typeof q==="string"?q:"",onChange:z},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"number":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("input",{className:l5,type:"number",value:q==null?"":String(q),onChange:(K)=>z(K.target.value===""?null:Number(K.target.value))},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"date":case"datetime":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("input",{className:l5,type:Q.type==="date"?"date":"datetime-local",value:q??"",onChange:(K)=>z(K.target.value||null)},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"boolean":return MZ.jsxDEV("label",{className:"flex items-center gap-2",children:[MZ.jsxDEV("input",{type:"checkbox",checked:Boolean(q),onChange:(K)=>z(K.target.checked)},void 0,!1,void 0,this),MZ.jsxDEV("span",{className:"text-sm text-fg",children:Q.label??Q.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this);case"select":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(hv,{def:Q,value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"media":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(bv,{value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"group":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:MZ.jsxDEV(QF,{schema:Q.fields??[],value:q??{},onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"repeater":return MZ.jsxDEV(vv,{def:Q,value:q??[],onChange:z,api:_,label:W},void 0,!1,void 0,this);default:return null}}function xv(Q){let q=Q.trim();return/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(q)?q:null}function BP(Q){return Q.replace(/<\s*(script|style)[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/(href|src)\s*=\s*("javascript:[^"]*"|'javascript:[^']*')/gi,'$1="#"')}function yv({value:Q,onChange:q}){let z=oY.useRef(null),_=oY.useRef("");oY.useEffect(()=>{let L=z.current;if(L&&Q!==_.current)L.innerHTML=BP(Q||""),_.current=Q||""},[Q]);let W=()=>{let L=BP(z.current?.innerHTML??"");_.current=L,q(L)},K=(L,O)=>{z.current?.focus(),document.execCommand(L,!1,O),W()},A=(L)=>{L.preventDefault(),document.execCommand("insertText",!1,L.clipboardData.getData("text/plain"))};return MZ.jsxDEV("div",{className:"overflow-hidden rounded-lg border border-border bg-surface-card",children:[MZ.jsxDEV("div",{className:"flex flex-wrap gap-0.5 border-b border-border bg-surface-muted px-2 py-1.5",children:kv.map((L)=>MZ.jsxDEV("button",{type:"button",className:"rounded border-0 bg-transparent px-2.5 py-0.5 text-xs text-fg-muted hover:bg-surface-card hover:text-fg",title:L.title,onMouseDown:(O)=>O.preventDefault(),onClick:()=>L.run(K),children:L.label},L.label,!1,void 0,this))},void 0,!1,void 0,this),MZ.jsxDEV("div",{ref:z,className:"prose prose-sm min-h-[180px] max-w-none px-4 py-3.5 text-sm leading-relaxed text-fg outline-none empty:before:text-fg-subtle empty:before:content-[attr(data-placeholder)]",contentEditable:!0,suppressContentEditableWarning:!0,"data-placeholder":"Write…",onInput:W,onBlur:W,onPaste:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vv({def:Q,value:q,onChange:z,api:_,label:W}){let K=Array.isArray(q)?q:[],A=(N,M)=>z(K.map((R,j)=>j===N?M:R)),L=()=>z([...K,{}]),O=(N)=>z(K.filter((M,R)=>R!==N)),I=(N,M)=>{let R=N+M;if(R<0||R>=K.length)return;let j=K.slice();[j[N],j[R]]=[j[R],j[N]],z(j)};return MZ.jsxDEV("div",{className:"flex flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:W},void 0,!1,void 0,this),K.map((N,M)=>MZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:[MZ.jsxDEV("div",{className:"mb-2 flex justify-end gap-1",children:[MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>I(M,-1),children:"↑"},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>I(M,1),children:"↓"},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>O(M),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),MZ.jsxDEV(QF,{schema:Q.fields??[],value:N,onChange:(R)=>A(M,R),api:_},void 0,!1,void 0,this)]},M,!0,void 0,this)),MZ.jsxDEV(yZ,{variant:"secondary",size:"sm",className:"self-start",onPress:L,isDisabled:Q.max!=null&&K.length>=Q.max,children:["+ add ",Q.label??Q.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function hv({def:Q,value:q,onChange:z,api:_}){let[W,K]=oY.useState(null),A=Q.optionsFrom;oY.useEffect(()=>{if(!A)return;let I=!0;return _.call(A).then((N)=>{if(I)K(Array.isArray(N)?N:[])}).catch(()=>{if(I)K([])}),()=>{I=!1}},[A,_]);let L=Boolean(A)&&W===null,O=A?W??[]:(Q.options??[]).map((I)=>({value:I,label:I}));return MZ.jsxDEV("select",{className:l5,value:q??"",onChange:(I)=>z(I.target.value||null),children:[MZ.jsxDEV("option",{value:"",children:L?"Načítám…":"—"},void 0,!1,void 0,this),O.map((I)=>MZ.jsxDEV("option",{value:I.value,children:I.label},I.value,!1,void 0,this))]},void 0,!0,void 0,this)}function bv({value:Q,onChange:q,api:z}){let[_,W]=oY.useState(!1),[K,A]=oY.useState(null);return oY.useEffect(()=>{if(Q)z.call("getMedia",{id:Q}).then(A).catch(()=>A(null));else A(null)},[Q,z]),MZ.jsxDEV("div",{children:[MZ.jsxDEV("div",{className:"flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",children:[K?MZ.jsxDEV("img",{className:"h-10 w-10 rounded object-cover",src:z.resolve(`/media/${K.file.key}`),alt:""},void 0,!1,void 0,this):MZ.jsxDEV("span",{className:"text-fg-subtle",children:"no media"},void 0,!1,void 0,this),MZ.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:K?.file.filename??Q??""},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"pick"},void 0,!1,void 0,this),Q?MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>q(null),children:"clear"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),_?MZ.jsxDEV(gv,{api:z,onClose:()=>W(!1),onPick:(L)=>{q(L),W(!1)}},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function gv({api:Q,onClose:q,onPick:z}){let[_,W]=oY.useState([]),[K,A]=oY.useState(!1),[L,O]=oY.useState(""),I=()=>Q.listMedia().then(W).catch((M)=>O(String(M.message??M)));oY.useEffect(()=>{I()},[]);let N=async(M)=>{A(!0),O("");try{let R=await Q.uploadMedia(M);z(R.id)}catch(R){O(String(R.message??R))}finally{A(!1)}};return MZ.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(20,15,5,0.28)] p-6",onClick:q,children:MZ.jsxDEV("div",{className:"max-h-[86vh] w-full max-w-[680px] overflow-auto rounded-panel border border-border bg-surface-card px-9 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.12)]",onClick:(M)=>M.stopPropagation(),children:[MZ.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal text-fg",children:["Choose ",MZ.jsxDEV("span",{className:"text-fg-subtle",children:"a file"},void 0,!1,void 0,this)," from the library"]},void 0,!0,void 0,this),L?MZ.jsxDEV("div",{className:"my-2 rounded-lg border border-danger bg-surface-card px-3.5 py-2.5 text-[13px] text-danger",children:L},void 0,!1,void 0,this):null,MZ.jsxDEV("label",{className:"mb-4 flex w-full flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Upload a new file"},void 0,!1,void 0,this),MZ.jsxDEV("input",{type:"file",className:"text-sm text-fg-muted",disabled:K,onChange:(M)=>M.target.files?.[0]&&N(M.target.files[0])},void 0,!1,void 0,this)]},void 0,!0,void 0,this),MZ.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:_.map((M)=>MZ.jsxDEV("div",{className:"cursor-pointer overflow-hidden rounded-lg border border-border bg-surface-card",onClick:()=>z(M.id),children:[(M.file.contentType??"").startsWith("image/")?MZ.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:Q.resolve(`/media/${M.file.key}`),alt:""},void 0,!1,void 0,this):MZ.jsxDEV("div",{className:"h-[130px] bg-surface-muted"},void 0,!1,void 0,this),MZ.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:M.file.filename??M.id},void 0,!1,void 0,this)]},M.id,!0,void 0,this))},void 0,!1,void 0,this),MZ.jsxDEV("div",{className:"mt-3 text-right",children:MZ.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"close"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var oY,MZ,l5="h-10 w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none transition-colors placeholder:text-fg-muted focus:border-brand-green",kv;var LP=C(()=>{WH();oY=f(ZZ(),1),MZ=f($Z(),1);kv=[{label:"B",title:"Bold",run:(Q)=>Q("bold")},{label:"I",title:"Italic",run:(Q)=>Q("italic")},{label:"H2",title:"Heading",run:(Q)=>Q("formatBlock","H2")},{label:"H3",title:"Subheading",run:(Q)=>Q("formatBlock","H3")},{label:"¶",title:"Paragraph",run:(Q)=>Q("formatBlock","P")},{label:"• List",title:"Bulleted list",run:(Q)=>Q("insertUnorderedList")},{label:"1. List",title:"Numbered list",run:(Q)=>Q("insertOrderedList")},{label:"Link",title:"Add link",run:(Q)=>{let q=window.prompt("Link URL (https://, mailto:, /path)","https://");if(!q)return;let z=xv(q);if(!z){window.alert("Only http(s), mailto, tel, or relative (/, #) links are allowed.");return}Q("createLink",z)}},{label:"Unlink",title:"Remove link",run:(Q)=>Q("unlink")},{label:"Clear",title:"Clear formatting",run:(Q)=>Q("removeFormat")}]});function GF({lead:Q,em:q,children:z}){return P.jsxDEV("div",{className:"mx-auto grid max-w-[1200px] grid-cols-[1fr_auto] items-center gap-6 px-7 pb-6 pt-8 max-[820px]:grid-cols-1",children:[P.jsxDEV("h1",{className:"m-0 text-[56px] font-normal leading-[1.05] tracking-[-0.01em] max-[820px]:text-[40px]",children:[P.jsxDEV("span",{className:"block text-fg-subtle",children:Q},void 0,!1,void 0,this),P.jsxDEV("span",{className:"block text-fg",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z]},void 0,!0,void 0,this)}function n5({text:Q,em:q,children:z}){return P.jsxDEV("div",{className:"flex min-w-[360px] items-center gap-4 rounded-full bg-brand-green py-3 pl-7 pr-3 max-[820px]:min-w-0",children:[P.jsxDEV("span",{className:"text-lg text-[#0f3a25]",children:[Q," ",P.jsxDEV("span",{className:"font-semibold",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z]},void 0,!0,void 0,this)}function KH({children:Q}){return P.jsxDEV("div",{className:"mb-2 mt-[18px] text-sm text-fg-subtle first:mt-0",children:Q},void 0,!1,void 0,this)}function hz({status:Q,children:q}){return P.jsxDEV("span",{className:`inline-block whitespace-nowrap rounded-full border px-2.5 py-0.5 text-[11px] font-medium ${Q==="published"||Q==="active"?"bg-brand-green text-[#0f3a25] border-transparent":Q==="in_review"||Q==="review"?"bg-accent-yellow text-[#4a3512] border-transparent":Q==="rejected"||Q==="archived"||Q==="inactive"?"border-danger text-danger bg-surface-card":"border-border text-fg-muted bg-surface-card"}`,children:q},void 0,!1,void 0,this)}function s5({onClose:Q,wide:q,children:z}){return P.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(20,15,5,0.28)] p-6",onClick:Q,children:P.jsxDEV("div",{className:`max-h-[86vh] w-full overflow-auto rounded-panel border border-border bg-surface-card px-9 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.12)] ${q?"max-w-[680px]":"max-w-[520px]"}`,onClick:(_)=>_.stopPropagation(),children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function a5({children:Q}){return P.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal leading-[1.15] text-fg",children:Q},void 0,!1,void 0,this)}function HF({children:Q,className:q}){return P.jsxDEV("div",{className:`grid grid-cols-[auto_1fr] gap-x-3.5 gap-y-2 text-[13px] text-fg-muted [&>span:nth-child(odd)]:text-fg-subtle ${q??""}`,children:Q},void 0,!1,void 0,this)}function FP({children:Q}){return P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-6",children:Q},void 0,!1,void 0,this)}function o5({ok:Q,children:q}){return P.jsxDEV("div",{className:`my-2 rounded-lg border px-3.5 py-2.5 text-[13px] ${Q?"border-brand-green bg-brand-green/20 text-[#0f3a25]":"border-danger bg-surface-card text-danger"}`,children:q},void 0,!1,void 0,this)}function MP({api:Q,pages:q,blockTypes:z,onOpen:_,onCreated:W,onError:K}){let[A,L]=NZ.useState(!1);return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Pages",em:q.length===0?"None yet":q.length===1?"1 page total":`${q.length} pages total`,children:P.jsxDEV(n5,{text:"Let's",em:"create something",children:P.jsxDEV(yZ,{className:"shrink-0",onPress:()=>L(!0),children:"+ New page"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[q.map((O)=>P.jsxDEV("div",{className:`${xW} cursor-pointer hover:bg-surface-muted`,onClick:()=>_(O),children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:O.title},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",O.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:O.locale},void 0,!1,void 0,this),P.jsxDEV(hz,{status:O.status,children:O.status},void 0,!1,void 0,this)]},O.id,!0,void 0,this)),q.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:["No pages yet. ",z.length===0?"Define block types + a content type first (via the API/admin).":"Create one."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this),A?P.jsxDEV(mv,{api:Q,onClose:()=>L(!1),onCreated:()=>{L(!1),W()},onError:K},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function mv({api:Q,onClose:q,onCreated:z,onError:_}){let[W,K]=NZ.useState([]),[A,L]=NZ.useState(""),[O,I]=NZ.useState(""),[N,M]=NZ.useState("");NZ.useEffect(()=>{Q.listContentTypes().then((j)=>{if(K(j),j[0])L(j[0].id)}).catch((j)=>_(IX(j)))},[Q,_]);let R=async()=>{try{await Q.call("createPage",{typeId:A,title:O,slug:N||OP(O)}),z()}catch(j){_(IX(j))}};return P.jsxDEV(s5,{onClose:q,children:[P.jsxDEV(a5,{children:["Create a ",P.jsxDEV(JF,{children:"new page"},void 0,!1,void 0,this)," and define the essentials",P.jsxDEV(JF,{children:"."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV("label",{className:"flex w-full flex-col gap-2",children:[P.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Content type"},void 0,!1,void 0,this),P.jsxDEV("select",{className:"h-10 w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none focus:border-brand-green",value:A,onChange:(j)=>L(j.target.value),children:W.map((j)=>P.jsxDEV("option",{value:j.id,children:j.name},j.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV(xY,{label:"Title",value:O,onChange:I},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Slug",value:N,onChange:M,placeholder:OP(O)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex justify-end gap-2",children:[P.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"cancel"},void 0,!1,void 0,this),P.jsxDEV(yZ,{onPress:R,isDisabled:!A||!O,children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function NP({api:Q,page:q,blockTypes:z,tab:_,onTab:W,onBack:K,onChange:A}){let[L,O]=NZ.useState(null),[I,N]=NZ.useState(null),[M,R]=NZ.useState(""),j=NZ.useRef(new Set),[h,d]=NZ.useState(0),b=NZ.useCallback((E,g)=>{let e=j.current;if(g?e.has(E):!e.has(E))return;if(g)e.add(E);else e.delete(E);d(e.size)},[]),a=()=>j.current.size===0||window.confirm(`You have unsaved changes in ${j.current.size} block${j.current.size===1?"":"s"}. Leave without saving?`),t=NZ.useMemo(()=>new Map(z.map((E)=>[E.slug,E])),[z]),qZ=NZ.useCallback(async()=>{try{let[E,g]=await Promise.all([Q.getContentType(q.typeId),Q.getPagePreview(q.slug,q.locale)]);O(E??null),N(g)}catch(E){R(IX(E))}},[Q,q.typeId,q.slug,q.locale]);NZ.useEffect(()=>{qZ()},[qZ]),NZ.useEffect(()=>{if(h===0)return;let E=(g)=>{g.preventDefault(),g.returnValue=""};return window.addEventListener("beforeunload",E),()=>window.removeEventListener("beforeunload",E)},[h]);let QZ=L?.regions??[],LZ=(E,g)=>N((e)=>e?{...e,regions:{...e.regions,[E]:g(e.regions[E]??[])}}:e),kZ=async(E,g)=>{let e=`tmp:${crypto.randomUUID()}`;LZ(E,(p)=>[...p,{id:e,block_id:e,block_type:g,title:null,fields:{},is_shared:!1,pending:!0}]);try{let{block:p,placement:w}=await Q.call("addBlock",{pageId:q.id,blockTypeSlug:g,region:E,fields:{}}),o={id:String(w.id),block_id:String(p.id),block_type:g,title:p.title??null,fields:p.fields??{},is_shared:Boolean(w.isShared)};LZ(E,(AZ)=>AZ.map((VZ)=>VZ.id===e?o:VZ))}catch(p){LZ(E,(w)=>w.filter((o)=>o.id!==e)),R(IX(p))}},JZ=async(E)=>{try{await Q.call("removeBlock",{pageBlockId:E.id}),await qZ()}catch(g){R(IX(g))}},l=async(E,g)=>{try{await Q.call("reorderRegion",{pageId:q.id,region:E,order:g}),await qZ()}catch(e){R(IX(e))}},OZ=NZ.useCallback((E,g)=>{N((e)=>{if(!e)return e;let p={};for(let[w,o]of Object.entries(e.regions))p[w]=o.map((AZ)=>AZ.id===E?{...AZ,fields:g}:AZ);return{...e,regions:p}})},[]),[n,wZ]=NZ.useState(null),WZ=(E,g)=>wZ({region:E,from:g,over:g}),HZ=(E,g)=>wZ((e)=>e&&e.region===E&&e.over!==g?{...e,over:g}:e),v=()=>wZ(null),m=(E)=>{if(wZ(null),!n||n.region!==E||n.from===n.over)return;let g=(I?.regions[E]??[]).map((p)=>p.id),[e]=g.splice(n.from,1);g.splice(n.over,0,e),l(E,g)};return P.jsxDEV("div",{className:"grid min-h-[calc(100vh-68px)] grid-cols-[260px_1fr_400px] gap-5 px-7 pb-7 pt-2 max-[820px]:grid-cols-1",children:[P.jsxDEV("div",{className:"overflow-auto rounded-panel bg-surface-muted p-[18px]",children:[P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>{if(a())K()},children:"← all pages"},void 0,!1,void 0,this),h>0?P.jsxDEV("p",{className:"mt-2 text-[11px] text-accent-strong",children:["● ",h," unsaved block",h===1?"":"s"]},void 0,!0,void 0,this):null,P.jsxDEV(KH,{children:"Regions"},void 0,!1,void 0,this),QZ.map((E)=>P.jsxDEV("div",{className:`${xW} mb-2`,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:E.label??E.name},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:(I?.regions[E.name]??[]).length},void 0,!1,void 0,this)]},E.name,!0,void 0,this)),P.jsxDEV(KH,{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:q.title},void 0,!1,void 0,this),P.jsxDEV(hz,{status:q.status,children:q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"overflow-auto py-1.5",children:[M?P.jsxDEV(o5,{children:M},void 0,!1,void 0,this):null,QZ.map((E)=>{let g=I?.regions[E.name]??[],e=E.allowedTypes&&E.allowedTypes.length?E.allowedTypes:z.map((p)=>p.slug);return P.jsxDEV("div",{className:"mb-8",children:[P.jsxDEV("h3",{className:"m-0 mb-3 text-[22px] font-normal text-fg",children:E.label??E.name},void 0,!1,void 0,this),g.length===0?P.jsxDEV("p",{className:"mb-3 text-sm text-fg-subtle",children:"No blocks yet — add one below."},void 0,!1,void 0,this):null,g.map((p,w)=>P.jsxDEV(fv,{api:Q,block:p,blockType:t.get(p.block_type),isFirst:w===0,isLast:w===g.length-1,onMove:(o)=>Yh(g,E.name,w,o,l),onRemove:()=>JZ(p),onPatch:OZ,onDirtyChange:b,onError:R,dragging:n?.region===E.name&&n.from===w,isOver:!!n&&n.region===E.name&&n.over===w&&n.from!==w,onDragStartBlock:()=>WZ(E.name,w),onDragOverBlock:()=>HZ(E.name,w),onDropBlock:()=>m(E.name),onDragEndBlock:v},p.id,!1,void 0,this)),P.jsxDEV(uv,{allowed:e,btBySlug:t,onAdd:(p)=>kZ(E.name,p)},void 0,!1,void 0,this)]},E.name,!0,void 0,this)}),QZ.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"This page's content type has no regions."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-5",children:[P.jsxDEV("div",{className:"mb-3 flex gap-1",children:i5.map((E)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:_===E?"bg-surface-muted text-fg":"text-fg-muted",onPress:()=>W(E),children:E},E,!1,void 0,this))},void 0,!1,void 0,this),_==="settings"?P.jsxDEV(dv,{page:q},void 0,!1,void 0,this):null,_==="seo"?P.jsxDEV(cv,{api:Q,page:q,onError:R},void 0,!1,void 0,this):null,_==="workflow"?P.jsxDEV(pv,{api:Q,page:q,onChanged:(E)=>{A(E)},onError:R},void 0,!1,void 0,this):null,_==="i18n"?P.jsxDEV(lv,{api:Q,page:q,onError:R},void 0,!1,void 0,this):null,_==="audit"?P.jsxDEV(iv,{api:Q,pageId:q.id,onError:R},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function fv({api:Q,block:q,blockType:z,isFirst:_,isLast:W,onMove:K,onRemove:A,onPatch:L,onDirtyChange:O,onError:I,dragging:N,isOver:M,onDragStartBlock:R,onDragOverBlock:j,onDropBlock:h,onDragEndBlock:d}){let[b,a]=NZ.useState(null),[t,qZ]=NZ.useState(!1),[QZ,LZ]=NZ.useState("idle"),kZ=NZ.useRef(""),JZ=NZ.useRef(null),l=q.block_id,OZ=q.id;NZ.useEffect(()=>{if(q.pending){a({}),kZ.current="{}";return}let m=!0;return Q.call("getBlock",{blockId:l}).then((E)=>{if(!m)return;let g=E?.fields??{};a(g),kZ.current=JSON.stringify(g)}).catch((E)=>I(IX(E))),()=>{m=!1}},[Q,l,I,q.pending]);let n=b!=null&&JSON.stringify(b)!==kZ.current,wZ=NZ.useCallback(async()=>{if(q.pending||b==null)return;let m=JSON.stringify(b);if(m===kZ.current)return;LZ("saving");try{await Q.call("updateBlock",{blockId:l,fields:b}),kZ.current=m,L(OZ,b),LZ("saved"),setTimeout(()=>LZ((E)=>E==="saved"?"idle":E),1500)}catch(E){I(IX(E)),LZ("idle")}},[Q,l,OZ,b,L,I,q.pending]),WZ=(m)=>a(m);NZ.useEffect(()=>{O(OZ,n)},[n,OZ,O]),NZ.useEffect(()=>()=>{O(OZ,!1)},[OZ,O]);let HZ=z?.fieldsSchema??[],v=z?.name??q.block_type;return P.jsxDEV("div",{ref:JZ,className:`mb-2.5 rounded-panel border bg-surface-card transition-colors ${M?"border-brand-green":"border-border"} ${N?"opacity-40":""} ${q.pending?"pointer-events-none opacity-60":""}`,onDragOver:(m)=>{m.preventDefault(),j()},onDrop:(m)=>{m.preventDefault(),h()},children:[P.jsxDEV("div",{className:"flex items-center gap-2.5 px-3.5 py-2.5",children:[P.jsxDEV("span",{draggable:!0,onDragStart:(m)=>{if(JZ.current)m.dataTransfer.setDragImage(JZ.current,12,12);m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",""),R()},onDragEnd:d,className:"shrink-0 cursor-grab select-none px-0.5 text-fg-subtle hover:text-fg active:cursor-grabbing",title:"Drag to reorder",children:"⠿"},void 0,!1,void 0,this),P.jsxDEV("button",{type:"button",className:"w-4 shrink-0 text-fg-subtle hover:text-fg",title:t?"Expand":"Collapse",onClick:()=>qZ((m)=>!m),children:t?"▸":"▾"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"font-medium text-fg",children:v},void 0,!1,void 0,this),q.is_shared?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"shared"},void 0,!1,void 0,this):null,P.jsxDEV("span",{className:`text-[11px] ${n&&QZ!=="saving"?"text-accent-strong":"text-fg-subtle"}`,children:QZ==="saving"?"saving…":QZ==="saved"?"saved ✓":n?"● unsaved":""},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:_,onPress:()=>K(-1),children:"↑"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:W,onPress:()=>K(1),children:"↓"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:A,children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t?P.jsxDEV("div",{className:"cursor-pointer truncate px-3.5 pb-3 text-sm text-fg-subtle",onClick:()=>qZ(!1),children:b==null?"…":Xh(b)||P.jsxDEV("span",{className:"italic",children:"empty"},void 0,!1,void 0,this)},void 0,!1,void 0,this):P.jsxDEV("div",{className:"border-t border-border px-3.5 py-3.5",children:b==null?P.jsxDEV("p",{className:"text-sm text-fg-subtle",children:"loading…"},void 0,!1,void 0,this):HZ.length===0?P.jsxDEV("p",{className:"text-sm text-fg-subtle",children:"This block has no editable fields."},void 0,!1,void 0,this):P.jsxDEV(P.Fragment,{children:[P.jsxDEV(QF,{schema:HZ,value:b,onChange:WZ,api:Q},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-3.5 flex items-center gap-2 border-t border-border pt-3",children:[P.jsxDEV(yZ,{size:"sm",onPress:()=>void wZ(),isDisabled:!n||QZ==="saving"||q.pending,children:QZ==="saving"?"Saving…":"Save"},void 0,!1,void 0,this),n?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"Unsaved changes"},void 0,!1,void 0,this):QZ==="saved"?P.jsxDEV("span",{className:"text-[11px] text-fg-subtle",children:"Saved ✓"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function uv({allowed:Q,btBySlug:q,onAdd:z}){let[_,W]=NZ.useState(!1);if(!_)return P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"+ Add block"},void 0,!1,void 0,this);return P.jsxDEV("div",{className:"rounded-panel border border-border bg-surface-card p-2.5",children:[P.jsxDEV("div",{className:"mb-1.5 px-1 text-[11px] text-fg-subtle",children:"Add a block"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:Q.map((K)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>{z(K),W(!1)},children:q.get(K)?.name??K},K,!1,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-1.5 text-right",children:P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-fg-subtle",onPress:()=>W(!1),children:"cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function dv({page:Q}){return P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Title"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.title},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Slug"},void 0,!1,void 0,this),P.jsxDEV("span",{children:["/",Q.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{children:"Locale"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.locale},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function cv({api:Q,page:q,onError:z}){let[_,W]=NZ.useState({metaTitle:q.metaTitle??"",metaDescription:q.metaDescription??"",canonicalUrl:q.canonicalUrl??"",robots:q.robots??"",ogTitle:q.ogTitle??"",ogDescription:q.ogDescription??""}),[K,A]=NZ.useState(!1),L=async()=>{try{await Q.call("updatePageSeo",{pageId:q.id,..._}),A(!0),setTimeout(()=>A(!1),1500)}catch(I){z(IX(I))}},O=(I,N,M=!1)=>M?P.jsxDEV(ZF,{label:N,value:_[I],onChange:(R)=>W({..._,[I]:R})},void 0,!1,void 0,this):P.jsxDEV(xY,{label:N,value:_[I],onChange:(R)=>W({..._,[I]:R})},void 0,!1,void 0,this);return P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(KH,{children:"SEO"},void 0,!1,void 0,this),K?P.jsxDEV(o5,{ok:!0,children:"saved"},void 0,!1,void 0,this):null,O("metaTitle","Meta title"),O("metaDescription","Meta description",!0),O("canonicalUrl","Canonical URL"),O("robots","Robots (e.g. noindex)"),O("ogTitle","OG title"),O("ogDescription","OG description",!0),P.jsxDEV(yZ,{className:"w-full",onPress:L,children:"Save SEO"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function pv({api:Q,page:q,onChanged:z,onError:_}){let W=async(L,O)=>{try{let I=await Q.call(L,{pageId:q.id,...O});if(I?.page)z(I.page)}catch(I){_(IX(I))}},K=String(q.status),A=K==="review"?[{label:"Approve (publish)",action:"approve"},{label:"Reject",action:"reject",variant:"secondary"},{label:"Publish directly",action:"publishPage",variant:"secondary"}]:K==="published"?[{label:"Unpublish",action:"unpublishPage",variant:"secondary"}]:[{label:"Publish",action:"publishPage"},{label:"Submit for review",action:"submitForReview",variant:"secondary"}];return P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Workflow"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-3 flex items-center gap-2 text-[13px] text-fg-muted",children:[P.jsxDEV("span",{className:"text-fg-subtle",children:"Status"},void 0,!1,void 0,this),P.jsxDEV(hz,{status:q.status,children:q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:A.map((L)=>P.jsxDEV(yZ,{variant:L.variant,onPress:()=>W(L.action),children:L.label},L.action,!1,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("p",{className:"mt-2.5 text-fg-subtle",children:"Publish needs a reviewer/admin role; submit-for-review is editor-gated."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lv({api:Q,page:q,onError:z}){let[_,W]=NZ.useState([]),[K,A]=NZ.useState(""),L=NZ.useCallback(()=>Q.call("listTranslations",{pageId:q.id}).then(W).catch((I)=>z(IX(I))),[Q,q.id,z]);NZ.useEffect(()=>{L()},[L]);let O=async()=>{try{await Q.call("createTranslation",{pageId:q.id,locale:K}),A(""),L()}catch(I){z(IX(I))}};return P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Translations"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:_.map((I)=>P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:I.locale},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",I.slug]},void 0,!0,void 0,this),P.jsxDEV(hz,{status:I.status,children:I.status},void 0,!1,void 0,this)]},I.id,!0,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex items-end gap-1.5",children:[P.jsxDEV(xY,{label:"",value:K,onChange:A,placeholder:"locale (e.g. cs)"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",onPress:O,isDisabled:!K,children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function iv({api:Q,pageId:q,onError:z}){let[_,W]=NZ.useState([]);return NZ.useEffect(()=>{Q.listPageAudit(q).then(W).catch((K)=>z(IX(K)))},[Q,q,z]),P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Audit trail"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((K)=>P.jsxDEV("div",{className:`${xW} text-xs`,children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:K.action},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:[K.fromStatus," → ",K.toStatus]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:K.actor??"system"},void 0,!1,void 0,this)]},K.id,!0,void 0,this)),_.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No history yet."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function IP({api:Q,onError:q}){let[z,_]=NZ.useState([]),[W,K]=NZ.useState(0),[A,L]=NZ.useState(!1),[O,I]=NZ.useState(null),[N,M]=NZ.useState(!1),R=NZ.useCallback((h)=>{Q.listMedia(AP,h).then((d)=>{_((b)=>h===0?d:[...b,...d]),L(d.length===AP),K(h+d.length)}).catch((d)=>q(IX(d)))},[Q,q]);NZ.useEffect(()=>{R(0)},[R]);let j=async(h)=>{if(!h?.length)return;M(!0),q("");try{for(let d of Array.from(h))await Q.uploadMedia(d);R(0)}catch(d){q(IX(d))}finally{M(!1)}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Media",em:z.length===0?"None yet":z.length===1?"1 file":`${z.length}${A?"+":""} files`,children:P.jsxDEV(n5,{text:"Let's",em:"upload something",children:P.jsxDEV("label",{className:`inline-flex shrink-0 cursor-pointer items-center rounded-full bg-surface-inverted px-6 py-3 text-compact text-fg-inverted ${N?"pointer-events-none opacity-50":""}`,children:[N?"Uploading…":"+ Upload",P.jsxDEV("input",{type:"file",multiple:!0,hidden:!0,disabled:N,onChange:(h)=>{j(h.target.files),h.target.value=""}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:[z.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No media yet. Upload images to use them in blocks and SEO."},void 0,!1,void 0,this):P.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:z.map((h)=>P.jsxDEV("div",{className:`cursor-pointer overflow-hidden rounded-lg border bg-surface-card ${O?.id===h.id?"border-fg":"border-border"}`,onClick:()=>I(h),children:[VP(h)?P.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:Q.resolve(`/media/${h.file.key}`),alt:h.alt??""},void 0,!1,void 0,this):P.jsxDEV("div",{className:"flex h-[130px] items-center justify-center bg-surface-muted font-mono text-xs text-fg-subtle",children:RP(h)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:h.file.filename??h.id},void 0,!1,void 0,this)]},h.id,!0,void 0,this))},void 0,!1,void 0,this),A?P.jsxDEV("div",{className:"mt-3.5 text-center",children:P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>R(W),children:"Load more"},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,O?P.jsxDEV(nv,{api:Q,media:O,onClose:()=>I(null),onSaved:(h)=>{I(h),_((d)=>d.map((b)=>b.id===h.id?h:b))},onDeleted:(h)=>{I(null),_((d)=>d.filter((b)=>b.id!==h))},onError:q},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function nv({api:Q,media:q,onClose:z,onSaved:_,onDeleted:W,onError:K}){let[A,L]=NZ.useState(q.alt??""),[O,I]=NZ.useState(!1);NZ.useEffect(()=>L(q.alt??""),[q]);let N=Q.resolve(`/media/${q.file.key}`),M=async()=>{I(!0);try{_(await Q.updateMedia(q.id,A||null))}catch(j){K(IX(j))}finally{I(!1)}},R=async()=>{if(!confirm("Delete this file permanently? If a block or page still references it, that image will break — this cannot be undone."))return;I(!0);try{await Q.deleteMedia(q.id),W(q.id)}catch(j){K(IX(j))}finally{I(!1)}};return P.jsxDEV(s5,{onClose:z,wide:!0,children:[P.jsxDEV(a5,{children:[P.jsxDEV(JF,{children:"Media"},void 0,!1,void 0,this)," ",q.file.filename??""]},void 0,!0,void 0,this),VP(q)?P.jsxDEV("img",{className:"mx-auto mb-3.5 block max-h-[340px] max-w-full rounded-lg bg-surface-muted object-contain",src:N,alt:q.alt??""},void 0,!1,void 0,this):P.jsxDEV("div",{className:"mb-3.5 flex h-[200px] items-center justify-center rounded-lg bg-surface-muted font-mono text-fg-subtle",children:RP(q)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-4",children:P.jsxDEV(xY,{label:"Alt text (for accessibility & SEO)",value:A,onChange:L,placeholder:"Describe the image…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Type"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q.file.contentType??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Size"},void 0,!1,void 0,this),P.jsxDEV("span",{children:ev(q.file.size)},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Uploaded"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q.file.uploadedAt?new Date(q.file.uploadedAt).toLocaleString():q.createdAt??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"URL"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"break-all",children:P.jsxDEV("a",{className:"underline underline-offset-2",href:N,target:"_blank",rel:"noreferrer",children:["/media/",q.file.key]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"mt-3.5 flex items-center gap-2",children:[P.jsxDEV(yZ,{onPress:M,isDisabled:O||A===(q.alt??""),children:"Save"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>navigator.clipboard?.writeText(N),children:"Copy URL"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",className:"text-danger",onPress:R,isDisabled:O,children:"Delete"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",onPress:z,children:"Close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function sv(Q){let q=Q.roles;if(Array.isArray(q))return q.filter((z)=>typeof z==="string");if(typeof q==="string")try{let z=JSON.parse(q);return Array.isArray(z)?z:[]}catch{return[]}return[]}function TP({api:Q,me:q,onError:z}){let[_,W]=NZ.useState([]),[K,A]=NZ.useState(!1),[L,O]=NZ.useState(""),I=NZ.useCallback(()=>{Q.call("listUsers",{limit:200}).then(W).catch((j)=>z(IX(j)))},[Q,z]);NZ.useEffect(()=>{I()},[I]);let N=async(j,h)=>{O(j.username);try{await Q.call("setUserRoles",{username:j.username,roles:h}),I()}catch(d){z(IX(d))}finally{O("")}},M=async(j,h)=>{O(j.username);try{await Q.call("setUserActive",{username:j.username,active:h}),I()}catch(d){z(IX(d))}finally{O("")}},R=async(j)=>{if(!confirm(`Delete user ${j.username}? This cannot be undone.`))return;O(j.username);try{await Q.call("deleteUser",{username:j.username}),I()}catch(h){z(IX(h))}finally{O("")}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Users",em:_.length===0?"None yet":_.length===1?"1 account":`${_.length} accounts`,children:P.jsxDEV(n5,{text:"Let's",em:"invite someone",children:P.jsxDEV(yZ,{className:"shrink-0",onPress:()=>A(!0),children:"+ Invite"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((j)=>{let h=sv(j),d=q?.userId===j.username,b=j.active===void 0||j.active===null?!0:Boolean(Number(j.active));return P.jsxDEV("div",{className:`${xW} flex-wrap items-start`,children:[P.jsxDEV("div",{className:"flex min-w-[200px] flex-1 flex-col gap-0.5",children:[P.jsxDEV("span",{className:"font-semibold",children:[j.username,d?P.jsxDEV("span",{className:"ml-1.5 font-normal text-fg-subtle",children:"(you)"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),j.email&&j.email!==j.username?P.jsxDEV("span",{className:"text-xs text-fg-subtle",children:j.email},void 0,!1,void 0,this):null,j.createdAt?P.jsxDEV("span",{className:"text-[11px] text-fg-subtle",children:["joined ",new Date(Number(j.createdAt)).toLocaleDateString()]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),P.jsxDEV(av,{value:h,disabled:L===j.username,onSave:(a)=>N(j,a)},void 0,!1,void 0,this),P.jsxDEV(hz,{status:b?"active":"inactive",children:b?"active":"inactive"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:L===j.username||d,onPress:()=>M(j,!b),children:b?"Deactivate":"Activate"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",isDisabled:L===j.username||d,onPress:()=>R(j),children:"Delete"},void 0,!1,void 0,this)]},j.username,!0,void 0,this)}),_.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No users yet. Invite someone to get started."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this),K?P.jsxDEV(ov,{api:Q,onClose:()=>A(!1),onInvited:()=>{A(!1),I()},onError:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function av({value:Q,disabled:q,onSave:z}){let[_,W]=NZ.useState(Q.join(", ")),[K,A]=NZ.useState(!1);NZ.useEffect(()=>{W(Q.join(", "))},[Q]);let L=()=>{A(!1);let O=_.split(",").map((I)=>I.trim()).filter(Boolean);if(O.length===0){W(Q.join(", "));return}if(O.length===Q.length&&O.every((I,N)=>I===Q[N]))return;z(O)};if(K)return P.jsxDEV("input",{autoFocus:!0,className:"h-10 w-[220px] rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none focus:border-brand-green",value:_,disabled:q,onChange:(O)=>W(O.target.value),onBlur:L,onKeyDown:(O)=>{if(O.key==="Enter")L();if(O.key==="Escape")W(Q.join(", ")),A(!1)}},void 0,!1,void 0,this);return P.jsxDEV("span",{className:"flex cursor-pointer flex-wrap gap-1",onClick:()=>A(!0),title:"Click to edit",children:Q.length===0?P.jsxDEV(hz,{children:"no roles"},void 0,!1,void 0,this):Q.map((O)=>P.jsxDEV(hz,{status:O==="admin"?"published":void 0,children:O},O,!1,void 0,this))},void 0,!1,void 0,this)}function ov({api:Q,onClose:q,onInvited:z,onError:_}){let[W,K]=NZ.useState(""),[A,L]=NZ.useState("editor"),[O,I]=NZ.useState(!1);return P.jsxDEV(s5,{onClose:q,children:[P.jsxDEV(a5,{children:["Invite an ",P.jsxDEV(JF,{children:"editor"},void 0,!1,void 0,this)," or teammate"]},void 0,!0,void 0,this),P.jsxDEV("p",{className:"-mt-2 mb-4 text-fg-subtle",children:"They'll get a one-time magic link that logs them in and creates their account."},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(xY,{label:"Email",type:"email",autoFocus:!0,value:W,onChange:K,placeholder:"them@example.com"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Roles (comma-separated — e.g. editor, reviewer, admin)",value:A,onChange:L,placeholder:"editor"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex justify-end gap-2",children:[P.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"Cancel"},void 0,!1,void 0,this),P.jsxDEV(yZ,{onPress:async()=>{I(!0);try{let M=A.split(",").map((R)=>R.trim()).filter(Boolean);await Q.call("inviteUser",{email:W,roles:M}),z()}catch(M){_(IX(M))}finally{I(!1)}},isDisabled:O||!W,children:O?"Sending…":"Send invite"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wP({api:Q,cfg:q,me:z,onSignOut:_,onError:W}){return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Settings",em:z?.userId??"your account"},void 0,!1,void 0,this),P.jsxDEV("div",{className:`${qF} grid grid-cols-2 gap-5 max-[820px]:grid-cols-1`,children:[P.jsxDEV(rv,{api:Q,me:z,onError:W,onSignOut:_},void 0,!1,void 0,this),P.jsxDEV(tv,{cfg:q,me:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function rv({api:Q,me:q,onError:z,onSignOut:_}){let[W,K]=NZ.useState(""),[A,L]=NZ.useState(""),[O,I]=NZ.useState(""),[N,M]=NZ.useState(""),[R,j]=NZ.useState(!1),h=(a)=>{M(a),setTimeout(()=>M(""),1800)},d=async()=>{j(!0);try{await Q.call("changeEmail",{email:W}),K(""),h("Contact email updated")}catch(a){z(IX(a))}finally{j(!1)}},b=async()=>{j(!0);try{await Q.call("changePassword",{currentPassword:A,newPassword:O}),L(""),I(""),h("Password updated")}catch(a){z(IX(a))}finally{j(!1)}};return P.jsxDEV(FP,{children:[P.jsxDEV(KH,{children:"My account"},void 0,!1,void 0,this),N?P.jsxDEV(o5,{ok:!0,children:N},void 0,!1,void 0,this):null,P.jsxDEV(HF,{className:"mb-4",children:[P.jsxDEV("span",{children:"Username"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q?.userId??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Roles"},void 0,!1,void 0,this),P.jsxDEV("span",{children:(q?.roles??[]).join(", ")||"—"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(xY,{label:"Change contact email",type:"email",value:W,onChange:K,placeholder:"you@example.com"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:d,isDisabled:R||!W,children:"Save email"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Current password",type:"password",value:A,onChange:L,autoComplete:"current-password"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"New password (at least 8 characters)",type:"password",value:O,onChange:I,autoComplete:"new-password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:b,isDisabled:R||O.length<8||A.length===0,children:"Change password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",className:"mt-2 w-full text-danger",onPress:_,children:"Sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function tv({cfg:Q,me:q}){return P.jsxDEV(FP,{children:[P.jsxDEV(KH,{children:"About"},void 0,!1,void 0,this),P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Tenant"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.tenant||"main"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"API"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"break-all",children:Q.baseUrl},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Signed in as"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q?.userId??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Editor"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"pramen · cms-editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function VP(Q){return(Q.file.contentType??"").startsWith("image/")}function RP(Q){let q=(Q.file.contentType??"").split("/")[1];return(Q.file.filename?.split(".").pop()??q??"file").slice(0,5).toUpperCase()}function ev(Q){if(!Q||Q<=0)return"—";let q=["B","KB","MB","GB"],z=0,_=Q;while(_>=1024&&z<q.length-1)_/=1024,z++;return`${_<10&&z>0?_.toFixed(1):Math.round(_)} ${q[z]}`}function IX(Q){if(Q instanceof EW)return Q.message;return Q instanceof Error?Q.message:String(Q)}function OP(Q){return Q.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Zh(Q){return Q.replace(/<[^>]*>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/\s+/g," ").trim()}function Xh(Q){let q=Object.values(Q).find((_)=>typeof _==="string"&&_.trim());if(typeof q!=="string")return"";let z=Zh(q);return z.length>90?z.slice(0,90)+"…":z}function Yh(Q,q,z,_,W){let K=z+_;if(K<0||K>=Q.length)return;let A=Q.map((L)=>L.id);[A[z],A[K]]=[A[K],A[z]],W(q,A)}var NZ,P,i5,xW="flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",qF="mx-auto max-w-[1200px] px-7 pb-8 pt-2",JF=({children:Q})=>P.jsxDEV("span",{className:"text-fg-subtle",children:Q},void 0,!1,void 0,this),AP=60;var yW=C(()=>{WH();d5();LP();NZ=f(ZZ(),1),P=f($Z(),1),i5=["settings","seo","workflow","i18n","audit"]});var jP={};p_(jP,{default:()=>Qh});var qB,CP,Qh;var PP=C(()=>{Hq();UH();yW();qB=f(ZZ(),1),CP=f($Z(),1),Qh=kQ().route("/").render(function(){let{api:q,setError:z}=_J(),_=XJ(),[W,K]=qB.useState([]),[A,L]=qB.useState([]),O=()=>q.listPages().then(K).catch((I)=>z(IX(I)));return qB.useEffect(()=>{O(),q.listBlockTypes().then(L).catch((I)=>z(IX(I)))},[q]),CP.jsxDEV(MP,{api:q,pages:W,blockTypes:A,onOpen:(I)=>_("page",{params:{pageId:I.id}}),onCreated:O,onError:z},void 0,!1,void 0,this)})});var DP={};p_(DP,{default:()=>Jh});var $P,Jh;var SP=C(()=>{Hq();UH();yW();$P=f($Z(),1),Jh=kQ().route("/media").render(function(){let{api:q,setError:z}=_J();return $P.jsxDEV(IP,{api:q,onError:z},void 0,!1,void 0,this)})});var EP={};p_(EP,{default:()=>qh});var vW,bz,qh;var kP=C(()=>{Hq();WH();UH();yW();vW=f(ZZ(),1),bz=f($Z(),1),qh=kQ().params({pageId:"string",tab:"?string"}).route("/pages/:pageId").render(function({params:q}){let{api:z,setError:_}=_J(),W=XJ(),[K,A]=vW.useState(null),[L,O]=vW.useState([]),[I,N]=vW.useState(!1);vW.useEffect(()=>{let j=!0;return N(!1),z.listPages().then((h)=>{if(!j)return;let d=h.find((b)=>b.id===q.pageId)??null;A(d),N(!d)}).catch((h)=>_(IX(h))),z.listBlockTypes().then((h)=>j&&O(h)).catch((h)=>_(IX(h))),()=>{j=!1}},[z,q.pageId,_]);let M=i5.includes(q.tab)?q.tab:"settings",R=(j)=>W("page",{params:{pageId:q.pageId,tab:j},replace:!0});if(I)return bz.jsxDEV("div",{className:"mx-auto flex max-w-[1200px] items-center gap-2 px-7 pt-8",children:[bz.jsxDEV("p",{className:"text-fg-subtle",children:"Page not found."},void 0,!1,void 0,this),bz.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>W("home"),children:"← all pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(!K)return bz.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:bz.jsxDEV("p",{className:"text-fg-subtle",children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return bz.jsxDEV(NP,{api:z,page:K,blockTypes:L,tab:M,onTab:R,onBack:()=>W("home"),onChange:A},void 0,!1,void 0,this)})});var xP={};p_(xP,{default:()=>Gh});var yP,Gh;var vP=C(()=>{Hq();UH();yW();yP=f($Z(),1),Gh=kQ().route("/settings").render(function(){let{api:q,cfg:z,me:_,setError:W,reconfigure:K}=_J();return yP.jsxDEV(wP,{api:q,cfg:z,me:_,onSignOut:K,onError:W},void 0,!1,void 0,this)})});var hP={};p_(hP,{default:()=>Hh});var gz,Hh;var bP=C(()=>{Hq();WH();UH();yW();gz=f($Z(),1),Hh=kQ().route("/users").render(function(){let{api:q,me:z,isAdmin:_,setError:W}=_J(),K=XJ();if(z===null)return gz.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:gz.jsxDEV("p",{className:"text-fg-subtle",children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!_)return gz.jsxDEV("div",{className:"mx-auto flex max-w-[1200px] items-center gap-2 px-7 pt-8",children:[gz.jsxDEV("p",{className:"text-fg-subtle",children:"Admins only."},void 0,!1,void 0,this),gz.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>K("home"),children:"← back to pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return gz.jsxDEV(TP,{api:q,me:z,onError:W},void 0,!1,void 0,this)})});var gP={};p_(gP,{default:()=>zh});var BH,zh;var mP=C(()=>{Hq();WH();BH=f($Z(),1),zh=kQ().render(function(){let q=XJ();return BH.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:[BH.jsxDEV("h1",{className:"m-0 text-[56px] font-normal leading-[1.05] tracking-[-0.01em] max-[820px]:text-[40px]",children:[BH.jsxDEV("span",{className:"block text-fg-subtle",children:"Not found"},void 0,!1,void 0,this),BH.jsxDEV("span",{className:"block text-fg",children:"Nothing lives here"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BH.jsxDEV("div",{className:"mt-4 flex items-center gap-2",children:[BH.jsxDEV("p",{className:"text-fg-subtle",children:"That page doesn't exist."},void 0,!1,void 0,this),BH.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>q("home"),children:"← back to pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})});Hq();var nP=f(ZZ(),1),sP=f(Z2(),1);Hq();var mz=f(ZZ(),1);Hq();WH();UH();var TY=f($Z(),1);function p5(){let{cfg:Q,isAdmin:q,error:z,reconfigure:_}=_J(),W=XJ(),{pathname:K}=SA(),A=K.startsWith("/pages")||K==="/"?"pages":K.startsWith("/media")?"media":K.startsWith("/users")?"users":K.startsWith("/settings")?"settings":"",L=(I)=>A===I?"bg-surface-muted text-fg":"text-fg-muted",O=typeof window<"u"?window.PRAMEN_CMS_EDITOR?.extraNav??[]:[];return TY.jsxDEV(TY.Fragment,{children:[TY.jsxDEV("div",{className:"sticky top-0 z-10 flex items-center gap-4 bg-surface px-7 py-4",children:[TY.jsxDEV("span",{className:"text-[15px] font-bold tracking-[0.01em] text-fg",children:["pramen ",TY.jsxDEV("span",{className:"font-normal text-fg-subtle",children:"· cms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TY.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),TY.jsxDEV("nav",{className:"flex items-center gap-0.5",children:[TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("pages"),onPress:()=>W("home"),children:"Pages"},void 0,!1,void 0,this),TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("media"),onPress:()=>W("media"),children:"Media"},void 0,!1,void 0,this),q?TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("users"),onPress:()=>W("users"),children:"Users"},void 0,!1,void 0,this):null,TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("settings"),onPress:()=>W("settings"),children:"Settings"},void 0,!1,void 0,this),O.map((I)=>TY.jsxDEV("a",{href:I.href,target:"_blank",rel:"noopener noreferrer",className:"rounded-md px-2.5 py-1.5 text-sm text-fg-muted transition-colors hover:bg-surface-muted hover:text-fg",children:I.label},I.href,!1,void 0,this))]},void 0,!0,void 0,this),TY.jsxDEV("span",{className:"ml-3 text-fg-subtle",children:Q.tenant},void 0,!1,void 0,this),TY.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:_,children:"sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z?TY.jsxDEV("div",{className:"mx-7 mt-2 rounded-lg border border-danger bg-surface-card px-4 py-2.5 text-sm text-danger",children:z},void 0,!1,void 0,this):null,TY.jsxDEV(a_,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fP=()=>Promise.resolve().then(() => (PP(),jP)).then((Q)=>({default:Q.default.component})),uP=()=>Promise.resolve().then(() => (SP(),DP)).then((Q)=>({default:Q.default.component})),dP=()=>Promise.resolve().then(() => (kP(),EP)).then((Q)=>({default:Q.default.component})),cP=()=>Promise.resolve().then(() => (vP(),xP)).then((Q)=>({default:Q.default.component})),pP=()=>Promise.resolve().then(() => (bP(),hP)).then((Q)=>({default:Q.default.component})),lP=()=>Promise.resolve().then(() => (mP(),gP)).then((Q)=>({default:Q.default.component})),r5={home:"/",media:"/media",page:"/pages/:pageId",settings:"/settings",users:"/users"},_h=[{path:"/",component:p5,isLayout:!0,children:[{path:"/home",matchPath:"/",component:mz.lazy(fP),preload:fP},{path:"/media",component:mz.lazy(uP),preload:uP},{path:"/page",matchPath:"/pages/:pageId",component:mz.lazy(dP),preload:dP},{path:"/settings",component:mz.lazy(cP),preload:cP},{path:"/users",component:mz.lazy(pP),preload:pP},{path:"/:__notFound+",component:mz.lazy(lP),preload:lP}]}],t5=a9(_h);UH();var zF=f($Z(),1),iP=document.getElementById("app");if(iP)sP.createRoot(iP).render(zF.jsxDEV(nP.StrictMode,{children:zF.jsxDEV(KP,{children:zF.jsxDEV($A,{routes:t5,pageRegistry:r5},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this));
251
+ <%s key={someKey} {...props} />`,VZ,IZ,YX,IZ),p[IZ+VZ]=!0)}if(IZ=null,AZ!==void 0&&(z(AZ),IZ=""+AZ),A(o)&&(z(o.key),IZ=""+o.key),"key"in o){AZ={};for(var TX in o)TX!=="key"&&(AZ[TX]=o[TX])}else AZ=o;return IZ&&L(AZ,typeof w==="function"?w.displayName||w.name||"Unknown":w),I(w,IZ,AZ,W(),vZ,JX)}function M(w){R(w)?w._store&&(w._store.validated=1):typeof w==="object"&&w!==null&&w.$$typeof===l&&(w._payload.status==="fulfilled"?R(w._payload.value)&&w._payload.value._store&&(w._payload.value._store.validated=1):w._store&&(w._store.validated=1))}function R(w){return typeof w==="object"&&w!==null&&w.$$typeof===j}var j=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),t=Symbol.for("react.consumer"),qZ=Symbol.for("react.context"),QZ=Symbol.for("react.forward_ref"),LZ=Symbol.for("react.suspense"),kZ=Symbol.for("react.suspense_list"),JZ=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),OZ=Symbol.for("react.activity"),n=Symbol.for("react.client.reference"),wZ=vz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,WZ=Object.prototype.hasOwnProperty,HZ=Array.isArray,v=console.createTask?console.createTask:function(){return null};vz={react_stack_bottom_frame:function(w){return w()}};var m,E={},g=vz.react_stack_bottom_frame.bind(vz,K)(),e=v(_(K)),p={};_v.Fragment=d,_v.jsxDEV=function(w,o,AZ,VZ){var vZ=1e4>wZ.recentlyCreatedOwnerStacks++;return N(w,o,AZ,VZ,vZ?Error("react-stack-top-frame"):g,vZ?v(_(w)):e)}})()});var $W,Wv,xY=({label:Q,description:q,errorMessage:z,placeholder:_,size:W,...K})=>$W.jsxDEV(YB,{...K,className:"flex w-full flex-col gap-2",children:[$W.jsxDEV(Bz,{className:"text-heading5 font-medium text-fg",children:Q},void 0,!1,void 0,this),$W.jsxDEV(Wv,{placeholder:_,fieldSize:W},void 0,!1,void 0,this),q?$W.jsxDEV(ZG,{slot:"description",className:"text-xs text-fg-muted",children:q},void 0,!1,void 0,this):null,$W.jsxDEV(LW,{className:"text-xs text-danger",children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var yC=C(()=>{zJ();FY();$W=f($Z(),1),Wv=mZ(RO,{displayName:"InputControl",baseClass:"w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none transition-colors duration-200 placeholder:text-fg-muted data-[hovered]:border-fg-subtle data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring data-[invalid]:border-danger data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none",variants:{fieldSize:{sm:"h-8",md:"h-10",lg:"h-12"}},defaultVariants:{fieldSize:"md"}})});var SW,Uv,ZF=({label:Q,description:q,errorMessage:z,placeholder:_,rows:W,...K})=>SW.jsxDEV(YB,{...K,className:"flex w-full flex-col gap-2",children:[SW.jsxDEV(Bz,{className:"text-sm font-medium text-fg",children:Q},void 0,!1,void 0,this),SW.jsxDEV(Uv,{placeholder:_,rows:W},void 0,!1,void 0,this),q?SW.jsxDEV(ZG,{slot:"description",className:"text-xs text-fg-muted",children:q},void 0,!1,void 0,this):null,SW.jsxDEV(LW,{className:"text-xs text-danger",children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var vC=C(()=>{zJ();FY();SW=f($Z(),1),Uv=mZ(y5,{displayName:"TextAreaControl",baseClass:"min-h-[120px] w-full resize-y rounded-lg border border-border bg-surface-card px-4 py-3 text-sm text-fg outline-none transition-colors duration-200 placeholder:text-fg-muted data-[hovered]:border-fg-subtle data-[focused]:border-brand-green data-[focused]:ring-2 data-[focused]:ring-ring data-[invalid]:border-danger data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"})});var hC;var bC=C(()=>{hC=f($Z(),1)});var Kv;var gC=C(()=>{Kv=f($Z(),1)});var Bv;var mC=C(()=>{Bv=f($Z(),1)});var Lv,hYZ,bYZ;var fC=C(()=>{zJ();FY();Lv=f($Z(),1),hYZ=mZ(Rz,{displayName:"SelectTrigger",baseClass:"flex min-h-[58px] w-full items-center justify-between gap-2.5 rounded-lg bg-surface-card p-5 text-sm text-fg outline-none transition-colors data-[hovered]:bg-surface-muted data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring group-data-[invalid]:ring-2 group-data-[invalid]:ring-danger data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),bYZ=mZ(tK,{displayName:"SelectItem",baseClass:"flex cursor-pointer select-none items-center rounded-md px-5 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[selected]:font-medium data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"})});var uC,pYZ,lYZ;var dC=C(()=>{zJ();FY();uC=f($Z(),1),pYZ=mZ(rO,{displayName:"DialogOverlay",baseClass:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[rgba(179,179,179,0.5)] backdrop-blur-[2px] data-[entering]:animate-in data-[exiting]:animate-out"}),lYZ=mZ(R5,{displayName:"DialogModal",baseClass:"rounded-lg bg-surface p-5 outline-none shadow-[0px_2px_8px_0px_rgba(0,0,0,0.06)]"})});var Ov,aYZ,oYZ;var cC=C(()=>{zJ();FY();Ov=f($Z(),1),aYZ=mZ(kz,{displayName:"DropdownMenuItem",baseClass:"flex cursor-pointer select-none items-center gap-2.5 rounded-md px-4 py-3 text-sm text-fg outline-none data-[focused]:bg-surface-card data-[hovered]:bg-surface-card data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50",variants:{destructive:{true:"text-danger data-[focused]:text-danger data-[hovered]:text-danger"}}}),oYZ=mZ(H6,{displayName:"DropdownMenuSeparator",baseClass:"my-2 h-px border-0 bg-border"})});var XF,pC,ZQZ;var lC=C(()=>{zJ();FY();XF=f(ZZ(),1),pC=f($Z(),1),ZQZ=mZ(kz,{displayName:"ContextMenuItem",baseClass:"flex min-h-[34px] cursor-pointer select-none items-center gap-2.5 rounded-[10px] px-3 py-1.5 text-compact text-white outline-none data-[focused]:bg-[#2f2f2f] data-[focused]:font-medium data-[hovered]:bg-[#2f2f2f] data-[hovered]:font-medium data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45",variants:{destructive:{true:"text-[#ffb5b5] data-[focused]:text-[#ffb5b5]"}}})});var Fv;var m5=C(()=>{Fv=f($Z(),1)});var iC,HQZ;var nC=C(()=>{zJ();iC=f($Z(),1),HQZ=new QB({maxVisibleToasts:5})});var UQZ,KQZ;var sC=C(()=>{zJ();FY();UQZ=mZ(M5,{displayName:"Disclosure"}),KQZ=mZ(N5,{displayName:"DisclosurePanel"})});var OQZ,FQZ,MQZ;var aC=C(()=>{zJ();FY();OQZ=mZ(E5,{displayName:"TabList",baseClass:"flex gap-2 border-b border-border"}),FQZ=mZ(k5,{displayName:"Tab",baseClass:"cursor-pointer select-none border-b-2 border-transparent px-4 py-3 text-sm font-medium text-fg-muted outline-none transition-colors data-[hovered]:text-fg data-[selected]:border-brand-primary data-[selected]:text-fg data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),MQZ=mZ(x5,{displayName:"TabPanel",baseClass:"py-4 text-sm text-fg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"})});var Mv;var oC=C(()=>{b5();Mv=f($Z(),1)});var Nv;var rC=C(()=>{Nv=f($Z(),1)});var RQZ,jQZ;var tC=C(()=>{FY();RQZ=mZ("span",{displayName:"Text",baseClass:"text-fg",variants:{size:{micro:"text-micro",caption:"text-caption",label:"text-label",compact:"text-compact",callout:"text-callout",body:"text-body",subtitle:"text-subtitle",title:"text-title",headline:"text-headline",display:"text-display"},weight:{regular:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},tone:{default:"text-fg",muted:"text-fg-muted",subtle:"text-fg-subtle",inverted:"text-fg-inverted"}},defaultVariants:{size:"body",weight:"regular",tone:"default"}}),jQZ=mZ("h2",{displayName:"Heading",baseClass:"font-medium tracking-tight text-fg",variants:{level:{"1":"text-heading1","2":"text-heading2","3":"text-heading3","4":"text-heading4","5":"text-heading5"}},defaultVariants:{level:"2"}})});var Iv;var eC=C(()=>{m5();Iv=f($Z(),1)});var kQZ;var ZP=C(()=>{FY();kQZ=mZ("div",{displayName:"Card",baseClass:"relative rounded-lg bg-surface-card",variants:{variant:{plain:"",outlined:"border border-border",elevated:"shadow-md"},padding:{none:"p-0",sm:"p-4",md:"p-6",lg:"p-8"}},defaultVariants:{variant:"plain",padding:"md"}})});var vQZ;var XP=C(()=>{FY();vQZ=mZ("section",{displayName:"Section",baseClass:"w-full",variants:{padding:{none:"py-0",sm:"py-4",md:"py-6 sm:py-8",lg:"py-8 sm:py-12",xl:"py-12 sm:py-16"}},defaultVariants:{padding:"md"}})});var gQZ;var YP=C(()=>{FY();gQZ=mZ("div",{displayName:"PageContainer",baseClass:"w-full",variants:{size:{sm:"max-w-screen-sm mx-auto",md:"max-w-screen-md mx-auto",lg:"max-w-screen-lg mx-auto",xl:"max-w-screen-xl ml-0 mr-0 min-[1200px]:max-w-full","2xl":"max-w-screen-2xl mx-auto min-[1600px]:max-w-full min-[1600px]:mx-0",full:"max-w-full"}}})});var QP,Tv,uQZ,dQZ,cQZ;var JP=C(()=>{FY();QP=f(ZZ(),1),Tv=f($Z(),1),uQZ=mZ("div",{displayName:"AppShell",baseClass:"grid h-screen w-full overflow-hidden bg-surface grid-rows-[100%] grid-cols-[1fr] md:grid-cols-[auto_1fr]"}),dQZ=mZ("aside",{displayName:"AppShell.Sidebar",baseClass:"h-full w-64 shrink-0 overflow-y-auto border-r border-border bg-surface"}),cQZ=mZ("main",{displayName:"AppShell.Main",baseClass:"min-w-0 flex-1 bg-surface px-6 pb-6 pt-6"})});var qP,wv,Vv,Rv,jv=(Q)=>qP.jsxDEV(Rv,{...Q},void 0,!1,void 0,this),Cv,Pv,sQZ,aQZ,oQZ;var GP=C(()=>{zJ();FY();qP=f($Z(),1),wv=mZ("header",{displayName:"Topbar",baseClass:"flex h-14 w-full items-center gap-5 border-b border-border"}),Vv=mZ("div",{displayName:"Topbar.Brand",baseClass:"flex min-w-0 items-center gap-3 text-compact leading-4 font-medium tracking-tight text-fg"}),Rv=mZ("nav",{displayName:"Topbar.Nav",baseClass:"ml-auto flex min-w-0 items-center gap-2 overflow-x-auto"}),Cv=mZ("div",{displayName:"Topbar.Actions",baseClass:"ml-auto flex items-center gap-4"}),Pv=mZ("a",{displayName:"Topbar.NavLink",baseClass:"inline-flex items-center rounded-sm px-[13px] py-[6px] text-compact leading-4 whitespace-nowrap text-fg no-underline transition-colors hover:bg-surface-muted hover:text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring data-[active]:bg-surface-muted data-[active]:text-fg",variants:{active:{true:"",false:""}},variantsAsDataAttrs:["active"]}),sQZ=mZ(tK,{displayName:"WorkspaceSwitcher.Item",baseClass:"flex cursor-pointer select-none items-center rounded-sm px-3 py-2 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[selected]:font-medium"}),aQZ=mZ(kz,{displayName:"UserMenu.Item",baseClass:"flex cursor-pointer select-none items-center rounded-sm px-3 py-2 text-sm text-fg outline-none data-[focused]:bg-surface-muted data-[disabled]:opacity-50 data-[disabled]:pointer-events-none"}),oQZ=Object.assign(wv,{Brand:Vv,Nav:jv,NavLink:Pv,Actions:Cv})});var Dv,$v,eQZ;var HP=C(()=>{FY();Dv=f(ZZ(),1),$v=f($Z(),1),eQZ=mZ("header",{displayName:"PersistentPageShell.Header",baseClass:"flex w-full flex-col gap-6 bg-surface",variants:{sticky:{true:"sticky top-0 z-[1]",false:""}},defaultVariants:{sticky:!1}})});var WH=C(()=>{FY();b5();yC();vC();bC();gC();mC();fC();dC();cC();lC();m5();nC();sC();aC();oC();rC();tC();eC();ZP();XP();YP();JP();GP();HP()});function YF(Q){try{let q=String(Q).split(".")[1];if(!q)return!1;let z=JSON.parse(atob(q.replace(/-/g,"+").replace(/_/g,"/")));return typeof z.exp==="number"&&Date.now()>=z.exp*1000}catch{return!1}}function zP(){try{let Q=localStorage.getItem(f5);if(Q)return JSON.parse(Q)}catch{}return{baseUrl:"http://localhost:8787",token:"",tenant:"main"}}function _P(Q){localStorage.setItem(f5,JSON.stringify(Q))}function WP(){try{localStorage.removeItem(f5)}catch{}}class u5{cfg;onExpired;constructor(Q,q){this.cfg=Q;this.onExpired=q}setConfig(Q){this.cfg=Q}base(){return this.cfg.baseUrl.replace(/\/+$/,"")}async call(Q,q){if(this.onExpired&&this.cfg.token&&YF(this.cfg.token))return this.onExpired(),new Promise(()=>{});let z=await fetch(`${this.base()}/rpc/${Q}`,{method:"POST",headers:{"content-type":"application/json","x-pramen-tenant":this.cfg.tenant||"main",...this.cfg.token?{authorization:`Bearer ${this.cfg.token}`}:{}},body:JSON.stringify(q??{})}),_;try{_=await z.json()}catch{throw new EW(`non-JSON response (HTTP ${z.status})`,"bad_response",z.status)}if(_.ok!==!0){let W=_.error??`request failed (HTTP ${z.status})`,K=z.status===403?" — check your token has an editor/reviewer role":"";throw new EW(W+K,_.code??"error",z.status)}return _.result}async put(Q,q,z){let _=Q.startsWith("http")?Q:`${this.base()}${Q}`,W=await fetch(_,{method:"PUT",headers:{"content-type":z},body:q});if(!W.ok)throw new EW(`upload failed (HTTP ${W.status})`,"upload_failed",W.status)}resolve(Q){return Q.startsWith("http")?Q:`${this.base()}${Q}`}listBlockTypes=()=>this.call("listBlockTypes");listContentTypes=()=>this.call("listContentTypes");getContentType=(Q)=>this.call("getContentType",{id:Q});listPages=()=>this.call("listPages");getPagePreview=(Q,q)=>this.call("getPage",{slug:Q,locale:q,preview:!0});listPageAudit=(Q)=>this.call("listPageAudit",{pageId:Q});listMedia=(Q=50,q=0)=>this.call("listMedia",{limit:Q,offset:q});getMedia=(Q)=>this.call("getMedia",{id:Q});updateMedia=(Q,q)=>this.call("updateMedia",{id:Q,alt:q});deleteMedia=(Q)=>this.call("deleteMedia",{id:Q});async uploadMedia(Q){let q=Q.type||"application/octet-stream",z=await this.call("signMediaUpload",{contentType:q,filename:Q.name});return await this.put(z.url,await Q.arrayBuffer(),q),this.call("createMedia",{ref:z.ref,alt:Q.name})}}var EW,f5="pramen.cmsEditor";var d5=C(()=>{EW=class EW extends Error{code;status;constructor(Q,q,z){super(Q);this.code=q;this.status=z;this.name="ApiError"}}});function c5(){WP(),location.replace(JB)}function _J(){let Q=KQ.use(UP);if(!Q)throw Error("useApp must be used within <AppProvider>");return Q}function KP({children:Q}){let[q,z]=KQ.useState(zP()),[_,W]=KQ.useState(null),[K,A]=KQ.useState(""),L=Boolean(q.baseUrl&&q.token)&&!YF(q.token),O=KQ.useMemo(()=>new u5(q,JB?c5:void 0),[q]);if(KQ.useEffect(()=>{if(!JB)return;let N=()=>{if(!q.token||YF(q.token))c5()};N();let M=()=>{if(!document.hidden)N()},R=window.setInterval(N,30000);return window.addEventListener("visibilitychange",M),window.addEventListener("focus",N),()=>{window.clearInterval(R),window.removeEventListener("visibilitychange",M),window.removeEventListener("focus",N)}},[q.token]),KQ.useEffect(()=>{if(!L)return;O.call("me").then(W).catch(()=>W({}))},[O,L]),!L)return JB?null:UQ.jsxDEV(Sv,{cfg:q,onSave:(N)=>{_P(N),z(N)}},void 0,!1,void 0,this);let I={api:O,cfg:q,me:_,isAdmin:(_?.roles??[]).includes("admin"),error:K,setError:A,reconfigure:()=>{if(JB){c5();return}W(null),A(""),z({...q,token:""})}};return UQ.jsxDEV(UP,{value:I,children:Q},void 0,!1,void 0,this)}function Sv({cfg:Q,onSave:q}){let[z,_]=KQ.useState(Q);return UQ.jsxDEV("div",{className:"mx-auto mt-[14vh] w-full max-w-[520px] px-6",children:UQ.jsxDEV("div",{className:"rounded-panel border border-border bg-surface-card px-10 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.08)]",children:[UQ.jsxDEV("h1",{className:"mb-4 text-display text-fg",children:["pramen ",UQ.jsxDEV("span",{className:"text-fg-subtle",children:"· cms editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),UQ.jsxDEV("p",{className:"mb-6 text-sm text-fg-muted",children:["Point at your Worker and paste an editor/reviewer JWT. CORS must allow this origin (",UQ.jsxDEV("code",{children:"CORS_ORIGINS"},void 0,!1,void 0,this),")."]},void 0,!0,void 0,this),UQ.jsxDEV("div",{className:"flex flex-col gap-4",children:[UQ.jsxDEV(xY,{label:"Worker base URL",value:z.baseUrl,onChange:(W)=>_({...z,baseUrl:W}),placeholder:"https://your-worker.workers.dev"},void 0,!1,void 0,this),UQ.jsxDEV(xY,{label:"Tenant",value:z.tenant,onChange:(W)=>_({...z,tenant:W}),placeholder:"main"},void 0,!1,void 0,this),UQ.jsxDEV(xY,{label:"Bearer token (editor or reviewer)",value:z.token,onChange:(W)=>_({...z,token:W}),placeholder:"eyJ…"},void 0,!1,void 0,this),UQ.jsxDEV(yZ,{className:"mt-2 w-full",onPress:()=>q(z),isDisabled:!z.baseUrl||!z.token,children:"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var KQ,UQ,JB,UP;var UH=C(()=>{WH();d5();KQ=f(ZZ(),1),UQ=f($Z(),1),JB=typeof window<"u"&&!new URLSearchParams(window.location.search).has("setup")?window.PRAMEN_CMS_EDITOR?.signInUrl:void 0;UP=KQ.createContext(null)});function kW({label:Q,children:q}){return MZ.jsxDEV("label",{className:"flex w-full flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:Q},void 0,!1,void 0,this),q]},void 0,!0,void 0,this)}function QF({schema:Q,value:q,onChange:z,api:_}){let W=(K,A)=>z({...q,[K]:A});return MZ.jsxDEV("div",{className:"flex flex-col gap-4",children:Q.map((K)=>MZ.jsxDEV(Ev,{def:K,value:q[K.name],onChange:(A)=>W(K.name,A),api:_},K.name,!1,void 0,this))},void 0,!1,void 0,this)}function Ev({def:Q,value:q,onChange:z,api:_}){let W=MZ.jsxDEV(MZ.Fragment,{children:[Q.label??Q.name," ",Q.required?MZ.jsxDEV("span",{className:"text-danger",children:"*"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);switch(Q.type){case"text":case"url":return MZ.jsxDEV(xY,{label:W,value:q??"",onChange:z,placeholder:Q.type==="url"?"https://…":""},void 0,!1,void 0,this);case"textarea":return MZ.jsxDEV(ZF,{label:W,value:typeof q==="string"?q:q==null?"":JSON.stringify(q),onChange:z},void 0,!1,void 0,this);case"richtext":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(yv,{value:typeof q==="string"?q:"",onChange:z},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"number":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("input",{className:l5,type:"number",value:q==null?"":String(q),onChange:(K)=>z(K.target.value===""?null:Number(K.target.value))},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"date":case"datetime":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("input",{className:l5,type:Q.type==="date"?"date":"datetime-local",value:q??"",onChange:(K)=>z(K.target.value||null)},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"boolean":return MZ.jsxDEV("label",{className:"flex items-center gap-2",children:[MZ.jsxDEV("input",{type:"checkbox",checked:Boolean(q),onChange:(K)=>z(K.target.checked)},void 0,!1,void 0,this),MZ.jsxDEV("span",{className:"text-sm text-fg",children:Q.label??Q.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this);case"select":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(hv,{def:Q,value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"media":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV(bv,{value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"group":return MZ.jsxDEV(kW,{label:W,children:MZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:MZ.jsxDEV(QF,{schema:Q.fields??[],value:q??{},onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"repeater":return MZ.jsxDEV(vv,{def:Q,value:q??[],onChange:z,api:_,label:W},void 0,!1,void 0,this);default:return null}}function xv(Q){let q=Q.trim();return/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(q)?q:null}function BP(Q){return Q.replace(/<\s*(script|style)[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/(href|src)\s*=\s*("javascript:[^"]*"|'javascript:[^']*')/gi,'$1="#"')}function yv({value:Q,onChange:q}){let z=oY.useRef(null),_=oY.useRef("");oY.useEffect(()=>{let L=z.current;if(L&&Q!==_.current)L.innerHTML=BP(Q||""),_.current=Q||""},[Q]);let W=()=>{let L=BP(z.current?.innerHTML??"");_.current=L,q(L)},K=(L,O)=>{z.current?.focus(),document.execCommand(L,!1,O),W()},A=(L)=>{L.preventDefault(),document.execCommand("insertText",!1,L.clipboardData.getData("text/plain"))};return MZ.jsxDEV("div",{className:"overflow-hidden rounded-lg border border-border bg-surface-card",children:[MZ.jsxDEV("div",{className:"flex flex-wrap gap-0.5 border-b border-border bg-surface-muted px-2 py-1.5",children:kv.map((L)=>MZ.jsxDEV("button",{type:"button",className:"rounded border-0 bg-transparent px-2.5 py-0.5 text-xs text-fg-muted hover:bg-surface-card hover:text-fg",title:L.title,onMouseDown:(O)=>O.preventDefault(),onClick:()=>L.run(K),children:L.label},L.label,!1,void 0,this))},void 0,!1,void 0,this),MZ.jsxDEV("div",{ref:z,className:"prose prose-sm min-h-[180px] max-w-none px-4 py-3.5 text-sm leading-relaxed text-fg outline-none empty:before:text-fg-subtle empty:before:content-[attr(data-placeholder)]",contentEditable:!0,suppressContentEditableWarning:!0,"data-placeholder":"Write…",onInput:W,onBlur:W,onPaste:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vv({def:Q,value:q,onChange:z,api:_,label:W}){let K=Array.isArray(q)?q:[],A=(N,M)=>z(K.map((R,j)=>j===N?M:R)),L=()=>z([...K,{}]),O=(N)=>z(K.filter((M,R)=>R!==N)),I=(N,M)=>{let R=N+M;if(R<0||R>=K.length)return;let j=K.slice();[j[N],j[R]]=[j[R],j[N]],z(j)};return MZ.jsxDEV("div",{className:"flex flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:W},void 0,!1,void 0,this),K.map((N,M)=>MZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:[MZ.jsxDEV("div",{className:"mb-2 flex justify-end gap-1",children:[MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>I(M,-1),children:"↑"},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>I(M,1),children:"↓"},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>O(M),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),MZ.jsxDEV(QF,{schema:Q.fields??[],value:N,onChange:(R)=>A(M,R),api:_},void 0,!1,void 0,this)]},M,!0,void 0,this)),MZ.jsxDEV(yZ,{variant:"secondary",size:"sm",className:"self-start",onPress:L,isDisabled:Q.max!=null&&K.length>=Q.max,children:["+ add ",Q.label??Q.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function hv({def:Q,value:q,onChange:z,api:_}){let[W,K]=oY.useState(null),A=Q.optionsFrom;oY.useEffect(()=>{if(!A)return;let I=!0;return _.call(A).then((N)=>{if(I)K(Array.isArray(N)?N:[])}).catch(()=>{if(I)K([])}),()=>{I=!1}},[A,_]);let L=Boolean(A)&&W===null,O=A?W??[]:(Q.options??[]).map((I)=>({value:I,label:I}));return MZ.jsxDEV("select",{className:l5,value:q??"",onChange:(I)=>z(I.target.value||null),children:[MZ.jsxDEV("option",{value:"",children:L?"Načítám…":"—"},void 0,!1,void 0,this),O.map((I)=>MZ.jsxDEV("option",{value:I.value,children:I.label},I.value,!1,void 0,this))]},void 0,!0,void 0,this)}function bv({value:Q,onChange:q,api:z}){let[_,W]=oY.useState(!1),[K,A]=oY.useState(null);return oY.useEffect(()=>{if(Q)z.call("getMedia",{id:Q}).then(A).catch(()=>A(null));else A(null)},[Q,z]),MZ.jsxDEV("div",{children:[MZ.jsxDEV("div",{className:"flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",children:[K?MZ.jsxDEV("img",{className:"h-10 w-10 rounded object-cover",src:z.resolve(`/media/${K.file.key}`),alt:""},void 0,!1,void 0,this):MZ.jsxDEV("span",{className:"text-fg-subtle",children:"no media"},void 0,!1,void 0,this),MZ.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:K?.file.filename??Q??""},void 0,!1,void 0,this),MZ.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"pick"},void 0,!1,void 0,this),Q?MZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>q(null),children:"clear"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),_?MZ.jsxDEV(gv,{api:z,onClose:()=>W(!1),onPick:(L)=>{q(L),W(!1)}},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function gv({api:Q,onClose:q,onPick:z}){let[_,W]=oY.useState([]),[K,A]=oY.useState(!1),[L,O]=oY.useState(""),I=()=>Q.listMedia().then(W).catch((M)=>O(String(M.message??M)));oY.useEffect(()=>{I()},[]);let N=async(M)=>{A(!0),O("");try{let R=await Q.uploadMedia(M);z(R.id)}catch(R){O(String(R.message??R))}finally{A(!1)}};return MZ.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(20,15,5,0.28)] p-6",onClick:q,children:MZ.jsxDEV("div",{className:"max-h-[86vh] w-full max-w-[680px] overflow-auto rounded-panel border border-border bg-surface-card px-9 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.12)]",onClick:(M)=>M.stopPropagation(),children:[MZ.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal text-fg",children:["Choose ",MZ.jsxDEV("span",{className:"text-fg-subtle",children:"a file"},void 0,!1,void 0,this)," from the library"]},void 0,!0,void 0,this),L?MZ.jsxDEV("div",{className:"my-2 rounded-lg border border-danger bg-surface-card px-3.5 py-2.5 text-[13px] text-danger",children:L},void 0,!1,void 0,this):null,MZ.jsxDEV("label",{className:"mb-4 flex w-full flex-col gap-2",children:[MZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Upload a new file"},void 0,!1,void 0,this),MZ.jsxDEV("input",{type:"file",className:"text-sm text-fg-muted",disabled:K,onChange:(M)=>M.target.files?.[0]&&N(M.target.files[0])},void 0,!1,void 0,this)]},void 0,!0,void 0,this),MZ.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:_.map((M)=>MZ.jsxDEV("div",{className:"cursor-pointer overflow-hidden rounded-lg border border-border bg-surface-card",onClick:()=>z(M.id),children:[(M.file.contentType??"").startsWith("image/")?MZ.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:Q.resolve(`/media/${M.file.key}`),alt:""},void 0,!1,void 0,this):MZ.jsxDEV("div",{className:"h-[130px] bg-surface-muted"},void 0,!1,void 0,this),MZ.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:M.file.filename??M.id},void 0,!1,void 0,this)]},M.id,!0,void 0,this))},void 0,!1,void 0,this),MZ.jsxDEV("div",{className:"mt-3 text-right",children:MZ.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"close"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var oY,MZ,l5="h-10 w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none transition-colors placeholder:text-fg-muted focus:border-brand-green",kv;var LP=C(()=>{WH();oY=f(ZZ(),1),MZ=f($Z(),1);kv=[{label:"B",title:"Bold",run:(Q)=>Q("bold")},{label:"I",title:"Italic",run:(Q)=>Q("italic")},{label:"H2",title:"Heading",run:(Q)=>Q("formatBlock","H2")},{label:"H3",title:"Subheading",run:(Q)=>Q("formatBlock","H3")},{label:"¶",title:"Paragraph",run:(Q)=>Q("formatBlock","P")},{label:"• List",title:"Bulleted list",run:(Q)=>Q("insertUnorderedList")},{label:"1. List",title:"Numbered list",run:(Q)=>Q("insertOrderedList")},{label:"Link",title:"Add link",run:(Q)=>{let q=window.prompt("Link URL (https://, mailto:, /path)","https://");if(!q)return;let z=xv(q);if(!z){window.alert("Only http(s), mailto, tel, or relative (/, #) links are allowed.");return}Q("createLink",z)}},{label:"Unlink",title:"Remove link",run:(Q)=>Q("unlink")},{label:"Clear",title:"Clear formatting",run:(Q)=>Q("removeFormat")}]});function GF({lead:Q,em:q,children:z}){return P.jsxDEV("div",{className:"mx-auto grid max-w-[1200px] grid-cols-[1fr_auto] items-center gap-6 px-7 pb-6 pt-8 max-[820px]:grid-cols-1",children:[P.jsxDEV("h1",{className:"m-0 text-[56px] font-normal leading-[1.05] tracking-[-0.01em] max-[820px]:text-[40px]",children:[P.jsxDEV("span",{className:"block text-fg-subtle",children:Q},void 0,!1,void 0,this),P.jsxDEV("span",{className:"block text-fg",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z]},void 0,!0,void 0,this)}function n5({text:Q,em:q,children:z}){return P.jsxDEV("div",{className:"flex min-w-[360px] items-center gap-4 rounded-full bg-brand-green py-3 pl-7 pr-3 max-[820px]:min-w-0",children:[P.jsxDEV("span",{className:"text-lg text-[#0f3a25]",children:[Q," ",P.jsxDEV("span",{className:"font-semibold",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z]},void 0,!0,void 0,this)}function KH({children:Q}){return P.jsxDEV("div",{className:"mb-2 mt-[18px] text-sm text-fg-subtle first:mt-0",children:Q},void 0,!1,void 0,this)}function hz({status:Q,children:q}){return P.jsxDEV("span",{className:`inline-block whitespace-nowrap rounded-full border px-2.5 py-0.5 text-[11px] font-medium ${Q==="published"||Q==="active"?"bg-brand-green text-[#0f3a25] border-transparent":Q==="in_review"||Q==="review"?"bg-accent-yellow text-[#4a3512] border-transparent":Q==="rejected"||Q==="archived"||Q==="inactive"?"border-danger text-danger bg-surface-card":"border-border text-fg-muted bg-surface-card"}`,children:q},void 0,!1,void 0,this)}function s5({onClose:Q,wide:q,children:z}){return P.jsxDEV("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(20,15,5,0.28)] p-6",onClick:Q,children:P.jsxDEV("div",{className:`max-h-[86vh] w-full overflow-auto rounded-panel border border-border bg-surface-card px-9 py-8 shadow-[0_24px_60px_rgba(30,20,10,0.12)] ${q?"max-w-[680px]":"max-w-[520px]"}`,onClick:(_)=>_.stopPropagation(),children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function a5({children:Q}){return P.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal leading-[1.15] text-fg",children:Q},void 0,!1,void 0,this)}function HF({children:Q,className:q}){return P.jsxDEV("div",{className:`grid grid-cols-[auto_1fr] gap-x-3.5 gap-y-2 text-[13px] text-fg-muted [&>span:nth-child(odd)]:text-fg-subtle ${q??""}`,children:Q},void 0,!1,void 0,this)}function FP({children:Q}){return P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-6",children:Q},void 0,!1,void 0,this)}function o5({ok:Q,children:q}){return P.jsxDEV("div",{className:`my-2 rounded-lg border px-3.5 py-2.5 text-[13px] ${Q?"border-brand-green bg-brand-green/20 text-[#0f3a25]":"border-danger bg-surface-card text-danger"}`,children:q},void 0,!1,void 0,this)}function MP({api:Q,pages:q,blockTypes:z,onOpen:_,onCreated:W,onError:K}){let[A,L]=NZ.useState(!1);return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Pages",em:q.length===0?"None yet":q.length===1?"1 page total":`${q.length} pages total`,children:P.jsxDEV(n5,{text:"Let's",em:"create something",children:P.jsxDEV(yZ,{className:"shrink-0",onPress:()=>L(!0),children:"+ New page"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[q.map((O)=>P.jsxDEV("div",{className:`${xW} cursor-pointer hover:bg-surface-muted`,onClick:()=>_(O),children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:O.title},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",O.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:O.locale},void 0,!1,void 0,this),P.jsxDEV(hz,{status:O.status,children:O.status},void 0,!1,void 0,this)]},O.id,!0,void 0,this)),q.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:["No pages yet. ",z.length===0?"Define block types + a content type first (via the API/admin).":"Create one."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this),A?P.jsxDEV(mv,{api:Q,onClose:()=>L(!1),onCreated:()=>{L(!1),W()},onError:K},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function mv({api:Q,onClose:q,onCreated:z,onError:_}){let[W,K]=NZ.useState([]),[A,L]=NZ.useState(""),[O,I]=NZ.useState(""),[N,M]=NZ.useState("");NZ.useEffect(()=>{Q.listContentTypes().then((j)=>{if(K(j),j[0])L(j[0].id)}).catch((j)=>_(IX(j)))},[Q,_]);let R=async()=>{try{await Q.call("createPage",{typeId:A,title:O,slug:N||OP(O)}),z()}catch(j){_(IX(j))}};return P.jsxDEV(s5,{onClose:q,children:[P.jsxDEV(a5,{children:["Create a ",P.jsxDEV(JF,{children:"new page"},void 0,!1,void 0,this)," and define the essentials",P.jsxDEV(JF,{children:"."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV("div",{className:"flex w-full flex-col gap-2",children:[P.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Content type"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-wrap gap-2",children:W.map((j)=>P.jsxDEV("button",{type:"button",onClick:()=>L(j.id),className:`rounded-lg border px-4 py-2.5 text-sm font-medium transition-colors ${A===j.id?"border-brand-green bg-surface-muted text-fg":"border-border bg-surface-card text-fg-muted hover:border-fg-subtle hover:text-fg"}`,children:j.name},j.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV(xY,{label:"Title",value:O,onChange:I},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Slug",value:N,onChange:M,placeholder:OP(O)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex justify-end gap-2",children:[P.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"cancel"},void 0,!1,void 0,this),P.jsxDEV(yZ,{onPress:R,isDisabled:!A||!O,children:"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function NP({api:Q,page:q,blockTypes:z,tab:_,onTab:W,onBack:K,onChange:A}){let[L,O]=NZ.useState(null),[I,N]=NZ.useState(null),[M,R]=NZ.useState(""),j=NZ.useRef(new Set),[h,d]=NZ.useState(0),b=NZ.useCallback((E,g)=>{let e=j.current;if(g?e.has(E):!e.has(E))return;if(g)e.add(E);else e.delete(E);d(e.size)},[]),a=()=>j.current.size===0||window.confirm(`You have unsaved changes in ${j.current.size} block${j.current.size===1?"":"s"}. Leave without saving?`),t=NZ.useMemo(()=>new Map(z.map((E)=>[E.slug,E])),[z]),qZ=NZ.useCallback(async()=>{try{let[E,g]=await Promise.all([Q.getContentType(q.typeId),Q.getPagePreview(q.slug,q.locale)]);O(E??null),N(g)}catch(E){R(IX(E))}},[Q,q.typeId,q.slug,q.locale]);NZ.useEffect(()=>{qZ()},[qZ]),NZ.useEffect(()=>{if(h===0)return;let E=(g)=>{g.preventDefault(),g.returnValue=""};return window.addEventListener("beforeunload",E),()=>window.removeEventListener("beforeunload",E)},[h]);let QZ=L?.regions??[],LZ=(E,g)=>N((e)=>e?{...e,regions:{...e.regions,[E]:g(e.regions[E]??[])}}:e),kZ=async(E,g)=>{let e=`tmp:${crypto.randomUUID()}`;LZ(E,(p)=>[...p,{id:e,block_id:e,block_type:g,title:null,fields:{},is_shared:!1,pending:!0}]);try{let{block:p,placement:w}=await Q.call("addBlock",{pageId:q.id,blockTypeSlug:g,region:E,fields:{}}),o={id:String(w.id),block_id:String(p.id),block_type:g,title:p.title??null,fields:p.fields??{},is_shared:Boolean(w.isShared)};LZ(E,(AZ)=>AZ.map((VZ)=>VZ.id===e?o:VZ))}catch(p){LZ(E,(w)=>w.filter((o)=>o.id!==e)),R(IX(p))}},JZ=async(E)=>{try{await Q.call("removeBlock",{pageBlockId:E.id}),await qZ()}catch(g){R(IX(g))}},l=async(E,g)=>{try{await Q.call("reorderRegion",{pageId:q.id,region:E,order:g}),await qZ()}catch(e){R(IX(e))}},OZ=NZ.useCallback((E,g)=>{N((e)=>{if(!e)return e;let p={};for(let[w,o]of Object.entries(e.regions))p[w]=o.map((AZ)=>AZ.id===E?{...AZ,fields:g}:AZ);return{...e,regions:p}})},[]),[n,wZ]=NZ.useState(null),WZ=(E,g)=>wZ({region:E,from:g,over:g}),HZ=(E,g)=>wZ((e)=>e&&e.region===E&&e.over!==g?{...e,over:g}:e),v=()=>wZ(null),m=(E)=>{if(wZ(null),!n||n.region!==E||n.from===n.over)return;let g=(I?.regions[E]??[]).map((p)=>p.id),[e]=g.splice(n.from,1);g.splice(n.over,0,e),l(E,g)};return P.jsxDEV("div",{className:"grid min-h-[calc(100vh-68px)] grid-cols-[260px_1fr_400px] gap-5 px-7 pb-7 pt-2 max-[820px]:grid-cols-1",children:[P.jsxDEV("div",{className:"overflow-auto rounded-panel bg-surface-muted p-[18px]",children:[P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>{if(a())K()},children:"← all pages"},void 0,!1,void 0,this),h>0?P.jsxDEV("p",{className:"mt-2 text-[11px] text-accent-strong",children:["● ",h," unsaved block",h===1?"":"s"]},void 0,!0,void 0,this):null,P.jsxDEV(KH,{children:"Regions"},void 0,!1,void 0,this),QZ.map((E)=>P.jsxDEV("div",{className:`${xW} mb-2`,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:E.label??E.name},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:(I?.regions[E.name]??[]).length},void 0,!1,void 0,this)]},E.name,!0,void 0,this)),P.jsxDEV(KH,{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:q.title},void 0,!1,void 0,this),P.jsxDEV(hz,{status:q.status,children:q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"overflow-auto py-1.5",children:[M?P.jsxDEV(o5,{children:M},void 0,!1,void 0,this):null,QZ.map((E)=>{let g=I?.regions[E.name]??[],e=E.allowedTypes&&E.allowedTypes.length?E.allowedTypes:z.map((p)=>p.slug);return P.jsxDEV("div",{className:"mb-8",children:[P.jsxDEV("h3",{className:"m-0 mb-3 text-[22px] font-normal text-fg",children:E.label??E.name},void 0,!1,void 0,this),g.length===0?P.jsxDEV("p",{className:"mb-3 text-sm text-fg-subtle",children:"No blocks yet — add one below."},void 0,!1,void 0,this):null,g.map((p,w)=>P.jsxDEV(fv,{api:Q,block:p,blockType:t.get(p.block_type),isFirst:w===0,isLast:w===g.length-1,onMove:(o)=>Yh(g,E.name,w,o,l),onRemove:()=>JZ(p),onPatch:OZ,onDirtyChange:b,onError:R,dragging:n?.region===E.name&&n.from===w,isOver:!!n&&n.region===E.name&&n.over===w&&n.from!==w,onDragStartBlock:()=>WZ(E.name,w),onDragOverBlock:()=>HZ(E.name,w),onDropBlock:()=>m(E.name),onDragEndBlock:v},p.id,!1,void 0,this)),P.jsxDEV(uv,{allowed:e,btBySlug:t,onAdd:(p)=>kZ(E.name,p)},void 0,!1,void 0,this)]},E.name,!0,void 0,this)}),QZ.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"This page's content type has no regions."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-5",children:[P.jsxDEV("div",{className:"mb-3 flex gap-1",children:i5.map((E)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:_===E?"bg-surface-muted text-fg":"text-fg-muted",onPress:()=>W(E),children:E},E,!1,void 0,this))},void 0,!1,void 0,this),_==="settings"?P.jsxDEV(dv,{page:q},void 0,!1,void 0,this):null,_==="seo"?P.jsxDEV(cv,{api:Q,page:q,onError:R},void 0,!1,void 0,this):null,_==="workflow"?P.jsxDEV(pv,{api:Q,page:q,onChanged:(E)=>{A(E)},onError:R},void 0,!1,void 0,this):null,_==="i18n"?P.jsxDEV(lv,{api:Q,page:q,onError:R},void 0,!1,void 0,this):null,_==="audit"?P.jsxDEV(iv,{api:Q,pageId:q.id,onError:R},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function fv({api:Q,block:q,blockType:z,isFirst:_,isLast:W,onMove:K,onRemove:A,onPatch:L,onDirtyChange:O,onError:I,dragging:N,isOver:M,onDragStartBlock:R,onDragOverBlock:j,onDropBlock:h,onDragEndBlock:d}){let[b,a]=NZ.useState(null),[t,qZ]=NZ.useState(!1),[QZ,LZ]=NZ.useState("idle"),kZ=NZ.useRef(""),JZ=NZ.useRef(null),l=q.block_id,OZ=q.id;NZ.useEffect(()=>{if(q.pending){a({}),kZ.current="{}";return}let m=!0;return Q.call("getBlock",{blockId:l}).then((E)=>{if(!m)return;let g=E?.fields??{};a(g),kZ.current=JSON.stringify(g)}).catch((E)=>I(IX(E))),()=>{m=!1}},[Q,l,I,q.pending]);let n=b!=null&&JSON.stringify(b)!==kZ.current,wZ=NZ.useCallback(async()=>{if(q.pending||b==null)return;let m=JSON.stringify(b);if(m===kZ.current)return;LZ("saving");try{await Q.call("updateBlock",{blockId:l,fields:b}),kZ.current=m,L(OZ,b),LZ("saved"),setTimeout(()=>LZ((E)=>E==="saved"?"idle":E),1500)}catch(E){I(IX(E)),LZ("idle")}},[Q,l,OZ,b,L,I,q.pending]),WZ=(m)=>a(m);NZ.useEffect(()=>{O(OZ,n)},[n,OZ,O]),NZ.useEffect(()=>()=>{O(OZ,!1)},[OZ,O]);let HZ=z?.fieldsSchema??[],v=z?.name??q.block_type;return P.jsxDEV("div",{ref:JZ,className:`mb-2.5 rounded-panel border bg-surface-card transition-colors ${M?"border-brand-green":"border-border"} ${N?"opacity-40":""} ${q.pending?"pointer-events-none opacity-60":""}`,onDragOver:(m)=>{m.preventDefault(),j()},onDrop:(m)=>{m.preventDefault(),h()},children:[P.jsxDEV("div",{className:"flex items-center gap-2.5 px-3.5 py-2.5",children:[P.jsxDEV("span",{draggable:!0,onDragStart:(m)=>{if(JZ.current)m.dataTransfer.setDragImage(JZ.current,12,12);m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",""),R()},onDragEnd:d,className:"shrink-0 cursor-grab select-none px-0.5 text-fg-subtle hover:text-fg active:cursor-grabbing",title:"Drag to reorder",children:"⠿"},void 0,!1,void 0,this),P.jsxDEV("button",{type:"button",className:"w-4 shrink-0 text-fg-subtle hover:text-fg",title:t?"Expand":"Collapse",onClick:()=>qZ((m)=>!m),children:t?"▸":"▾"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"font-medium text-fg",children:v},void 0,!1,void 0,this),q.is_shared?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"shared"},void 0,!1,void 0,this):null,P.jsxDEV("span",{className:`text-[11px] ${n&&QZ!=="saving"?"text-accent-strong":"text-fg-subtle"}`,children:QZ==="saving"?"saving…":QZ==="saved"?"saved ✓":n?"● unsaved":""},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:_,onPress:()=>K(-1),children:"↑"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:W,onPress:()=>K(1),children:"↓"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:A,children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t?P.jsxDEV("div",{className:"cursor-pointer truncate px-3.5 pb-3 text-sm text-fg-subtle",onClick:()=>qZ(!1),children:b==null?"…":Xh(b)||P.jsxDEV("span",{className:"italic",children:"empty"},void 0,!1,void 0,this)},void 0,!1,void 0,this):P.jsxDEV("div",{className:"border-t border-border px-3.5 py-3.5",children:b==null?P.jsxDEV("p",{className:"text-sm text-fg-subtle",children:"loading…"},void 0,!1,void 0,this):HZ.length===0?P.jsxDEV("p",{className:"text-sm text-fg-subtle",children:"This block has no editable fields."},void 0,!1,void 0,this):P.jsxDEV(P.Fragment,{children:[P.jsxDEV(QF,{schema:HZ,value:b,onChange:WZ,api:Q},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-3.5 flex items-center gap-2 border-t border-border pt-3",children:[P.jsxDEV(yZ,{size:"sm",onPress:()=>void wZ(),isDisabled:!n||QZ==="saving"||q.pending,children:QZ==="saving"?"Saving…":"Save"},void 0,!1,void 0,this),n?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"Unsaved changes"},void 0,!1,void 0,this):QZ==="saved"?P.jsxDEV("span",{className:"text-[11px] text-fg-subtle",children:"Saved ✓"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function uv({allowed:Q,btBySlug:q,onAdd:z}){let[_,W]=NZ.useState(!1);if(!_)return P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"+ Add block"},void 0,!1,void 0,this);return P.jsxDEV("div",{className:"rounded-panel border border-border bg-surface-card p-2.5",children:[P.jsxDEV("div",{className:"mb-1.5 px-1 text-[11px] text-fg-subtle",children:"Add a block"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:Q.map((K)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>{z(K),W(!1)},children:q.get(K)?.name??K},K,!1,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-1.5 text-right",children:P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-fg-subtle",onPress:()=>W(!1),children:"cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function dv({page:Q}){return P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Title"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.title},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Slug"},void 0,!1,void 0,this),P.jsxDEV("span",{children:["/",Q.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{children:"Locale"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.locale},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function cv({api:Q,page:q,onError:z}){let[_,W]=NZ.useState({metaTitle:q.metaTitle??"",metaDescription:q.metaDescription??"",canonicalUrl:q.canonicalUrl??"",robots:q.robots??"",ogTitle:q.ogTitle??"",ogDescription:q.ogDescription??""}),[K,A]=NZ.useState(!1),L=async()=>{try{await Q.call("updatePageSeo",{pageId:q.id,..._}),A(!0),setTimeout(()=>A(!1),1500)}catch(I){z(IX(I))}},O=(I,N,M=!1)=>M?P.jsxDEV(ZF,{label:N,value:_[I],onChange:(R)=>W({..._,[I]:R})},void 0,!1,void 0,this):P.jsxDEV(xY,{label:N,value:_[I],onChange:(R)=>W({..._,[I]:R})},void 0,!1,void 0,this);return P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(KH,{children:"SEO"},void 0,!1,void 0,this),K?P.jsxDEV(o5,{ok:!0,children:"saved"},void 0,!1,void 0,this):null,O("metaTitle","Meta title"),O("metaDescription","Meta description",!0),O("canonicalUrl","Canonical URL"),O("robots","Robots (e.g. noindex)"),O("ogTitle","OG title"),O("ogDescription","OG description",!0),P.jsxDEV(yZ,{className:"w-full",onPress:L,children:"Save SEO"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function pv({api:Q,page:q,onChanged:z,onError:_}){let W=async(L,O)=>{try{let I=await Q.call(L,{pageId:q.id,...O});if(I?.page)z(I.page)}catch(I){_(IX(I))}},K=String(q.status),A=K==="review"?[{label:"Approve (publish)",action:"approve"},{label:"Reject",action:"reject",variant:"secondary"},{label:"Publish directly",action:"publishPage",variant:"secondary"}]:K==="published"?[{label:"Unpublish",action:"unpublishPage",variant:"secondary"}]:[{label:"Publish",action:"publishPage"},{label:"Submit for review",action:"submitForReview",variant:"secondary"}];return P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Workflow"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-3 flex items-center gap-2 text-[13px] text-fg-muted",children:[P.jsxDEV("span",{className:"text-fg-subtle",children:"Status"},void 0,!1,void 0,this),P.jsxDEV(hz,{status:q.status,children:q.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:A.map((L)=>P.jsxDEV(yZ,{variant:L.variant,onPress:()=>W(L.action),children:L.label},L.action,!1,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("p",{className:"mt-2.5 text-fg-subtle",children:"Publish needs a reviewer/admin role; submit-for-review is editor-gated."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lv({api:Q,page:q,onError:z}){let[_,W]=NZ.useState([]),[K,A]=NZ.useState(""),L=NZ.useCallback(()=>Q.call("listTranslations",{pageId:q.id}).then(W).catch((I)=>z(IX(I))),[Q,q.id,z]);NZ.useEffect(()=>{L()},[L]);let O=async()=>{try{await Q.call("createTranslation",{pageId:q.id,locale:K}),A(""),L()}catch(I){z(IX(I))}};return P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Translations"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:_.map((I)=>P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:I.locale},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",I.slug]},void 0,!0,void 0,this),P.jsxDEV(hz,{status:I.status,children:I.status},void 0,!1,void 0,this)]},I.id,!0,void 0,this))},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex items-end gap-1.5",children:[P.jsxDEV(xY,{label:"",value:K,onChange:A,placeholder:"locale (e.g. cs)"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",onPress:O,isDisabled:!K,children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function iv({api:Q,pageId:q,onError:z}){let[_,W]=NZ.useState([]);return NZ.useEffect(()=>{Q.listPageAudit(q).then(W).catch((K)=>z(IX(K)))},[Q,q,z]),P.jsxDEV("div",{children:[P.jsxDEV(KH,{children:"Audit trail"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((K)=>P.jsxDEV("div",{className:`${xW} text-xs`,children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:K.action},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:[K.fromStatus," → ",K.toStatus]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:K.actor??"system"},void 0,!1,void 0,this)]},K.id,!0,void 0,this)),_.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No history yet."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function IP({api:Q,onError:q}){let[z,_]=NZ.useState([]),[W,K]=NZ.useState(0),[A,L]=NZ.useState(!1),[O,I]=NZ.useState(null),[N,M]=NZ.useState(!1),R=NZ.useCallback((h)=>{Q.listMedia(AP,h).then((d)=>{_((b)=>h===0?d:[...b,...d]),L(d.length===AP),K(h+d.length)}).catch((d)=>q(IX(d)))},[Q,q]);NZ.useEffect(()=>{R(0)},[R]);let j=async(h)=>{if(!h?.length)return;M(!0),q("");try{for(let d of Array.from(h))await Q.uploadMedia(d);R(0)}catch(d){q(IX(d))}finally{M(!1)}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Media",em:z.length===0?"None yet":z.length===1?"1 file":`${z.length}${A?"+":""} files`,children:P.jsxDEV(n5,{text:"Let's",em:"upload something",children:P.jsxDEV("label",{className:`inline-flex shrink-0 cursor-pointer items-center rounded-full bg-surface-inverted px-6 py-3 text-compact text-fg-inverted ${N?"pointer-events-none opacity-50":""}`,children:[N?"Uploading…":"+ Upload",P.jsxDEV("input",{type:"file",multiple:!0,hidden:!0,disabled:N,onChange:(h)=>{j(h.target.files),h.target.value=""}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:[z.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No media yet. Upload images to use them in blocks and SEO."},void 0,!1,void 0,this):P.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:z.map((h)=>P.jsxDEV("div",{className:`cursor-pointer overflow-hidden rounded-lg border bg-surface-card ${O?.id===h.id?"border-fg":"border-border"}`,onClick:()=>I(h),children:[VP(h)?P.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:Q.resolve(`/media/${h.file.key}`),alt:h.alt??""},void 0,!1,void 0,this):P.jsxDEV("div",{className:"flex h-[130px] items-center justify-center bg-surface-muted font-mono text-xs text-fg-subtle",children:RP(h)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:h.file.filename??h.id},void 0,!1,void 0,this)]},h.id,!0,void 0,this))},void 0,!1,void 0,this),A?P.jsxDEV("div",{className:"mt-3.5 text-center",children:P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>R(W),children:"Load more"},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,O?P.jsxDEV(nv,{api:Q,media:O,onClose:()=>I(null),onSaved:(h)=>{I(h),_((d)=>d.map((b)=>b.id===h.id?h:b))},onDeleted:(h)=>{I(null),_((d)=>d.filter((b)=>b.id!==h))},onError:q},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function nv({api:Q,media:q,onClose:z,onSaved:_,onDeleted:W,onError:K}){let[A,L]=NZ.useState(q.alt??""),[O,I]=NZ.useState(!1);NZ.useEffect(()=>L(q.alt??""),[q]);let N=Q.resolve(`/media/${q.file.key}`),M=async()=>{I(!0);try{_(await Q.updateMedia(q.id,A||null))}catch(j){K(IX(j))}finally{I(!1)}},R=async()=>{if(!confirm("Delete this file permanently? If a block or page still references it, that image will break — this cannot be undone."))return;I(!0);try{await Q.deleteMedia(q.id),W(q.id)}catch(j){K(IX(j))}finally{I(!1)}};return P.jsxDEV(s5,{onClose:z,wide:!0,children:[P.jsxDEV(a5,{children:[P.jsxDEV(JF,{children:"Media"},void 0,!1,void 0,this)," ",q.file.filename??""]},void 0,!0,void 0,this),VP(q)?P.jsxDEV("img",{className:"mx-auto mb-3.5 block max-h-[340px] max-w-full rounded-lg bg-surface-muted object-contain",src:N,alt:q.alt??""},void 0,!1,void 0,this):P.jsxDEV("div",{className:"mb-3.5 flex h-[200px] items-center justify-center rounded-lg bg-surface-muted font-mono text-fg-subtle",children:RP(q)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-4",children:P.jsxDEV(xY,{label:"Alt text (for accessibility & SEO)",value:A,onChange:L,placeholder:"Describe the image…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Type"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q.file.contentType??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Size"},void 0,!1,void 0,this),P.jsxDEV("span",{children:ev(q.file.size)},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Uploaded"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q.file.uploadedAt?new Date(q.file.uploadedAt).toLocaleString():q.createdAt??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"URL"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"break-all",children:P.jsxDEV("a",{className:"underline underline-offset-2",href:N,target:"_blank",rel:"noreferrer",children:["/media/",q.file.key]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"mt-3.5 flex items-center gap-2",children:[P.jsxDEV(yZ,{onPress:M,isDisabled:O||A===(q.alt??""),children:"Save"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>navigator.clipboard?.writeText(N),children:"Copy URL"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",className:"text-danger",onPress:R,isDisabled:O,children:"Delete"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",onPress:z,children:"Close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function sv(Q){let q=Q.roles;if(Array.isArray(q))return q.filter((z)=>typeof z==="string");if(typeof q==="string")try{let z=JSON.parse(q);return Array.isArray(z)?z:[]}catch{return[]}return[]}function TP({api:Q,me:q,onError:z}){let[_,W]=NZ.useState([]),[K,A]=NZ.useState(!1),[L,O]=NZ.useState(""),I=NZ.useCallback(()=>{Q.call("listUsers",{limit:200}).then(W).catch((j)=>z(IX(j)))},[Q,z]);NZ.useEffect(()=>{I()},[I]);let N=async(j,h)=>{O(j.username);try{await Q.call("setUserRoles",{username:j.username,roles:h}),I()}catch(d){z(IX(d))}finally{O("")}},M=async(j,h)=>{O(j.username);try{await Q.call("setUserActive",{username:j.username,active:h}),I()}catch(d){z(IX(d))}finally{O("")}},R=async(j)=>{if(!confirm(`Delete user ${j.username}? This cannot be undone.`))return;O(j.username);try{await Q.call("deleteUser",{username:j.username}),I()}catch(h){z(IX(h))}finally{O("")}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Users",em:_.length===0?"None yet":_.length===1?"1 account":`${_.length} accounts`,children:P.jsxDEV(n5,{text:"Let's",em:"invite someone",children:P.jsxDEV(yZ,{className:"shrink-0",onPress:()=>A(!0),children:"+ Invite"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P.jsxDEV("div",{className:qF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((j)=>{let h=sv(j),d=q?.userId===j.username,b=j.active===void 0||j.active===null?!0:Boolean(Number(j.active));return P.jsxDEV("div",{className:`${xW} flex-wrap items-start`,children:[P.jsxDEV("div",{className:"flex min-w-[200px] flex-1 flex-col gap-0.5",children:[P.jsxDEV("span",{className:"font-semibold",children:[j.username,d?P.jsxDEV("span",{className:"ml-1.5 font-normal text-fg-subtle",children:"(you)"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),j.email&&j.email!==j.username?P.jsxDEV("span",{className:"text-xs text-fg-subtle",children:j.email},void 0,!1,void 0,this):null,j.createdAt?P.jsxDEV("span",{className:"text-[11px] text-fg-subtle",children:["joined ",new Date(Number(j.createdAt)).toLocaleDateString()]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),P.jsxDEV(av,{value:h,disabled:L===j.username,onSave:(a)=>N(j,a)},void 0,!1,void 0,this),P.jsxDEV(hz,{status:b?"active":"inactive",children:b?"active":"inactive"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:L===j.username||d,onPress:()=>M(j,!b),children:b?"Deactivate":"Activate"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",isDisabled:L===j.username||d,onPress:()=>R(j),children:"Delete"},void 0,!1,void 0,this)]},j.username,!0,void 0,this)}),_.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"No users yet. Invite someone to get started."},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this),K?P.jsxDEV(ov,{api:Q,onClose:()=>A(!1),onInvited:()=>{A(!1),I()},onError:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function av({value:Q,disabled:q,onSave:z}){let[_,W]=NZ.useState(Q.join(", ")),[K,A]=NZ.useState(!1);NZ.useEffect(()=>{W(Q.join(", "))},[Q]);let L=()=>{A(!1);let O=_.split(",").map((I)=>I.trim()).filter(Boolean);if(O.length===0){W(Q.join(", "));return}if(O.length===Q.length&&O.every((I,N)=>I===Q[N]))return;z(O)};if(K)return P.jsxDEV("input",{autoFocus:!0,className:"h-10 w-[220px] rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none focus:border-brand-green",value:_,disabled:q,onChange:(O)=>W(O.target.value),onBlur:L,onKeyDown:(O)=>{if(O.key==="Enter")L();if(O.key==="Escape")W(Q.join(", ")),A(!1)}},void 0,!1,void 0,this);return P.jsxDEV("span",{className:"flex cursor-pointer flex-wrap gap-1",onClick:()=>A(!0),title:"Click to edit",children:Q.length===0?P.jsxDEV(hz,{children:"no roles"},void 0,!1,void 0,this):Q.map((O)=>P.jsxDEV(hz,{status:O==="admin"?"published":void 0,children:O},O,!1,void 0,this))},void 0,!1,void 0,this)}function ov({api:Q,onClose:q,onInvited:z,onError:_}){let[W,K]=NZ.useState(""),[A,L]=NZ.useState("editor"),[O,I]=NZ.useState(!1);return P.jsxDEV(s5,{onClose:q,children:[P.jsxDEV(a5,{children:["Invite an ",P.jsxDEV(JF,{children:"editor"},void 0,!1,void 0,this)," or teammate"]},void 0,!0,void 0,this),P.jsxDEV("p",{className:"-mt-2 mb-4 text-fg-subtle",children:"They'll get a one-time magic link that logs them in and creates their account."},void 0,!1,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(xY,{label:"Email",type:"email",autoFocus:!0,value:W,onChange:K,placeholder:"them@example.com"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Roles (comma-separated — e.g. editor, reviewer, admin)",value:A,onChange:L,placeholder:"editor"},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mt-2 flex justify-end gap-2",children:[P.jsxDEV(yZ,{variant:"ghost",onPress:q,children:"Cancel"},void 0,!1,void 0,this),P.jsxDEV(yZ,{onPress:async()=>{I(!0);try{let M=A.split(",").map((R)=>R.trim()).filter(Boolean);await Q.call("inviteUser",{email:W,roles:M}),z()}catch(M){_(IX(M))}finally{I(!1)}},isDisabled:O||!W,children:O?"Sending…":"Send invite"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wP({api:Q,cfg:q,me:z,onSignOut:_,onError:W}){return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(GF,{lead:"Settings",em:z?.userId??"your account"},void 0,!1,void 0,this),P.jsxDEV("div",{className:`${qF} grid grid-cols-2 gap-5 max-[820px]:grid-cols-1`,children:[P.jsxDEV(rv,{api:Q,me:z,onError:W,onSignOut:_},void 0,!1,void 0,this),P.jsxDEV(tv,{cfg:q,me:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function rv({api:Q,me:q,onError:z,onSignOut:_}){let[W,K]=NZ.useState(""),[A,L]=NZ.useState(""),[O,I]=NZ.useState(""),[N,M]=NZ.useState(""),[R,j]=NZ.useState(!1),h=(a)=>{M(a),setTimeout(()=>M(""),1800)},d=async()=>{j(!0);try{await Q.call("changeEmail",{email:W}),K(""),h("Contact email updated")}catch(a){z(IX(a))}finally{j(!1)}},b=async()=>{j(!0);try{await Q.call("changePassword",{currentPassword:A,newPassword:O}),L(""),I(""),h("Password updated")}catch(a){z(IX(a))}finally{j(!1)}};return P.jsxDEV(FP,{children:[P.jsxDEV(KH,{children:"My account"},void 0,!1,void 0,this),N?P.jsxDEV(o5,{ok:!0,children:N},void 0,!1,void 0,this):null,P.jsxDEV(HF,{className:"mb-4",children:[P.jsxDEV("span",{children:"Username"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q?.userId??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Roles"},void 0,!1,void 0,this),P.jsxDEV("span",{children:(q?.roles??[]).join(", ")||"—"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.jsxDEV("div",{className:"flex flex-col gap-4",children:[P.jsxDEV(xY,{label:"Change contact email",type:"email",value:W,onChange:K,placeholder:"you@example.com"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:d,isDisabled:R||!W,children:"Save email"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"Current password",type:"password",value:A,onChange:L,autoComplete:"current-password"},void 0,!1,void 0,this),P.jsxDEV(xY,{label:"New password (at least 8 characters)",type:"password",value:O,onChange:I,autoComplete:"new-password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:b,isDisabled:R||O.length<8||A.length===0,children:"Change password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",className:"mt-2 w-full text-danger",onPress:_,children:"Sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function tv({cfg:Q,me:q}){return P.jsxDEV(FP,{children:[P.jsxDEV(KH,{children:"About"},void 0,!1,void 0,this),P.jsxDEV(HF,{children:[P.jsxDEV("span",{children:"Tenant"},void 0,!1,void 0,this),P.jsxDEV("span",{children:Q.tenant||"main"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"API"},void 0,!1,void 0,this),P.jsxDEV("span",{className:"break-all",children:Q.baseUrl},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Signed in as"},void 0,!1,void 0,this),P.jsxDEV("span",{children:q?.userId??"—"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Editor"},void 0,!1,void 0,this),P.jsxDEV("span",{children:"pramen · cms-editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function VP(Q){return(Q.file.contentType??"").startsWith("image/")}function RP(Q){let q=(Q.file.contentType??"").split("/")[1];return(Q.file.filename?.split(".").pop()??q??"file").slice(0,5).toUpperCase()}function ev(Q){if(!Q||Q<=0)return"—";let q=["B","KB","MB","GB"],z=0,_=Q;while(_>=1024&&z<q.length-1)_/=1024,z++;return`${_<10&&z>0?_.toFixed(1):Math.round(_)} ${q[z]}`}function IX(Q){if(Q instanceof EW)return Q.message;return Q instanceof Error?Q.message:String(Q)}function OP(Q){return Q.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Zh(Q){return Q.replace(/<[^>]*>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/\s+/g," ").trim()}function Xh(Q){let q=Object.values(Q).find((_)=>typeof _==="string"&&_.trim());if(typeof q!=="string")return"";let z=Zh(q);return z.length>90?z.slice(0,90)+"…":z}function Yh(Q,q,z,_,W){let K=z+_;if(K<0||K>=Q.length)return;let A=Q.map((L)=>L.id);[A[z],A[K]]=[A[K],A[z]],W(q,A)}var NZ,P,i5,xW="flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",qF="mx-auto max-w-[1200px] px-7 pb-8 pt-2",JF=({children:Q})=>P.jsxDEV("span",{className:"text-fg-subtle",children:Q},void 0,!1,void 0,this),AP=60;var yW=C(()=>{WH();d5();LP();NZ=f(ZZ(),1),P=f($Z(),1),i5=["settings","seo","workflow","i18n","audit"]});var jP={};p_(jP,{default:()=>Qh});var qB,CP,Qh;var PP=C(()=>{Hq();UH();yW();qB=f(ZZ(),1),CP=f($Z(),1),Qh=kQ().route("/").render(function(){let{api:q,setError:z}=_J(),_=XJ(),[W,K]=qB.useState([]),[A,L]=qB.useState([]),O=()=>q.listPages().then(K).catch((I)=>z(IX(I)));return qB.useEffect(()=>{O(),q.listBlockTypes().then(L).catch((I)=>z(IX(I)))},[q]),CP.jsxDEV(MP,{api:q,pages:W,blockTypes:A,onOpen:(I)=>_("page",{params:{pageId:I.id}}),onCreated:O,onError:z},void 0,!1,void 0,this)})});var DP={};p_(DP,{default:()=>Jh});var $P,Jh;var SP=C(()=>{Hq();UH();yW();$P=f($Z(),1),Jh=kQ().route("/media").render(function(){let{api:q,setError:z}=_J();return $P.jsxDEV(IP,{api:q,onError:z},void 0,!1,void 0,this)})});var EP={};p_(EP,{default:()=>qh});var vW,bz,qh;var kP=C(()=>{Hq();WH();UH();yW();vW=f(ZZ(),1),bz=f($Z(),1),qh=kQ().params({pageId:"string",tab:"?string"}).route("/pages/:pageId").render(function({params:q}){let{api:z,setError:_}=_J(),W=XJ(),[K,A]=vW.useState(null),[L,O]=vW.useState([]),[I,N]=vW.useState(!1);vW.useEffect(()=>{let j=!0;return N(!1),z.listPages().then((h)=>{if(!j)return;let d=h.find((b)=>b.id===q.pageId)??null;A(d),N(!d)}).catch((h)=>_(IX(h))),z.listBlockTypes().then((h)=>j&&O(h)).catch((h)=>_(IX(h))),()=>{j=!1}},[z,q.pageId,_]);let M=i5.includes(q.tab)?q.tab:"settings",R=(j)=>W("page",{params:{pageId:q.pageId,tab:j},replace:!0});if(I)return bz.jsxDEV("div",{className:"mx-auto flex max-w-[1200px] items-center gap-2 px-7 pt-8",children:[bz.jsxDEV("p",{className:"text-fg-subtle",children:"Page not found."},void 0,!1,void 0,this),bz.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>W("home"),children:"← all pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(!K)return bz.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:bz.jsxDEV("p",{className:"text-fg-subtle",children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return bz.jsxDEV(NP,{api:z,page:K,blockTypes:L,tab:M,onTab:R,onBack:()=>W("home"),onChange:A},void 0,!1,void 0,this)})});var xP={};p_(xP,{default:()=>Gh});var yP,Gh;var vP=C(()=>{Hq();UH();yW();yP=f($Z(),1),Gh=kQ().route("/settings").render(function(){let{api:q,cfg:z,me:_,setError:W,reconfigure:K}=_J();return yP.jsxDEV(wP,{api:q,cfg:z,me:_,onSignOut:K,onError:W},void 0,!1,void 0,this)})});var hP={};p_(hP,{default:()=>Hh});var gz,Hh;var bP=C(()=>{Hq();WH();UH();yW();gz=f($Z(),1),Hh=kQ().route("/users").render(function(){let{api:q,me:z,isAdmin:_,setError:W}=_J(),K=XJ();if(z===null)return gz.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:gz.jsxDEV("p",{className:"text-fg-subtle",children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!_)return gz.jsxDEV("div",{className:"mx-auto flex max-w-[1200px] items-center gap-2 px-7 pt-8",children:[gz.jsxDEV("p",{className:"text-fg-subtle",children:"Admins only."},void 0,!1,void 0,this),gz.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>K("home"),children:"← back to pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return gz.jsxDEV(TP,{api:q,me:z,onError:W},void 0,!1,void 0,this)})});var gP={};p_(gP,{default:()=>zh});var BH,zh;var mP=C(()=>{Hq();WH();BH=f($Z(),1),zh=kQ().render(function(){let q=XJ();return BH.jsxDEV("div",{className:"mx-auto max-w-[1200px] px-7 pt-8",children:[BH.jsxDEV("h1",{className:"m-0 text-[56px] font-normal leading-[1.05] tracking-[-0.01em] max-[820px]:text-[40px]",children:[BH.jsxDEV("span",{className:"block text-fg-subtle",children:"Not found"},void 0,!1,void 0,this),BH.jsxDEV("span",{className:"block text-fg",children:"Nothing lives here"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BH.jsxDEV("div",{className:"mt-4 flex items-center gap-2",children:[BH.jsxDEV("p",{className:"text-fg-subtle",children:"That page doesn't exist."},void 0,!1,void 0,this),BH.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>q("home"),children:"← back to pages"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})});Hq();var nP=f(ZZ(),1),sP=f(Z2(),1);Hq();var mz=f(ZZ(),1);Hq();WH();UH();var TY=f($Z(),1);function p5(){let{cfg:Q,isAdmin:q,error:z,reconfigure:_}=_J(),W=XJ(),{pathname:K}=SA(),A=K.startsWith("/pages")||K==="/"?"pages":K.startsWith("/media")?"media":K.startsWith("/users")?"users":K.startsWith("/settings")?"settings":"",L=(I)=>A===I?"bg-surface-muted text-fg":"text-fg-muted",O=typeof window<"u"?window.PRAMEN_CMS_EDITOR?.extraNav??[]:[];return TY.jsxDEV(TY.Fragment,{children:[TY.jsxDEV("div",{className:"sticky top-0 z-10 flex items-center gap-4 bg-surface px-7 py-4",children:[TY.jsxDEV("span",{className:"text-[15px] font-bold tracking-[0.01em] text-fg",children:["pramen ",TY.jsxDEV("span",{className:"font-normal text-fg-subtle",children:"· cms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TY.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),TY.jsxDEV("nav",{className:"flex items-center gap-0.5",children:[TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("pages"),onPress:()=>W("home"),children:"Pages"},void 0,!1,void 0,this),TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("media"),onPress:()=>W("media"),children:"Media"},void 0,!1,void 0,this),q?TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("users"),onPress:()=>W("users"),children:"Users"},void 0,!1,void 0,this):null,TY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("settings"),onPress:()=>W("settings"),children:"Settings"},void 0,!1,void 0,this),O.map((I)=>TY.jsxDEV("a",{href:I.href,target:"_blank",rel:"noopener noreferrer",className:"rounded-md px-2.5 py-1.5 text-sm text-fg-muted transition-colors hover:bg-surface-muted hover:text-fg",children:I.label},I.href,!1,void 0,this))]},void 0,!0,void 0,this),TY.jsxDEV("span",{className:"ml-3 text-fg-subtle",children:Q.tenant},void 0,!1,void 0,this),TY.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:_,children:"sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z?TY.jsxDEV("div",{className:"mx-7 mt-2 rounded-lg border border-danger bg-surface-card px-4 py-2.5 text-sm text-danger",children:z},void 0,!1,void 0,this):null,TY.jsxDEV(a_,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var fP=()=>Promise.resolve().then(() => (PP(),jP)).then((Q)=>({default:Q.default.component})),uP=()=>Promise.resolve().then(() => (SP(),DP)).then((Q)=>({default:Q.default.component})),dP=()=>Promise.resolve().then(() => (kP(),EP)).then((Q)=>({default:Q.default.component})),cP=()=>Promise.resolve().then(() => (vP(),xP)).then((Q)=>({default:Q.default.component})),pP=()=>Promise.resolve().then(() => (bP(),hP)).then((Q)=>({default:Q.default.component})),lP=()=>Promise.resolve().then(() => (mP(),gP)).then((Q)=>({default:Q.default.component})),r5={home:"/",media:"/media",page:"/pages/:pageId",settings:"/settings",users:"/users"},_h=[{path:"/",component:p5,isLayout:!0,children:[{path:"/home",matchPath:"/",component:mz.lazy(fP),preload:fP},{path:"/media",component:mz.lazy(uP),preload:uP},{path:"/page",matchPath:"/pages/:pageId",component:mz.lazy(dP),preload:dP},{path:"/settings",component:mz.lazy(cP),preload:cP},{path:"/users",component:mz.lazy(pP),preload:pP},{path:"/:__notFound+",component:mz.lazy(lP),preload:lP}]}],t5=a9(_h);UH();var zF=f($Z(),1),iP=document.getElementById("app");if(iP)sP.createRoot(iP).render(zF.jsxDEV(nP.StrictMode,{children:zF.jsxDEV(KP,{children:zF.jsxDEV($A,{routes:t5,pageRegistry:r5},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pramen/cms-editor",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "Visual block/page editor for @pramen/cms — a standalone React SPA that talks to the CMS handlers over HTTP.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -139,14 +139,27 @@ function CreatePage({ api, onClose, onCreated, onError }: { api: Api; onClose: (
139
139
  <Modal onClose={onClose}>
140
140
  <ModalTitle>Create a <Dim>new page</Dim> and define the essentials<Dim>.</Dim></ModalTitle>
141
141
  <div className="flex flex-col gap-4">
142
- <label className="flex w-full flex-col gap-2">
142
+ <div className="flex w-full flex-col gap-2">
143
143
  <span className="text-sm font-medium text-fg">Content type</span>
144
- <select className="h-10 w-full rounded-lg border border-border bg-surface-card px-4 text-sm text-fg outline-none focus:border-brand-green" value={typeId} onChange={(e) => setTypeId(e.target.value)}>
144
+ {/* Visible cards, not a dropdown: the type is an easy-to-miss choice, and picking the
145
+ wrong one puts the entry under a different route. Cards make the selection deliberate. */}
146
+ <div className="flex flex-wrap gap-2">
145
147
  {cts.map((c) => (
146
- <option key={c.id} value={c.id}>{c.name}</option>
148
+ <button
149
+ key={c.id}
150
+ type="button"
151
+ onClick={() => setTypeId(c.id)}
152
+ className={`rounded-lg border px-4 py-2.5 text-sm font-medium transition-colors ${
153
+ typeId === c.id
154
+ ? "border-brand-green bg-surface-muted text-fg"
155
+ : "border-border bg-surface-card text-fg-muted hover:border-fg-subtle hover:text-fg"
156
+ }`}
157
+ >
158
+ {c.name}
159
+ </button>
147
160
  ))}
148
- </select>
149
- </label>
161
+ </div>
162
+ </div>
150
163
  <Input label="Title" value={title} onChange={setTitle} />
151
164
  <Input label="Slug" value={slug} onChange={setSlug} placeholder={slugify(title)} />
152
165
  <div className="mt-2 flex justify-end gap-2">