@avocadostudio-ai/cli 0.11.0 → 0.11.1
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/editor-dist/assets/{Editor-EPSED64A-v67Mj6eU.js → Editor-EPSED64A-DQfKV56Z.js} +1 -1
- package/editor-dist/assets/{PuckPrototypeRoute-Bg0Ajkvj.js → PuckPrototypeRoute-b-3hrBRO.js} +4 -4
- package/editor-dist/assets/{Render-CU35UAWV-oIqQ5ogK.js → Render-CU35UAWV-Bw1SX1GE.js} +1 -1
- package/editor-dist/assets/{chunk-2CNEFIQP-D17xZITK.js → chunk-2CNEFIQP-BSjAFi8f.js} +1 -1
- package/editor-dist/assets/{full-N67EAB2Q-DUZXpeF6.js → full-N67EAB2Q-C3-evmbU.js} +1 -1
- package/editor-dist/assets/{index-BAOfCB-R.js → index-Bi9Ztgaj.js} +1 -1
- package/editor-dist/assets/index-CXnWvIPx.css +1 -0
- package/editor-dist/assets/{index-DlMcVY9e.js → index-DK3g9FRS.js} +1 -1
- package/editor-dist/assets/{index-DLDc3yaL.js → index-De_49C4P.js} +2 -2
- package/editor-dist/assets/{loaded-F37CNCVG-DYzSXe4-.js → loaded-F37CNCVG-BbpK14bZ.js} +1 -1
- package/editor-dist/assets/{loaded-H325ZSK5-BMRs-ASR.js → loaded-H325ZSK5-BS8aiM-5.js} +1 -1
- package/editor-dist/assets/{loaded-MIY725CK-C-aVagH0.js → loaded-MIY725CK-CPTND_UZ.js} +1 -1
- package/editor-dist/index.html +2 -2
- package/package.json +2 -2
- package/editor-dist/assets/index-BLX1VSZN.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PuckPrototypeRoute-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PuckPrototypeRoute-b-3hrBRO.js","assets/PuckPrototypeRoute-lKyfvVc1.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var W8=Object.defineProperty;var Z8=(e,t,n)=>t in e?W8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ee=(e,t,n)=>Z8(e,typeof t!="symbol"?t+"":t,n);function Y8(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ex={exports:{}},Af={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -731,7 +731,7 @@ ${n.innerHTML}
|
|
|
731
731
|
`);return}},parse:{}}}}}),Q1e=on.create({name:"heading"}),exe=Q1e.extend({addStorage(){return{markdown:{serialize:Bo.nodes.heading,parse:{}}}}}),txe=on.create({name:"horizontalRule"}),nxe=txe.extend({addStorage(){return{markdown:{serialize:Bo.nodes.horizontal_rule,parse:{}}}}}),rxe=on.create({name:"image"}),ixe=rxe.extend({addStorage(){return{markdown:{serialize:Bo.nodes.image,parse:{}}}}}),sxe=on.create({name:"listItem"}),oxe=sxe.extend({addStorage(){return{markdown:{serialize:Bo.nodes.list_item,parse:{}}}}}),axe=on.create({name:"orderedList"});function lxe(e,t,n){let r=0;for(;n-r>0&&t.child(n-r-1).type.name===e.type.name;r++);return r}const uxe=axe.extend({addStorage(){return{markdown:{serialize(e,t,n,r){const i=t.attrs.start||1,s=String(i+t.childCount-1).length,o=e.repeat(" ",s+2),u=lxe(t,n,r)%2?") ":". ";e.renderList(t,o,d=>{const f=String(i+d);return e.repeat(" ",s-f.length)+f+u})},parse:{}}}}}),cxe=on.create({name:"paragraph"}),dxe=cxe.extend({addStorage(){return{markdown:{serialize:Bo.nodes.paragraph,parse:{}}}}});function Hv(e){var t,n;return(t=e==null||(n=e.content)===null||n===void 0?void 0:n.content)!==null&&t!==void 0?t:[]}const fxe=on.create({name:"table"}),hxe=fxe.extend({addStorage(){return{markdown:{serialize(e,t,n){if(!pxe(t)){Jb.storage.markdown.serialize.call(this,e,t,n);return}e.inTable=!0,t.forEach((r,i,s)=>{if(e.write("| "),r.forEach((o,a,u)=>{u&&e.write(" | ");const d=o.firstChild;d.textContent.trim()&&e.renderInline(d)}),e.write(" |"),e.ensureNewLine(),!s){const o=Array.from({length:r.childCount}).map(()=>"---").join(" | ");e.write(`| ${o} |`),e.ensureNewLine()}}),e.closeBlock(t),e.inTable=!1},parse:{}}}}});function PD(e){return e.attrs.colspan>1||e.attrs.rowspan>1}function pxe(e){const t=Hv(e),n=t[0],r=t.slice(1);return!(Hv(n).some(i=>i.type.name!=="tableHeader"||PD(i)||i.childCount>1)||r.some(i=>Hv(i).some(s=>s.type.name==="tableHeader"||PD(s)||s.childCount>1)))}const mxe=on.create({name:"taskItem"}),gxe=mxe.extend({addStorage(){return{markdown:{serialize(e,t){const n=t.attrs.checked?"[x]":"[ ]";e.write(`${n} `),e.renderContent(t)},parse:{updateDOM(e){[...e.querySelectorAll(".task-list-item")].forEach(t=>{const n=t.querySelector("input");t.setAttribute("data-type","taskItem"),n&&(t.setAttribute("data-checked",n.checked),n.remove())})}}}}}}),bxe=on.create({name:"taskList"}),yxe=bxe.extend({addStorage(){return{markdown:{serialize:dL.storage.markdown.serialize,parse:{setup(e){e.use(I1e)},updateDOM(e){[...e.querySelectorAll(".contains-task-list")].forEach(t=>{t.setAttribute("data-type","taskList")})}}}}}}),xxe=on.create({name:"text"}),vxe=xxe.extend({addStorage(){return{markdown:{serialize(e,t){e.text(U1e(t.text))},parse:{}}}}}),kxe=bi.create({name:"bold"}),Sxe=kxe.extend({addStorage(){return{markdown:{serialize:Bo.marks.strong,parse:{}}}}}),wxe=bi.create({name:"code"}),Cxe=wxe.extend({addStorage(){return{markdown:{serialize:Bo.marks.code,parse:{}}}}}),_xe=bi.create({name:"italic"}),Exe=_xe.extend({addStorage(){return{markdown:{serialize:Bo.marks.em,parse:{}}}}}),Txe=bi.create({name:"link"}),Axe=Txe.extend({addStorage(){return{markdown:{serialize:Bo.marks.link,parse:{}}}}}),Nxe=bi.create({name:"strike"}),Mxe=Nxe.extend({addStorage(){return{markdown:{serialize:{open:"~~",close:"~~",expelEnclosingWhitespace:!0},parse:{}}}}}),Dxe=[W1e,dL,J1e,fL,exe,nxe,Jb,ixe,oxe,uxe,dxe,hxe,gxe,yxe,vxe,Sxe,Cxe,cL,Exe,Axe,Mxe];function rb(e){var t,n;const r=(t=e.storage)===null||t===void 0?void 0:t.markdown,i=(n=Dxe.find(s=>s.name===e.name))===null||n===void 0?void 0:n.storage.markdown;return r||i?{...i,...r}:null}class Rxe{constructor(t){nb(this,"editor",null),this.editor=t}serialize(t){const n=new F1e(this.nodes,this.marks,{hardBreakNodeName:fL.name});return n.renderContent(t),n.out}get nodes(){var t;return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(n=>[n,this.serializeNode(Jb)])),...Object.fromEntries((t=this.editor.extensionManager.extensions.filter(n=>n.type==="node"&&this.serializeNode(n)).map(n=>[n.name,this.serializeNode(n)]))!==null&&t!==void 0?t:[])}}get marks(){var t;return{...Object.fromEntries(Object.keys(this.editor.schema.marks).map(n=>[n,this.serializeMark(cL)])),...Object.fromEntries((t=this.editor.extensionManager.extensions.filter(n=>n.type==="mark"&&this.serializeMark(n)).map(n=>[n.name,this.serializeMark(n)]))!==null&&t!==void 0?t:[])}}serializeNode(t){var n;return(n=rb(t))===null||n===void 0||(n=n.serialize)===null||n===void 0?void 0:n.bind({editor:this.editor,options:t.options})}serializeMark(t){var n;const r=(n=rb(t))===null||n===void 0?void 0:n.serialize;return r?{...r,open:typeof r.open=="function"?r.open.bind({editor:this.editor,options:t.options}):r.open,close:typeof r.close=="function"?r.close.bind({editor:this.editor,options:t.options}):r.close}:null}}class jxe{constructor(t,n){nb(this,"editor",null),nb(this,"md",null);let{html:r,linkify:i,breaks:s}=n;this.editor=t,this.md=this.withPatchedRenderer(Ki({html:r,linkify:i,breaks:s}))}parse(t){let{inline:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof t=="string"){this.editor.extensionManager.extensions.forEach(s=>{var o;return(o=rb(s))===null||o===void 0||(o=o.parse)===null||o===void 0||(o=o.setup)===null||o===void 0?void 0:o.call({editor:this.editor,options:s.options},this.md)});const r=this.md.render(t),i=K2(r);return this.editor.extensionManager.extensions.forEach(s=>{var o;return(o=rb(s))===null||o===void 0||(o=o.parse)===null||o===void 0||(o=o.updateDOM)===null||o===void 0?void 0:o.call({editor:this.editor,options:s.options},i)}),this.normalizeDOM(i,{inline:n,content:t}),i.innerHTML}return t}normalizeDOM(t,n){let{inline:r,content:i}=n;return this.normalizeBlocks(t),t.querySelectorAll("*").forEach(s=>{var o;((o=s.nextSibling)===null||o===void 0?void 0:o.nodeType)===Node.TEXT_NODE&&!s.closest("pre")&&(s.nextSibling.textContent=s.nextSibling.textContent.replace(/^\n/,""))}),r&&this.normalizeInline(t,i),t}normalizeBlocks(t){const r=Object.values(this.editor.schema.nodes).filter(i=>i.isBlock).map(i=>{var s;return(s=i.spec.parseDOM)===null||s===void 0?void 0:s.map(o=>o.tag)}).flat().filter(Boolean).join(",");r&&[...t.querySelectorAll(r)].forEach(i=>{i.parentElement.matches("p")&&H1e(i)})}normalizeInline(t,n){var r;if((r=t.firstElementChild)!==null&&r!==void 0&&r.matches("p")){var i,s,o,a;const u=t.firstElementChild,{nextElementSibling:d}=u,f=(i=(s=n.match(/^\s+/))===null||s===void 0?void 0:s[0])!==null&&i!==void 0?i:"",p=d?"":(o=(a=n.match(/\s+$/))===null||a===void 0?void 0:a[0])!==null&&o!==void 0?o:"";if(n.match(/^\n\n/)){u.innerHTML=`${u.innerHTML}${p}`;return}V1e(u),t.innerHTML=`${f}${t.innerHTML}${p}`}}withPatchedRenderer(t){const n=r=>function(){const i=r(...arguments);return i===`
|
|
732
732
|
`?i:i[i.length-1]===`
|
|
733
733
|
`?i.slice(0,-1):i};return t.renderer.rules.hardbreak=n(t.renderer.rules.hardbreak),t.renderer.rules.softbreak=n(t.renderer.rules.softbreak),t.renderer.rules.fence=n(t.renderer.rules.fence),t.renderer.rules.code_block=n(t.renderer.rules.code_block),t.renderer.renderToken=n(t.renderer.renderToken.bind(t.renderer)),t}}const Ixe=Mn.create({name:"markdownClipboard",addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new Zn({key:new jr("markdownClipboard"),props:{clipboardTextParser:(e,t,n)=>{if(n||!this.options.transformPastedText)return null;const r=this.editor.storage.markdown.parser.parse(e,{inline:!0});return ga.fromSchema(this.editor.schema).parseSlice(K2(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),Oxe=Mn.create({name:"markdown",priority:50,addOptions(){return{html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}},addCommands(){const e=VP.Commands.config.addCommands();return{setContent:(t,n)=>r=>e.setContent(r.editor.storage.markdown.parser.parse(t),n)(r),insertContentAt:(t,n,r)=>i=>e.insertContentAt(t,i.editor.storage.markdown.parser.parse(n,{inline:!0}),r)(i)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new jxe(this.editor,this.options),serializer:new Rxe(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage(){return{}},addExtensions(){return[z1e.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),Ixe.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),hL=vz.extend({addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),anchor:{default:null},uuid:{default:null},linktype:{default:null}}}}).configure({openOnClick:!1}),pL=bi.create({name:"textStyle",addAttributes(){return{color:{default:null}}},parseHTML(){return[{tag:"span",getAttrs:e=>{var t;return(t=e.style)!=null&&t.color?{}:!1}}]},renderHTML({HTMLAttributes:e}){return["span",qn(e),0]}}),mL=Mn.create({name:"avocadoBlockKeys",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock"],attributes:{_key:{default:null,rendered:!1}}}]}});function Pxe(e){if(e&&typeof e=="object"){const t=e;for(const n of["_type","nodeType","type"])if(typeof t[n]=="string")return t[n]}return"Embedded content"}const zxe=on.create({name:"avocadoUnknownBlock",group:"block",atom:!0,selectable:!0,draggable:!0,addAttributes(){return{data:{default:null,rendered:!1},_key:{default:null,rendered:!1}}},parseHTML(){return[{tag:"div[data-avocado-unknown-block]"}]},renderHTML({node:e,HTMLAttributes:t}){return["div",qn(t,{"data-avocado-unknown-block":"",class:"rte-unknown-block"}),Pxe(e.attrs.data)]}}),gL=bi.create({name:"avocadoUnknownHtml",addAttributes(){return{tag:{default:"span",rendered:!1},attributes:{default:null,rendered:!1}}},parseHTML(){return[{tag:"span[data-avocado-unknown-html]"}]},renderHTML({HTMLAttributes:e}){return["span",qn(e,{"data-avocado-unknown-html":"",class:"rte-unknown-html"}),0]}}),bL=on.create({name:"avocadoUnknownInline",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{data:{default:null,rendered:!1}}},parseHTML(){return[{tag:"span[data-avocado-unknown-inline]"}]},renderHTML({HTMLAttributes:e}){return["span",qn(e,{"data-avocado-unknown-inline":"",class:"rte-unknown-inline"})]}}),yL=Mn.create({name:"avocadoHtmlAttributes",addGlobalAttributes(){return[{types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","bold","italic","strike","code"],attributes:{htmlAttributes:{default:null,rendered:!1}}}]}}),Lxe=[L2.configure({heading:{levels:[1,2,3,4,5,6]},link:!1}),hL,pL,mL,yL,zxe,bL,gL],Bxe=on.create({name:"doc",topNode:!0,content:"paragraph"}),$xe=[L2.configure({document:!1,heading:!1,bulletList:!1,orderedList:!1,listItem:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,link:!1}),Bxe,hL,pL,mL,yL,bL,gL],Fxe=new Set(["bold","italic","strike","code","underline","link","textStyle","avocadoUnknownHtml"]);function Uxe(e){return bi.create({name:e,parseHTML(){return[{tag:`span[data-decorator="${e}"]`}]},renderHTML(){return["span",{"data-decorator":e,class:"rte-decorator"},0]}})}function Hxe(e=[],t={}){const n=new Set(Fxe),r=[];for(const s of e){const o=s==null?void 0:s.name;typeof o!="string"||o.length===0||n.has(o)||(n.add(o),r.push(Uxe(o)))}const i=t.inline?$xe:Lxe;return r.length>0?[...i,...r]:i}const zD=340,Vxe=340,qxe=Rre().map(e=>`.${e}`).join(",");function Gxe(e){return e==null||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Kxe(e){var i;const t=(i=e.contentType)==null?void 0:i.split("/").pop(),n=e.path.split(".").pop(),r=t&&t!=="octet-stream"?t:n;return r&&r.length<=5?r.toUpperCase():""}function Wxe({anchorRef:e,initialValue:t,canUpload:n,onCommit:r,onCancel:i}){const{t:s}=_n(),o=fe(O=>O.availablePages),a=fe(O=>O.availableFiles),u=fe(O=>O.filesStatus),d=fe(O=>O.setAvailableFiles),f=fe(O=>O.setFilesStatus);_.useEffect(()=>{Yw()},[]);const[p,g]=_.useState(null);_.useLayoutEffect(()=>{const O=()=>{var L;const $=(L=e.current)==null?void 0:L.getBoundingClientRect();if(!$)return;const ne=window.innerHeight-$.bottom>=zD?$.bottom+6:Math.max(8,$.top-zD-6),P=Math.min(Math.max(8,$.left),Math.max(8,window.innerWidth-Vxe-8));g({top:ne,left:P})};return O(),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[e]);const[y,x]=_.useState(t),[v,S]=_.useState(!1),[w,T]=_.useState(null),[A,M]=_.useState(!1),j=_.useRef(null),D=_.useRef(null),I=_.useRef(null);_.useEffect(()=>{var O,$;(O=j.current)==null||O.focus(),($=j.current)==null||$.select()},[]),_.useEffect(()=>{const O=$=>{var ne,P;const Y=$.target;(ne=I.current)!=null&&ne.contains(Y)||(P=e.current)!=null&&P.contains(Y)||i()};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[e,i]);const R=y.trim(),V=jw(R,o,a),{pages:F,files:W}=_.useMemo(()=>VI(R,{pages:o,files:a,limit:6,browseFiles:!0}),[o,a,R]),U=V.kind==="file"&&u==="loading",q=V.kind==="file"&&u==="unavailable",K=O=>r(O),H=async O=>{S(!0),T(null);try{const $=await bue(O),Y={path:$.url??"",...$.name?{name:$.name}:{},...$.contentType?{contentType:$.contentType}:{},...$.size!=null?{size:$.size}:{}};if(Y.path){d([...(a??[]).filter(ne=>ne.path!==Y.path),Y]),f("ready"),K(Y.path);return}T(s("linkPicker.uploadNoUrl"))}catch($){T($ instanceof Error?$.message:String($))}finally{S(!1)}};return p?Td.createPortal(m.jsxs("div",{ref:I,className:`link-picker${A?" is-dropping":""}`,role:"dialog","aria-label":s("linkPicker.title"),style:{top:p.top,left:p.left},onDragOver:n?O=>{O.dataTransfer.types.includes("Files")&&(O.preventDefault(),O.dataTransfer.dropEffect="copy",M(!0))}:void 0,onDragLeave:n?O=>{O.currentTarget.contains(O.relatedTarget)||M(!1)}:void 0,onDrop:n?O=>{var Y;O.preventDefault(),M(!1);const $=(Y=O.dataTransfer.files)==null?void 0:Y[0];$&&H($)}:void 0,children:[A?m.jsxs("div",{className:"link-picker-drop","aria-hidden":"true",children:[m.jsx(jg,{size:16})," ",s("linkPicker.dropHere")]}):null,m.jsxs("div",{className:"link-picker-head",children:[m.jsx("span",{className:"link-picker-title",children:s("linkPicker.title")}),m.jsx("button",{type:"button",className:"link-picker-close",onClick:i,"aria-label":s("common.cancel"),children:m.jsx($s,{size:13,"aria-hidden":"true"})})]}),m.jsx("input",{ref:j,type:"text",className:"link-picker-input",placeholder:s("linkPicker.placeholder"),value:y,title:y,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",onChange:O=>x(O.target.value),onKeyDown:O=>{O.key==="Escape"&&(O.stopPropagation(),i()),O.key==="Enter"&&(O.preventDefault(),K(R))}}),R!==""&&V.missing===!0?m.jsxs("div",{className:"link-picker-warn",children:[m.jsx(PS,{size:11,"aria-hidden":"true"})," ",s(V.kind==="file"?"linkPicker.noFile":"linkPicker.noPage")]}):null,q?m.jsx("div",{className:"link-picker-note",children:s("linkPicker.filesUnavailable",{orchestrator:$e})}):null,m.jsxs("div",{className:"link-picker-list",role:"listbox",children:[F.map(O=>{var $;return m.jsxs("button",{type:"button",role:"option","aria-selected":(($=V.page)==null?void 0:$.slug)===O.slug,className:"link-picker-option",onMouseDown:Y=>Y.preventDefault(),onClick:()=>K(O.path??O.slug),children:[m.jsx(ib,{size:12,"aria-hidden":"true"}),m.jsx("span",{className:"link-picker-option-title",children:O.title||O.slug}),m.jsx("span",{className:"link-picker-option-path",title:O.path??O.slug,children:O.path??O.slug})]},`p:${O.slug}`)}),W.map(O=>{var $;return m.jsxs("button",{type:"button",role:"option","aria-selected":(($=V.file)==null?void 0:$.path)===O.path,className:"link-picker-option",onMouseDown:Y=>Y.preventDefault(),title:O.path,onClick:()=>K(O.path),children:[m.jsx(sb,{size:12,"aria-hidden":"true"}),m.jsx("span",{className:"link-picker-option-title",children:O.name??O.path.split("/").pop()}),m.jsx("span",{className:"link-picker-option-meta",children:[Kxe(O),Gxe(O.size)].filter(Boolean).join(" · ")})]},`f:${O.path}`)}),U&&W.length===0?m.jsxs("div",{className:"link-picker-empty",children:[m.jsx(Jv,{size:12,className:"link-picker-spin","aria-hidden":"true"})," ",s("linkPicker.loadingFiles")]}):null,!U&&F.length===0&&W.length===0?m.jsx("div",{className:"link-picker-empty",children:V.kind==="external"?m.jsxs(m.Fragment,{children:[m.jsx(Rg,{size:12,"aria-hidden":"true"})," ",s("linkPicker.externalHint")]}):V.kind==="email"?s("linkPicker.emailHint"):V.kind==="phone"?s("linkPicker.phoneHint"):V.kind==="anchor"?s("linkPicker.anchorHint"):s("linkPicker.noMatches")}):null]}),w?m.jsx("div",{className:"link-picker-warn",children:w}):null,m.jsxs("div",{className:"link-picker-foot",children:[n?m.jsxs(m.Fragment,{children:[m.jsx("input",{ref:D,type:"file",hidden:!0,accept:qxe,onChange:O=>{var Y;const $=(Y=O.target.files)==null?void 0:Y[0];O.target.value="",$&&H($)}}),m.jsxs("button",{type:"button",className:"link-picker-upload",disabled:v,title:s("linkPicker.uploadHint"),onClick:()=>{var O;return(O=D.current)==null?void 0:O.click()},children:[v?m.jsx(Jv,{size:12,className:"link-picker-spin","aria-hidden":"true"}):m.jsx(jg,{size:12,"aria-hidden":"true"})," ",s(v?"linkPicker.uploading":"linkPicker.upload")]})]}):m.jsx("span",{}),m.jsxs("div",{className:"link-picker-actions",children:[t!==""?m.jsx("button",{type:"button",className:"link-picker-remove",onClick:()=>K(""),children:s("linkPicker.remove")}):null,m.jsx("button",{type:"button",className:"link-picker-apply",onClick:()=>K(R),children:s("linkPicker.apply")})]})]})]}),document.body):null}const ca=14,Zxe=[L2.configure({heading:{levels:[2,3,4,5,6]},link:!1,underline:!1}),vz.configure({openOnClick:!1}),Oxe.configure({html:!1,transformPastedText:!0,transformCopiedText:!0})];function Yxe(e){var n,r;const t=(r=(n=e.storage.markdown)==null?void 0:n.getMarkdown)==null?void 0:r.call(n);return typeof t=="string"?t:""}function vo({active:e,onClick:t,title:n,className:r,children:i}){return m.jsx("button",{type:"button",className:`rte-toolbar-btn${e?" is-active":""}${r?` ${r}`:""}`,onClick:t,title:n,onMouseDown:s=>s.preventDefault(),children:i})}function xL({editor:e,trailing:t,decorators:n,inline:r}){const[i,s]=_.useState(!1),o=_.useRef(null),a=fe(f=>f.canUploadFiles),u=e.getAttributes("link").href??"",d=_.useCallback(f=>{if(s(!1),f===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:f}).run()},[e]);return m.jsxs("div",{className:`rte-toolbar${t?" rte-toolbar--with-trailing":""}`,children:[m.jsx(vo,{active:e.isActive("bold"),onClick:()=>e.chain().focus().toggleBold().run(),title:"Bold",children:m.jsx(EB,{size:ca})}),m.jsx(vo,{active:e.isActive("italic"),onClick:()=>e.chain().focus().toggleItalic().run(),title:"Italic",children:m.jsx(p9,{size:ca})}),m.jsx(vo,{active:e.isActive("strike"),onClick:()=>e.chain().focus().toggleStrike().run(),title:"Strikethrough",children:m.jsx(Y9,{size:ca})}),!r&&m.jsx("span",{className:"rte-toolbar-sep"}),!r&&m.jsx(vo,{active:e.isActive("heading",{level:2}),onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:m.jsx(n9,{size:ca})}),!r&&m.jsx(vo,{active:e.isActive("heading",{level:3}),onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:m.jsx(o9,{size:ca})}),!r&&m.jsx(vo,{active:e.isActive("heading",{level:4}),onClick:()=>e.chain().focus().toggleHeading({level:4}).run(),title:"Heading 4",children:m.jsx(i9,{size:ca})}),!r&&m.jsx("span",{className:"rte-toolbar-sep"}),!r&&m.jsx(vo,{active:e.isActive("bulletList"),onClick:()=>e.chain().focus().toggleBulletList().run(),title:"Bullet list",children:m.jsx(x9,{size:ca})}),!r&&m.jsx(vo,{active:e.isActive("orderedList"),onClick:()=>e.chain().focus().toggleOrderedList().run(),title:"Ordered list",children:m.jsx(b9,{size:ca})}),m.jsx("span",{className:"rte-toolbar-sep"}),m.jsxs("span",{className:"rte-link-anchor",ref:o,children:[m.jsx(vo,{active:e.isActive("link"),onClick:()=>s(f=>!f),title:"Link",children:m.jsx(JD,{size:ca})}),i?m.jsx(Wxe,{anchorRef:o,initialValue:u,canUpload:a,onCommit:d,onCancel:()=>s(!1)}):null]}),(n??[]).map(f=>m.jsx(vo,{className:"rte-toolbar-btn--tag",active:e.isActive(f.name),onClick:()=>e.chain().focus().toggleMark(f.name).run(),title:f.title??f.name,children:f.title??f.name},f.name)),t?m.jsx("div",{className:"rte-toolbar-trailing",children:t}):null]})}function Jxe({value:e,onChange:t,onFocus:n,onBlur:r,trailing:i}){const s=_.useRef(!1),o=_.useRef(e),a=oz({extensions:Zxe,content:H3(e),onUpdate:({editor:u})=>{if(s.current)return;const d=Yxe(u);o.current=d,t(d)},onFocus:()=>n==null?void 0:n(),onBlur:()=>r==null?void 0:r()});return _.useEffect(()=>{if(!a||a.isDestroyed||e===o.current)return;o.current=e,s.current=!0;const{from:u,to:d}=a.state.selection;a.commands.setContent(H3(e));const f=a.state.doc.content.size,p=Math.min(u,f),g=Math.min(d,f);try{a.commands.setTextSelection({from:p,to:g})}catch{}s.current=!1},[e,a]),a?m.jsxs("div",{className:"rte-wrap",children:[m.jsx(xL,{editor:a,trailing:i}),m.jsx(_2,{editor:a,className:"rte-content"})]}):null}function vL({value:e,onChange:t,onFocus:n,onBlur:r,decorators:i,inline:s}){const o=_.useRef(!1),a=_.useRef(JSON.stringify(e)),u=`${s?"inline":"block"}:${(i??[]).map(p=>p.name).join(",")}`,d=_.useMemo(()=>Hxe(i??[],{inline:s}),[u]),f=oz({extensions:d,content:e,onUpdate:({editor:p})=>{if(o.current)return;const g=p.getJSON();a.current=JSON.stringify(g),t(g)},onFocus:()=>n==null?void 0:n(),onBlur:()=>r==null?void 0:r()},[u]);return _.useEffect(()=>{if(!f||f.isDestroyed)return;const p=JSON.stringify(e);if(p===a.current)return;a.current=p,o.current=!0;const{from:g,to:y}=f.state.selection;f.commands.setContent(e);const x=f.state.doc.content.size;try{f.commands.setTextSelection({from:Math.min(g,x),to:Math.min(y,x)})}catch{}o.current=!1},[e,f]),f?m.jsxs("div",{className:`rte-wrap${s?" rte-wrap--inline":""}`,children:[m.jsx(xL,{editor:f,decorators:i,inline:s}),m.jsx(_2,{editor:f,className:"rte-content"})]}):null}const LD=new Set(["text","richtext","imageAlt"]),Xxe=()=>{};function W2(e,t){const n=_.useRef(null),r=_.useRef(void 0);return _.useEffect(()=>{if(!e||!t||t!==e){r.current=t;return}if(r.current===t)return;const i=r.current;r.current=t;const s=n.current;if(!s)return;s.scrollIntoView({behavior:"smooth",block:"nearest"}),s.classList.add("property-field--flash");const o=setTimeout(()=>s.classList.remove("property-field--flash"),1800);return()=>{clearTimeout(o),s.classList.remove("property-field--flash"),r.current=i}},[e,t]),n}const Qxe=Sn.memo(function({style:t,blockId:n,blockType:r,props:i,status:s,failure:o,failedSlug:a,failedOrigin:u,onRetry:d,onFieldChange:f,onImageClick:p,onAiAssist:g,slug:y,pageName:x,navLabel:v,onNavLabelChange:S,pageMeta:w,onPageMetaChange:T,onDeselectBlock:A,onPageAiAssist:M,onAiQuickAction:j,onPageAiQuickAction:D,aiLoading:I,aiLoadingPath:R,onAddListItem:V,onRemoveListItem:F,highlightPath:W,manifestByType:U,siteOrigin:q,onClose:K}){const H=fe(ee=>ee.activeBlockId),O=fe(ee=>ee.activeBlockType),$=fe(ee=>ee.slug),Y=fe(ee=>ee.isLoading),ne=fe(ee=>ee.activeEditablePath),P=n??H,L=r??O,J=y??$,z=I??Y,Q=R??ne,oe=W??ne,{t:se}=_n(),ie=K?m.jsx("button",{type:"button",className:"property-panel-context-close",onClick:K,"aria-label":se("propertyPanel.close"),title:se("propertyPanel.close"),children:m.jsx($s,{size:16})}):null,Me=m.jsxs("div",{className:"property-panel-context property-panel-context--page",children:[m.jsxs("svg",{className:"property-panel-context-icon",viewBox:"0 0 16 16",width:"16",height:"16",fill:"none","aria-hidden":"true",children:[m.jsx("path",{d:"M3.5 1.5h6L13 5v9a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5v-12a.5.5 0 0 1 .5-.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),m.jsx("path",{d:"M9.5 1.5V5h3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})]}),m.jsx("div",{className:"property-panel-context-text",children:m.jsx("span",{className:"property-panel-context-breadcrumb",children:m.jsx("span",{className:"property-panel-context-breadcrumb-current",children:se("propertyPanel.page")})})}),ie]});if(!P||!L)return m.jsxs("div",{className:"property-panel",style:t,children:[Me,m.jsxs("div",{className:"property-panel-fields",children:[J&&J!=="/"&&S?m.jsx(dve,{slug:J,navLabel:v??"",onNavLabelChange:S,onAiAssist:M,onAiQuickAction:D,aiLoading:z,fieldShimmer:z===!0&&Q==="Nav label"}):null,J&&T?m.jsx(fve,{pageMeta:w??{},onPageMetaChange:T,onAiAssist:M,onAiQuickAction:D,aiLoading:z,aiLoadingPath:Q}):null]})]});const ke=pu(),Oe=U==null?void 0:U.get(L),ce=Oe?Ere(Oe,ke[L]):ke[L];return ce?m.jsxs("div",{className:"property-panel",style:t,children:[m.jsxs("div",{className:"property-panel-context property-panel-context--component",children:[m.jsxs("svg",{className:"property-panel-context-icon",viewBox:"0 0 16 16",width:"16",height:"16",fill:"none","aria-hidden":"true",children:[m.jsx("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),m.jsx("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),m.jsx("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"}),m.jsx("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2"})]}),m.jsx("div",{className:"property-panel-context-text",children:m.jsxs("span",{className:"property-panel-context-breadcrumb",children:[m.jsx("button",{type:"button",className:"property-panel-context-breadcrumb-link",onClick:A,children:se("propertyPanel.page")}),m.jsx("span",{className:"property-panel-context-breadcrumb-sep","aria-hidden":"true",children:"›"}),m.jsx("span",{className:"property-panel-context-breadcrumb-current",children:ce.displayName})]})}),ie]}),(s==="loading"||s==="idle"&&!i)&&!i?m.jsx("div",{className:"property-panel-empty",children:se("propertyPanel.loading")}):s==="error"?m.jsx(eve,{failure:o??"unreachable",slug:a??J,origin:u,onRetry:d}):i?m.jsxs("div",{className:"property-panel-fields",children:[Object.keys(ce.fields).length>0?m.jsx(Xb,{id:`block:${L}:fields`,title:se("propertyPanel.content"),count:Object.keys(ce.fields).length,children:kL(Object.entries(ce.fields),i,"",L,f,p,g,j,z,Q,oe,q)}):null,ce.listFields?Object.entries(ce.listFields).map(([ee,Re])=>{const Ce=Array.isArray(i[ee])?i[ee]:[];return m.jsx(ave,{listKey:ee,listField:Re,items:Ce,blockType:L,onFieldChange:f,onImageClick:p,onAiAssist:g,onAiQuickAction:j,aiLoading:z,aiLoadingPath:Q,highlightPath:oe,onAddItem:V?()=>V(ee):void 0,onRemoveItem:F?Je=>F(ee,Je):void 0,siteOrigin:q},ee)}):null]}):null]}):m.jsxs("div",{className:"property-panel",style:t,children:[Me,m.jsxs("div",{className:"property-panel-empty",children:[se("propertyPanel.unknownBlock"),": ",L]})]})});function Xb({id:e,title:t,count:n,headerExtra:r,children:i}){const[s,o]=Oj(e);return m.jsxs("div",{className:`property-section${s?" is-collapsed":""}`,children:[m.jsxs("div",{className:"property-section-header",children:[m.jsxs("button",{type:"button",className:"property-section-toggle",onClick:o,"aria-expanded":!s,children:[m.jsx("span",{className:"property-section-chevron","aria-hidden":"true"}),m.jsx("span",{className:"property-section-title",children:t}),typeof n=="number"?m.jsx("span",{className:"property-section-count",children:n}):null]}),r]}),s?null:m.jsx("div",{className:"property-section-body",children:i})]})}function eve({failure:e,slug:t,origin:n,onRetry:r}){const{t:i}=_n(),s=i(e==="blockMissing"?"propertyPanel.loadFailedMissing":e==="pageMissing"?"propertyPanel.loadFailedNoPage":"propertyPanel.loadFailed"),o=i(e==="blockMissing"?"propertyPanel.loadFailedMissingHint":e==="pageMissing"?"propertyPanel.loadFailedNoPageHint":"propertyPanel.loadFailedUnreachableHint");return m.jsxs("div",{className:"property-panel-empty",children:[s,m.jsx("div",{className:"sites-form-hint",style:{marginTop:8},children:o}),e!=="unreachable"||n?m.jsxs("div",{className:"sites-form-hint",style:{marginTop:8},children:[m.jsx("code",{children:t}),n?m.jsxs(m.Fragment,{children:[" · ",m.jsx("code",{children:n})]}):null]}):null,r?m.jsx("button",{type:"button",className:"property-panel-retry",onClick:r,style:{marginTop:12},children:i("propertyPanel.retry")}):null]})}function BD(e,t){return!!(e==="imageUrl"&&t==="imageAlt"||e==="src"&&t==="alt"||e.endsWith(".src")&&t===e.replace(/\.src$/,".alt"))}function $D(e){try{const n=new URL(e,"http://localhost").pathname.split("/").pop()||"";return n.length>30?n.slice(0,27)+"...":n||"(image)"}catch{return e.length>30?e.slice(0,27)+"...":e||"(empty)"}}function kL(e,t,n,r,i,s,o,a,u,d,f,p){const g=new Set,y=new Set,x=new Set(e.map(([S])=>S));for(let S=0;S<e.length;S++){const[w,T]=e[S];if(T.kind==="image")for(const[A,M]of e)M.kind==="imageAlt"&&BD(w,A)&&g.add(A);if(T.kind==="link"||T.kind==="file"){const A=F3(w);x.has(A)&&y.add(A)}}const v=[];for(const[S,w]of e)if(!w.internal&&!g.has(S)&&!y.has(S))if(w.kind==="stringList"){const T=t[S];v.push(m.jsx(sve,{label:w.label??S,values:Array.isArray(T)?T.map(A=>A==null?"":String(A)):[],basePath:n+S,onFieldChange:i},S))}else if(w.kind==="imageList"){const T=t[S];v.push(m.jsx(ove,{label:w.label??S,rows:Array.isArray(T)?T:[],basePath:n+S,blockType:r,siteOrigin:p,onFieldChange:i,onImageClick:s},S))}else if(w.kind==="image"){const T=e.find(([j,D])=>D.kind==="imageAlt"&&BD(S,j)),A=T==null?void 0:T[0],M=A?t[A]==null?"":String(t[A]):void 0;v.push(m.jsx(wL,{label:w.label??S,blockType:r,imageUrl:t[S]==null?"":String(t[S]),altText:M,onChangeClick:()=>s==null?void 0:s(n+S,t[S]==null?"":String(t[S])),onRemove:()=>{i(n+S,""),A&&i(n+A,"")},onAltCommit:A?j=>i(n+A,j):void 0,onAltAiAssist:A&&o?()=>o(n+A,"Alt text","imageAlt",M??""):void 0,onAltAiQuickAction:A&&a?j=>a(n+A,"Alt text","imageAlt",M??"",j):void 0,fieldPath:n+S,...A?{altFieldPath:n+A}:{},highlightPath:f,aiLoading:u,fieldShimmer:u===!0&&A!=null&&d===n+A,siteOrigin:p},S))}else if(w.kind==="link"||w.kind==="file"){const T=F3(S),A=y.has(T);v.push(m.jsx(rve,{label:w.label??S,required:w.required,value:t[S]==null?"":String(t[S]),newTab:A?t[T]===!0:void 0,onCommit:M=>i(n+S,M),onNewTabCommit:A?M=>i(n+T,M):void 0,fieldPath:n+S,highlightPath:f,siteOrigin:p},S))}else v.push(m.jsx(cve,{fieldKey:S,field:w,value:t[S],blockType:r,onCommit:T=>i(n+S,T),onAiAssist:LD.has(w.kind)&&o?()=>o(n+S,w.label??S,w.kind,t[S]==null?"":String(t[S])):void 0,onAiQuickAction:LD.has(w.kind)&&a?T=>a(n+S,w.label??S,w.kind,t[S]==null?"":String(t[S]),T):void 0,aiLoading:u,fieldShimmer:u===!0&&d===n+S,highlightPath:f,fieldPath:n+S},S));return v}const tve={empty:JD,page:ib,file:sb,external:Rg,email:S9,phone:D9,anchor:e9},nve=8;function Vv(e){var n;const t=(n=e.title)==null?void 0:n.trim();return t&&t.length>0?t:e.slug}function rve({label:e,required:t,value:n,newTab:r,onCommit:i,onNewTabCommit:s,fieldPath:o,highlightPath:a,siteOrigin:u}){const{t:d}=_n(),f=fe($=>$.availablePages),p=fe($=>$.availableFiles),g=a!=null&&a===o,y=W2(g?a:void 0,a),[x,v]=_.useState(!1),[S,w]=_.useState(n),[T,A]=_.useState(!1),M=_.useRef(null),{debouncedCommit:j,flushCommit:D}=jd(i,400),I=T?S:n,R=jw(n,f,p),V=tve[R.kind],F=R.kind==="external"?$re(n,u):void 0,{pages:W,files:U}=_.useMemo(()=>VI(T?S:"",{pages:f,files:p,limit:nve}),[f,p,S,T]),q=_.useMemo(()=>T?void 0:Bre(n,f),[n,f,T]);_.useEffect(()=>{if(!x)return;const $=Y=>{var ne;(ne=M.current)!=null&&ne.contains(Y.target)||v(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[x]);const K=$=>{const Y=$.path??$.slug;w(Y),D(),i(Y),v(!1)},H=$=>{w($.path),D(),i($.path),v(!1)},O=s!=null&&R.kind==="external";return m.jsxs("div",{className:`property-field${g?" is-targeted":""}`,ref:y,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[e,t&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsxs("div",{className:"property-field-link",ref:M,children:[m.jsxs("div",{className:"property-field-link-input-wrap",children:[m.jsx(V,{size:13,className:"property-field-link-icon","aria-hidden":"true"}),m.jsx("input",{type:"text",className:"property-field-input property-field-link-input",placeholder:d("propertyPanel.linkPlaceholder"),value:I,onFocus:()=>{Yw(),w(n),A(!0),v(!0)},onChange:$=>{w($.target.value),v(!0),j($.target.value)},onBlur:()=>{A(!1),D()},onKeyDown:$=>{if($.key==="Escape"&&x&&($.stopPropagation(),v(!1)),$.key==="Enter"&&x){const Y=W[0];Y&&S.trim()!==""&&S!==n?($.preventDefault(),K(Y)):v(!1)}}}),m.jsx("button",{type:"button",className:"property-field-link-toggle","aria-label":d("propertyPanel.linkBrowsePages"),"aria-expanded":x,onClick:()=>v($=>!$),children:m.jsx(Ol,{size:13,"aria-hidden":"true"})})]}),!T&&R.kind==="page"&&R.page?m.jsx("div",{className:"property-field-link-note",children:Vv(R.page)}):null,!T&&R.kind==="file"&&R.file?m.jsx("div",{className:"property-field-link-note",children:R.file.name??$D(R.file.path)}):null,R.missing===!0?m.jsxs("div",{className:"property-field-link-note property-field-link-note--warn",children:[m.jsx(PS,{size:11,"aria-hidden":"true"})," ",d(R.kind==="file"?"propertyPanel.linkNoFile":"propertyPanel.linkNoPage")]}):null,q?m.jsx("button",{type:"button",className:"property-field-link-convert",onClick:()=>{const $=q.path??q.slug;w($),i($)},children:d("propertyPanel.linkDidYouMean",{page:Vv(q)})}):null,F?m.jsx("button",{type:"button",className:"property-field-link-convert",onClick:()=>{w(F),i(F)},children:d("propertyPanel.linkUseInternal",{path:F})}):null,O?m.jsxs("label",{className:"property-field-link-newtab",children:[m.jsx("input",{type:"checkbox",checked:r===!0,onChange:$=>s==null?void 0:s($.target.checked)}),m.jsx("span",{children:d("propertyPanel.linkNewTab")})]}):null,x?m.jsxs("div",{className:"property-field-link-menu",role:"listbox",children:[W.map($=>{var Y,ne;return m.jsxs("button",{type:"button",role:"option","aria-selected":((Y=R.page)==null?void 0:Y.slug)===$.slug,className:`property-field-link-option${((ne=R.page)==null?void 0:ne.slug)===$.slug?" is-current":""}`,onMouseDown:P=>P.preventDefault(),onClick:()=>K($),children:[m.jsx(ib,{size:12,"aria-hidden":"true"}),m.jsx("span",{className:"property-field-link-option-title",children:Vv($)}),m.jsx("span",{className:"property-field-link-option-slug",children:$.path??$.slug})]},$.slug)}),U.map($=>{var Y,ne;return m.jsxs("button",{type:"button",role:"option","aria-selected":((Y=R.file)==null?void 0:Y.path)===$.path,className:`property-field-link-option${((ne=R.file)==null?void 0:ne.path)===$.path?" is-current":""}`,onMouseDown:P=>P.preventDefault(),onClick:()=>H($),children:[m.jsx(sb,{size:12,"aria-hidden":"true"}),m.jsx("span",{className:"property-field-link-option-title",children:$.name??$D($.path)}),m.jsx("span",{className:"property-field-link-option-slug",children:$.path})]},$.path)}),W.length===0&&U.length===0?m.jsx("div",{className:"property-field-link-empty",children:d("propertyPanel.linkNoMatches")}):null]}):null]})]})}function Yh({onClick:e,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i,onQuickAction:s,onCustomPrompt:o,aiLoading:a,variant:u="overlay"}){const[d,f]=_.useState(null),p=y=>{s&&t&&n&&r!==void 0?f(y.currentTarget.getBoundingClientRect()):e()},g=u==="toolbar"?"rte-toolbar-ai-btn":"property-field-ai-btn";return m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:`${g}${a?` ${g}--loading`:""}`,onClick:p,onMouseDown:y=>y.preventDefault(),title:"AI suggestions",children:a?m.jsx(kh,{size:14,"aria-hidden":"true"}):m.jsx(XD,{size:14,"aria-hidden":"true"})}),d&&t&&n&&r!==void 0&&m.jsx(ive,{anchorRect:d,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i??"",aiLoading:a,onSelect:y=>{f(null),s==null||s(y)},onCustomPrompt:()=>{f(null),(o??e)()},onDismiss:()=>f(null)})]})}function ive({anchorRect:e,fieldKind:t,fieldLabel:n,blockType:r,currentValue:i,aiLoading:s,onSelect:o,onCustomPrompt:a,onDismiss:u}){const d=Kue(t,n,r,i),p=window.innerHeight-e.bottom<160,g=p?void 0:e.bottom+4,y=p?window.innerHeight-e.top+4:void 0,x=window.innerWidth-e.right;return _.useEffect(()=>{const v=S=>{S.key==="Escape"&&u()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[u]),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"ai-quick-actions-backdrop",onClick:u}),m.jsxs("div",{className:"ai-quick-actions-menu",style:{top:g,bottom:y,right:x},children:[d.map(v=>m.jsxs("button",{type:"button",className:"ai-quick-actions-item",disabled:s,onClick:()=>o(v),children:[m.jsx(XD,{size:12,"aria-hidden":"true"}),v]},v)),m.jsx("div",{className:"ai-quick-actions-divider"}),m.jsxs("button",{type:"button",className:"ai-quick-actions-item ai-quick-actions-item--custom",onClick:a,children:[m.jsx(N9,{size:12,"aria-hidden":"true"}),"Custom prompt..."]})]})]})}function SL(e,t){return!e||!t||/^https?:\/\//i.test(e)?e:e.startsWith("/")?`${t}${e}`:e}function sve({label:e,values:t,basePath:n,onFieldChange:r}){const{t:i}=_n();return m.jsxs("div",{className:"property-field property-field--list",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:e})}),m.jsx("div",{className:"property-list-rows",children:t.map((s,o)=>m.jsxs("div",{className:"property-list-row",children:[m.jsx("input",{className:"property-field-input",value:s,onChange:a=>r(`${n}[${o}]`,a.target.value)}),m.jsx("button",{type:"button",className:"property-list-item-remove-btn",title:i("propertyPanel.removeItem"),onClick:()=>r(n,t.filter((a,u)=>u!==o)),children:"×"})]},`${n}-${o}`))}),m.jsx("button",{type:"button",className:"property-list-add-btn",onClick:()=>r(n,[...t,""]),children:i("propertyPanel.addItem")})]})}function ove({label:e,rows:t,basePath:n,blockType:r,siteOrigin:i,onFieldChange:s,onImageClick:o}){const{t:a}=_n(),u=t.find(p=>p&&typeof p=="object")??{},d=["url","imageUrl","src","image"].find(p=>p in u)??"url",f=["alt","imageAlt","image_alt"].find(p=>p in u)??"alt";return m.jsxs("div",{className:"property-field property-field--list",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:e})}),m.jsx("div",{className:"property-list-rows",children:t.map((p,g)=>{const y=`${n}[${g}]`,x=(p==null?void 0:p[d])==null?"":String(p[d]),v=(p==null?void 0:p[f])==null?"":String(p[f]);return m.jsx(wL,{label:`${e} ${g+1}`,blockType:r,imageUrl:x,altText:v,fieldPath:`${y}.${d}`,altFieldPath:`${y}.${f}`,onChangeClick:()=>o==null?void 0:o(`${y}.${d}`,x),onRemove:()=>s(n,t.filter((S,w)=>w!==g)),onAltCommit:S=>s(`${y}.${f}`,S),siteOrigin:i},y)})}),m.jsx("button",{type:"button",className:"property-list-add-btn",onClick:()=>s(n,[...t,{[d]:"",[f]:""}]),children:a("propertyPanel.addItem")})]})}function wL({label:e,blockType:t,imageUrl:n,altText:r,fieldPath:i,altFieldPath:s,highlightPath:o,onChangeClick:a,onRemove:u,onAltCommit:d,onAltAiAssist:f,onAltAiQuickAction:p,aiLoading:g,fieldShimmer:y,siteOrigin:x}){const{t:v}=_n(),S=o&&(o===i||o===s),w=W2(S?o:void 0,o),T=S&&o===s,A=`property-field${S?" is-targeted":""}`,[M,j]=_.useState(r??""),[D,I]=_.useState(!1),[R,V]=_.useState(!1),F=D?M:r??"",{debouncedCommit:W,flushCommit:U}=jd(d??Xxe,400);return m.jsxs("div",{className:A,ref:w,children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:e})}),m.jsxs("div",{className:"property-field-image-widget",children:[n&&!R?m.jsxs("div",{className:"property-field-image-preview",children:[m.jsx("img",{className:"property-field-image-thumb",src:SL(n,x),alt:"",onError:()=>V(!0)}),m.jsxs("div",{className:"property-field-image-actions",children:[m.jsxs("button",{type:"button",className:"property-field-image-change",onClick:a,children:[m.jsx(L9,{size:13})," ",v("propertyPanel.change")]}),u?m.jsxs("button",{type:"button",className:"property-field-image-remove",onClick:u,children:[m.jsx(OS,{size:13})," ",v("propertyPanel.remove")]}):null]})]}):m.jsxs("button",{type:"button",className:"property-field-image-empty",onClick:a,children:[m.jsx(l9,{size:18,"aria-hidden":"true"}),m.jsx("span",{children:v("propertyPanel.chooseImage")})]}),d!==void 0&&m.jsxs("div",{className:"property-field-image-alt-group",children:[m.jsx("div",{className:"property-field-image-alt-label",children:m.jsx("span",{children:v("propertyPanel.altText")})}),m.jsxs("div",{className:`property-field-input-wrap${y?" property-field-input-wrap--ai-loading":""}`,children:[m.jsx("input",{type:"text",className:`property-field-image-alt${T?" is-targeted":""}`,placeholder:v("propertyPanel.altPlaceholder"),value:F,onFocus:()=>{j(r??""),I(!0)},onChange:q=>{j(q.target.value),W(q.target.value)},onBlur:()=>{I(!1),U()}}),f?m.jsx(Yh,{onClick:f,fieldKind:"imageAlt",fieldLabel:v("propertyPanel.altText"),blockType:t??"",currentValue:r??"",onQuickAction:p,onCustomPrompt:f,aiLoading:y}):null]})]})]})]})}function ave({listKey:e,listField:t,items:n,blockType:r,onFieldChange:i,onImageClick:s,onAiAssist:o,onAiQuickAction:a,aiLoading:u,aiLoadingPath:d,highlightPath:f,onAddItem:p,onRemoveItem:g,siteOrigin:y}){const[x,v]=_.useState(null),S=t.label??e;return _.useEffect(()=>{if(!f)return;const w=`${e}[`;if(!f.startsWith(w))return;const T=f.slice(w.length),A=T.indexOf("]");if(A<0)return;const M=Number(T.slice(0,A));!Number.isNaN(M)&&M>=0&&M<n.length&&v(M)},[f,e,n.length]),m.jsxs(Xb,{id:`list:${r}:${e}`,title:S,count:n.length,children:[n.map((w,T)=>{const A=x===T,{fields:M,discriminantValue:j}=Tre(t,w),D=Object.keys(M).find(U=>M[U].kind==="image"),I=D&&w[D]!=null?String(w[D]):"",V=Are(M,w,T,{...t.discriminator?{discriminator:t.discriminator}:{}}).label,F=j?`[${j}] ${V}`:V,W=F.length>40?F.slice(0,40)+"...":F;return m.jsxs("div",{className:"property-list-item",children:[m.jsxs("button",{type:"button",className:`property-list-item-toggle ${A?"is-expanded":""}`,onClick:()=>v(A?null:T),children:[m.jsx("span",{className:"property-list-item-chevron","aria-hidden":"true"}),I?m.jsx("img",{className:"property-list-item-thumb",src:SL(I,y),alt:"",loading:"lazy"}):null,m.jsx("span",{className:"property-list-item-preview",children:W})]}),A?m.jsxs("div",{className:"property-list-item-fields",children:[kL(Object.entries(M),w,`${e}[${T}].`,r,i,s,o,a,u,d,f,y),g?m.jsxs("button",{type:"button",className:"property-list-item-remove-btn",onClick:()=>g(T),children:[m.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:m.jsx("path",{d:"M2.5 4h11M6 4V2.5h4V4M5 4l.5 9h5l.5-9M6.5 6.5v4M9.5 6.5v4"})}),"Remove item"]}):null]}):null]},T)}),p?m.jsxs("button",{type:"button",className:"property-list-add-btn",onClick:p,children:[m.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:m.jsx("path",{d:"M8 3v10M3 8h10"})}),"Add"]}):null]})}const lve={h1:"H1 — Page title",h2:"H2 — Section",h3:"H3 — Subsection",h4:"H4",h5:"H5",h6:"H6"};function uve({value:e,onCommit:t,onFocus:n,onBlur:r,inline:i}){const s=_.useRef(null),[o,a]=_.useState(()=>q3(e)),{debouncedCommit:u,flushCommit:d}=jd(t,400);return _.useEffect(()=>{e!==s.current&&(s.current=null,a(q3(e)))},[e]),m.jsx(vL,{value:o,onChange:f=>{a(f);const p=die(f);s.current=p,u(p)},onFocus:n,onBlur:()=>{d(),r==null||r()},inline:i})}function cve({fieldKey:e,field:t,value:n,blockType:r,onCommit:i,onAiAssist:s,onAiQuickAction:o,aiLoading:a,fieldShimmer:u,highlightPath:d,fieldPath:f}){const p=Wue(n),g=p?p.text:n==null?"":String(n),[y,x]=_.useState(g),[v,S]=_.useState(!1),{debouncedCommit:w,flushCommit:T}=jd(i,400),A=W2(f,d),M=`property-field${f&&f===d?" is-targeted":""}`,j=v?y:g,D=t.label??e,I=()=>{x(g),S(!0)},R=()=>{S(!1),T()};if(t.kind==="reference"){const U=Une(n,t.referenceLabelKey);return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsxs("div",{className:"property-field-reference",title:U?`${U} — managed in the CMS`:"No reference set",children:[m.jsx("span",{className:"property-field-reference-target",children:U||"(not set)"}),m.jsx("span",{className:"property-field-reference-note",children:"CMS"})]})]})}if(p)return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:"property-field-input-wrap",children:m.jsx("textarea",{className:"property-field-textarea",rows:Math.min(8,Math.max(3,g.split(`
|
|
734
|
-
`).length)),readOnly:!p.editable,value:j,onFocus:p.editable?I:void 0,onBlur:p.editable?R:void 0,onChange:p.editable?U=>{x(U.target.value),w(Zue(U.target.value))}:void 0})})]});if(t.kind==="headingLevel"){const U=(r&&jI[r])??"h2",q=g&&/^h[1-6]$/.test(g)?g:"";return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsxs("select",{className:"property-field-input property-field-select",value:q,onChange:K=>i(K.target.value),children:[m.jsxs("option",{value:"",children:["Auto (",U.toUpperCase(),")"]}),["h1","h2","h3","h4","h5","h6"].map(K=>m.jsx("option",{value:K,children:lve[K]},K))]})]})}if(t.kind==="image")return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsx("div",{className:"property-field-image-url",title:g,children:g||"(empty)"})]});if(t.kind==="enum"&&t.options){const U=t.options.includes(g);return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsxs("select",{className:"property-field-input property-field-select",value:g,onChange:q=>i(q.target.value),children:[!U&&m.jsx("option",{value:g,children:g||"—"}),t.options.map(q=>m.jsx("option",{value:q,children:q},q))]})]})}if(t.kind==="boolean"){const U=g==="true"||g==="1";return m.jsx("div",{className:`${M} property-field--inline`,ref:A,children:m.jsxs("div",{className:"property-field-label",children:[m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]}),m.jsx("button",{type:"button",role:"switch","aria-checked":U,"aria-label":D,className:`property-field-switch${U?" is-on":""}`,onClick:()=>i(U?"false":"true"),children:m.jsx("span",{className:"property-field-switch-knob","aria-hidden":"true"})})]})})}if(t.kind==="color")return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsx("input",{type:"color",className:"property-field-color",value:g||"#000000",onChange:U=>i(U.target.value)})]});if(t.kind==="html")return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:"property-field-input-wrap",children:m.jsx(uve,{value:g,onCommit:U=>i(U),onFocus:I,onBlur:R,inline:t.inline})})]});if(t.kind==="richtext")return n!==null&&typeof n=="object"?m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:"property-field-input-wrap",children:m.jsx(vL,{value:n,onChange:U=>w(U),onFocus:I,onBlur:R,decorators:t.decorators,inline:t.inline})})]}):m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:m.jsx(Jxe,{value:g,onChange:U=>{x(U),w(U)},onFocus:I,onBlur:R,trailing:s?m.jsx(Yh,{variant:"toolbar",onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null})})]});const V=t.multiline===!0,F=t.kind==="number"?"number":t.kind==="url"?"url":"text",W={value:j,onFocus:I,onChange:U=>{x(U.target.value),w(U.target.value)},onBlur:R};return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsxs("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:[V?m.jsx("textarea",{className:"property-field-textarea",rows:3,...W}):m.jsx("input",{type:F,className:"property-field-input",...W}),s?m.jsx(Yh,{onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null]})]})}function dve({slug:e,navLabel:t,onNavLabelChange:n,onAiAssist:r,onAiQuickAction:i,aiLoading:s,fieldShimmer:o}){const{t:a}=_n(),[u,d]=_.useState(t),[f,p]=_.useState(!1),g=f?u:t,{debouncedCommit:y,flushCommit:x}=jd(v=>n(e,v),400);return m.jsx(Xb,{id:"page:nav",title:a("propertyPanel.navigation"),count:1,children:m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:a("propertyPanel.navLabel")})}),m.jsxs("div",{className:`property-field-input-wrap${o?" property-field-input-wrap--ai-loading":""}`,children:[m.jsx("input",{type:"text",className:"property-field-input",placeholder:a("propertyPanel.navPlaceholder"),value:g,onFocus:()=>{d(t),p(!0)},onChange:v=>{d(v.target.value),y(v.target.value)},onBlur:()=>{p(!1),x()}}),r?m.jsx(Yh,{onClick:()=>r("Nav label","text",t),fieldKind:"text",fieldLabel:"Nav label",blockType:"Page",currentValue:t,onQuickAction:i?v=>i("Nav label","text",t,v):void 0,onCustomPrompt:()=>r("Nav label","text",t),aiLoading:o}):null]})]})})}function fve({pageMeta:e,onPageMetaChange:t,onAiAssist:n,onAiQuickAction:r,aiLoading:i,aiLoadingPath:s}){const{t:o}=_n();return m.jsxs(Xb,{id:"page:seo",title:o("propertyPanel.seo"),count:3,children:[m.jsx(qv,{label:o("propertyPanel.seoTitle"),fieldKind:"text",blockType:"Page",value:e.title??"",placeholder:o("propertyPanel.seoTitlePlaceholder"),multiline:!0,autosizeRows:{min:2,max:2},recommendedMax:60,onCommit:a=>t("title",a),onAiAssist:n?()=>n("SEO title","text",e.title??""):void 0,onAiQuickAction:r?a=>r("SEO title","text",e.title??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="SEO title"}),m.jsx(qv,{label:o("propertyPanel.metaDescription"),fieldKind:"richtext",blockType:"Page",value:e.description??"",placeholder:o("propertyPanel.metaDescPlaceholder"),multiline:!0,autosizeRows:{min:3,max:6},recommendedMax:160,onCommit:a=>t("description",a),onAiAssist:n?()=>n("Meta description","richtext",e.description??""):void 0,onAiQuickAction:r?a=>r("Meta description","richtext",e.description??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="Meta description"}),m.jsx(qv,{label:o("propertyPanel.ogImage"),fieldKind:"url",blockType:"Page",value:e.ogImage??"",placeholder:"https://...",onCommit:a=>t("ogImage",a)})]})}function qv({label:e,fieldKind:t,blockType:n,value:r,placeholder:i,multiline:s,autosizeRows:o,recommendedMax:a,onCommit:u,onAiAssist:d,onAiQuickAction:f,aiLoading:p,fieldShimmer:g}){const[y,x]=_.useState(r),[v,S]=_.useState(!1),w=_.useRef(null),T=v?y:r,{debouncedCommit:A,flushCommit:M}=jd(u,400),j=s===!0&&o!=null,D=_.useCallback(()=>{if(!j||!w.current||!o)return;const V=w.current,F=getComputedStyle(V),W=Number.parseFloat(F.lineHeight),U=Number.parseFloat(F.fontSize)||15,q=Number.isFinite(W)?W:U*1.2,K=(Number.parseFloat(F.paddingTop)||0)+(Number.parseFloat(F.paddingBottom)||0),H=(Number.parseFloat(F.borderTopWidth)||0)+(Number.parseFloat(F.borderBottomWidth)||0),O=o.min*q+K+H,$=o.max*q+K+H;V.style.height="0px";const Y=V.scrollHeight,ne=Math.max(O,Math.min($,Y));V.style.height=`${ne}px`,V.style.overflowY=Y>$?"auto":"hidden"},[j,o]);_.useLayoutEffect(()=>{D()},[D,T,v,r]),_.useEffect(()=>{if(!j)return;const V=()=>D();return window.addEventListener("resize",V),()=>window.removeEventListener("resize",V)},[j,D]);const I={placeholder:i,value:T,onFocus:()=>{x(r),S(!0)},onChange:V=>{x(V.target.value),A(V.target.value)},onBlur:()=>{S(!1),M()}},R=(v?y:r).length;return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:e})}),m.jsxs("div",{className:`property-field-input-wrap${g?" property-field-input-wrap--ai-loading":""}`,children:[s?m.jsx("textarea",{ref:j?w:void 0,className:`property-field-textarea${j?" property-field-textarea--autosize":""}`,rows:(o==null?void 0:o.min)??3,...I}):m.jsx("input",{type:"text",className:"property-field-input",...I}),d?m.jsx(Yh,{onClick:d,fieldKind:t,fieldLabel:e,blockType:n,currentValue:v?y:r,onQuickAction:f,onCustomPrompt:d,aiLoading:g}):null]}),a!=null&&m.jsxs("span",{className:`property-field-char-count${R>a?" property-field-char-count--over":""}`,children:[R," / ",a]})]})}class Gv extends _.Component{constructor(){super(...arguments);Ee(this,"state",{error:null});Ee(this,"reset",()=>{var n,r;(r=(n=this.props).onReset)==null||r.call(n),this.setState({error:null})})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){var i,s;console.error("[editor] Uncaught error in component tree:",n,r.componentStack),(s=(i=this.props).onError)==null||s.call(i,n,r)}render(){return this.state.error?m.jsxs("div",{style:this.props.style,className:"flex flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground h-full",children:[m.jsx("p",{className:"font-medium text-foreground",children:this.props.fallbackLabel??"Something went wrong"}),m.jsx("p",{className:"max-w-xs opacity-70 text-xs",children:this.state.error.message}),m.jsx("button",{type:"button",onClick:this.reset,className:"rounded-md border px-3 py-1.5 text-xs hover:bg-accent transition-colors",children:"Try again"})]}):this.props.children}}function hve({siteId:e,orchestratorUrl:t,hostedIds:n,siteOwnOrchestrator:r}){const{t:i}=_n(),s=()=>{Tue(e),window.location.href=Aue(window.location.href)},o=()=>{r&&(Eue(e,r),window.location.reload())};return r?m.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[m.jsxs("div",{className:"orchestrator-mismatch-body",children:[m.jsx("strong",{children:i("orchestratorMismatch.ownTitle")}),m.jsx("span",{children:i("orchestratorMismatch.ownDetail",{orchestrator:t,siteOrchestrator:r})})]}),m.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:o,children:i("orchestratorMismatch.useSiteOwn")})]}):m.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[m.jsxs("div",{className:"orchestrator-mismatch-body",children:[m.jsx("strong",{children:i("orchestratorMismatch.title")}),m.jsx("span",{children:n.length>0?i("orchestratorMismatch.detailHosts",{orchestrator:t,hosted:n.join(", ")}):i("orchestratorMismatch.detail",{orchestrator:t})})]}),m.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:s,children:i("orchestratorMismatch.useDefault")})]})}const yg=3e3;function pve(e){const[t,n]=_.useState({status:"loading",blocks:[],manifest:null});_.useEffect(()=>{let i=!0,s=null;const o=async()=>{try{const u=await fetch(`${e||Ed}/api/editor/blocks`);if(!u.ok){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:`Manifest endpoint returned ${u.status}`}),s=setTimeout(()=>{i&&o()},yg);return}const d=await u.json(),f=OI.safeParse(d);if(!f.success){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:"Manifest response shape is invalid"}),s=setTimeout(()=>{i&&o()},yg);return}const p=BI(f.data.blocks);if(p){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:p}),s=setTimeout(()=>{i&&o()},yg);return}if(!i)return;n({status:"ready",blocks:f.data.blocks,version:f.data.version,manifest:f.data})}catch(a){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:a instanceof Error?a.message:"Manifest fetch failed"}),s=setTimeout(()=>{i&&o()},yg)}};return o(),()=>{i=!1,s&&clearTimeout(s)}},[e]);const r=_.useMemo(()=>{const i=new Map;for(const s of t.blocks)i.set(s.type,s);return i},[t.blocks]);return{...t,byType:r,siteCapabilities:{allowStructuralEdits:t.status==="ready",manifestStatus:t.status,reason:t.reason,manifestVersion:t.version,blockCount:t.blocks.length,checkedAt:new Date().toISOString()},allowStructuralEdits:t.status==="ready"}}function mve(e){const[t,n]=_.useState(void 0);return _.useEffect(()=>{if(kg)return;let r=!1;return _ue(e).then(i=>{r||!i||i.replace(/\/+$/,"")!==$e.replace(/\/+$/,"")&&n(i)}),()=>{r=!0}},[e]),t}function gve(e){return null}function bve(){const e=gve();return e||"text"}const yve=/^[a-z]{2}(?:-[a-z0-9]{2,8})?$/i,_l="default",xve=2;let Vf;function vve(e){if(!yve.test(e))return!1;if(Vf===void 0)try{Vf=new Intl.DisplayNames(["en"],{type:"language",fallback:"none"})}catch{Vf=null}if(!Vf)return!1;try{return typeof Vf.of(e)=="string"}catch{return!1}}function Qb(e){return e.split("/").filter(Boolean)}function $u(e){const t=Qb(e);return t.length===0?"/":`/${t.join("/")}`}function kve(e){const t={},n=[];for(const u of e){const d=Qb(u)[0];if(d&&vve(d)){const f=d.toLowerCase();(t[f]||(t[f]=[])).push(u)}else n.push(u)}const r=Object.keys(t).sort();if(r.length<2)return null;const i=new Map;for(const u of r)for(const d of new Set(t[u].map(f=>Z2(f,u))))i.set(d,(i.get(d)??0)+1);if(![...i.values()].some(u=>u>=2))return null;const o=n.filter(u=>i.has($u(u))).length>=xve,a=o?[]:n;o&&(t[_l]=n,r.unshift(_l));for(const u of r){const d=u===_l?"/":`/${u}`;t[u].sort((f,p)=>f===d?-1:p===d?1:0)}return{locales:r,byLocale:t,shared:a}}function CL(e,t){var i;const n=(i=Qb(e)[0])==null?void 0:i.toLowerCase();if(n&&t.byLocale[n])return n;const r=t.byLocale[_l];return r!=null&&r.some(s=>$u(s)===$u(e))?_l:void 0}function Z2(e,t){var i;if(!t||t===_l)return $u(e);const n=Qb(e);if(((i=n[0])==null?void 0:i.toLowerCase())!==t.toLowerCase())return $u(e);const r=n.slice(1);return r.length===0?"/":`/${r.join("/")}`}function Sve(e,t){return`${xj(Z2(e,t))} (${e})`}function wve(e,t,n){const r=n.byLocale[t];if(!r||r.length===0)return e;const i=Z2(e,CL(e,n)),s=t===_l?i:i==="/"?`/${t}`:`/${t}${i}`;return r.find(a=>$u(a)===$u(s))??r[0]}function Cve(e){try{const t=new Intl.DisplayNames([e],{type:"language"}).of(e);if(t&&t.toLowerCase()!==e.toLowerCase())return t.charAt(0).toUpperCase()+t.slice(1)}catch{}return e.toUpperCase()}const FD=bve(),_ve=S$(),Eve=_.lazy(()=>yB(()=>import("./PuckPrototypeRoute-Bg0Ajkvj.js").then(e=>e.P),__vite__mapDeps([0,1])).then(e=>({default:e.PuckPrototypeRoute}))),Tve=new Set(["/editor/puck","/editor/puck/"]),Ave=3e4,_L="site-reachable-v1:",Nve=5e3;function EL(e){if(typeof sessionStorage>"u")return null;try{const t=sessionStorage.getItem(_L+e);if(!t)return null;const n=JSON.parse(t);return Date.now()-n.ts>Ave?null:n.ok}catch{return null}}function UD(e,t){if(!(typeof sessionStorage>"u"))try{sessionStorage.setItem(_L+e,JSON.stringify({ok:t,ts:Date.now()}))}catch{}}function Mve({name:e,origin:t,statusClass:n,active:r,dimmed:i,onSelect:s}){const o=t.replace(/^https?:\/\//,"");return m.jsxs("button",{type:"button",role:"menuitem",className:`site-switcher-item${r?" is-active":""}${i?" is-dimmed":""}`,onClick:s,title:t,children:[m.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${n}`,"aria-hidden":"true"}),m.jsxs("span",{className:"site-switcher-item-body",children:[m.jsx("span",{className:"site-switcher-item-name",children:e}),m.jsx("span",{className:"site-switcher-item-origin",children:o})]}),r?m.jsx(Xh,{size:12,"aria-hidden":"true"}):null]})}function HD(e){if(typeof sessionStorage>"u")return null;const t=new Set;let n=!1;for(const r of e){const i=EL(r);i!==null&&(n=!0,i&&t.add(r))}return n?t:null}function Dve(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Rve(){const e=typeof window<"u"?window.location.pathname:"/",t=e==="/"||e==="/editor"||e==="/editor/",n=Tve.has(e),r=e==="/sites"||e==="/sites/";fe(d=>d.chatDarkMode);const i=fe(d=>d.setChatDarkMode),s=_.useMemo(()=>_G(),[]),o=_.useMemo(()=>Ej(),[]),a=_.useRef(!1);if(!a.current){a.current=!0;const d=typeof window<"u"?window.location.origin:"http://localhost:4100";z$({sessionId:s,siteId:o,editorOrigin:d,orchestratorUrl:$e})}const u=Mue(o,s);return _.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=p=>i(p.matches);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[i]),n?m.jsx(_.Suspense,{fallback:m.jsx("div",{style:{height:"100vh",display:"grid",placeItems:"center"},children:"Loading prototype…"}),children:m.jsx(Eve,{})}):r?m.jsx(bN,{sites:u,session:s}):t?m.jsx(Ove,{sites:u}):m.jsx(bN,{sites:u,session:s})}const jve=new Set(["avocado-hub","avocado-stories","avocado-magic","avocado-odyssey"]);function Ive(e){return e.split(".").map(t=>{const n=t.match(/^([a-zA-Z_]+)\[(\d+)\]$/);return n?`${VD(n[1])} ${Number(n[2])+1}`:VD(t)}).join(" · ")}function VD(e){const n=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s*url\s*$/i,"").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):e}function Ove({sites:e}){var Dp,Rp,Vd;const{t}=_n(),n=Ui(),r=Hi(),i=fe(E=>E.chatDarkMode),s=fe(E=>E.setChatDarkMode),{activeSiteConfig:o}=e,a=_.useMemo(()=>ku(o),[o]),u=pve(a),d=typeof window<"u"?window.location.origin:"http://localhost:4100",f=mve(a),p=e.siteHosting==="notHosted"||f!=null,g=fe(E=>E.slug),y=fe(E=>E.setSlug),x=fe(E=>E.availableSlugs);fe(E=>E.setAvailableSlugs);const v=fe(E=>E.isLoadingSlugs),S=fe(E=>E.modelKey),w=fe(E=>E.setModelKey),T=fe(E=>E.provider),A=fe(E=>E.setProvider),M=fe(E=>E.availableProviders),j=fe(E=>E.setAvailableProviders),[D,I]=_.useState(""),R=fe(E=>E.activeBlockId),V=fe(E=>E.activeBlockType),F=fe(E=>E.activeEditablePath),W=E=>fe.getState().setActiveBlock(E),U=E=>{const Z=fe.getState();Z.setActiveBlock(Z.activeBlockId,E)},q=(E,Z)=>fe.getState().setActiveBlock(E,Z),K=fe(E=>E.setActiveEditablePath),H=fe(E=>E.useStreaming),O=fe(E=>E.setUseStreaming),$=fe(E=>E.autoScrollTrackingEnabled),Y=fe(E=>E.setAutoScrollTrackingEnabled),[ne,P]=_.useState(!1),[L,J]=_.useState(_ve),z=_.useCallback(E=>{J(E);try{window.localStorage.setItem(Qv,E?"1":"0")}catch{}},[]),Q=_.useMemo(()=>!0,[]),oe=Q&&L,[se,ie]=_.useState(!1),[Me,ke]=_.useState(0),Oe=_.useCallback(()=>ke(E=>E+1),[]),ce=fe(E=>E.showSettingsModal),ee=fe(E=>E.setShowSettingsModal),Re=fe(E=>E.showDebugDetails),Ce=fe(E=>E.setShowDebugDetails),Je=fe(E=>E.composerHeight),st=fe(E=>E.setComposerHeight),gt=fe(E=>E.addBlockPicker),Qe=fe(E=>E.setAddBlockPicker),ot=fe(E=>E.addBlockSearch),mn=fe(E=>E.setAddBlockSearch),Dn=fe(E=>E.isAddingBlock),Bn=fe(E=>E.setIsAddingBlock),Rt=fe(E=>E.copiedDebugEntryId),bt=fe(E=>E.setCopiedDebugEntryId),En=fe(E=>E.feedbackNoteEntryId),de=fe(E=>E.setFeedbackNoteEntryId),be=fe(E=>E.feedbackNoteText),ze=fe(E=>E.setFeedbackNoteText),et=fe(E=>E.selectedVariationId),tt=fe(E=>E.setSelectedVariationId),Ct=fe(E=>E.imagePickerTarget),Yn=fe(E=>E.setImagePickerTarget),Jn=Ct!==null,gn=fe(E=>E.backendFeatures),hr=fe(E=>E.setBackendFeatures),pe=fe(E=>E.setBackendSite),Le=fe(E=>E.selectionModeEnabled),ct=fe(E=>E.setSelectionModeEnabled),kt=fe(E=>E.anchorRect),qe=fe(E=>E.setAnchorRect),ye=fe(E=>E.anchoredExpanded),Be=fe(E=>E.setAnchoredExpanded),Fe=fe(E=>E.activeTab),Ve=fe(E=>E.setActiveTab),[_t,yt]=_.useState(!1),[Zt,an]=_.useState(!1),Rn=_.useRef(null);_.useEffect(()=>{if(!Zt)return;const E=me=>{Rn.current&&!Rn.current.contains(me.target)&&an(!1)},Z=me=>{me.key==="Escape"&&an(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",Z)}},[Zt]);const[Yi,bs]=_.useState(()=>HD(e.siteList.map(E=>E.id))),si=_.useCallback(E=>{bs(Z=>Dve(Z,E)?Z:E)},[]);_.useEffect(()=>{if(!Zt)return;si(HD(e.siteList.map(me=>me.id)));let E=!0;return(async()=>{let me=!0;const Ne=await Promise.all(e.siteList.map(async Pe=>{const Te=EL(Pe.id);if(Te!==null)return{id:Pe.id,ok:Te};me=!1;const Ge=ku(Pe);try{const Nt=await fetch(`${Ge}/api/editor/blocks?siteId=${encodeURIComponent(Pe.id)}`,{signal:AbortSignal.timeout(2500)});return UD(Pe.id,Nt.ok),{id:Pe.id,ok:Nt.ok}}catch{return UD(Pe.id,!1),{id:Pe.id,ok:!1}}}));E&&!me&&si(new Set(Ne.filter(Pe=>Pe.ok).map(Pe=>Pe.id)))})(),()=>{E=!1}},[Zt,e.siteList,si]);const Ir=_.useMemo(()=>{const E=Yi===null;return e.siteList.map(Z=>{const me=E||Z.id===r||Yi.has(Z.id);return{site:Z,origin:ku(Z),online:me,probing:E}}).sort((Z,me)=>Z.site.id===r?-1:me.site.id===r?1:Z.online!==me.online?Z.online?-1:1:Z.site.name.localeCompare(me.site.name))},[Yi,e.siteList,r]),{onlineEntries:ys,activeEntry:Ni}=_.useMemo(()=>({onlineEntries:Ir.filter(E=>E.online),activeEntry:Ir.find(E=>E.site.id===r)}),[Ir,r]),$n=_.useRef(null),Ji=_.useRef(null),kr=_.useRef(!0),Tn=_.useRef(!1),jn=_.useRef(null),Sr=_.useRef(void 0),pr=_.useRef(!1),$o=_.useRef(null),Hs=_.useRef(!1),xs=_.useRef(0),yi=_.useRef(null),Xn=_.useRef(null),en=fe(E=>E.chatWidth),bn=fe(E=>E.setChatWidth),xi=fe(E=>E.propsWidth),mr=fe(E=>E.setPropsWidth),tn=_.useRef(null),Xi=_.useRef(null),[Mi,Di]=_.useState(1),oi=_.useRef(null),uo=_.useRef(null),Vs=_.useRef(!1),co=_.useRef(!1);_.useEffect(()=>{if(!co.current&&!(v||x.length===0)){if(g!=="/"||x.includes("/")){co.current=!0;return}co.current=!0,pr.current=!1,y(x[0])}},[x,v,g,y]);const fo=_.useMemo(()=>{const E=Array.from(new Set([...x,g].filter(Boolean)));return E.includes("/")?["/",...E.filter(Z=>Z!=="/")]:E},[x,g]),tr=_.useMemo(()=>kve(fo),[fo]),wr=tr?CL(g,tr)??tr.locales[0]:void 0,Kr=_.useMemo(()=>!tr||!wr?fo:tr.byLocale[wr]??[],[tr,wr,fo]),nr=_.useMemo(()=>{if(!u.allowStructuralEdits)return[];if(u.blocks.length>0)return u.blocks.map(Z=>({type:Z.type,label:Z.displayName??Z.type,category:"content"})).sort((Z,me)=>Z.label.localeCompare(me.label));const E=pu();return[...Pk].map(Z=>{var me,Ne;return{type:Z,label:((me=E[Z])==null?void 0:me.displayName)??Z,category:((Ne=E[Z])==null?void 0:Ne.category)??"content"}}).sort((Z,me)=>Z.label.localeCompare(me.label))},[u.allowStructuralEdits,u.blocks]),Ea=_.useMemo(()=>{const E=ot.trim().toLowerCase(),Z=E?nr.filter(Pe=>Pe.label.toLowerCase().includes(E)||Pe.type.toLowerCase().includes(E)):nr,me=new Map;for(const Pe of Z){const Te=Pe.category||"content",Ge=me.get(Te);Ge?Ge.push(Pe):me.set(Te,[Pe])}const Ne=["content","layout","conversion","navigation","media"];return[...me.entries()].sort((Pe,Te)=>{const Ge=Ne.indexOf(Pe[0]),Nt=Ne.indexOf(Te[0]),ln=Ge===-1?Number.MAX_SAFE_INTEGER:Ge,ar=Nt===-1?Number.MAX_SAFE_INTEGER:Nt;return ln!==ar?ln-ar:Pe[0].localeCompare(Te[0])}).map(([Pe,Te])=>({category:Pe,options:Te}))},[ot,nr]),qs=()=>{const E=Date.now();E-xs.current<1200||(xs.current=E,He.pushAssistantFromResult({status:"needs_clarification",summary:t("streamError.structuralDisabled"),changes:YO(u.reason)}))},Fo=_.useRef(()=>{}),Lr=_.useCallback(E=>{fe.getState().slug!==E&&(Hs.current=!0,y(E))},[y]),vs=_.useMemo(()=>({onBlockClicked:(E,Z,me,Ne,Pe,Te)=>{Lr(E),q(Z,me),K(Ne),qe(Z?Te:null),fe.getState().setActiveTab(Z?"properties":"chat")},onRouteChanged:E=>{fe.getState().slug!==E&&q(void 0,void 0),Lr(E),K(void 0),qe(null),rr.current("setSelectionMode",{enabled:fe.getState().selectionModeEnabled}),Fo.current(E)},onBlockReordered:(E,Z,me)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.reorderBlock(E,Z,me)},onBlockDeleteRequested:(E,Z)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.deleteBlock(E,Z)},onBlockAddRequested:(E,Z)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),!(!Z.afterBlockId&&!Z.beforeBlockId)&&Qe({slug:E,afterBlockId:Z.afterBlockId,beforeBlockId:Z.beforeBlockId})},onListItemAddRequested:(E,Z,me,Ne,Pe)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.addListItem(E,Z,me,Ne,Pe)},onListItemRemoveRequested:(E,Z,me,Ne,Pe)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.removeListItem(E,Z,me,Ne,Pe)},onListItemMoveRequested:(E,Z,me,Ne,Pe,Te)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.moveListItem(E,Z,me,Ne,Pe,Te)},onOpenImagePicker:(E,Z,me,Ne,Pe)=>{Yn({slug:E,blockId:Z,editablePath:me,currentUrl:Ne,blockType:Pe??(Z===R?V:void 0)})},onEditBlockRequested:(E,Z)=>{Be(!0)},onInlineTextCommitted:(E,Z,me,Ne)=>{E!==g&&Lr(E),me&&K(me),He.inlineEditCommit(E,Z,me,Ne)},onIframeScrolled:()=>{qe(null),fe.getState().isLoading&&fe.getState().setAutoScrollSuppressed(!0)}}),[u.allowStructuralEdits,Lr,g]);_.useCallback(async()=>{var E;try{const Z=`${$e}/draft/pages?session=${encodeURIComponent(n)}&siteId=${encodeURIComponent(r)}&slug=${encodeURIComponent(g)}`,me=await fetch(Z,{cache:"no-store"});if(!me.ok)return;const Pe=((await me.json()).blocks??[]).find(Te=>Te.type==="Hero");if(!Pe)return;q(Pe.id,Pe.type),Yn({slug:g,blockId:Pe.id,editablePath:"imageUrl",currentUrl:typeof((E=Pe.props)==null?void 0:E.imageUrl)=="string"?Pe.props.imageUrl:void 0,blockType:Pe.type})}catch{}},[n,r,g,Yn]);const Yt=Due(g,vs,a),rr=_.useRef(Yt.postToSite);_.useEffect(()=>{rr.current=Yt.postToSite},[Yt.postToSite]);const Uo=_.useCallback(E=>{const Z=E??!Le;ct(Z),Yt.postToSite("setSelectionMode",{enabled:Z})},[Le,Yt]);_.useEffect(()=>{const E=Z=>{Z.key==="Escape"&&Le&&Uo(!1)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[Le,Uo]),_.useEffect(()=>{if(Fe!=="history")return;const E=Z=>{Z.key==="Escape"&&fe.getState().setActiveTab("chat")};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[Fe]);const Ho=_.useCallback((E,Z)=>{(E==="draftUpdated"||E==="liveDraft")&&Oe(),Yt.postToSite(E,Z)},[Yt,Oe]),ho=_.useCallback((E,Z,me,Ne)=>(Oe(),Yt.postPatchToSite(E,Z,me,Ne)),[Yt,Oe]),He=Lue({activeSiteConfig:o,siteRegistryChecked:e.siteRegistryChecked,postToSite:Ho,postPatchToSite:ho,componentManifest:u.manifest,siteCapabilities:u.siteCapabilities,allowStructuralEdits:u.allowStructuralEdits,getBlockDefaultProps:E=>{var Z;return((Z=u.byType.get(E))==null?void 0:Z.defaultProps)??null},onApplied:()=>{var E;(E=Sr.current)==null||E.call(Sr)},agentModeEnabled:gn.agentMode??!1}),Wr=fe(E=>E.chatLog),ks=fe(E=>E.chatAttachments),Ss=fe(E=>E.setChatAttachments),ir=fe(E=>E.isLoading),Or=fe(E=>E.streamStatus),Gs=fe(E=>E.streamingText),Ta=fe(E=>E.streamingChanges),Pd=fe(E=>E.streamSteps),Zu=fe(E=>E.streamTokenCount),Ri=fe(E=>E.latestStreamFocusBlockId),gr=fe(E=>E.imageProgress),ql=fe(E=>E.plannerBadgeState),[ai,ji]=_.useState(!1),Br=fe(E=>E.setPlannerBadgeState),Yu=fe(E=>E.pendingPlanId),at=fe(E=>E.variationModal),St=fe(E=>E.isApplyingVariation),_e=fe(E=>E.setVariationModal),Lt=fe(E=>E.continuationChainId),li=fe(E=>E.fieldDraftDebugEnabled),Ii=fe(E=>E.setFieldDraftDebugEnabled),Fn=fe(E=>E.fieldDraftDebug);_.useEffect(()=>{jve.has(r)||(w("balanced"),He.clearChat())},[r]);function ui(E){var Z,me;typeof E.navigateToSlug=="string"&&E.navigateToSlug.length>0&&E.navigateToSlug!==g&&y(E.navigateToSlug),typeof E.canUndo=="boolean"&&((Z=He.setCanUndoServer)==null||Z.call(He,E.canUndo)),typeof E.canRedo=="boolean"&&((me=He.setCanRedoServer)==null||me.call(He,E.canRedo)),Yt.postToSite("draftUpdated",{focusBlockId:null}),Oe()}async function lt(E){yt(!0);try{const me=await(await fetch(`${$e}/history/restore`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,targetVersion:E})})).json();me.status==="applied"&&ui(me)}catch{}finally{yt(!1)}}const rt=Fue(n,r,a,Me),nn=$ue(n,r,ir,He.pushAssistantFromResult,a,()=>{Yt.postToSite("draftUpdated",{focusBlockId:null}),rt.markPublished()}),In=rt.summary?rt.summary.total>0:!0,sr=Uue(),Et=Fe==="properties"&&He.hasBootstrapped,xt=que(n,r,g,R,Et),or=Gue(n,r,g,Et);_.useEffect(()=>{!R||V||!xt.blockType||U(xt.blockType)},[R,V,xt.blockType]);const Ot=VG(n,r,!!n),Ju=qG(Ot.findings),po=_.useRef(null),Zr=_.useCallback((E,Z,me)=>{q(E,Z),K(me),qe(null),fe.getState().selectionModeEnabled||(fe.getState().setSelectionModeEnabled(!0),rr.current("setSelectionMode",{enabled:!0})),rr.current("highlightBlock",{blockId:E,editablePath:me??null,scrollIntoView:!0})},[]),vi=_.useCallback(E=>{const Z=po.current;!Z||Z.slug!==E||(po.current=null,!(Z.expiresAt!==void 0&&Date.now()>Z.expiresAt)&&Zr(Z.blockId,Z.blockType,Z.path))},[Zr]);_.useEffect(()=>{if(!po.current)return;const E=setTimeout(()=>vi(g),400);return()=>clearTimeout(E)},[g,vi]),_.useEffect(()=>{Fo.current=vi},[vi]);const mo=_.useCallback((E,Z,me,Ne)=>{if(!Z){E!==fe.getState().slug&&y(E),q(void 0,void 0),K(void 0),Ve("properties");return}if(E!==fe.getState().slug){po.current={slug:E,blockId:Z,blockType:me,path:Ne},y(E),Ve("properties");return}Ve("properties"),po.current={slug:E,blockId:Z,...me?{blockType:me}:{},...Ne?{path:Ne}:{},expiresAt:Date.now()+Nve},Zr(Z,me,Ne)},[Zr]);Sr.current=()=>{xt.refetch(),or.refetch(),Oe()};const[zd,ey]=_.useState(()=>xk(g,{session:n,siteId:r,editorOrigin:d},a)),[ty,mp]=_.useState(!1);_.useEffect(()=>{mp(!1)},[zd]),_.useEffect(()=>{$o.current!==a&&($o.current=a,pr.current=!1);const E={session:n,siteId:r,editorOrigin:d};if(Hs.current){Hs.current=!1;return}if($g&&pr.current){Yt.postToSite("navigate",{href:vk(g,E)});return}const Z=xk(g,E,a);ey(me=>me===Z?me:Z)},[a,d,n,r,g]);const Xu=_.useMemo(()=>{var me;const E=(me=o.vercelProductionUrl)==null?void 0:me.trim(),Z=E&&/^https?:\/\//i.test(E)?E:a;try{const Ne=new URL(Z);return Ne.origin===a?AG(g,{},a):(Ne.pathname=g==="/"?"/":g,Ne.search="",Ne.hash="",Ne.toString())}catch{return}},[o.vercelProductionUrl,a,g]),gp=_.useMemo(()=>a?`${a}${vk(g,{session:n,siteId:r,editorOrigin:d,immersive:"1"})}`:void 0,[a,d,n,r,g]);_.useEffect(()=>{let E=!0;const Z=async()=>{const Ne=[`${$e}/status/planner`];$e.includes("localhost")&&Ne.push(`${$e.replace("localhost","127.0.0.1")}/status/planner`);try{for(const Pe of Ne){const Te=await fetch(Pe);if(!Te.ok)continue;const Ge=await Te.json();if(!E)return;if(Ge.features&&hr(Ge.features),Ge.site&&pe(Ge.site),Array.isArray(Ge.availableProviders)&&Ge.availableProviders.length>0&&(j(Ge.availableProviders),(!Ge.availableProviders.includes(T)||T!=="anthropic"&&Ge.availableProviders.includes("anthropic"))&&A(Ge.availableProviders.includes("anthropic")?"anthropic":Ge.availableProviders[0])),Ge.plannerSource==="openai"||Ge.plannerSource==="anthropic"||Ge.plannerSource==="gemini"||Ge.plannerSource==="demo"){Br(Ge.plannerSource);return}}E&&Br("error")}catch{E&&Br("error")}};Z();const me=window.setInterval(()=>{Z()},1e4);return()=>{E=!1,window.clearInterval(me)}},[]);const bp=_.useRef(0),yp=_.useRef(0);_.useEffect(()=>{const E=Ji.current;if(!E)return;const Z=()=>{const me=Math.abs(E.scrollHeight-E.scrollTop-E.clientHeight)<2||E.scrollHeight<=E.clientHeight;!me&&E.scrollTop<bp.current?kr.current=!1:me&&(kr.current=!0),bp.current=E.scrollTop};return E.addEventListener("scroll",Z,{passive:!0}),()=>{E.removeEventListener("scroll",Z)}},[]),_.useEffect(()=>{const E=Ji.current;if(!E||!(Wr.length>0||!!Or||!!Gs))return;const me=Wr.reduce((Nt,ln)=>ln.role==="user"?Nt+1:Nt,0);me>yp.current&&(kr.current=!0),yp.current=me;const Ne=!Tn.current,Pe=Wr.some(Nt=>Nt.role==="user");if(Ne&&!Pe&&!Or&&!Gs){Tn.current=!0,kr.current=!1;return}if(!Ne&&!kr.current)return;const Ge=window.requestAnimationFrame(()=>{E.scrollTop=E.scrollHeight,kr.current=!0,Tn.current=!0});return()=>window.cancelAnimationFrame(Ge)},[Wr.length,Or,Gs,Pd.length,Ta.length]),_.useEffect(()=>{Yt.postToSite("setNestedLabelsVisibility",{visible:ne})},[ne]),_.useEffect(()=>{const E=rr.current;if(!ir){Vs.current&&E("aiFieldLoading",{blockId:"",active:!1}),uo.current=null,Vs.current=!1;return}const Z=Ri??R??"",Ne=Z&&Z===(R??"")?F??"":"";E("aiFieldLoading",{blockId:Z,editablePath:Ne,active:!0}),uo.current={blockId:Z,editablePath:Ne},Vs.current=!0},[ir,Ri,R,F]),_.useEffect(()=>{if(!ir)return;const E=window.setInterval(()=>{const Z=uo.current;Z&&rr.current("aiFieldLoading",{blockId:Z.blockId,editablePath:Z.editablePath,active:!0})},1200);return()=>window.clearInterval(E)},[ir]),_.useEffect(()=>{R&&Yt.postToSite("highlightBlock",{blockId:R,editablePath:F??null})},[R,F]),_.useEffect(()=>{He.clearFieldAiContext()},[R]),_.useEffect(()=>{R||qe(null)},[R]),_.useEffect(()=>{Be(!1)},[kt]),_.useEffect(()=>{const E=()=>qe(null);return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]);const ny=R$(),Aa=_.useMemo(()=>{if(!ny||!kt||!Le||!R||typeof window>"u"||window.innerWidth<=1040)return null;const E=Yt.iframeRef.current;if(!E)return null;const Z=E.getBoundingClientRect(),me=380,Ne=36,Pe=26,Te=8,Ge=Z.top+kt.top*Mi;if(Ge+kt.height*Mi<Z.top||Ge>Z.bottom)return null;const ln=Ge+Te-(Ne-Pe)/2;let ar=Z.left+(kt.left+kt.width)*Mi-Ne-Te;return ar=Math.max(Z.left+Te,Math.min(ar,Z.right-Ne-Te)),{top:ln,left:ar,width:me}},[kt,Le,R,Yt.iframeRef,Mi]);_.useEffect(()=>{Aa&&ye&&requestAnimationFrame(()=>{var E,Z;(Z=(E=oi.current)==null?void 0:E.querySelector("textarea"))==null||Z.focus()})},[!!Aa,ye]);const xp=_.useCallback((E,Z,me,Ne)=>{var ln;if(!R||!V)return;const Te=((ln=pu()[V])==null?void 0:ln.displayName)??V;K(E);const Ge=Yk(me,Z,V,Ne),Nt={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Te} → ${Z}`,fieldAiContext:{blockId:R,blockType:V,fieldPath:E,fieldLabel:Z,blockDisplayName:Te},suggestions:Ge};He.setFieldAiContext(Nt)},[R,V]),ry=_.useCallback((E,Z,me)=>{const Ne=Yk(Z,E,"Page",me),Pe={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${E}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:E,fieldLabel:E,blockDisplayName:"Page"},suggestions:Ne};He.setFieldAiContext(Pe)},[]),iy=_.useCallback((E,Z,me,Ne,Pe)=>{var ln;if(!R||!V)return;const Ge=((ln=pu()[V])==null?void 0:ln.displayName)??V;K(E),Yt.postToSite("aiFieldLoading",{blockId:R,editablePath:E,active:!0}),uo.current={blockId:R,editablePath:E},Vs.current=!0;const Nt={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Ge} → ${Z}`,fieldAiContext:{blockId:R,blockType:V,fieldPath:E,fieldLabel:Z,blockDisplayName:Ge}};He.setFieldAiContext(Nt),He.submitChat(Pe)},[R,V]),sy=_.useCallback((E,Z,me,Ne)=>{K(E);const Pe={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${E}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:E,fieldLabel:E,blockDisplayName:"Page"}};He.setFieldAiContext(Pe),He.submitChat(Ne)},[]);_.useEffect(()=>{He.refreshRouteSlugs()},[n,r,e.siteRegistryChecked]);const Ld=E=>{const me=$n.current,Ne=Ji.current;if(!me||!Ne)return Math.max(56,E);const Pe=120,Te=10,Ge=Ne.offsetTop,Nt=Math.max(56,me.clientHeight-Ge-Te-Pe);return Math.min(Nt,Math.max(56,E))},Bd=_.useCallback(E=>{st(Z=>{const me=Ld(E);return me===Z?Z:me})},[]);_.useEffect(()=>{const E=me=>{const Ne=yi.current;if(Ne){const Te=me.clientY-Ne.y,Ge=Ld(Ne.composerHeight-Te);st(Ge)}const Pe=Xn.current;if(Pe){const Te=me.clientX-Pe.x;Pe.target==="chat"?bn(nk(Pe.width+Te)):mr(rk(Pe.width-Te))}},Z=()=>{const me=!!Xn.current;yi.current=null,Xn.current=null,document.body.style.userSelect="",me&&document.body.classList.remove("panel-resizing")};return window.addEventListener("pointermove",E),window.addEventListener("pointerup",Z),()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",Z),document.body.style.userSelect="",document.body.classList.remove("panel-resizing")}},[]),_.useEffect(()=>{const E=()=>{st(Z=>Ld(Z)),bn(Z=>Z&&nk(Z)),mr(Z=>Z&&rk(Z))};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[bn,mr]),_.useEffect(()=>{if(!at)return;const E=Z=>{Z.key==="Escape"&&!St&&_e(null)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[at,St]),_.useEffect(()=>{at!=null&&at.options.length?tt(at.options[0].id):tt(null)},[at]),_.useEffect(()=>{gt||mn("")},[gt]),_.useEffect(()=>{if(!gt)return;const E=Z=>{Z.key==="Escape"&&!Dn&&Qe(null)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[gt,Dn]);const $d=Or?/failed|error/i.test(Or):!1,[vp,kp]=_.useState(0),Sp=gr==null?void 0:gr.stage;_.useEffect(()=>{if(kp(0),!ir)return;const E=window.setInterval(()=>kp(Z=>Z+1),1e3);return()=>window.clearInterval(E)},[ir,Or,Sp]);const wp=ir&&!$d&&vp>=5?` · ${vp}s`:"",oy=(gr?gr.stage:Or??(Zu>0?t("stream.shapingUpdate"):t("stream.gettingReady")))+wp,Cp=(gr?gr.stage:Or??(Zu>0?t("stream.updating"):t("stream.thinking")))+wp,Ks=(Or==null?void 0:Or.match(/reconnecting(?:\s+agent\s+stream)?(?:\s+\((\d+)\/(\d+)\))?/i))??null,_p=Ks!=null&&Ks[1]?Number(Ks[1]):null,Ep=Ks!=null&&Ks[2]?Number(Ks[2]):null,Qu=Ks?_p&&Ep?`Reconnect ${_p}/${Ep}`:"Reconnecting":null,Tp=`field_draft ${Fn.eventsPerSecond}/s · chars ${Fn.charsPerSecond}/s · lag ${Fn.typingLagChars}`,ay={"--composer-height":`${Je}px`},Ws=Fe==="properties",Zs=Fe==="history",ec=Fe==="health",Fd=_.useCallback(()=>{W(void 0),U(void 0),Ve("chat")},[]);_.useLayoutEffect(()=>{const E=Xi.current,Z=Yt.iframeRef.current;if(!E||!Z)return;const me=Te=>{var Qi;if(Te?Z.classList.remove("preview-iframe-no-transition"):Z.classList.add("preview-iframe-no-transition"),!Ws){Z.style.removeProperty("width"),Z.style.removeProperty("height"),Z.style.removeProperty("transform"),Di(Oi=>Oi===1?Oi:1);return}const Ge=E.offsetWidth,Nt=((Qi=tn.current)==null?void 0:Qi.offsetWidth)??0;if(Ge<=0||Nt<=0)return;const ln=Ge+Nt,ar=Ge/ln;Z.style.width=`${ln}px`,Z.style.height=`${100/ar}%`,Z.style.transform=`scale(${ar})`,Di(Oi=>Math.abs(Oi-ar)<5e-4?Oi:ar)};me(!0);const Ne=new ResizeObserver(()=>me(!1)),Pe=window.setTimeout(()=>{Ne.observe(E);const Te=tn.current;Te&&Ne.observe(Te)},240);return()=>{window.clearTimeout(Pe),Z.classList.remove("preview-iframe-no-transition"),Ne.disconnect()}},[Ws,Yt.iframeRef]);const Ap={...en?{"--chat-width":`${en}px`}:{},...xi?{"--props-width":`${xi}px`}:{}},Ud=Wr.some(E=>E.role==="user"),Hd=_.useCallback(E=>{const Z=[];E.text&&Z.push(E.text),E.status&&!E.canUndo&&E.status!=="needs_clarification"&&E.status!=="plan_ready"&&Z.push(`status: ${E.status}`);const me=(E.changes??[]).filter(Ne=>!vj(E.text,Ne));if(me.length>0&&Z.push(`changes: ${me.join(`
|
|
734
|
+
`).length)),readOnly:!p.editable,value:j,onFocus:p.editable?I:void 0,onBlur:p.editable?R:void 0,onChange:p.editable?U=>{x(U.target.value),w(Zue(U.target.value))}:void 0})})]});if(t.kind==="headingLevel"){const U=(r&&jI[r])??"h2",q=g&&/^h[1-6]$/.test(g)?g:"";return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsxs("select",{className:"property-field-input property-field-select",value:q,onChange:K=>i(K.target.value),children:[m.jsxs("option",{value:"",children:["Auto (",U.toUpperCase(),")"]}),["h1","h2","h3","h4","h5","h6"].map(K=>m.jsx("option",{value:K,children:lve[K]},K))]})]})}if(t.kind==="image")return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsx("div",{className:"property-field-image-url",title:g,children:g||"(empty)"})]});if(t.kind==="enum"&&t.options){const U=t.options.includes(g);return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsxs("select",{className:"property-field-input property-field-select",value:g,onChange:q=>i(q.target.value),children:[!U&&m.jsx("option",{value:g,children:g||"—"}),t.options.map(q=>m.jsx("option",{value:q,children:q},q))]})]})}if(t.kind==="boolean"){const U=g==="true"||g==="1";return m.jsx("div",{className:`${M} property-field--inline`,ref:A,children:m.jsxs("div",{className:"property-field-label",children:[m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]}),m.jsx("button",{type:"button",role:"switch","aria-checked":U,"aria-label":D,className:`property-field-switch${U?" is-on":""}`,onClick:()=>i(U?"false":"true"),children:m.jsx("span",{className:"property-field-switch-knob","aria-hidden":"true"})})]})})}if(t.kind==="color")return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:D})}),m.jsx("input",{type:"color",className:"property-field-color",value:g||"#000000",onChange:U=>i(U.target.value)})]});if(t.kind==="html")return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:"property-field-input-wrap",children:m.jsx(uve,{value:g,onCommit:U=>i(U),onFocus:I,onBlur:R,inline:t.inline})})]});if(t.kind==="richtext")return n!==null&&typeof n=="object"?m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:"property-field-input-wrap",children:m.jsx(vL,{value:n,onChange:U=>w(U),onFocus:I,onBlur:R,decorators:t.decorators,inline:t.inline})})]}):m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsx("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:m.jsx(Jxe,{value:g,onChange:U=>{x(U),w(U)},onFocus:I,onBlur:R,trailing:s?m.jsx(Yh,{variant:"toolbar",onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null})})]});const V=t.multiline===!0,F=t.kind==="number"?"number":t.kind==="url"?"url":"text",W={value:j,onFocus:I,onChange:U=>{x(U.target.value),w(U.target.value)},onBlur:R};return m.jsxs("div",{className:M,ref:A,children:[m.jsx("div",{className:"property-field-label",children:m.jsxs("span",{children:[D,t.required&&m.jsx("span",{className:"property-field-required",children:"*"})]})}),m.jsxs("div",{className:`property-field-input-wrap${u?" property-field-input-wrap--ai-loading":""}`,children:[V?m.jsx("textarea",{className:"property-field-textarea",rows:3,...W}):m.jsx("input",{type:F,className:"property-field-input",...W}),s?m.jsx(Yh,{onClick:s,fieldKind:t.kind,fieldLabel:t.label??e,blockType:r??"",currentValue:g,onQuickAction:o,onCustomPrompt:s,aiLoading:u}):null]})]})}function dve({slug:e,navLabel:t,onNavLabelChange:n,onAiAssist:r,onAiQuickAction:i,aiLoading:s,fieldShimmer:o}){const{t:a}=_n(),[u,d]=_.useState(t),[f,p]=_.useState(!1),g=f?u:t,{debouncedCommit:y,flushCommit:x}=jd(v=>n(e,v),400);return m.jsx(Xb,{id:"page:nav",title:a("propertyPanel.navigation"),count:1,children:m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:a("propertyPanel.navLabel")})}),m.jsxs("div",{className:`property-field-input-wrap${o?" property-field-input-wrap--ai-loading":""}`,children:[m.jsx("input",{type:"text",className:"property-field-input",placeholder:a("propertyPanel.navPlaceholder"),value:g,onFocus:()=>{d(t),p(!0)},onChange:v=>{d(v.target.value),y(v.target.value)},onBlur:()=>{p(!1),x()}}),r?m.jsx(Yh,{onClick:()=>r("Nav label","text",t),fieldKind:"text",fieldLabel:"Nav label",blockType:"Page",currentValue:t,onQuickAction:i?v=>i("Nav label","text",t,v):void 0,onCustomPrompt:()=>r("Nav label","text",t),aiLoading:o}):null]})]})})}function fve({pageMeta:e,onPageMetaChange:t,onAiAssist:n,onAiQuickAction:r,aiLoading:i,aiLoadingPath:s}){const{t:o}=_n();return m.jsxs(Xb,{id:"page:seo",title:o("propertyPanel.seo"),count:3,children:[m.jsx(qv,{label:o("propertyPanel.seoTitle"),fieldKind:"text",blockType:"Page",value:e.title??"",placeholder:o("propertyPanel.seoTitlePlaceholder"),multiline:!0,autosizeRows:{min:2,max:2},recommendedMax:60,onCommit:a=>t("title",a),onAiAssist:n?()=>n("SEO title","text",e.title??""):void 0,onAiQuickAction:r?a=>r("SEO title","text",e.title??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="SEO title"}),m.jsx(qv,{label:o("propertyPanel.metaDescription"),fieldKind:"richtext",blockType:"Page",value:e.description??"",placeholder:o("propertyPanel.metaDescPlaceholder"),multiline:!0,autosizeRows:{min:3,max:6},recommendedMax:160,onCommit:a=>t("description",a),onAiAssist:n?()=>n("Meta description","richtext",e.description??""):void 0,onAiQuickAction:r?a=>r("Meta description","richtext",e.description??"",a):void 0,aiLoading:i,fieldShimmer:i===!0&&s==="Meta description"}),m.jsx(qv,{label:o("propertyPanel.ogImage"),fieldKind:"url",blockType:"Page",value:e.ogImage??"",placeholder:"https://...",onCommit:a=>t("ogImage",a)})]})}function qv({label:e,fieldKind:t,blockType:n,value:r,placeholder:i,multiline:s,autosizeRows:o,recommendedMax:a,onCommit:u,onAiAssist:d,onAiQuickAction:f,aiLoading:p,fieldShimmer:g}){const[y,x]=_.useState(r),[v,S]=_.useState(!1),w=_.useRef(null),T=v?y:r,{debouncedCommit:A,flushCommit:M}=jd(u,400),j=s===!0&&o!=null,D=_.useCallback(()=>{if(!j||!w.current||!o)return;const V=w.current,F=getComputedStyle(V),W=Number.parseFloat(F.lineHeight),U=Number.parseFloat(F.fontSize)||15,q=Number.isFinite(W)?W:U*1.2,K=(Number.parseFloat(F.paddingTop)||0)+(Number.parseFloat(F.paddingBottom)||0),H=(Number.parseFloat(F.borderTopWidth)||0)+(Number.parseFloat(F.borderBottomWidth)||0),O=o.min*q+K+H,$=o.max*q+K+H;V.style.height="0px";const Y=V.scrollHeight,ne=Math.max(O,Math.min($,Y));V.style.height=`${ne}px`,V.style.overflowY=Y>$?"auto":"hidden"},[j,o]);_.useLayoutEffect(()=>{D()},[D,T,v,r]),_.useEffect(()=>{if(!j)return;const V=()=>D();return window.addEventListener("resize",V),()=>window.removeEventListener("resize",V)},[j,D]);const I={placeholder:i,value:T,onFocus:()=>{x(r),S(!0)},onChange:V=>{x(V.target.value),A(V.target.value)},onBlur:()=>{S(!1),M()}},R=(v?y:r).length;return m.jsxs("div",{className:"property-field",children:[m.jsx("div",{className:"property-field-label",children:m.jsx("span",{children:e})}),m.jsxs("div",{className:`property-field-input-wrap${g?" property-field-input-wrap--ai-loading":""}`,children:[s?m.jsx("textarea",{ref:j?w:void 0,className:`property-field-textarea${j?" property-field-textarea--autosize":""}`,rows:(o==null?void 0:o.min)??3,...I}):m.jsx("input",{type:"text",className:"property-field-input",...I}),d?m.jsx(Yh,{onClick:d,fieldKind:t,fieldLabel:e,blockType:n,currentValue:v?y:r,onQuickAction:f,onCustomPrompt:d,aiLoading:g}):null]}),a!=null&&m.jsxs("span",{className:`property-field-char-count${R>a?" property-field-char-count--over":""}`,children:[R," / ",a]})]})}class Gv extends _.Component{constructor(){super(...arguments);Ee(this,"state",{error:null});Ee(this,"reset",()=>{var n,r;(r=(n=this.props).onReset)==null||r.call(n),this.setState({error:null})})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){var i,s;console.error("[editor] Uncaught error in component tree:",n,r.componentStack),(s=(i=this.props).onError)==null||s.call(i,n,r)}render(){return this.state.error?m.jsxs("div",{style:this.props.style,className:"flex flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground h-full",children:[m.jsx("p",{className:"font-medium text-foreground",children:this.props.fallbackLabel??"Something went wrong"}),m.jsx("p",{className:"max-w-xs opacity-70 text-xs",children:this.state.error.message}),m.jsx("button",{type:"button",onClick:this.reset,className:"rounded-md border px-3 py-1.5 text-xs hover:bg-accent transition-colors",children:"Try again"})]}):this.props.children}}function hve({siteId:e,orchestratorUrl:t,hostedIds:n,siteOwnOrchestrator:r}){const{t:i}=_n(),s=()=>{Tue(e),window.location.href=Aue(window.location.href)},o=()=>{r&&(Eue(e,r),window.location.reload())};return r?m.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[m.jsxs("div",{className:"orchestrator-mismatch-body",children:[m.jsx("strong",{children:i("orchestratorMismatch.ownTitle")}),m.jsx("span",{children:i("orchestratorMismatch.ownDetail",{orchestrator:t,siteOrchestrator:r})})]}),m.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:o,children:i("orchestratorMismatch.useSiteOwn")})]}):m.jsxs("div",{className:"orchestrator-mismatch",role:"alert",children:[m.jsxs("div",{className:"orchestrator-mismatch-body",children:[m.jsx("strong",{children:i("orchestratorMismatch.title")}),m.jsx("span",{children:n.length>0?i("orchestratorMismatch.detailHosts",{orchestrator:t,hosted:n.join(", ")}):i("orchestratorMismatch.detail",{orchestrator:t})})]}),m.jsx("button",{type:"button",className:"orchestrator-mismatch-action",onClick:s,children:i("orchestratorMismatch.useDefault")})]})}const yg=3e3;function pve(e){const[t,n]=_.useState({status:"loading",blocks:[],manifest:null});_.useEffect(()=>{let i=!0,s=null;const o=async()=>{try{const u=await fetch(`${e||Ed}/api/editor/blocks`);if(!u.ok){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:`Manifest endpoint returned ${u.status}`}),s=setTimeout(()=>{i&&o()},yg);return}const d=await u.json(),f=OI.safeParse(d);if(!f.success){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:"Manifest response shape is invalid"}),s=setTimeout(()=>{i&&o()},yg);return}const p=BI(f.data.blocks);if(p){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:p}),s=setTimeout(()=>{i&&o()},yg);return}if(!i)return;n({status:"ready",blocks:f.data.blocks,version:f.data.version,manifest:f.data})}catch(a){if(!i)return;n({status:"degraded",blocks:[],manifest:null,reason:a instanceof Error?a.message:"Manifest fetch failed"}),s=setTimeout(()=>{i&&o()},yg)}};return o(),()=>{i=!1,s&&clearTimeout(s)}},[e]);const r=_.useMemo(()=>{const i=new Map;for(const s of t.blocks)i.set(s.type,s);return i},[t.blocks]);return{...t,byType:r,siteCapabilities:{allowStructuralEdits:t.status==="ready",manifestStatus:t.status,reason:t.reason,manifestVersion:t.version,blockCount:t.blocks.length,checkedAt:new Date().toISOString()},allowStructuralEdits:t.status==="ready"}}function mve(e){const[t,n]=_.useState(void 0);return _.useEffect(()=>{if(kg)return;let r=!1;return _ue(e).then(i=>{r||!i||i.replace(/\/+$/,"")!==$e.replace(/\/+$/,"")&&n(i)}),()=>{r=!0}},[e]),t}function gve(e){return null}function bve(){const e=gve();return e||"text"}const yve=/^[a-z]{2}(?:-[a-z0-9]{2,8})?$/i,_l="default",xve=2;let Vf;function vve(e){if(!yve.test(e))return!1;if(Vf===void 0)try{Vf=new Intl.DisplayNames(["en"],{type:"language",fallback:"none"})}catch{Vf=null}if(!Vf)return!1;try{return typeof Vf.of(e)=="string"}catch{return!1}}function Qb(e){return e.split("/").filter(Boolean)}function $u(e){const t=Qb(e);return t.length===0?"/":`/${t.join("/")}`}function kve(e){const t={},n=[];for(const u of e){const d=Qb(u)[0];if(d&&vve(d)){const f=d.toLowerCase();(t[f]||(t[f]=[])).push(u)}else n.push(u)}const r=Object.keys(t).sort();if(r.length<2)return null;const i=new Map;for(const u of r)for(const d of new Set(t[u].map(f=>Z2(f,u))))i.set(d,(i.get(d)??0)+1);if(![...i.values()].some(u=>u>=2))return null;const o=n.filter(u=>i.has($u(u))).length>=xve,a=o?[]:n;o&&(t[_l]=n,r.unshift(_l));for(const u of r){const d=u===_l?"/":`/${u}`;t[u].sort((f,p)=>f===d?-1:p===d?1:0)}return{locales:r,byLocale:t,shared:a}}function CL(e,t){var i;const n=(i=Qb(e)[0])==null?void 0:i.toLowerCase();if(n&&t.byLocale[n])return n;const r=t.byLocale[_l];return r!=null&&r.some(s=>$u(s)===$u(e))?_l:void 0}function Z2(e,t){var i;if(!t||t===_l)return $u(e);const n=Qb(e);if(((i=n[0])==null?void 0:i.toLowerCase())!==t.toLowerCase())return $u(e);const r=n.slice(1);return r.length===0?"/":`/${r.join("/")}`}function Sve(e,t){return`${xj(Z2(e,t))} (${e})`}function wve(e,t,n){const r=n.byLocale[t];if(!r||r.length===0)return e;const i=Z2(e,CL(e,n)),s=t===_l?i:i==="/"?`/${t}`:`/${t}${i}`;return r.find(a=>$u(a)===$u(s))??r[0]}function Cve(e){try{const t=new Intl.DisplayNames([e],{type:"language"}).of(e);if(t&&t.toLowerCase()!==e.toLowerCase())return t.charAt(0).toUpperCase()+t.slice(1)}catch{}return e.toUpperCase()}const FD=bve(),_ve=S$(),Eve=_.lazy(()=>yB(()=>import("./PuckPrototypeRoute-b-3hrBRO.js").then(e=>e.P),__vite__mapDeps([0,1])).then(e=>({default:e.PuckPrototypeRoute}))),Tve=new Set(["/editor/puck","/editor/puck/"]),Ave=3e4,_L="site-reachable-v1:",Nve=5e3;function EL(e){if(typeof sessionStorage>"u")return null;try{const t=sessionStorage.getItem(_L+e);if(!t)return null;const n=JSON.parse(t);return Date.now()-n.ts>Ave?null:n.ok}catch{return null}}function UD(e,t){if(!(typeof sessionStorage>"u"))try{sessionStorage.setItem(_L+e,JSON.stringify({ok:t,ts:Date.now()}))}catch{}}function Mve({name:e,origin:t,statusClass:n,active:r,dimmed:i,onSelect:s}){const o=t.replace(/^https?:\/\//,"");return m.jsxs("button",{type:"button",role:"menuitem",className:`site-switcher-item${r?" is-active":""}${i?" is-dimmed":""}`,onClick:s,title:t,children:[m.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${n}`,"aria-hidden":"true"}),m.jsxs("span",{className:"site-switcher-item-body",children:[m.jsx("span",{className:"site-switcher-item-name",children:e}),m.jsx("span",{className:"site-switcher-item-origin",children:o})]}),r?m.jsx(Xh,{size:12,"aria-hidden":"true"}):null]})}function HD(e){if(typeof sessionStorage>"u")return null;const t=new Set;let n=!1;for(const r of e){const i=EL(r);i!==null&&(n=!0,i&&t.add(r))}return n?t:null}function Dve(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Rve(){const e=typeof window<"u"?window.location.pathname:"/",t=e==="/"||e==="/editor"||e==="/editor/",n=Tve.has(e),r=e==="/sites"||e==="/sites/";fe(d=>d.chatDarkMode);const i=fe(d=>d.setChatDarkMode),s=_.useMemo(()=>_G(),[]),o=_.useMemo(()=>Ej(),[]),a=_.useRef(!1);if(!a.current){a.current=!0;const d=typeof window<"u"?window.location.origin:"http://localhost:4100";z$({sessionId:s,siteId:o,editorOrigin:d,orchestratorUrl:$e})}const u=Mue(o,s);return _.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=p=>i(p.matches);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[i]),n?m.jsx(_.Suspense,{fallback:m.jsx("div",{style:{height:"100vh",display:"grid",placeItems:"center"},children:"Loading prototype…"}),children:m.jsx(Eve,{})}):r?m.jsx(bN,{sites:u,session:s}):t?m.jsx(Ove,{sites:u}):m.jsx(bN,{sites:u,session:s})}const jve=new Set(["avocado-hub","avocado-stories","avocado-magic","avocado-odyssey"]);function Ive(e){return e.split(".").map(t=>{const n=t.match(/^([a-zA-Z_]+)\[(\d+)\]$/);return n?`${VD(n[1])} ${Number(n[2])+1}`:VD(t)}).join(" · ")}function VD(e){const n=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s*url\s*$/i,"").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):e}function Ove({sites:e}){var Dp,Rp,Vd;const{t}=_n(),n=Ui(),r=Hi(),i=fe(E=>E.chatDarkMode),s=fe(E=>E.setChatDarkMode),{activeSiteConfig:o}=e,a=_.useMemo(()=>ku(o),[o]),u=pve(a),d=typeof window<"u"?window.location.origin:"http://localhost:4100",f=mve(a),p=e.siteHosting==="notHosted"||f!=null,g=fe(E=>E.slug),y=fe(E=>E.setSlug),x=fe(E=>E.availableSlugs);fe(E=>E.setAvailableSlugs);const v=fe(E=>E.isLoadingSlugs),S=fe(E=>E.modelKey),w=fe(E=>E.setModelKey),T=fe(E=>E.provider),A=fe(E=>E.setProvider),M=fe(E=>E.availableProviders),j=fe(E=>E.setAvailableProviders),[D,I]=_.useState(""),R=fe(E=>E.activeBlockId),V=fe(E=>E.activeBlockType),F=fe(E=>E.activeEditablePath),W=E=>fe.getState().setActiveBlock(E),U=E=>{const Z=fe.getState();Z.setActiveBlock(Z.activeBlockId,E)},q=(E,Z)=>fe.getState().setActiveBlock(E,Z),K=fe(E=>E.setActiveEditablePath),H=fe(E=>E.useStreaming),O=fe(E=>E.setUseStreaming),$=fe(E=>E.autoScrollTrackingEnabled),Y=fe(E=>E.setAutoScrollTrackingEnabled),[ne,P]=_.useState(!1),[L,J]=_.useState(_ve),z=_.useCallback(E=>{J(E);try{window.localStorage.setItem(Qv,E?"1":"0")}catch{}},[]),Q=_.useMemo(()=>!0,[]),oe=Q&&L,[se,ie]=_.useState(!1),[Me,ke]=_.useState(0),Oe=_.useCallback(()=>ke(E=>E+1),[]),ce=fe(E=>E.showSettingsModal),ee=fe(E=>E.setShowSettingsModal),Re=fe(E=>E.showDebugDetails),Ce=fe(E=>E.setShowDebugDetails),Je=fe(E=>E.composerHeight),st=fe(E=>E.setComposerHeight),gt=fe(E=>E.addBlockPicker),Qe=fe(E=>E.setAddBlockPicker),ot=fe(E=>E.addBlockSearch),mn=fe(E=>E.setAddBlockSearch),Dn=fe(E=>E.isAddingBlock),Bn=fe(E=>E.setIsAddingBlock),Rt=fe(E=>E.copiedDebugEntryId),bt=fe(E=>E.setCopiedDebugEntryId),En=fe(E=>E.feedbackNoteEntryId),de=fe(E=>E.setFeedbackNoteEntryId),be=fe(E=>E.feedbackNoteText),ze=fe(E=>E.setFeedbackNoteText),et=fe(E=>E.selectedVariationId),tt=fe(E=>E.setSelectedVariationId),Ct=fe(E=>E.imagePickerTarget),Yn=fe(E=>E.setImagePickerTarget),Jn=Ct!==null,gn=fe(E=>E.backendFeatures),hr=fe(E=>E.setBackendFeatures),pe=fe(E=>E.setBackendSite),Le=fe(E=>E.selectionModeEnabled),ct=fe(E=>E.setSelectionModeEnabled),kt=fe(E=>E.anchorRect),qe=fe(E=>E.setAnchorRect),ye=fe(E=>E.anchoredExpanded),Be=fe(E=>E.setAnchoredExpanded),Fe=fe(E=>E.activeTab),Ve=fe(E=>E.setActiveTab),[_t,yt]=_.useState(!1),[Zt,an]=_.useState(!1),Rn=_.useRef(null);_.useEffect(()=>{if(!Zt)return;const E=me=>{Rn.current&&!Rn.current.contains(me.target)&&an(!1)},Z=me=>{me.key==="Escape"&&an(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",Z)}},[Zt]);const[Yi,bs]=_.useState(()=>HD(e.siteList.map(E=>E.id))),si=_.useCallback(E=>{bs(Z=>Dve(Z,E)?Z:E)},[]);_.useEffect(()=>{if(!Zt)return;si(HD(e.siteList.map(me=>me.id)));let E=!0;return(async()=>{let me=!0;const Ne=await Promise.all(e.siteList.map(async Pe=>{const Te=EL(Pe.id);if(Te!==null)return{id:Pe.id,ok:Te};me=!1;const Ge=ku(Pe);try{const Nt=await fetch(`${Ge}/api/editor/blocks?siteId=${encodeURIComponent(Pe.id)}`,{signal:AbortSignal.timeout(2500)});return UD(Pe.id,Nt.ok),{id:Pe.id,ok:Nt.ok}}catch{return UD(Pe.id,!1),{id:Pe.id,ok:!1}}}));E&&!me&&si(new Set(Ne.filter(Pe=>Pe.ok).map(Pe=>Pe.id)))})(),()=>{E=!1}},[Zt,e.siteList,si]);const Ir=_.useMemo(()=>{const E=Yi===null;return e.siteList.map(Z=>{const me=E||Z.id===r||Yi.has(Z.id);return{site:Z,origin:ku(Z),online:me,probing:E}}).sort((Z,me)=>Z.site.id===r?-1:me.site.id===r?1:Z.online!==me.online?Z.online?-1:1:Z.site.name.localeCompare(me.site.name))},[Yi,e.siteList,r]),{onlineEntries:ys,activeEntry:Ni}=_.useMemo(()=>({onlineEntries:Ir.filter(E=>E.online),activeEntry:Ir.find(E=>E.site.id===r)}),[Ir,r]),$n=_.useRef(null),Ji=_.useRef(null),kr=_.useRef(!0),Tn=_.useRef(!1),jn=_.useRef(null),Sr=_.useRef(void 0),pr=_.useRef(!1),$o=_.useRef(null),Hs=_.useRef(!1),xs=_.useRef(0),yi=_.useRef(null),Xn=_.useRef(null),en=fe(E=>E.chatWidth),bn=fe(E=>E.setChatWidth),xi=fe(E=>E.propsWidth),mr=fe(E=>E.setPropsWidth),tn=_.useRef(null),Xi=_.useRef(null),[Mi,Di]=_.useState(1),oi=_.useRef(null),uo=_.useRef(null),Vs=_.useRef(!1),co=_.useRef(!1);_.useEffect(()=>{if(!co.current&&!(v||x.length===0)){if(g!=="/"||x.includes("/")){co.current=!0;return}co.current=!0,pr.current=!1,y(x[0])}},[x,v,g,y]);const fo=_.useMemo(()=>{const E=Array.from(new Set([...x,g].filter(Boolean)));return E.includes("/")?["/",...E.filter(Z=>Z!=="/")]:E},[x,g]),tr=_.useMemo(()=>kve(fo),[fo]),wr=tr?CL(g,tr)??tr.locales[0]:void 0,Kr=_.useMemo(()=>!tr||!wr?fo:tr.byLocale[wr]??[],[tr,wr,fo]),nr=_.useMemo(()=>{if(!u.allowStructuralEdits)return[];if(u.blocks.length>0)return u.blocks.map(Z=>({type:Z.type,label:Z.displayName??Z.type,category:"content"})).sort((Z,me)=>Z.label.localeCompare(me.label));const E=pu();return[...Pk].map(Z=>{var me,Ne;return{type:Z,label:((me=E[Z])==null?void 0:me.displayName)??Z,category:((Ne=E[Z])==null?void 0:Ne.category)??"content"}}).sort((Z,me)=>Z.label.localeCompare(me.label))},[u.allowStructuralEdits,u.blocks]),Ea=_.useMemo(()=>{const E=ot.trim().toLowerCase(),Z=E?nr.filter(Pe=>Pe.label.toLowerCase().includes(E)||Pe.type.toLowerCase().includes(E)):nr,me=new Map;for(const Pe of Z){const Te=Pe.category||"content",Ge=me.get(Te);Ge?Ge.push(Pe):me.set(Te,[Pe])}const Ne=["content","layout","conversion","navigation","media"];return[...me.entries()].sort((Pe,Te)=>{const Ge=Ne.indexOf(Pe[0]),Nt=Ne.indexOf(Te[0]),ln=Ge===-1?Number.MAX_SAFE_INTEGER:Ge,ar=Nt===-1?Number.MAX_SAFE_INTEGER:Nt;return ln!==ar?ln-ar:Pe[0].localeCompare(Te[0])}).map(([Pe,Te])=>({category:Pe,options:Te}))},[ot,nr]),qs=()=>{const E=Date.now();E-xs.current<1200||(xs.current=E,He.pushAssistantFromResult({status:"needs_clarification",summary:t("streamError.structuralDisabled"),changes:YO(u.reason)}))},Fo=_.useRef(()=>{}),Lr=_.useCallback(E=>{fe.getState().slug!==E&&(Hs.current=!0,y(E))},[y]),vs=_.useMemo(()=>({onBlockClicked:(E,Z,me,Ne,Pe,Te)=>{Lr(E),q(Z,me),K(Ne),qe(Z?Te:null),fe.getState().setActiveTab(Z?"properties":"chat")},onRouteChanged:E=>{fe.getState().slug!==E&&q(void 0,void 0),Lr(E),K(void 0),qe(null),rr.current("setSelectionMode",{enabled:fe.getState().selectionModeEnabled}),Fo.current(E)},onBlockReordered:(E,Z,me)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.reorderBlock(E,Z,me)},onBlockDeleteRequested:(E,Z)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.deleteBlock(E,Z)},onBlockAddRequested:(E,Z)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),!(!Z.afterBlockId&&!Z.beforeBlockId)&&Qe({slug:E,afterBlockId:Z.afterBlockId,beforeBlockId:Z.beforeBlockId})},onListItemAddRequested:(E,Z,me,Ne,Pe)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.addListItem(E,Z,me,Ne,Pe)},onListItemRemoveRequested:(E,Z,me,Ne,Pe)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.removeListItem(E,Z,me,Ne,Pe)},onListItemMoveRequested:(E,Z,me,Ne,Pe,Te)=>{if(!u.allowStructuralEdits){qs();return}E!==g&&Lr(E),K(void 0),He.moveListItem(E,Z,me,Ne,Pe,Te)},onOpenImagePicker:(E,Z,me,Ne,Pe)=>{Yn({slug:E,blockId:Z,editablePath:me,currentUrl:Ne,blockType:Pe??(Z===R?V:void 0)})},onEditBlockRequested:(E,Z)=>{Be(!0)},onInlineTextCommitted:(E,Z,me,Ne)=>{E!==g&&Lr(E),me&&K(me),He.inlineEditCommit(E,Z,me,Ne)},onIframeScrolled:()=>{qe(null),fe.getState().isLoading&&fe.getState().setAutoScrollSuppressed(!0)}}),[u.allowStructuralEdits,Lr,g]);_.useCallback(async()=>{var E;try{const Z=`${$e}/draft/pages?session=${encodeURIComponent(n)}&siteId=${encodeURIComponent(r)}&slug=${encodeURIComponent(g)}`,me=await fetch(Z,{cache:"no-store"});if(!me.ok)return;const Pe=((await me.json()).blocks??[]).find(Te=>Te.type==="Hero");if(!Pe)return;q(Pe.id,Pe.type),Yn({slug:g,blockId:Pe.id,editablePath:"imageUrl",currentUrl:typeof((E=Pe.props)==null?void 0:E.imageUrl)=="string"?Pe.props.imageUrl:void 0,blockType:Pe.type})}catch{}},[n,r,g,Yn]);const Yt=Due(g,vs,a),rr=_.useRef(Yt.postToSite);_.useEffect(()=>{rr.current=Yt.postToSite},[Yt.postToSite]);const Uo=_.useCallback(E=>{const Z=E??!Le;ct(Z),Yt.postToSite("setSelectionMode",{enabled:Z})},[Le,Yt]);_.useEffect(()=>{const E=Z=>{Z.key==="Escape"&&Le&&Uo(!1)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[Le,Uo]),_.useEffect(()=>{if(Fe!=="history")return;const E=Z=>{Z.key==="Escape"&&fe.getState().setActiveTab("chat")};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[Fe]);const Ho=_.useCallback((E,Z)=>{(E==="draftUpdated"||E==="liveDraft")&&Oe(),Yt.postToSite(E,Z)},[Yt,Oe]),ho=_.useCallback((E,Z,me,Ne)=>(Oe(),Yt.postPatchToSite(E,Z,me,Ne)),[Yt,Oe]),He=Lue({activeSiteConfig:o,siteRegistryChecked:e.siteRegistryChecked,postToSite:Ho,postPatchToSite:ho,componentManifest:u.manifest,siteCapabilities:u.siteCapabilities,allowStructuralEdits:u.allowStructuralEdits,getBlockDefaultProps:E=>{var Z;return((Z=u.byType.get(E))==null?void 0:Z.defaultProps)??null},onApplied:()=>{var E;(E=Sr.current)==null||E.call(Sr)},agentModeEnabled:gn.agentMode??!1}),Wr=fe(E=>E.chatLog),ks=fe(E=>E.chatAttachments),Ss=fe(E=>E.setChatAttachments),ir=fe(E=>E.isLoading),Or=fe(E=>E.streamStatus),Gs=fe(E=>E.streamingText),Ta=fe(E=>E.streamingChanges),Pd=fe(E=>E.streamSteps),Zu=fe(E=>E.streamTokenCount),Ri=fe(E=>E.latestStreamFocusBlockId),gr=fe(E=>E.imageProgress),ql=fe(E=>E.plannerBadgeState),[ai,ji]=_.useState(!1),Br=fe(E=>E.setPlannerBadgeState),Yu=fe(E=>E.pendingPlanId),at=fe(E=>E.variationModal),St=fe(E=>E.isApplyingVariation),_e=fe(E=>E.setVariationModal),Lt=fe(E=>E.continuationChainId),li=fe(E=>E.fieldDraftDebugEnabled),Ii=fe(E=>E.setFieldDraftDebugEnabled),Fn=fe(E=>E.fieldDraftDebug);_.useEffect(()=>{jve.has(r)||(w("balanced"),He.clearChat())},[r]);function ui(E){var Z,me;typeof E.navigateToSlug=="string"&&E.navigateToSlug.length>0&&E.navigateToSlug!==g&&y(E.navigateToSlug),typeof E.canUndo=="boolean"&&((Z=He.setCanUndoServer)==null||Z.call(He,E.canUndo)),typeof E.canRedo=="boolean"&&((me=He.setCanRedoServer)==null||me.call(He,E.canRedo)),Yt.postToSite("draftUpdated",{focusBlockId:null}),Oe()}async function lt(E){yt(!0);try{const me=await(await fetch(`${$e}/history/restore`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,targetVersion:E})})).json();me.status==="applied"&&ui(me)}catch{}finally{yt(!1)}}const rt=Fue(n,r,a,Me),nn=$ue(n,r,ir,He.pushAssistantFromResult,a,()=>{Yt.postToSite("draftUpdated",{focusBlockId:null}),rt.markPublished()}),In=rt.summary?rt.summary.total>0:!0,sr=Uue(),Et=Fe==="properties"&&He.hasBootstrapped,xt=que(n,r,g,R,Et),or=Gue(n,r,g,Et);_.useEffect(()=>{!R||V||!xt.blockType||U(xt.blockType)},[R,V,xt.blockType]);const Ot=VG(n,r,!!n),Ju=qG(Ot.findings),po=_.useRef(null),Zr=_.useCallback((E,Z,me)=>{q(E,Z),K(me),qe(null),fe.getState().selectionModeEnabled||(fe.getState().setSelectionModeEnabled(!0),rr.current("setSelectionMode",{enabled:!0})),rr.current("highlightBlock",{blockId:E,editablePath:me??null,scrollIntoView:!0})},[]),vi=_.useCallback(E=>{const Z=po.current;!Z||Z.slug!==E||(po.current=null,!(Z.expiresAt!==void 0&&Date.now()>Z.expiresAt)&&Zr(Z.blockId,Z.blockType,Z.path))},[Zr]);_.useEffect(()=>{if(!po.current)return;const E=setTimeout(()=>vi(g),400);return()=>clearTimeout(E)},[g,vi]),_.useEffect(()=>{Fo.current=vi},[vi]);const mo=_.useCallback((E,Z,me,Ne)=>{if(!Z){E!==fe.getState().slug&&y(E),q(void 0,void 0),K(void 0),Ve("properties");return}if(E!==fe.getState().slug){po.current={slug:E,blockId:Z,blockType:me,path:Ne},y(E),Ve("properties");return}Ve("properties"),po.current={slug:E,blockId:Z,...me?{blockType:me}:{},...Ne?{path:Ne}:{},expiresAt:Date.now()+Nve},Zr(Z,me,Ne)},[Zr]);Sr.current=()=>{xt.refetch(),or.refetch(),Oe()};const[zd,ey]=_.useState(()=>xk(g,{session:n,siteId:r,editorOrigin:d},a)),[ty,mp]=_.useState(!1);_.useEffect(()=>{mp(!1)},[zd]),_.useEffect(()=>{$o.current!==a&&($o.current=a,pr.current=!1);const E={session:n,siteId:r,editorOrigin:d};if(Hs.current){Hs.current=!1;return}if($g&&pr.current){Yt.postToSite("navigate",{href:vk(g,E)});return}const Z=xk(g,E,a);ey(me=>me===Z?me:Z)},[a,d,n,r,g]);const Xu=_.useMemo(()=>{var me;const E=(me=o.vercelProductionUrl)==null?void 0:me.trim(),Z=E&&/^https?:\/\//i.test(E)?E:a;try{const Ne=new URL(Z);return Ne.origin===a?AG(g,{},a):(Ne.pathname=g==="/"?"/":g,Ne.search="",Ne.hash="",Ne.toString())}catch{return}},[o.vercelProductionUrl,a,g]),gp=_.useMemo(()=>a?`${a}${vk(g,{session:n,siteId:r,editorOrigin:d,immersive:"1"})}`:void 0,[a,d,n,r,g]);_.useEffect(()=>{let E=!0;const Z=async()=>{const Ne=[`${$e}/status/planner`];$e.includes("localhost")&&Ne.push(`${$e.replace("localhost","127.0.0.1")}/status/planner`);try{for(const Pe of Ne){const Te=await fetch(Pe);if(!Te.ok)continue;const Ge=await Te.json();if(!E)return;if(Ge.features&&hr(Ge.features),Ge.site&&pe(Ge.site),Array.isArray(Ge.availableProviders)&&Ge.availableProviders.length>0&&(j(Ge.availableProviders),(!Ge.availableProviders.includes(T)||T!=="anthropic"&&Ge.availableProviders.includes("anthropic"))&&A(Ge.availableProviders.includes("anthropic")?"anthropic":Ge.availableProviders[0])),Ge.plannerSource==="openai"||Ge.plannerSource==="anthropic"||Ge.plannerSource==="gemini"||Ge.plannerSource==="demo"){Br(Ge.plannerSource);return}}E&&Br("error")}catch{E&&Br("error")}};Z();const me=window.setInterval(()=>{Z()},1e4);return()=>{E=!1,window.clearInterval(me)}},[]);const bp=_.useRef(0),yp=_.useRef(0);_.useEffect(()=>{const E=Ji.current;if(!E)return;const Z=()=>{const me=Math.abs(E.scrollHeight-E.scrollTop-E.clientHeight)<2||E.scrollHeight<=E.clientHeight;!me&&E.scrollTop<bp.current?kr.current=!1:me&&(kr.current=!0),bp.current=E.scrollTop};return E.addEventListener("scroll",Z,{passive:!0}),()=>{E.removeEventListener("scroll",Z)}},[]),_.useEffect(()=>{const E=Ji.current;if(!E||!(Wr.length>0||!!Or||!!Gs))return;const me=Wr.reduce((Nt,ln)=>ln.role==="user"?Nt+1:Nt,0);me>yp.current&&(kr.current=!0),yp.current=me;const Ne=!Tn.current,Pe=Wr.some(Nt=>Nt.role==="user");if(Ne&&!Pe&&!Or&&!Gs){Tn.current=!0,kr.current=!1;return}if(!Ne&&!kr.current)return;const Ge=window.requestAnimationFrame(()=>{E.scrollTop=E.scrollHeight,kr.current=!0,Tn.current=!0});return()=>window.cancelAnimationFrame(Ge)},[Wr.length,Or,Gs,Pd.length,Ta.length]),_.useEffect(()=>{Yt.postToSite("setNestedLabelsVisibility",{visible:ne})},[ne]),_.useEffect(()=>{const E=rr.current;if(!ir){Vs.current&&E("aiFieldLoading",{blockId:"",active:!1}),uo.current=null,Vs.current=!1;return}const Z=Ri??R??"",Ne=Z&&Z===(R??"")?F??"":"";E("aiFieldLoading",{blockId:Z,editablePath:Ne,active:!0}),uo.current={blockId:Z,editablePath:Ne},Vs.current=!0},[ir,Ri,R,F]),_.useEffect(()=>{if(!ir)return;const E=window.setInterval(()=>{const Z=uo.current;Z&&rr.current("aiFieldLoading",{blockId:Z.blockId,editablePath:Z.editablePath,active:!0})},1200);return()=>window.clearInterval(E)},[ir]),_.useEffect(()=>{R&&Yt.postToSite("highlightBlock",{blockId:R,editablePath:F??null})},[R,F]),_.useEffect(()=>{He.clearFieldAiContext()},[R]),_.useEffect(()=>{R||qe(null)},[R]),_.useEffect(()=>{Be(!1)},[kt]),_.useEffect(()=>{const E=()=>qe(null);return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]);const ny=R$(),Aa=_.useMemo(()=>{if(!ny||!kt||!Le||!R||typeof window>"u"||window.innerWidth<=1040)return null;const E=Yt.iframeRef.current;if(!E)return null;const Z=E.getBoundingClientRect(),me=380,Ne=36,Pe=26,Te=8,Ge=Z.top+kt.top*Mi;if(Ge+kt.height*Mi<Z.top||Ge>Z.bottom)return null;const ln=Ge+Te-(Ne-Pe)/2;let ar=Z.left+(kt.left+kt.width)*Mi-Ne-Te;return ar=Math.max(Z.left+Te,Math.min(ar,Z.right-Ne-Te)),{top:ln,left:ar,width:me}},[kt,Le,R,Yt.iframeRef,Mi]);_.useEffect(()=>{Aa&&ye&&requestAnimationFrame(()=>{var E,Z;(Z=(E=oi.current)==null?void 0:E.querySelector("textarea"))==null||Z.focus()})},[!!Aa,ye]);const xp=_.useCallback((E,Z,me,Ne)=>{var ln;if(!R||!V)return;const Te=((ln=pu()[V])==null?void 0:ln.displayName)??V;K(E);const Ge=Yk(me,Z,V,Ne),Nt={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Te} → ${Z}`,fieldAiContext:{blockId:R,blockType:V,fieldPath:E,fieldLabel:Z,blockDisplayName:Te},suggestions:Ge};He.setFieldAiContext(Nt)},[R,V]),ry=_.useCallback((E,Z,me)=>{const Ne=Yk(Z,E,"Page",me),Pe={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${E}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:E,fieldLabel:E,blockDisplayName:"Page"},suggestions:Ne};He.setFieldAiContext(Pe)},[]),iy=_.useCallback((E,Z,me,Ne,Pe)=>{var ln;if(!R||!V)return;const Ge=((ln=pu()[V])==null?void 0:ln.displayName)??V;K(E),Yt.postToSite("aiFieldLoading",{blockId:R,editablePath:E,active:!0}),uo.current={blockId:R,editablePath:E},Vs.current=!0;const Nt={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: ${Ge} → ${Z}`,fieldAiContext:{blockId:R,blockType:V,fieldPath:E,fieldLabel:Z,blockDisplayName:Ge}};He.setFieldAiContext(Nt),He.submitChat(Pe)},[R,V]),sy=_.useCallback((E,Z,me,Ne)=>{K(E);const Pe={id:`field-ai-${Date.now()}`,role:"assistant",text:`Editing: Page → ${E}`,fieldAiContext:{blockId:"__page__",blockType:"__page__",fieldPath:E,fieldLabel:E,blockDisplayName:"Page"}};He.setFieldAiContext(Pe),He.submitChat(Ne)},[]);_.useEffect(()=>{He.refreshRouteSlugs()},[n,r,e.siteRegistryChecked]);const Ld=E=>{const me=$n.current,Ne=Ji.current;if(!me||!Ne)return Math.max(56,E);const Pe=120,Te=10,Ge=Ne.offsetTop,Nt=Math.max(56,me.clientHeight-Ge-Te-Pe);return Math.min(Nt,Math.max(56,E))},Bd=_.useCallback(E=>{st(Z=>{const me=Ld(E);return me===Z?Z:me})},[]);_.useEffect(()=>{const E=me=>{const Ne=yi.current;if(Ne){const Te=me.clientY-Ne.y,Ge=Ld(Ne.composerHeight-Te);st(Ge)}const Pe=Xn.current;if(Pe){const Te=me.clientX-Pe.x;Pe.target==="chat"?bn(nk(Pe.width+Te)):mr(rk(Pe.width-Te))}},Z=()=>{const me=!!Xn.current;yi.current=null,Xn.current=null,document.body.style.userSelect="",me&&document.body.classList.remove("panel-resizing")};return window.addEventListener("pointermove",E),window.addEventListener("pointerup",Z),()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",Z),document.body.style.userSelect="",document.body.classList.remove("panel-resizing")}},[]),_.useEffect(()=>{const E=()=>{st(Z=>Ld(Z)),bn(Z=>Z&&nk(Z)),mr(Z=>Z&&rk(Z))};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[bn,mr]),_.useEffect(()=>{if(!at)return;const E=Z=>{Z.key==="Escape"&&!St&&_e(null)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[at,St]),_.useEffect(()=>{at!=null&&at.options.length?tt(at.options[0].id):tt(null)},[at]),_.useEffect(()=>{gt||mn("")},[gt]),_.useEffect(()=>{if(!gt)return;const E=Z=>{Z.key==="Escape"&&!Dn&&Qe(null)};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[gt,Dn]);const $d=Or?/failed|error/i.test(Or):!1,[vp,kp]=_.useState(0),Sp=gr==null?void 0:gr.stage;_.useEffect(()=>{if(kp(0),!ir)return;const E=window.setInterval(()=>kp(Z=>Z+1),1e3);return()=>window.clearInterval(E)},[ir,Or,Sp]);const wp=ir&&!$d&&vp>=5?` · ${vp}s`:"",oy=(gr?gr.stage:Or??(Zu>0?t("stream.shapingUpdate"):t("stream.gettingReady")))+wp,Cp=(gr?gr.stage:Or??(Zu>0?t("stream.updating"):t("stream.thinking")))+wp,Ks=(Or==null?void 0:Or.match(/reconnecting(?:\s+agent\s+stream)?(?:\s+\((\d+)\/(\d+)\))?/i))??null,_p=Ks!=null&&Ks[1]?Number(Ks[1]):null,Ep=Ks!=null&&Ks[2]?Number(Ks[2]):null,Qu=Ks?_p&&Ep?`Reconnect ${_p}/${Ep}`:"Reconnecting":null,Tp=`field_draft ${Fn.eventsPerSecond}/s · chars ${Fn.charsPerSecond}/s · lag ${Fn.typingLagChars}`,ay={"--composer-height":`${Je}px`},Ws=Fe==="properties",Zs=Fe==="history",ec=Fe==="health",Fd=_.useCallback(()=>{W(void 0),U(void 0),Ve("chat")},[]);_.useLayoutEffect(()=>{const E=Xi.current,Z=Yt.iframeRef.current;if(!E||!Z)return;const me=Te=>{var Qi;if(Te?Z.classList.remove("preview-iframe-no-transition"):Z.classList.add("preview-iframe-no-transition"),!Ws){Z.style.removeProperty("width"),Z.style.removeProperty("height"),Z.style.removeProperty("transform"),Di(Oi=>Oi===1?Oi:1);return}const Ge=E.offsetWidth,Nt=((Qi=tn.current)==null?void 0:Qi.offsetWidth)??0;if(Ge<=0||Nt<=0)return;const ln=Ge+Nt,ar=Ge/ln;Z.style.width=`${ln}px`,Z.style.height=`${100/ar}%`,Z.style.transform=`scale(${ar})`,Di(Oi=>Math.abs(Oi-ar)<5e-4?Oi:ar)};me(!0);const Ne=new ResizeObserver(()=>me(!1)),Pe=window.setTimeout(()=>{Ne.observe(E);const Te=tn.current;Te&&Ne.observe(Te)},240);return()=>{window.clearTimeout(Pe),Z.classList.remove("preview-iframe-no-transition"),Ne.disconnect()}},[Ws,Yt.iframeRef]);const Ap={...en?{"--chat-width":`${en}px`}:{},...xi?{"--props-width":`${xi}px`}:{}},Ud=Wr.some(E=>E.role==="user"),Hd=_.useCallback(E=>{const Z=[];E.text&&Z.push(E.text),E.status&&!E.canUndo&&E.status!=="needs_clarification"&&E.status!=="plan_ready"&&Z.push(`status: ${E.status}`);const me=(E.changes??[]).filter(Ne=>!vj(E.text,Ne));if(me.length>0&&Z.push(`changes: ${me.join(`
|
|
735
735
|
`)}`),(E.errors??[]).length>0&&Z.push(`errors: ${(E.errors??[]).join(`
|
|
736
736
|
`)}`),E.debug){if(Z.push(""),Z.push("Debug"),E.debug.traceId&&Z.push(`traceId: ${E.debug.traceId}`),E.debug.promptHash&&Z.push(`promptHash: ${E.debug.promptHash}`),E.debug.outcome&&Z.push(`outcome: ${E.debug.outcome}`),E.debug.reasonCategory&&Z.push(`reason: ${E.debug.reasonCategory}`),E.debug.reason&&E.debug.reason!==E.debug.reasonCategory&&Z.push(`reasonDetail: ${E.debug.reason}`),E.debug.intent&&Z.push(`intent: ${E.debug.intent}`),E.debug.plannerTier&&Z.push(`plannerTier: ${E.debug.plannerTier}`),E.debug.modelUsed&&Z.push(`model: ${E.debug.modelUsed}${E.debug.plannerSource?` (${E.debug.plannerSource})`:""}`),typeof E.debug.planningAttempts=="number"&&E.debug.planningAttempts>1&&Z.push(`planningAttempts: ${E.debug.planningAttempts}`),typeof E.debug.opCount=="number"&&Z.push(`opCount: ${E.debug.opCount}`),Array.isArray(E.debug.skippedOps)&&E.debug.skippedOps.length>0){const Pe=E.debug.skippedOps.map(Te=>`[${Te.index}] ${Te.op} ${Te.pageSlug??""}${Te.blockId?"#"+Te.blockId:""}: ${Te.reason}`).join(", ");Z.push(`skippedOps: ${Pe}`)}else typeof E.debug.skippedOpCount=="number"&&E.debug.skippedOpCount>0&&Z.push(`skippedOps: ${E.debug.skippedOpCount}`);if(Array.isArray(E.debug.opTypes)&&E.debug.opTypes.length>0&&Z.push(`ops: ${E.debug.opTypes.join(", ")}`),typeof E.debug.totalTokens=="number"&&Z.push(`tokens: in:${E.debug.inputTokens??"?"} out:${E.debug.outputTokens??"?"} total:${E.debug.totalTokens}`),typeof E.debug.estimatedUsd=="number"&&Z.push(`cost: $${E.debug.estimatedUsd.toFixed(4)}`),Array.isArray(E.debug.timeline)&&E.debug.timeline.length>0){const Pe=E.debug.timeline.map(Te=>`${Te.stage}:${Te.atMs}ms`).join(" -> ");Z.push(`timeline: ${Pe}`)}E.debug.promptExcerpt&&Z.push(`prompt: ${E.debug.promptExcerpt}`);const Ne=[];E.debug.currentPage&&Ne.push(`page: ${E.debug.currentPage}`),E.debug.siteId&&Ne.push(`site: ${E.debug.siteId}`),E.debug.activeBlockId&&Ne.push(`block: ${E.debug.activeBlockId}`),E.debug.activeEditablePath&&Ne.push(`path: ${E.debug.activeEditablePath}`),Ne.length>0&&Z.push(`context: ${Ne.join(", ")}`)}return Z.join(`
|
|
737
737
|
`)},[]),Np=_.useCallback(async E=>{const Z=Hd(E);if(Z.trim())try{await navigator.clipboard.writeText(Z),bt(E.id),window.setTimeout(()=>{fe.getState().copiedDebugEntryId===E.id&&bt(null)},1400)}catch{}},[Hd]),Na=_.useCallback(E=>{var me;if(!E.debug)return t("chat.expandDetails");const Z=[];if(E.debug.outcome&&Z.push(E.debug.outcome.replace(/_/g," ")),typeof E.debug.opCount=="number"){const Ne=E.debug.opCount;Z.push(`${Ne} op${Ne===1?"":"s"}`)}if(E.debug.intent&&Z.push(`intent: ${E.debug.intent.replace(/_/g," ")}`),E.debug.plannerTier&&Z.push(E.debug.plannerTier.replace(/_/g," ")),Array.isArray(E.debug.timeline)&&E.debug.timeline.length>0){const Ne=(me=E.debug.timeline[E.debug.timeline.length-1])==null?void 0:me.atMs;typeof Ne=="number"&&Z.push(`${Ne}ms`)}return Z.join(" · ")||t("chat.expandDetails")},[t]),Mp=m.jsxs("div",{className:"chat-header-slug-actions",children:[m.jsx("button",{type:"button",className:`chat-header-icon-btn${Ws?" is-active":""}`,"aria-label":t("tabs.properties"),title:t("tabs.properties"),"aria-pressed":Ws,onClick:()=>{Ws?Fd():(W(void 0),U(void 0),Ve("properties"))},children:m.jsx(V9,{size:14,"aria-hidden":"true"})}),m.jsx("button",{type:"button",className:`chat-header-icon-btn${Zs?" is-active":""}`,"aria-label":t("history.tooltip"),title:t("history.tooltip"),"aria-pressed":Zs,onClick:()=>Ve(Zs?"chat":"history"),children:m.jsx(zB,{size:14,"aria-hidden":"true"})}),m.jsxs("button",{type:"button",className:`chat-header-icon-btn${ec?" is-active":""}`,"aria-label":t("health.tooltip"),title:t("health.tooltip"),"aria-pressed":ec,onClick:()=>Ve(ec?"chat":"health"),children:[m.jsx(W9,{size:14,"aria-hidden":"true"}),Ot.findings.length>0?m.jsx("span",{className:`health-badge health-badge--${Ju??"info"}`,children:Ot.findings.length}):null]}),gp?m.jsx("a",{className:"chat-header-icon-btn",href:gp,target:"_blank",rel:"noreferrer","aria-label":t("header.openImmersive"),title:t("header.openImmersive"),children:m.jsx(YB,{size:14,"aria-hidden":"true"})}):null,Q?m.jsx("button",{type:"button",className:"chat-header-icon-btn","aria-label":t("header.moreOptions"),onClick:()=>ee(!0),children:m.jsx(UB,{size:14,"aria-hidden":"true"})}):null]});return m.jsxs("div",{className:`layout${Ws?" layout--props-open":""}${p?" layout--banner":""}`,style:Ap,children:[p?m.jsx(hve,{siteId:r,orchestratorUrl:$e,hostedIds:e.hostedSiteIds??[],...e.siteHosting==="notHosted"?{}:{siteOwnOrchestrator:f}}):null,m.jsxs("aside",{className:"chat-panel",ref:$n,style:ay,children:[m.jsxs("header",{className:"chat-header",children:[m.jsxs("div",{className:"chat-header-top",children:[m.jsxs("div",{className:"chat-header-site-name",ref:Rn,children:[e.siteList.length>1?m.jsxs("button",{type:"button",className:`site-switcher-trigger${Zt?" is-open":""}`,onClick:()=>an(E=>!E),"aria-expanded":Zt,"aria-haspopup":"menu",children:[m.jsx("span",{className:`site-switcher-item-dot site-switcher-item-dot-${Ni!=null&&Ni.probing?"probing":Ni!=null&&Ni.online?"online":"offline"}`,"aria-hidden":"true"}),m.jsx("span",{className:"site-switcher-trigger-label",children:o.name}),m.jsx(Ol,{size:12,className:`site-switcher-chevron${Zt?" is-open":""}`,"aria-hidden":"true"})]}):m.jsx("span",{className:"site-switcher-trigger-label",children:o.name}),Zt&&m.jsxs("div",{className:"site-switcher-dropdown",role:"menu","aria-label":t("header.allSites"),children:[m.jsxs("div",{className:"site-switcher-header",children:[m.jsx("span",{children:t("header.allSites")}),m.jsxs("a",{href:"/sites",className:"site-switcher-add-link",onClick:()=>an(!1),children:["+ ",t("sites.addSite")]})]}),m.jsx("div",{className:"site-switcher-list",children:ys.map(E=>m.jsx(Mve,{name:E.site.name,origin:E.origin,statusClass:E.probing?"probing":"online",active:E.site.id===r,onSelect:()=>{E.site.id!==r&&e.openEditorForSite(E.site.id),an(!1)}},E.site.id))}),m.jsxs("div",{className:"site-switcher-actions",role:"group",children:[m.jsxs("button",{type:"button",role:"menuitem",className:"site-switcher-action",onClick:()=>{an(!1),e.setConfigSiteId(r)},children:[m.jsx(U9,{size:14,"aria-hidden":"true"}),m.jsx("span",{children:t("header.siteSettings")})]}),He.siteHasCmsContent!==!1&&m.jsxs("button",{type:"button",role:"menuitem",className:"site-switcher-action",title:t("header.syncFromSiteTitle"),disabled:ir,onClick:async()=>{an(!1);const E=await He.syncFromSite();E.ok&&E.count>0?He.pushAssistantFromResult({status:"applied",summary:E.count===1?t("header.syncedPage"):t("header.syncedPages",{count:E.count}),changes:[]}):E.ok||He.pushAssistantFromResult({status:"error",summary:E.reason==="network"?t("header.syncFailedNetwork"):t("header.syncFailedEmpty"),changes:[]})},children:[m.jsx(jS,{size:14,"aria-hidden":"true"}),m.jsx("span",{children:t("header.syncFromSite")})]})]}),m.jsxs("a",{href:"/sites",className:"site-switcher-footer",onClick:()=>an(!1),children:[t("header.viewAllSites"),m.jsx(Rg,{size:11,"aria-hidden":"true"})]})]})]}),m.jsxs("div",{className:"chat-header-right",children:[u.status==="degraded"?m.jsx("span",{className:"planner-badge",title:u.reason??"Components unavailable",children:t("header.limited")}):null,ql==="demo"?m.jsxs("div",{className:"no-key-anchor",children:[m.jsx("button",{type:"button",className:"planner-badge planner-badge-demo planner-badge-button","aria-expanded":ai,"aria-haspopup":"dialog",onClick:()=>ji(E=>!E),children:t("header.noKeyBadge")}),ai?m.jsx(YJ,{onClose:()=>ji(!1)}):null]}):null,In||nn.publishInProgress?m.jsxs("button",{type:"button",className:"publish-preview-btn",onClick:()=>ie(!0),disabled:ir||nn.isPublishing,title:rt.summary&&rt.summary.total>0?t("header.unpublishedTooltip",{count:String(rt.summary.total)}):void 0,children:[nn.publishInProgress?m.jsx("span",{className:"publish-spinner","aria-hidden":"true"}):null,nn.publishInProgress?t("header.publishing"):t("header.publish"),rt.summary&&rt.summary.total>0?m.jsx("span",{className:"publish-preview-badge","aria-hidden":"true",children:rt.summary.total}):null]}):null,nn.publishStatus?m.jsxs(m.Fragment,{children:[nn.publishStatus.inspectUrl?m.jsx("a",{className:"publish-view-link",href:nn.publishStatus.inspectUrl,target:"_blank",rel:"noreferrer",children:t("header.viewDeploy")}):null,Xu?m.jsx("a",{className:"live-site-icon-btn",href:Xu,target:"_blank",rel:"noreferrer","aria-label":t("header.openLiveSite"),title:t("header.openLiveSite"),children:m.jsx(Rg,{size:16,"aria-hidden":"true"})}):null]}):null]})]}),tr&&wr?m.jsxs("div",{className:"chat-header-lang-row",children:[m.jsx("label",{className:"chat-header-lang",children:m.jsx("select",{value:wr,"aria-label":t("header.language"),title:t("header.language"),onChange:E=>y(wve(g,E.target.value,tr)),disabled:v,children:tr.locales.map(E=>m.jsx("option",{value:E,children:E===_l?t("header.defaultLanguage"):Cve(E)},E))})}),Mp]}):null,m.jsxs("div",{className:"chat-header-slug-row",children:[m.jsx("label",{className:"chat-header-slug",children:m.jsx("select",{value:g,"aria-label":t("header.page"),onChange:E=>y(E.target.value||"/"),disabled:v,children:tr&&wr?m.jsxs(m.Fragment,{children:[Kr.map(E=>m.jsx("option",{value:E,children:Sve(E,wr)},E)),tr.shared.length>0?m.jsx("optgroup",{label:t("header.pagesWithoutLanguage"),children:tr.shared.map(E=>m.jsx("option",{value:E,children:wx(E)},E))}):null]}):fo.map(E=>m.jsx("option",{value:E,children:wx(E)},E))})}),tr&&wr?null:Mp]})]}),m.jsxs("div",{className:"chat-thread-region",children:[null,m.jsx(Gv,{fallbackLabel:"Chat unavailable — try refreshing",onReset:()=>window.location.reload(),children:m.jsx(NG,{ref:Ji,className:"chat-thread",streamStatusLabel:Cp,undoInFlightEntryId:He.undoInFlightEntryId,onSuggestionClick:E=>void He.submitChat(E),onUndo:E=>void He.applyUndoHistory(E),undoLabel:t("chat.undo"),undoneLabel:t("chat.undone"),appliedDraftLabel:t("chat.appliedDraft"),keepLabel:t("chat.keep"),revertLabel:t("chat.revert"),revertedLabel:t("chat.reverted"),keptLabel:t("chat.kept"),renderEntryExtras:E=>{var Z,me,Ne,Pe;return m.jsxs(m.Fragment,{children:[E.variations&&Array.isArray(E.variations.options)&&E.variations.options.length>0?m.jsx("div",{className:"msg-variations",children:E.variations.options.map((Te,Ge)=>m.jsxs("button",{type:"button",className:"msg-variation-card",disabled:ir,onClick:async()=>{const Nt=E.variations;try{(await fetch(`${$e}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,ops:[{op:"update_props",pageSlug:Nt.pageSlug,blockId:Nt.blockId,patch:Te.patch}]})})).ok&&(Yt.postToSite("draftUpdated",{focusBlockId:Nt.blockId}),Oe(),He.pushAssistantFromResult({status:"applied",summary:`Applied variation: ${Te.title}`,changes:[Te.summary]}))}catch{}},children:[m.jsx("div",{className:"msg-variation-preview-wrap",children:m.jsx(oN,{block:{id:E.variations.blockId,type:E.variations.blockType,props:{...E.variations.baseProps,...Te.patch}},virtualWidth:1280})}),m.jsxs("div",{className:"msg-variation-meta",children:[m.jsx("span",{className:"msg-variation-badge",children:String.fromCharCode(65+Ge)}),m.jsxs("div",{className:"msg-variation-content",children:[m.jsx("span",{className:"msg-variation-title",children:Te.title}),m.jsx("span",{className:"msg-variation-summary",children:Te.summary})]})]})]},Te.id??`${E.id}-v-${Ge}`))}):null,E.status==="plan_ready"&&E.pendingPlanId?m.jsxs("div",{className:"msg-plan-actions",children:[E.planPreview?m.jsx(vse,{preview:E.planPreview}):null,E.destructiveReasons&&E.destructiveReasons.length>0?m.jsx("div",{className:"msg-destructive-warning",role:"alert",children:E.destructiveReasons.map((Te,Ge)=>m.jsxs("div",{className:"msg-destructive-warning-line",children:["⚠ ",Te]},Ge))}):null,(()=>{var Qi;const Te=E.pendingPlanId,Ge=ir||Yu!==Te,Nt=!!(E.destructiveReasons&&E.destructiveReasons.length>0),ln=((Qi=E.planPreview)==null?void 0:Qi.diff.pages.filter(Oi=>Oi.status==="removed").length)??0,ar=ln===1?t("plan.deletePage"):ln>1?t("plan.deletePages",{count:ln}):t(Nt?"plan.applyDestructive":"plan.apply");return m.jsxs("div",{className:"msg-plan-btn-row",children:[m.jsx("button",{type:"button",className:`primary-btn msg-plan-btn${Nt?" is-destructive":""}`,onClick:()=>void He.approvePendingPlan(Te),disabled:Ge,children:ar}),m.jsx("button",{type:"button",className:"secondary-btn msg-plan-btn",onClick:()=>void He.stopPendingPlan(Te),disabled:Ge,children:t("plan.discard")})]})})()]}):null,E.imageSwap?(()=>{const Te=E.imageSwap,Ge=/^image$/i.test((Te.fieldLabel??"").trim()),Nt=Te.fieldLabel&&!(Te.blockDisplayName&&Ge),ln=Te.blockDisplayName??(Nt?Te.fieldLabel:null),ar=Te.blockDisplayName&&Nt?Te.fieldLabel:null;return m.jsxs("button",{type:"button",className:"msg-image-swap-card",onClick:()=>{Yn({slug:Te.slug,blockId:Te.blockId,editablePath:Te.editablePath,currentUrl:Te.imageUrl,blockType:R===Te.blockId?V:void 0})},title:t("ops.imageSwap.pickAnother"),children:[m.jsx("img",{src:Te.imageUrl,alt:Te.altText??""}),m.jsxs("div",{className:"msg-image-swap-meta",children:[ln?m.jsx("span",{className:"msg-image-swap-block",children:ln}):null,ar?m.jsx("span",{className:"msg-image-swap-field",children:ar}):null,m.jsx("span",{className:"msg-image-swap-action",children:t("ops.imageSwap.pickAnother")})]})]})})():null,E.continuation?m.jsx("div",{className:"msg-plan-actions",children:m.jsxs("button",{type:"button",className:"primary-btn msg-plan-btn",onClick:()=>void He.continueChain(E.continuation.chainId),disabled:ir||Lt!==E.continuation.chainId,children:["Continue: ",E.continuation.nextStepLabel," (",E.continuation.currentStep," of ",E.continuation.totalSteps,")"]})}):null,(()=>{if(E.wasUndone)return null;const Te=(E.mentionedSlugs??[]).filter(Ge=>Ge!==g);return Te.length===0?null:m.jsx("div",{className:"msg-suggestions msg-page-links",children:Te.map((Ge,Nt)=>m.jsxs("button",{type:"button",className:"msg-suggestion msg-page-link",onClick:()=>{y(Ge)},disabled:ir,children:["Open ",Ge]},`${E.id}-route-${Nt}`))})})(),(E.errors??[]).length>0?m.jsx("ul",{className:"msg-errors",children:(Z=E.errors)==null?void 0:Z.map((Te,Ge)=>m.jsx("li",{children:Te},Ge))}):null,Re&&E.role==="assistant"&&E.debug?m.jsxs("div",{className:"msg-debug-shell",children:[m.jsxs("details",{className:"msg-debug-details",children:[m.jsxs("summary",{className:"msg-debug-summary",children:[m.jsxs("span",{className:"msg-debug-summary-left",children:[m.jsx("span",{className:"msg-debug-title",children:"Debug"}),m.jsx("span",{className:"msg-debug-summary-text",children:Na(E)})]}),m.jsx("span",{className:"msg-debug-chevron","aria-hidden":"true"})]}),m.jsx("div",{className:"msg-debug",children:m.jsxs("ul",{children:[E.debug.traceId?m.jsxs("li",{children:["traceId: ",E.debug.traceId]}):null,E.debug.promptHash?m.jsxs("li",{children:["promptHash: ",E.debug.promptHash]}):null,E.debug.outcome?m.jsxs("li",{children:["outcome: ",E.debug.outcome]}):null,E.debug.reasonCategory?m.jsxs("li",{children:["reason: ",E.debug.reasonCategory]}):null,E.debug.reason&&E.debug.reason!==E.debug.reasonCategory?m.jsxs("li",{children:["reasonDetail: ",E.debug.reason]}):null,E.debug.intent?m.jsxs("li",{children:["intent: ",E.debug.intent]}):null,E.debug.plannerTier?m.jsxs("li",{children:["plannerTier: ",E.debug.plannerTier]}):null,E.debug.modelUsed?m.jsxs("li",{children:["model: ",E.debug.modelUsed,E.debug.plannerSource?` (${E.debug.plannerSource})`:""]}):null,typeof E.debug.planningAttempts=="number"&&E.debug.planningAttempts>1?m.jsxs("li",{children:["planningAttempts: ",E.debug.planningAttempts]}):null,typeof E.debug.opCount=="number"?m.jsxs("li",{children:["opCount: ",E.debug.opCount]}):null,Array.isArray(E.debug.skippedOps)&&E.debug.skippedOps.length>0?m.jsxs("li",{children:["skippedOps: ",E.debug.skippedOps.map(Te=>`[${Te.index}] ${Te.op} ${Te.pageSlug??""}${Te.blockId?"#"+Te.blockId:""}: ${Te.reason}`).join(", ")]}):typeof E.debug.skippedOpCount=="number"&&E.debug.skippedOpCount>0?m.jsxs("li",{children:["skippedOps: ",E.debug.skippedOpCount]}):null,Array.isArray(E.debug.opTypes)&&E.debug.opTypes.length>0?m.jsxs("li",{children:["ops: ",E.debug.opTypes.join(", ")]}):null,typeof E.debug.totalTokens=="number"?m.jsxs("li",{children:["tokens: in:",E.debug.inputTokens??"?"," out:",E.debug.outputTokens??"?"," total:",E.debug.totalTokens]}):null,typeof E.debug.estimatedUsd=="number"?m.jsxs("li",{children:["cost: $",E.debug.estimatedUsd.toFixed(4)]}):null,Array.isArray(E.debug.timeline)&&E.debug.timeline.length>0?m.jsxs("li",{children:["timeline: ",E.debug.timeline.map(Te=>`${Te.stage}:${Te.atMs}ms`).join(" -> ")]}):null,E.debug.promptExcerpt?m.jsxs("li",{children:["prompt: ",E.debug.promptExcerpt]}):null,E.debug.currentPage||E.debug.siteId||E.debug.activeBlockId||E.debug.activeEditablePath?m.jsxs("li",{children:["context: ",[E.debug.currentPage?`page: ${E.debug.currentPage}`:null,E.debug.siteId?`site: ${E.debug.siteId}`:null,E.debug.activeBlockId?`block: ${E.debug.activeBlockId}`:null,E.debug.activeEditablePath?`path: ${E.debug.activeEditablePath}`:null].filter(Boolean).join(", ")]}):null]})})]}),m.jsx("button",{type:"button",className:"msg-debug-copy-btn",onClick:()=>void Np(E),"aria-label":Rt===E.id?t("chat.copied"):t("chat.copyDebug"),title:Rt===E.id?t("chat.copied"):t("chat.copy"),children:Rt===E.id?m.jsx(Xh,{"aria-hidden":"true",size:14}):m.jsx(YD,{"aria-hidden":"true",size:14})})]}):null,E.role==="assistant"&&((me=E.debug)!=null&&me.traceId)&&E.id!=="welcome"?m.jsxs("div",{className:"msg-feedback-row",children:[m.jsx("button",{type:"button",className:`msg-feedback-btn ${((Ne=E.feedback)==null?void 0:Ne.rating)==="up"?"msg-feedback-btn--active":""}`,onClick:()=>{E.feedback||He.submitFeedback(E.id,"up")},disabled:!!E.feedback,title:t("chat.goodResponse"),children:m.jsx(e$,{"aria-hidden":"true",size:13})}),m.jsx("button",{type:"button",className:`msg-feedback-btn ${((Pe=E.feedback)==null?void 0:Pe.rating)==="down"?"msg-feedback-btn--active":""}`,onClick:()=>{E.feedback||(de(En===E.id?null:E.id),ze(""))},disabled:!!E.feedback,title:t("chat.badResponse"),children:m.jsx(X9,{"aria-hidden":"true",size:13})}),E.feedback?m.jsxs("span",{className:"msg-feedback-label",children:[E.feedback.rating==="up"?t("chat.feedbackThanks"):t("chat.feedbackNoted"),E.feedback.note?` — "${E.feedback.note}"`:""]}):null,En===E.id&&!E.feedback?m.jsxs("form",{className:"msg-feedback-note-form",onSubmit:Te=>{Te.preventDefault(),He.submitFeedback(E.id,"down",be||void 0),de(null),ze("")},children:[m.jsx("input",{className:"msg-feedback-note-input",placeholder:t("chat.feedbackPlaceholder"),value:be,onChange:Te=>ze(Te.target.value),autoFocus:!0}),m.jsx("button",{type:"submit",className:"msg-feedback-note-submit",children:t("chat.feedbackSend")})]}):null]}):null]})},renderStreamingExtras:()=>m.jsxs(m.Fragment,{children:[Qu?m.jsx("span",{className:"stream-reconnect-badge stream-reconnect-badge-inline",title:Or??void 0,children:Qu}):null,Re&&li?m.jsx("div",{className:"streaming-debug-inline",children:Tp}):null]}),renderStreamStatusFallback:()=>m.jsxs("div",{className:`streaming-pill ${$d?"is-error":"is-active"} ${FD==="text"?"is-text":"is-legacy"}`,children:[FD==="text"?m.jsx("span",{className:"streaming-pill-status streaming-pill-status-text",children:Cp}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"streaming-pill-title",children:m.jsx("span",{className:"streaming-pill-sparkle",children:"✦"})}),m.jsx("span",{className:"streaming-pill-status",children:oy}),$d?null:m.jsxs("span",{className:"streaming-dots","aria-hidden":"true",children:[m.jsx("i",{}),m.jsx("i",{}),m.jsx("i",{})]})]}),Qu?m.jsx("span",{className:"stream-reconnect-badge",title:Or??void 0,children:Qu}):null,gr?m.jsx("div",{className:"image-gen-progress",children:m.jsx("div",{className:"image-gen-progress-fill",style:{width:`${gr.percent}%`}})}):null,Ri?m.jsx("button",{type:"button",className:"streaming-jump-btn",onClick:()=>Yt.postToSite("highlightBlock",{blockId:Ri,editablePath:null,scrollIntoView:!0}),children:"Jump to latest change"}):null,Re&&li?m.jsx("div",{className:"streaming-debug-inline",children:Tp}):null]})})})]}),m.jsx("div",{ref:jn,className:"composer-splitter",role:"separator","aria-orientation":"horizontal","aria-label":t("resize.inputPanel"),onPointerDown:E=>{yi.current={y:E.clientY,composerHeight:Je},document.body.style.userSelect="none"}}),m.jsx(MG,{className:"composer",message:D,isLoading:ir,hasUserEntry:Ud,onMessageChange:I,onSubmit:E=>{I(""),He.submitChat(E,D)},onTranscribeAudio:sr.transcribeAudio,onUploadAttachment:sr.uploadAttachment,attachments:ks,onAttachmentsChange:Ss,onCancel:He.cancelChat,onAutoHeightChange:Bd,selectionModeEnabled:Le,onToggleSelectionMode:()=>Uo(),canUndoServer:He.canUndoServer,canRedoServer:He.canRedoServer,onGlobalUndo:()=>void He.applyGlobalUndo(),onGlobalRedo:()=>void He.applyGlobalRedo(),undoTooltip:t("chat.undoTooltip"),redoTooltip:t("chat.redoTooltip"),contextChip:R&&V?{label:t("chatInput.editingBlock",{block:((Dp=pu()[V])==null?void 0:Dp.displayName)??V}),clearLabel:t("chatInput.clearSelection"),onClear:()=>{W(void 0),U(void 0)}}:null})]}),m.jsx("div",{className:"panel-splitter",role:"separator","aria-orientation":"vertical","aria-label":t("resize.chatPanel"),onPointerDown:E=>{const Z=$n.current;Z&&(Xn.current={x:E.clientX,width:Z.offsetWidth,target:"chat"},document.body.style.userSelect="none",document.body.classList.add("panel-resizing"))}}),m.jsx("div",{className:"preview",children:m.jsxs("div",{className:"preview-canvas",ref:Xi,children:[ty?null:m.jsx("div",{className:"preview-loading",role:"status","aria-label":t("preview.loading"),children:m.jsx("span",{className:"preview-loading-spinner","aria-hidden":"true"})}),m.jsx("iframe",{ref:Yt.iframeRef,title:t("preview.title"),src:zd,style:{colorScheme:"light dark"},onLoad:()=>{mp(!0),$g&&!pr.current&&(pr.current=!0,$o.current=a),Yt.postToSite("setNestedLabelsVisibility",{visible:ne})}})]})}),Ws?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"panel-splitter panel-splitter--props",role:"separator","aria-orientation":"vertical","aria-label":t("resize.chatPanel"),onPointerDown:E=>{const Z=tn.current;Z&&(Xn.current={x:E.clientX,width:Z.offsetWidth,target:"props"},document.body.style.userSelect="none",document.body.classList.add("panel-resizing"))}}),m.jsx("aside",{className:"props-panel",ref:tn,children:m.jsx(Gv,{fallbackLabel:"Properties panel unavailable — try refreshing",children:m.jsx(Qxe,{props:xt.props,status:xt.status,failure:xt.failure,failedSlug:xt.failedSlug,failedOrigin:xt.failedOrigin,onRetry:xt.retry,pageName:wx(g),onDeselectBlock:()=>{W(void 0),U(void 0)},onClose:Fd,navLabel:((Rp=e.headerConfig.navLabels)==null?void 0:Rp[g])??"",onNavLabelChange:(E,Z)=>{e.updateHeaderConfig({navLabels:{[E]:Z}}),Yt.postToSite("draftUpdated",{}),Oe()},pageMeta:or.meta,onPageMetaChange:(E,Z)=>{const me={...or.meta,[E]:Z};or.setMeta(me),(async()=>{try{const Ne=await fetch(`${$e}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({session:n,siteId:r,ops:[{op:"update_page_meta",pageSlug:g,patch:{[E]:Z}}]})}),Pe=await Ne.json();if(!Ne.ok||Pe.status!=="applied"){or.refetch();return}Yt.postToSite("draftUpdated",{}),Oe()}catch{or.refetch()}})()},onFieldChange:async(E,Z)=>{await He.inlineEditCommit(g,R,E,Z,{silent:!0}),xt.refetch()},onImageClick:(E,Z)=>{R&&Yn({slug:g,blockId:R,editablePath:E,currentUrl:Z,blockType:V})},onAiAssist:xp,onPageAiAssist:ry,onAiQuickAction:iy,onPageAiQuickAction:sy,onAddListItem:R&&V?E=>{He.addListItem(g,R,V,E).then(()=>xt.refetch())}:void 0,onRemoveListItem:R&&V?(E,Z)=>{He.removeListItem(g,R,V,E,Z).then(()=>xt.refetch())}:void 0,manifestByType:u.byType,siteOrigin:a})})})]}):null,ec?m.jsx("div",{className:"history-drawer-backdrop",onClick:()=>Ve("chat"),children:m.jsx("aside",{className:"history-drawer",role:"dialog","aria-label":t("health.title"),onClick:E=>E.stopPropagation(),children:m.jsx(Gv,{children:m.jsx(FG,{findings:Ot.findings,isLoading:Ot.isLoading,isRunning:Ot.isRunning,error:Ot.error,durable:Ot.durable,onRun:()=>void Ot.run(),onDismiss:E=>void Ot.setStatus(E,"dismissed"),onSnooze:E=>void Ot.setStatus(E,"snoozed"),onGoTo:mo,onClose:()=>Ve("chat")})})})}):null,Zs?m.jsx("div",{className:"history-drawer-backdrop",onClick:()=>Ve("chat"),children:m.jsx("aside",{className:"history-drawer",role:"dialog","aria-label":t("history.title"),onClick:E=>E.stopPropagation(),children:m.jsx(jG,{session:n,siteId:r,slug:g,visible:Zs,onRestore:lt,isRestoring:_t,onDiscarded:ui,onClose:()=>Ve("chat")})})}):null,Aa&&ye?m.jsx("div",{ref:oi,className:"composer--anchored is-expanded",style:{top:Aa.top,left:Aa.left,width:Aa.width},children:m.jsx(uR,{message:D,isLoading:ir,hasUserEntry:Ud,onMessageChange:I,onSubmit:E=>{I(""),He.submitChat(E,D)},onTranscribeAudio:sr.transcribeAudio,onUploadAttachment:sr.uploadAttachment,attachments:ks,onAttachmentsChange:Ss,onCancel:He.cancelChat,onAutoHeightChange:()=>{},compact:!0})}):null,at?(()=>{const E=at,Z=E.options.find(me=>me.id===et)??null;return m.jsx("div",{className:"variation-modal-backdrop",onClick:()=>{St||_e(null)},children:m.jsxs("div",{className:"variation-modal",role:"dialog","aria-modal":"true","aria-label":t("variation.title"),onClick:me=>me.stopPropagation(),children:[m.jsxs("div",{className:"variation-modal-header",children:[m.jsx("h2",{children:"Choose a Variation"}),m.jsx("button",{type:"button",className:"settings-close-btn","aria-label":t("variation.close"),onClick:()=>_e(null),disabled:St,children:"×"})]}),m.jsx("div",{className:"variation-modal-body",children:E.options.map((me,Ne)=>m.jsxs("article",{className:`variation-card${me.id===et?" is-selected":""}`,onClick:()=>tt(me.id),children:[m.jsxs("div",{className:"variation-card-preview-wrap",children:[m.jsx("span",{className:"variation-card-badge",children:String.fromCharCode(65+Ne)}),m.jsx(oN,{virtualWidth:w$.desktop,block:{id:E.blockId,type:E.blockType,props:j$(E.baseProps,me.patch)}}),me.imagePending?m.jsxs("div",{className:"variation-card-image-pending","aria-live":"polite",children:[m.jsx("span",{className:"variation-card-image-pending-spinner","aria-hidden":"true"}),m.jsx("span",{className:"variation-card-image-pending-label",children:"Generating image…"})]}):null]}),m.jsx("h3",{className:"variation-card-title",children:me.title}),m.jsx("p",{className:"variation-card-summary",children:me.summary})]},me.id))}),m.jsx("div",{className:"variation-modal-footer",children:m.jsx("button",{type:"button",className:"publish-preview-btn variation-apply-btn",onClick:()=>{Z&&He.applyVariation(Z)},disabled:St||!Z,children:St?t("variation.applying"):t("variation.apply",{title:(Z==null?void 0:Z.title)??""})})})]})})})():null,gt?m.jsx("div",{className:"add-block-modal-backdrop",onClick:()=>{Dn||Qe(null)},children:m.jsxs("div",{className:"add-block-modal",role:"dialog","aria-modal":"true","aria-label":t("addBlock.title"),onClick:E=>E.stopPropagation(),children:[m.jsxs("div",{className:"add-block-modal-header",children:[m.jsx("h2",{children:"Add block"}),m.jsx("p",{children:gt.beforeBlockId&&!gt.afterBlockId?t("addBlock.insertAbove"):t("addBlock.insertBelow")}),m.jsx("button",{type:"button",className:"settings-close-btn","aria-label":t("addBlock.close"),onClick:()=>Qe(null),disabled:Dn,children:"×"})]}),m.jsxs("div",{className:"add-block-modal-body",children:[m.jsx("label",{className:"add-block-search",children:m.jsx("input",{type:"search",value:ot,onChange:E=>mn(E.target.value),placeholder:t("addBlock.searchPlaceholder"),disabled:Dn})}),Ea.length===0?m.jsx("p",{className:"add-block-empty",children:"No block types match your search."}):m.jsx("div",{className:"add-block-flat-list",children:Ea.flatMap(E=>E.options).map(E=>m.jsxs("button",{type:"button",className:"add-block-option",disabled:Dn,onClick:async()=>{var Ne;if(!gt||Dn)return;Bn(!0);const Z=(Ne=u.byType.get(E.type))==null?void 0:Ne.defaultProps,me=await He.addBlockAfter(gt.slug,gt.afterBlockId,E.type,gt.beforeBlockId,Z);Bn(!1),me&&Qe(null)},children:[m.jsx("span",{className:"add-block-option-label",children:E.label}),m.jsx("span",{className:"add-block-option-actions","aria-hidden":"true",children:m.jsx("span",{className:"add-block-option-plus",children:"+"})})]},E.type))})]})]})}):null,m.jsx(MJ,{open:ce,onOpenChange:ee,useStreaming:H,onStreamingChange:O,showNestedLabels:ne,onNestedLabelsChange:P,chatDarkMode:i,onDarkModeChange:s,showDebugDetails:Re,onDebugDetailsChange:Ce,fieldDraftDebugEnabled:li,onFieldDraftDebugChange:Ii,autoScrollTrackingEnabled:$,onAutoScrollTrackingChange:Y,provider:T,modelKey:S,availableProviders:M,onModelChange:(E,Z)=>{A(E),w(Z)},onClearChat:He.clearChat,agentModeEnabled:gn.agentMode??!1,showDevOptions:oe,onShowDevOptionsChange:Q?z:void 0}),m.jsx(ZJ,{open:se,onOpenChange:ie,onConfirm:E=>void nn.publishSite(E),chatLog:Wr,isPublishing:nn.isPublishing,session:n,siteId:r,siteOrigin:a}),m.jsx(eO,{sites:e,onPreviewRefresh:()=>{Yt.postToSite("draftUpdated",{}),Oe()}}),m.jsx(kue,{open:Jn,features:{...gn,googleDrive:gn.googleDrive||!!((Vd=o.gdriveFolderId)!=null&&Vd.trim())},currentUrl:Ct==null?void 0:Ct.currentUrl,gdriveFolderId:o.gdriveFolderId,cmsMedia:o.cmsMedia,siteOrigin:a,onClose:()=>Yn(null),onSelect:(E,Z)=>{var jp;if(!Ct)return;const{slug:me,blockId:Ne,editablePath:Pe,currentUrl:Te,blockType:Ge}=Ct,Nt=JJ(Pe),ln=Pe.match(/^([a-zA-Z_]+)\[(\d+)\]\.(.+)$/),ar=Nt!==Pe?Nt.match(/^([a-zA-Z_]+)\[(\d+)\]\.(.+)$/):null;let Qi,Oi;if(ln){const[,es,Cr,Ma]=ln,Kd={[Ma]:E};ar&&(Kd[ar[3]]=Z),Qi=[{op:"update_item",pageSlug:me,blockId:Ne,listKey:es,index:Number(Cr),patch:Kd}],Oi=`${es}[${Cr}].${Ma}`}else{const es={[Pe]:E};Nt!==Pe&&(es[Nt]=Z),Qi=[{op:"update_props",pageSlug:me,blockId:Ne,patch:es}],Oi=Pe}const qd=Ge??(Ne===R?V:void 0)??(Ne===R&&xt.blockType?xt.blockType:void 0),ly=qd?((jp=pu()[qd])==null?void 0:jp.displayName)??qd:void 0,Gd={imageUrl:E,previousUrl:Te,altText:Z,slug:me,blockId:Ne,editablePath:Pe,blockDisplayName:ly,fieldLabel:Ive(Oi)};(async()=>{try{const es=await fetch(`${$e}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(js({session:n,siteId:r,ops:Qi},u.manifest))}),Cr=await es.json();es.ok&&Cr.status==="applied"?(Yt.postToSite("draftUpdated",{focusBlockId:Ne}),Oe(),He.pushAssistantFromResult({status:"applied",summary:t("ops.changedImage")},{canUndo:!0,imageSwap:Gd}),xt.refetch()):(console.error("[ImagePicker] ops failed:",es.status,Cr.error,Cr.details??"","ops:",JSON.stringify(Qi)),He.pushAssistantFromResult({status:"error",summary:t("ops.imageChangeFailed")},{imageSwap:{...Gd,imageUrl:Te??E}}))}catch(es){console.error("[ImagePicker] ops failed:",es),He.pushAssistantFromResult({status:"error",summary:t("ops.imageChangeFailed")},{imageSwap:{...Gd,imageUrl:Te??E}})}})()}}),null]})}const xg=$e,Kv={position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#0a0a0a",fontFamily:"system-ui, sans-serif",zIndex:99999},Wv={display:"flex",flexDirection:"column",gap:12,width:320,padding:32,borderRadius:12,background:"#18181b",border:"1px solid #27272a"},Zv={padding:"10px 16px",borderRadius:8,border:"none",background:"#3b82f6",color:"#fff",fontSize:14,fontWeight:500,cursor:"pointer"};function Pve({children:e}){const{t}=_n(),[n,r]=_.useState("checking"),[i,s]=_.useState(""),[o,a]=_.useState(!1),[u,d]=_.useState(""),[f,p]=_.useState(!1),[g,y]=_.useState(0),v=Math.min(15e3,1500*2**Math.max(0,g-1));_.useEffect(()=>{let w=!0;return r("checking"),fetch(`${xg}/auth/status`).then(T=>{if(!T.ok)throw new Error(`auth/status ${T.status}`);return T.json()}).then(T=>{if(w){if(T.mode==="closed"){Xm(),d(typeof T.reason=="string"?T.reason:""),r("closed");return}if(!T.gateEnabled)Xm(),r("open");else{const A=!!localStorage.getItem(Vk),M=Lw().length>0;r(A&&M?"open":"locked")}}}).catch(()=>{w&&r("unreachable")}),()=>{w=!1}},[g]),_.useEffect(()=>{if(n!=="unreachable")return;const w=setTimeout(()=>y(T=>T+1),v);return()=>clearTimeout(w)},[n,g,v]);const S=async w=>{w.preventDefault(),p(!0),a(!1);try{const T=await fetch(`${xg}/auth/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:i.trim()})}),A=await T.json().catch(()=>({}));T.ok?(localStorage.setItem(Vk,"1"),xoe(A.accessToken??""),r("open")):(Xm(),a(!0))}catch{Xm(),a(!0)}p(!1)};return n==="checking"?null:n==="open"?m.jsx(m.Fragment,{children:e}):n==="closed"?m.jsx("div",{style:Kv,children:m.jsxs("div",{style:{...Wv,width:420},children:[m.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.closedTitle")}),m.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:u||t("password.closedBody")}),m.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:t("password.closedFix")}),m.jsxs("code",{style:{color:"#71717a",fontSize:12,wordBreak:"break-all"},children:[xg,"/auth/status"]}),m.jsx("button",{type:"button",onClick:()=>y(w=>w+1),style:Zv,children:t("password.retry")})]})}):n==="unreachable"?m.jsx("div",{style:Kv,children:m.jsxs("div",{style:{...Wv,width:380},children:[m.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.unreachableTitle")}),m.jsx("p",{style:{margin:0,color:"#a1a1aa",fontSize:13,lineHeight:1.5},children:t("password.unreachableBody")}),m.jsxs("code",{style:{color:"#71717a",fontSize:12,wordBreak:"break-all"},children:[xg,"/auth/status"]}),m.jsx("button",{type:"button",onClick:()=>y(w=>w+1),style:Zv,children:t("password.retry")}),m.jsx("p",{style:{margin:0,color:"#71717a",fontSize:12},"aria-live":"polite",children:t("password.retryingIn",{seconds:String(Math.round(v/1e3))})})]})}):m.jsx("div",{style:Kv,children:m.jsxs("form",{onSubmit:S,style:Wv,children:[m.jsx("h2",{style:{margin:0,color:"#fafafa",fontSize:18},children:t("password.title")}),m.jsx("input",{type:"password",value:i,onChange:w=>s(w.target.value),placeholder:t("password.placeholder"),autoFocus:!0,style:{padding:"10px 12px",borderRadius:8,border:o?"1px solid #ef4444":"1px solid #3f3f46",background:"#09090b",color:"#fafafa",fontSize:14,outline:"none"}}),o&&m.jsx("span",{style:{color:"#ef4444",fontSize:13},children:t("password.incorrect")}),m.jsx("button",{type:"submit",disabled:f||!i.trim(),style:{...Zv,opacity:f||!i.trim()?.5:1},children:t(f?"password.checking":"password.continue")})]})})}Soe();sB.createRoot(document.getElementById("root")).render(m.jsx(_.StrictMode,{children:m.jsxs(f$,{children:[m.jsx(Pve,{children:m.jsx(Rve,{})}),m.jsx(mB,{})]})}));export{$ve as $,BZ as A,Uve as B,$Z as C,rw as D,pu as E,iw as F,O9 as G,Bve as H,np as I,Uue as J,MG as K,kue as L,$e as M,_h as N,Ej as O,hn as P,wx as Q,LZ as R,Yse as S,Ed as T,i$ as U,jG as V,yk as W,A$ as X,T$ as Y,Mj as Z,yB as _,Yc as a,bk as a0,fe as a1,Lue as a2,$ue as a3,ga as a4,kl as a5,Ku as a6,Zn as a7,jr as a8,wt as a9,O5 as aA,jb as aB,qce as aC,Gce as aD,Zce as aE,B5 as aF,ade as aG,z5 as aH,hs as aI,j5 as aJ,P5 as aK,Qce as aL,nde as aM,tde as aN,eM as aO,cde as aP,ba as aQ,Ue as aR,rde as aS,ide as aT,Hr as aU,qr as aV,It as aa,ft as ab,Fge as ac,nD as ad,I2 as ae,yz as af,v4 as ag,Hme as ah,$me as ai,Pj as aj,e2 as ak,Ul as al,Jw as am,T5 as an,Kc as ao,SP as ap,ehe as aq,no as ar,Ae as as,Id as at,L5 as au,n2 as av,Yce as aw,Kce as ax,Wce as ay,D5 as az,Vn as b,it as c,Qt as d,db as e,sw as f,P4 as g,Xj as h,ow as i,m as j,ip as k,ad as l,Hj as m,FZ as n,Sn as o,wd as p,m$ as q,_ as r,iR as s,b$ as t,Fg as u,Td as v,h$ as w,_re as x,GI as y,qI as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,f as d,S as p,H as c,i as f}from"./PuckPrototypeRoute-
|
|
1
|
+
import{d as a,f as d,S as p,H as c,i as f}from"./PuckPrototypeRoute-b-3hrBRO.js";import{a as g}from"./index-DK3g9FRS.js";import{j as h}from"./index-De_49C4P.js";import"./index-Bi9Ztgaj.js";f();function x(){const{options:s}=a(),l=d(s),{editor:r}=a(),i=g({editor:r,selector:t=>{var e,n;if((e=t.editor)!=null&&e.isActive("paragraph"))return"p";for(let o=1;o<=6;o++)if((n=t.editor)!=null&&n.isActive("heading",{level:o}))return`h${o}`;return"p"}}),u=t=>{const e=r==null?void 0:r.chain();if(t==="p")e==null||e.focus().setParagraph().run();else{const n=parseInt(t.replace("h",""),10);e==null||e.focus().toggleHeading({level:n}).run()}};return h.jsx(p,{options:l,onChange:u,value:i??"p",defaultValue:"p",renderDefaultIcon:c})}export{x as HeadingSelectLoaded};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as r,h as a,S as d,j as c,i as p}from"./PuckPrototypeRoute-
|
|
1
|
+
import{d as r,h as a,S as d,j as c,i as p}from"./PuckPrototypeRoute-b-3hrBRO.js";import{a as f}from"./index-DK3g9FRS.js";import{j as m}from"./index-De_49C4P.js";import"./index-Bi9Ztgaj.js";p();function C(){const{options:s}=r(),l=a(s),{editor:e}=r(),i=f({editor:e,selector:o=>{var t,n;return(t=o.editor)!=null&&t.isActive("bulletList")?"ul":(n=o.editor)!=null&&n.isActive("orderedList")?"ol":"p"}}),u=o=>{const t=e==null?void 0:e.chain();o==="p"?t==null||t.focus().setParagraph().run():o==="ol"?t==null||t.focus().toggleOrderedList().run():o==="ul"&&(t==null||t.focus().toggleBulletList().run())};return m.jsx(d,{options:l,onChange:u,value:i??"p",defaultValue:"p",renderDefaultIcon:c})}export{C as ListSelectLoaded};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as u,e as f,S as g,A,i as v}from"./PuckPrototypeRoute-
|
|
1
|
+
import{d as u,e as f,S as g,A,i as v}from"./PuckPrototypeRoute-b-3hrBRO.js";import{a as p}from"./index-DK3g9FRS.js";import{j as m}from"./index-De_49C4P.js";import"./index-Bi9Ztgaj.js";v();function C(){var l;const{options:n}=u(),a=f(n),{editor:i}=u(),c=(l=p({editor:i,selector:t=>{var e,o,r,s;return(e=t.editor)!=null&&e.isActive({textAlign:"center"})?"center":(o=t.editor)!=null&&o.isActive({textAlign:"right"})?"right":(r=t.editor)!=null&&r.isActive({textAlign:"justify"})?"justify":n!=null&&n.textAlign&&(s=n.textAlign.defaultAlignment)!=null?s:"left"}}))!=null?l:"left",d=t=>{const e=i==null?void 0:i.chain();e==null||e.focus().setTextAlign(t).run()};return m.jsx(g,{options:a,onChange:d,value:c,defaultValue:"left",renderDefaultIcon:A})}export{C as AlignSelectLoaded};
|
package/editor-dist/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>Avocado Studio</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-De_49C4P.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CXnWvIPx.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avocadostudio-ai/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Self-host launcher for the Avocado Studio editor UI",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"esbuild": "^0.24.0",
|
|
40
40
|
"tsx": "^4.19.0",
|
|
41
41
|
"typescript": "^5.7.3",
|
|
42
|
-
"@avocadostudio-ai/shared": "0.11.
|
|
42
|
+
"@avocadostudio-ai/shared": "0.11.1"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node22 --format=esm --outfile=dist/index.js --banner:js='#!/usr/bin/env node'",
|