1import{B as e,I as t,O as n,R as r,S as i,U as a,d as o,f as s,h as c,j as l,m as u,s as d,t as f,v as p,x as m}from"./cmsClient-V8g32bKp.js";import{f as h}from"./routing-CWrPCN4D.js";import{c as g,l as ee,o as _,s as v,u as te}from"./BlockEditor-tihOpkEn.js";import{g as y,t as b}from"./BlockRenderer-yPB4cD0u.js";import{K as x,W as S,a as ne,i as C}from"./index-BPPa88yO.js";import{n as w,t as T}from"./FormField-Dq-YpZOR.js";import{t as E}from"./Toggle-XC4XmqQz.js";import{t as re}from"./ColorPicker-D1Eoqxij.js";import{t as D}from"./CollapsiblePanel-BG8XEoUm.js";import{n as O,t as k}from"./useEntityEditor-DnDyMc50.js";import{t as ie}from"./blockData-Dv1PGI6R.js";function A(e){let t=new Map,n=new Map;for(let r of e){let e=r.parentBlockId??null,i=(t.get(e)??-1)+1;t.set(e,i),n.set(r.id,i)}return n}function j(e){let t=new Map;for(let n of e){let e=n.parentBlockId??null;(t.get(e)??t.set(e,[]).get(e)).push(n.id)}return t}function ae(e){let{current:t,saved:n,origIds:r,serialize:i}=e,a=new Set(t.map(e=>e.id)),o=[...r].filter(e=>!a.has(e)),s=A(t),c=new Map(n.map(e=>[e.id,e])),l=[];for(let e of t){let t=s.get(e.id)??0;if(!r.has(e.id)){l.push({id:e.id,order:t,isNew:!0});continue}let n=c.get(e.id);n!==void 0&&JSON.stringify(i(e,t))===JSON.stringify(i(n,n.sort_order??0))||l.push({id:e.id,order:t,isNew:!1})}let u=j(t),d=j(n),f=[];for(let[e,t]of u.entries()){if(t.length<2)continue;let n=d.get(e)??[];t.join(`,`)!==n.join(`,`)&&f.push({parentBlockId:e,blockIds:t})}return{deletes:o,writes:l,reorders:f}}var oe=i(`<div class=u-flex-row><input type=text placeholder="Page title"style=flex:1>`),se=i(`<input type=text placeholder=page-slug>`),ce=i(`<small class=form-help>URL: /`),le=i(`<button type=button class="ui-button ui-button--ghost ui-button--sm">Clear`),ue=i(`<div class=editor-properties__css-head><label>Custom CSS</label><span class=editor-properties__css-spacer>`),de=i(`<select><option value=draft>Draft</option><option value=published>Published</option><option value=archived>Archived`),fe=i(`<select><option value=public>Public</option><option value=member>Members Only</option><option value=patron>Patrons Only`),pe=i(`<div class=editor-properties><div class=editor-properties__main><div class="form-group page-editor__homepage-section"><div class=page-editor__homepage-toggle></div><div class=page-editor__homepage-toggle></div><div class=page-editor__homepage-toggle></div><div class=page-editor__header-row><div class=form-group><label>Header Style</label><div class=u-flex-row style=align-items:center;gap:6px><select><option value>- (use site default)</option><option value=default>Default</option><option value=alt>Alt</option></select></div></div><div class=form-group><label>Header Position</label><div class=u-flex-row style=align-items:center;gap:6px><select><option value>- (use site default)</option><option value=static>Static</option><option value=float>Float</option></select></div></div><div class=form-group><label>Page Background Color</label><div class=u-flex-row style=align-items:center;gap:6px></div></div></div><div class=editor-properties__css></div></div></div><div class=editor-properties__sidebar><div class="form-group page-editor__homepage-section"><small class="form-help page-editor__homepage-help">Show this page at <code>/</code>. The page is still reachable at <code>/</code>. Must be <strong>published</strong> to appear on the public site. Only one page can be the homepage at a time.`),me=i(`<span class=editor-brief__slug>/`),he=i(`<span class=editor-brief><span>`),ge=i(`<span class="editor-pill editor-pill--homepage">Homepage`),_e=i(`<span>`),ve=i(`<button type=button class="ui-button ui-button--secondary ui-button--sm">+ Add Custom CSS`),ye=i(`<h1 class=dynamic-page__title>`),be=i(`<div class="empty-state empty-state--plain">No content blocks to preview`),xe=i(`<div class="dynamic-page page-wrapper">`);function Se(e){return{id:e.id,type:e.type,parentBlockId:e.parentBlockId??null,sort_order:e.order??0,data:{title:e.title||``,content:e.content||``,...e.settings||{}},styleRef:_(e.style)}}function M(e,t){let{title:n,content:r,__styleRef:i,...a}=e.data,o=v(e.data,e.styleRef),s=g(o),c=s===void 0&&o.explicitlyCleared?null:s;return{type:e.type,parentBlockId:e.parentBlockId??null,title:n??void 0,content:r??void 0,settings:Object.keys(a).length>0?a:{},order:t,isVisible:!0,style:c}}var N=()=>{let[i,s]=a(``),[g,_]=a(`left`),[v,A]=a(``),[j,N]=a(!0),[P,F]=a(!0),[I,L]=a(!0),[R,z]=a(``),[B,V]=a(``),[H,U]=a(``),[W,G]=a(``),[Ce,we]=a(!1),Te=()=>$.appearance()?.codeTabWidth??`4`,[K,q]=a(`draft`),[J,Y]=a(`public`),[X,Z]=a(!1),Q=C(),Ee=async(e,t,n,r)=>{let i=ae({current:t,saved:n,origIds:r,serialize:M});for(let t of i.deletes)try{await f.pages.deleteBlock(e,t)}catch(e){if(!(e instanceof d))throw e}let a=new Map(t.map(e=>[e.id,e]));for(let t of i.writes){let n=a.get(t.id);if(!n)continue;let r=M(n,t.order);t.isNew?await f.pages.createBlock(e,{...r,id:t.id}):await f.pages.updateBlock(e,t.id,r)}for(let t of i.reorders)await f.pages.reorderBlocks(e,{parentBlockId:t.parentBlockId,blockIds:t.blockIds})},$=k({entityKind:`page`,listPath:`/admin/pages`,load:e=>f.pages.getById(e),status:K,autoSaveState:()=>({title:i(),titleAlignment:g(),slug:v(),status:K(),accessLevel:J(),isHomepage:X(),showTitle:j(),applyPagePadding:P(),applySiteGutter:I(),headerStyle:R(),headerPosition:B(),backgroundColor:H(),customCss:W()}),validate:()=>i()?v()?null:`Slug is required`:`Title is required`,save:async e=>{let t={title:i(),titleAlignment:g(),slug:v(),status:K(),accessLevel:J(),isHomepage:X(),showTitle:j(),applyPagePadding:P(),applySiteGutter:I(),headerStyle:R()||void 0,headerPosition:B()||void 0,backgroundColor:H(),customCss:W()},n=e.id;return e.isNew?n=(await f.pages.create(t)).id:await f.pages.update(e.id,t),n&&await Ee(n,e.blocks,e.isNew?[]:e.savedBlocks,e.originalBlockIds),n},snapshot:e=>f.pages.snapshotRevision(e),softDelete:e=>f.pages.update(e,{status:`deleted`}),restore:e=>f.pages.update(e,{status:`draft`}),onRestored:()=>
1q(`draft`),messages:{saved:()=>`Page '${i()}' saved`,saveError:`Failed to save page`,deleteError:`Failed to delete page`,restoreError:`Failed to restore page`}}),De=e=>{e.title!=null&&s(e.title),e.titleAlignment!=null&&_(e.titleAlignment),e.slug!=null&&A(e.slug),e.status!=null&&q(e.status),e.accessLevel!=null&&Y(e.accessLevel),e.showTitle!=null&&N(e.showTitle!==!1),e.applyPagePadding!=null&&F(e.applyPagePadding!==!1),e.applySiteGutter!=null&&L(e.applySiteGutter!==!1),e.headerStyle!=null&&z(e.headerStyle),e.headerPosition!=null&&V(e.headerPosition),e.backgroundColor!=null&&U(e.backgroundColor),e.customCss!=null&&G(e.customCss),e.isHomepage!=null&&Z(!!e.isHomepage),Array.isArray(e.blocks)&&$.setBlocks(e.blocks)};r(()=>{let e=$.entity();if(!e)return;s(e.title||``),_(e.titleAlignment||`left`),A(e.slug||``),q(e.status||`draft`),Y(e.accessLevel||`public`),N(e.showTitle!==!1),F(e.applyPagePadding!==!1),L(e.applySiteGutter!==!1),z(e.headerStyle||``),V(e.headerPosition||``),U(e.backgroundColor||``),G(e.customCss||``),Z(!!e.isHomepage);let t=e.blocks;if(t?.length){let e=t.map(e=>Se(e));$.setBlocks(e),$.setSavedBlocks(structuredClone(e)),$.setOriginalBlockIds(new Set(t.map(e=>String(e.id))))}let n=$.autoSave.getDraft();if(n){let t=new Date(e.updatedAt||0).getTime();n.timestamp>t+1e3?(De(n.data),Q.info(`Restored your unsaved draft for this page.`)):$.autoSave.clear()}});let Oe=t(D,{title:`Page Properties`,defaultOpen:!0,get headerContent(){return(()=>{var n=he(),r=n.firstChild;return u(r,()=>i()||`Untitled page`),u(n,t(l,{get when(){return v()},get children(){var e=me();return e.firstChild,u(e,v,null),e}}),null),e(()=>o(r,`editor-brief__title ${i()?``:`editor-brief__title--placeholder`}`)),n})()},get headerExtra(){return[t(l,{get when(){return X()},get children(){return ge()}}),(()=>{var t=_e();return u(t,K),e(()=>o(t,`editor-pill editor-pill--${K()}`)),t})(),(()=>{var t=_e();return u(t,J),e(()=>o(t,`editor-pill editor-pill--${J()}`)),t})()]},get children(){var n=pe(),r=n.firstChild,a=r.firstChild,o=a.firstChild,c=o.nextSibling,d=c.nextSibling,f=d.nextSibling,p=f.firstChild,m=p.firstChild.nextSibling,h=m.firstChild,y=p.nextSibling,b=y.firstChild.nextSibling,x=b.firstChild,S=y.nextSibling.firstChild.nextSibling,ne=f.nextSibling,C=r.nextSibling,D=C.firstChild,O=D.firstChild,k=O.firstChild.nextSibling.nextSibling.nextSibling;return k.firstChild,u(r,t(T,{label:`Title`,get children(){var n=oe(),r=n.firstChild;return r.$$input=e=>{s(e.currentTarget.value),$.markDirty()},u(n,t(ee,{label:`Title alignment`,get value(){return g()||`left`},onChange:e=>{_(e),$.markDirty()}}),null),e(()=>r.value=i()),n}}),a),u(r,t(T,{label:`Slug`,get children(){return[(()=>{var t=se();return t.$$input=e=>{A(e.currentTarget.value),$.markDirty()},e(()=>t.value=v()),t})(),(()=>{var e=ce();return e.firstChild,u(e,v,null),e})()]}}),a),u(o,t(E,{get checked(){return j()},onChange:e=>{N(e),$.markDirty()},label:`Show title on page`}),null),u(o,t(w,{header:`Show title on page`,content:`When on, the page renderer prints this page's title as a heading above the content blocks. Turn it off when your first block (e.g. a hero or carousel) already provides the visual headline and you don't want a duplicate.`}),null),u(c,t(E,{get checked(){return P()},onChange:e=>{F(e),$.markDirty()},label:`Apply Page Padding`}),null),u(c,t(w,{header:`Apply Page Padding`,content:`Apply the site's Page Padding (Settings â Appearance â Layout) to the top and bottom of this page. Default 0 until you set a value there â useful for pushing content down below a floating header.`}),null),u(d,t(E,{get checked(){return I()},onChange:e=>{L(e),$.markDirty()},label:`Apply Site Gutter`}),null),u(d,t(w,{header:`Apply Site Gutter`,content:`Apply the site's Gutter (left/right padding) to this page's content. Turn off for a full-bleed page.`}),null),h.addEventListener(`change`,e=>{z(e.currentTarget.value),$.markDirty()}),u(m,t(w,{header:`Header Style`,content:`Which Site Header colors this page renders. '-' follows the site's 'Default Page Header Style' (Settings â Site Header). 'Default' forces the regular header colors; 'Alt' forces the alternate colors â handy when the page has its own background behind a floating header.`}),null),x.addEventListener(`change`,e=>{V(e.currentTarget.value),$.markDirty()}),u(b,t(w,{header:`Header Position`,content:`How the site header sits on this page. '-' follows the site's 'Header Position' (Settings â Site Header). 'Static' renders the header at the top with the content below it; 'Float' places the header above (overlaying) the page content.`}),null),u(S,t(re,{get value(){return H()},onChange:e=>{U(e),$.markDirty()},clearable:!0,onClear:()=>{U(``),$.markDirty()}}
1),null),u(S,t(w,{header:`Page Background Color`,content:`Background for this page's content area. Empty inherits the site background (Settings â Appearance â Colors). Pick a swatch to stay linked to it, or enter a custom colour.`}),null),u(ne,t(l,{get when(){return Ce()||W().trim()},get fallback(){return(()=>{var e=ve();return e.$$click=()=>we(!0),e})()},get children(){return[(()=>{var e=ue(),n=e.firstChild.nextSibling;return u(e,t(w,{header:`Custom CSS`,content:`Rendered after this page's own styles, so these rules win. Useful for restyling parts of a built-in template â the shop's title and sidebar, say â without a setting per element. Tab indents by the amount set in Settings â Appearance â Code tab width.`}),n),u(e,t(l,{get when(){return W().trim()},get children(){var e=le();return e.$$click=()=>{confirm(`Remove this page's custom CSS?`)&&(G(``),we(!1),$.markDirty())},e}}),null),e})(),t(te,{get value(){return W()},onChange:e=>{G(e),$.markDirty()},get tabWidth(){return Te()},height:`280px`})]}})),u(C,t(T,{label:`Status`,get children(){var t=de();return t.addEventListener(`change`,e=>{q(e.currentTarget.value),$.markDirty()}),e(()=>t.value=K()),t}}),D),u(C,t(T,{label:`Access`,get children(){var t=fe();return t.addEventListener(`change`,e=>{Y(e.currentTarget.value),$.markDirty()}),e(()=>t.value=J()),t}}),D),u(D,t(E,{get checked(){return X()},onChange:e=>{Z(e),$.markDirty()},label:`Use as homepage`}),O),u(k,()=>v()||`slug`,null),e(()=>h.value=R()),e(()=>x.value=B()),n}}),ke=t(ne,{get children(){var r=xe();return u(r,t(l,{get when(){return c(()=>!!i())()&&j()},get children(){var t=ye();return u(t,i),e(e=>p(t,`text-align`,g()||`left`)),t}}),null),u(r,t(n,{get each(){return y($.blocks().map(e=>ie(e,$.params.id)))},children:e=>t(b,{block:e})}),null),u(r,t(l,{get when(){return!$.blocks().length},get children(){return be()}}),null),e(e=>m(r,S(`--site-page-padding`,P(),I()),e)),r}}),Ae=h();return t(O,{containerStyleExtra:()=>x(H()),editor:$,revisionsEntityType:`page`,title:i,status:K,publicUrl:()=>`/${$.entity()?.slug||v()}`,previewStatus:()=>K()===`published`?`Published`:`Draft`,rootClass:()=>`page-editor admin-full-bleed`,labels:{newHeading:`New Page`,editHeading:e=>`Edit Page: ${e||`Untitled`}`,blockEditorTitle:`Page Content`,saveLabel:`Save Page`,deleteLabel:`Delete Page`,previewLabel:`Preview`,restoreLabel:`Restore`,viewLabel:`View â`,deleteModalTitle:`Delete Page`,deleteModalMessage:`Are you sure you want to delete this page? It will be moved to the trash and can be restored later.`,restoreModalTitle:`Restore Page`,restoreModalMessage:`Are you sure you want to restore this page? It will be changed back to draft status.`},properties:Oe,previewBody:ke,onClone:async()=>{let e=$.entity(),t=e?.id;if(!t)return;let n=e?.title||i()||`Untitled`,r=e?.slug||v();try{let e=await f.entities.copy(`page`,t,{title:`${n} (Copy)`,...r?{slug:`${r}-copy`}:{},status:`draft`});e?.id&&Ae(`/admin/pages/${e.id}`)}catch(e){Q.error(`Could not clone this page: ${e.message}`)}},cloneLabel:`Clone`})};s([`input`,`click`]);export{N as default}; 2//# sourceMappingURL=PageEditor-r9QwWDkj.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.