@pramen/cms-editor 0.0.25 → 0.0.26
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
|
@@ -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} />`,jZ,FZ,YX,FZ),s[FZ+jZ]=!0)}if(FZ=null,TZ!==void 0&&(z(TZ),FZ=""+TZ),A(t)&&(z(t.key),FZ=""+t.key),"key"in t){TZ={};for(var TX in t)TX!=="key"&&(TZ[TX]=t[TX])}else TZ=t;return FZ&&L(TZ,typeof V==="function"?V.displayName||V.name||"Unknown":V),T(V,FZ,TZ,W(),xZ,JX)}function M(V){R(V)?V._store&&(V._store.validated=1):typeof V==="object"&&V!==null&&V.$$typeof===b&&(V._payload.status==="fulfilled"?R(V._payload.value)&&V._payload.value._store&&(V._payload.value._store.validated=1):V._store&&(V._store.validated=1))}function R(V){return typeof V==="object"&&V!==null&&V.$$typeof===j}var j=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),JZ=Symbol.for("react.context"),qZ=Symbol.for("react.forward_ref"),IZ=Symbol.for("react.suspense"),mZ=Symbol.for("react.suspense_list"),QZ=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),AZ=Symbol.for("react.activity"),a=Symbol.for("react.client.reference"),LZ=vz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,WZ=Object.prototype.hasOwnProperty,zZ=Array.isArray,y=console.createTask?console.createTask:function(){return null};vz={react_stack_bottom_frame:function(V){return V()}};var u,c={},p=vz.react_stack_bottom_frame.bind(vz,K)(),KZ=y(_(K)),s={};Wv.Fragment=f,Wv.jsxDEV=function(V,t,TZ,jZ){var xZ=1e4>LZ.recentlyCreatedOwnerStacks++;return N(V,t,TZ,jZ,xZ?Error("react-stack-top-frame"):p,xZ?y(_(V)):KZ)}})()});var $W,Uv,kY=({label:J,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:J},void 0,!1,void 0,this),$W.jsxDEV(Uv,{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=g(PZ(),1),Uv=gZ(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,Kv,ZF=({label:J,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:J},void 0,!1,void 0,this),SW.jsxDEV(Kv,{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=g(PZ(),1),Kv=gZ(v5,{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=g(PZ(),1)});var Bv;var gC=C(()=>{Bv=g(PZ(),1)});var Lv;var mC=C(()=>{Lv=g(PZ(),1)});var Av,xYZ,yYZ;var fC=C(()=>{zJ();FY();Av=g(PZ(),1),xYZ=gZ(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"}),yYZ=gZ(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,uYZ,dYZ;var dC=C(()=>{zJ();FY();uC=g(PZ(),1),uYZ=gZ(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"}),dYZ=gZ(j5,{displayName:"DialogModal",baseClass:"rounded-lg bg-surface p-5 outline-none shadow-[0px_2px_8px_0px_rgba(0,0,0,0.06)]"})});var Fv,iYZ,nYZ;var cC=C(()=>{zJ();FY();Fv=g(PZ(),1),iYZ=gZ(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"}}}),nYZ=gZ(z6,{displayName:"DropdownMenuSeparator",baseClass:"my-2 h-px border-0 bg-border"})});var XF,pC,rYZ;var lC=C(()=>{zJ();FY();XF=g(e(),1),pC=g(PZ(),1),rYZ=gZ(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 Mv;var f5=C(()=>{Mv=g(PZ(),1)});var iC,JQZ;var nC=C(()=>{zJ();iC=g(PZ(),1),JQZ=new QB({maxVisibleToasts:5})});var zQZ,_QZ;var sC=C(()=>{zJ();FY();zQZ=gZ(N5,{displayName:"Disclosure"}),_QZ=gZ(I5,{displayName:"DisclosurePanel"})});var BQZ,LQZ,AQZ;var aC=C(()=>{zJ();FY();BQZ=gZ(k5,{displayName:"TabList",baseClass:"flex gap-2 border-b border-border"}),LQZ=gZ(x5,{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"}),AQZ=gZ(y5,{displayName:"TabPanel",baseClass:"py-4 text-sm text-fg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"})});var Nv;var oC=C(()=>{g5();Nv=g(PZ(),1)});var Iv;var rC=C(()=>{Iv=g(PZ(),1)});var TQZ,wQZ;var tC=C(()=>{FY();TQZ=gZ("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"}}),wQZ=gZ("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 Tv;var eC=C(()=>{f5();Tv=g(PZ(),1)});var $QZ;var ZD=C(()=>{FY();$QZ=gZ("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 kQZ;var XD=C(()=>{FY();kQZ=gZ("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 vQZ;var YD=C(()=>{FY();vQZ=gZ("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 QD,wv,gQZ,mQZ,fQZ;var JD=C(()=>{FY();QD=g(e(),1),wv=g(PZ(),1),gQZ=gZ("div",{displayName:"AppShell",baseClass:"grid h-screen w-full overflow-hidden bg-surface grid-rows-[100%] grid-cols-[1fr] md:grid-cols-[auto_1fr]"}),mQZ=gZ("aside",{displayName:"AppShell.Sidebar",baseClass:"h-full w-64 shrink-0 overflow-y-auto border-r border-border bg-surface"}),fQZ=gZ("main",{displayName:"AppShell.Main",baseClass:"min-w-0 flex-1 bg-surface px-6 pb-6 pt-6"})});var qD,Vv,Rv,jv,Cv=(J)=>qD.jsxDEV(jv,{...J},void 0,!1,void 0,this),Dv,Pv,lQZ,iQZ,nQZ;var GD=C(()=>{zJ();FY();qD=g(PZ(),1),Vv=gZ("header",{displayName:"Topbar",baseClass:"flex h-14 w-full items-center gap-5 border-b border-border"}),Rv=gZ("div",{displayName:"Topbar.Brand",baseClass:"flex min-w-0 items-center gap-3 text-compact leading-4 font-medium tracking-tight text-fg"}),jv=gZ("nav",{displayName:"Topbar.Nav",baseClass:"ml-auto flex min-w-0 items-center gap-2 overflow-x-auto"}),Dv=gZ("div",{displayName:"Topbar.Actions",baseClass:"ml-auto flex items-center gap-4"}),Pv=gZ("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"]}),lQZ=gZ(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"}),iQZ=gZ(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"}),nQZ=Object.assign(Vv,{Brand:Rv,Nav:Cv,NavLink:Pv,Actions:Dv})});var $v,Sv,oQZ;var HD=C(()=>{FY();$v=g(e(),1),Sv=g(PZ(),1),oQZ=gZ("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();g5();yC();vC();bC();gC();mC();fC();dC();cC();lC();f5();nC();sC();aC();oC();rC();tC();eC();ZD();XD();YD();JD();GD();HD()});function YF(J){try{let q=String(J).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 zD(){try{let J=localStorage.getItem(u5);if(J)return JSON.parse(J)}catch{}return{baseUrl:"http://localhost:8787",token:"",tenant:"main"}}function _D(J){localStorage.setItem(u5,JSON.stringify(J))}function WD(){try{localStorage.removeItem(u5)}catch{}}class d5{cfg;onExpired;constructor(J,q){this.cfg=J;this.onExpired=q}setConfig(J){this.cfg=J}base(){return this.cfg.baseUrl.replace(/\/+$/,"")}async call(J,q){if(this.onExpired&&this.cfg.token&&YF(this.cfg.token))return this.onExpired(),new Promise(()=>{});let z=await fetch(`${this.base()}/rpc/${J}`,{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(J,q,z){let _=J.startsWith("http")?J:`${this.base()}${J}`,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(J){return J.startsWith("http")?J:`${this.base()}${J}`}listBlockTypes=()=>this.call("listBlockTypes");listContentTypes=()=>this.call("listContentTypes");getContentType=(J)=>this.call("getContentType",{id:J});listPages=()=>this.call("listPages");getPagePreview=(J,q)=>this.call("getPage",{slug:J,locale:q,preview:!0});listPageAudit=(J)=>this.call("listPageAudit",{pageId:J});listMedia=(J=50,q=0)=>this.call("listMedia",{limit:J,offset:q});getMedia=(J)=>this.call("getMedia",{id:J});updateMedia=(J,q)=>this.call("updateMedia",{id:J,alt:q});deleteMedia=(J)=>this.call("deleteMedia",{id:J});async uploadMedia(J){let q=J.type||"application/octet-stream",z=await this.call("signMediaUpload",{contentType:q,filename:J.name});return await this.put(z.url,await J.arrayBuffer(),q),this.call("createMedia",{ref:z.ref,alt:J.name})}}var EW,u5="pramen.cmsEditor";var c5=C(()=>{EW=class EW extends Error{code;status;constructor(J,q,z){super(J);this.code=q;this.status=z;this.name="ApiError"}}});function p5(){WD(),location.replace(JB)}function _J(){let J=UQ.use(UD);if(!J)throw Error("useApp must be used within <AppProvider>");return J}function KD({children:J}){let[q,z]=UQ.useState(zD()),[_,W]=UQ.useState(null),[K,A]=UQ.useState(""),L=Boolean(q.baseUrl&&q.token)&&!YF(q.token),F=UQ.useMemo(()=>new d5(q,JB?p5:void 0),[q]);if(UQ.useEffect(()=>{if(!JB)return;let N=()=>{if(!q.token||YF(q.token))p5()};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]),UQ.useEffect(()=>{if(!L)return;F.call("me").then(W).catch(()=>W({}))},[F,L]),!L)return JB?null:WQ.jsxDEV(Ev,{cfg:q,onSave:(N)=>{_D(N),z(N)}},void 0,!1,void 0,this);let T={api:F,cfg:q,me:_,isAdmin:(_?.roles??[]).includes("admin"),error:K,setError:A,reconfigure:()=>{if(JB){p5();return}W(null),A(""),z({...q,token:""})}};return WQ.jsxDEV(UD,{value:T,children:J},void 0,!1,void 0,this)}function Ev({cfg:J,onSave:q}){let[z,_]=UQ.useState(J);return WQ.jsxDEV("div",{className:"mx-auto mt-[14vh] w-full max-w-[520px] px-6",children:WQ.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:[WQ.jsxDEV("h1",{className:"mb-4 text-display text-fg",children:["pramen ",WQ.jsxDEV("span",{className:"text-fg-subtle",children:"· cms editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),WQ.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 (",WQ.jsxDEV("code",{children:"CORS_ORIGINS"},void 0,!1,void 0,this),")."]},void 0,!0,void 0,this),WQ.jsxDEV("div",{className:"flex flex-col gap-4",children:[WQ.jsxDEV(kY,{label:"Worker base URL",value:z.baseUrl,onChange:(W)=>_({...z,baseUrl:W}),placeholder:"https://your-worker.workers.dev"},void 0,!1,void 0,this),WQ.jsxDEV(kY,{label:"Tenant",value:z.tenant,onChange:(W)=>_({...z,tenant:W}),placeholder:"main"},void 0,!1,void 0,this),WQ.jsxDEV(kY,{label:"Bearer token (editor or reviewer)",value:z.token,onChange:(W)=>_({...z,token:W}),placeholder:"eyJ…"},void 0,!1,void 0,this),WQ.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 UQ,WQ,JB,UD;var UH=C(()=>{WH();c5();UQ=g(e(),1),WQ=g(PZ(),1),JB=typeof window<"u"?window.PRAMEN_CMS_EDITOR?.signInUrl:void 0;UD=UQ.createContext(null)});function kW({label:J,children:q}){return NZ.jsxDEV("label",{className:"flex w-full flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:J},void 0,!1,void 0,this),q]},void 0,!0,void 0,this)}function QF({schema:J,value:q,onChange:z,api:_}){let W=(K,A)=>z({...q,[K]:A});return NZ.jsxDEV("div",{className:"flex flex-col gap-4",children:J.map((K)=>NZ.jsxDEV(kv,{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 kv({def:J,value:q,onChange:z,api:_}){let W=NZ.jsxDEV(NZ.Fragment,{children:[J.label??J.name," ",J.required?NZ.jsxDEV("span",{className:"text-danger",children:"*"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);switch(J.type){case"text":case"url":return NZ.jsxDEV(kY,{label:W,value:q??"",onChange:z,placeholder:J.type==="url"?"https://…":""},void 0,!1,void 0,this);case"textarea":return NZ.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 NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV(vv,{value:typeof q==="string"?q:"",onChange:z},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"number":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("input",{className:i5,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 NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("input",{className:i5,type:J.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 NZ.jsxDEV("label",{className:"flex items-center gap-2",children:[NZ.jsxDEV("input",{type:"checkbox",checked:Boolean(q),onChange:(K)=>z(K.target.checked)},void 0,!1,void 0,this),NZ.jsxDEV("span",{className:"text-sm text-fg",children:J.label??J.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this);case"select":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("select",{className:i5,value:q??"",onChange:(K)=>z(K.target.value||null),children:[NZ.jsxDEV("option",{value:"",children:"—"},void 0,!1,void 0,this),(J.options??[]).map((K)=>NZ.jsxDEV("option",{value:K,children:K},K,!1,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this);case"media":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV(bv,{value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"group":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:NZ.jsxDEV(QF,{schema:J.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 NZ.jsxDEV(hv,{def:J,value:q??[],onChange:z,api:_,label:W},void 0,!1,void 0,this);default:return null}}function yv(J){let q=J.trim();return/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(q)?q:null}function BD(J){return J.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 vv({value:J,onChange:q}){let z=gQ.useRef(null),_=gQ.useRef("");gQ.useEffect(()=>{let L=z.current;if(L&&J!==_.current)L.innerHTML=BD(J||""),_.current=J||""},[J]);let W=()=>{let L=BD(z.current?.innerHTML??"");_.current=L,q(L)},K=(L,F)=>{z.current?.focus(),document.execCommand(L,!1,F),W()},A=(L)=>{L.preventDefault(),document.execCommand("insertText",!1,L.clipboardData.getData("text/plain"))};return NZ.jsxDEV("div",{className:"overflow-hidden rounded-lg border border-border bg-surface-card",children:[NZ.jsxDEV("div",{className:"flex flex-wrap gap-0.5 border-b border-border bg-surface-muted px-2 py-1.5",children:xv.map((L)=>NZ.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:(F)=>F.preventDefault(),onClick:()=>L.run(K),children:L.label},L.label,!1,void 0,this))},void 0,!1,void 0,this),NZ.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 hv({def:J,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,{}]),F=(N)=>z(K.filter((M,R)=>R!==N)),T=(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 NZ.jsxDEV("div",{className:"flex flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:W},void 0,!1,void 0,this),K.map((N,M)=>NZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:[NZ.jsxDEV("div",{className:"mb-2 flex justify-end gap-1",children:[NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>T(M,-1),children:"↑"},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>T(M,1),children:"↓"},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>F(M),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),NZ.jsxDEV(QF,{schema:J.fields??[],value:N,onChange:(R)=>A(M,R),api:_},void 0,!1,void 0,this)]},M,!0,void 0,this)),NZ.jsxDEV(yZ,{variant:"secondary",size:"sm",className:"self-start",onPress:L,isDisabled:J.max!=null&&K.length>=J.max,children:["+ add ",J.label??J.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function bv({value:J,onChange:q,api:z}){let[_,W]=gQ.useState(!1),[K,A]=gQ.useState(null);return gQ.useEffect(()=>{if(J)z.call("getMedia",{id:J}).then(A).catch(()=>A(null));else A(null)},[J,z]),NZ.jsxDEV("div",{children:[NZ.jsxDEV("div",{className:"flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",children:[K?NZ.jsxDEV("img",{className:"h-10 w-10 rounded object-cover",src:z.resolve(`/media/${K.file.key}`),alt:""},void 0,!1,void 0,this):NZ.jsxDEV("span",{className:"text-fg-subtle",children:"no media"},void 0,!1,void 0,this),NZ.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:K?.file.filename??J??""},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"pick"},void 0,!1,void 0,this),J?NZ.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),_?NZ.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:J,onClose:q,onPick:z}){let[_,W]=gQ.useState([]),[K,A]=gQ.useState(!1),[L,F]=gQ.useState(""),T=()=>J.listMedia().then(W).catch((M)=>F(String(M.message??M)));gQ.useEffect(()=>{T()},[]);let N=async(M)=>{A(!0),F("");try{let R=await J.uploadMedia(M);z(R.id)}catch(R){F(String(R.message??R))}finally{A(!1)}};return NZ.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:NZ.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:[NZ.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal text-fg",children:["Choose ",NZ.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?NZ.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,NZ.jsxDEV("label",{className:"mb-4 flex w-full flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Upload a new file"},void 0,!1,void 0,this),NZ.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),NZ.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:_.map((M)=>NZ.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/")?NZ.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:J.resolve(`/media/${M.file.key}`),alt:""},void 0,!1,void 0,this):NZ.jsxDEV("div",{className:"h-[130px] bg-surface-muted"},void 0,!1,void 0,this),NZ.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),NZ.jsxDEV("div",{className:"mt-3 text-right",children:NZ.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 gQ,NZ,i5="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",xv;var LD=C(()=>{WH();gQ=g(e(),1),NZ=g(PZ(),1);xv=[{label:"B",title:"Bold",run:(J)=>J("bold")},{label:"I",title:"Italic",run:(J)=>J("italic")},{label:"H2",title:"Heading",run:(J)=>J("formatBlock","H2")},{label:"H3",title:"Subheading",run:(J)=>J("formatBlock","H3")},{label:"¶",title:"Paragraph",run:(J)=>J("formatBlock","P")},{label:"• List",title:"Bulleted list",run:(J)=>J("insertUnorderedList")},{label:"1. List",title:"Numbered list",run:(J)=>J("insertOrderedList")},{label:"Link",title:"Add link",run:(J)=>{let q=window.prompt("Link URL (https://, mailto:, /path)","https://");if(!q)return;let z=yv(q);if(!z){window.alert("Only http(s), mailto, tel, or relative (/, #) links are allowed.");return}J("createLink",z)}},{label:"Unlink",title:"Remove link",run:(J)=>J("unlink")},{label:"Clear",title:"Clear formatting",run:(J)=>J("removeFormat")}]});function HF({lead:J,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:J},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 s5({text:J,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:[J," ",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:J}){return P.jsxDEV("div",{className:"mb-2 mt-[18px] text-sm text-fg-subtle first:mt-0",children:J},void 0,!1,void 0,this)}function hz({status:J,children:q}){return P.jsxDEV("span",{className:`inline-block whitespace-nowrap rounded-full border px-2.5 py-0.5 text-[11px] font-medium ${J==="published"||J==="active"?"bg-brand-green text-[#0f3a25] border-transparent":J==="in_review"||J==="review"?"bg-accent-yellow text-[#4a3512] border-transparent":J==="rejected"||J==="archived"||J==="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 a5({onClose:J,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:J,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 o5({children:J}){return P.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal leading-[1.15] text-fg",children:J},void 0,!1,void 0,this)}function zF({children:J,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:J},void 0,!1,void 0,this)}function MD({children:J}){return P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-6",children:J},void 0,!1,void 0,this)}function JF({ok:J,children:q}){return P.jsxDEV("div",{className:`my-2 rounded-lg border px-3.5 py-2.5 text-[13px] ${J?"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 ND({api:J,pages:q,blockTypes:z,onOpen:_,onCreated:W,onError:K}){let[A,L]=EZ.useState(!1);return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Pages",em:q.length===0?"None yet":q.length===1?"1 page total":`${q.length} pages total`,children:P.jsxDEV(s5,{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:GF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[q.map((F)=>P.jsxDEV("div",{className:`${xW} cursor-pointer hover:bg-surface-muted`,onClick:()=>_(F),children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:F.title},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",F.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:F.locale},void 0,!1,void 0,this),P.jsxDEV(hz,{status:F.status,children:F.status},void 0,!1,void 0,this)]},F.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:J,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:J,onClose:q,onCreated:z,onError:_}){let[W,K]=EZ.useState([]),[A,L]=EZ.useState(""),[F,T]=EZ.useState(""),[N,M]=EZ.useState("");EZ.useEffect(()=>{J.listContentTypes().then((j)=>{if(K(j),j[0])L(j[0].id)}).catch((j)=>_(IX(j)))},[J,_]);let R=async()=>{try{await J.call("createPage",{typeId:A,title:F,slug:N||OD(F)}),z()}catch(j){_(IX(j))}};return P.jsxDEV(a5,{onClose:q,children:[P.jsxDEV(o5,{children:["Create a ",P.jsxDEV(qF,{children:"new page"},void 0,!1,void 0,this)," and define the essentials",P.jsxDEV(qF,{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(kY,{label:"Title",value:F,onChange:T},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"Slug",value:N,onChange:M,placeholder:OD(F)},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||!F,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 ID({api:J,page:q,blockTypes:z,tab:_,onTab:W,onBack:K,onChange:A}){let[L,F]=EZ.useState(null),[T,N]=EZ.useState(null),[M,R]=EZ.useState(null),[j,v]=EZ.useState(""),[f,h]=EZ.useState(""),n=EZ.useMemo(()=>new Map(z.map((b)=>[b.slug,b])),[z]),r=EZ.useCallback(async()=>{try{let[b,AZ]=await Promise.all([J.getContentType(q.typeId),J.getPagePreview(q.slug,q.locale)]);F(b??null),N(AZ)}catch(b){v(IX(b))}},[J,q.typeId,q.slug,q.locale]);EZ.useEffect(()=>{r(),R(null)},[r]);let JZ=L?.regions??[],qZ=(b)=>{h(b),setTimeout(()=>h(""),1800)},IZ=async(b,AZ)=>{try{await J.call("addBlock",{pageId:q.id,blockTypeSlug:AZ,region:b,fields:{}}),await r(),qZ("block added")}catch(a){v(IX(a))}},mZ=async(b)=>{try{if(await J.call("removeBlock",{pageBlockId:b.id}),M?.id===b.id)R(null);await r()}catch(AZ){v(IX(AZ))}},QZ=async(b,AZ)=>{try{await J.call("reorderRegion",{pageId:q.id,region:b,order:AZ}),await r()}catch(a){v(IX(a))}};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:K,children:"← all pages"},void 0,!1,void 0,this),P.jsxDEV(KH,{children:"Regions"},void 0,!1,void 0,this),JZ.map((b)=>P.jsxDEV("div",{className:`${xW} mb-2`,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:b.label??b.name},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:(T?.regions[b.name]??[]).length},void 0,!1,void 0,this)]},b.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:[j?P.jsxDEV(JF,{children:j},void 0,!1,void 0,this):null,f?P.jsxDEV(JF,{ok:!0,children:f},void 0,!1,void 0,this):null,JZ.map((b)=>{let AZ=T?.regions[b.name]??[],a=b.allowedTypes&&b.allowedTypes.length?b.allowedTypes:z.map((LZ)=>LZ.slug);return P.jsxDEV("div",{className:"mb-6",children:[P.jsxDEV("h3",{className:"m-0 mb-3 flex items-baseline gap-3 text-[22px] font-normal text-fg",children:[b.label??b.name,b.allowedTypes?P.jsxDEV("span",{className:"text-[11px] font-normal text-fg-subtle",children:["only: ",b.allowedTypes.join(", ")]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),AZ.map((LZ,WZ)=>P.jsxDEV("div",{className:`mb-2.5 rounded-panel border bg-surface-card p-3.5 ${M?.id===LZ.id?"border-fg":"border-border"}`,onClick:()=>R(LZ),children:P.jsxDEV("div",{className:"flex items-center gap-2.5",children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:LZ.block_type},void 0,!1,void 0,this),LZ.is_shared?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"shared"},void 0,!1,void 0,this):null,P.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:ev(LZ.fields)},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>FD(AZ,b.name,WZ,-1,QZ),children:"↑"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>FD(AZ,b.name,WZ,1,QZ),children:"↓"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>mZ(LZ),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},LZ.id,!1,void 0,this)),P.jsxDEV("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:a.map((LZ)=>P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>IZ(b.name,LZ),children:["+ ",n.get(LZ)?.name??LZ]},LZ,!0,void 0,this))},void 0,!1,void 0,this)]},b.name,!0,void 0,this)}),JZ.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:M?P.jsxDEV(fv,{api:J,block:M,blockType:n.get(M.block_type),onClose:()=>R(null),onSaved:r,onError:v},void 0,!1,void 0,this):P.jsxDEV(P.Fragment,{children:[P.jsxDEV("div",{className:"mb-3 flex gap-1",children:n5.map((b)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:_===b?"bg-surface-muted text-fg":"text-fg-muted",onPress:()=>W(b),children:b},b,!1,void 0,this))},void 0,!1,void 0,this),_==="settings"?P.jsxDEV(uv,{page:q},void 0,!1,void 0,this):null,_==="seo"?P.jsxDEV(dv,{api:J,page:q,onError:v},void 0,!1,void 0,this):null,_==="workflow"?P.jsxDEV(cv,{api:J,page:q,onChanged:(b)=>{A(b)},onError:v},void 0,!1,void 0,this):null,_==="i18n"?P.jsxDEV(pv,{api:J,page:q,onError:v},void 0,!1,void 0,this):null,_==="audit"?P.jsxDEV(lv,{api:J,pageId:q.id,onError:v},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fv({api:J,block:q,blockType:z,onClose:_,onSaved:W,onError:K}){let[A,L]=EZ.useState({}),[F,T]=EZ.useState(!1);EZ.useEffect(()=>{J.call("getBlock",{blockId:q.block_id}).then((R)=>L(R?.fields??{})).catch((R)=>K(IX(R)))},[J,q.block_id,K]);let N=z?.fieldsSchema??[],M=async()=>{T(!0);try{await J.call("updateBlock",{blockId:q.block_id,fields:A}),W()}catch(R){K(IX(R))}finally{T(!1)}};return P.jsxDEV("div",{children:[P.jsxDEV("div",{className:"flex items-center gap-2",children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:q.block_type},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",onPress:_,children:"done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"This block type has no fields."},void 0,!1,void 0,this):P.jsxDEV(QF,{schema:N,value:A,onChange:L,api:J},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"mt-3 w-full",onPress:M,isDisabled:F,children:"Save block"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function uv({page:J}){return P.jsxDEV(zF,{children:[P.jsxDEV("span",{children:"Title"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.title},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Slug"},void 0,!1,void 0,this),P.jsxDEV("span",{children:["/",J.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{children:"Locale"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.locale},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function dv({api:J,page:q,onError:z}){let[_,W]=EZ.useState({metaTitle:q.metaTitle??"",metaDescription:q.metaDescription??"",canonicalUrl:q.canonicalUrl??"",robots:q.robots??"",ogTitle:q.ogTitle??"",ogDescription:q.ogDescription??""}),[K,A]=EZ.useState(!1),L=async()=>{try{await J.call("updatePageSeo",{pageId:q.id,..._}),A(!0),setTimeout(()=>A(!1),1500)}catch(T){z(IX(T))}},F=(T,N,M=!1)=>M?P.jsxDEV(ZF,{label:N,value:_[T],onChange:(R)=>W({..._,[T]:R})},void 0,!1,void 0,this):P.jsxDEV(kY,{label:N,value:_[T],onChange:(R)=>W({..._,[T]: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(JF,{ok:!0,children:"saved"},void 0,!1,void 0,this):null,F("metaTitle","Meta title"),F("metaDescription","Meta description",!0),F("canonicalUrl","Canonical URL"),F("robots","Robots (e.g. noindex)"),F("ogTitle","OG title"),F("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 cv({api:J,page:q,onChanged:z,onError:_}){let W=async(L,F)=>{try{let T=await J.call(L,{pageId:q.id,...F});if(T?.page)z(T.page)}catch(T){_(IX(T))}},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 pv({api:J,page:q,onError:z}){let[_,W]=EZ.useState([]),[K,A]=EZ.useState(""),L=EZ.useCallback(()=>J.call("listTranslations",{pageId:q.id}).then(W).catch((T)=>z(IX(T))),[J,q.id,z]);EZ.useEffect(()=>{L()},[L]);let F=async()=>{try{await J.call("createTranslation",{pageId:q.id,locale:K}),A(""),L()}catch(T){z(IX(T))}};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((T)=>P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:T.locale},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",T.slug]},void 0,!0,void 0,this),P.jsxDEV(hz,{status:T.status,children:T.status},void 0,!1,void 0,this)]},T.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(kY,{label:"",value:K,onChange:A,placeholder:"locale (e.g. cs)"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",onPress:F,isDisabled:!K,children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function lv({api:J,pageId:q,onError:z}){let[_,W]=EZ.useState([]);return EZ.useEffect(()=>{J.listPageAudit(q).then(W).catch((K)=>z(IX(K)))},[J,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 TD({api:J,onError:q}){let[z,_]=EZ.useState([]),[W,K]=EZ.useState(0),[A,L]=EZ.useState(!1),[F,T]=EZ.useState(null),[N,M]=EZ.useState(!1),R=EZ.useCallback((v)=>{J.listMedia(AD,v).then((f)=>{_((h)=>v===0?f:[...h,...f]),L(f.length===AD),K(v+f.length)}).catch((f)=>q(IX(f)))},[J,q]);EZ.useEffect(()=>{R(0)},[R]);let j=async(v)=>{if(!v?.length)return;M(!0),q("");try{for(let f of Array.from(v))await J.uploadMedia(f);R(0)}catch(f){q(IX(f))}finally{M(!1)}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Media",em:z.length===0?"None yet":z.length===1?"1 file":`${z.length}${A?"+":""} files`,children:P.jsxDEV(s5,{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:(v)=>{j(v.target.files),v.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:GF,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((v)=>P.jsxDEV("div",{className:`cursor-pointer overflow-hidden rounded-lg border bg-surface-card ${F?.id===v.id?"border-fg":"border-border"}`,onClick:()=>T(v),children:[RD(v)?P.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:J.resolve(`/media/${v.file.key}`),alt:v.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:jD(v)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:v.file.filename??v.id},void 0,!1,void 0,this)]},v.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,F?P.jsxDEV(iv,{api:J,media:F,onClose:()=>T(null),onSaved:(v)=>{T(v),_((f)=>f.map((h)=>h.id===v.id?v:h))},onDeleted:(v)=>{T(null),_((f)=>f.filter((h)=>h.id!==v))},onError:q},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function iv({api:J,media:q,onClose:z,onSaved:_,onDeleted:W,onError:K}){let[A,L]=EZ.useState(q.alt??""),[F,T]=EZ.useState(!1);EZ.useEffect(()=>L(q.alt??""),[q]);let N=J.resolve(`/media/${q.file.key}`),M=async()=>{T(!0);try{_(await J.updateMedia(q.id,A||null))}catch(j){K(IX(j))}finally{T(!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;T(!0);try{await J.deleteMedia(q.id),W(q.id)}catch(j){K(IX(j))}finally{T(!1)}};return P.jsxDEV(a5,{onClose:z,wide:!0,children:[P.jsxDEV(o5,{children:[P.jsxDEV(qF,{children:"Media"},void 0,!1,void 0,this)," ",q.file.filename??""]},void 0,!0,void 0,this),RD(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:jD(q)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-4",children:P.jsxDEV(kY,{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(zF,{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:tv(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:F||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:F,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 nv(J){let q=J.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 wD({api:J,me:q,onError:z}){let[_,W]=EZ.useState([]),[K,A]=EZ.useState(!1),[L,F]=EZ.useState(""),T=EZ.useCallback(()=>{J.call("listUsers",{limit:200}).then(W).catch((j)=>z(IX(j)))},[J,z]);EZ.useEffect(()=>{T()},[T]);let N=async(j,v)=>{F(j.username);try{await J.call("setUserRoles",{username:j.username,roles:v}),T()}catch(f){z(IX(f))}finally{F("")}},M=async(j,v)=>{F(j.username);try{await J.call("setUserActive",{username:j.username,active:v}),T()}catch(f){z(IX(f))}finally{F("")}},R=async(j)=>{if(!confirm(`Delete user ${j.username}? This cannot be undone.`))return;F(j.username);try{await J.call("deleteUser",{username:j.username}),T()}catch(v){z(IX(v))}finally{F("")}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Users",em:_.length===0?"None yet":_.length===1?"1 account":`${_.length} accounts`,children:P.jsxDEV(s5,{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:GF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((j)=>{let v=nv(j),f=q?.userId===j.username,h=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,f?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(sv,{value:v,disabled:L===j.username,onSave:(n)=>N(j,n)},void 0,!1,void 0,this),P.jsxDEV(hz,{status:h?"active":"inactive",children:h?"active":"inactive"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:L===j.username||f,onPress:()=>M(j,!h),children:h?"Deactivate":"Activate"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",isDisabled:L===j.username||f,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(av,{api:J,onClose:()=>A(!1),onInvited:()=>{A(!1),T()},onError:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function sv({value:J,disabled:q,onSave:z}){let[_,W]=EZ.useState(J.join(", ")),[K,A]=EZ.useState(!1);EZ.useEffect(()=>{W(J.join(", "))},[J]);let L=()=>{A(!1);let F=_.split(",").map((T)=>T.trim()).filter(Boolean);if(F.length===0){W(J.join(", "));return}if(F.length===J.length&&F.every((T,N)=>T===J[N]))return;z(F)};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:(F)=>W(F.target.value),onBlur:L,onKeyDown:(F)=>{if(F.key==="Enter")L();if(F.key==="Escape")W(J.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:J.length===0?P.jsxDEV(hz,{children:"no roles"},void 0,!1,void 0,this):J.map((F)=>P.jsxDEV(hz,{status:F==="admin"?"published":void 0,children:F},F,!1,void 0,this))},void 0,!1,void 0,this)}function av({api:J,onClose:q,onInvited:z,onError:_}){let[W,K]=EZ.useState(""),[A,L]=EZ.useState("editor"),[F,T]=EZ.useState(!1);return P.jsxDEV(a5,{onClose:q,children:[P.jsxDEV(o5,{children:["Invite an ",P.jsxDEV(qF,{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(kY,{label:"Email",type:"email",autoFocus:!0,value:W,onChange:K,placeholder:"them@example.com"},void 0,!1,void 0,this),P.jsxDEV(kY,{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()=>{T(!0);try{let M=A.split(",").map((R)=>R.trim()).filter(Boolean);await J.call("inviteUser",{email:W,roles:M}),z()}catch(M){_(IX(M))}finally{T(!1)}},isDisabled:F||!W,children:F?"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 VD({api:J,cfg:q,me:z,onSignOut:_,onError:W}){return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Settings",em:z?.userId??"your account"},void 0,!1,void 0,this),P.jsxDEV("div",{className:`${GF} grid grid-cols-2 gap-5 max-[820px]:grid-cols-1`,children:[P.jsxDEV(ov,{api:J,me:z,onError:W,onSignOut:_},void 0,!1,void 0,this),P.jsxDEV(rv,{cfg:q,me:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ov({api:J,me:q,onError:z,onSignOut:_}){let[W,K]=EZ.useState(""),[A,L]=EZ.useState(""),[F,T]=EZ.useState(""),[N,M]=EZ.useState(""),[R,j]=EZ.useState(!1),v=(n)=>{M(n),setTimeout(()=>M(""),1800)},f=async()=>{j(!0);try{await J.call("changeEmail",{email:W}),K(""),v("Contact email updated")}catch(n){z(IX(n))}finally{j(!1)}},h=async()=>{j(!0);try{await J.call("changePassword",{currentPassword:A,newPassword:F}),L(""),T(""),v("Password updated")}catch(n){z(IX(n))}finally{j(!1)}};return P.jsxDEV(MD,{children:[P.jsxDEV(KH,{children:"My account"},void 0,!1,void 0,this),N?P.jsxDEV(JF,{ok:!0,children:N},void 0,!1,void 0,this):null,P.jsxDEV(zF,{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(kY,{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:f,isDisabled:R||!W,children:"Save email"},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"Current password",type:"password",value:A,onChange:L,autoComplete:"current-password"},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"New password (at least 8 characters)",type:"password",value:F,onChange:T,autoComplete:"new-password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:h,isDisabled:R||F.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 rv({cfg:J,me:q}){return P.jsxDEV(MD,{children:[P.jsxDEV(KH,{children:"About"},void 0,!1,void 0,this),P.jsxDEV(zF,{children:[P.jsxDEV("span",{children:"Tenant"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.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:J.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 RD(J){return(J.file.contentType??"").startsWith("image/")}function jD(J){let q=(J.file.contentType??"").split("/")[1];return(J.file.filename?.split(".").pop()??q??"file").slice(0,5).toUpperCase()}function tv(J){if(!J||J<=0)return"—";let q=["B","KB","MB","GB"],z=0,_=J;while(_>=1024&&z<q.length-1)_/=1024,z++;return`${_<10&&z>0?_.toFixed(1):Math.round(_)} ${q[z]}`}function IX(J){if(J instanceof EW)return J.message;return J instanceof Error?J.message:String(J)}function OD(J){return J.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function ev(J){let q=Object.values(J).find((z)=>typeof z==="string"&&z);return typeof q==="string"?q.length>48?q.slice(0,48)+"…":q:""}function FD(J,q,z,_,W){let K=z+_;if(K<0||K>=J.length)return;let A=J.map((L)=>L.id);[A[z],A[K]]=[A[K],A[z]],W(q,A)}var EZ,P,n5,xW="flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",GF="mx-auto max-w-[1200px] px-7 pb-8 pt-2",qF=({children:J})=>P.jsxDEV("span",{className:"text-fg-subtle",children:J},void 0,!1,void 0,this),AD=60;var yW=C(()=>{WH();c5();LD();EZ=g(e(),1),P=g(PZ(),1),n5=["settings","seo","workflow","i18n","audit"]});var CD={};p_(CD,{default:()=>Zh});var qB,DD,Zh;var PD=C(()=>{Hq();UH();yW();qB=g(e(),1),DD=g(PZ(),1),Zh=EQ().route("/").render(function(){let{api:q,setError:z}=_J(),_=XJ(),[W,K]=qB.useState([]),[A,L]=qB.useState([]),F=()=>q.listPages().then(K).catch((T)=>z(IX(T)));return qB.useEffect(()=>{F(),q.listBlockTypes().then(L).catch((T)=>z(IX(T)))},[q]),DD.jsxDEV(ND,{api:q,pages:W,blockTypes:A,onOpen:(T)=>_("page",{params:{pageId:T.id}}),onCreated:F,onError:z},void 0,!1,void 0,this)})});var $D={};p_($D,{default:()=>Xh});var SD,Xh;var ED=C(()=>{Hq();UH();yW();SD=g(PZ(),1),Xh=EQ().route("/media").render(function(){let{api:q,setError:z}=_J();return SD.jsxDEV(TD,{api:q,onError:z},void 0,!1,void 0,this)})});var kD={};p_(kD,{default:()=>Yh});var vW,bz,Yh;var xD=C(()=>{Hq();WH();UH();yW();vW=g(e(),1),bz=g(PZ(),1),Yh=EQ().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,F]=vW.useState([]),[T,N]=vW.useState(!1);vW.useEffect(()=>{let j=!0;return N(!1),z.listPages().then((v)=>{if(!j)return;let f=v.find((h)=>h.id===q.pageId)??null;A(f),N(!f)}).catch((v)=>_(IX(v))),z.listBlockTypes().then((v)=>j&&F(v)).catch((v)=>_(IX(v))),()=>{j=!1}},[z,q.pageId,_]);let M=n5.includes(q.tab)?q.tab:"settings",R=(j)=>W("page",{params:{pageId:q.pageId,tab:j},replace:!0});if(T)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(ID,{api:z,page:K,blockTypes:L,tab:M,onTab:R,onBack:()=>W("home"),onChange:A},void 0,!1,void 0,this)})});var yD={};p_(yD,{default:()=>Qh});var vD,Qh;var hD=C(()=>{Hq();UH();yW();vD=g(PZ(),1),Qh=EQ().route("/settings").render(function(){let{api:q,cfg:z,me:_,setError:W,reconfigure:K}=_J();return vD.jsxDEV(VD,{api:q,cfg:z,me:_,onSignOut:K,onError:W},void 0,!1,void 0,this)})});var bD={};p_(bD,{default:()=>Jh});var gz,Jh;var gD=C(()=>{Hq();WH();UH();yW();gz=g(PZ(),1),Jh=EQ().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(wD,{api:q,me:z,onError:W},void 0,!1,void 0,this)})});var mD={};p_(mD,{default:()=>qh});var BH,qh;var fD=C(()=>{Hq();WH();BH=g(PZ(),1),qh=EQ().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 sD=g(e(),1),aD=g(Z2(),1);Hq();var mz=g(e(),1);Hq();WH();UH();var xY=g(PZ(),1);function l5(){let{cfg:J,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=(F)=>A===F?"bg-surface-muted text-fg":"text-fg-muted";return xY.jsxDEV(xY.Fragment,{children:[xY.jsxDEV("div",{className:"sticky top-0 z-10 flex items-center gap-4 bg-surface px-7 py-4",children:[xY.jsxDEV("span",{className:"text-[15px] font-bold tracking-[0.01em] text-fg",children:["pramen ",xY.jsxDEV("span",{className:"font-normal text-fg-subtle",children:"· cms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),xY.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),xY.jsxDEV("nav",{className:"flex items-center gap-0.5",children:[xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("pages"),onPress:()=>W("home"),children:"Pages"},void 0,!1,void 0,this),xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("media"),onPress:()=>W("media"),children:"Media"},void 0,!1,void 0,this),q?xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("users"),onPress:()=>W("users"),children:"Users"},void 0,!1,void 0,this):null,xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("settings"),onPress:()=>W("settings"),children:"Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),xY.jsxDEV("span",{className:"ml-3 text-fg-subtle",children:J.tenant},void 0,!1,void 0,this),xY.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:_,children:"sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z?xY.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,xY.jsxDEV(a_,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var uD=()=>Promise.resolve().then(() => (PD(),CD)).then((J)=>({default:J.default.component})),dD=()=>Promise.resolve().then(() => (ED(),$D)).then((J)=>({default:J.default.component})),cD=()=>Promise.resolve().then(() => (xD(),kD)).then((J)=>({default:J.default.component})),pD=()=>Promise.resolve().then(() => (hD(),yD)).then((J)=>({default:J.default.component})),lD=()=>Promise.resolve().then(() => (gD(),bD)).then((J)=>({default:J.default.component})),iD=()=>Promise.resolve().then(() => (fD(),mD)).then((J)=>({default:J.default.component})),r5={home:"/",media:"/media",page:"/pages/:pageId",settings:"/settings",users:"/users"},Gh=[{path:"/",component:l5,isLayout:!0,children:[{path:"/home",matchPath:"/",component:mz.lazy(uD),preload:uD},{path:"/media",component:mz.lazy(dD),preload:dD},{path:"/page",matchPath:"/pages/:pageId",component:mz.lazy(cD),preload:cD},{path:"/settings",component:mz.lazy(pD),preload:pD},{path:"/users",component:mz.lazy(lD),preload:lD},{path:"/:__notFound+",component:mz.lazy(iD),preload:iD}]}],t5=o9(Gh);UH();var _F=g(PZ(),1),nD=document.getElementById("app");if(nD)aD.createRoot(nD).render(_F.jsxDEV(sD.StrictMode,{children:_F.jsxDEV(KD,{children:_F.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} />`,jZ,FZ,YX,FZ),s[FZ+jZ]=!0)}if(FZ=null,TZ!==void 0&&(z(TZ),FZ=""+TZ),A(t)&&(z(t.key),FZ=""+t.key),"key"in t){TZ={};for(var TX in t)TX!=="key"&&(TZ[TX]=t[TX])}else TZ=t;return FZ&&L(TZ,typeof V==="function"?V.displayName||V.name||"Unknown":V),T(V,FZ,TZ,W(),xZ,JX)}function M(V){R(V)?V._store&&(V._store.validated=1):typeof V==="object"&&V!==null&&V.$$typeof===b&&(V._payload.status==="fulfilled"?R(V._payload.value)&&V._payload.value._store&&(V._payload.value._store.validated=1):V._store&&(V._store.validated=1))}function R(V){return typeof V==="object"&&V!==null&&V.$$typeof===j}var j=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),JZ=Symbol.for("react.context"),qZ=Symbol.for("react.forward_ref"),IZ=Symbol.for("react.suspense"),mZ=Symbol.for("react.suspense_list"),QZ=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),AZ=Symbol.for("react.activity"),a=Symbol.for("react.client.reference"),LZ=vz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,WZ=Object.prototype.hasOwnProperty,zZ=Array.isArray,y=console.createTask?console.createTask:function(){return null};vz={react_stack_bottom_frame:function(V){return V()}};var u,c={},p=vz.react_stack_bottom_frame.bind(vz,K)(),KZ=y(_(K)),s={};Wv.Fragment=f,Wv.jsxDEV=function(V,t,TZ,jZ){var xZ=1e4>LZ.recentlyCreatedOwnerStacks++;return N(V,t,TZ,jZ,xZ?Error("react-stack-top-frame"):p,xZ?y(_(V)):KZ)}})()});var $W,Uv,kY=({label:J,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:J},void 0,!1,void 0,this),$W.jsxDEV(Uv,{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=g(PZ(),1),Uv=gZ(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,Kv,ZF=({label:J,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:J},void 0,!1,void 0,this),SW.jsxDEV(Kv,{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=g(PZ(),1),Kv=gZ(v5,{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=g(PZ(),1)});var Bv;var gC=C(()=>{Bv=g(PZ(),1)});var Lv;var mC=C(()=>{Lv=g(PZ(),1)});var Av,xYZ,yYZ;var fC=C(()=>{zJ();FY();Av=g(PZ(),1),xYZ=gZ(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"}),yYZ=gZ(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,uYZ,dYZ;var dC=C(()=>{zJ();FY();uC=g(PZ(),1),uYZ=gZ(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"}),dYZ=gZ(j5,{displayName:"DialogModal",baseClass:"rounded-lg bg-surface p-5 outline-none shadow-[0px_2px_8px_0px_rgba(0,0,0,0.06)]"})});var Fv,iYZ,nYZ;var cC=C(()=>{zJ();FY();Fv=g(PZ(),1),iYZ=gZ(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"}}}),nYZ=gZ(z6,{displayName:"DropdownMenuSeparator",baseClass:"my-2 h-px border-0 bg-border"})});var XF,pC,rYZ;var lC=C(()=>{zJ();FY();XF=g(e(),1),pC=g(PZ(),1),rYZ=gZ(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 Mv;var f5=C(()=>{Mv=g(PZ(),1)});var iC,JQZ;var nC=C(()=>{zJ();iC=g(PZ(),1),JQZ=new QB({maxVisibleToasts:5})});var zQZ,_QZ;var sC=C(()=>{zJ();FY();zQZ=gZ(N5,{displayName:"Disclosure"}),_QZ=gZ(I5,{displayName:"DisclosurePanel"})});var BQZ,LQZ,AQZ;var aC=C(()=>{zJ();FY();BQZ=gZ(k5,{displayName:"TabList",baseClass:"flex gap-2 border-b border-border"}),LQZ=gZ(x5,{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"}),AQZ=gZ(y5,{displayName:"TabPanel",baseClass:"py-4 text-sm text-fg outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-ring"})});var Nv;var oC=C(()=>{g5();Nv=g(PZ(),1)});var Iv;var rC=C(()=>{Iv=g(PZ(),1)});var TQZ,wQZ;var tC=C(()=>{FY();TQZ=gZ("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"}}),wQZ=gZ("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 Tv;var eC=C(()=>{f5();Tv=g(PZ(),1)});var $QZ;var ZD=C(()=>{FY();$QZ=gZ("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 kQZ;var XD=C(()=>{FY();kQZ=gZ("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 vQZ;var YD=C(()=>{FY();vQZ=gZ("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 QD,wv,gQZ,mQZ,fQZ;var JD=C(()=>{FY();QD=g(e(),1),wv=g(PZ(),1),gQZ=gZ("div",{displayName:"AppShell",baseClass:"grid h-screen w-full overflow-hidden bg-surface grid-rows-[100%] grid-cols-[1fr] md:grid-cols-[auto_1fr]"}),mQZ=gZ("aside",{displayName:"AppShell.Sidebar",baseClass:"h-full w-64 shrink-0 overflow-y-auto border-r border-border bg-surface"}),fQZ=gZ("main",{displayName:"AppShell.Main",baseClass:"min-w-0 flex-1 bg-surface px-6 pb-6 pt-6"})});var qD,Vv,Rv,jv,Cv=(J)=>qD.jsxDEV(jv,{...J},void 0,!1,void 0,this),Dv,Pv,lQZ,iQZ,nQZ;var GD=C(()=>{zJ();FY();qD=g(PZ(),1),Vv=gZ("header",{displayName:"Topbar",baseClass:"flex h-14 w-full items-center gap-5 border-b border-border"}),Rv=gZ("div",{displayName:"Topbar.Brand",baseClass:"flex min-w-0 items-center gap-3 text-compact leading-4 font-medium tracking-tight text-fg"}),jv=gZ("nav",{displayName:"Topbar.Nav",baseClass:"ml-auto flex min-w-0 items-center gap-2 overflow-x-auto"}),Dv=gZ("div",{displayName:"Topbar.Actions",baseClass:"ml-auto flex items-center gap-4"}),Pv=gZ("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"]}),lQZ=gZ(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"}),iQZ=gZ(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"}),nQZ=Object.assign(Vv,{Brand:Rv,Nav:Cv,NavLink:Pv,Actions:Dv})});var $v,Sv,oQZ;var HD=C(()=>{FY();$v=g(e(),1),Sv=g(PZ(),1),oQZ=gZ("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();g5();yC();vC();bC();gC();mC();fC();dC();cC();lC();f5();nC();sC();aC();oC();rC();tC();eC();ZD();XD();YD();JD();GD();HD()});function YF(J){try{let q=String(J).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 zD(){try{let J=localStorage.getItem(u5);if(J)return JSON.parse(J)}catch{}return{baseUrl:"http://localhost:8787",token:"",tenant:"main"}}function _D(J){localStorage.setItem(u5,JSON.stringify(J))}function WD(){try{localStorage.removeItem(u5)}catch{}}class d5{cfg;onExpired;constructor(J,q){this.cfg=J;this.onExpired=q}setConfig(J){this.cfg=J}base(){return this.cfg.baseUrl.replace(/\/+$/,"")}async call(J,q){if(this.onExpired&&this.cfg.token&&YF(this.cfg.token))return this.onExpired(),new Promise(()=>{});let z=await fetch(`${this.base()}/rpc/${J}`,{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(J,q,z){let _=J.startsWith("http")?J:`${this.base()}${J}`,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(J){return J.startsWith("http")?J:`${this.base()}${J}`}listBlockTypes=()=>this.call("listBlockTypes");listContentTypes=()=>this.call("listContentTypes");getContentType=(J)=>this.call("getContentType",{id:J});listPages=()=>this.call("listPages");getPagePreview=(J,q)=>this.call("getPage",{slug:J,locale:q,preview:!0});listPageAudit=(J)=>this.call("listPageAudit",{pageId:J});listMedia=(J=50,q=0)=>this.call("listMedia",{limit:J,offset:q});getMedia=(J)=>this.call("getMedia",{id:J});updateMedia=(J,q)=>this.call("updateMedia",{id:J,alt:q});deleteMedia=(J)=>this.call("deleteMedia",{id:J});async uploadMedia(J){let q=J.type||"application/octet-stream",z=await this.call("signMediaUpload",{contentType:q,filename:J.name});return await this.put(z.url,await J.arrayBuffer(),q),this.call("createMedia",{ref:z.ref,alt:J.name})}}var EW,u5="pramen.cmsEditor";var c5=C(()=>{EW=class EW extends Error{code;status;constructor(J,q,z){super(J);this.code=q;this.status=z;this.name="ApiError"}}});function p5(){WD(),location.replace(JB)}function _J(){let J=UQ.use(UD);if(!J)throw Error("useApp must be used within <AppProvider>");return J}function KD({children:J}){let[q,z]=UQ.useState(zD()),[_,W]=UQ.useState(null),[K,A]=UQ.useState(""),L=Boolean(q.baseUrl&&q.token)&&!YF(q.token),F=UQ.useMemo(()=>new d5(q,JB?p5:void 0),[q]);if(UQ.useEffect(()=>{if(!JB)return;let N=()=>{if(!q.token||YF(q.token))p5()};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]),UQ.useEffect(()=>{if(!L)return;F.call("me").then(W).catch(()=>W({}))},[F,L]),!L)return JB?null:WQ.jsxDEV(Ev,{cfg:q,onSave:(N)=>{_D(N),z(N)}},void 0,!1,void 0,this);let T={api:F,cfg:q,me:_,isAdmin:(_?.roles??[]).includes("admin"),error:K,setError:A,reconfigure:()=>{if(JB){p5();return}W(null),A(""),z({...q,token:""})}};return WQ.jsxDEV(UD,{value:T,children:J},void 0,!1,void 0,this)}function Ev({cfg:J,onSave:q}){let[z,_]=UQ.useState(J);return WQ.jsxDEV("div",{className:"mx-auto mt-[14vh] w-full max-w-[520px] px-6",children:WQ.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:[WQ.jsxDEV("h1",{className:"mb-4 text-display text-fg",children:["pramen ",WQ.jsxDEV("span",{className:"text-fg-subtle",children:"· cms editor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),WQ.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 (",WQ.jsxDEV("code",{children:"CORS_ORIGINS"},void 0,!1,void 0,this),")."]},void 0,!0,void 0,this),WQ.jsxDEV("div",{className:"flex flex-col gap-4",children:[WQ.jsxDEV(kY,{label:"Worker base URL",value:z.baseUrl,onChange:(W)=>_({...z,baseUrl:W}),placeholder:"https://your-worker.workers.dev"},void 0,!1,void 0,this),WQ.jsxDEV(kY,{label:"Tenant",value:z.tenant,onChange:(W)=>_({...z,tenant:W}),placeholder:"main"},void 0,!1,void 0,this),WQ.jsxDEV(kY,{label:"Bearer token (editor or reviewer)",value:z.token,onChange:(W)=>_({...z,token:W}),placeholder:"eyJ…"},void 0,!1,void 0,this),WQ.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 UQ,WQ,JB,UD;var UH=C(()=>{WH();c5();UQ=g(e(),1),WQ=g(PZ(),1),JB=typeof window<"u"&&!new URLSearchParams(window.location.search).has("setup")?window.PRAMEN_CMS_EDITOR?.signInUrl:void 0;UD=UQ.createContext(null)});function kW({label:J,children:q}){return NZ.jsxDEV("label",{className:"flex w-full flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:J},void 0,!1,void 0,this),q]},void 0,!0,void 0,this)}function QF({schema:J,value:q,onChange:z,api:_}){let W=(K,A)=>z({...q,[K]:A});return NZ.jsxDEV("div",{className:"flex flex-col gap-4",children:J.map((K)=>NZ.jsxDEV(kv,{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 kv({def:J,value:q,onChange:z,api:_}){let W=NZ.jsxDEV(NZ.Fragment,{children:[J.label??J.name," ",J.required?NZ.jsxDEV("span",{className:"text-danger",children:"*"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);switch(J.type){case"text":case"url":return NZ.jsxDEV(kY,{label:W,value:q??"",onChange:z,placeholder:J.type==="url"?"https://…":""},void 0,!1,void 0,this);case"textarea":return NZ.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 NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV(vv,{value:typeof q==="string"?q:"",onChange:z},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"number":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("input",{className:i5,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 NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("input",{className:i5,type:J.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 NZ.jsxDEV("label",{className:"flex items-center gap-2",children:[NZ.jsxDEV("input",{type:"checkbox",checked:Boolean(q),onChange:(K)=>z(K.target.checked)},void 0,!1,void 0,this),NZ.jsxDEV("span",{className:"text-sm text-fg",children:J.label??J.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this);case"select":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("select",{className:i5,value:q??"",onChange:(K)=>z(K.target.value||null),children:[NZ.jsxDEV("option",{value:"",children:"—"},void 0,!1,void 0,this),(J.options??[]).map((K)=>NZ.jsxDEV("option",{value:K,children:K},K,!1,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this);case"media":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV(bv,{value:q,onChange:z,api:_},void 0,!1,void 0,this)},void 0,!1,void 0,this);case"group":return NZ.jsxDEV(kW,{label:W,children:NZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:NZ.jsxDEV(QF,{schema:J.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 NZ.jsxDEV(hv,{def:J,value:q??[],onChange:z,api:_,label:W},void 0,!1,void 0,this);default:return null}}function yv(J){let q=J.trim();return/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(q)?q:null}function BD(J){return J.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 vv({value:J,onChange:q}){let z=gQ.useRef(null),_=gQ.useRef("");gQ.useEffect(()=>{let L=z.current;if(L&&J!==_.current)L.innerHTML=BD(J||""),_.current=J||""},[J]);let W=()=>{let L=BD(z.current?.innerHTML??"");_.current=L,q(L)},K=(L,F)=>{z.current?.focus(),document.execCommand(L,!1,F),W()},A=(L)=>{L.preventDefault(),document.execCommand("insertText",!1,L.clipboardData.getData("text/plain"))};return NZ.jsxDEV("div",{className:"overflow-hidden rounded-lg border border-border bg-surface-card",children:[NZ.jsxDEV("div",{className:"flex flex-wrap gap-0.5 border-b border-border bg-surface-muted px-2 py-1.5",children:xv.map((L)=>NZ.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:(F)=>F.preventDefault(),onClick:()=>L.run(K),children:L.label},L.label,!1,void 0,this))},void 0,!1,void 0,this),NZ.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 hv({def:J,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,{}]),F=(N)=>z(K.filter((M,R)=>R!==N)),T=(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 NZ.jsxDEV("div",{className:"flex flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:W},void 0,!1,void 0,this),K.map((N,M)=>NZ.jsxDEV("div",{className:"rounded-lg border border-border bg-surface-muted p-3.5",children:[NZ.jsxDEV("div",{className:"mb-2 flex justify-end gap-1",children:[NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>T(M,-1),children:"↑"},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>T(M,1),children:"↓"},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>F(M),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),NZ.jsxDEV(QF,{schema:J.fields??[],value:N,onChange:(R)=>A(M,R),api:_},void 0,!1,void 0,this)]},M,!0,void 0,this)),NZ.jsxDEV(yZ,{variant:"secondary",size:"sm",className:"self-start",onPress:L,isDisabled:J.max!=null&&K.length>=J.max,children:["+ add ",J.label??J.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function bv({value:J,onChange:q,api:z}){let[_,W]=gQ.useState(!1),[K,A]=gQ.useState(null);return gQ.useEffect(()=>{if(J)z.call("getMedia",{id:J}).then(A).catch(()=>A(null));else A(null)},[J,z]),NZ.jsxDEV("div",{children:[NZ.jsxDEV("div",{className:"flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",children:[K?NZ.jsxDEV("img",{className:"h-10 w-10 rounded object-cover",src:z.resolve(`/media/${K.file.key}`),alt:""},void 0,!1,void 0,this):NZ.jsxDEV("span",{className:"text-fg-subtle",children:"no media"},void 0,!1,void 0,this),NZ.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:K?.file.filename??J??""},void 0,!1,void 0,this),NZ.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>W(!0),children:"pick"},void 0,!1,void 0,this),J?NZ.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),_?NZ.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:J,onClose:q,onPick:z}){let[_,W]=gQ.useState([]),[K,A]=gQ.useState(!1),[L,F]=gQ.useState(""),T=()=>J.listMedia().then(W).catch((M)=>F(String(M.message??M)));gQ.useEffect(()=>{T()},[]);let N=async(M)=>{A(!0),F("");try{let R=await J.uploadMedia(M);z(R.id)}catch(R){F(String(R.message??R))}finally{A(!1)}};return NZ.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:NZ.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:[NZ.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal text-fg",children:["Choose ",NZ.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?NZ.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,NZ.jsxDEV("label",{className:"mb-4 flex w-full flex-col gap-2",children:[NZ.jsxDEV("span",{className:"text-sm font-medium text-fg",children:"Upload a new file"},void 0,!1,void 0,this),NZ.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),NZ.jsxDEV("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2.5",children:_.map((M)=>NZ.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/")?NZ.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:J.resolve(`/media/${M.file.key}`),alt:""},void 0,!1,void 0,this):NZ.jsxDEV("div",{className:"h-[130px] bg-surface-muted"},void 0,!1,void 0,this),NZ.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),NZ.jsxDEV("div",{className:"mt-3 text-right",children:NZ.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 gQ,NZ,i5="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",xv;var LD=C(()=>{WH();gQ=g(e(),1),NZ=g(PZ(),1);xv=[{label:"B",title:"Bold",run:(J)=>J("bold")},{label:"I",title:"Italic",run:(J)=>J("italic")},{label:"H2",title:"Heading",run:(J)=>J("formatBlock","H2")},{label:"H3",title:"Subheading",run:(J)=>J("formatBlock","H3")},{label:"¶",title:"Paragraph",run:(J)=>J("formatBlock","P")},{label:"• List",title:"Bulleted list",run:(J)=>J("insertUnorderedList")},{label:"1. List",title:"Numbered list",run:(J)=>J("insertOrderedList")},{label:"Link",title:"Add link",run:(J)=>{let q=window.prompt("Link URL (https://, mailto:, /path)","https://");if(!q)return;let z=yv(q);if(!z){window.alert("Only http(s), mailto, tel, or relative (/, #) links are allowed.");return}J("createLink",z)}},{label:"Unlink",title:"Remove link",run:(J)=>J("unlink")},{label:"Clear",title:"Clear formatting",run:(J)=>J("removeFormat")}]});function HF({lead:J,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:J},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 s5({text:J,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:[J," ",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:J}){return P.jsxDEV("div",{className:"mb-2 mt-[18px] text-sm text-fg-subtle first:mt-0",children:J},void 0,!1,void 0,this)}function hz({status:J,children:q}){return P.jsxDEV("span",{className:`inline-block whitespace-nowrap rounded-full border px-2.5 py-0.5 text-[11px] font-medium ${J==="published"||J==="active"?"bg-brand-green text-[#0f3a25] border-transparent":J==="in_review"||J==="review"?"bg-accent-yellow text-[#4a3512] border-transparent":J==="rejected"||J==="archived"||J==="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 a5({onClose:J,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:J,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 o5({children:J}){return P.jsxDEV("h2",{className:"mb-5 text-[28px] font-normal leading-[1.15] text-fg",children:J},void 0,!1,void 0,this)}function zF({children:J,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:J},void 0,!1,void 0,this)}function MD({children:J}){return P.jsxDEV("div",{className:"overflow-auto rounded-panel border border-border bg-surface-card p-6",children:J},void 0,!1,void 0,this)}function JF({ok:J,children:q}){return P.jsxDEV("div",{className:`my-2 rounded-lg border px-3.5 py-2.5 text-[13px] ${J?"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 ND({api:J,pages:q,blockTypes:z,onOpen:_,onCreated:W,onError:K}){let[A,L]=EZ.useState(!1);return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Pages",em:q.length===0?"None yet":q.length===1?"1 page total":`${q.length} pages total`,children:P.jsxDEV(s5,{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:GF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[q.map((F)=>P.jsxDEV("div",{className:`${xW} cursor-pointer hover:bg-surface-muted`,onClick:()=>_(F),children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:F.title},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",F.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:F.locale},void 0,!1,void 0,this),P.jsxDEV(hz,{status:F.status,children:F.status},void 0,!1,void 0,this)]},F.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:J,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:J,onClose:q,onCreated:z,onError:_}){let[W,K]=EZ.useState([]),[A,L]=EZ.useState(""),[F,T]=EZ.useState(""),[N,M]=EZ.useState("");EZ.useEffect(()=>{J.listContentTypes().then((j)=>{if(K(j),j[0])L(j[0].id)}).catch((j)=>_(IX(j)))},[J,_]);let R=async()=>{try{await J.call("createPage",{typeId:A,title:F,slug:N||OD(F)}),z()}catch(j){_(IX(j))}};return P.jsxDEV(a5,{onClose:q,children:[P.jsxDEV(o5,{children:["Create a ",P.jsxDEV(qF,{children:"new page"},void 0,!1,void 0,this)," and define the essentials",P.jsxDEV(qF,{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(kY,{label:"Title",value:F,onChange:T},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"Slug",value:N,onChange:M,placeholder:OD(F)},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||!F,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 ID({api:J,page:q,blockTypes:z,tab:_,onTab:W,onBack:K,onChange:A}){let[L,F]=EZ.useState(null),[T,N]=EZ.useState(null),[M,R]=EZ.useState(null),[j,v]=EZ.useState(""),[f,h]=EZ.useState(""),n=EZ.useMemo(()=>new Map(z.map((b)=>[b.slug,b])),[z]),r=EZ.useCallback(async()=>{try{let[b,AZ]=await Promise.all([J.getContentType(q.typeId),J.getPagePreview(q.slug,q.locale)]);F(b??null),N(AZ)}catch(b){v(IX(b))}},[J,q.typeId,q.slug,q.locale]);EZ.useEffect(()=>{r(),R(null)},[r]);let JZ=L?.regions??[],qZ=(b)=>{h(b),setTimeout(()=>h(""),1800)},IZ=async(b,AZ)=>{try{await J.call("addBlock",{pageId:q.id,blockTypeSlug:AZ,region:b,fields:{}}),await r(),qZ("block added")}catch(a){v(IX(a))}},mZ=async(b)=>{try{if(await J.call("removeBlock",{pageBlockId:b.id}),M?.id===b.id)R(null);await r()}catch(AZ){v(IX(AZ))}},QZ=async(b,AZ)=>{try{await J.call("reorderRegion",{pageId:q.id,region:b,order:AZ}),await r()}catch(a){v(IX(a))}};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:K,children:"← all pages"},void 0,!1,void 0,this),P.jsxDEV(KH,{children:"Regions"},void 0,!1,void 0,this),JZ.map((b)=>P.jsxDEV("div",{className:`${xW} mb-2`,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:b.label??b.name},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:(T?.regions[b.name]??[]).length},void 0,!1,void 0,this)]},b.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:[j?P.jsxDEV(JF,{children:j},void 0,!1,void 0,this):null,f?P.jsxDEV(JF,{ok:!0,children:f},void 0,!1,void 0,this):null,JZ.map((b)=>{let AZ=T?.regions[b.name]??[],a=b.allowedTypes&&b.allowedTypes.length?b.allowedTypes:z.map((LZ)=>LZ.slug);return P.jsxDEV("div",{className:"mb-6",children:[P.jsxDEV("h3",{className:"m-0 mb-3 flex items-baseline gap-3 text-[22px] font-normal text-fg",children:[b.label??b.name,b.allowedTypes?P.jsxDEV("span",{className:"text-[11px] font-normal text-fg-subtle",children:["only: ",b.allowedTypes.join(", ")]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),AZ.map((LZ,WZ)=>P.jsxDEV("div",{className:`mb-2.5 rounded-panel border bg-surface-card p-3.5 ${M?.id===LZ.id?"border-fg":"border-border"}`,onClick:()=>R(LZ),children:P.jsxDEV("div",{className:"flex items-center gap-2.5",children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:LZ.block_type},void 0,!1,void 0,this),LZ.is_shared?P.jsxDEV("span",{className:"text-[11px] text-accent-strong",children:"shared"},void 0,!1,void 0,this):null,P.jsxDEV("span",{className:"flex-1 truncate text-fg-subtle",children:ev(LZ.fields)},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>FD(AZ,b.name,WZ,-1,QZ),children:"↑"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:()=>FD(AZ,b.name,WZ,1,QZ),children:"↓"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",onPress:()=>mZ(LZ),children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},LZ.id,!1,void 0,this)),P.jsxDEV("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:a.map((LZ)=>P.jsxDEV(yZ,{variant:"secondary",size:"sm",onPress:()=>IZ(b.name,LZ),children:["+ ",n.get(LZ)?.name??LZ]},LZ,!0,void 0,this))},void 0,!1,void 0,this)]},b.name,!0,void 0,this)}),JZ.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:M?P.jsxDEV(fv,{api:J,block:M,blockType:n.get(M.block_type),onClose:()=>R(null),onSaved:r,onError:v},void 0,!1,void 0,this):P.jsxDEV(P.Fragment,{children:[P.jsxDEV("div",{className:"mb-3 flex gap-1",children:n5.map((b)=>P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:_===b?"bg-surface-muted text-fg":"text-fg-muted",onPress:()=>W(b),children:b},b,!1,void 0,this))},void 0,!1,void 0,this),_==="settings"?P.jsxDEV(uv,{page:q},void 0,!1,void 0,this):null,_==="seo"?P.jsxDEV(dv,{api:J,page:q,onError:v},void 0,!1,void 0,this):null,_==="workflow"?P.jsxDEV(cv,{api:J,page:q,onChanged:(b)=>{A(b)},onError:v},void 0,!1,void 0,this):null,_==="i18n"?P.jsxDEV(pv,{api:J,page:q,onError:v},void 0,!1,void 0,this):null,_==="audit"?P.jsxDEV(lv,{api:J,pageId:q.id,onError:v},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fv({api:J,block:q,blockType:z,onClose:_,onSaved:W,onError:K}){let[A,L]=EZ.useState({}),[F,T]=EZ.useState(!1);EZ.useEffect(()=>{J.call("getBlock",{blockId:q.block_id}).then((R)=>L(R?.fields??{})).catch((R)=>K(IX(R)))},[J,q.block_id,K]);let N=z?.fieldsSchema??[],M=async()=>{T(!0);try{await J.call("updateBlock",{blockId:q.block_id,fields:A}),W()}catch(R){K(IX(R))}finally{T(!1)}};return P.jsxDEV("div",{children:[P.jsxDEV("div",{className:"flex items-center gap-2",children:[P.jsxDEV("span",{className:"rounded-full bg-surface-muted px-2 py-0.5 font-mono text-xs text-fg-muted",children:q.block_type},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",onPress:_,children:"done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.length===0?P.jsxDEV("p",{className:"text-fg-subtle",children:"This block type has no fields."},void 0,!1,void 0,this):P.jsxDEV(QF,{schema:N,value:A,onChange:L,api:J},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"mt-3 w-full",onPress:M,isDisabled:F,children:"Save block"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function uv({page:J}){return P.jsxDEV(zF,{children:[P.jsxDEV("span",{children:"Title"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.title},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Slug"},void 0,!1,void 0,this),P.jsxDEV("span",{children:["/",J.slug]},void 0,!0,void 0,this),P.jsxDEV("span",{children:"Locale"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.locale},void 0,!1,void 0,this),P.jsxDEV("span",{children:"Status"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function dv({api:J,page:q,onError:z}){let[_,W]=EZ.useState({metaTitle:q.metaTitle??"",metaDescription:q.metaDescription??"",canonicalUrl:q.canonicalUrl??"",robots:q.robots??"",ogTitle:q.ogTitle??"",ogDescription:q.ogDescription??""}),[K,A]=EZ.useState(!1),L=async()=>{try{await J.call("updatePageSeo",{pageId:q.id,..._}),A(!0),setTimeout(()=>A(!1),1500)}catch(T){z(IX(T))}},F=(T,N,M=!1)=>M?P.jsxDEV(ZF,{label:N,value:_[T],onChange:(R)=>W({..._,[T]:R})},void 0,!1,void 0,this):P.jsxDEV(kY,{label:N,value:_[T],onChange:(R)=>W({..._,[T]: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(JF,{ok:!0,children:"saved"},void 0,!1,void 0,this):null,F("metaTitle","Meta title"),F("metaDescription","Meta description",!0),F("canonicalUrl","Canonical URL"),F("robots","Robots (e.g. noindex)"),F("ogTitle","OG title"),F("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 cv({api:J,page:q,onChanged:z,onError:_}){let W=async(L,F)=>{try{let T=await J.call(L,{pageId:q.id,...F});if(T?.page)z(T.page)}catch(T){_(IX(T))}},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 pv({api:J,page:q,onError:z}){let[_,W]=EZ.useState([]),[K,A]=EZ.useState(""),L=EZ.useCallback(()=>J.call("listTranslations",{pageId:q.id}).then(W).catch((T)=>z(IX(T))),[J,q.id,z]);EZ.useEffect(()=>{L()},[L]);let F=async()=>{try{await J.call("createTranslation",{pageId:q.id,locale:K}),A(""),L()}catch(T){z(IX(T))}};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((T)=>P.jsxDEV("div",{className:xW,children:[P.jsxDEV("span",{className:"flex-1 truncate font-medium",children:T.locale},void 0,!1,void 0,this),P.jsxDEV("span",{className:"text-fg-subtle",children:["/",T.slug]},void 0,!0,void 0,this),P.jsxDEV(hz,{status:T.status,children:T.status},void 0,!1,void 0,this)]},T.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(kY,{label:"",value:K,onChange:A,placeholder:"locale (e.g. cs)"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"secondary",onPress:F,isDisabled:!K,children:"add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function lv({api:J,pageId:q,onError:z}){let[_,W]=EZ.useState([]);return EZ.useEffect(()=>{J.listPageAudit(q).then(W).catch((K)=>z(IX(K)))},[J,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 TD({api:J,onError:q}){let[z,_]=EZ.useState([]),[W,K]=EZ.useState(0),[A,L]=EZ.useState(!1),[F,T]=EZ.useState(null),[N,M]=EZ.useState(!1),R=EZ.useCallback((v)=>{J.listMedia(AD,v).then((f)=>{_((h)=>v===0?f:[...h,...f]),L(f.length===AD),K(v+f.length)}).catch((f)=>q(IX(f)))},[J,q]);EZ.useEffect(()=>{R(0)},[R]);let j=async(v)=>{if(!v?.length)return;M(!0),q("");try{for(let f of Array.from(v))await J.uploadMedia(f);R(0)}catch(f){q(IX(f))}finally{M(!1)}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Media",em:z.length===0?"None yet":z.length===1?"1 file":`${z.length}${A?"+":""} files`,children:P.jsxDEV(s5,{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:(v)=>{j(v.target.files),v.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:GF,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((v)=>P.jsxDEV("div",{className:`cursor-pointer overflow-hidden rounded-lg border bg-surface-card ${F?.id===v.id?"border-fg":"border-border"}`,onClick:()=>T(v),children:[RD(v)?P.jsxDEV("img",{className:"block h-[130px] w-full object-cover",src:J.resolve(`/media/${v.file.key}`),alt:v.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:jD(v)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"truncate px-2 py-1.5 text-[11px] text-fg-muted",children:v.file.filename??v.id},void 0,!1,void 0,this)]},v.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,F?P.jsxDEV(iv,{api:J,media:F,onClose:()=>T(null),onSaved:(v)=>{T(v),_((f)=>f.map((h)=>h.id===v.id?v:h))},onDeleted:(v)=>{T(null),_((f)=>f.filter((h)=>h.id!==v))},onError:q},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function iv({api:J,media:q,onClose:z,onSaved:_,onDeleted:W,onError:K}){let[A,L]=EZ.useState(q.alt??""),[F,T]=EZ.useState(!1);EZ.useEffect(()=>L(q.alt??""),[q]);let N=J.resolve(`/media/${q.file.key}`),M=async()=>{T(!0);try{_(await J.updateMedia(q.id,A||null))}catch(j){K(IX(j))}finally{T(!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;T(!0);try{await J.deleteMedia(q.id),W(q.id)}catch(j){K(IX(j))}finally{T(!1)}};return P.jsxDEV(a5,{onClose:z,wide:!0,children:[P.jsxDEV(o5,{children:[P.jsxDEV(qF,{children:"Media"},void 0,!1,void 0,this)," ",q.file.filename??""]},void 0,!0,void 0,this),RD(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:jD(q)},void 0,!1,void 0,this),P.jsxDEV("div",{className:"mb-4",children:P.jsxDEV(kY,{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(zF,{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:tv(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:F||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:F,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 nv(J){let q=J.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 wD({api:J,me:q,onError:z}){let[_,W]=EZ.useState([]),[K,A]=EZ.useState(!1),[L,F]=EZ.useState(""),T=EZ.useCallback(()=>{J.call("listUsers",{limit:200}).then(W).catch((j)=>z(IX(j)))},[J,z]);EZ.useEffect(()=>{T()},[T]);let N=async(j,v)=>{F(j.username);try{await J.call("setUserRoles",{username:j.username,roles:v}),T()}catch(f){z(IX(f))}finally{F("")}},M=async(j,v)=>{F(j.username);try{await J.call("setUserActive",{username:j.username,active:v}),T()}catch(f){z(IX(f))}finally{F("")}},R=async(j)=>{if(!confirm(`Delete user ${j.username}? This cannot be undone.`))return;F(j.username);try{await J.call("deleteUser",{username:j.username}),T()}catch(v){z(IX(v))}finally{F("")}};return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Users",em:_.length===0?"None yet":_.length===1?"1 account":`${_.length} accounts`,children:P.jsxDEV(s5,{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:GF,children:P.jsxDEV("div",{className:"flex flex-col gap-2",children:[_.map((j)=>{let v=nv(j),f=q?.userId===j.username,h=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,f?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(sv,{value:v,disabled:L===j.username,onSave:(n)=>N(j,n)},void 0,!1,void 0,this),P.jsxDEV(hz,{status:h?"active":"inactive",children:h?"active":"inactive"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",isDisabled:L===j.username||f,onPress:()=>M(j,!h),children:h?"Deactivate":"Activate"},void 0,!1,void 0,this),P.jsxDEV(yZ,{variant:"ghost",size:"sm",className:"text-danger",isDisabled:L===j.username||f,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(av,{api:J,onClose:()=>A(!1),onInvited:()=>{A(!1),T()},onError:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}function sv({value:J,disabled:q,onSave:z}){let[_,W]=EZ.useState(J.join(", ")),[K,A]=EZ.useState(!1);EZ.useEffect(()=>{W(J.join(", "))},[J]);let L=()=>{A(!1);let F=_.split(",").map((T)=>T.trim()).filter(Boolean);if(F.length===0){W(J.join(", "));return}if(F.length===J.length&&F.every((T,N)=>T===J[N]))return;z(F)};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:(F)=>W(F.target.value),onBlur:L,onKeyDown:(F)=>{if(F.key==="Enter")L();if(F.key==="Escape")W(J.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:J.length===0?P.jsxDEV(hz,{children:"no roles"},void 0,!1,void 0,this):J.map((F)=>P.jsxDEV(hz,{status:F==="admin"?"published":void 0,children:F},F,!1,void 0,this))},void 0,!1,void 0,this)}function av({api:J,onClose:q,onInvited:z,onError:_}){let[W,K]=EZ.useState(""),[A,L]=EZ.useState("editor"),[F,T]=EZ.useState(!1);return P.jsxDEV(a5,{onClose:q,children:[P.jsxDEV(o5,{children:["Invite an ",P.jsxDEV(qF,{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(kY,{label:"Email",type:"email",autoFocus:!0,value:W,onChange:K,placeholder:"them@example.com"},void 0,!1,void 0,this),P.jsxDEV(kY,{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()=>{T(!0);try{let M=A.split(",").map((R)=>R.trim()).filter(Boolean);await J.call("inviteUser",{email:W,roles:M}),z()}catch(M){_(IX(M))}finally{T(!1)}},isDisabled:F||!W,children:F?"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 VD({api:J,cfg:q,me:z,onSignOut:_,onError:W}){return P.jsxDEV(P.Fragment,{children:[P.jsxDEV(HF,{lead:"Settings",em:z?.userId??"your account"},void 0,!1,void 0,this),P.jsxDEV("div",{className:`${GF} grid grid-cols-2 gap-5 max-[820px]:grid-cols-1`,children:[P.jsxDEV(ov,{api:J,me:z,onError:W,onSignOut:_},void 0,!1,void 0,this),P.jsxDEV(rv,{cfg:q,me:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ov({api:J,me:q,onError:z,onSignOut:_}){let[W,K]=EZ.useState(""),[A,L]=EZ.useState(""),[F,T]=EZ.useState(""),[N,M]=EZ.useState(""),[R,j]=EZ.useState(!1),v=(n)=>{M(n),setTimeout(()=>M(""),1800)},f=async()=>{j(!0);try{await J.call("changeEmail",{email:W}),K(""),v("Contact email updated")}catch(n){z(IX(n))}finally{j(!1)}},h=async()=>{j(!0);try{await J.call("changePassword",{currentPassword:A,newPassword:F}),L(""),T(""),v("Password updated")}catch(n){z(IX(n))}finally{j(!1)}};return P.jsxDEV(MD,{children:[P.jsxDEV(KH,{children:"My account"},void 0,!1,void 0,this),N?P.jsxDEV(JF,{ok:!0,children:N},void 0,!1,void 0,this):null,P.jsxDEV(zF,{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(kY,{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:f,isDisabled:R||!W,children:"Save email"},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"Current password",type:"password",value:A,onChange:L,autoComplete:"current-password"},void 0,!1,void 0,this),P.jsxDEV(kY,{label:"New password (at least 8 characters)",type:"password",value:F,onChange:T,autoComplete:"new-password"},void 0,!1,void 0,this),P.jsxDEV(yZ,{className:"w-full",onPress:h,isDisabled:R||F.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 rv({cfg:J,me:q}){return P.jsxDEV(MD,{children:[P.jsxDEV(KH,{children:"About"},void 0,!1,void 0,this),P.jsxDEV(zF,{children:[P.jsxDEV("span",{children:"Tenant"},void 0,!1,void 0,this),P.jsxDEV("span",{children:J.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:J.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 RD(J){return(J.file.contentType??"").startsWith("image/")}function jD(J){let q=(J.file.contentType??"").split("/")[1];return(J.file.filename?.split(".").pop()??q??"file").slice(0,5).toUpperCase()}function tv(J){if(!J||J<=0)return"—";let q=["B","KB","MB","GB"],z=0,_=J;while(_>=1024&&z<q.length-1)_/=1024,z++;return`${_<10&&z>0?_.toFixed(1):Math.round(_)} ${q[z]}`}function IX(J){if(J instanceof EW)return J.message;return J instanceof Error?J.message:String(J)}function OD(J){return J.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function ev(J){let q=Object.values(J).find((z)=>typeof z==="string"&&z);return typeof q==="string"?q.length>48?q.slice(0,48)+"…":q:""}function FD(J,q,z,_,W){let K=z+_;if(K<0||K>=J.length)return;let A=J.map((L)=>L.id);[A[z],A[K]]=[A[K],A[z]],W(q,A)}var EZ,P,n5,xW="flex items-center gap-3 rounded-[14px] border border-transparent bg-surface-card px-[18px] py-3.5",GF="mx-auto max-w-[1200px] px-7 pb-8 pt-2",qF=({children:J})=>P.jsxDEV("span",{className:"text-fg-subtle",children:J},void 0,!1,void 0,this),AD=60;var yW=C(()=>{WH();c5();LD();EZ=g(e(),1),P=g(PZ(),1),n5=["settings","seo","workflow","i18n","audit"]});var CD={};p_(CD,{default:()=>Zh});var qB,DD,Zh;var PD=C(()=>{Hq();UH();yW();qB=g(e(),1),DD=g(PZ(),1),Zh=EQ().route("/").render(function(){let{api:q,setError:z}=_J(),_=XJ(),[W,K]=qB.useState([]),[A,L]=qB.useState([]),F=()=>q.listPages().then(K).catch((T)=>z(IX(T)));return qB.useEffect(()=>{F(),q.listBlockTypes().then(L).catch((T)=>z(IX(T)))},[q]),DD.jsxDEV(ND,{api:q,pages:W,blockTypes:A,onOpen:(T)=>_("page",{params:{pageId:T.id}}),onCreated:F,onError:z},void 0,!1,void 0,this)})});var $D={};p_($D,{default:()=>Xh});var SD,Xh;var ED=C(()=>{Hq();UH();yW();SD=g(PZ(),1),Xh=EQ().route("/media").render(function(){let{api:q,setError:z}=_J();return SD.jsxDEV(TD,{api:q,onError:z},void 0,!1,void 0,this)})});var kD={};p_(kD,{default:()=>Yh});var vW,bz,Yh;var xD=C(()=>{Hq();WH();UH();yW();vW=g(e(),1),bz=g(PZ(),1),Yh=EQ().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,F]=vW.useState([]),[T,N]=vW.useState(!1);vW.useEffect(()=>{let j=!0;return N(!1),z.listPages().then((v)=>{if(!j)return;let f=v.find((h)=>h.id===q.pageId)??null;A(f),N(!f)}).catch((v)=>_(IX(v))),z.listBlockTypes().then((v)=>j&&F(v)).catch((v)=>_(IX(v))),()=>{j=!1}},[z,q.pageId,_]);let M=n5.includes(q.tab)?q.tab:"settings",R=(j)=>W("page",{params:{pageId:q.pageId,tab:j},replace:!0});if(T)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(ID,{api:z,page:K,blockTypes:L,tab:M,onTab:R,onBack:()=>W("home"),onChange:A},void 0,!1,void 0,this)})});var yD={};p_(yD,{default:()=>Qh});var vD,Qh;var hD=C(()=>{Hq();UH();yW();vD=g(PZ(),1),Qh=EQ().route("/settings").render(function(){let{api:q,cfg:z,me:_,setError:W,reconfigure:K}=_J();return vD.jsxDEV(VD,{api:q,cfg:z,me:_,onSignOut:K,onError:W},void 0,!1,void 0,this)})});var bD={};p_(bD,{default:()=>Jh});var gz,Jh;var gD=C(()=>{Hq();WH();UH();yW();gz=g(PZ(),1),Jh=EQ().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(wD,{api:q,me:z,onError:W},void 0,!1,void 0,this)})});var mD={};p_(mD,{default:()=>qh});var BH,qh;var fD=C(()=>{Hq();WH();BH=g(PZ(),1),qh=EQ().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 sD=g(e(),1),aD=g(Z2(),1);Hq();var mz=g(e(),1);Hq();WH();UH();var xY=g(PZ(),1);function l5(){let{cfg:J,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=(F)=>A===F?"bg-surface-muted text-fg":"text-fg-muted";return xY.jsxDEV(xY.Fragment,{children:[xY.jsxDEV("div",{className:"sticky top-0 z-10 flex items-center gap-4 bg-surface px-7 py-4",children:[xY.jsxDEV("span",{className:"text-[15px] font-bold tracking-[0.01em] text-fg",children:["pramen ",xY.jsxDEV("span",{className:"font-normal text-fg-subtle",children:"· cms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),xY.jsxDEV("span",{className:"flex-1"},void 0,!1,void 0,this),xY.jsxDEV("nav",{className:"flex items-center gap-0.5",children:[xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("pages"),onPress:()=>W("home"),children:"Pages"},void 0,!1,void 0,this),xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("media"),onPress:()=>W("media"),children:"Media"},void 0,!1,void 0,this),q?xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("users"),onPress:()=>W("users"),children:"Users"},void 0,!1,void 0,this):null,xY.jsxDEV(yZ,{variant:"ghost",size:"sm",className:L("settings"),onPress:()=>W("settings"),children:"Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),xY.jsxDEV("span",{className:"ml-3 text-fg-subtle",children:J.tenant},void 0,!1,void 0,this),xY.jsxDEV(yZ,{variant:"ghost",size:"sm",onPress:_,children:"sign out"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z?xY.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,xY.jsxDEV(a_,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var uD=()=>Promise.resolve().then(() => (PD(),CD)).then((J)=>({default:J.default.component})),dD=()=>Promise.resolve().then(() => (ED(),$D)).then((J)=>({default:J.default.component})),cD=()=>Promise.resolve().then(() => (xD(),kD)).then((J)=>({default:J.default.component})),pD=()=>Promise.resolve().then(() => (hD(),yD)).then((J)=>({default:J.default.component})),lD=()=>Promise.resolve().then(() => (gD(),bD)).then((J)=>({default:J.default.component})),iD=()=>Promise.resolve().then(() => (fD(),mD)).then((J)=>({default:J.default.component})),r5={home:"/",media:"/media",page:"/pages/:pageId",settings:"/settings",users:"/users"},Gh=[{path:"/",component:l5,isLayout:!0,children:[{path:"/home",matchPath:"/",component:mz.lazy(uD),preload:uD},{path:"/media",component:mz.lazy(dD),preload:dD},{path:"/page",matchPath:"/pages/:pageId",component:mz.lazy(cD),preload:cD},{path:"/settings",component:mz.lazy(pD),preload:pD},{path:"/users",component:mz.lazy(lD),preload:lD},{path:"/:__notFound+",component:mz.lazy(iD),preload:iD}]}],t5=o9(Gh);UH();var _F=g(PZ(),1),nD=document.getElementById("app");if(nD)aD.createRoot(nD).render(_F.jsxDEV(sD.StrictMode,{children:_F.jsxDEV(KD,{children:_F.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
package/src/app-context.tsx
CHANGED
|
@@ -16,8 +16,12 @@ declare global {
|
|
|
16
16
|
|
|
17
17
|
/** External sign-in URL, if the host configured one via /config.js. When set, an
|
|
18
18
|
* unauthenticated OR expired session is redirected here instead of the built-in Setup
|
|
19
|
-
* screen — for deployments whose auth (magic-link, SSO, …) lives on a separate page.
|
|
20
|
-
|
|
19
|
+
* screen — for deployments whose auth (magic-link, SSO, …) lives on a separate page.
|
|
20
|
+
*
|
|
21
|
+
* `?setup=1` forces the built-in Setup screen even when a sign-in URL is configured — the
|
|
22
|
+
* bootstrap escape hatch for pasting a first-admin JWT before any account exists. */
|
|
23
|
+
const SIGN_IN_URL: string | undefined =
|
|
24
|
+
typeof window !== "undefined" && !new URLSearchParams(window.location.search).has("setup") ? window.PRAMEN_CMS_EDITOR?.signInUrl : undefined;
|
|
21
25
|
|
|
22
26
|
/** Drop the stale session and hand off to the external sign-in page. */
|
|
23
27
|
function redirectToSignIn(): void {
|