@creaditor/web-starterkit 1.0.71 → 1.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/creaditor.bundle.js
CHANGED
|
@@ -3409,7 +3409,7 @@
|
|
|
3409
3409
|
color: var(--color-primary, #5b57e0);
|
|
3410
3410
|
opacity: 1;
|
|
3411
3411
|
}
|
|
3412
|
-
`,customElements.define("cdtr-sidebar-menu",X);var Z=a(58423),Q=a(13548);
|
|
3412
|
+
`,customElements.define("cdtr-sidebar-menu",X);var Z=a(58423),Q=a(13548);const K="aiDoc",J="aiDocParked";function $(){const t=I.M.get("components");if(!t||"object"!=typeof t)return null;const e=I.M.get("app"),n=e&&"string"==typeof e.rootComponent?e.rootComponent:null,r=n?t[n]:null;return r&&"root"===r.type?r:Object.values(t).find(t=>t&&"root"===t.type)||null}const tt=new WeakSet;function et(){try{const t=$(),e=t&&t.props?t.props[K]:null;if(!e)return null;const n="string"==typeof e?JSON.parse(e):e;if(!n||"string"!=typeof n.html||!n.html)return null;const r={html:n.html,edits:Array.isArray(n.edits)?n.edits:[],origin:"generated"===n.origin?"generated":"imported"};return tt.add(r),r}catch(t){return console.debug("[ai-editor] unreadable aiDoc on root, opening in component mode",t),null}}function nt(){return null!==et()}let rt=null,ot=null,it=null,at=!1;function st(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:K;L.Ay.store().updateComponent(t,n,e)}function lt(){it&&(clearTimeout(it),it=null);const t=rt,e=ot;if(rt=null,ot=null,t)try{const n=$();if(!n||!n.id)return;if(e&&e!==n.id)return void console.debug("[ai-editor] dropped a pending aiDoc write: the document was replaced");st(n.id,t)}catch(t){console.debug("[ai-editor] failed to persist aiDoc to root",t)}}function ct(){rt=null,ot=null,it&&(clearTimeout(it),it=null)}function dt(t){try{const e="string"==typeof t?JSON.parse(t):t;return e&&"string"==typeof e.html&&e.html?{html:e.html,edits:Array.isArray(e.edits)?e.edits:[],origin:"generated"===e.origin?"generated":"imported"}:null}catch(t){return null}}function pt(t){if(!t||"string"!=typeof t.html||!t.html)return;if(tt.has(t))return void tt.delete(t);rt={html:t.html,edits:Array.isArray(t.edits)?t.edits:[],origin:"generated"===t.origin?"generated":"imported"};const e=$();if(ot=e&&e.id||null,it&&clearTimeout(it),it=setTimeout(lt,300),!at&&"undefined"!=typeof window){at=!0;const t=()=>{"hidden"===document.visibilityState&<()};document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",lt),window.addEventListener("beforeunload",lt)}}async function ht(t,e){let{snackbarTextKey:n}=e;const r=JSON.parse(JSON.stringify(t));ct(),I.M.get("editKey")&&await(0,Q.WX)(r);const o=()=>{Z.A.unSubscribe("editor-content-replaced",o);const t=I.M.get("commands"),e=I.M.get("config","editor","props","onSave");t?.toJSON&&"function"==typeof e&&e({transactions:[],toJson:t.toJSON,toJSON:t.toJSON,toHTML:t.toHTML||(()=>Promise.resolve(""))}),Z.A.dispatch("snackbar",{text:I.M.get("lang",n)})};Z.A.subscribe("editor-content-replaced",o),I.M.get("setEditorContent")(r)}const ut=S.AH`
|
|
3413
3413
|
*{
|
|
3414
3414
|
box-sizing: border-box;
|
|
3415
3415
|
}
|
|
@@ -3670,7 +3670,7 @@
|
|
|
3670
3670
|
min-width: 320px;
|
|
3671
3671
|
max-width: 90vw;
|
|
3672
3672
|
}
|
|
3673
|
-
`;class
|
|
3673
|
+
`;class ft extends S.WF{constructor(){super(),this._storeConnectCallback=null,this._copyFeedbackTimeout=null,this.transferDataPanelOpen=!1,this.panelView="options",this.accessCodeInput="",this.generatedCode="",this.copyFeedback="",this.generateLoading=!1,this.submitLoading=!1,this.submitError="",this.expiresAt="",this.expirationEnabled=!1,this.showSubmitConfirmModal=!1,this.pendingAccessCodeValue="",this.pastedJson="",this.pendingPastedList=null,this.confirmSource="code"}_getErrorMessage(t,e){const n=t;return n?.response?.data?.message??n?.message??I.M.get("lang",e)}_getMinDatetimeLocal(){const t=new Date;return t.setMinutes(t.getMinutes()-t.getTimezoneOffset()),t.toISOString().slice(0,16)}_setExpirationPreset(t){const e=new Date;e.setHours(e.getHours()+t),e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),this.expiresAt=e.toISOString().slice(0,16)}_isPresetActive(t){if(!this.expiresAt)return!1;const e=new Date(this.expiresAt),n=new Date;return n.setHours(n.getHours()+t),Math.abs(e.getTime()-n.getTime())<12e4}connectedCallback(){super.connectedCallback(),this._storeConnectCallback=t=>{const e=t;this.transferDataPanelOpen=e.sidebarTransferDataPanelOpen,this.transferDataPanelOpen&&(this.panelView="options")},I.M.connect("sidebarTransferDataPanelOpen",this._storeConnectCallback),this.transferDataPanelOpen=I.M.get("sidebarTransferDataPanelOpen"),this.transferDataPanelOpen&&(this.panelView="options")}disconnectedCallback(){super.disconnectedCallback(),this._storeConnectCallback&&I.M.disconnect(this._storeConnectCallback),this._copyFeedbackTimeout&&clearTimeout(this._copyFeedbackTimeout)}_onSubmitAccessCode(t){t.preventDefault();const e=t.target,n=e?.querySelector("#access-code-input"),r=((n?.value??this.accessCodeInput)||"").trim();r&&!this.submitLoading?(this.pendingAccessCodeValue=r,this.confirmSource="code",this.showSubmitConfirmModal=!0):Z.A.dispatch("snackbar",{text:I.M.get("lang","transferData_enter_valid_code")})}_onSubmitPastedJson(t){if(t.preventDefault(),this.submitLoading)return;const e=t.target,n=e?.querySelector("#paste-json-input"),r=((n?.value??this.pastedJson)||"").trim();if(!r)return void(this.submitError=I.M.get("lang","transferData_enter_valid_json"));let o;try{o=JSON.parse(r)}catch{return void(this.submitError=I.M.get("lang","transferData_invalid_json"))}Array.isArray(o)&&0!==o.length?(this.submitError="",this.pendingPastedList=o,this.confirmSource="paste",this.showSubmitConfirmModal=!0):this.submitError=I.M.get("lang","transferData_invalid_template_data")}_cancelSubmitConfirm(){this.showSubmitConfirmModal=!1,this.pendingAccessCodeValue="",this.pendingPastedList=null}_confirmSubmit(){"paste"===this.confirmSource?this._confirmAndLoadPastedJson():this._confirmAndSubmitAccessCode()}async _confirmAndLoadPastedJson(){const t=this.pendingPastedList;if(this.showSubmitConfirmModal=!1,this.pendingPastedList=null,Array.isArray(t)&&0!==t.length){this.submitError="",this.submitLoading=!0;try{await this._loadListIntoEditor(t)&&(this.pastedJson="")}finally{this.submitLoading=!1}}}async _confirmAndSubmitAccessCode(){const t=this.pendingAccessCodeValue?.trim()||"";if(this.showSubmitConfirmModal=!1,this.pendingAccessCodeValue="",t){this.accessCodeInput=t,this.submitError="",this.submitLoading=!0;try{await this._doSubmitAccessCode(t)}finally{this.submitLoading=!1,this.accessCodeInput=""}}}async _doSubmitAccessCode(t){try{const e=(await(0,Q.sU)(t)||{}).data,n=e?.data,r=n?.data;if("string"!=typeof r)return void Z.A.dispatch("snackbar",{text:I.M.get("lang","transferData_no_template_data")});const o=JSON.parse(r);if(!Array.isArray(o)||0===o.length)return void Z.A.dispatch("snackbar",{text:I.M.get("lang","transferData_invalid_template_data")});await this._loadListIntoEditor(o)}catch(t){const e=this._getErrorMessage(t,"transferData_failed_submit_code");this.submitError=e,Z.A.dispatch("snackbar",{text:e})}}async _loadListIntoEditor(t){try{return await ht(t,{snackbarTextKey:"transferData_template_loaded"}),!0}catch(t){console.error("Load template failed",t);const e=this._getErrorMessage(t,"transferData_failed_load_template");return this.submitError=e,Z.A.dispatch("snackbar",{text:e}),!1}}async _generateCode(){if(!this.generateLoading){this.generateLoading=!0,this.submitError="";try{const t={data:(0,H.U2)()};this.expiresAt&&(t.expiresAt=new Date(this.expiresAt).toISOString());const e=(await(0,Q.bA)(t)||{}).data,{code:n}=e?.data||{};n?(this.generatedCode=n,this.copyFeedback=""):Z.A.dispatch("snackbar",{text:I.M.get("lang","transferData_unexpected_response")})}catch(t){const e=this._getErrorMessage(t,"transferData_failed_generate_code");Z.A.dispatch("snackbar",{text:e})}finally{this.generateLoading=!1}}}async _copyCode(){if(this.generatedCode){this._copyFeedbackTimeout&&clearTimeout(this._copyFeedbackTimeout);try{await navigator.clipboard.writeText(this.generatedCode),this.copyFeedback=I.M.get("lang","transferData_copied"),this._copyFeedbackTimeout=setTimeout(()=>{this.copyFeedback="",this._copyFeedbackTimeout=null},2e3)}catch{this.copyFeedback=I.M.get("lang","transferData_copy_failed")}}}_goBack(){this.panelView="options",this.submitError=""}_onDrawerClose(){setTimeout(()=>(0,T.su)(),250)}render(){return S.qy`
|
|
3674
3674
|
<div class="main">
|
|
3675
3675
|
<slot name="main"></slot>
|
|
3676
3676
|
</div>
|
|
@@ -3925,9 +3925,9 @@
|
|
|
3925
3925
|
</button>
|
|
3926
3926
|
`}
|
|
3927
3927
|
</section>
|
|
3928
|
-
`}}
|
|
3928
|
+
`}}ft.properties={transferDataPanelOpen:{type:Boolean,state:!0},panelView:{type:String,state:!0},accessCodeInput:{type:String,state:!0},generatedCode:{type:String,state:!0},copyFeedback:{type:String,state:!0},generateLoading:{type:Boolean,state:!0},submitLoading:{type:Boolean,state:!0},submitError:{type:String,state:!0},expiresAt:{type:String,state:!0},expirationEnabled:{type:Boolean,state:!0},showSubmitConfirmModal:{type:Boolean,state:!0},pendingAccessCodeValue:{type:String,state:!0},pastedJson:{type:String,state:!0},pendingPastedList:{state:!0},confirmSource:{type:String,state:!0}},ft.styles=[ut],customElements.define("cdtr-sidebar-content-switcher",ft);const mt="https://claude.ai/settings/connectors";function gt(){const t="undefined"!=typeof window&&window.location.hostname||"";return/^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])$/.test(t)}function bt(){const t=I.M.get("config","mcpUrl");if("string"==typeof t&&t)return t;return`${gt()?"http://localhost:3000":"https://api.creaditor.ai"}/v1/mcp`}function yt(){const t="undefined"!=typeof window?window.open("about:blank","_blank"):null,e=e=>{t?t.location.href=e:"undefined"!=typeof window&&window.open(e,"_blank","noopener,noreferrer")};(async function(){const t=I.M.get("editor");if(!t)return null;if("function"==typeof t.studioTokenProvider)try{const e=await t.studioTokenProvider({});if("string"==typeof e&&e)return e}catch{}return"string"==typeof t.studioToken&&t.studioToken?t.studioToken:null})().then(async t=>{if(!t)return e(mt);const n=await fetch(`${bt().replace(/\/v1\/mcp\/?$/,"")}/oauth/connect/ticket`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!n.ok)return e(mt);const{sessionUrl:r}=await n.json();e(r||mt)}).catch(()=>e(mt))}const At=[{id:"claude",headingKey:"mcp_client_claude_heading",headingFallback:"Claude",descKey:"mcp_client_claude_desc",descFallback:"Connect in one click. No password needed.",oneClick:!0,available:!0,icon:"Logos/claude-fill",iconColor:"d97757",steps:[]},{id:"chatgpt",headingKey:"mcp_client_chatgpt_heading",headingFallback:"ChatGPT",descKey:"mcp_client_chatgpt_desc",descFallback:"Add it in ChatGPT settings. Takes a minute.",oneClick:!1,available:!0,icon:"Logos/openai-fill",iconColor:"000000",steps:[{key:"mcp_chatgpt_step1",fallback:"In ChatGPT, open Settings, then Apps, then Advanced, and turn on Developer mode."},{key:"mcp_chatgpt_step2",fallback:"Still in Settings, open Connectors (called Plugins in newer versions) and click Create."},{key:"mcp_chatgpt_step3",fallback:"Paste the connection link below as the server URL, name it Creaditor, add a short description, and choose OAuth."},{key:"mcp_chatgpt_step4",fallback:"Copy the ready prompt and paste it into a new chat."}],note:{key:"mcp_chatgpt_note",fallback:"Developer mode needs a paid ChatGPT plan and works on the web app."}},{id:"other",headingKey:"mcp_client_other_heading",headingFallback:"Another AI assistant",descKey:"mcp_client_other_desc",descFallback:"Copy the connection link and add it yourself.",oneClick:!1,available:!0,icon:"System/apps-2-fill",iconColor:"6b7280",steps:[{key:"mcp_connect_manual_step1",fallback:"Copy the connection link below."},{key:"mcp_connect_manual_step2",fallback:"In your AI assistant, open its connector settings and add it."},{key:"mcp_connect_manual_step3",fallback:"Copy the ready prompt and paste it into a new chat."}]}];function wt(t,e){return I.M.get("lang",t)||e}function xt(t){return S.qy`
|
|
3929
3929
|
<div class="cardGrid">
|
|
3930
|
-
${
|
|
3930
|
+
${At.map(e=>S.qy`
|
|
3931
3931
|
<button
|
|
3932
3932
|
type="button"
|
|
3933
3933
|
class="card ${e.available?"":"cardDisabled"}"
|
|
@@ -3942,28 +3942,28 @@
|
|
|
3942
3942
|
height="28"
|
|
3943
3943
|
/>
|
|
3944
3944
|
<span class="cardText">
|
|
3945
|
-
<h3 class="cardHeading">${
|
|
3946
|
-
<p class="cardDesc">${
|
|
3945
|
+
<h3 class="cardHeading">${wt(e.headingKey,e.headingFallback)}</h3>
|
|
3946
|
+
<p class="cardDesc">${wt(e.descKey,e.descFallback)}</p>
|
|
3947
3947
|
</span>
|
|
3948
3948
|
</button>
|
|
3949
3949
|
`)}
|
|
3950
3950
|
</div>
|
|
3951
|
-
`}const
|
|
3951
|
+
`}const vt=[{id:"page",labelKey:"mcp_prompt_page_label",labelFallback:"Build the whole page",bodyKey:"mcp_prompt_page_body",bodyFallback:"Start with get_site_context to learn my business and brand, then get_tree to see the page as it is. Build a complete, modern, responsive landing page using add_section, add_element and style_component, and find_image for imagery.\n\nAsk me what the page should be about before you start."},{id:"section",labelKey:"mcp_prompt_section_label",labelFallback:"Add one section",bodyKey:"mcp_prompt_section_body",bodyFallback:"Read the page first with get_tree so you match what is already there. Then add ONE new section with build_section and style it with style_component so it fits the existing design. Do not change or remove anything else.\n\nAsk me which section I want and where it should go."},{id:"restyle",labelKey:"mcp_prompt_restyle_label",labelFallback:"Restyle what is there",bodyKey:"mcp_prompt_restyle_body",bodyFallback:"Read the page with get_tree and get_site_context, then improve only the LOOK using style_component: colours, backgrounds, spacing, corners and shadows. Do not add, remove or reword anything. Tell me what you changed."}];function kt(t){return function(){const t=I.M.get("app"),e=t&&t._id;return[`Connect to my Creaditor site builder via its MCP connector at ${bt()}.`,"",e?`Work on the site with id \`${e}\`.`:"Use list_sites to find my site.",""].join("\n")}()+function(t,e){return I.M.get("lang",t)||e}(t.bodyKey,t.bodyFallback)}function Ct(t,e){return I.M.get("lang",t)||e}function _t(t,e){try{const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select(),document.execCommand("copy"),document.body.removeChild(n),e()}catch{}}function Et(t,e){"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(e).catch(()=>_t(t,e)):_t(t,e)}class St extends S.WF{constructor(){super(),this._storeConnectCallback=null,this._copyFeedbackTimeout=null,this.opened=!1,this.clientId="",this.copyFeedback=""}connectedCallback(){super.connectedCallback(),this._storeConnectCallback=t=>{const e=t;this.opened=e[T.Ke],this.opened&&(this.clientId="",this._clearFeedback())},I.M.connect(T.Ke,this._storeConnectCallback),this.opened=I.M.get(T.Ke)}disconnectedCallback(){super.disconnectedCallback(),this._storeConnectCallback&&I.M.disconnect(this._storeConnectCallback),this._copyFeedbackTimeout&&clearTimeout(this._copyFeedbackTimeout)}selectClient(t){this.clientId=t,this._clearFeedback()}_clearFeedback(){this._copyFeedbackTimeout&&clearTimeout(this._copyFeedbackTimeout),this._copyFeedbackTimeout=null,this.copyFeedback=""}_flash(t,e){this._copyFeedbackTimeout&&clearTimeout(this._copyFeedbackTimeout),this.copyFeedback=Ct(t,e),this._copyFeedbackTimeout=setTimeout(()=>{this.copyFeedback="",this._copyFeedbackTimeout=null},2e3)}_connect(){Et(bt(),()=>this._flash("mcp_connect_link_copied","Connection link copied. Paste it in Claude's connector settings.")),yt()}_copyLink(){Et(bt(),()=>this._flash("mcp_connect_link_copied_plain","Connection link copied."))}_copyPrompt(t){Et(kt(t),()=>this._flash("mcp_connect_prompt_copied","Prompt copied. Paste it into a new chat."))}_renderPromptPresets(){return S.qy`
|
|
3952
3952
|
<section class="section">
|
|
3953
3953
|
<h3 class="sectionTitle">
|
|
3954
|
-
${
|
|
3954
|
+
${Ct("mcp_connect_prompt_heading","Copy a starting prompt")}
|
|
3955
3955
|
</h3>
|
|
3956
3956
|
<p class="sectionDesc">
|
|
3957
|
-
${
|
|
3957
|
+
${Ct("mcp_connect_prompt_desc","Pick what you want done, then paste it into a new chat.")}
|
|
3958
3958
|
</p>
|
|
3959
3959
|
<div class="presetList">
|
|
3960
|
-
${
|
|
3960
|
+
${vt.map(t=>S.qy`
|
|
3961
3961
|
<button
|
|
3962
3962
|
type="button"
|
|
3963
3963
|
class="btn presetBtn"
|
|
3964
3964
|
@click=${()=>this._copyPrompt(t)}
|
|
3965
3965
|
>
|
|
3966
|
-
${
|
|
3966
|
+
${Ct(t.labelKey,t.labelFallback)}
|
|
3967
3967
|
</button>
|
|
3968
3968
|
`)}
|
|
3969
3969
|
</div>
|
|
@@ -3972,47 +3972,47 @@
|
|
|
3972
3972
|
`}_onDrawerClose(){(0,T.DX)()}_renderLinkField(){return S.qy`
|
|
3973
3973
|
<section class="section">
|
|
3974
3974
|
<h3 class="sectionTitle">
|
|
3975
|
-
${
|
|
3975
|
+
${Ct("mcp_connect_url_label","Connection link")}
|
|
3976
3976
|
</h3>
|
|
3977
3977
|
<div class="row">
|
|
3978
3978
|
<input
|
|
3979
3979
|
class="input"
|
|
3980
3980
|
type="text"
|
|
3981
3981
|
readonly
|
|
3982
|
-
.value=${
|
|
3982
|
+
.value=${bt()}
|
|
3983
3983
|
@focus=${t=>t.target.select()}
|
|
3984
3984
|
/>
|
|
3985
3985
|
</div>
|
|
3986
3986
|
</section>
|
|
3987
|
-
`}_renderDetail(){const t=(e=this.clientId,
|
|
3987
|
+
`}_renderDetail(){const t=(e=this.clientId,At.find(t=>t.id===e));var e;const n=!!t?.oneClick;return S.qy`
|
|
3988
3988
|
<button
|
|
3989
3989
|
type="button"
|
|
3990
3990
|
class="backRow"
|
|
3991
3991
|
@click=${()=>this.selectClient("")}
|
|
3992
3992
|
>
|
|
3993
3993
|
<cdtr-icon icon="arrowLeft" color="currentColor"></cdtr-icon>
|
|
3994
|
-
<span>${
|
|
3994
|
+
<span>${Ct("mcp_connect_back","All assistants")}</span>
|
|
3995
3995
|
</button>
|
|
3996
3996
|
|
|
3997
3997
|
${n?S.qy`
|
|
3998
3998
|
<section class="section">
|
|
3999
3999
|
<p class="sectionDesc">
|
|
4000
|
-
${
|
|
4000
|
+
${Ct("mcp_connect_claude_intro","Add the Creaditor connector to Claude, then paste the ready prompt into a chat.")}
|
|
4001
4001
|
</p>
|
|
4002
4002
|
<button type="button" class="btn" @click=${this._connect}>
|
|
4003
|
-
${
|
|
4003
|
+
${Ct("mcp_connect_btn","Connect with Claude")}
|
|
4004
4004
|
</button>
|
|
4005
|
-
${
|
|
4006
|
-
${
|
|
4005
|
+
${gt()?S.qy`<p class="sectionDesc">
|
|
4006
|
+
${Ct("mcp_connect_localhost_note","This editor is running on your own machine, so an AI on the web can't reach it. Use Claude Desktop, or ask your developer to open it up (ngrok).")}
|
|
4007
4007
|
</p>`:""}
|
|
4008
4008
|
</section>
|
|
4009
4009
|
`:S.qy`
|
|
4010
4010
|
<section class="section">
|
|
4011
4011
|
<ol class="stepList">
|
|
4012
|
-
${(t?.steps??[]).map(t=>S.qy`<li>${
|
|
4012
|
+
${(t?.steps??[]).map(t=>S.qy`<li>${Ct(t.key,t.fallback)}</li>`)}
|
|
4013
4013
|
</ol>
|
|
4014
4014
|
${t?.note?S.qy`<p class="sectionDesc">
|
|
4015
|
-
${
|
|
4015
|
+
${Ct(t.note.key,t.note.fallback)}
|
|
4016
4016
|
</p>`:""}
|
|
4017
4017
|
</section>
|
|
4018
4018
|
`}
|
|
@@ -4020,7 +4020,7 @@
|
|
|
4020
4020
|
${n?"":S.qy`
|
|
4021
4021
|
<section class="section">
|
|
4022
4022
|
<button type="button" class="btn" @click=${this._copyLink}>
|
|
4023
|
-
${
|
|
4023
|
+
${Ct("mcp_connect_copy_link_btn","Copy connection link")}
|
|
4024
4024
|
</button>
|
|
4025
4025
|
</section>
|
|
4026
4026
|
`}
|
|
@@ -4031,21 +4031,21 @@
|
|
|
4031
4031
|
?opened=${this.opened}
|
|
4032
4032
|
backdropColor="rgba(0,0,0,0.5)"
|
|
4033
4033
|
width="400px"
|
|
4034
|
-
headerText=${
|
|
4034
|
+
headerText=${Ct("sidebarMenu_mcp_connection","MCP connection")}
|
|
4035
4035
|
@close=${this._onDrawerClose}
|
|
4036
4036
|
>
|
|
4037
4037
|
<div class="panel">
|
|
4038
4038
|
${this.clientId?this._renderDetail():S.qy`
|
|
4039
4039
|
<section class="section">
|
|
4040
4040
|
<p class="sectionDesc">
|
|
4041
|
-
${
|
|
4041
|
+
${Ct("mcp_connect_intro","Build your page by chatting with an AI assistant. Pick the one you use.")}
|
|
4042
4042
|
</p>
|
|
4043
4043
|
</section>
|
|
4044
|
-
${
|
|
4044
|
+
${xt(this)}
|
|
4045
4045
|
`}
|
|
4046
4046
|
</div>
|
|
4047
4047
|
</cdtr-drawer>
|
|
4048
|
-
`}}function
|
|
4048
|
+
`}}function Mt(t,e){const n=e.get(t);if(!n)return null;const r=Array.isArray(n.children)?n.children:[];return{...n,children:r.map(t=>Mt(t,e)).filter(t=>null!==t)}}function Bt(t){const e=new Map(t.map(t=>[t.id,t])),n=t.find(t=>"root"===t.type);return n?(n.children??[]).map(t=>Mt(t,e)).filter(t=>null!==t):[]}function Tt(t,e){return I.M.get("lang",t)||e}St.properties={opened:{type:Boolean,state:!0},clientId:{type:String,state:!0},copyFeedback:{type:String,state:!0}},St.styles=[ut,S.AH`
|
|
4049
4049
|
:host {
|
|
4050
4050
|
display: contents;
|
|
4051
4051
|
}
|
|
@@ -4101,21 +4101,21 @@
|
|
|
4101
4101
|
line-height: 1.6;
|
|
4102
4102
|
color: var(--color-text-secondary, #333);
|
|
4103
4103
|
}
|
|
4104
|
-
`],customElements.define("cdtr-mcp-connection-panel",
|
|
4104
|
+
`],customElements.define("cdtr-mcp-connection-panel",St);const Lt=`${gt()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/newsletter/import`;let It=null;const Ot=S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
4105
4105
|
<path d="m9 8-4 4 4 4"></path>
|
|
4106
4106
|
<path d="m15 8 4 4-4 4"></path>
|
|
4107
|
-
</svg>`,
|
|
4107
|
+
</svg>`,Nt=S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
4108
4108
|
<path d="M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7"></path>
|
|
4109
4109
|
<path d="M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7"></path>
|
|
4110
|
-
</svg>`,
|
|
4110
|
+
</svg>`,Ht=S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
4111
4111
|
<circle cx="12" cy="12" r="9"></circle>
|
|
4112
4112
|
<path d="m8.5 12.2 2.3 2.3 4.7-5"></path>
|
|
4113
|
-
</svg>`;class
|
|
4113
|
+
</svg>`;class zt extends S.WF{constructor(){super(),this._storeConnectCallback=void 0,this.opened=!1,this.view="options",this.htmlInput="",this.urlInput="",this.mode="append",this.loading=!1,this.error="",this.warnings=[],this.doneMode="append",this.showReplaceConfirm=!1}connectedCallback(){super.connectedCallback(),this._storeConnectCallback=t=>{const e=t;this.opened=e[T.yZ],this.opened&&(this.view="options",this.error="",this.warnings=[])},I.M.connect(T.yZ,this._storeConnectCallback),this.opened=I.M.get(T.yZ)||!1,this.opened&&It&&Date.now()-It.at<15e3&&(this.view="done",this.doneMode=It.mode,this.warnings=It.warnings,It=null)}disconnectedCallback(){super.disconnectedCallback(),this._storeConnectCallback&&I.M.disconnect(this._storeConnectCallback)}_goTo(t){this.view=t,this.error=""}_onSubmit(t){if(t.preventDefault(),this.loading)return;("paste"===this.view?this.htmlInput.trim():this.urlInput.trim())?(this.error="","replace"!==this.mode?this._doImport():this.showReplaceConfirm=!0):this.error="paste"===this.view?Tt("htmlImport_error_empty_html","Paste the HTML code first"):Tt("htmlImport_error_empty_url","Enter the page URL first")}async _doImport(){this.showReplaceConfirm=!1,this.loading=!0,this.error="",this.warnings=[];try{const t="paste"===this.view?{html:this.htmlInput.trim()}:{url:this.urlInput.trim()},e=await fetch(Lt,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await e.json().catch(()=>null);if(!e.ok||!n?.output?.nodes)return void(this.error=n?.reason||n?.error||Tt("htmlImport_error_generic","Import failed"));const r=n.output.nodes;if("replace"===this.mode){It={mode:"replace",warnings:n.output.warnings??[],at:Date.now()};try{await ht(r,{snackbarTextKey:"htmlImport_loaded"})}catch(t){throw It=null,t}}else{const t=function(t){const e=I.M.get("components"),n=e?Object.values(e).find(t=>t&&"root"===t.type):void 0;if(!n)return 0;const r=Bt(t),o=Array.isArray(n.children)?n.children.length:0,i=L.Ay;return r.forEach((t,e)=>{i.store().createComponent({body:t,parentId:n.id,index:o+e})}),r.length}(r);if(0===t)return void(this.error=Tt("htmlImport_error_generic","Import failed"));Z.A.dispatch("snackbar",{text:Tt("htmlImport_loaded","HTML imported")})}this.warnings=n.output.warnings??[],this.doneMode=this.mode,this.htmlInput="",this.urlInput="",this.view="done"}catch(t){console.error("[html-import] failed",t),this.error=t instanceof TypeError?Tt("htmlImport_error_network","Could not reach the import service. Check that it is running and allowed for this address."):Tt("htmlImport_error_generic","Import failed")}finally{this.loading=!1}}_renderBackRow(){return S.qy`
|
|
4114
4114
|
<button
|
|
4115
4115
|
type="button"
|
|
4116
4116
|
class="backRow"
|
|
4117
4117
|
@click=${()=>this._goTo("options")}
|
|
4118
|
-
aria-label=${
|
|
4118
|
+
aria-label=${Tt("back","Back")}
|
|
4119
4119
|
>
|
|
4120
4120
|
<cdtr-icon
|
|
4121
4121
|
icon="arrowLeft"
|
|
@@ -4123,34 +4123,34 @@
|
|
|
4123
4123
|
width="16"
|
|
4124
4124
|
height="16"
|
|
4125
4125
|
></cdtr-icon>
|
|
4126
|
-
${
|
|
4126
|
+
${Tt("back","Back")}
|
|
4127
4127
|
</button>
|
|
4128
4128
|
`}_renderOptions(){return S.qy`
|
|
4129
4129
|
<section class="section">
|
|
4130
4130
|
<p class="sectionDesc">
|
|
4131
|
-
${
|
|
4131
|
+
${Tt("htmlImport_desc","Bring a newsletter that lives somewhere else: it becomes regular content you can edit.")}
|
|
4132
4132
|
</p>
|
|
4133
4133
|
</section>
|
|
4134
4134
|
<div class="cardGrid">
|
|
4135
4135
|
<button type="button" class="card" @click=${()=>this._goTo("paste")}>
|
|
4136
|
-
<span class="cardIcon">${
|
|
4136
|
+
<span class="cardIcon">${Ot}</span>
|
|
4137
4137
|
<span class="cardText">
|
|
4138
4138
|
<h3 class="cardHeading">
|
|
4139
|
-
${
|
|
4139
|
+
${Tt("htmlImport_paste_card_heading","Paste HTML code")}
|
|
4140
4140
|
</h3>
|
|
4141
4141
|
<p class="cardDesc">
|
|
4142
|
-
${
|
|
4142
|
+
${Tt("htmlImport_paste_card_desc","Copy the newsletter HTML and paste it here.")}
|
|
4143
4143
|
</p>
|
|
4144
4144
|
</span>
|
|
4145
4145
|
</button>
|
|
4146
4146
|
<button type="button" class="card" @click=${()=>this._goTo("url")}>
|
|
4147
|
-
<span class="cardIcon">${
|
|
4147
|
+
<span class="cardIcon">${Nt}</span>
|
|
4148
4148
|
<span class="cardText">
|
|
4149
4149
|
<h3 class="cardHeading">
|
|
4150
|
-
${
|
|
4150
|
+
${Tt("htmlImport_url_card_heading","Import from a URL")}
|
|
4151
4151
|
</h3>
|
|
4152
4152
|
<p class="cardDesc">
|
|
4153
|
-
${
|
|
4153
|
+
${Tt("htmlImport_url_card_desc","Paste a link to a published newsletter or page.")}
|
|
4154
4154
|
</p>
|
|
4155
4155
|
</span>
|
|
4156
4156
|
</button>
|
|
@@ -4170,11 +4170,11 @@
|
|
|
4170
4170
|
`;return S.qy`
|
|
4171
4171
|
<section class="section" style="margin-top:16px">
|
|
4172
4172
|
<h3 class="sectionTitle">
|
|
4173
|
-
${
|
|
4173
|
+
${Tt("htmlImport_dest_title","Where should it go?")}
|
|
4174
4174
|
</h3>
|
|
4175
4175
|
<div class="destGroup">
|
|
4176
|
-
${t("append",
|
|
4177
|
-
${t("replace",
|
|
4176
|
+
${t("append",Tt("htmlImport_mode_append","Add below existing content"))}
|
|
4177
|
+
${t("replace",Tt("htmlImport_mode_replace","Replace all content"))}
|
|
4178
4178
|
</div>
|
|
4179
4179
|
</section>
|
|
4180
4180
|
`}_renderForm(){const t="paste"===this.view;return S.qy`
|
|
@@ -4182,7 +4182,7 @@
|
|
|
4182
4182
|
<form @submit=${t=>this._onSubmit(t)}>
|
|
4183
4183
|
<section class="section">
|
|
4184
4184
|
<h3 class="sectionTitle">
|
|
4185
|
-
${t?
|
|
4185
|
+
${t?Tt("htmlImport_paste_card_heading","Paste HTML code"):Tt("htmlImport_url_card_heading","Import from a URL")}
|
|
4186
4186
|
</h3>
|
|
4187
4187
|
${t?S.qy`<textarea
|
|
4188
4188
|
class="input jsonInput htmlInput"
|
|
@@ -4190,7 +4190,7 @@
|
|
|
4190
4190
|
placeholder="<html>...</html>"
|
|
4191
4191
|
.value=${this.htmlInput}
|
|
4192
4192
|
@input=${t=>{this.htmlInput=t.target.value,this.error=""}}
|
|
4193
|
-
aria-label=${
|
|
4193
|
+
aria-label=${Tt("htmlImport_paste_card_heading","Paste HTML code")}
|
|
4194
4194
|
?disabled=${this.loading}
|
|
4195
4195
|
></textarea>`:S.qy`<input
|
|
4196
4196
|
class="input urlInput"
|
|
@@ -4198,29 +4198,29 @@
|
|
|
4198
4198
|
placeholder="https://..."
|
|
4199
4199
|
.value=${this.urlInput}
|
|
4200
4200
|
@input=${t=>{this.urlInput=t.target.value,this.error=""}}
|
|
4201
|
-
aria-label=${
|
|
4201
|
+
aria-label=${Tt("htmlImport_url_card_heading","Import from a URL")}
|
|
4202
4202
|
?disabled=${this.loading}
|
|
4203
4203
|
/>`}
|
|
4204
4204
|
</section>
|
|
4205
4205
|
${this._renderDestination()}
|
|
4206
4206
|
<div class="row" style="justify-content:flex-end;margin-top:16px">
|
|
4207
4207
|
<button type="submit" class="btn" ?disabled=${this.loading}>
|
|
4208
|
-
${this.loading?
|
|
4208
|
+
${this.loading?Tt("htmlImport_loading","Importing..."):Tt("htmlImport_submit","Import")}
|
|
4209
4209
|
</button>
|
|
4210
4210
|
</div>
|
|
4211
4211
|
${this.error?S.qy`<p class="error">${this.error}</p>`:""}
|
|
4212
4212
|
</form>
|
|
4213
4213
|
`}_renderDone(){return S.qy`
|
|
4214
4214
|
<div class="doneHero">
|
|
4215
|
-
${
|
|
4216
|
-
<h3 class="doneTitle">${
|
|
4215
|
+
${Ht}
|
|
4216
|
+
<h3 class="doneTitle">${Tt("htmlImport_loaded","Import complete")}</h3>
|
|
4217
4217
|
<p class="doneDesc">
|
|
4218
|
-
${"append"===this.doneMode?
|
|
4218
|
+
${"append"===this.doneMode?Tt("htmlImport_done_appended","The imported sections were added below your existing content."):Tt("htmlImport_done_replaced","Your newsletter now holds the imported content.")}
|
|
4219
4219
|
</p>
|
|
4220
4220
|
</div>
|
|
4221
4221
|
${this.warnings.length?S.qy`<div class="warningBox">
|
|
4222
4222
|
<h4 class="warningBoxTitle">
|
|
4223
|
-
${
|
|
4223
|
+
${Tt("htmlImport_warnings_title","Adjustments made during import")}
|
|
4224
4224
|
</h4>
|
|
4225
4225
|
${this.warnings.map(t=>S.qy`<span>${t}</span>`)}
|
|
4226
4226
|
</div>`:""}
|
|
@@ -4230,14 +4230,14 @@
|
|
|
4230
4230
|
class="presetBtn"
|
|
4231
4231
|
@click=${()=>this._goTo("options")}
|
|
4232
4232
|
>
|
|
4233
|
-
${
|
|
4233
|
+
${Tt("htmlImport_import_another","Import another")}
|
|
4234
4234
|
</button>
|
|
4235
4235
|
<button
|
|
4236
4236
|
type="button"
|
|
4237
4237
|
class="btn"
|
|
4238
4238
|
@click=${()=>(0,T.n_)()}
|
|
4239
4239
|
>
|
|
4240
|
-
${
|
|
4240
|
+
${Tt("htmlImport_done_cta","Done")}
|
|
4241
4241
|
</button>
|
|
4242
4242
|
</div>
|
|
4243
4243
|
`}render(){return S.qy`
|
|
@@ -4245,7 +4245,7 @@
|
|
|
4245
4245
|
?opened=${this.opened}
|
|
4246
4246
|
backdropColor="rgba(0,0,0,0.5)"
|
|
4247
4247
|
width="400px"
|
|
4248
|
-
headerText=${
|
|
4248
|
+
headerText=${Tt("htmlImport_title","Import HTML")}
|
|
4249
4249
|
@close=${()=>(0,T.n_)()}
|
|
4250
4250
|
>
|
|
4251
4251
|
<div class="panel">
|
|
@@ -4258,10 +4258,10 @@
|
|
|
4258
4258
|
class="transferDataConfirmDialog"
|
|
4259
4259
|
>
|
|
4260
4260
|
<h3 class="sectionTitle" style="margin-top:0">
|
|
4261
|
-
${
|
|
4261
|
+
${Tt("htmlImport_replace_confirm_title","Replace all content?")}
|
|
4262
4262
|
</h3>
|
|
4263
4263
|
<p class="sectionDesc">
|
|
4264
|
-
${
|
|
4264
|
+
${Tt("htmlImport_replace_confirm_message","The current newsletter content will be replaced by the import. This cannot be undone.")}
|
|
4265
4265
|
</p>
|
|
4266
4266
|
<div
|
|
4267
4267
|
class="row"
|
|
@@ -4273,20 +4273,20 @@
|
|
|
4273
4273
|
style="background:#6b7280;color:#fff"
|
|
4274
4274
|
@click=${()=>this.showReplaceConfirm=!1}
|
|
4275
4275
|
>
|
|
4276
|
-
${
|
|
4276
|
+
${Tt("cancel","Cancel")}
|
|
4277
4277
|
</button>
|
|
4278
4278
|
<button
|
|
4279
4279
|
type="button"
|
|
4280
4280
|
class="btn"
|
|
4281
4281
|
@click=${()=>{this._doImport()}}
|
|
4282
4282
|
>
|
|
4283
|
-
${
|
|
4283
|
+
${Tt("htmlImport_replace_confirm_cta","Replace")}
|
|
4284
4284
|
</button>
|
|
4285
4285
|
</div>
|
|
4286
4286
|
</paper-dialog>
|
|
4287
4287
|
</div>
|
|
4288
4288
|
</cdtr-drawer>
|
|
4289
|
-
`}}
|
|
4289
|
+
`}}function Pt(t,e){return I.M.get("lang",t)||e}zt.properties={opened:{type:Boolean,state:!0},view:{type:String,state:!0},htmlInput:{type:String,state:!0},urlInput:{type:String,state:!0},mode:{type:String,state:!0},loading:{type:Boolean,state:!0},error:{type:String,state:!0},warnings:{type:Array,state:!0},doneMode:{type:String,state:!0},showReplaceConfirm:{type:Boolean,state:!0}},zt.styles=[ut,S.AH`
|
|
4290
4290
|
:host {
|
|
4291
4291
|
display: contents;
|
|
4292
4292
|
}
|
|
@@ -4424,9 +4424,9 @@
|
|
|
4424
4424
|
gap: 8px;
|
|
4425
4425
|
margin-top: 4px;
|
|
4426
4426
|
}
|
|
4427
|
-
`],customElements.define("cdtr-html-import-panel",
|
|
4427
|
+
`],customElements.define("cdtr-html-import-panel",zt);const Dt=S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
4428
4428
|
<path d="M12 3l1.9 4.9L18.8 9.8l-4.9 1.9L12 16.6l-1.9-4.9L5.2 9.8l4.9-1.9L12 3z"></path>
|
|
4429
|
-
</svg>`;class Rt extends S.WF{constructor(){super(),this._onPanelKey=void 0,this._onModeKey=void 0,this.opened=!1,this.mode=!1}connectedCallback(){super.connectedCallback();const t=I.M;this._onPanelKey=t=>{this.opened=t[T.WP]},t.connect(T.WP,this._onPanelKey),this._onModeKey=t=>{this.mode=t[T.n6]},t.connect(T.n6,this._onModeKey),this.opened=I.M.get(T.WP)||!1,this.mode=I.M.get(T.n6)||!1}disconnectedCallback(){super.disconnectedCallback();const t=I.M;this._onPanelKey&&t.disconnect(this._onPanelKey),this._onModeKey&&t.disconnect(this._onModeKey)}_turnOn(){!function(){try{const t
|
|
4429
|
+
</svg>`;class Rt extends S.WF{constructor(){super(),this._onPanelKey=void 0,this._onModeKey=void 0,this.opened=!1,this.mode=!1}connectedCallback(){super.connectedCallback();const t=I.M;this._onPanelKey=t=>{this.opened=t[T.WP]},t.connect(T.WP,this._onPanelKey),this._onModeKey=t=>{this.mode=t[T.n6]},t.connect(T.n6,this._onModeKey),this.opened=I.M.get(T.WP)||!1,this.mode=I.M.get(T.n6)||!1}disconnectedCallback(){super.disconnectedCallback();const t=I.M;this._onPanelKey&&t.disconnect(this._onPanelKey),this._onModeKey&&t.disconnect(this._onModeKey)}_turnOn(){!function(){try{const t=$();if(!t||!t.id||!t.props)return!1;const e=dt(t.props[J]);return!!e&&(ct(),st(t.id,e),st(t.id,null,J),!0)}catch(t){return console.debug("[ai-editor] failed to restore the parked aiDoc",t),!1}}(),(0,T.R9)(!0),(0,T.ap)(),setTimeout(()=>{const t=I.M.get(T.yS);t&&!et()&&pt(t)},0)}_turnOff(){(0,T.R9)(!1),function(){const t=rt,e=ot;ct();try{const n=$();if(!n||!n.id)return;const r=!t||e&&e!==n.id?null:t,o=n.props?dt(n.props[K]):null,i=r||o;if(!i)return;st(n.id,i,J),n.props&&null!=n.props[K]&&st(n.id,null)}catch(t){console.debug("[ai-editor] failed to park aiDoc on root",t)}}(),(0,T.ap)()}render(){return S.qy`
|
|
4430
4430
|
<cdtr-drawer
|
|
4431
4431
|
?opened=${this.opened}
|
|
4432
4432
|
backdropColor="rgba(0,0,0,0.5)"
|
|
@@ -4487,7 +4487,7 @@
|
|
|
4487
4487
|
</div>
|
|
4488
4488
|
</div>
|
|
4489
4489
|
</cdtr-drawer>
|
|
4490
|
-
`}}Rt.properties={opened:{type:Boolean,state:!0},mode:{type:Boolean,state:!0}},Rt.styles=[
|
|
4490
|
+
`}}Rt.properties={opened:{type:Boolean,state:!0},mode:{type:Boolean,state:!0}},Rt.styles=[ut,S.AH`
|
|
4491
4491
|
:host {
|
|
4492
4492
|
display: contents;
|
|
4493
4493
|
}
|
|
@@ -4640,7 +4640,7 @@
|
|
|
4640
4640
|
</div>
|
|
4641
4641
|
</div>
|
|
4642
4642
|
</cdtr-drawer>
|
|
4643
|
-
`}}Wt.properties={opened:{type:Boolean,state:!0},source:{type:String,state:!0},sourceUrl:{type:String,state:!0},error:{type:String,state:!0},fileName:{type:String,state:!0},dragging:{type:Boolean,state:!0}},Wt.styles=[
|
|
4643
|
+
`}}Wt.properties={opened:{type:Boolean,state:!0},source:{type:String,state:!0},sourceUrl:{type:String,state:!0},error:{type:String,state:!0},fileName:{type:String,state:!0},dragging:{type:Boolean,state:!0}},Wt.styles=[ut,S.AH`
|
|
4644
4644
|
:host {
|
|
4645
4645
|
display: contents;
|
|
4646
4646
|
}
|
|
@@ -6088,7 +6088,7 @@
|
|
|
6088
6088
|
</svg>`,ae=()=>V`
|
|
6089
6089
|
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
6090
6090
|
<polyline points="9 6 15 12 9 18"></polyline>
|
|
6091
|
-
</svg>`;customElements.get("cdtr-chat")||customElements.define("cdtr-chat",Qt),t.CdtrChat=Qt,t.STRINGS=Dt,t.isRtl=Rt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});var al=a(80687);const sl=Math.random().toString(36).slice(2)+Date.now().toString(36);let ll=null,cl=null,dl=null,pl=null;const hl=new Map,ul=new Set,fl=new Set;function ml(){if(ll)return ll;if("function"!=typeof BroadcastChannel)return null;try{ll=new BroadcastChannel("cdtr-ai-turn")}catch{return null}return ll.onmessage=t=>function(t){if(!t||"object"!=typeof t||t.tabId===sl||"string"!=typeof t.docId)return;if("end"===t.state)return void yl(t.tabId);if("event"===t.state){if(!hl.has(t.tabId))return;for(const e of fl)try{e(t.docId,t.kind,t.payload)}catch(t){console.warn("[turn-presence] event listener failed",t)}return}if("start"!==t.state&&"ping"!==t.state)return;const e=hl.get(t.tabId);e&&clearTimeout(e.expireTimer);const n=setTimeout(()=>yl(t.tabId),7e4);hl.set(t.tabId,{docId:t.docId,info:t.info||null,expireTimer:n}),e&&e.docId===t.docId||bl(t.docId)}(t.data),window.addEventListener("pagehide",()=>{cl&&gl("end",cl)}),ll}function gl(t,e,n){try{ml()?.postMessage({...n,state:t,docId:e,tabId:sl})}catch{}}function bl(t){for(const e of ul)try{e(t)}catch(t){console.warn("[turn-presence] listener failed",t)}}function yl(t){const e=hl.get(t);e&&(clearTimeout(e.expireTimer),hl.delete(t),bl(e.docId))}function Al(t,e){cl&&gl("event",cl,{kind:t,payload:e})}function wl(){clearInterval(pl),pl=null,cl&&(gl("end",cl),cl=null,dl=null)}function xl(t){if(!t)return!1;for(const e of hl.values())if(e.docId===t)return!0;return!1}var vl=a(45070);const kl={en:{head:'<html lang="en">',title:"Untitled page",line:"Your page will be built here",hint:"Tell the chat what to build."},he:{head:'<html lang="he" dir="rtl">',title:"עמוד ללא שם",line:"הדף שלכם ייבנה כאן",hint:"ספרו בצ׳אט מה לבנות."}};function Cl(t){const e=kl[t];return`<!doctype html>\n${e.head}<head><meta charset="utf-8"><title>${e.title}</title>\n<style>\n body { margin:0; min-height:100vh; display:flex; flex-direction:column; font:16px/1.6 system-ui,sans-serif; background:#fff; }\n header { display:flex; align-items:center; gap:28px; padding:22px 40px; border-bottom:1px solid #f1f2f5; }\n header i { display:block; height:10px; border-radius:6px; background:#eef0f4; }\n header .logo { width:96px; height:22px; border-radius:8px; }\n header nav { display:flex; gap:22px; margin-inline-start:auto; }\n header nav i { width:56px; }\n header .btn { width:112px; height:34px; border-radius:10px; background:#e9e6f7; }\n main { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:48px 24px; }\n main p { margin:0; font-size:22px; font-weight:600; color:#c4c8d2; letter-spacing:-.01em; }\n main small { margin-top:6px; font-size:15px; color:#cfd2da; }\n</style></head>\n<body>\n <header><i class="logo"></i><nav><i></i><i></i><i></i></nav><i class="btn"></i></header>\n <main><p>${e.line}</p><small>${e.hint}</small></main>\n</body></html>`}const _l=new Set(["en","he"].map(t=>jt.createAiDoc(Cl(t),{origin:"generated"}).html));function El(t){return!t||!t.html||_l.has(t.html)&&!(Array.isArray(t.edits)&&t.edits.length>0)}class Sl extends S.WF{constructor(){super(...arguments),this._onAppKey=void 0,this._onActivity=void 0,this._onFocus=void 0,this._frameScrollY=0,this._restoreScrollY=null,this._keepScroll=!1,this._reportLock=!1,this._focus={keys:[],mode:"read",label:""},this._onDocClick=void 0,this._onRemotePatch=void 0,this._onModeKey=void 0,this._onDocKey=void 0,this._onMessage=void 0,this._onTreeLoad=void 0,this._onHistory=void 0,this._fit=void 0,this._zoomObserver=void 0,this._zoom=1,this._stageHeight=0,this._stageWidth=0,this._fitObserver=void 0,this._frameHtml="",this._frameDoc=null,this._framePreview=!1,this._frameReady=!1,this._reloads=0,this.postToFrame=t=>{const e=this.renderRoot.querySelector("iframe")?.contentWindow,n="generated"===this.doc?.origin;e?.postMessage(t,n?"*":window.location.origin)},this._onManualOps=t=>{var e,n;e=t.detail,(n=this.manualCtx()).building||Xt(e.key,()=>e.ops,n)},this._onUnlock=()=>{I.M.set({kitSelection:null}),(0,T.Ut)(!1),this.postToFrame({type:Yt.FRAME_MESSAGE_TYPES.unlock})},this._onFormLock=()=>{const t=I.M.get("kitSelection");t?.key&&this.postToFrame(function(t){return{type:Yt.FRAME_MESSAGE_TYPES.edit,key:t,typable:!1,label:oe[ie].form}}(t.key))},this.startRename=async()=>{this.renaming=!0,await this.updateComplete;const t=this.renderRoot.querySelector(".title-input");t?.focus(),t?.select()},this.onRenameKey=t=>{const e=t.target;"Enter"===t.key?(t.preventDefault(),e.blur()):"Escape"===t.key&&(t.preventDefault(),e.value=this.addressBar().title,e.blur())}}fullReload(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._reloads+=1,this._restoreScrollY=t?this._frameScrollY:null,this._frameHtml=this.srcdoc()+`\x3c!--cdtr-frame-${this._reloads}--\x3e`,this._frameDoc=this.doc,this._framePreview=this.preview,this._frameReady=!1}manualCtx(){return{building:this.building,keepScroll:()=>{this._keepScroll=!0}}}postAiState(){if(this.preview)return;const t=this.renderRoot.querySelector("iframe")?.contentWindow;if(!t||!this._frameReady)return;const e="generated"===this.doc?.origin?"*":window.location.origin,n=jt.FRAME_MESSAGE_TYPES;t.postMessage({type:n.busy,on:this.building},e),this.building&&t.postMessage({type:n.focus,...this._focus},e)}syncFrame(){if(!this.mode||!this.doc)return this._frameHtml="",void(this._frameDoc=null);if(this.doc===this._frameDoc&&this.preview===this._framePreview)return;const t=this._keepScroll;this._keepScroll=!1;const e=!this.preview&&!this._framePreview&&this._frameReady&&this._frameDoc?jt.patchesFor(this._frameDoc,this.doc):null,n=this.renderRoot.querySelector("iframe")?.contentWindow;if(e&&n){if(e.length>0){const t="generated"===this.doc.origin;n.postMessage({type:jt.FRAME_MESSAGE_TYPES.patch,patches:e},t?"*":window.location.origin)}this._frameDoc=this.doc,this._reportLock&&(this._reportLock=!1,pe(this.postToFrame,!0))}else this.fullReload(t)}willUpdate(){this.syncFrame()}fitBelowToolbar(){const t=this.parentElement,e=this.getRootNode(),n=e.querySelector?.("cdtr-top-navbar")||document.querySelector("cdtr-top-navbar");if(!t||!n)return void(this.style.top="");let r=n.getBoundingClientRect().bottom;const o=[n];n.shadowRoot&&o.push(n.shadowRoot);const i=o.flatMap(t=>Array.from(t.querySelectorAll("div")));for(const t of i)"sticky"===getComputedStyle(t).position&&(r=Math.max(r,t.getBoundingClientRect().bottom));const a=Math.max(0,Math.round(r-t.getBoundingClientRect().top));this.style.top=a>0?`${a}px`:""}ensureDoc(){const t=Et();t?I.M.set({[T.yS]:t}):I.M.get(T.yS)||I.M.set({[T.yS]:jt.createAiDoc(Cl(Ml()),{origin:"generated"})})}worthPersisting(t){if(!t)return!1;return!(El(t)&&(!t.edits||0===t.edits.length))}connectedCallback(){super.connectedCallback();const t=I.M;this._onModeKey=t=>{const e=Boolean(t[T.n6]);this.mode=e,this.toggleAttribute("active",e),e&&(this.ensureDoc(),requestAnimationFrame(()=>this._fit?.())),e||(I.M.set({kitSelection:null}),(0,T.Ut)(!1))},t.connect(T.n6,this._onModeKey),this._onDocKey=t=>{this.doc=t[T.yS],this.worthPersisting(this.doc)&&zt(this.doc)},t.connect(T.yS,this._onDocKey),this._onAppKey=()=>this.requestUpdate(),t.connect("app",this._onAppKey),this._onHistory=()=>{setTimeout(()=>{if(!this.mode)return;Nt();const t=Et(),e=I.M.get(T.yS),n=t||jt.createAiDoc(Cl(Ml()),{origin:"generated"});if(e&&e.html===n.html&&JSON.stringify(e.edits||[])===JSON.stringify(n.edits||[]))return;const r=I.M.get("kitSelection"),o=!(!r?.key||!Yt.selectionContext(n,r.key));this._keepScroll=!0,this._reportLock=o,I.M.set(o?{[T.yS]:n}:{[T.yS]:n,kitSelection:null}),o||(0,T.Ut)(!1)},0)},vl.A.on(vl.q.ON_UNDO,this._onHistory),vl.A.on(vl.q.ON_REDO,this._onHistory),this._onRemotePatch=t=>{const e=t.detail?.key;if(e!==vt)return;const n=I.M.get("app","_id");if("string"==typeof n&&xl(n))return;const r=Et();if(!this.mode)return void(r&&(0,T.R9)(!0));if(Nt(),!r)return void(0,T.R9)(!1);const o=I.M.get(T.yS);if(o&&o.html===r.html&&JSON.stringify(o.edits||[])===JSON.stringify(r.edits||[]))return;const i=I.M.get("kitSelection"),a=!!(i&&i.key&&jt.selectionContext(r,i.key));this._keepScroll=!0,I.M.set(a?{[T.yS]:r}:{[T.yS]:r,kitSelection:null}),a||(0,T.Ut)(!1)},window.addEventListener(al.JI,this._onRemotePatch),this._onMessage=t=>{const e=t.origin===window.location.origin,n="null"===t.origin;if(!e&&!n)return;const r=this.renderRoot.querySelector("iframe");if(!r||t.source!==r.contentWindow)return;const o=t.data,i=jt.FRAME_MESSAGE_TYPES;if(o?.type===i.scrolled)return void(this._frameScrollY=Number(o.y)||0);if(o?.type===i.ready){if(this._frameReady=!0,this._restoreScrollY){const t="generated"===this.doc?.origin;r.contentWindow?.postMessage({type:i.scrollTo,y:this._restoreScrollY},t?"*":window.location.origin)}return this._restoreScrollY=null,this.building&&this.postAiState(),this.nudgeFrame(r),I.M.get("kitSelection")&&pe(this.postToFrame,this._reportLock),this._reportLock=!1,void(this.doc!==this._frameDoc&&this.requestUpdate())}if(o?.type===i.typed)return void function(t,e){String(t.html??"").length>5e4||Xt(t.key,e=>Yt.typedTextOps(e,t.key,String(t.html??"")),e)}(o,this.manualCtx());if(o?.type===i.patchFailed)return this._keepScroll=!0,this._frameDoc=null,this._frameReady=!1,void this.requestUpdate();if(o?.type===i.cleared)return I.M.set({kitSelection:null}),void(0,T.Ut)(!1);if(o?.type===i.imageAction){const t=o.action;if(!jt.IMAGE_ACTIONS.includes(t))return;const e=I.M.get(T.yS),n=I.M.get("kitSelection");if(!e||!n||n.key!==o.key)return;if(!jt.selectionContext(e,o.key))return;return void window.dispatchEvent(new CustomEvent("cdtr-ai-image-action",{detail:{key:o.key,action:t}}))}if(o?.type===i.history){const t="redo"===o.action;return void window.dispatchEvent(new KeyboardEvent("keydown",{key:t?"y":"z",ctrlKey:!0}))}if(o?.type===i.elementAction){const t=o.action;if(!jt.ELEMENT_ACTIONS.includes(t))return;if(this.building)return;const e=I.M.get(T.yS),n=I.M.get("kitSelection");if(!e||!n||n.key!==o.key)return;if("form"===t){const t=jt.formOf(e,o.key);return void(t&&(ce(Ml()),(0,T.DP)(t.key,"fields")))}const r=jt.removeElementOps(e,o.key);if(!r)return;return I.M.set({[T.yS]:jt.appendAiEdits(e,r),kitSelection:null}),void(0,T.Ut)(!1)}if(o?.type!==i.selected)return;const a=I.M.get(T.yS);if(!a)return;const s=jt.selectionContext(a,o.key);if(s)if(I.M.set({kitSelection:{componentId:T.o6,kitId:T.o6,...s}}),function(t,e,n,r,o){ie=r;const{look:i,size:a}=Yt.cleanReport(n),s=Yt.manualKind(t,e,i);if(!s)return I.M.set({[T.cP]:null}),(0,T.$4)(),!1;const l={key:e,kind:s,look:i,size:a,props:Yt.panelProps(t,e,i)};return I.M.set({[T.cP]:l}),(0,T.vF)(),o(de(l)),!0}(a,o.key,o,Ml(),this.postToFrame))I.M.set({[T.c1]:null});else{const t=jt.enclosingForm(a,o.key);t?(ce(Ml()),(0,T.DP)(t.key,void 0,o.key)):(I.M.set({[T.c1]:null}),(0,T.Ut)(!0))}},window.addEventListener("message",this._onMessage),window.addEventListener(Gt,this._onManualOps),window.addEventListener(he,this._onUnlock),window.addEventListener(T.Bj,this._onFormLock),St()&&!I.M.get(T.n6)&&(0,T.R9)(!0),this.mode=I.M.get(T.n6)||!1,this.toggleAttribute("active",this.mode),this.mode&&this.ensureDoc(),this.doc=I.M.get(T.yS)||null,this.preview=!1,this.device="desktop",this.zoomChoice="fit",this.zoomMenu=!1,this.building=!1,this._onActivity=t=>{const e="thinking"===t.detail?.state;e!==this.building&&(this.building=e,e||(this._focus={keys:[],mode:"read",label:""}),this.postAiState())},window.addEventListener(Vt.bm,this._onActivity),this._onFocus=t=>{const e=t.detail||{};this._focus={keys:Array.isArray(e.keys)?e.keys.filter(t=>"string"==typeof t):[],mode:"edit"===e.mode?"edit":"read",label:"string"==typeof e.label?e.label:""},this.building&&this.postAiState()},window.addEventListener(Vt.CC,this._onFocus),this._onDocClick=()=>{this.zoomMenu&&(this.zoomMenu=!1)},document.addEventListener("click",this._onDocClick),this._fit=()=>this.fitBelowToolbar(),window.addEventListener("resize",this._fit);const e=document.querySelector("cdtr-top-navbar");e&&"undefined"!=typeof ResizeObserver&&(this._fitObserver=new ResizeObserver(()=>this._fit?.()),this._fitObserver.observe(e)),requestAnimationFrame(()=>this._fit?.()),"undefined"!=typeof ResizeObserver&&(this._zoomObserver=new ResizeObserver(()=>this.measureZoom()),this._zoomObserver.observe(this)),this.mode||(this._onTreeLoad=()=>{const t=I.M;this._onTreeLoad&&t.disconnect(this._onTreeLoad),this._onTreeLoad=void 0,I.M.get(T.n6)||I.M.get(T.yS)||St()&&((0,T.R9)(!0),this.mode=!0,this.toggleAttribute("active",!0),this.ensureDoc(),this.doc=I.M.get(T.yS)||null)},t.connect("components",this._onTreeLoad))}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(Gt,this._onManualOps),window.removeEventListener(he,this._onUnlock),window.removeEventListener(T.Bj,this._onFormLock);const t=I.M;this._onModeKey&&t.disconnect(this._onModeKey),this._onDocKey&&t.disconnect(this._onDocKey),this._onAppKey&&t.disconnect(this._onAppKey),this._onTreeLoad&&t.disconnect(this._onTreeLoad),this._onTreeLoad=void 0,this._onHistory&&(vl.A.off(vl.q.ON_UNDO,this._onHistory),vl.A.off(vl.q.ON_REDO,this._onHistory)),this._onHistory=void 0,this._onRemotePatch&&window.removeEventListener(al.JI,this._onRemotePatch),this._onRemotePatch=void 0,this._onMessage&&window.removeEventListener("message",this._onMessage),this._onMessage=void 0,this._zoomObserver?.disconnect(),this._zoomObserver=void 0,this._onActivity&&window.removeEventListener(Vt.bm,this._onActivity),this._onFocus&&window.removeEventListener(Vt.CC,this._onFocus),this._onDocClick&&document.removeEventListener("click",this._onDocClick),this._fit&&window.removeEventListener("resize",this._fit),this._fit=void 0,this._fitObserver?.disconnect(),this._fitObserver=void 0}srcdoc(){if(!this.doc)return"";const t=jt.renderAiDoc(this.doc,{scripts:this.preview});if(this.preview)return t;const e=jt.frameInspectorScript({accent:"#6366f1",origin:window.location.origin,labels:"en"===Ml()?{replace:"Replace image",crop:"Crop",remove:"Delete",form:"Edit form"}:{replace:"החלפת תמונה",crop:"חיתוך",remove:"מחיקה",form:"עריכת טופס"}});return jt.injectInspector(t,e)}nudgeFrame(t){const e=t.style.height,n=parseFloat(e);Number.isFinite(n)&&(t.style.height=`${n+1}px`,requestAnimationFrame(()=>{t.style.height=e}))}measureZoom(){const t=this.renderRoot.querySelector(".viewport");if(!t)return;const e=t.clientWidth,n=t.clientHeight;if(!e||!n)return;this._stageWidth=e;const r=Math.min(1,e/1280);Math.abs(r-this._zoom)<.001&&n===this._stageHeight||(this._zoom=r,this._stageHeight=n,this.requestUpdate())}updated(){this.mode&&this.doc&&!this._stageHeight&&requestAnimationFrame(()=>this.measureZoom())}render(){if(!this.mode||!this.doc)return S.qy``;const t=this.doc&&"generated"===this.doc.origin?"allow-scripts":"allow-scripts allow-same-origin",e=Bl[Ml()],n="mobile"===this.device,r=n?Ll:1280,o=Math.min(1,(this._stageWidth||r)/r),i="fit"===this.zoomChoice?o:Number(this.zoomChoice)||o,a=this._stageHeight||0,s=`width:${Math.round(r*i)}px;`,l=`width:${r}px;height:${Math.ceil(a/i)}px;transform:scale(${i});`,c=Math.round(r*i)>(this._stageWidth||0)+1,d=`${"fit"===this.zoomChoice?e.fit+" ":""}${Math.round(100*i)}%`,{title:p,address:h,live:u}=this.addressBar(),f=a?S.qy`<iframe
|
|
6091
|
+
</svg>`;customElements.get("cdtr-chat")||customElements.define("cdtr-chat",Qt),t.CdtrChat=Qt,t.STRINGS=Dt,t.isRtl=Rt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});var al=a(80687);const sl=Math.random().toString(36).slice(2)+Date.now().toString(36);let ll=null,cl=null,dl=null,pl=null;const hl=new Map,ul=new Set,fl=new Set;function ml(){if(ll)return ll;if("function"!=typeof BroadcastChannel)return null;try{ll=new BroadcastChannel("cdtr-ai-turn")}catch{return null}return ll.onmessage=t=>function(t){if(!t||"object"!=typeof t||t.tabId===sl||"string"!=typeof t.docId)return;if("end"===t.state)return void yl(t.tabId);if("event"===t.state){if(!hl.has(t.tabId))return;for(const e of fl)try{e(t.docId,t.kind,t.payload)}catch(t){console.warn("[turn-presence] event listener failed",t)}return}if("start"!==t.state&&"ping"!==t.state)return;const e=hl.get(t.tabId);e&&clearTimeout(e.expireTimer);const n=setTimeout(()=>yl(t.tabId),7e4);hl.set(t.tabId,{docId:t.docId,info:t.info||null,expireTimer:n}),e&&e.docId===t.docId||bl(t.docId)}(t.data),window.addEventListener("pagehide",()=>{cl&&gl("end",cl)}),ll}function gl(t,e,n){try{ml()?.postMessage({...n,state:t,docId:e,tabId:sl})}catch{}}function bl(t){for(const e of ul)try{e(t)}catch(t){console.warn("[turn-presence] listener failed",t)}}function yl(t){const e=hl.get(t);e&&(clearTimeout(e.expireTimer),hl.delete(t),bl(e.docId))}function Al(t,e){cl&&gl("event",cl,{kind:t,payload:e})}function wl(){clearInterval(pl),pl=null,cl&&(gl("end",cl),cl=null,dl=null)}function xl(t){if(!t)return!1;for(const e of hl.values())if(e.docId===t)return!0;return!1}var vl=a(45070);const kl={en:{head:'<html lang="en">',title:"Untitled page",line:"Your page will be built here",hint:"Tell the chat what to build."},he:{head:'<html lang="he" dir="rtl">',title:"עמוד ללא שם",line:"הדף שלכם ייבנה כאן",hint:"ספרו בצ׳אט מה לבנות."}};function Cl(t){const e=kl[t];return`<!doctype html>\n${e.head}<head><meta charset="utf-8"><title>${e.title}</title>\n<style>\n body { margin:0; min-height:100vh; display:flex; flex-direction:column; font:16px/1.6 system-ui,sans-serif; background:#fff; }\n header { display:flex; align-items:center; gap:28px; padding:22px 40px; border-bottom:1px solid #f1f2f5; }\n header i { display:block; height:10px; border-radius:6px; background:#eef0f4; }\n header .logo { width:96px; height:22px; border-radius:8px; }\n header nav { display:flex; gap:22px; margin-inline-start:auto; }\n header nav i { width:56px; }\n header .btn { width:112px; height:34px; border-radius:10px; background:#e9e6f7; }\n main { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:48px 24px; }\n main p { margin:0; font-size:22px; font-weight:600; color:#c4c8d2; letter-spacing:-.01em; }\n main small { margin-top:6px; font-size:15px; color:#cfd2da; }\n</style></head>\n<body>\n <header><i class="logo"></i><nav><i></i><i></i><i></i></nav><i class="btn"></i></header>\n <main><p>${e.line}</p><small>${e.hint}</small></main>\n</body></html>`}const _l=new Set(["en","he"].map(t=>jt.createAiDoc(Cl(t),{origin:"generated"}).html));function El(t){return!t||!t.html||_l.has(t.html)&&!(Array.isArray(t.edits)&&t.edits.length>0)}class Sl extends S.WF{constructor(){super(...arguments),this._onAppKey=void 0,this._onActivity=void 0,this._onFocus=void 0,this._frameScrollY=0,this._restoreScrollY=null,this._keepScroll=!1,this._reportLock=!1,this._focus={keys:[],mode:"read",label:""},this._onDocClick=void 0,this._onRemotePatch=void 0,this._onContentReplaced=void 0,this._onModeKey=void 0,this._onDocKey=void 0,this._onMessage=void 0,this._onTreeLoad=void 0,this._onHistory=void 0,this._fit=void 0,this._zoomObserver=void 0,this._zoom=1,this._stageHeight=0,this._stageWidth=0,this._fitObserver=void 0,this._frameHtml="",this._frameDoc=null,this._framePreview=!1,this._frameReady=!1,this._reloads=0,this.postToFrame=t=>{const e=this.renderRoot.querySelector("iframe")?.contentWindow,n="generated"===this.doc?.origin;e?.postMessage(t,n?"*":window.location.origin)},this._onManualOps=t=>{var e,n;e=t.detail,(n=this.manualCtx()).building||Xt(e.key,()=>e.ops,n)},this._onUnlock=()=>{I.M.set({kitSelection:null}),(0,T.Ut)(!1),this.postToFrame({type:Yt.FRAME_MESSAGE_TYPES.unlock})},this._onFormLock=()=>{const t=I.M.get("kitSelection");t?.key&&this.postToFrame(function(t){return{type:Yt.FRAME_MESSAGE_TYPES.edit,key:t,typable:!1,label:oe[ie].form}}(t.key))},this.startRename=async()=>{this.renaming=!0,await this.updateComplete;const t=this.renderRoot.querySelector(".title-input");t?.focus(),t?.select()},this.onRenameKey=t=>{const e=t.target;"Enter"===t.key?(t.preventDefault(),e.blur()):"Escape"===t.key&&(t.preventDefault(),e.value=this.addressBar().title,e.blur())}}fullReload(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._reloads+=1,this._restoreScrollY=t?this._frameScrollY:null,this._frameHtml=this.srcdoc()+`\x3c!--cdtr-frame-${this._reloads}--\x3e`,this._frameDoc=this.doc,this._framePreview=this.preview,this._frameReady=!1}manualCtx(){return{building:this.building,keepScroll:()=>{this._keepScroll=!0}}}postAiState(){if(this.preview)return;const t=this.renderRoot.querySelector("iframe")?.contentWindow;if(!t||!this._frameReady)return;const e="generated"===this.doc?.origin?"*":window.location.origin,n=jt.FRAME_MESSAGE_TYPES;t.postMessage({type:n.busy,on:this.building},e),this.building&&t.postMessage({type:n.focus,...this._focus},e)}syncFrame(){if(!this.mode||!this.doc)return this._frameHtml="",void(this._frameDoc=null);if(this.doc===this._frameDoc&&this.preview===this._framePreview)return;const t=this._keepScroll;this._keepScroll=!1;const e=!this.preview&&!this._framePreview&&this._frameReady&&this._frameDoc?jt.patchesFor(this._frameDoc,this.doc):null,n=this.renderRoot.querySelector("iframe")?.contentWindow;if(e&&n){if(e.length>0){const t="generated"===this.doc.origin;n.postMessage({type:jt.FRAME_MESSAGE_TYPES.patch,patches:e},t?"*":window.location.origin)}this._frameDoc=this.doc,this._reportLock&&(this._reportLock=!1,pe(this.postToFrame,!0))}else this.fullReload(t)}willUpdate(){this.syncFrame()}fitBelowToolbar(){const t=this.parentElement,e=this.getRootNode(),n=e.querySelector?.("cdtr-top-navbar")||document.querySelector("cdtr-top-navbar");if(!t||!n)return void(this.style.top="");let r=n.getBoundingClientRect().bottom;const o=[n];n.shadowRoot&&o.push(n.shadowRoot);const i=o.flatMap(t=>Array.from(t.querySelectorAll("div")));for(const t of i)"sticky"===getComputedStyle(t).position&&(r=Math.max(r,t.getBoundingClientRect().bottom));const a=Math.max(0,Math.round(r-t.getBoundingClientRect().top));this.style.top=a>0?`${a}px`:""}ensureDoc(){const t=et();t?I.M.set({[T.yS]:t}):I.M.get(T.yS)||I.M.set({[T.yS]:jt.createAiDoc(Cl(Ml()),{origin:"generated"})})}worthPersisting(t){if(!t)return!1;return!(El(t)&&(!t.edits||0===t.edits.length))}connectedCallback(){super.connectedCallback();const t=I.M;this._onModeKey=t=>{const e=Boolean(t[T.n6]);this.mode=e,this.toggleAttribute("active",e),e&&(this.ensureDoc(),requestAnimationFrame(()=>this._fit?.())),e||(I.M.set({kitSelection:null}),(0,T.Ut)(!1))},t.connect(T.n6,this._onModeKey),this._onDocKey=t=>{this.doc=t[T.yS],this.worthPersisting(this.doc)&&pt(this.doc)},t.connect(T.yS,this._onDocKey),this._onAppKey=()=>this.requestUpdate(),t.connect("app",this._onAppKey),this._onHistory=()=>{setTimeout(()=>{if(!this.mode)return;ct();const t=et(),e=I.M.get(T.yS),n=t||jt.createAiDoc(Cl(Ml()),{origin:"generated"});if(e&&e.html===n.html&&JSON.stringify(e.edits||[])===JSON.stringify(n.edits||[]))return;const r=I.M.get("kitSelection"),o=!(!r?.key||!Yt.selectionContext(n,r.key));this._keepScroll=!0,this._reportLock=o,I.M.set(o?{[T.yS]:n}:{[T.yS]:n,kitSelection:null}),o||(0,T.Ut)(!1)},0)},vl.A.on(vl.q.ON_UNDO,this._onHistory),vl.A.on(vl.q.ON_REDO,this._onHistory),this._onRemotePatch=t=>{const e=t.detail?.key;if(e!==K)return;const n=I.M.get("app","_id");if("string"==typeof n&&xl(n))return;const r=et();if(!this.mode)return void(r&&(0,T.R9)(!0));if(ct(),!r)return void(0,T.R9)(!1);const o=I.M.get(T.yS);if(o&&o.html===r.html&&JSON.stringify(o.edits||[])===JSON.stringify(r.edits||[]))return;const i=I.M.get("kitSelection"),a=!!(i&&i.key&&jt.selectionContext(r,i.key));this._keepScroll=!0,I.M.set(a?{[T.yS]:r}:{[T.yS]:r,kitSelection:null}),a||(0,T.Ut)(!1)},window.addEventListener(al.JI,this._onRemotePatch),this._onContentReplaced=()=>{ct();const t=et();if(!t)return this.mode&&(0,T.R9)(!1),void I.M.set({[T.yS]:null,kitSelection:null});this.mode?(I.M.set({[T.yS]:t,kitSelection:null}),(0,T.Ut)(!1)):(0,T.R9)(!0)},Z.A.subscribe("editor-content-replaced",this._onContentReplaced),this._onMessage=t=>{const e=t.origin===window.location.origin,n="null"===t.origin;if(!e&&!n)return;const r=this.renderRoot.querySelector("iframe");if(!r||t.source!==r.contentWindow)return;const o=t.data,i=jt.FRAME_MESSAGE_TYPES;if(o?.type===i.scrolled)return void(this._frameScrollY=Number(o.y)||0);if(o?.type===i.ready){if(this._frameReady=!0,this._restoreScrollY){const t="generated"===this.doc?.origin;r.contentWindow?.postMessage({type:i.scrollTo,y:this._restoreScrollY},t?"*":window.location.origin)}return this._restoreScrollY=null,this.building&&this.postAiState(),this.nudgeFrame(r),I.M.get("kitSelection")&&pe(this.postToFrame,this._reportLock),this._reportLock=!1,void(this.doc!==this._frameDoc&&this.requestUpdate())}if(o?.type===i.typed)return void function(t,e){String(t.html??"").length>5e4||Xt(t.key,e=>Yt.typedTextOps(e,t.key,String(t.html??"")),e)}(o,this.manualCtx());if(o?.type===i.patchFailed)return this._keepScroll=!0,this._frameDoc=null,this._frameReady=!1,void this.requestUpdate();if(o?.type===i.cleared)return I.M.set({kitSelection:null}),void(0,T.Ut)(!1);if(o?.type===i.imageAction){const t=o.action;if(!jt.IMAGE_ACTIONS.includes(t))return;const e=I.M.get(T.yS),n=I.M.get("kitSelection");if(!e||!n||n.key!==o.key)return;if(!jt.selectionContext(e,o.key))return;return void window.dispatchEvent(new CustomEvent("cdtr-ai-image-action",{detail:{key:o.key,action:t}}))}if(o?.type===i.history){const t="redo"===o.action;return void window.dispatchEvent(new KeyboardEvent("keydown",{key:t?"y":"z",ctrlKey:!0}))}if(o?.type===i.elementAction){const t=o.action;if(!jt.ELEMENT_ACTIONS.includes(t))return;if(this.building)return;const e=I.M.get(T.yS),n=I.M.get("kitSelection");if(!e||!n||n.key!==o.key)return;if("form"===t){const t=jt.formOf(e,o.key);return void(t&&(ce(Ml()),(0,T.DP)(t.key,"fields")))}const r=jt.removeElementOps(e,o.key);if(!r)return;return I.M.set({[T.yS]:jt.appendAiEdits(e,r),kitSelection:null}),void(0,T.Ut)(!1)}if(o?.type!==i.selected)return;const a=I.M.get(T.yS);if(!a)return;const s=jt.selectionContext(a,o.key);if(s)if(I.M.set({kitSelection:{componentId:T.o6,kitId:T.o6,...s}}),function(t,e,n,r,o){ie=r;const{look:i,size:a}=Yt.cleanReport(n),s=Yt.manualKind(t,e,i);if(!s)return I.M.set({[T.cP]:null}),(0,T.$4)(),!1;const l={key:e,kind:s,look:i,size:a,props:Yt.panelProps(t,e,i)};return I.M.set({[T.cP]:l}),(0,T.vF)(),o(de(l)),!0}(a,o.key,o,Ml(),this.postToFrame))I.M.set({[T.c1]:null});else{const t=jt.enclosingForm(a,o.key);t?(ce(Ml()),(0,T.DP)(t.key,void 0,o.key)):(I.M.set({[T.c1]:null}),(0,T.Ut)(!0))}},window.addEventListener("message",this._onMessage),window.addEventListener(Gt,this._onManualOps),window.addEventListener(he,this._onUnlock),window.addEventListener(T.Bj,this._onFormLock),nt()&&!I.M.get(T.n6)&&(0,T.R9)(!0),this.mode=I.M.get(T.n6)||!1,this.toggleAttribute("active",this.mode),this.mode&&this.ensureDoc(),this.doc=I.M.get(T.yS)||null,this.preview=!1,this.device="desktop",this.zoomChoice="fit",this.zoomMenu=!1,this.building=!1,this._onActivity=t=>{const e="thinking"===t.detail?.state;e!==this.building&&(this.building=e,e||(this._focus={keys:[],mode:"read",label:""}),this.postAiState())},window.addEventListener(Vt.bm,this._onActivity),this._onFocus=t=>{const e=t.detail||{};this._focus={keys:Array.isArray(e.keys)?e.keys.filter(t=>"string"==typeof t):[],mode:"edit"===e.mode?"edit":"read",label:"string"==typeof e.label?e.label:""},this.building&&this.postAiState()},window.addEventListener(Vt.CC,this._onFocus),this._onDocClick=()=>{this.zoomMenu&&(this.zoomMenu=!1)},document.addEventListener("click",this._onDocClick),this._fit=()=>this.fitBelowToolbar(),window.addEventListener("resize",this._fit);const e=document.querySelector("cdtr-top-navbar");e&&"undefined"!=typeof ResizeObserver&&(this._fitObserver=new ResizeObserver(()=>this._fit?.()),this._fitObserver.observe(e)),requestAnimationFrame(()=>this._fit?.()),"undefined"!=typeof ResizeObserver&&(this._zoomObserver=new ResizeObserver(()=>this.measureZoom()),this._zoomObserver.observe(this)),this.mode||(this._onTreeLoad=()=>{const t=I.M;this._onTreeLoad&&t.disconnect(this._onTreeLoad),this._onTreeLoad=void 0,I.M.get(T.n6)||I.M.get(T.yS)||nt()&&((0,T.R9)(!0),this.mode=!0,this.toggleAttribute("active",!0),this.ensureDoc(),this.doc=I.M.get(T.yS)||null)},t.connect("components",this._onTreeLoad))}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(Gt,this._onManualOps),window.removeEventListener(he,this._onUnlock),window.removeEventListener(T.Bj,this._onFormLock);const t=I.M;this._onModeKey&&t.disconnect(this._onModeKey),this._onDocKey&&t.disconnect(this._onDocKey),this._onAppKey&&t.disconnect(this._onAppKey),this._onTreeLoad&&t.disconnect(this._onTreeLoad),this._onTreeLoad=void 0,this._onHistory&&(vl.A.off(vl.q.ON_UNDO,this._onHistory),vl.A.off(vl.q.ON_REDO,this._onHistory)),this._onHistory=void 0,this._onRemotePatch&&window.removeEventListener(al.JI,this._onRemotePatch),this._onRemotePatch=void 0,this._onContentReplaced&&Z.A.unSubscribe("editor-content-replaced",this._onContentReplaced),this._onContentReplaced=void 0,this._onMessage&&window.removeEventListener("message",this._onMessage),this._onMessage=void 0,this._zoomObserver?.disconnect(),this._zoomObserver=void 0,this._onActivity&&window.removeEventListener(Vt.bm,this._onActivity),this._onFocus&&window.removeEventListener(Vt.CC,this._onFocus),this._onDocClick&&document.removeEventListener("click",this._onDocClick),this._fit&&window.removeEventListener("resize",this._fit),this._fit=void 0,this._fitObserver?.disconnect(),this._fitObserver=void 0}srcdoc(){if(!this.doc)return"";const t=jt.renderAiDoc(this.doc,{scripts:this.preview});if(this.preview)return t;const e=jt.frameInspectorScript({accent:"#6366f1",origin:window.location.origin,labels:"en"===Ml()?{replace:"Replace image",crop:"Crop",remove:"Delete",form:"Edit form"}:{replace:"החלפת תמונה",crop:"חיתוך",remove:"מחיקה",form:"עריכת טופס"}});return jt.injectInspector(t,e)}nudgeFrame(t){const e=t.style.height,n=parseFloat(e);Number.isFinite(n)&&(t.style.height=`${n+1}px`,requestAnimationFrame(()=>{t.style.height=e}))}measureZoom(){const t=this.renderRoot.querySelector(".viewport");if(!t)return;const e=t.clientWidth,n=t.clientHeight;if(!e||!n)return;this._stageWidth=e;const r=Math.min(1,e/1280);Math.abs(r-this._zoom)<.001&&n===this._stageHeight||(this._zoom=r,this._stageHeight=n,this.requestUpdate())}updated(){this.mode&&this.doc&&!this._stageHeight&&requestAnimationFrame(()=>this.measureZoom())}render(){if(!this.mode||!this.doc)return S.qy``;const t=this.doc&&"generated"===this.doc.origin?"allow-scripts":"allow-scripts allow-same-origin",e=Bl[Ml()],n="mobile"===this.device,r=n?Ll:1280,o=Math.min(1,(this._stageWidth||r)/r),i="fit"===this.zoomChoice?o:Number(this.zoomChoice)||o,a=this._stageHeight||0,s=`width:${Math.round(r*i)}px;`,l=`width:${r}px;height:${Math.ceil(a/i)}px;transform:scale(${i});`,c=Math.round(r*i)>(this._stageWidth||0)+1,d=`${"fit"===this.zoomChoice?e.fit+" ":""}${Math.round(100*i)}%`,{title:p,address:h,live:u}=this.addressBar(),f=a?S.qy`<iframe
|
|
6092
6092
|
part="frame"
|
|
6093
6093
|
sandbox=${t}
|
|
6094
6094
|
style=${l}
|
|
@@ -6355,7 +6355,7 @@
|
|
|
6355
6355
|
@media (prefers-reduced-motion: reduce) {
|
|
6356
6356
|
.progress::after { animation: none; width: 100%; opacity: 0.5; }
|
|
6357
6357
|
}
|
|
6358
|
-
`;const Bl={he:{device:"מכשיר",desktop:"מחשב",mobile:"נייד",fit:"התאמה",fitLong:"התאמה למסך",draft:"טיוטה, עוד לא פורסם",untitled:"דף ללא שם",rename:"שינוי שם הדף",renameFailed:"לא הצלחנו לשמור את שם הדף. נסו שוב."},en:{device:"Device",desktop:"Desktop",mobile:"Mobile",fit:"Fit",fitLong:"Fit to screen",draft:"Draft, not published yet",untitled:"Untitled page",rename:"Rename page",renameFailed:"Couldn't save the page name. Please try again."}},Tl=["fit","0.5","0.75","1"],Ll=390,Il=t=>S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" .innerHTML=${t}></svg>`,Ol=Il('<rect x="3" y="4.5" width="18" height="12" rx="2"/><path d="M8.5 20h7M12 16.5V20"/>'),Nl=Il('<rect x="7" y="3" width="10" height="18" rx="2.5"/><path d="M11 17.5h2"/>'),Hl=Il('<rect x="5" y="10.5" width="14" height="10" rx="2"/><path d="M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5"/>'),zl=Il('<circle cx="12" cy="12" r="8.5" stroke-dasharray="3 3"/>'),Pl=Il('<polyline points="6 9 12 15 18 9"/>');customElements.define("cdtr-ai-canvas",Sl);const Dl="cdtr-studio-fonts";const Rl=/[-]/;function jl(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"he";const n=Array.isArray(t?.messages)?t.messages:[];for(let t=n.length-1;t>=0;t--){const e=n[t];if(e&&"user"===e.role&&"string"==typeof e.text&&e.text.trim())return Rl.test(e.text)?"he":"en"}return"en"===e?"en":"he"}function Fl(t,e){Wl(t);const n=t?.shadowRoot?.querySelector(".messages");return!!n&&(e.parentNode===n&&e===n.lastElementChild||n.appendChild(e),function(t){const e=t?.shadowRoot?.querySelector(".body");e&&(e.scrollTop=e.scrollHeight)}(t),!0)}function ql(t,e,n){Fl(t,e),Promise.resolve(t.updateComplete).then(()=>{n&&!n()||Fl(t,e)}).catch(()=>{})}const Ul="\n /* Specificity note: <cdtr-chat>'s own sheet is an ADOPTED stylesheet, and\n adopted sheets cascade after <style> elements in the shadow root, so on a\n tie the chat's rules win. Every rule here that competes with one of its\n (.row, the studio bubble reset) is written heavier on purpose. */\n /* The chat's own typing row, while ours is showing: two would read as the\n work happening twice. */\n :host(.cdtr-edit-busy-on) .row.assistant.typing { display: none; }\n\n /* While a turn runs nothing else may change the conversation or the page:\n new chat, history, close, attach and voice wait for it (Stop does not). */\n :host(.cdtr-edit-busy-on) .header button,\n :host(.cdtr-edit-busy-on) .header-actions button,\n :host(.cdtr-edit-busy-on) .card-attach,\n :host(.cdtr-edit-busy-on) .icon-btn.voice,\n :host(.cdtr-edit-busy-on) .icon-btn:not(.send):not(.cdtr-edit-stop) {\n opacity: .38; pointer-events: none; cursor: default;\n transition: opacity .2s ease;\n }\n\n /* ---------- sidebar ---------- */\n /* The sidebar (editChatDrawer) draws the header now: title, tabs, tokens,\n new conversation. The chat's own header would be a second, dead bar. */\n :host([variant]) .header, .header { display: none !important; }\n\n /* Nothing in a conversation may push the panel wider than itself: a long\n link, a pasted path, a code line used to make the whole chat scroll\n sideways. Wrap instead, everywhere a message can render. */\n :host([variant]) .body, .body { overflow-x: hidden; }\n .messages, .row { min-width: 0; max-width: 100%; }\n :host([variant]) .bubble, .bubble { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }\n .bubble.md pre, .bubble.md code { white-space: pre-wrap; overflow-wrap: anywhere; }\n .bubble.md pre { max-width: 100%; overflow-x: auto; }\n .bubble img, .bubble video, .bubble table { max-width: 100%; }\n\n /* ---------- reply avatar ----------\n A still of Meshavektor at the start of each of his replies, so a long\n conversation shows who said what. Only the chat's own reply rows, not\n ours (every row we add carries a cdtr- class) and not its typing row.\n A reply that follows another keeps the space but hides the face. Still,\n never video: motion belongs to the live working row alone. */\n .messages > .row.assistant:not(.typing):not([class*='cdtr-'])::before {\n content: '';\n flex: 0 0 28px;\n width: 28px;\n height: 28px;\n margin-block-start: 2px;\n margin-inline-end: 10px;\n border-radius: 50%;\n background: #1565a6 url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAYKADAAQAAAABAAAAYAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+ICpElDQ19QUk9GSUxFAAEBAAAClGFwcGwCEAAAbW50clJHQiBYWVogB9UABAABAAEAAQABYWNzcEFQUEwAAAAAQVBQTAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMZGVzYwAAARQAAABfY3BydAAAAXQAAAAid3RwdAAAAZgAAAAUclhZWgAAAawAAAAUZ1hZWgAAAcAAAAAUYlhZWgAAAdQAAAAUclRSQwAAAegAAAAOdmNndAAAAfgAAAAwbmRpbgAAAigAAAA+Y2hhZAAAAmgAAAAsYlRSQwAAAegAAAAOZ1RSQwAAAegAAAAOZGVzYwAAAAAAAAAFSERUVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdGV4dAAAAABDb3B5cmlnaHQgMjAwNyBBcHBsZSBJbmMuAAAAWFlaIAAAAAAAAPNRAAEAAAABFsxYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9jdXJ2AAAAAAAAAAEB9gAAdmNndAAAAAAAAAABAAEAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAQAAbmRpbgAAAAAAAAA2AACj1wAAVHsAAEzNAACZmgAAJmYAAA9cAABQDQAAVDkAAfYEAAH2BAAB9gQAAAAAAAAAAHNmMzIAAAAAAAEMQgAABd7///MmAAAHkwAA/ZD///ui///9owAAA9wAAMBu/8AAEQgAYABgAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICAwICAwQDAwMEBQQEBAQFBwUFBQUFBwgHBwcHBwcICAgICAgICAoKCgoKCgsLCwsLDQ0NDQ0NDQ0NDf/bAEMBAgICAwMDBgMDBg0JBwkNDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDf/dAAQABv/aAAwDAQACEQMRAD8A+JwfSnc55pop5I696/p/qfy9YTJp2cjrTe9YmuXk0ECW1qSlxdlo43xnywBl3+qjoO5xXJj8bSweHniq7tGKu/67vZHZl+Aq4zEQwtBXlJ2X9dluF9rKwyPaWUf2i4T/AFgziOPv87AE5/2QCfpWM1xfXkXnHUsKG2kW4SNVY9FJcMQfqRWPo3g/xz431RvDfgDTri4eEKZmnkSGCPeSFZ35fc7A4wGcntjmvZ4P2L/2o9n2tbXRSzJtZJNTYPIh6pIGgww/3jketfzlxD4k161ZxqYlUY9IqVml5tat/cvI/pfhzwww2HoKccK6z6ylG6b68qell5Xfdnm8UF7HIv8AxNbhGb5VSdY2BYdV5UfN7Z+lbEFzdQtEl60Usc52xTxZUFx/BIhJKNwcckHHrxWrZ/skftTPI1mvhWGKLKhWuNVtvLTY2QVZWdiByBlQcflWx4m/Zg/aP8FeH77xHreiabqmm2aC7vLfTr83NwIosMzLE0MZfZjcQhLYB2gnAPLlHiRUwWIhfGKpFvWLmpX8rtuz7fqtDpzrw1oY7DTSwTpSS0lGDjZ+aSV13XbtuZOR+NI2RXF+GNXF2UgSTzYJ4ftNqxfeQmQGTcRlgMgqTzg/jXafrmv6NybNqWY4SGMo3SfR7prRo/mjOsorZZjJ4Ovq11WzT1TQ0UdaUYzmg9eK9Q8r1P/Q+JxQKKK/p8/l8fznOKyXtTe+JLGAHAa3nI5xyGTuen17VqjNYPim08Q2GgR+MLLT7r+y4rl9Ol1MJ/o0MsygBWfOQdwC7sbdx253cV8fx3KmslqwqTScuVK7Su+ZOy7t2ei1PsuAI1P7co1IQclHmbsr2XK1d9km1q9D7h/Y68Owaffa4WeOeRtUWU7f4AluAqtyeQQWxkkAjPOa/RQCvwv8KftZP8HPBFr4W8E6OD4jnTz73Vb/AGzQQSz53YtkZZGeNQFSORlwpDMSTg+meGP20P2gNG8Or418WXHhvVNDEiqsdzZyWV5OC4X5Ps8kmCRkr+7bPfA5r+Lc44MzXH4uri6UVa+ibV2lpfsk/No/tzLONMqwWFo4Ocm2lq0tE227a2d1fWya8z9hdoqOWKOaJ4JQGSRSjA9CrDBB/A1+dfjn/goz8KrDwkl58OSde8Sy7V/s+7t7q0ggPG9pJTFyEBIAH3j3FeM+D/21PjXrC3Xj3XtT0Cy8PaY/7zTRprRi75x5Uc7XBlVz0DhT82PkPIrwsDwLnGJi5xp8tv5tG/Rfq7LzPXx3HGU4aag6nNf+XVL1f6avyPEn0C00SaxhgiEJtrnVbJUUYCwQTbUA68AKB7c9OlaY70+68Sy/FbX/ABH8SPCehXdl4ZiuGu7iJmik/subUHRJEmKFQPOmjaVQu8hZNzbVIpg9K/t7w0qKWSxTa503zK6bi3rZ22dtfRp7M/h3xQg455KUU+RxXK7NKSWl13V7r103A+opM4OadgZ4o4H0r9BPztn/0fiel9zSDtmnfSv6dP5fEzXsuj6SfE/wA8Q6LoO062x1LSLhJpDHC1vdJJcxhuCBu3Ao2DiVe/IPjVdh4G8Z3HgTWLnUVsxqNhqNqbPULIsEM0YyY3RmGBJESdueCGIJHBr858UeHMVnGTcmBXNVpTjUjH+a1019zbXdpI/TvCbijCZJnnPmD5aNWEqcpfyqVmpfekn2TbMb9o74H+I9T1TRPiv4W0W61TQdY0WxF6dPhM8kF3axKoLxx5ciaMrhgpxsIPUV8/aD8Iviv8V9bt9A07QNVtLZOGvL2zmtbOwhJCvKzzLGpZQeEUlmOAOOR+1H7LniKLWPhlptnuJe3tYSqt18vaBz7qRg133j/wAQaZNay+H7eaYXiOrgwgbUljIZd2fvAdwB+Oa/kyjxjmGCUsrjSTlC6UnfRLa68v6Xf+vcRwbluOqRzSdVqM7SaVrNvez31+f+Xyl+0f8AsxQeI/2evCmh+ANOiOq+CBb/AGJFCpNdWuzypofMbHzyDDjc2DIq7iOTX5VS/Dr4paveR+G7bwd4hDwSFI7NtOnTEmduSWUJnJ67sY5zjmv2ptNc8TFP7G1LUL57O22+cmF/exyA5USFM4xx0G31r6N8M69p+uWe6xdy0ICusv8ArFHbJ/i+vtzzXHlnFWYZPhpUp01Ui23dt6X723Tev6nZnHCWW5tiVVhUcJWSslul69UtP0Pyb0v4VXPwZ+DvifRvFBVta1C60SHyBKWjttSu40mvUUA7WZLQKN2einHBOfM9pzur2v48+PZPF/jvVdFtYwmn6PrN7IsgcN9qneG3txJjHyiKOIoOTncTwK8WHPFf1r4R5XisLkn1zGq1XES9o/JNJR+TS5l6n8e+MObYXFZ79TwP8PDx9mvNpty+5vl+Q3tTlximkY4oz7V+on5Uf//S+JxTsim07Hr1r+nT+YOgZ7dqSSSOKJppWCRxgszMcBVHJJPYCkdkiUySMFRRlmY4AHuTXkXi/wAT2euWsuh6ZKzWrgrczrkBwRwiHHKnqx6dueceRnGcUMuoOrUfvdF1b/rd9D2ckySvmWIVGkvd+1Lol/n2XU+4vgR4q1jwJoenareyTwaTqNzcQwXEi7GtJXlJSCYc7UmVlkt3bh1cKcNt3fenhKLwxq2mXE+qRWc92zyO8tyisxV+QctyQO4FfI3whiT4k/BnQPEuiLbT6jFpy6FrmmXPFnqDafmBkkyD5coC5ilwQVYBgVwVm8PXer+Gr+XTfD5a+t7bBn0HVZPI1PTwc48uQ7xLFkYUsSp/hlIwB/GPHnDeJoYmeLrq1Oq+aM18L5nfll/LJXtZ6NarW6P7f4B4hw+JwtPB4d3q0Uoypt+97qtzR/mi7X01i3Zq1mfQui2tnL4kittR0/Q0sFZsTCzKl/TG6RlQt67RWB8VfiNoXw1t9S1bTU8q38kQpbWUeTdS9SFCDhct878Kq5ZiBk1yaeL/ABTqLiz03wncG6fiNZ7y3CFj0yYmlfH0U11mk/Bi48bQaz4L8RSjUNZ1qyeLxJf25MdvoumuvmRabaMDkT3LKhc53smZHKjyUr5nKctp4nMKVCPvuTS5U1te7beqVlrf7j6XPszq4PL6uIqvkUU2pST3toknZu76fez81t11cSTXl6Q11dTSXE5X7vmysXbHsCcD2FIf1rz3wt4sKWlvpniadI75VCeefljmYD5ucABwc8HGRyO+PQgAw3Kcg8j3/Gv71yfG4TE4WDwTXKklbrGy0TXkf5851gcZhcXNY5Pnbbv0ld6tPrcCMH1pRyTSE9h0pyj1zivVPIP/0/iKaeC2iM9zIsUa/edyFUfia4zUvHEEe5NHga7kHAkkJiiH5jc34DHvXF67qa+IL03DfPaRti2U9Ao/5af7zHoeoGMd6z4ZMOYJSWIGVY9Svv7iv0vOeNa8qkqOCtGK05t2/NdEu2/yPzzI+A8OqUa+YXlJ68uyXk+rffb5jdUuNc1sltUuBJGDkQKNsS/RR1PuxJrOtIoxHsc4kOSynhtx68VvEBVOCM1Qt1En75/ml5Uk/wAJHUD0H86+Er1KlWp7SpJuT6vVn6FQoU6NNUqUVGK6LRH37/wTs8d6XoPxP1b4Xa/FDLa+Lbf7fpjTAEJqdghEsa5/intsMB/0xY/X9a/iV4S+FV54Zutb+IVvY6fp2iwvdtqrMLOXT0QZaRLlCrx8dQDhuhBBxX81Nrq+qeG7608T6JdXVhqWjTx39rc2LAXMUkB3Zi3Bl3MuVwwKsGKsCpIP9CGh+D7744eGNK8SfEbUbPVdEmsoLrRrbTd32G98+IOmoXUbfekIbCQ5McXLAlipX28vca9CWErK8ez1Vn3XVHzmb05YfERxlKTi+60d12fR/wDDn50Xf7Yt9puo3en+ANEjufDpuFW11m6WOz124shgOwhEZt0mk5MTSBdoIMkQbIH6ifA3x38L/Gnwtg8SfDFnh0hEma7hugy30F0AWm+2eZl2nY5YyEsJQQ6sykGvwX+N3g2y+FnxS8S/Dvw+zvpGmvGd0bEy2QmQSzQQ8NvMUZ3RZx1VT0zX7Q+KPhZott8Kk8QfA+9j0OGbwxHpzSQLvgvdDMOchQyhbiKMs8EvOxmbghiD6kOGMlyynGtlGH9nOd+bfVq2ib2V+itHbRGeZ8Q5nmnLDM67nGNuXyT6tLrbq9d9T+fTzrW+tRcBgYJh5qMeMK3zA89OD3rQ0nU9T06NWsJ2hX/nmRuiYdjsP3c+ikVl6Q0TaRZyQR7Ymt4ikec7UKDAyeuBxz1qxGqi5CRjapQsy9hzxx2718fh6tShJTpSaa6p2Z9RXw9KvTdKtFSi+js0eh2HjiPITVrdoT082DMifiuN6/kR713FneWt9AtxZTJNEf4kYEfT2rxMxAVLoGpvpWppeA4hnk8q4XsUJ2qx90POfTNfd5NxpiI1YUcbaUW7c2zXm7aNd9F3ufnue8CYaVGdfA3jJK/Lun5Lqn82uh//1PyrUYAGMVDcYRRL3jYE/Q8H9KnQkgGmzKHUoe4IP413NXRa7k45FVmPkTCXPyyEK/s38J/p+VLZyeZbRseu0A/UcGp5Y0kjKN0cYNG6C9nqSZx25r9sP+CdHxFbxV8EJPA17JuvfAupyaYoLbj/AGfcf6TZn12ojmIZ/wCefU1+I9rKzq0cnMkZ2t7+h/EV9r/sCePW8GftCp4duJilh440ubTmU/d+3aeHu7U57Ex/aF9CSB1xnty6ry149np9/wDwTzc3w/tcLNdVr93/AALnkfxcvv7Z+NnxF1dvm+0eJbkKevFvHHbj/wBF1+jP7MPxHe9/Y28aaRdzlrrwBaazpylv4bRrdrqzA/2Y4pljH+5X5c6zO1z4v8V3TnLS+JdbOfb7dMB+gFeyfCrxnP4f+FH7QPh5WYDVvA0dxbqvXz45ZbWRhjvsuY8+wGO9frub4eP9hwq2+FJ/erP8Xc+Bwl5Y+VHu7fc/8rnyDo8T2+j2MD8PHbRKw9CqAGrMBLzzOP7wQf8AARz+pNTEiJGdhgICfoBUdmpWFd33iNx+rcn+dfituh+olmRtqF2ONoJ/KqMag2yI3defxHP86lvmxayDuw2/99HH9aYQAuFpdQb0P//Z') center / cover no-repeat;\n box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9), 0 1px 4px rgba(43, 18, 64, 0.16);\n }\n .messages > .row.assistant:not(.typing):not([class*='cdtr-'])\n + .row.assistant:not(.typing):not([class*='cdtr-'])::before {\n visibility: hidden;\n }\n\n /* ---------- working row ---------- */\n .row.cdtr-edit-row { display: block; }\n :host([variant]) .row.assistant.cdtr-edit-row .bubble.cdtr-edit-bubble,\n .row.assistant.cdtr-edit-row .bubble.cdtr-edit-bubble {\n display: grid;\n gap: 8px;\n width: 100%;\n max-width: 100%;\n box-sizing: border-box;\n padding: 12px 12px 12px 14px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n border-radius: 18px;\n }\n :host([variant]) .row.assistant.cdtr-edit-row[dir='rtl'] .bubble.cdtr-edit-bubble {\n padding: 12px 14px 12px 12px;\n }\n .cdtr-edit-busy-head {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 28px;\n }\n /* Big enough to see him at work: the row is where the face spends a turn. */\n .cdtr-edit-face { --face-size: 80px; }\n /* The label gives way, never the timer or the stop button: a long step\n label (\"מצייר כיוונים לעיצוב שתוכלו לבחור\") once squeezed them until\n \"0:13\" and \"עצור\" each broke over two lines. */\n .cdtr-edit-busy-label {\n font-size: 14px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n margin-inline-end: auto;\n flex: 1 1 auto;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .cdtr-edit-face, .cdtr-edit-elapsed, .cdtr-edit-stop { flex: 0 0 auto; white-space: nowrap; }\n .cdtr-edit-elapsed {\n font-size: 12px;\n color: var(--cdtr-chat-muted, #6f676b);\n font-variant-numeric: tabular-nums;\n }\n .cdtr-edit-thinking {\n display: none;\n max-height: 132px;\n overflow-y: auto;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 1.6;\n color: var(--cdtr-chat-muted, #6f676b);\n -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px);\n mask-image: linear-gradient(to bottom, transparent 0, #000 28px);\n padding-top: 6px;\n scrollbar-width: none;\n }\n .cdtr-edit-thinking::-webkit-scrollbar { display: none; }\n .cdtr-edit-bubble.has-thinking .cdtr-edit-thinking { display: block; }\n .cdtr-edit-stop {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 28px;\n padding: 0 10px;\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n border-radius: 10px;\n background: rgba(255, 255, 255, 0.5);\n color: var(--cdtr-chat-ink-2, #4a4347);\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;\n }\n .cdtr-edit-stop::before {\n content: '';\n width: 8px;\n height: 8px;\n border-radius: 2px;\n background: currentColor;\n }\n .cdtr-edit-stop:hover { color: #a3261f; border-color: rgba(163, 38, 31, 0.35); background: #fdf3f2; }\n .cdtr-edit-stop:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n\n /* ---------- answer chips ---------- */\n .row.cdtr-chip-row.cdtr-chip-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: -6px;\n }\n .cdtr-chip {\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n color: var(--cdtr-chat-fg, #1f1b1d);\n border-radius: 12px;\n padding: 8px 12px;\n font: inherit;\n font-size: 14px;\n line-height: 1.25;\n cursor: pointer;\n text-align: start;\n transition: background 0.15s ease, border-color 0.15s ease;\n }\n .cdtr-chip:hover { background: var(--cdtr-chat-glass-strong, rgba(255, 255, 255, 0.78)); }\n .cdtr-chip:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-chip-primary {\n background: var(--cdtr-chat-fg, #1f1b1d);\n border-color: var(--cdtr-chat-fg, #1f1b1d);\n /* Fixed, not --cdtr-chat-bg: the glass variant makes that transparent,\n which left the primary chip a dark pill with no visible label. */\n color: #fff;\n font-weight: 600;\n }\n .cdtr-chip-primary:hover { background: #000; border-color: #000; }\n\n /* ---------- memory chips (memory.js) ---------- */\n .row.cdtr-mem-row.cdtr-mem-row {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n }\n .cdtr-mem-chip {\n display: inline-flex;\n align-items: baseline;\n gap: 8px;\n max-width: 100%;\n box-sizing: border-box;\n padding: 5px 10px;\n border-radius: 10px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n color: var(--cdtr-chat-ink-2, #4a4347);\n font-size: 12.5px;\n line-height: 1.35;\n }\n .cdtr-mem-text { min-width: 0; overflow-wrap: anywhere; }\n .cdtr-mem-chip.is-undone .cdtr-mem-text { text-decoration: line-through; opacity: .55; }\n .cdtr-mem-undo {\n flex: 0 0 auto;\n background: none;\n border: none;\n padding: 0;\n font: inherit;\n font-weight: 600;\n color: var(--cdtr-chat-accent, #6b2c8f);\n text-decoration: underline;\n cursor: pointer;\n }\n .cdtr-mem-undo:disabled { color: var(--cdtr-chat-muted, #6f676b); text-decoration: none; cursor: default; }\n .cdtr-mem-undo:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n\n /* ---------- page interview card (brief.js) ---------- */\n .row.cdtr-brief.cdtr-brief {\n display: grid;\n gap: 14px;\n padding: 14px;\n border-radius: 16px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n }\n .cdtr-brief-q { display: grid; gap: 8px; }\n .cdtr-brief-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n }\n .cdtr-brief-opts { display: flex; flex-wrap: wrap; gap: 6px; }\n .cdtr-brief-opt { padding: 6px 11px; font-size: 13px; }\n /* Fixed colours, not the chat's tokens: --cdtr-chat-bg is transparent on\n the glass variant, which once made a selected label invisible. */\n .cdtr-brief-opt[aria-pressed=\"true\"] {\n background: #1f1b1d;\n border-color: #1f1b1d;\n color: #fff;\n }\n .cdtr-brief-other {\n font: inherit;\n font-size: 13px;\n padding: 7px 10px;\n border-radius: 10px;\n border: 1px solid rgba(31, 27, 29, 0.14);\n background: rgba(255, 255, 255, 0.7);\n color: #1f1b1d;\n min-width: 0;\n }\n .cdtr-brief-other:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 1px; }\n .cdtr-brief-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .cdtr-brief-go {\n font: inherit;\n font-size: 14px;\n font-weight: 600;\n padding: 9px 20px;\n border-radius: 12px;\n border: 0;\n background: #1f1b1d;\n color: #fff;\n cursor: pointer;\n }\n .cdtr-brief-go:hover { background: #000; }\n .cdtr-brief-skip {\n font: inherit;\n font-size: 13px;\n background: none;\n border: 0;\n padding: 4px;\n color: var(--cdtr-chat-muted, #6f676b);\n text-decoration: underline;\n cursor: pointer;\n }\n .cdtr-brief-go:focus-visible, .cdtr-brief-skip:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n :host(.cdtr-edit-busy-on) .cdtr-brief { opacity: .5; pointer-events: none; }\n\n /* ---------- direction cards ---------- */\n .row.cdtr-dir.cdtr-dir {\n display: grid;\n gap: 12px;\n }\n .cdtr-dir-head { display: grid; gap: 2px; }\n .cdtr-dir-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n }\n .cdtr-dir-sub {\n margin: 0;\n font-size: 13px;\n color: var(--cdtr-chat-muted, #6f676b);\n }\n .cdtr-dir-list { display: grid; gap: 12px; }\n .cdtr-dir-item { position: relative; }\n .cdtr-dir-card {\n display: grid;\n gap: 0;\n width: 100%;\n padding: 0;\n overflow: hidden;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n border-radius: 18px;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: pointer;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.2s ease;\n }\n .cdtr-dir-card:hover {\n transform: translateY(-2px);\n background: var(--cdtr-chat-glass-strong, rgba(255, 255, 255, 0.78));\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 18px 36px -16px rgba(22, 26, 34, 0.45);\n }\n .cdtr-dir-card:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-dir-card img {\n display: block;\n width: 100%;\n aspect-ratio: 16 / 10;\n object-fit: cover;\n object-position: top;\n border-bottom: 1px solid rgba(255, 255, 255, 0.7);\n background: rgba(255, 255, 255, 0.4);\n }\n .cdtr-dir-meta {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px 12px;\n }\n .cdtr-dir-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }\n .cdtr-dir-name { font-size: 14px; font-weight: 600; line-height: 1.3; }\n .cdtr-dir-mood {\n font-size: 13px;\n line-height: 1.45;\n color: var(--cdtr-chat-muted, #6f676b);\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n .cdtr-dir-go {\n flex: none;\n height: 30px;\n padding: 0 12px;\n display: inline-flex;\n align-items: center;\n border-radius: 8px;\n /* Fixed colours: the glass variant's --cdtr-chat-bg is transparent, which\n made the label vanish into an empty black pill. */\n background: #1f1b1d;\n color: #ffffff;\n font-size: 13px;\n font-weight: 600;\n opacity: 0;\n transform: translateY(2px);\n transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);\n }\n .cdtr-dir-card:hover .cdtr-dir-go,\n .cdtr-dir-card:focus-visible .cdtr-dir-go { opacity: 1; transform: none; }\n .cdtr-dir-zoom {\n position: absolute;\n top: 8px;\n inset-inline-end: 8px;\n width: 30px;\n height: 30px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 8px;\n background: rgba(255, 255, 255, 0.92);\n color: var(--cdtr-chat-fg, #1f1b1d);\n box-shadow: 0 1px 2px rgba(31, 27, 29, 0.12), 0 4px 12px -4px rgba(31, 27, 29, 0.25);\n cursor: zoom-in;\n opacity: 0;\n transition: opacity 0.15s ease;\n }\n .cdtr-dir-item:hover .cdtr-dir-zoom,\n .cdtr-dir-zoom:focus-visible { opacity: 1; }\n .cdtr-dir-zoom:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-dir-zoom svg { width: 16px; height: 16px; }\n\n @media (prefers-reduced-motion: reduce) {\n .cdtr-dir-card, .cdtr-dir-go { transition: none; }\n }\n";function Wl(t){const e=t?.shadowRoot;if(!e||e.getElementById("cdtr-edit-row-styles"))return;const n=document.createElement("style");n.id="cdtr-edit-row-styles",n.textContent=Ul,e.appendChild(n)}const Vl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><line x1="16" y1="16" x2="20.5" y2="20.5"/><line x1="11" y1="8.5" x2="11" y2="13.5"/><line x1="8.5" y1="11" x2="13.5" y2="11"/></svg>',Yl=/```[ \t]*cx-(options|confirm)[ \t]*\r?\n([\s\S]*?)```/g;function Gl(t){const e="string"==typeof t?t:"",n=[];let r,o=null;for(Yl.lastIndex=0;null!==(r=Yl.exec(e));){"confirm"===r[1]?o="confirm":null===o&&(o="options");for(const t of String(r[2]||"").split("\n")){const e=t.trim().replace(/^[-*•]\s*/,"").replace(/^\d+[.)]\s*/,"").trim();!e||e.length>60||(n.includes(e)||n.push(e))}}return{text:e.replace(Yl,"").replace(/\n{3,}/g,"\n\n").trim(),chips:n.slice(0,5),kind:o}}function Xl(t){if(t&&t._chipRow){try{t._chipRow.remove()}catch{}t._chipRow=null}}function Zl(t,e,n,r,o){if(Xl(t),!t||!Array.isArray(n)||0===n.length)return;const i=document.createElement("div");i.className="row cdtr-chip-row",i.dir="he"===e?"rtl":"ltr",n.forEach((e,n)=>{const a=document.createElement("button");a.type="button",a.className="cdtr-chip"+("confirm"===r&&0===n?" cdtr-chip-primary":""),a.textContent=e,a.addEventListener("click",()=>{Xl(t),o(e)}),i.appendChild(a)}),t._chipRow=i,ql(t,i,()=>t._chipRow===i)}const Ql=/```[ \t]*cx-brief[ \t]*\r?\n([\s\S]*?)```/,Kl={he:{other:"משהו אחר…",go:"המשך",skip:"דלג, תחליט אתה",decide:"תחליט אתה"},en:{other:"Something else…",go:"Continue",skip:"Skip, you decide",decide:"you decide"}};function Jl(t){const e="string"==typeof t?t:"",n=Ql.exec(e);if(!n)return{text:e,questions:[]};const r=[];for(const t of String(n[1]||"").split("\n")){const e=t.trim();if(!e)continue;const n=/^\?(\+)?\s*(.+)$/.exec(e);if(n){if(r.length>=5)break;r.push({q:n[2].trim().slice(0,140),multi:!!n[1],options:[]});continue}const o=r[r.length-1];if(!o)continue;const i=e.replace(/^[-*•]\s*/,"").replace(/^\d+[.)]\s*/,"").trim();!i||i.length>60||o.options.includes(i)||o.options.length<6&&o.options.push(i)}return{text:e.replace(Ql,"").replace(/\n{3,}/g,"\n\n").trim(),questions:r.filter(t=>t.q)}}function $l(t){if(t&&t._briefCard){try{t._briefCard.remove()}catch{}t._briefCard=null}}function tc(t,e,n,r){if($l(t),!t||!Array.isArray(n)||0===n.length)return;const o=Kl[e]||Kl.en,i=n.map(()=>new Set),a=n.map(()=>""),s=document.createElement("div");s.className="row cdtr-brief",s.dir="he"===e?"rtl":"ltr",n.forEach((t,e)=>{const n=document.createElement("div");n.className="cdtr-brief-q",n.setAttribute("role","group");const r=document.createElement("p");r.className="cdtr-brief-title",r.textContent=t.q,n.setAttribute("aria-label",t.q),n.appendChild(r);const l=document.createElement("div");l.className="cdtr-brief-opts";const c=[];t.options.forEach(n=>{const r=document.createElement("button");r.type="button",r.className="cdtr-chip cdtr-brief-opt",r.textContent=n,r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>{const r=i[e];r.has(n)?r.delete(n):(t.multi||r.clear(),r.add(n));for(const t of c)t.setAttribute("aria-pressed",String(r.has(t.textContent)))}),c.push(r),l.appendChild(r)}),n.appendChild(l);const d=document.createElement("input");d.type="text",d.className="cdtr-brief-other",d.placeholder=o.other,d.maxLength=200,d.addEventListener("input",()=>{a[e]=d.value}),d.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),h())}),n.appendChild(d),s.appendChild(n)});const l=document.createElement("div");l.className="cdtr-brief-actions";const c=document.createElement("button");c.type="button",c.className="cdtr-brief-go",c.textContent=o.go;const d=document.createElement("button");d.type="button",d.className="cdtr-brief-skip",d.textContent=o.skip,l.append(c,d),s.appendChild(l);let p=!1;function h(){let o=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(p||t._editInFlight)return;p=!0;const s=n.map((t,e)=>o?[]:[...t.options.filter(t=>i[e].has(t)),a[e].trim()].filter(Boolean));$l(t),r(function(t,e,n){const r=Kl[n]||Kl.en;return t.map((t,n)=>{const o=(e[n]||[]).filter(Boolean);return`${t.q.replace(/[?؟]\s*$/,"")}: ${o.length?o.join(", "):r.decide}`}).join("\n")}(n,s,e))}c.addEventListener("click",()=>h(!1)),d.addEventListener("click",()=>h(!0)),t._briefCard=s,ql(t,s,()=>t._briefCard===s)}var ec=a(38941),nc=a(58991);const rc=/```[ \t]*cx-gallery[ \t]*\r?\n([\s\S]*?)```/,oc={he:{pick:"בחירה מהגלריה",change:"החלפת התמונה",picked:t=>`בחרתי תמונה מהגלריה: ${t}`,swapAi:t=>`החלף את התמונה של האלמנט שבחרתי בתמונה הזו מהגלריה: ${t}`,uploadFailed:"לא הצלחנו לשמור את התמונה החתוכה בגלריה. נסו שוב."},en:{pick:"Choose from gallery",change:"Change image",picked:t=>`I picked this image from my gallery: ${t}`,swapAi:t=>`Replace the image of the element I selected with this one from my gallery: ${t}`,uploadFailed:"The cropped image could not be saved to your gallery. Please try again."}},ic=t=>oc["en"===t?"en":"he"];function ac(){return"undefined"!=typeof customElements&&!!customElements.get("cdtr-gallery")}function sc(){return new Promise(t=>{const e=document.createElement("cdtr-gallery");let n=!1;const r=r=>{if(!n){n=!0,dc();try{e.opened=!1,e.remove()}catch{}t(r)}};e.multi=!1,e.addEventListener("file",t=>{const e=t?.detail?.src;r("string"==typeof e&&/^https?:\/\//i.test(e)?e:null)}),e.addEventListener("close",()=>r(null)),document.body.append(e),e.opened=!0})}const lc=/\.(mp4|mov|webm|m4v|avi|mp3|wav|pdf|zip)(\?|$)/i;let cc=null;function dc(){cc=null}function pc(){if(cc&&Date.now()-cc.at<12e4)return cc.list;const t=I.M.get("config","editor","configure","mediaGalleryManager");if("function"!=typeof t)return Promise.resolve([]);const e=new Promise(e=>{let n=!1;const r=t=>{n||(n=!0,e(function(t){const e=[],n=new Set;for(const r of Array.isArray(t)?t:[]){const t=String(r?.src||r?.url||"").trim();if(!/^https:\/\//i.test(t)||t.length>2e3||lc.test(t)||n.has(t))continue;n.add(t);const o=String(r?.name||"").replace(/\s+/g," ").trim().slice(0,80);if(e.push({url:t,...o?{name:o}:{},...r?.isFavorite?{favorite:!0}:{}}),e.length>=50)break}return e}(t)))};setTimeout(()=>r([]),3e3);try{const e=new ec.A;e.files=[],e.close=()=>{};const n=()=>e.dispatch("load-files",{resolve:r});e.render=n,t(e),n()}catch(t){console.warn("[edit-chat] gallery list unavailable",t),r([])}});return cc={at:Date.now(),list:e},e}function hc(t){const e="string"==typeof t?t:"",n=rc.exec(e);if(!n)return{text:e,ask:null,auto:null};const r=String(n[1]||"").split("\n").map(t=>t.trim()).filter(Boolean);return{text:e.replace(rc,"").replace(/\n{3,}/g,"\n\n").trim(),ask:(r[0]||"").slice(0,60),auto:r[1]?r[1].slice(0,60):null}}function uc(t){if(t&&t._galleryRow){try{t._galleryRow.remove()}catch{}t._galleryRow=null}}function fc(t,e,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;if(uc(t),!t||!ac())return;const i=document.createElement("div");i.className="row cdtr-chip-row",i.dir="en"===e?"ltr":"rtl";const a=document.createElement("button");if(a.type="button",a.className="cdtr-chip cdtr-chip-primary",a.textContent=n?`${ic(e).pick}: ${n}`:ic(e).pick,a.addEventListener("click",async()=>{const n=await sc();n&&(uc(t),r(ic(e).picked(n)))}),i.appendChild(a),o){const e=document.createElement("button");e.type="button",e.className="cdtr-chip",e.textContent=o,e.addEventListener("click",()=>{uc(t),r(o)}),i.appendChild(e)}t._galleryRow=i,ql(t,i,()=>t._galleryRow===i)}function mc(t){if(!t||"object"!=typeof t)return!1;if("img"===String(t.tag||"").toLowerCase())return!0;const e=String(t.html||"");return/<img[\s>]/i.test(e)||/background(-image)?\s*:[^;"]*url\(/i.test(e)}function gc(t){const e=String(t?.html||""),n=/<img[^>]*\ssrc="(https?:[^"]+)"/i.exec(e)||/url\((?:"|["'])?(https?:[^"')&]+)/i.exec(e);return n?n[1]:""}const bc=["display:inline-flex","align-items:center","gap:8px","margin:2px 2px 6px","padding-block:5px","padding-inline:5px 12px","border-radius:999px","border:1px solid rgba(15,23,42,.12)","background:rgba(255,255,255,.82)","font-family:inherit","font-size:13px","font-weight:500","line-height:1.2","color:#0f172a","cursor:pointer"].join(";"),yc=["width:26px","height:26px","border-radius:50%","object-fit:cover","display:block","background:#eef0f3","flex:0 0 auto"].join(";");let Ac=null;function wc(t,e,n){let{getSelection:r,isBusy:o,swap:i,notify:a}=n;Ac&&window.removeEventListener("cdtr-ai-image-action",Ac),Ac=async t=>{const{key:n,action:s}=t.detail||{};if(o())return;const l=r();if(l&&l.key===n){if("replace"===s){if(!ac())return;const t=await sc();return void(t&&await i(t,l))}if("crop"===s){const n=String(t.detail.src||"")||gc(l);if(!n)return;(0,nc.f)({props:{src:n}},{onApply:async t=>{const n=await function(t){const e=I.M.get("config","editor","configure","mediaGalleryManager");return"function"!=typeof e||"string"!=typeof t?Promise.resolve(null):new Promise(n=>{let r=!1;const o=t=>{r||(r=!0,dc(),n("string"==typeof t&&/^https:\/\//i.test(t)?t:null))};setTimeout(()=>o(null),6e4);try{const n=atob(t.split(",")[1]||""),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const i=new File([r],`cropped-${Date.now()}.png`,{type:"image/png"}),a=new ec.A;a.files=[],a.close=()=>{};let s=!1;const l=()=>{s||(s=!0,a.dispatch("upload-file",{file:i,dirId:null,uploadId:`${i.name}`,execCommand:(t,e)=>{"src"===t&&o(e)},options:{},onProgress:()=>{}}))},c=()=>{a.events?.["upload-file"]&&l()};a.render=c,e(a),c()}catch(t){console.warn("[edit-chat] crop upload failed",t),o(null)}})}(t);n?await i(n,r()||l):a(ic(e).uploadFailed)}})}}},window.addEventListener("cdtr-ai-image-action",Ac)}const xc={en:"About",he:"לגבי"},vc=["display:inline-flex","align-items:center","gap:4px","max-width:100%","margin:2px 2px 6px","padding-block:3px","padding-inline:10px 4px","border-radius:999px","border:0","background:#efebff","color:#4c36c7","font:inherit","font-size:12px","box-sizing:border-box"].join(";"),kc=["display:grid","place-items:center","width:20px","height:20px","flex:none","padding:0","border:0","border-radius:50%","background:none","color:inherit","cursor:pointer"].join(";");function Cc(t,e,n){let{getSelection:r,onChange:o}=n;if(!t)return;const i=()=>{const n=r();let o=t._selectionChip;if(!n)return o?.remove(),void(t._selectionChip=null);if(!o){o=document.createElement("div"),o.setAttribute("slot","above-composer"),o.setAttribute("style",vc);const n=document.createElement("span");n.setAttribute("style","overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0");const r=document.createElement("button");r.type="button",r.setAttribute("style",kc),r.setAttribute("aria-label","he"===e?"בטל בחירה":"Clear selection"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>',r.addEventListener("click",ue),o.append(n,r),t.prepend(o),t._selectionChip=o}o.dir="en"===e?"ltr":"rtl",o.firstChild.textContent=`${xc[e]||xc.en}: ${(t=>{const e=fe(t),n=e.length>40?`${e.slice(0,40)}…`:e;return[me(t),n&&`"${n}"`].filter(Boolean).join(" ")})(n)}`};i(),o(i)}const _c={he:{title:"איזה כיוון הכי מתאים לכם?",sub:"בחרו כיוון והדף ייבנה ממנו.",pick:t=>`בחרתי: ${t}`,go:"בחירה",open:"הגדלה"},en:{title:"Which direction fits best?",sub:"Pick one and the page is built from it.",pick:t=>`I chose: ${t}`,go:"Choose",open:"Enlarge"}};let Ec=!1;function Sc(t){if(t&&t._dirPanel){try{t._dirPanel.remove()}catch{}t._dirPanel=null}}function Mc(t){return t&&"object"==typeof t&&"string"==typeof t.html&&t.html?{name:String(t.name||"").slice(0,60)||"direction",style:t.style,...t.mood?{mood:String(t.mood).slice(0,300)}:{},css:String(t.css||"").slice(0,3e4),html:t.html.slice(0,6e4)}:null}function Bc(t,e){!function(){if(Ec)return;Ec=!0;const t=document.createElement("style");t.textContent="\n .cdtr-dir-lightbox {\n position: fixed;\n inset: 0;\n z-index: 2147483001;\n background: rgba(24, 20, 22, 0.66);\n -webkit-backdrop-filter: blur(6px);\n backdrop-filter: blur(6px);\n display: grid;\n place-items: center;\n padding: 32px;\n cursor: zoom-out;\n animation: cdtr-dir-fade 0.2s ease both;\n }\n .cdtr-dir-lightbox img {\n max-width: min(1280px, 92vw);\n max-height: 86vh;\n border-radius: 12px;\n box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);\n animation: cdtr-dir-rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;\n }\n @keyframes cdtr-dir-fade { from { opacity: 0; } }\n @keyframes cdtr-dir-rise { from { transform: translateY(10px) scale(0.985); } }\n @media (prefers-reduced-motion: reduce) {\n .cdtr-dir-lightbox, .cdtr-dir-lightbox img { animation: none; }\n }\n ",document.head.appendChild(t)}();const n=document.createElement("div");n.className="cdtr-dir-lightbox",n.setAttribute("role","dialog");const r=document.createElement("img");r.src=t,r.alt=e,n.appendChild(r);const o=()=>n.remove();n.addEventListener("click",o),document.addEventListener("keydown",function t(e){"Escape"===e.key&&(o(),document.removeEventListener("keydown",t))}),document.body.appendChild(n)}function Tc(t,e,n,r){Sc(t);const o=(Array.isArray(n)?n:[]).filter(t=>t&&"string"==typeof t.image&&t.image.startsWith("data:image/"));if(!t||0===o.length)return;const i=_c[e]||_c.en,a=document.createElement("div");a.className="row cdtr-dir",a.dir="he"===e?"rtl":"ltr";const s=document.createElement("div");s.className="cdtr-dir-head";const l=document.createElement("p");l.className="cdtr-dir-title",l.textContent=i.title;const c=document.createElement("p");c.className="cdtr-dir-sub",c.textContent=i.sub,s.append(l,c),a.appendChild(s);const d=document.createElement("div");d.className="cdtr-dir-list";for(const e of o.slice(0,4)){const n=document.createElement("div");n.className="cdtr-dir-item";const o=document.createElement("button");o.type="button",o.className="cdtr-dir-card";const a=document.createElement("img");a.src=e.image,a.alt=e.name||"",a.loading="lazy";const s=document.createElement("span");s.className="cdtr-dir-meta";const l=document.createElement("span");l.className="cdtr-dir-text";const c=document.createElement("span");if(c.className="cdtr-dir-name",c.textContent=e.name||"",l.appendChild(c),e.mood){const t=document.createElement("span");t.className="cdtr-dir-mood",t.textContent=String(e.mood),l.appendChild(t)}const p=document.createElement("span");p.className="cdtr-dir-go",p.setAttribute("aria-hidden","true"),p.textContent=i.go,s.append(l,p),o.append(a,s),o.addEventListener("click",()=>{Sc(t),r(i.pick(e.name||""),Mc(e))});const h=document.createElement("button");h.type="button",h.className="cdtr-dir-zoom",h.setAttribute("aria-label",`${i.open}: ${e.name||""}`),h.title=i.open,h.innerHTML=Vl,h.addEventListener("click",t=>{t.stopPropagation(),Bc(e.image,e.name||"")}),n.append(o,h),d.appendChild(n)}a.appendChild(d),t._dirPanel=a,ql(t,a,()=>t._dirPanel===a)}const Lc="cdtr-ai-sidebar:tab",Ic={he:{empty:"עוד אין שיחות קודמות בדף הזה.",failed:"לא הצלחתי לטעון את השיחות.",untitled:"שיחה",current:"עכשיו",loading:"טוען…"},en:{empty:"No earlier conversations on this page yet.",failed:"Could not load the conversations.",untitled:"Conversation",current:"Current",loading:"Loading…"}};async function Oc(t,e,n){const r=e&&e._historyDeps;if(!t||!r)return;!function(t){const e=t.getRootNode?t.getRootNode():document,n=e instanceof ShadowRoot?e:document.head;if(e instanceof ShadowRoot?e.getElementById(Hc):document.getElementById(Hc))return;const r=document.createElement("style");r.id=Hc,r.textContent=zc,n.appendChild(r)}(t);const o="en"===r.lang?"en":"he",i=Ic[o],a={};t._listToken=a,t.className="cdtr-history",t.dir="en"===o?"ltr":"rtl",t.textContent=i.loading;const s=r.listPath();let l=[];try{if(!s)throw new Error("no document");const t=await r.request(s);l=Array.isArray(t?.sessions)?t.sessions.slice(0,30):[]}catch(e){return console.warn("[edit-chat] conversation list failed:",e),void(t._listToken===a&&(t.textContent=i.failed))}if(t._listToken===a){if(t.textContent="",0===l.length){const e=document.createElement("div");return e.className="cdtr-history-empty",e.textContent=i.empty,void t.appendChild(e)}for(const a of l){const s=document.createElement("button");s.type="button",s.className="cdtr-history-row"+(a.id===e._sessionId?" current":"");const l=document.createElement("span");l.className="cdtr-history-label",l.textContent=(a.preview||"").trim()||`${i.untitled} ${Nc(a.created_at,o)}`;const c=document.createElement("span");c.className="cdtr-history-when",c.textContent=a.id===e._sessionId?i.current:Nc(a.last_active_at??a.created_at,o),s.append(l,c),s.addEventListener("click",async()=>{if(!e._editInFlight){if(a.id!==e._sessionId)try{const t=await r.request(r.sessionPath(a.id));r.onOpen(a.id,Array.isArray(t?.messages)?t.messages:[])}catch(t){return void console.warn("[edit-chat] conversation load failed:",t)}"function"==typeof n&&n()}}),t.appendChild(s)}}}function Nc(t,e){const n="number"==typeof t?t:Date.parse(String(t||""));if(!Number.isFinite(n))return"";const r=n<1e12?1e3*n:n,o=Date.now()-r,i=36e5,a=24*i;if(o>7*a)return new Date(r).toLocaleDateString("en"===e?"en-GB":"he-IL",{day:"numeric",month:"short"});const s=new Intl.RelativeTimeFormat("en"===e?"en":"he",{numeric:"auto"});return o<i?s.format(-Math.max(1,Math.round(o/6e4)),"minute"):o<a?s.format(-Math.round(o/i),"hour"):s.format(-Math.round(o/a),"day")}const Hc="cdtr-history-styles",zc="\n .cdtr-history { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;\n font: 14px/1.45 Heebo, Arial, sans-serif; color: #6b6680; }\n .cdtr-history-empty { padding: 28px 8px; text-align: center; }\n .cdtr-history-row {\n display: flex; width: 100%; gap: 10px; align-items: baseline; justify-content: space-between;\n padding: 11px 12px; border: 0; border-radius: 12px; background: none; cursor: pointer;\n font: inherit; color: #16131f; text-align: start;\n }\n .cdtr-history-row:hover, .cdtr-history-row:focus-visible { background: rgba(40, 30, 80, 0.05); outline: none; }\n .cdtr-history-row.current { background: rgba(106, 76, 240, 0.09); }\n .cdtr-history-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .cdtr-history-when { flex: 0 0 auto; font-size: 12px; color: #6b6680; }\n";const Pc=`${(0,N.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/memories`,Dc="cdtr-ai-memory-changed",Rc={business:20,page:10,text:300};function jc(t){try{window.dispatchEvent(new CustomEvent(Dc,{detail:t||{}}))}catch{}}async function Fc(t){const e=!(!t||!t.forceRefresh),n="function"==typeof L.Ay.studioTokenProvider?L.Ay.studioTokenProvider:null;if(n)try{const t=await n({forceRefresh:e});if("string"==typeof t&&t.length>0)return t}catch(t){console.warn("[ai-memory] studioTokenProvider threw; falling back to editor.studioToken.",t)}return"string"==typeof L.Ay.studioToken&&L.Ay.studioToken.length>0?L.Ay.studioToken:null}async function qc(t,e,n,r){const o=await Fc({forceRefresh:r}),i={Accept:"application/json"};return void 0!==n&&(i["Content-Type"]="application/json"),o&&(i.Authorization=`Bearer ${o}`),fetch(e,{method:t,headers:i,body:void 0!==n?JSON.stringify(n):void 0})}async function Uc(t,e,n){try{let r=await qc(t,e,n,!1);401===r.status&&(r=await qc(t,e,n,!0));let o=null;try{o=await r.json()}catch{o=null}return r.ok||console.warn(`[ai-memory] ${t} failed: HTTP ${r.status}`,o),{ok:r.ok,status:r.status,data:o}}catch(e){return console.warn(`[ai-memory] ${t} error`,e),{ok:!1,status:0,data:null}}}async function Wc(t){const e=await Uc("DELETE",`${Pc}/${encodeURIComponent(t)}`);return{ok:e.ok||404===e.status,status:e.status}}function Vc(t){if(t&&t._memoryRow){try{t._memoryRow.remove()}catch{}t._memoryRow=null}}const Yc=/^image\/(png|jpe?g|webp|gif)$/i,Gc=/\.(html?|txt|md|css|json|csv|xml|svg)$/i;function Xc(t){return/<!doctype\s+html|<html[\s>]|<body[\s>]/i.test(String(t||""))}function Zc(t,e){t._attachments=[],t._files=[],t._attachLang=e,t.setAttribute("accept","image/png,image/jpeg,image/webp,image/gif,.html,.htm,.txt,.md,.css,.json,.csv,text/html,text/plain"),t.addEventListener("cdtr-chat:files",e=>{$c(t,e?.detail?.files||[])}),t.addEventListener("paste",e=>{const n=function(t){if(!t)return[];const e=Array.from(t.items||[]),n=e.filter(t=>"file"===t.kind&&Yc.test(t.type)).map(t=>t.getAsFile()).filter(Boolean);return n.length>0?n:Array.from(t.files||[]).filter(t=>Yc.test(t.type))}(e.clipboardData);if(n.length>0)return e.preventDefault(),void $c(t,n);const r=e.clipboardData?.getData("text/plain")||"";r.length<2e3||(e.preventDefault(),Jc(t,function(t){return Xc(t)?"page.html":function(t){return(String(t||"").match(/<[a-z][\w-]*[\s>]/gi)||[]).length>=5}(t)?"snippet.html":"pasted.txt"}(r),r))}),t.addEventListener("dragover",t=>{var e;(e=t.dataTransfer)&&Array.from(e.types||[]).includes("Files")&&t.preventDefault()}),t.addEventListener("drop",e=>{const n=Array.from(e.dataTransfer?.files||[]).filter(t=>Yc.test(t.type)||Gc.test(t.name));0!==n.length&&(e.preventDefault(),$c(t,n))})}function Qc(t){return(t._files||[]).map(t=>{let{name:e,text:n}=t;return{name:e,text:n}})}function Kc(t,e){t._files=(t._files||[]).filter(t=>t!==e&&t.text!==e?.text),sd(t)}function Jc(t,e,n){const r=String(n).slice(0,15e5);t._files=[...t._files||[],{name:e,text:r,size:r.length}].slice(-3),sd(t)}async function $c(t,e){for(const n of Array.from(e))try{if(Yc.test(n.type)){const e=await td(n);t._attachments=[...t._attachments||[],e].slice(-4)}else(Gc.test(n.name||"")||/^text\//.test(n.type||""))&&Jc(t,n.name||"file.txt",await n.text())}catch(t){console.warn("[edit-chat] could not read file",n?.name,t)}sd(t)}async function td(t){const e=await createImageBitmap(t),n=Math.min(1,1568/Math.max(e.width,e.height)),r=Math.max(1,Math.round(e.width*n)),o=Math.max(1,Math.round(e.height*n)),i=document.createElement("canvas");i.width=r,i.height=o;const a=i.getContext("2d");a.fillStyle="#ffffff",a.fillRect(0,0,r,o),a.drawImage(e,0,0,r,o),e.close?.();const s=i.toDataURL("image/jpeg",.85);return{media_type:"image/jpeg",b64:s.slice(s.indexOf(",")+1),preview:s}}const ed=["display:flex","gap:8px","padding:4px 2px","overflow-x:auto","align-items:center"].join(";"),nd=["position:relative","width:56px","height:56px","border-radius:8px","overflow:hidden","flex:0 0 auto","border:1px solid rgba(15,23,42,.12)","background:#fff"].join(";"),rd=["position:relative","height:56px","min-width:150px","max-width:220px","box-sizing:border-box","padding:8px 28px 8px 10px","border-radius:8px","flex:0 0 auto","display:flex","gap:8px","align-items:center","border:1px solid rgba(15,23,42,.12)","background:#fff","font:12px/1.3 system-ui,sans-serif","color:#0f172a","direction:ltr"].join(";"),od=["flex:0 0 auto","width:34px","height:34px","border-radius:6px","display:flex","align-items:center","justify-content:center","font:700 10px system-ui,sans-serif","color:#fff","background:#6366f1","text-transform:uppercase"].join(";"),id=["position:absolute","top:2px","inset-inline-end:2px","width:18px","height:18px","padding:0","border:0","border-radius:50%","background:rgba(15,23,42,.72)","color:#fff","font:12px/18px system-ui,sans-serif","cursor:pointer"].join(";");function ad(t,e){const n=document.createElement("button");return n.type="button",n.textContent="×",n.setAttribute("aria-label",t),n.setAttribute("style",id),n.addEventListener("click",e),n}function sd(t){const e=t._attachLang;let n=t._attachStrip;const r=t._attachments||[],o=t._files||[];if(0===r.length&&0===o.length)return n?.remove(),void(t._attachStrip=null);n||(n=document.createElement("div"),n.setAttribute("slot","above-composer"),n.setAttribute("style",ed),t.appendChild(n),t._attachStrip=n);const i="en"===e,a=o.map(e=>{const n=document.createElement("div");n.setAttribute("style",rd),n.title=e.name;const r=document.createElement("div");r.setAttribute("style",od),r.textContent=(e.name.split(".").pop()||"txt").slice(0,4);const o=document.createElement("div");o.setAttribute("style","min-width:0;overflow:hidden");const a=document.createElement("div");a.setAttribute("style","font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"),a.textContent=e.name;const s=document.createElement("div");var l;return s.setAttribute("style","color:#64748b"),s.textContent=(l=e.size||e.text.length)>=1024?`${Math.round(l/1024)} KB`:`${l} B`,o.append(a,s),n.append(r,o,ad(i?"Remove file":"הסרת קובץ",()=>Kc(t,e))),n}),s=r.map((e,n)=>{const r=document.createElement("div");r.setAttribute("style",nd);const o=document.createElement("img");return o.src=e.preview,o.alt="",o.setAttribute("style","width:100%;height:100%;object-fit:cover;display:block"),r.append(o,ad(i?"Remove image":"הסרת תמונה",()=>{t._attachments=(t._attachments||[]).filter((t,e)=>e!==n),sd(t)})),r});n.replaceChildren(...a,...s)}const ld={he:{title:"שפרו את הבקשה",busy:"משפר את הבקשה…",failed:"לא הצלחתי לשפר כרגע, נסו שוב",empty:"דף נחיתה לעסק שלי"},en:{title:"Improve my request",busy:"Improving your request…",failed:"Could not improve it right now, try again",empty:"A landing page for my business"}};function cd(t,e){const n=ld[e.lang]||ld.en;let r=null;const o=()=>t.shadowRoot?.querySelector("textarea");async function i(){if(!r||r.disabled||e.busy())return;const i=o(),a=String(t._draft??i?.value??"").trim()||n.empty;r.disabled=!0,r.classList.add("working");const s=i?.placeholder;i&&(i.placeholder=n.busy);try{const n=await e.improve(a);if(!n)throw new Error("empty");t._draft=n,i&&(i.value=n),t.requestUpdate?.(),requestAnimationFrame(()=>{const t=o();t&&(t.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),t.focus(),t.setSelectionRange(t.value.length,t.value.length))})}catch(t){return console.warn("[edit-chat] improve failed:",t),i&&(i.placeholder=n.failed),setTimeout(()=>{const t=o();t&&t.placeholder===n.failed&&(t.placeholder=s||"")},2600),r.disabled=!1,void r.classList.remove("working")}i&&(i.placeholder=s||""),r.disabled=!1,r.classList.remove("working")}const a=()=>{const e=t.shadowRoot;if(!e)return;if(!e.getElementById("cdtr-improve-styles")){const t=document.createElement("style");t.id="cdtr-improve-styles",t.textContent="\n .cdtr-improve { position: relative; }\n .cdtr-improve svg { display: block; }\n .cdtr-improve.working svg { animation: cdtr-improve-spin 1s linear infinite; }\n .cdtr-improve:not(:disabled):hover { color: #7c3aed; }\n @keyframes cdtr-improve-spin { to { transform: rotate(360deg); } }\n @media (prefers-reduced-motion: reduce) { .cdtr-improve.working svg { animation: none; } }\n",e.appendChild(t)}const o=e.querySelector(".tools");if(!o)return;if(r&&r.isConnected&&o.contains(r))return;r=r||(()=>{const t=document.createElement("button");return t.type="button",t.className="icon-btn cdtr-improve",t.title=n.title,t.setAttribute("aria-label",n.title),t.innerHTML='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3.5l1.8 4.7 4.7 1.8-4.7 1.8L12 16.5l-1.8-4.7L5.5 10l4.7-1.8z"/><path d="M18.5 15.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></svg>',t.addEventListener("click",i),t})();const a=o.querySelector(".spacer");o.insertBefore(r,a||null)},s=t.updated?.bind(t);t.updated=function(t){s?.(t),a()},Promise.resolve(t.updateComplete).then(a).catch(()=>{})}const dd=["createMailingList"];function pd(t){const e=t&&t.hostTools;return e&&"object"==typeof e?dd.filter(t=>"function"==typeof e[t]):[]}function hd(t,e){const n=t?.configure?.editorProps?.form;if(!n)return;const r={id:e.id,name:e.name,key:e.id,label:e.name};Array.isArray(n.mailingLists)?n.mailingLists.some(t=>String(t?.id??t?.key)===e.id)||n.mailingLists.push(r):n.mailingLists&&Array.isArray(n.mailingLists.items)?n.mailingLists.items.some(t=>String(t?.id??t?.key)===e.id)||n.mailingLists.items.push(r):n.mailingLists=[r]}async function ud(t,e,n){const r=e&&e.call_id;if(!r)return;const o=e.name,i=dd.includes(o)&&t?.hostTools&&t.hostTools[o];let a;if("function"!=typeof i)a={call_id:r,ok:!1,error:"This platform does not offer that action."};else try{const n=await function(t,e){let n;return Promise.race([t,new Promise((t,r)=>{n=setTimeout(()=>r(new Error("timeout")),e)})]).finally(()=>clearTimeout(n))}(Promise.resolve(i.call(t.hostTools,e.args||{})),55e3);if("createMailingList"===o){const o=n&&(n.id??n.key),i=null!=o&&""!==o?String(o):"";if(!i)throw new Error("The list was not created.");const s={id:i,name:String(n&&(n.name||n.label)||e.args?.name||i)};hd(t,s),a={call_id:r,ok:!0,result:s}}else a={call_id:r,ok:!0,result:n??null}}catch(t){const e=t&&"timeout"===t.message?"The platform did not answer in time.":String(t&&t.message||t||"failed");console.warn(`[edit-chat] host tool ${o} failed:`,t),a={call_id:r,ok:!1,error:e.slice(0,300)}}try{await n(a)}catch(t){console.warn("[edit-chat] host tool result not delivered:",t)}}var fd=a(3916);const md=/(?:https?:\/\/|www\.)[^\s<>"'`]+/i,gd=/[.,;:!?)\]}'"׳״”’]+$/,bd=new Set(["vimeo.com","player.vimeo.com","youtube.com","m.youtube.com","youtu.be","youtube-nocookie.com"]),yd=/\.(mp4|webm|mov|m4v|ogg|mp3|wav|png|jpe?g|gif|webp|svg|avif|pdf)$/i;function Ad(t){if("string"!=typeof t)return null;const e=md.exec(t);if(!e)return null;const n=e[0].replace(gd,"");let r=/^www\./i.test(n)?`https://${n}`:n;try{const t=new URL(r);if("http:"!==t.protocol&&"https:"!==t.protocol)return null;if(!t.hostname.includes("."))return null;if(function(t){const e=t.hostname.toLowerCase().replace(/^www\./,"");return bd.has(e)||yd.test(t.pathname)}(t))return null;r=t.toString()}catch{return null}return{url:r,rest:(t.slice(0,e.index)+t.slice(e.index+e[0].length)).replace(/\s+/g," ").trim()}}function wd(t){return"string"!=typeof t?0:t.replace(/<(script|style|noscript|template)\b[^>]*>[\s\S]*?<\/\1>/gi," ").replace(/<[^>]+>/g," ").replace(/&[a-z#0-9]+;/gi," ").replace(/\s+/g," ").trim().length}const xd=200;let vd=!1;vl.A.on(vl.q.ON_UNDO,()=>{vd=!0});const kd=(0,N.Ay)()?"http://127.0.0.1:8000/api/newsletter/chat-edit-v2":"https://studio.creaditor.ai/api/newsletter/chat-edit-v2",Cd=(0,N.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai",_d="/api/datastore/sessions/by-doc";function Ed(){return(0,T.zZ)()?"ai-page":"editor-panel"}const Sd="cdtr-edit:messages";function Md(t){return t?"":(0,T.zZ)()?`${Sd}:ai-page`:Sd}const Bd=[{id:"tighten",label:"קצר וחד יותר"},{id:"warmer",label:"הוסף חמימות"},{id:"cta",label:"חזק את הקריאה לפעולה"}],Td=[{id:"tighten",label:"Tighten the copy"},{id:"warmer",label:"Make it warmer"},{id:"cta",label:"Strengthen the CTA"}],Ld=[{id:"reviews",label:"הוסף ביקורות של לקוחות"},{id:"warmer",label:"שנה את הטון לחם ואישי יותר"},{id:"cta",label:"חזק את הכפתור הראשי"}],Id=[{id:"reviews",label:"Add customer reviews"},{id:"warmer",label:"Make the tone warmer and more personal"},{id:"cta",label:"Strengthen the main button"}],Od={he:"משווקטור",en:"Meshavektor"},Nd={he:"עצור",en:"Stop"},Hd={he:"חושב…",en:"Thinking…"},zd={he:t=>1===t?"בוצע שינוי אחד.":`בוצעו ${t} שינויים.`,en:t=>1===t?"Applied 1 change.":`Applied ${t} changes.`},Pd={he:t=>"\n\n⛔ נגמרו לכם הטוקנים באמצע העריכה, ולכן היא נעצרה. מה שכבר בוצע נשמר. יש להטעין יתרה כדי להמשיך."+(t?`\n${t}`:""),en:t=>"\n\n⛔ You ran out of tokens partway through, so the edit stopped here. What was already applied is kept. Top up your balance to continue."+(t?`\n${t}`:"")},Dd={he:t=>t>0?`\n\n⏳ הפעולה נעצרה באמצע כי היא הגיעה לתקרת האורך של תור בודד. ${1===t?"שינוי אחד שכבר בוצע נשמר":`${t} שינויים שכבר בוצעו נשמרו`} על הקנבס, אבל היא לא הסתיימה. אפשר לבקש להמשיך, או לפצל לבקשות קטנות יותר.`:"\n\n⏳ הפעולה נעצרה באמצע כי היא הגיעה לתקרת האורך של תור בודד, לפני שהספיקה לשנות משהו. הקנבס לא השתנה. אפשר לבקש להמשיך, או לפצל לבקשות קטנות יותר.",en:t=>t>0?`\n\nThe turn hit the per-turn ceiling and stopped partway. ${1===t?"1 change was":`${t} changes were`} applied and kept on the canvas, but it did not finish. Ask it to continue, or split the request into smaller steps.`:"\n\nThe turn hit the per-turn ceiling and stopped before it changed anything. The canvas was not modified. Ask it to continue, or split the request into smaller steps."},Rd={he:t=>`\n\n⚠️ ${1===t?"שינוי אחד לא הוחל":`${t} שינויים לא הוחלו`} על הקנבס. פרטים בקונסול (\`[edit-chat]\`).`,en:t=>`\n\n⚠️ ${1===t?"1 change was not applied":`${t} changes were not applied`} to the canvas. See the console (\`[edit-chat]\`) for details.`},jd={he:"\n\nℹ️ לא בוצע שינוי בקנבס בתור הזה.",en:"\n\nNo change was made to the canvas in this turn."},Fd={he:"⏹ העריכה הופסקה. שינויים שכבר בוצעו נשארו על הקנבס.",en:"⏹ Edit stopped. Any changes already applied are still on the canvas."},qd={he:{prefix:"⚠️ העריכה נכשלה",network:"לא ניתן להתחבר לשרת. בדקו את החיבור ונסו שוב.",auth:"פג תוקף ההרשאה. יש להתחבר מחדש.",generic:t=>`משהו השתבש: ${t}`},en:{prefix:"⚠️ Edit failed",network:"Could not connect to the server. Check your connection and try again.",auth:"Your session has expired. Please sign in again.",generic:t=>`Something went wrong: ${t}`}};function Ud(t,e){return t&&(t._turnError=!0),e}function Wd(t,e){let{isNetwork:n=!1,isAuth:r=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const o=qd[t]||qd.en;let i;return i=n?o.network:r?o.auth:o.generic("string"==typeof e?e:String(e)),`${o.prefix}\n\n${i}`}function Vd(t){t?._busyEl&&Fl(t,t._busyEl)}const Yd=new Set(["fetch_url","search_pexels","search_icons","read_page","read_element","find_in_page","screenshot","get_outline","get_component","get_business_profile","list_components_by_type","list_leaf_components","find_components_by_content","critique_newsletter"]),Gd={he:{propose_directions:"מצייר כיווני עיצוב…",generate_page:"בונה את הדף…",generate_section:"בונה סקשן…",adapt_section:"מתאים את הדף…",kit_apply_ops:"עורך את הדף…",read_page:"קורא את הדף…",read_element:"בודק את הדף…",find_in_page:"מחפש בדף…",screenshot:"מסתכל על הדף…",search_pexels:"מחפש תמונות…",search_icons:"מחפש אייקונים…",fetch_url:"קורא את הקישור…",get_outline:"סורק את מבנה הדף…",get_component:"בודק את הרכיב…",get_business_profile:"קורא את פרטי העסק…",list_components_by_type:"סורק את הדף…",list_leaf_components:"סורק את הדף…",find_components_by_content:"מחפש בדף…",critique_newsletter:"בוחן את העיצוב…",apply_patch_ops:"עורך את הדף…",format_text:"מעצב את הטקסט…",insert_section:"מוסיף סקשן…",replace_section:"מחליף סקשן…",delete_section:"מוחק סקשן…",create_mailing_list:"יוצר קבוצת דיוור…"},en:{propose_directions:"Drawing looks for you to pick from…",generate_page:"Building the page…",generate_section:"Building a section…",adapt_section:"Adapting the page…",kit_apply_ops:"Editing the page…",create_mailing_list:"Creating a mailing list…",read_page:"Reading the page…",read_element:"Checking the page…",find_in_page:"Searching the page…",screenshot:"Looking at the page…",search_pexels:"Finding photos…",search_icons:"Finding icons…",fetch_url:"Reading the link…",get_outline:"Scanning the page layout…",get_component:"Checking an element…",get_business_profile:"Reading your business details…",list_components_by_type:"Scanning the page…",list_leaf_components:"Scanning the page…",find_components_by_content:"Searching the page…",critique_newsletter:"Reviewing the design…",apply_patch_ops:"Editing the page…",format_text:"Formatting text…",insert_section:"Adding a section…",replace_section:"Replacing a section…",delete_section:"Removing a section…"}},Xd={he:{read:"בודק את זה",edit:"משנה את זה",found:"מצאתי"},en:{read:"Looking at this",edit:"Changing this",found:"Found"}};function Zd(t,e,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Xl(t),Vc(t),$l(t),uc(t),Sc(t),t._busyEl&&$d(t);const o=t.shadowRoot?.querySelector("textarea");o&&(o.disabled=!0,t._busyTextarea=o),t._busyButtons=[...t.shadowRoot?.querySelectorAll("button")||[]].filter(t=>!t.disabled&&!t.classList.contains("send")&&!t.classList.contains("cdtr-edit-stop"));for(const e of t._busyButtons)e.disabled=!0;var i,a;document.documentElement.classList.add("cdtr-ai-turn"),t._busyRemote=!!r.remote,r.remote||(i=rp(),a={lang:e,userText:r.userText||""},i&&(cl&&cl!==i&&wl(),cl=i,dl=a||null,gl("start",i,{info:dl}),clearInterval(pl),pl=setInterval(()=>gl("ping",i,{info:dl}),4e3)));const s=document.createElement("div");s.className="row assistant cdtr-edit-row",s.dir="he"===e?"rtl":"ltr";const l=document.createElement("div");l.className="bubble cdtr-edit-bubble",s.appendChild(l);const c=document.createElement("div");c.className="cdtr-edit-busy-head";const d=document.createElement("cdtr-ai-face");d.className="cdtr-edit-face",c.appendChild(d),t._turnError=!1,(0,Vt.L)("thinking");const p=document.createElement("span");p.className="cdtr-edit-busy-label",p.textContent=Hd[e]||Hd.en,c.appendChild(p);const h=document.createElement("span");h.className="cdtr-edit-elapsed",h.textContent="0:00",c.appendChild(h);const u=Date.now();if(t._busyTimer=setInterval(()=>{h.textContent=function(t){const e=Math.max(0,Math.floor(t/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}(Date.now()-u),s.isConnected||Vd(t)},1e3),!r.remote){const r=document.createElement("button");r.type="button",r.className="cdtr-edit-stop",r.textContent=Nd[e]||Nd.en,r.addEventListener("click",()=>{try{n?.abort()}catch{}}),t._abortTurn=()=>{try{n?.abort()}catch{}},c.appendChild(r)}l.appendChild(c);const f=document.createElement("div");f.className="cdtr-edit-thinking",f.setAttribute("dir","auto"),l.appendChild(f),t._thinkingEl=f,t._busyEl=s,t._busyBubble=l,t.classList.add("cdtr-edit-busy-on"),Vd(t),Promise.resolve(t.updateComplete).then(()=>Vd(t)).catch(()=>{})}function Qd(t,e){const n=t._thinkingEl;n&&t._busyEl&&(n.textContent=(n.textContent+e).replace(/\*\*/g,""),t._busyRemote||Al("thinking",e),t._busyBubble?.classList.add("has-thinking"),n.scrollTop=n.scrollHeight,Vd(t))}function Kd(t){const e=t._thinkingEl;e&&(t._busyRemote||Al("reset"),e.textContent="",t._busyBubble?.classList.remove("has-thinking"))}function Jd(t,e){const n=t?._busyEl?.querySelector(".cdtr-edit-busy-label");n&&e&&(n.textContent=e),n&&e&&!t._busyRemote&&Al("label",e)}function $d(t){t._busyEl&&(0,Vt.L)(t._turnError?"error":"happy"),t._busyTimer&&(clearInterval(t._busyTimer),t._busyTimer=null),t._busyEl&&(t._busyEl.remove(),t._busyEl=null),t._busyBubble=null,t._thinkingEl=null,t.classList?.remove("cdtr-edit-busy-on"),t._busyTextarea&&(t._busyTextarea.disabled=!1,t._busyTextarea=null);for(const e of t._busyButtons||[])e.disabled=!1;t._busyButtons=null,document.documentElement.classList.remove("cdtr-ai-turn"),(0,Vt.QG)([]),t._busyRemote||wl(),t._busyRemote=!1}const tp={he:"הבינה המלאכותית עובדת על הדף הזה בלשונית אחרת. אפשר להמשיך כשהיא תסיים.",en:"The AI is working on this page in another tab. You can continue when it finishes."};function ep(t,e){const n=rp(),r=xl(n);if(r===!!t._remoteLock)return;t._remoteLock=r;const o=t.shadowRoot?.querySelector("textarea");if(r){o&&(o.disabled=!0),t.placeholder=tp[e]||tp.en;const r=function(t){for(const e of hl.values())if(e.docId===t)return e.info;return null}(n);if(!t._editInFlight&&!t._busyEl){const n="en"===r?.lang?"en":"he"===r?.lang?"he":e;r?.userText&&t.appendMessage?.({role:"user",text:r.userText,ts:Date.now()}),Zd(t,n,null,{remote:!0})}return}t._busyRemote&&$d(t),o&&!t._busyEl&&(o.disabled=!1),t.placeholder=t._contextPlaceholder||"",t._editInFlight||lp(t)}function np(t,e){return!!xl(rp())&&(t.appendMessage?.({role:"assistant",text:tp[e]||tp.en,ts:Date.now()}),!0)}function rp(){try{const t=I.M.get("app","_id");return"string"==typeof t&&t.length>0?t:null}catch(t){return null}}function op(t,e,n){const r=()=>{t._pendingDirection=n,t._submitChip?.(e)};if(!t._editInFlight)return r();t._stoppedForPick=!0,t._abortTurn?.();const o=Date.now(),i=()=>{if(!t._editInFlight)return r();Date.now()-o>8e3||setTimeout(i,120)};setTimeout(i,120)}function ip(t){const e="string"==typeof t.content?t.content:"";return"assistant"===t.role?Gl(Jl(hc(e).text).text).text:e}function ap(t,e){const n=e.filter(t=>t&&("user"===t.role||"assistant"===t.role)).pop();if(!n||"assistant"!==n.role)return;const r=jl(t),o=n.attachments&&Array.isArray(n.attachments.directions)?n.attachments.directions:null;o&&o.length>0&&Tc(t,r,o,(e,n)=>op(t,e,n));const i=hc("string"==typeof n.content?n.content:"");null!==i.ask&&fc(t,r,i.ask,e=>t._submitChip?.(e),i.auto);const a=i.text,s=Jl(a);if(s.questions.length>0)return void tc(t,r,s.questions,e=>t._submitChip?.(e));const l=Gl(a);l.chips.length>0&&Zl(t,r,l.chips,l.kind,e=>t._submitChip?.(e))}async function sp(t){const e=await mp(L.Ay,{forceRefresh:!1});if(!e)throw new Error("no studio token");const n=await fetch(`${Cd}${t}`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`}});if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function lp(t){const e=rp();if(!e)return;t.storageKey="";const n=t.messages||[],r=t._chatEpoch||0;let o=null;try{o=await mp(L.Ay,{forceRefresh:!1})}catch(t){return}if(!o)return;const i=`${Cd}${_d}?doc_id=${encodeURIComponent(e)}&surface=${Ed()}`;try{const e=await fetch(i,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${o}`}});if(!e.ok)return void console.warn(`[edit-chat] transcript load failed: HTTP ${e.status}`);const a=await e.json();t._sessionId="string"==typeof a?.session_id?a.session_id:null;const s=Array.isArray(a?.messages)?a.messages:[];if(0===s.length)return;if((t._chatEpoch||0)!==r)return;const l=s.filter(t=>t&&("user"===t.role||"assistant"===t.role)).map(t=>({role:t.role,text:ip(t),ts:"number"==typeof t.created_at?t.created_at:Date.now()})).filter(t=>t.text.length>0);t.messages=function(t,e,n){const r=e.length<=n.length&&e.every((t,e)=>n[e]===t)?n.slice(e.length):n;if(0===r.length)return t;const o=t=>`${t.role}\0${t.text}`;let i=Math.min(t.length,r.length);for(;i>0;){const e=t.slice(t.length-i).map(o),n=r.slice(0,i).map(o);if(e.every((t,e)=>t===n[e]))break;i--}return[...t,...r.slice(i)]}(l,n,t.messages||[]),0===n.length&&Promise.resolve(t.updateComplete).then(()=>ap(t,s)).catch(()=>{})}catch(t){console.warn("[edit-chat] transcript load failed:",t)}}const cp={he:{tokens:"טוקנים",low:"יתרה נמוכה",empty:"נגמרו הטוקנים"},en:{tokens:"tokens",low:"Low balance",empty:"Out of tokens"}};function dp(t){const e=Math.max(0,Math.round(t));if(e<1e3)return String(e);if(e<1e6){const t=e/1e3,n=t<10?t.toFixed(1).replace(/\.0$/,""):String(Math.round(t));if("1000"!==n)return`${n}K`}const n=e/1e6;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}M`}const pp="cdtr-ai-balance";let hp=null;function up(t,e,n,r){if(!t)return;const o=t.querySelector(":scope > .cdtr-balance")||t.shadowRoot&&t.shadowRoot.querySelector(".cdtr-balance")||null;if("number"!=typeof n||Number.isNaN(n))return void o?.remove();r&&(t._balancePaymentUrl=r);const i=r||t._balancePaymentUrl||"";!function(){if(document.getElementById("cdtr-balance-styles"))return;const t=document.createElement("style");t.id="cdtr-balance-styles",t.textContent="\n .cdtr-balance {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 26px;\n padding: 0 8px;\n margin-inline-end: 2px;\n border-radius: 8px;\n border: 0;\n background: transparent;\n color: #6f676b;\n font-size: 12px;\n font-weight: 500;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n text-decoration: none;\n cursor: default;\n }\n .cdtr-balance.is-low { color: #8a5a00; background: #fbf4e6; }\n .cdtr-balance.is-empty { color: #a3261f; background: #fdf1f0; }\n /* Only clickable when there is somewhere to send them. */\n .cdtr-balance[href] { cursor: pointer; }\n .cdtr-balance[href]:hover { text-decoration: underline; text-underline-offset: 3px; }\n .cdtr-balance-dot {\n width: 6px; height: 6px; border-radius: 50%;\n background: currentColor; opacity: 0.55; flex: none;\n }\n ",document.head.appendChild(t)}();const a=cp[e]||cp.en,s=n<=0,l=!s&&n<4e4;!function(t){hp=t;try{window.dispatchEvent(new CustomEvent(pp,{detail:t}))}catch{}}({balance:n,url:i,low:l,empty:s,text:s?a.empty:dp(n),title:`${n.toLocaleString()} ${a.tokens}${l?` -- ${a.low}`:""}`});const c=!!i&&(l||s),d=o&&"A"===o.tagName!==c;d&&o.remove();let p=d?null:o;if(!p&&(p=document.createElement(c?"a":"span"),p.className="cdtr-balance",p.setAttribute("slot","header-extra"),t.appendChild(p),null===p.assignedSlot)){const e=t.shadowRoot&&t.shadowRoot.querySelector(".header-actions");if(!e)return p.remove(),void(t._balanceAnchorWarned||(t._balanceAnchorWarned=!0,console.warn("[edit-chat] balance pill: no header-extra slot and no .header-actions; skipping")));if(p.removeAttribute("slot"),e.prepend(p),!t.shadowRoot.getElementById("cdtr-balance-styles")){const e=document.getElementById("cdtr-balance-styles");e&&t.shadowRoot.appendChild(e.cloneNode(!0))}}p.classList.toggle("is-low",l),p.classList.toggle("is-empty",s),c&&(p.setAttribute("href",i),p.setAttribute("target","_blank"),p.setAttribute("rel","noopener noreferrer"));const h=s?a.empty:`${dp(n)} ${a.tokens}`;p.textContent="";const u=document.createElement("span");u.className="cdtr-balance-dot",p.appendChild(u),p.appendChild(document.createTextNode(h)),p.title=s?a.empty:`${n.toLocaleString()} ${a.tokens}${l?` -- ${a.low}`:""}`}function fp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e="en"===t.lang?"en":"he",n=t.endpoint||kd,r=document.createElement("cdtr-chat");r.setAttribute("lang",e),function(){if(document.getElementById(Dl))return;const t=document.createElement("link");t.id=Dl,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Assistant:wght@400;500;600;700&family=Frank+Ruhl+Libre:wght@400;500&display=swap",document.head.appendChild(t)}(),r.setAttribute("variant","studio"),r.style.setProperty("--cdtr-chat-font","Arial, Helvetica, sans-serif"),r.style.setProperty("--cdtr-chat-display-font","Arial, Helvetica, sans-serif");const o=document.createElement("cdtr-ai-face");o.setAttribute("slot","avatar"),o.style.setProperty("--face-size","68px"),r.appendChild(o);let i=null;r.addEventListener("input",()=>{r._busyEl||((0,Vt.L)("listening"),clearTimeout(i),i=setTimeout(()=>{r._busyEl||(0,Vt.L)("idle")},1400))}),r.closable=!1,r.addEventListener("cdtr-chat:close",()=>(0,T.$7)()),Promise.resolve(r.updateComplete).then(()=>Wl(r)).catch(()=>{}),r.setAttribute("storage-key",Md(rp())),r.setAttribute("header","he"===e?"שיחה חדשה":"New conversation"),r.setAttribute("greeting","he"===e?`היי, אני ${Od.he}`:`Hi, I'm ${Od.en}`);const a="he"===e;let s=null;const l=t=>{r._contextPlaceholder=t,r._remoteLock||(r.placeholder=t)},c=()=>{const t=(0,T.zZ)()&&El(I.M.get(T.yS))?"new-page":(0,T.zZ)()?"page":"components";t!==s&&(s=t,"new-page"===t?(r.setAttribute("prompt",a?"מה בונים היום?":"What are we building today?"),l(a?"למשל: סטודיו פילאטיס בגבעתיים, שיעור ניסיון ב-49 ₪, וואטסאפ 050-1234567":"e.g. Pilates studio in Brooklyn, first class $15, WhatsApp +1 555 123 4567"),r.actions=[]):"page"===t?(r.setAttribute("prompt",a?"מה לשנות בדף?":"What should we change?"),l(""),r.actions=a?Ld:Id):(r.setAttribute("prompt",a?"מה לערוך?":"What should I edit?"),l(""),r.actions=a?Bd:Td))};var d;c(),I.M.connect(T.n6,c),I.M.connect(T.yS,c),d=t=>{t===rp()&&ep(r,e)},ml(),ul.add(d),function(t){ml(),fl.add(t)}((t,e,n)=>{if(t===rp()){if("doc"===e){if(!(0,T.zZ)()||!n||"string"!=typeof n.html)return;return Nt(),o=n,_t.add(o),void I.M.set({[T.yS]:n})}var o;r._busyRemote&&("thinking"===e&&"string"==typeof n?Qd(r,n):"reset"===e?Kd(r):"label"===e&&"string"==typeof n&&Jd(r,n))}}),I.M.connect(T.yS,()=>{null!==cl&&r._busyEl&&!r._busyRemote&&Al("doc",I.M.get(T.yS))}),Promise.resolve(r.updateComplete).then(()=>ep(r,e)).catch(()=>{}),Zc(r,e);const p=async(t,n)=>{const o=I.M.get(T.yS),i=o?jt.imageSwapOps(o,n.key,t):null,a=i?Ip(T.o6,i):null;if(a&&a.applied>0){const t=jt.selectionContext(I.M.get(T.yS),n.key);return void(t&&I.M.set({kitSelection:{...n,...t}}))}r._submitChip?.(function(t,e){return ic(t).swapAi(e)}(jl(r,e),t))},h=()=>(0,T.zZ)()?I.M.get("kitSelection"):null;Cc(r,e,{getSelection:h,onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t),I.M.connect(T.cP,t)}}),function(t,e,n){let{getSelection:r,onChange:o,isBusy:i,swap:a}=n;if(!t)return;const s=()=>{const n=r(),o=ac()&&mc(n);let s=t._swapBtn;if(!o)return s?.remove(),void(t._swapBtn=null);s||(s=document.createElement("button"),s.type="button",s.setAttribute("slot","above-composer"),s.setAttribute("style",bc),s.addEventListener("click",async()=>{if(i())return;const t=r();if(!mc(t))return;const e=await sc();e&&await a(e,t)}),t.appendChild(s),t._swapBtn=s),s.dir="en"===e?"ltr":"rtl";const l=gc(n),c=document.createElement("span");if(c.textContent=ic(e).change,l){const t=document.createElement("img");t.alt="",t.src=l,t.setAttribute("style",yc),t.addEventListener("error",()=>t.remove()),s.style.paddingInlineStart="5px",s.replaceChildren(t,c)}else s.style.paddingInlineStart="12px",s.replaceChildren(c)};s(),o(s)}(r,e,{getSelection:h,onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t)},isBusy:()=>!!r._editInFlight,swap:p}),wc(0,e,{getSelection:h,isBusy:()=>!!r._editInFlight,swap:p,notify:t=>r.appendMessage?.({role:"assistant",text:t,ts:Date.now()})}),Pe(r,e,{getSelection:h,getDoc:()=>I.M.get(T.yS),onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t)},onDocChange:t=>(I.M.connect(T.yS,t),()=>I.M.disconnect(t)),isBusy:()=>!!r._editInFlight,fields:()=>L.Ay?.configure?.editorProps?.form?.fields||[],mailingLists:()=>_p(L.Ay).formConfig?.mailingLists||[],hasFieldHook:t=>"function"==typeof L.Ay?.formHooks?.[t],approveField:(t,e)=>(0,fd.f)(t,e),addToCatalog:(t,e)=>{const n=L.Ay?.configure?.editorProps?.form;if(!n||!t)return;Array.isArray(n.fields)||(n.fields=[]);const r=n.fields.findIndex(n=>n===e||n&&null!=t.id&&n.id===t.id);-1===r?n.fields.push(t):n.fields[r]={...n.fields[r],...t}},createList:"function"==typeof L.Ay?.hostTools?.createMailingList?async t=>{const e=await L.Ay.hostTools.createMailingList({name:t,description:""}),n=e&&(e.id??e.key);if(null==n||""===n)return null;const r={id:String(n),name:String(e&&(e.name||e.label)||t)};return hd(L.Ay,r),r}:null,apply:t=>{const e=Ip(T.o6,t);if(!e||0===e.applied)return!1;const n=I.M.get("kitSelection"),r=n&&jt.selectionContext(I.M.get(T.yS),n.key);return r&&I.M.set({kitSelection:{...n,...r}}),!0}}),cd(r,{lang:e,busy:()=>!!r._editInFlight,improve:async t=>{const e=await mp(L.Ay,{forceRefresh:!1});if(!e)throw new Error("no studio token");const n=I.M.get(T.yS),r=I.M.get("kitSelection"),o=r&&(r.label||r.text)?`${r.label||""}${r.text?`: ${String(r.text).slice(0,300)}`:""}`:void 0,i=await fetch(`${Cd}/api/prompt-improve`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({text:t,page:n&&!El(n)?"existing":"new",...o?{selection:o.slice(0,400)}:{}})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const a=await i.json();return"string"==typeof a?.text?a.text:""}}),function(t,e){t._historyDeps=e}(r,{lang:e,request:sp,listPath:()=>{const t=rp();return t?`${_d}/list?doc_id=${encodeURIComponent(t)}&surface=${Ed()}&limit=30`:null},sessionPath:t=>`/api/datastore/sessions/${encodeURIComponent(t)}`,onOpen:(t,e)=>{r._chatEpoch=(r._chatEpoch||0)+1,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=t,r._newSession=!1,r.messages=e.filter(t=>t&&("user"===t.role||"assistant"===t.role)).map(t=>({role:t.role,text:ip(t),ts:"number"==typeof t.created_at?t.created_at:Date.now()})).filter(t=>t.text.length>0),Promise.resolve(r.updateComplete).then(()=>ap(r,e)).catch(()=>{})}}),r.setAttribute("header",Od[e]||Od.en);const u=()=>{!async function(t,e){try{const n=L.Ay,r=await mp(n);if(!r)return;const o=await fetch(`${Cd}/api/business-analyze/balance`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});if(!o.ok)return;const i=await o.json();up(t,e,i&&i.balance,i&&i.paymentUrl)}catch(t){console.warn("[edit-chat] balance probe failed; pill not shown",t)}}(r,e)};r.updateComplete&&"function"==typeof r.updateComplete.then?r.updateComplete.then(u).catch(u):setTimeout(u,0),r._refreshBalance=u,r.addEventListener("cdtr-chat:submit",t=>{if(r._editInFlight)return void console.log("[edit-chat] submit ignored: previous edit still streaming");const o=t?.detail?.text;if("string"!=typeof o||!o.trim())return;const i=r._pendingLinkText;if(r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),i)return r.appendMessage?.({role:"user",text:o.trim(),ts:Date.now()}),void vp(r,n,e,`${i}\n${o.trim()}`,{userBubbleShown:!0});const a="web"===I.M.get("config","channel")?function(t){return(t._files||[]).find(t=>!t.reference&&Xc(t.text))||null}(r):null;if(a)return void async function(t,e,n,r,o){const i=/[\u0590-\u05FF]/.test(r)||!r&&"he"===n,a=i?xp.he:xp.en;t.appendMessage?.({role:"user",text:r,ts:Date.now()});const s=()=>{o.reference=!0,vp(t,e,n,r,{userBubbleShown:!0})},l=()=>{if(wd(o.text)<200)return t.appendMessage?.({role:"assistant",text:a.shell,ts:Date.now()}),void s();Ft(o.text,""),Kc(t,o),console.log(`[edit-chat] page opened from attached ${o.name} (${o.text.length}ch)`),t.appendMessage?.({role:"assistant",text:a.opened(o.name),ts:Date.now()})},c=I.M.get(T.yS);if((0,T.zZ)()&&(!c||El(c)))return void l();t.appendMessage?.({role:"assistant",text:a.ask(o.name),ts:Date.now()}),Zl(t,n,[a.open,a.reference],"confirm",e=>{Xl(t),Vc(t),$l(t),uc(t),Sc(t),e===a.open?l():s()})}(r,n,e,o.trim(),a);const s="web"===I.M.get("config","channel")?Ad(o.trim()):null;s?async function(t,e,n,r,o){const i=/[\u0590-\u05FF]/.test(o.rest)||!o.rest&&"he"===n,a=i?wp.he:wp.en;let s=o.url;try{s=new URL(o.url).hostname.replace(/^www\./,"")}catch{}t.appendMessage?.({role:"user",text:r,ts:Date.now()});const l=async()=>{if(np(t,i?"he":"en"))return;t._editInFlight=!0;const l=new AbortController;let c;Zd(t,n,l,{userText:r}),Jd(t,a.opening);try{c=await async function(t,e){const n=async n=>{const r=await mp(L.Ay,{forceRefresh:n}),o={"Content-Type":"application/json",Accept:"application/json"};return r&&(o.Authorization=`Bearer ${r}`),fetch(`${Cd}${Ap}`,{method:"POST",headers:o,body:JSON.stringify({url:t}),signal:e})};try{let e=await n(!1);401===e.status&&(e=await n(!0));const r=await e.json().catch(()=>({}));return e.ok?"string"!=typeof r?.html?{ok:!1,reason:"the response had no page in it"}:{ok:!0,html:r.html,finalUrl:r.finalUrl||t}:{ok:!1,reason:r?.reason||`status ${e.status}`}}catch(t){return{ok:!1,reason:t?.message||String(t)}}}(o.url,l.signal)}finally{t._editInFlight=!1,t.busy=!1,$d(t)}if(!l.signal.aborted)if(c.ok)if(wd(c.html)<xd)t.appendMessage?.({role:"assistant",text:a.shell(s),ts:Date.now()});else{if(Ft(c.html,c.finalUrl),console.log(`[edit-chat] page copied from ${c.finalUrl} (${c.html.length}ch)`),!o.rest)return t.appendMessage?.({role:"assistant",text:a.opened(s),ts:Date.now()}),void Zl(t,n,[a.adapt],"options",e=>t._submitChip?.(e));vp(t,e,n,r,{userBubbleShown:!0})}else t.appendMessage?.({role:"assistant",text:a.failed(s,c.reason),ts:Date.now()})},c=I.M.get(T.yS);if((0,T.zZ)()&&(!c||El(c)))return void await l();t.appendMessage?.({role:"assistant",text:a.ask(s),ts:Date.now()}),t._pendingLinkText=r,Zl(t,n,[a.copy,a.useLink],"confirm",o=>{t._pendingLinkText=null,Xl(t),Vc(t),$l(t),uc(t),Sc(t),o===a.copy?l():vp(t,e,n,r,{userBubbleShown:!0})})}(r,n,e,o.trim(),s):vp(r,n,e,o.trim())}),r._submitChip=t=>{r._editInFlight||vp(r,n,e,t)},r.addEventListener("cdtr-chat:new",()=>{r._chatEpoch=(r._chatEpoch||0)+1,r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=null,r._newSession=!0});let f=Ed();return I.M.connect(T.n6,()=>{const t=Ed();if(t===f)return;f=t,r._chatEpoch=(r._chatEpoch||0)+1,r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=null,r._newSession=!1,r.messages=[];rp()?lp(r):r.storageKey=Md(null)}),r.addEventListener("cdtr-chat:action",t=>{if(r._editInFlight)return void console.log("[edit-chat] action ignored: previous edit still streaming");const o=t?.detail?.label;"string"==typeof o&&o&&vp(r,n,e,o)}),r}async function mp(t,e){const n=!(!e||!e.forceRefresh),r="function"==typeof t.studioTokenProvider?t.studioTokenProvider:null;if(r)try{const t=await r({forceRefresh:n});if("string"==typeof t&&t.length>0)return t}catch(t){console.warn("[edit-chat] studioTokenProvider threw; falling back to editor.studioToken.",t)}return"string"==typeof t.studioToken&&t.studioToken.length>0?t.studioToken:null}async function gp(t,e,n,r){const{forceRefresh:o=!1,onEvent:i=null,signal:a}=r||{},s=await mp(t,{forceRefresh:o});s||console.warn("[edit-chat] no auth token (neither editor.studioTokenProvider nor editor.studioToken yielded one); request will likely 401 from scopeGate."),o&&console.log("[edit-chat] retry attempt with refreshed token; token-present=",null!=s);const l={"Content-Type":"application/json",Accept:"text/event-stream, application/json"};s&&(l.Authorization=`Bearer ${s}`);let c=null;try{c=await fetch(e,{method:"POST",headers:l,body:JSON.stringify(n),signal:a})}catch(t){throw t}if((c.headers.get("content-type")||"").includes("text/event-stream")&&c.body&&i)return await async function(t,e){const n=t.getReader(),r=new TextDecoder;let o="";try{for(;;){const{done:t,value:i}=await n.read();if(t)break;let a;for(o+=r.decode(i,{stream:!0});-1!==(a=o.indexOf("\n\n"));){const t=o.slice(0,a);o=o.slice(a+2);let n,r="message",i="";for(const e of t.split("\n"))e.startsWith("event:")?r=e.slice(6).trim():e.startsWith("data:")&&(i+=(i?"\n":"")+e.slice(5).replace(/^ /,""));if(i){try{n=JSON.parse(i)}catch(t){console.warn("[edit-chat] sse data parse failed event="+r,t);continue}try{await e(r,n)}catch(t){console.warn("[edit-chat] sse handler threw event="+r,t)}}}}}finally{try{n.releaseLock()}catch{}}}(c.body,i),{resp:c,body:null,streamed:!0};let d=null;try{d=await c.json()}catch{d=null}return{resp:c,body:d,streamed:!1}}const bp=new Set(["edit","section","page","adapt"]);function yp(t){const e=function(t){return Array.isArray(t)?t.map(t=>{if(!t||"root"!==t.type)return t;const e=Object.prototype.hasOwnProperty.call(t,"aiDocParked"),n=t.props&&Object.prototype.hasOwnProperty.call(t.props,"aiDocParked");if(!e&&!n)return t;const{aiDocParked:r,...o}=t;if(!n)return o;const i={...t.props};return delete i.aiDocParked,{...o,props:i}}):t}((0,H.U2)());if(!bp.has(t))return e;const n=Array.isArray(e)?e:[],r=n.find(t=>t&&"root"===t.type)||n[0];if(!r)return e;const{aiDoc:o,...i}=r,a={...i.props||{}};return delete a.aiDoc,[{...i,props:a,children:[]}]}const Ap="/api/page-fetch",wp={he:{ask:t=>`להעתיק את הדף מ-${t} במקום הדף שעל הקנבס?`,opening:"פותח את הדף…",copy:"להעתיק את הדף",useLink:"לא, רק להשתמש בקישור",failed:(t,e)=>`לא הצלחתי לפתוח את ${t}: ${e}`,shell:t=>`הדף ב-${t} נבנה בדפדפן עם JavaScript, אז מה שמגיע ממנו ריק. אפשר לפתוח אותו בדפדפן, להעתיק את ה-HTML ולהדביק דרך Import HTML.`,opened:t=>`פתחתי את הדף מ-${t} כמו שהוא. מה לשנות בו?`,adapt:"תתאים את הדף לעסק שלי"},en:{ask:t=>`Copy the page from ${t} over the one on the canvas?`,opening:"Opening the page…",copy:"Copy the page",useLink:"No, just use the link",failed:(t,e)=>`I could not open ${t}: ${e}`,shell:t=>`The page at ${t} is built in the browser by JavaScript, so what comes back is empty. Open it in your browser, copy its HTML and paste it through Import HTML.`,opened:t=>`I opened the page from ${t} as it is. What should change?`,adapt:"Adapt this page to my business"}};const xp={he:{ask:t=>`להשתמש ב-${t} כדף שלך במקום הדף שעל הקנבס, או רק כהשראה?`,open:"זה הדף שלי",reference:"רק השראה",shell:"הדף הזה כמעט ריק (הוא נבנה עם JavaScript), אז אין מה לפתוח. אשתמש בו כהשראה.",opened:t=>`פתחתי את ${t} כדף שלך. מה לשנות בו?`},en:{ask:t=>`Use ${t} as your page, replacing the one on the canvas, or just as a reference?`,open:"This is my page",reference:"Just a reference",shell:"That page is almost empty (it is built by JavaScript), so there is nothing to open. I will use it as a reference.",opened:t=>`I opened ${t} as your page. What should change?`}};async function vp(t,e,n,r,o){if(np(t,/[\u0590-\u05FF]/.test(r)?"he":n))return;t._editInFlight=!0;const i=new AbortController;Zd(t,/[\u0590-\u05FF]/.test(r)?"he":n,i,{userText:r});try{return await async function(t,e,n,r,o,i){const a=jl(t,n),s=L.Ay,l=function(t){const e=(t._attachments||[]).map(t=>{let{media_type:e,b64:n}=t;return{media_type:e,b64:n}});return t._attachments=[],sd(t),e}(t),c=function(){if(!(0,T.zZ)())return{intent:"components"};const t=I.M.get(T.yS);if(El(t)){const e=Tp(t);return e?{intent:"page",anchorKey:e.key,anchorPos:e.pos,documentHasContent:!1}:{intent:"page"}}const e=Tp(t);if(!e)return{intent:"page"};const n=!t||"generated"!==t.origin,r=jt.sectionsOf(t).map(e=>({...e,content:jt.contentMap(t,e.key)||{text:[],images:[],links:[]}}));if(!n)return{intent:"page",anchorKey:e.key,anchorPos:e.pos,styleDigest:jt.styleDigest(t),documentHasContent:!0,...r.length>0?{sections:r}:{}};return{intent:r.length>0?"adapt":"section",anchorKey:e.key,anchorPos:e.pos,styleDigest:jt.styleDigest(t),documentHasContent:!0,...r.length>0?{sections:r}:{}}}(),d=yp(c.intent),p=Array.isArray(s.components)&&s.components[0]?.id?s.components[0].id:void 0;i?.userBubbleShown||t.appendMessage?.({role:"user",text:r,ts:Date.now()});t.busy=!0;const h=(t.messages||[]).map(t=>({role:t.role,content:t.text}));if(i?.userBubbleShown){for(;h.length>0&&"user"!==h[h.length-1].role;)h.pop();h[h.length-1]?.content!==r&&h.push({role:"user",content:r})}const u=rp(),f=I.M.get("config","channel"),m=I.M.get("kitSelection"),g="components"!==c.intent?await pc():[],b={messages:h,currentNewsletter:d,language:n,...p?{selectedComponentId:p}:{},...m?{kitSelection:m}:{},...u?{doc_id:u,surface:Ed()}:{},...u&&t._newSession?{new_session:!0}:{},...u&&!t._newSession&&t._sessionId?{session_id:t._sessionId}:{},...f?{channel:f}:{},...l.length>0?{attachments:l}:{},..."components"!==c.intent&&ac()?{canPickImages:!0}:{},...g.length>0?{galleryImages:g}:{},..."components"!==c.intent&&vd?{undone:!0}:{},..."components"!==c.intent&&Qc(t).length>0?{files:Qc(t)}:{},..."components"!==c.intent?kp():{},..."components"!==c.intent?_p(s):{},..."components"!==c.intent&&pd(s).length>0?{hostTools:pd(s)}:{},...t._pendingDirection?{direction:t._pendingDirection}:{},...c};t._pendingDirection=null,vd=!1;const y={counters:{text:0,marks:0,prop:0,removed:0,created:0,moved:0,skipped:0,kit:0},finalReply:"",finalSummary:"",sseError:null,outOfTokens:!1,paymentUrl:"",truncated:!1,directions:null};let A=!1;const w=async(r,o)=>{if("host_tool_call"!==r){if("directions"===r)return y.directions=Array.isArray(o&&o.cards)?o.cards:null,void(o&&o.partial&&y.directions&&y.directions.length>0&&Tc(t,jl(t),y.directions,(e,n)=>op(t,e,n)));if("ops"===r){const t=Array.isArray(o&&o.ops)?o.ops:[];if(0===t.length)return;const e=await Op(t);return y.counters.text+=e.text,y.counters.marks+=e.marks,y.counters.prop+=e.prop,y.counters.removed+=e.removed,y.counters.created+=e.created,y.counters.moved+=e.moved,y.counters.skipped+=e.skipped,void console.log(`[edit-chat] sse ops batch call_id=${o.call_id} count=${t.length}`)}if("kit_reset"===r){if("page"!==c.intent)return void console.warn("[edit-chat] kit_reset ignored: this turn is not a page build");const t=I.M.get(T.yS);return t?(I.M.set({[T.yS]:jt.clearAiDocBody(t)}),I.M.set({kitSelection:null}),void console.log("[edit-chat] kit_reset: page cleared for a rebuild")):void console.warn("[edit-chat] kit_reset ignored: there is no AI document")}if("kit_ops"===r){const t=Array.isArray(o&&o.ops)?o.ops:[],e=Ip(o&&o.componentId,t);return("page"===c.intent||"section"===c.intent)&&e.applied>0&&e.inserted>0&&(A=!0),y.counters.kit+=e.applied,void(e.reason?console.warn(`[edit-chat] kit_ops not applied call_id=${o&&o.call_id}: ${e.reason}`):console.log(`[edit-chat] sse kit_ops batch call_id=${o&&o.call_id} count=${e.applied}`))}if("thinking"===r){const e=o&&"string"==typeof o.delta?o.delta:"";if(!e)return;return void Qd(t,e)}if("text"===r){const e=o&&"string"==typeof o.delta?o.delta:"";if(!e)return;return void Qd(t,e)}if("text_reset"!==r){if("tool_start"===r||"tool_end"===r){const e=Array.isArray(o&&o.keys)?o.keys:null;if("tool_start"===r){const e="en"===jl(t)?"en":"he",n=Gd[e][o&&o.name]||Hd[e]||Hd.en;Jd(t,n),t._busyEl&&(0,Vt.L)("thinking",Yd.has(o&&o.name)?"research":"build")}if("tool_start"===r){const n=o&&"edit"===o.mode,r=Xd["en"===jl(t)?"en":"he"];(0,Vt.QG)(e||[],n?"edit":"read",n?r.edit:r.read)}else e&&e.length&&(0,Vt.QG)(e,"read",Xd["en"===jl(t)?"en":"he"].found);return}if("done"!==r)"error"!==r?"memory"!==r||function(t,e,n){(function(t){if(!t||"saved"!==t.action&&"forgotten"!==t.action)return!1;const e=t.memory;return!(!e||"string"!=typeof e.text||!e.text.trim())})(n)&&jc({action:n.action,memory:n.memory})}(0,jl(t),o):y.sseError={reason:o&&o.reason||"chat edit failed"};else if(o&&"string"==typeof o.session_id&&o.session_id&&(t._sessionId=o.session_id,t._newSession=!1),y.finalReply=o&&"string"==typeof o.reply?o.reply:"",y.finalSummary=o&&"string"==typeof o.summary?o.summary:"",y.outOfTokens=!(!o||!o.outOfTokens),y.truncated=!(!o||!o.truncated),y.paymentUrl=o&&"string"==typeof o.paymentUrl?o.paymentUrl:"",o&&"number"==typeof o.balance&&up(t,n,o.balance,y.paymentUrl),A&&(0,T.zZ)()){const t=I.M.get(T.yS);t&&(I.M.set({[T.yS]:jt.flattenAiDoc(t)}),I.M.set({kitSelection:null}))}}else Kd(t)}else await ud(s,o,async t=>{const n=await mp(s,{}),r=await fetch(`${e}/host-tool-result`,{method:"POST",headers:{"Content-Type":"application/json",...n?{Authorization:`Bearer ${n}`}:{}},body:JSON.stringify(t)});if(!r.ok)throw new Error(`host-tool-result ${r.status}`)})};let x,v,k=!1;try{let n=await gp(s,e,b,{allowProviderRefresh:!0,onEvent:w,signal:o.signal});!n.resp||401!==n.resp.status&&403!==n.resp.status||(console.warn(`[edit-chat] auth ${n.resp.status}; asking studioTokenProvider for a fresh token and retrying once.`),n=await gp(s,e,b,{allowProviderRefresh:!0,forceRefresh:!0,onEvent:w,signal:o.signal}),!n.resp||401!==n.resp.status&&403!==n.resp.status||t.dispatchEvent?.(new CustomEvent("cdtr-edit:auth-expired",{bubbles:!0,composed:!0,detail:{status:n.resp.status}}))),x=n.resp,v=n.body,k=n.streamed}catch(e){if(t.busy=!1,o.signal.aborted||"AbortError"===e?.name)return t._stoppedForPick?void(t._stoppedForPick=!1):void t.appendMessage?.({role:"assistant",text:Fd[a]||Fd.en,ts:Date.now()});const n=e&&("TypeError"===e.name||e.message?.includes("fetch"));return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,e,{isNetwork:n})),ts:Date.now()})}if(t.busy=!1,k){if(y.sseError)return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,y.sseError.reason)),ts:Date.now()});const e=y.counters,n=e.skipped>0?(Rd[a]||Rd.en)(e.skipped):"",r=y.outOfTokens?(Pd[a]||Pd.en)(y.paymentUrl):"",o=e.text+e.marks+e.prop+e.removed+e.created+e.moved+e.kit,i=y.truncated?(Dd[a]||Dd.en)(o):"",s=0!==o||0!==e.skipped||y.outOfTokens||y.truncated?"":jd[a]||jd.en,l=r||i||n;let c=l||s;const d=hc(y.finalReply);null!==d.ask&&(y.finalReply=d.text,fc(t,a,d.ask,e=>t._submitChip?.(e),d.auto),c=l);const p=Jl(y.finalReply);if(p.questions.length>0)return p.text.length>0&&t.appendMessage?.({role:"assistant",text:Gl(p.text).text+l,ts:Date.now()}),void tc(t,a,p.questions,e=>t._submitChip?.(e));const h=Gl(y.finalReply);if(y.directions&&y.directions.length>0&&(c=l,Tc(t,a,y.directions,(e,n)=>op(t,e,n))),h.chips.length>0)h.text.length>0&&t.appendMessage?.({role:"assistant",text:h.text+l,ts:Date.now()}),Zl(t,a,h.chips,h.kind,e=>t._submitChip?.(e));else if(y.finalReply.length>0)t.appendMessage?.({role:"assistant",text:y.finalReply+c,ts:Date.now()});else if(o>0){const e=(zd[a]||zd.en)(o);t.appendMessage?.({role:"assistant",text:e+c,ts:Date.now()})}else c&&t.appendMessage?.({role:"assistant",text:c.trim(),ts:Date.now()});return void console.log(`[edit-chat] applied ops (streamed): text=${e.text}, marks=${e.marks}, prop=${e.prop}, removed=${e.removed}, created=${e.created}, moved=${e.moved}, kit=${e.kit}, skipped=${e.skipped}; summary=${y.finalSummary}`)}if(!x||!x.ok||v&&v.error){const e=v&&v.reason||`HTTP ${x?x.status:"unknown"}`,n=x&&(401===x.status||403===x.status);return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,e,{isAuth:n})),ts:Date.now()})}const{reply:C,ops:_,summary:E}=v||{},S=Array.isArray(_)&&_.length>0,M=S?"":jd[n]||jd.en;"string"==typeof C&&C.length>0&&t.appendMessage?.({role:"assistant",text:C+M,ts:Date.now()});if(!S)return void console.log("[edit-chat] response had no ops; summary=",E);const B=await Op(_);console.log(`[edit-chat] applied ops: text=${B.text}, marks=${B.marks}, prop=${B.prop}, removed=${B.removed}, created=${B.created}, moved=${B.moved}, skipped=${B.skipped}; summary=${E}`)}(t,e,n,r,i,o)}finally{t._editInFlight=!1,t.busy=!1,$d(t)}}function kp(){const t=I.M.get(T.yS);if(!t)return{};try{const e=jt.renderAiDoc(t);return"string"==typeof e&&e.length>0?{page:e}:{}}catch{return{}}}const Cp=(t,e)=>"string"==typeof t||"number"==typeof t?String(t).replace(/\s+/g," ").trim().slice(0,e):"";function _p(t){const e=t?.configure?.editorProps?.form,n=Array.isArray(e?.fields)?e.fields:[],r=new Set((Array.isArray(e?.defaultFields)?e.defaultFields:[]).map(t=>String(t&&"object"==typeof t?t.id:t))),o=n.map(t=>{const e=Cp(t?.paramName||t?.id,80);if(!e)return null;const n=(Array.isArray(t.items)?t.items:Array.isArray(t.options)?t.options:[]).map(t=>{const e=Cp(t&&"object"==typeof t?t.value??t.id??t.label:t,60),n=Cp(t&&"object"==typeof t?t.label??t.name??e:t,60);return e?{label:n||e,value:e}:null}).filter(Boolean).slice(0,30);return{paramName:e,...Cp(t.label||t.name,80)?{label:Cp(t.label||t.name,80)}:{},...Cp(t.type,30)?{type:Cp(t.type,30)}:{},...Cp(t.inputType,30)?{inputType:Cp(t.inputType,30)}:{},...n.length>0?{options:n}:{},...r.has(String(t.id))?{isDefault:!0}:{}}}).filter(Boolean).slice(0,80);if(0===o.length)return{};const i=Array.isArray(e?.mailingLists)?e.mailingLists:e?.mailingLists?.items??[],a=(Array.isArray(i)?i:[]).map(t=>{const e=Cp(t?.id??t?.key,40);return e?{id:e,name:Cp(t.name??t.label??e,80)}:null}).filter(Boolean).slice(0,50);return{formConfig:{fields:o,...a.length>0?{mailingLists:a}:{}}}}const Ep=["div","main","article","form"],Sp=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Mp(t){return String(t&&t.name||"").toLowerCase()}function Bp(t){const e=[];for(const n of t||[])n&&"tag"===n.type&&"head"!==Mp(n)&&e.push(n);const n=e.filter(t=>"html"===Mp(t));if(!n.length)return e;const r=[];for(const t of n)r.push(...Bp(t.children));return r}function Tp(t){const e=t&&t.html?t.html:"";if(!e)return null;const n=jt.parse(e),r=new WeakMap,o=[],i=[];jt.walk(n,(t,e)=>{const n=!!e&&!!r.get(e),a=Mp(t),s=n||"head"===a;r.set(t,s),s||("body"===a&&o.push(t),"main"===a&&i.push(t))});const a=(t,e)=>{if(!t)return null;const n=Mp(t);if("html"===n||"head"===n)return null;if(r.get(t))return null;if("append"===e&&Sp.has(n))return null;const o=t.attribs&&t.attribs["data-k"];return o?{key:o,pos:e}:null},s=a(o[0],"append");if(s)return s;const l=a(i[0],"append");if(l)return l;const c=Bp(n);if(1===c.length&&Ep.includes(Mp(c[0]))){const t=a(c[0],"append");if(t)return t}return a(c[c.length-1],"after")}const Lp=150;function Ip(t,e){const{ops:n,dropped:r}=jt.normalizeIncomingOps(e),o=n.filter(t=>t&&"insert"===t.op).length;if(0===n.length)return{applied:0,inserted:0,dropped:r.length,reason:"no applicable ops in batch"};if(!t)return{applied:0,inserted:0,dropped:r.length,reason:"no componentId on the event"};if(t===T.o6){const t=I.M.get(T.yS);return t?(I.M.set({[T.yS]:jt.appendAiEditsOverManual(t,n)}),{applied:n.length,inserted:o,dropped:r.length,reason:""}):{applied:0,inserted:0,dropped:r.length,reason:"AI mode is on but there is no document"}}const i=L.Ay.getComponent?L.Ay.getComponent(t):null,a=Array.isArray(L.Ay.components)?L.Ay.components.find(e=>e&&e.id===t):null,s=(i&&i.kit?i:null)||(a&&a.kit?a:null)||i;if(!s)return{applied:0,inserted:0,dropped:r.length,reason:`component ${t} is not in this document`};const l=s.kit;return l&&"function"==typeof l.push?(l.push(...n),{applied:n.length,inserted:o,dropped:r.length,reason:""}):{applied:0,inserted:0,dropped:r.length,reason:`component ${t} has no mounted kit api`}}async function Op(t){const e=L.Ay,n={text:0,marks:0,prop:0,removed:0,created:0,moved:0,skipped:0};let r=new Set,o=0;const i=new Set;try{const n=e&&e.getComponents?e.getComponents():null;r=new Set(n?Object.keys(n):[]),o=r.size;const i=n?Object.values(n).filter(t=>t&&"root"===t.type).map(t=>t&&t.id):[],a=t.find(t=>t&&"create"===t.op);console.log(`[edit-chat] BATCH START total=${o} rootIds=${JSON.stringify(i)} firstParentId=${a&&a.parentId} firstParentInStore=${a?!!e.getComponent(a.parentId):"no-creates"}`)}catch(t){console.warn("[edit-chat] batch-start diagnostic failed",t)}let a=!0;for(const s of t){!a&&Lp>0&&await new Promise(t=>setTimeout(t,Lp)),a=!1;const t=e.store();if(s&&"string"==typeof s.op)try{if("updateText"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateText",s.id);continue}t.updateComponent(r,"text",{childNodes:s.value}),n.text++}else if("updateTextMarks"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateTextMarks",s.id);continue}t.updateComponent(r,"text",{childNodes:s.value}),n.marks++}else if("updateProp"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateProp",s.id);continue}t.updateComponent(r,s.key,s.value),n.prop++}else if("remove"===s.op)t.removeComponent({componentId:s.id}),n.removed++;else if("create"===s.op){const a=s.body&&(s.body.id||s.body._id),l=e&&e.getComponents&&e.getComponents()||{},c=Object.keys(l).length,d=!!e.getComponent(s.parentId);let p;p=r.has(s.parentId)?"PRE-EXISTING":i.has(s.parentId)?"SELF-DECLARED":"PHANTOM",t.createComponent({parentId:s.parentId,index:s.index,body:s.body},{clone:!0});const h=e&&e.getComponents&&e.getComponents()||{},u=Object.keys(h).length,f=!!e.getComponent(a);let m=0;r.forEach(t=>{t in h&&m++}),i.add(a),console.log(`[edit-chat] CREATE type=${s.body&&s.body.type} id=${a} parentId=${s.parentId} idx=${s.index} parentInStore=${d} parentSource=${p} bodyInStoreAfter=${f} total=${c}->${u} initialSurvived=${m}/${o}`),n.created++}else"move"===s.op?(t.moveComponent({id:s.id,oldParentId:s.oldParentId,newParentId:s.newParentId,oldIndex:s.oldIndex,newIndex:s.newIndex}),n.moved++):(console.warn("[edit-chat] unknown op type:",s.op),n.skipped++)}catch(t){console.error(`[edit-chat] op dispatch FAILED op=${s.op} id=${s.id||s.body&&s.body.id||"?"}`,t,s),n.skipped++}else n.skipped++}return n}I.M.set({createEditChat:fp});const Np={mem_title:"Assistant memory",mem_intro:"What the assistant remembers about you. Edit or delete any line.",mem_group_business:"About the business (all pages)",mem_group_page:"About this page",mem_source_ai:"From chat",mem_source_user:"Added by you",mem_edit:"Edit",mem_delete:"Delete",mem_save:"Save",mem_cancel:"Cancel",mem_empty_group:"Nothing yet. The assistant saves lasting facts as you chat.",mem_too_long:"Up to {limit} characters.",mem_error:"Could not load the memory.",mem_retry:"Try again",mem_no_token:"Sign in to see what the assistant remembers.",mem_action_failed:"That did not work. Try again."};function Hp(t,e){const n=I.M.get("lang",t);let r="string"==typeof n&&n?n:Np[t]||t;if(e)for(const[t,n]of Object.entries(e))r=r.split(`{${t}}`).join(String(n));return r}const zp=["business","page"];class Pp extends S.WF{constructor(){super(),this._memories=[],this._limits={...Rc},this._loading=!1,this._error=!1,this._noToken=!1,this._editingId=null,this._busyId=null,this._notice={},this._loaded=!1,this._onStore=()=>{this._syncDir(),this.requestUpdate()},this._onChanged=()=>this._load({quiet:!0})}connectedCallback(){super.connectedCallback(),this._syncDir(),I.M.connect(["lang","langConfig"],this._onStore),window.addEventListener(Dc,this._onChanged),this._load()}disconnectedCallback(){I.M.disconnect(this._onStore),window.removeEventListener(Dc,this._onChanged),super.disconnectedCallback()}_syncDir(){this.setAttribute("dir",function(){const t=I.M.get("langConfig");return!(!t||"rtl"!==t.direction)}()?"rtl":"ltr")}async _load(){let{quiet:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&this._loaded||(this._loading=!0),!await async function(){return null!=await Fc({forceRefresh:!1})}())return this._noToken=!0,void(this._loading=!1);this._noToken=!1;const e=await async function(t){const e=t?`${Pc}?doc_id=${encodeURIComponent(t)}`:Pc,n=await Uc("GET",e),r=n.ok&&n.data&&Array.isArray(n.data.memories)?n.data.memories:[],o={...Rc,...n.ok&&n.data&&n.data.limits||{}};return{ok:n.ok,status:n.status,memories:r,limits:o}}(rp());this._loading=!1,e.ok?(this._error=!1,this._loaded=!0,this._memories=e.memories,this._limits=e.limits):this._loaded||(this._error=!0)}_group(t){return this._memories.filter(e=>e&&e.scope===t)}_setNotice(t,e){this._notice={...this._notice,[t]:e||""}}async _save(t,e){const n=(e.value||"").trim();if(!n)return;if(n===t.text)return void(this._editingId=null);if(n.length>this._limits.text)return void this._setNotice(t.scope,Hp("mem_too_long",{limit:this._limits.text}));this._setNotice(t.scope,""),this._busyId=t.id;const r=await async function(t,e){const n=await Uc("PATCH",`${Pc}/${encodeURIComponent(t)}`,{text:e});return{ok:n.ok,status:n.status,memory:n.data&&n.data.memory||null,error:n.data&&n.data.error||(n.ok?null:"request_failed")}}(t.id,n);return this._busyId=null,r.ok?(this._editingId=null,void(this._memories=this._memories.map(e=>e.id===t.id?r.memory||{...e,text:n}:e))):404===r.status?(this._editingId=null,void this._load({quiet:!0})):void this._setNotice(t.scope,Hp("mem_action_failed"))}async _delete(t){this._setNotice(t.scope,""),this._busyId=t.id;const e=await Wc(t.id);if(this._busyId=null,e.ok)return this._memories=this._memories.filter(e=>e.id!==t.id),void(this._editingId===t.id&&(this._editingId=null));this._setNotice(t.scope,Hp("mem_action_failed"))}_updateChars(t){const e=t.parentElement&&t.parentElement.querySelector(".chars");e&&(e.textContent=`${(t.value||"").length}/${this._limits.text}`)}_head(){return S.qy`<div class="head">
|
|
6358
|
+
`;const Bl={he:{device:"מכשיר",desktop:"מחשב",mobile:"נייד",fit:"התאמה",fitLong:"התאמה למסך",draft:"טיוטה, עוד לא פורסם",untitled:"דף ללא שם",rename:"שינוי שם הדף",renameFailed:"לא הצלחנו לשמור את שם הדף. נסו שוב."},en:{device:"Device",desktop:"Desktop",mobile:"Mobile",fit:"Fit",fitLong:"Fit to screen",draft:"Draft, not published yet",untitled:"Untitled page",rename:"Rename page",renameFailed:"Couldn't save the page name. Please try again."}},Tl=["fit","0.5","0.75","1"],Ll=390,Il=t=>S.qy`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" .innerHTML=${t}></svg>`,Ol=Il('<rect x="3" y="4.5" width="18" height="12" rx="2"/><path d="M8.5 20h7M12 16.5V20"/>'),Nl=Il('<rect x="7" y="3" width="10" height="18" rx="2.5"/><path d="M11 17.5h2"/>'),Hl=Il('<rect x="5" y="10.5" width="14" height="10" rx="2"/><path d="M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5"/>'),zl=Il('<circle cx="12" cy="12" r="8.5" stroke-dasharray="3 3"/>'),Pl=Il('<polyline points="6 9 12 15 18 9"/>');customElements.define("cdtr-ai-canvas",Sl);const Dl="cdtr-studio-fonts";const Rl=/[-]/;function jl(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"he";const n=Array.isArray(t?.messages)?t.messages:[];for(let t=n.length-1;t>=0;t--){const e=n[t];if(e&&"user"===e.role&&"string"==typeof e.text&&e.text.trim())return Rl.test(e.text)?"he":"en"}return"en"===e?"en":"he"}function Fl(t,e){Wl(t);const n=t?.shadowRoot?.querySelector(".messages");return!!n&&(e.parentNode===n&&e===n.lastElementChild||n.appendChild(e),function(t){const e=t?.shadowRoot?.querySelector(".body");e&&(e.scrollTop=e.scrollHeight)}(t),!0)}function ql(t,e,n){Fl(t,e),Promise.resolve(t.updateComplete).then(()=>{n&&!n()||Fl(t,e)}).catch(()=>{})}const Ul="\n /* Specificity note: <cdtr-chat>'s own sheet is an ADOPTED stylesheet, and\n adopted sheets cascade after <style> elements in the shadow root, so on a\n tie the chat's rules win. Every rule here that competes with one of its\n (.row, the studio bubble reset) is written heavier on purpose. */\n /* The chat's own typing row, while ours is showing: two would read as the\n work happening twice. */\n :host(.cdtr-edit-busy-on) .row.assistant.typing { display: none; }\n\n /* While a turn runs nothing else may change the conversation or the page:\n new chat, history, close, attach and voice wait for it (Stop does not). */\n :host(.cdtr-edit-busy-on) .header button,\n :host(.cdtr-edit-busy-on) .header-actions button,\n :host(.cdtr-edit-busy-on) .card-attach,\n :host(.cdtr-edit-busy-on) .icon-btn.voice,\n :host(.cdtr-edit-busy-on) .icon-btn:not(.send):not(.cdtr-edit-stop) {\n opacity: .38; pointer-events: none; cursor: default;\n transition: opacity .2s ease;\n }\n\n /* ---------- sidebar ---------- */\n /* The sidebar (editChatDrawer) draws the header now: title, tabs, tokens,\n new conversation. The chat's own header would be a second, dead bar. */\n :host([variant]) .header, .header { display: none !important; }\n\n /* Nothing in a conversation may push the panel wider than itself: a long\n link, a pasted path, a code line used to make the whole chat scroll\n sideways. Wrap instead, everywhere a message can render. */\n :host([variant]) .body, .body { overflow-x: hidden; }\n .messages, .row { min-width: 0; max-width: 100%; }\n :host([variant]) .bubble, .bubble { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }\n .bubble.md pre, .bubble.md code { white-space: pre-wrap; overflow-wrap: anywhere; }\n .bubble.md pre { max-width: 100%; overflow-x: auto; }\n .bubble img, .bubble video, .bubble table { max-width: 100%; }\n\n /* ---------- reply avatar ----------\n A still of Meshavektor at the start of each of his replies, so a long\n conversation shows who said what. Only the chat's own reply rows, not\n ours (every row we add carries a cdtr- class) and not its typing row.\n A reply that follows another keeps the space but hides the face. Still,\n never video: motion belongs to the live working row alone. */\n .messages > .row.assistant:not(.typing):not([class*='cdtr-'])::before {\n content: '';\n flex: 0 0 28px;\n width: 28px;\n height: 28px;\n margin-block-start: 2px;\n margin-inline-end: 10px;\n border-radius: 50%;\n background: #1565a6 url('data:image/jpeg;base64,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') center / cover no-repeat;\n box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9), 0 1px 4px rgba(43, 18, 64, 0.16);\n }\n .messages > .row.assistant:not(.typing):not([class*='cdtr-'])\n + .row.assistant:not(.typing):not([class*='cdtr-'])::before {\n visibility: hidden;\n }\n\n /* ---------- working row ---------- */\n .row.cdtr-edit-row { display: block; }\n :host([variant]) .row.assistant.cdtr-edit-row .bubble.cdtr-edit-bubble,\n .row.assistant.cdtr-edit-row .bubble.cdtr-edit-bubble {\n display: grid;\n gap: 8px;\n width: 100%;\n max-width: 100%;\n box-sizing: border-box;\n padding: 12px 12px 12px 14px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n border-radius: 18px;\n }\n :host([variant]) .row.assistant.cdtr-edit-row[dir='rtl'] .bubble.cdtr-edit-bubble {\n padding: 12px 14px 12px 12px;\n }\n .cdtr-edit-busy-head {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 28px;\n }\n /* Big enough to see him at work: the row is where the face spends a turn. */\n .cdtr-edit-face { --face-size: 80px; }\n /* The label gives way, never the timer or the stop button: a long step\n label (\"מצייר כיוונים לעיצוב שתוכלו לבחור\") once squeezed them until\n \"0:13\" and \"עצור\" each broke over two lines. */\n .cdtr-edit-busy-label {\n font-size: 14px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n margin-inline-end: auto;\n flex: 1 1 auto;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .cdtr-edit-face, .cdtr-edit-elapsed, .cdtr-edit-stop { flex: 0 0 auto; white-space: nowrap; }\n .cdtr-edit-elapsed {\n font-size: 12px;\n color: var(--cdtr-chat-muted, #6f676b);\n font-variant-numeric: tabular-nums;\n }\n .cdtr-edit-thinking {\n display: none;\n max-height: 132px;\n overflow-y: auto;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: 13px;\n line-height: 1.6;\n color: var(--cdtr-chat-muted, #6f676b);\n -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px);\n mask-image: linear-gradient(to bottom, transparent 0, #000 28px);\n padding-top: 6px;\n scrollbar-width: none;\n }\n .cdtr-edit-thinking::-webkit-scrollbar { display: none; }\n .cdtr-edit-bubble.has-thinking .cdtr-edit-thinking { display: block; }\n .cdtr-edit-stop {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 28px;\n padding: 0 10px;\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n border-radius: 10px;\n background: rgba(255, 255, 255, 0.5);\n color: var(--cdtr-chat-ink-2, #4a4347);\n font: inherit;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;\n }\n .cdtr-edit-stop::before {\n content: '';\n width: 8px;\n height: 8px;\n border-radius: 2px;\n background: currentColor;\n }\n .cdtr-edit-stop:hover { color: #a3261f; border-color: rgba(163, 38, 31, 0.35); background: #fdf3f2; }\n .cdtr-edit-stop:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n\n /* ---------- answer chips ---------- */\n .row.cdtr-chip-row.cdtr-chip-row {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-top: -6px;\n }\n .cdtr-chip {\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n color: var(--cdtr-chat-fg, #1f1b1d);\n border-radius: 12px;\n padding: 8px 12px;\n font: inherit;\n font-size: 14px;\n line-height: 1.25;\n cursor: pointer;\n text-align: start;\n transition: background 0.15s ease, border-color 0.15s ease;\n }\n .cdtr-chip:hover { background: var(--cdtr-chat-glass-strong, rgba(255, 255, 255, 0.78)); }\n .cdtr-chip:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-chip-primary {\n background: var(--cdtr-chat-fg, #1f1b1d);\n border-color: var(--cdtr-chat-fg, #1f1b1d);\n /* Fixed, not --cdtr-chat-bg: the glass variant makes that transparent,\n which left the primary chip a dark pill with no visible label. */\n color: #fff;\n font-weight: 600;\n }\n .cdtr-chip-primary:hover { background: #000; border-color: #000; }\n\n /* ---------- memory chips (memory.js) ---------- */\n .row.cdtr-mem-row.cdtr-mem-row {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n }\n .cdtr-mem-chip {\n display: inline-flex;\n align-items: baseline;\n gap: 8px;\n max-width: 100%;\n box-sizing: border-box;\n padding: 5px 10px;\n border-radius: 10px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n color: var(--cdtr-chat-ink-2, #4a4347);\n font-size: 12.5px;\n line-height: 1.35;\n }\n .cdtr-mem-text { min-width: 0; overflow-wrap: anywhere; }\n .cdtr-mem-chip.is-undone .cdtr-mem-text { text-decoration: line-through; opacity: .55; }\n .cdtr-mem-undo {\n flex: 0 0 auto;\n background: none;\n border: none;\n padding: 0;\n font: inherit;\n font-weight: 600;\n color: var(--cdtr-chat-accent, #6b2c8f);\n text-decoration: underline;\n cursor: pointer;\n }\n .cdtr-mem-undo:disabled { color: var(--cdtr-chat-muted, #6f676b); text-decoration: none; cursor: default; }\n .cdtr-mem-undo:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n\n /* ---------- page interview card (brief.js) ---------- */\n .row.cdtr-brief.cdtr-brief {\n display: grid;\n gap: 14px;\n padding: 14px;\n border-radius: 16px;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n }\n .cdtr-brief-q { display: grid; gap: 8px; }\n .cdtr-brief-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n }\n .cdtr-brief-opts { display: flex; flex-wrap: wrap; gap: 6px; }\n .cdtr-brief-opt { padding: 6px 11px; font-size: 13px; }\n /* Fixed colours, not the chat's tokens: --cdtr-chat-bg is transparent on\n the glass variant, which once made a selected label invisible. */\n .cdtr-brief-opt[aria-pressed=\"true\"] {\n background: #1f1b1d;\n border-color: #1f1b1d;\n color: #fff;\n }\n .cdtr-brief-other {\n font: inherit;\n font-size: 13px;\n padding: 7px 10px;\n border-radius: 10px;\n border: 1px solid rgba(31, 27, 29, 0.14);\n background: rgba(255, 255, 255, 0.7);\n color: #1f1b1d;\n min-width: 0;\n }\n .cdtr-brief-other:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 1px; }\n .cdtr-brief-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .cdtr-brief-go {\n font: inherit;\n font-size: 14px;\n font-weight: 600;\n padding: 9px 20px;\n border-radius: 12px;\n border: 0;\n background: #1f1b1d;\n color: #fff;\n cursor: pointer;\n }\n .cdtr-brief-go:hover { background: #000; }\n .cdtr-brief-skip {\n font: inherit;\n font-size: 13px;\n background: none;\n border: 0;\n padding: 4px;\n color: var(--cdtr-chat-muted, #6f676b);\n text-decoration: underline;\n cursor: pointer;\n }\n .cdtr-brief-go:focus-visible, .cdtr-brief-skip:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n :host(.cdtr-edit-busy-on) .cdtr-brief { opacity: .5; pointer-events: none; }\n\n /* ---------- direction cards ---------- */\n .row.cdtr-dir.cdtr-dir {\n display: grid;\n gap: 12px;\n }\n .cdtr-dir-head { display: grid; gap: 2px; }\n .cdtr-dir-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n color: var(--cdtr-chat-fg, #1f1b1d);\n }\n .cdtr-dir-sub {\n margin: 0;\n font-size: 13px;\n color: var(--cdtr-chat-muted, #6f676b);\n }\n .cdtr-dir-list { display: grid; gap: 12px; }\n .cdtr-dir-item { position: relative; }\n .cdtr-dir-card {\n display: grid;\n gap: 0;\n width: 100%;\n padding: 0;\n overflow: hidden;\n background: var(--cdtr-chat-glass, rgba(255, 255, 255, 0.55));\n -webkit-backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n backdrop-filter: var(--cdtr-chat-glass-blur, blur(18px) saturate(1.6));\n border: 1px solid var(--cdtr-chat-glass-edge, rgba(255, 255, 255, 0.85));\n box-shadow: var(--cdtr-chat-glass-shadow, inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 32px -16px rgba(22, 26, 34, 0.32));\n border-radius: 18px;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: pointer;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.2s ease;\n }\n .cdtr-dir-card:hover {\n transform: translateY(-2px);\n background: var(--cdtr-chat-glass-strong, rgba(255, 255, 255, 0.78));\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 18px 36px -16px rgba(22, 26, 34, 0.45);\n }\n .cdtr-dir-card:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-dir-card img {\n display: block;\n width: 100%;\n aspect-ratio: 16 / 10;\n object-fit: cover;\n object-position: top;\n border-bottom: 1px solid rgba(255, 255, 255, 0.7);\n background: rgba(255, 255, 255, 0.4);\n }\n .cdtr-dir-meta {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px 12px;\n }\n .cdtr-dir-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }\n .cdtr-dir-name { font-size: 14px; font-weight: 600; line-height: 1.3; }\n .cdtr-dir-mood {\n font-size: 13px;\n line-height: 1.45;\n color: var(--cdtr-chat-muted, #6f676b);\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n .cdtr-dir-go {\n flex: none;\n height: 30px;\n padding: 0 12px;\n display: inline-flex;\n align-items: center;\n border-radius: 8px;\n /* Fixed colours: the glass variant's --cdtr-chat-bg is transparent, which\n made the label vanish into an empty black pill. */\n background: #1f1b1d;\n color: #ffffff;\n font-size: 13px;\n font-weight: 600;\n opacity: 0;\n transform: translateY(2px);\n transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);\n }\n .cdtr-dir-card:hover .cdtr-dir-go,\n .cdtr-dir-card:focus-visible .cdtr-dir-go { opacity: 1; transform: none; }\n .cdtr-dir-zoom {\n position: absolute;\n top: 8px;\n inset-inline-end: 8px;\n width: 30px;\n height: 30px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: 8px;\n background: rgba(255, 255, 255, 0.92);\n color: var(--cdtr-chat-fg, #1f1b1d);\n box-shadow: 0 1px 2px rgba(31, 27, 29, 0.12), 0 4px 12px -4px rgba(31, 27, 29, 0.25);\n cursor: zoom-in;\n opacity: 0;\n transition: opacity 0.15s ease;\n }\n .cdtr-dir-item:hover .cdtr-dir-zoom,\n .cdtr-dir-zoom:focus-visible { opacity: 1; }\n .cdtr-dir-zoom:focus-visible { outline: 2px solid var(--cdtr-chat-accent, #6b2c8f); outline-offset: 2px; }\n .cdtr-dir-zoom svg { width: 16px; height: 16px; }\n\n @media (prefers-reduced-motion: reduce) {\n .cdtr-dir-card, .cdtr-dir-go { transition: none; }\n }\n";function Wl(t){const e=t?.shadowRoot;if(!e||e.getElementById("cdtr-edit-row-styles"))return;const n=document.createElement("style");n.id="cdtr-edit-row-styles",n.textContent=Ul,e.appendChild(n)}const Vl='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><line x1="16" y1="16" x2="20.5" y2="20.5"/><line x1="11" y1="8.5" x2="11" y2="13.5"/><line x1="8.5" y1="11" x2="13.5" y2="11"/></svg>',Yl=/```[ \t]*cx-(options|confirm)[ \t]*\r?\n([\s\S]*?)```/g;function Gl(t){const e="string"==typeof t?t:"",n=[];let r,o=null;for(Yl.lastIndex=0;null!==(r=Yl.exec(e));){"confirm"===r[1]?o="confirm":null===o&&(o="options");for(const t of String(r[2]||"").split("\n")){const e=t.trim().replace(/^[-*•]\s*/,"").replace(/^\d+[.)]\s*/,"").trim();!e||e.length>60||(n.includes(e)||n.push(e))}}return{text:e.replace(Yl,"").replace(/\n{3,}/g,"\n\n").trim(),chips:n.slice(0,5),kind:o}}function Xl(t){if(t&&t._chipRow){try{t._chipRow.remove()}catch{}t._chipRow=null}}function Zl(t,e,n,r,o){if(Xl(t),!t||!Array.isArray(n)||0===n.length)return;const i=document.createElement("div");i.className="row cdtr-chip-row",i.dir="he"===e?"rtl":"ltr",n.forEach((e,n)=>{const a=document.createElement("button");a.type="button",a.className="cdtr-chip"+("confirm"===r&&0===n?" cdtr-chip-primary":""),a.textContent=e,a.addEventListener("click",()=>{Xl(t),o(e)}),i.appendChild(a)}),t._chipRow=i,ql(t,i,()=>t._chipRow===i)}const Ql=/```[ \t]*cx-brief[ \t]*\r?\n([\s\S]*?)```/,Kl={he:{other:"משהו אחר…",go:"המשך",skip:"דלג, תחליט אתה",decide:"תחליט אתה"},en:{other:"Something else…",go:"Continue",skip:"Skip, you decide",decide:"you decide"}};function Jl(t){const e="string"==typeof t?t:"",n=Ql.exec(e);if(!n)return{text:e,questions:[]};const r=[];for(const t of String(n[1]||"").split("\n")){const e=t.trim();if(!e)continue;const n=/^\?(\+)?\s*(.+)$/.exec(e);if(n){if(r.length>=5)break;r.push({q:n[2].trim().slice(0,140),multi:!!n[1],options:[]});continue}const o=r[r.length-1];if(!o)continue;const i=e.replace(/^[-*•]\s*/,"").replace(/^\d+[.)]\s*/,"").trim();!i||i.length>60||o.options.includes(i)||o.options.length<6&&o.options.push(i)}return{text:e.replace(Ql,"").replace(/\n{3,}/g,"\n\n").trim(),questions:r.filter(t=>t.q)}}function $l(t){if(t&&t._briefCard){try{t._briefCard.remove()}catch{}t._briefCard=null}}function tc(t,e,n,r){if($l(t),!t||!Array.isArray(n)||0===n.length)return;const o=Kl[e]||Kl.en,i=n.map(()=>new Set),a=n.map(()=>""),s=document.createElement("div");s.className="row cdtr-brief",s.dir="he"===e?"rtl":"ltr",n.forEach((t,e)=>{const n=document.createElement("div");n.className="cdtr-brief-q",n.setAttribute("role","group");const r=document.createElement("p");r.className="cdtr-brief-title",r.textContent=t.q,n.setAttribute("aria-label",t.q),n.appendChild(r);const l=document.createElement("div");l.className="cdtr-brief-opts";const c=[];t.options.forEach(n=>{const r=document.createElement("button");r.type="button",r.className="cdtr-chip cdtr-brief-opt",r.textContent=n,r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>{const r=i[e];r.has(n)?r.delete(n):(t.multi||r.clear(),r.add(n));for(const t of c)t.setAttribute("aria-pressed",String(r.has(t.textContent)))}),c.push(r),l.appendChild(r)}),n.appendChild(l);const d=document.createElement("input");d.type="text",d.className="cdtr-brief-other",d.placeholder=o.other,d.maxLength=200,d.addEventListener("input",()=>{a[e]=d.value}),d.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),h())}),n.appendChild(d),s.appendChild(n)});const l=document.createElement("div");l.className="cdtr-brief-actions";const c=document.createElement("button");c.type="button",c.className="cdtr-brief-go",c.textContent=o.go;const d=document.createElement("button");d.type="button",d.className="cdtr-brief-skip",d.textContent=o.skip,l.append(c,d),s.appendChild(l);let p=!1;function h(){let o=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(p||t._editInFlight)return;p=!0;const s=n.map((t,e)=>o?[]:[...t.options.filter(t=>i[e].has(t)),a[e].trim()].filter(Boolean));$l(t),r(function(t,e,n){const r=Kl[n]||Kl.en;return t.map((t,n)=>{const o=(e[n]||[]).filter(Boolean);return`${t.q.replace(/[?؟]\s*$/,"")}: ${o.length?o.join(", "):r.decide}`}).join("\n")}(n,s,e))}c.addEventListener("click",()=>h(!1)),d.addEventListener("click",()=>h(!0)),t._briefCard=s,ql(t,s,()=>t._briefCard===s)}var ec=a(38941),nc=a(58991);const rc=/```[ \t]*cx-gallery[ \t]*\r?\n([\s\S]*?)```/,oc={he:{pick:"בחירה מהגלריה",change:"החלפת התמונה",picked:t=>`בחרתי תמונה מהגלריה: ${t}`,swapAi:t=>`החלף את התמונה של האלמנט שבחרתי בתמונה הזו מהגלריה: ${t}`,uploadFailed:"לא הצלחנו לשמור את התמונה החתוכה בגלריה. נסו שוב."},en:{pick:"Choose from gallery",change:"Change image",picked:t=>`I picked this image from my gallery: ${t}`,swapAi:t=>`Replace the image of the element I selected with this one from my gallery: ${t}`,uploadFailed:"The cropped image could not be saved to your gallery. Please try again."}},ic=t=>oc["en"===t?"en":"he"];function ac(){return"undefined"!=typeof customElements&&!!customElements.get("cdtr-gallery")}function sc(){return new Promise(t=>{const e=document.createElement("cdtr-gallery");let n=!1;const r=r=>{if(!n){n=!0,dc();try{e.opened=!1,e.remove()}catch{}t(r)}};e.multi=!1,e.addEventListener("file",t=>{const e=t?.detail?.src;r("string"==typeof e&&/^https?:\/\//i.test(e)?e:null)}),e.addEventListener("close",()=>r(null)),document.body.append(e),e.opened=!0})}const lc=/\.(mp4|mov|webm|m4v|avi|mp3|wav|pdf|zip)(\?|$)/i;let cc=null;function dc(){cc=null}function pc(){if(cc&&Date.now()-cc.at<12e4)return cc.list;const t=I.M.get("config","editor","configure","mediaGalleryManager");if("function"!=typeof t)return Promise.resolve([]);const e=new Promise(e=>{let n=!1;const r=t=>{n||(n=!0,e(function(t){const e=[],n=new Set;for(const r of Array.isArray(t)?t:[]){const t=String(r?.src||r?.url||"").trim();if(!/^https:\/\//i.test(t)||t.length>2e3||lc.test(t)||n.has(t))continue;n.add(t);const o=String(r?.name||"").replace(/\s+/g," ").trim().slice(0,80);if(e.push({url:t,...o?{name:o}:{},...r?.isFavorite?{favorite:!0}:{}}),e.length>=50)break}return e}(t)))};setTimeout(()=>r([]),3e3);try{const e=new ec.A;e.files=[],e.close=()=>{};const n=()=>e.dispatch("load-files",{resolve:r});e.render=n,t(e),n()}catch(t){console.warn("[edit-chat] gallery list unavailable",t),r([])}});return cc={at:Date.now(),list:e},e}function hc(t){const e="string"==typeof t?t:"",n=rc.exec(e);if(!n)return{text:e,ask:null,auto:null};const r=String(n[1]||"").split("\n").map(t=>t.trim()).filter(Boolean);return{text:e.replace(rc,"").replace(/\n{3,}/g,"\n\n").trim(),ask:(r[0]||"").slice(0,60),auto:r[1]?r[1].slice(0,60):null}}function uc(t){if(t&&t._galleryRow){try{t._galleryRow.remove()}catch{}t._galleryRow=null}}function fc(t,e,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;if(uc(t),!t||!ac())return;const i=document.createElement("div");i.className="row cdtr-chip-row",i.dir="en"===e?"ltr":"rtl";const a=document.createElement("button");if(a.type="button",a.className="cdtr-chip cdtr-chip-primary",a.textContent=n?`${ic(e).pick}: ${n}`:ic(e).pick,a.addEventListener("click",async()=>{const n=await sc();n&&(uc(t),r(ic(e).picked(n)))}),i.appendChild(a),o){const e=document.createElement("button");e.type="button",e.className="cdtr-chip",e.textContent=o,e.addEventListener("click",()=>{uc(t),r(o)}),i.appendChild(e)}t._galleryRow=i,ql(t,i,()=>t._galleryRow===i)}function mc(t){if(!t||"object"!=typeof t)return!1;if("img"===String(t.tag||"").toLowerCase())return!0;const e=String(t.html||"");return/<img[\s>]/i.test(e)||/background(-image)?\s*:[^;"]*url\(/i.test(e)}function gc(t){const e=String(t?.html||""),n=/<img[^>]*\ssrc="(https?:[^"]+)"/i.exec(e)||/url\((?:"|["'])?(https?:[^"')&]+)/i.exec(e);return n?n[1]:""}const bc=["display:inline-flex","align-items:center","gap:8px","margin:2px 2px 6px","padding-block:5px","padding-inline:5px 12px","border-radius:999px","border:1px solid rgba(15,23,42,.12)","background:rgba(255,255,255,.82)","font-family:inherit","font-size:13px","font-weight:500","line-height:1.2","color:#0f172a","cursor:pointer"].join(";"),yc=["width:26px","height:26px","border-radius:50%","object-fit:cover","display:block","background:#eef0f3","flex:0 0 auto"].join(";");let Ac=null;function wc(t,e,n){let{getSelection:r,isBusy:o,swap:i,notify:a}=n;Ac&&window.removeEventListener("cdtr-ai-image-action",Ac),Ac=async t=>{const{key:n,action:s}=t.detail||{};if(o())return;const l=r();if(l&&l.key===n){if("replace"===s){if(!ac())return;const t=await sc();return void(t&&await i(t,l))}if("crop"===s){const n=String(t.detail.src||"")||gc(l);if(!n)return;(0,nc.f)({props:{src:n}},{onApply:async t=>{const n=await function(t){const e=I.M.get("config","editor","configure","mediaGalleryManager");return"function"!=typeof e||"string"!=typeof t?Promise.resolve(null):new Promise(n=>{let r=!1;const o=t=>{r||(r=!0,dc(),n("string"==typeof t&&/^https:\/\//i.test(t)?t:null))};setTimeout(()=>o(null),6e4);try{const n=atob(t.split(",")[1]||""),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const i=new File([r],`cropped-${Date.now()}.png`,{type:"image/png"}),a=new ec.A;a.files=[],a.close=()=>{};let s=!1;const l=()=>{s||(s=!0,a.dispatch("upload-file",{file:i,dirId:null,uploadId:`${i.name}`,execCommand:(t,e)=>{"src"===t&&o(e)},options:{},onProgress:()=>{}}))},c=()=>{a.events?.["upload-file"]&&l()};a.render=c,e(a),c()}catch(t){console.warn("[edit-chat] crop upload failed",t),o(null)}})}(t);n?await i(n,r()||l):a(ic(e).uploadFailed)}})}}},window.addEventListener("cdtr-ai-image-action",Ac)}const xc={en:"About",he:"לגבי"},vc=["display:inline-flex","align-items:center","gap:4px","max-width:100%","margin:2px 2px 6px","padding-block:3px","padding-inline:10px 4px","border-radius:999px","border:0","background:#efebff","color:#4c36c7","font:inherit","font-size:12px","box-sizing:border-box"].join(";"),kc=["display:grid","place-items:center","width:20px","height:20px","flex:none","padding:0","border:0","border-radius:50%","background:none","color:inherit","cursor:pointer"].join(";");function Cc(t,e,n){let{getSelection:r,onChange:o}=n;if(!t)return;const i=()=>{const n=r();let o=t._selectionChip;if(!n)return o?.remove(),void(t._selectionChip=null);if(!o){o=document.createElement("div"),o.setAttribute("slot","above-composer"),o.setAttribute("style",vc);const n=document.createElement("span");n.setAttribute("style","overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0");const r=document.createElement("button");r.type="button",r.setAttribute("style",kc),r.setAttribute("aria-label","he"===e?"בטל בחירה":"Clear selection"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>',r.addEventListener("click",ue),o.append(n,r),t.prepend(o),t._selectionChip=o}o.dir="en"===e?"ltr":"rtl",o.firstChild.textContent=`${xc[e]||xc.en}: ${(t=>{const e=fe(t),n=e.length>40?`${e.slice(0,40)}…`:e;return[me(t),n&&`"${n}"`].filter(Boolean).join(" ")})(n)}`};i(),o(i)}const _c={he:{title:"איזה כיוון הכי מתאים לכם?",sub:"בחרו כיוון והדף ייבנה ממנו.",pick:t=>`בחרתי: ${t}`,go:"בחירה",open:"הגדלה"},en:{title:"Which direction fits best?",sub:"Pick one and the page is built from it.",pick:t=>`I chose: ${t}`,go:"Choose",open:"Enlarge"}};let Ec=!1;function Sc(t){if(t&&t._dirPanel){try{t._dirPanel.remove()}catch{}t._dirPanel=null}}function Mc(t){return t&&"object"==typeof t&&"string"==typeof t.html&&t.html?{name:String(t.name||"").slice(0,60)||"direction",style:t.style,...t.mood?{mood:String(t.mood).slice(0,300)}:{},css:String(t.css||"").slice(0,3e4),html:t.html.slice(0,6e4)}:null}function Bc(t,e){!function(){if(Ec)return;Ec=!0;const t=document.createElement("style");t.textContent="\n .cdtr-dir-lightbox {\n position: fixed;\n inset: 0;\n z-index: 2147483001;\n background: rgba(24, 20, 22, 0.66);\n -webkit-backdrop-filter: blur(6px);\n backdrop-filter: blur(6px);\n display: grid;\n place-items: center;\n padding: 32px;\n cursor: zoom-out;\n animation: cdtr-dir-fade 0.2s ease both;\n }\n .cdtr-dir-lightbox img {\n max-width: min(1280px, 92vw);\n max-height: 86vh;\n border-radius: 12px;\n box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);\n animation: cdtr-dir-rise 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;\n }\n @keyframes cdtr-dir-fade { from { opacity: 0; } }\n @keyframes cdtr-dir-rise { from { transform: translateY(10px) scale(0.985); } }\n @media (prefers-reduced-motion: reduce) {\n .cdtr-dir-lightbox, .cdtr-dir-lightbox img { animation: none; }\n }\n ",document.head.appendChild(t)}();const n=document.createElement("div");n.className="cdtr-dir-lightbox",n.setAttribute("role","dialog");const r=document.createElement("img");r.src=t,r.alt=e,n.appendChild(r);const o=()=>n.remove();n.addEventListener("click",o),document.addEventListener("keydown",function t(e){"Escape"===e.key&&(o(),document.removeEventListener("keydown",t))}),document.body.appendChild(n)}function Tc(t,e,n,r){Sc(t);const o=(Array.isArray(n)?n:[]).filter(t=>t&&"string"==typeof t.image&&t.image.startsWith("data:image/"));if(!t||0===o.length)return;const i=_c[e]||_c.en,a=document.createElement("div");a.className="row cdtr-dir",a.dir="he"===e?"rtl":"ltr";const s=document.createElement("div");s.className="cdtr-dir-head";const l=document.createElement("p");l.className="cdtr-dir-title",l.textContent=i.title;const c=document.createElement("p");c.className="cdtr-dir-sub",c.textContent=i.sub,s.append(l,c),a.appendChild(s);const d=document.createElement("div");d.className="cdtr-dir-list";for(const e of o.slice(0,4)){const n=document.createElement("div");n.className="cdtr-dir-item";const o=document.createElement("button");o.type="button",o.className="cdtr-dir-card";const a=document.createElement("img");a.src=e.image,a.alt=e.name||"",a.loading="lazy";const s=document.createElement("span");s.className="cdtr-dir-meta";const l=document.createElement("span");l.className="cdtr-dir-text";const c=document.createElement("span");if(c.className="cdtr-dir-name",c.textContent=e.name||"",l.appendChild(c),e.mood){const t=document.createElement("span");t.className="cdtr-dir-mood",t.textContent=String(e.mood),l.appendChild(t)}const p=document.createElement("span");p.className="cdtr-dir-go",p.setAttribute("aria-hidden","true"),p.textContent=i.go,s.append(l,p),o.append(a,s),o.addEventListener("click",()=>{Sc(t),r(i.pick(e.name||""),Mc(e))});const h=document.createElement("button");h.type="button",h.className="cdtr-dir-zoom",h.setAttribute("aria-label",`${i.open}: ${e.name||""}`),h.title=i.open,h.innerHTML=Vl,h.addEventListener("click",t=>{t.stopPropagation(),Bc(e.image,e.name||"")}),n.append(o,h),d.appendChild(n)}a.appendChild(d),t._dirPanel=a,ql(t,a,()=>t._dirPanel===a)}const Lc="cdtr-ai-sidebar:tab",Ic={he:{empty:"עוד אין שיחות קודמות בדף הזה.",failed:"לא הצלחתי לטעון את השיחות.",untitled:"שיחה",current:"עכשיו",loading:"טוען…"},en:{empty:"No earlier conversations on this page yet.",failed:"Could not load the conversations.",untitled:"Conversation",current:"Current",loading:"Loading…"}};async function Oc(t,e,n){const r=e&&e._historyDeps;if(!t||!r)return;!function(t){const e=t.getRootNode?t.getRootNode():document,n=e instanceof ShadowRoot?e:document.head;if(e instanceof ShadowRoot?e.getElementById(Hc):document.getElementById(Hc))return;const r=document.createElement("style");r.id=Hc,r.textContent=zc,n.appendChild(r)}(t);const o="en"===r.lang?"en":"he",i=Ic[o],a={};t._listToken=a,t.className="cdtr-history",t.dir="en"===o?"ltr":"rtl",t.textContent=i.loading;const s=r.listPath();let l=[];try{if(!s)throw new Error("no document");const t=await r.request(s);l=Array.isArray(t?.sessions)?t.sessions.slice(0,30):[]}catch(e){return console.warn("[edit-chat] conversation list failed:",e),void(t._listToken===a&&(t.textContent=i.failed))}if(t._listToken===a){if(t.textContent="",0===l.length){const e=document.createElement("div");return e.className="cdtr-history-empty",e.textContent=i.empty,void t.appendChild(e)}for(const a of l){const s=document.createElement("button");s.type="button",s.className="cdtr-history-row"+(a.id===e._sessionId?" current":"");const l=document.createElement("span");l.className="cdtr-history-label",l.textContent=(a.preview||"").trim()||`${i.untitled} ${Nc(a.created_at,o)}`;const c=document.createElement("span");c.className="cdtr-history-when",c.textContent=a.id===e._sessionId?i.current:Nc(a.last_active_at??a.created_at,o),s.append(l,c),s.addEventListener("click",async()=>{if(!e._editInFlight){if(a.id!==e._sessionId)try{const t=await r.request(r.sessionPath(a.id));r.onOpen(a.id,Array.isArray(t?.messages)?t.messages:[])}catch(t){return void console.warn("[edit-chat] conversation load failed:",t)}"function"==typeof n&&n()}}),t.appendChild(s)}}}function Nc(t,e){const n="number"==typeof t?t:Date.parse(String(t||""));if(!Number.isFinite(n))return"";const r=n<1e12?1e3*n:n,o=Date.now()-r,i=36e5,a=24*i;if(o>7*a)return new Date(r).toLocaleDateString("en"===e?"en-GB":"he-IL",{day:"numeric",month:"short"});const s=new Intl.RelativeTimeFormat("en"===e?"en":"he",{numeric:"auto"});return o<i?s.format(-Math.max(1,Math.round(o/6e4)),"minute"):o<a?s.format(-Math.round(o/i),"hour"):s.format(-Math.round(o/a),"day")}const Hc="cdtr-history-styles",zc="\n .cdtr-history { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;\n font: 14px/1.45 Heebo, Arial, sans-serif; color: #6b6680; }\n .cdtr-history-empty { padding: 28px 8px; text-align: center; }\n .cdtr-history-row {\n display: flex; width: 100%; gap: 10px; align-items: baseline; justify-content: space-between;\n padding: 11px 12px; border: 0; border-radius: 12px; background: none; cursor: pointer;\n font: inherit; color: #16131f; text-align: start;\n }\n .cdtr-history-row:hover, .cdtr-history-row:focus-visible { background: rgba(40, 30, 80, 0.05); outline: none; }\n .cdtr-history-row.current { background: rgba(106, 76, 240, 0.09); }\n .cdtr-history-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .cdtr-history-when { flex: 0 0 auto; font-size: 12px; color: #6b6680; }\n";const Pc=`${(0,N.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/memories`,Dc="cdtr-ai-memory-changed",Rc={business:20,page:10,text:300};function jc(t){try{window.dispatchEvent(new CustomEvent(Dc,{detail:t||{}}))}catch{}}async function Fc(t){const e=!(!t||!t.forceRefresh),n="function"==typeof L.Ay.studioTokenProvider?L.Ay.studioTokenProvider:null;if(n)try{const t=await n({forceRefresh:e});if("string"==typeof t&&t.length>0)return t}catch(t){console.warn("[ai-memory] studioTokenProvider threw; falling back to editor.studioToken.",t)}return"string"==typeof L.Ay.studioToken&&L.Ay.studioToken.length>0?L.Ay.studioToken:null}async function qc(t,e,n,r){const o=await Fc({forceRefresh:r}),i={Accept:"application/json"};return void 0!==n&&(i["Content-Type"]="application/json"),o&&(i.Authorization=`Bearer ${o}`),fetch(e,{method:t,headers:i,body:void 0!==n?JSON.stringify(n):void 0})}async function Uc(t,e,n){try{let r=await qc(t,e,n,!1);401===r.status&&(r=await qc(t,e,n,!0));let o=null;try{o=await r.json()}catch{o=null}return r.ok||console.warn(`[ai-memory] ${t} failed: HTTP ${r.status}`,o),{ok:r.ok,status:r.status,data:o}}catch(e){return console.warn(`[ai-memory] ${t} error`,e),{ok:!1,status:0,data:null}}}async function Wc(t){const e=await Uc("DELETE",`${Pc}/${encodeURIComponent(t)}`);return{ok:e.ok||404===e.status,status:e.status}}function Vc(t){if(t&&t._memoryRow){try{t._memoryRow.remove()}catch{}t._memoryRow=null}}const Yc=/^image\/(png|jpe?g|webp|gif)$/i,Gc=/\.(html?|txt|md|css|json|csv|xml|svg)$/i;function Xc(t){return/<!doctype\s+html|<html[\s>]|<body[\s>]/i.test(String(t||""))}function Zc(t,e){t._attachments=[],t._files=[],t._attachLang=e,t.setAttribute("accept","image/png,image/jpeg,image/webp,image/gif,.html,.htm,.txt,.md,.css,.json,.csv,text/html,text/plain"),t.addEventListener("cdtr-chat:files",e=>{$c(t,e?.detail?.files||[])}),t.addEventListener("paste",e=>{const n=function(t){if(!t)return[];const e=Array.from(t.items||[]),n=e.filter(t=>"file"===t.kind&&Yc.test(t.type)).map(t=>t.getAsFile()).filter(Boolean);return n.length>0?n:Array.from(t.files||[]).filter(t=>Yc.test(t.type))}(e.clipboardData);if(n.length>0)return e.preventDefault(),void $c(t,n);const r=e.clipboardData?.getData("text/plain")||"";r.length<2e3||(e.preventDefault(),Jc(t,function(t){return Xc(t)?"page.html":function(t){return(String(t||"").match(/<[a-z][\w-]*[\s>]/gi)||[]).length>=5}(t)?"snippet.html":"pasted.txt"}(r),r))}),t.addEventListener("dragover",t=>{var e;(e=t.dataTransfer)&&Array.from(e.types||[]).includes("Files")&&t.preventDefault()}),t.addEventListener("drop",e=>{const n=Array.from(e.dataTransfer?.files||[]).filter(t=>Yc.test(t.type)||Gc.test(t.name));0!==n.length&&(e.preventDefault(),$c(t,n))})}function Qc(t){return(t._files||[]).map(t=>{let{name:e,text:n}=t;return{name:e,text:n}})}function Kc(t,e){t._files=(t._files||[]).filter(t=>t!==e&&t.text!==e?.text),sd(t)}function Jc(t,e,n){const r=String(n).slice(0,15e5);t._files=[...t._files||[],{name:e,text:r,size:r.length}].slice(-3),sd(t)}async function $c(t,e){for(const n of Array.from(e))try{if(Yc.test(n.type)){const e=await td(n);t._attachments=[...t._attachments||[],e].slice(-4)}else(Gc.test(n.name||"")||/^text\//.test(n.type||""))&&Jc(t,n.name||"file.txt",await n.text())}catch(t){console.warn("[edit-chat] could not read file",n?.name,t)}sd(t)}async function td(t){const e=await createImageBitmap(t),n=Math.min(1,1568/Math.max(e.width,e.height)),r=Math.max(1,Math.round(e.width*n)),o=Math.max(1,Math.round(e.height*n)),i=document.createElement("canvas");i.width=r,i.height=o;const a=i.getContext("2d");a.fillStyle="#ffffff",a.fillRect(0,0,r,o),a.drawImage(e,0,0,r,o),e.close?.();const s=i.toDataURL("image/jpeg",.85);return{media_type:"image/jpeg",b64:s.slice(s.indexOf(",")+1),preview:s}}const ed=["display:flex","gap:8px","padding:4px 2px","overflow-x:auto","align-items:center"].join(";"),nd=["position:relative","width:56px","height:56px","border-radius:8px","overflow:hidden","flex:0 0 auto","border:1px solid rgba(15,23,42,.12)","background:#fff"].join(";"),rd=["position:relative","height:56px","min-width:150px","max-width:220px","box-sizing:border-box","padding:8px 28px 8px 10px","border-radius:8px","flex:0 0 auto","display:flex","gap:8px","align-items:center","border:1px solid rgba(15,23,42,.12)","background:#fff","font:12px/1.3 system-ui,sans-serif","color:#0f172a","direction:ltr"].join(";"),od=["flex:0 0 auto","width:34px","height:34px","border-radius:6px","display:flex","align-items:center","justify-content:center","font:700 10px system-ui,sans-serif","color:#fff","background:#6366f1","text-transform:uppercase"].join(";"),id=["position:absolute","top:2px","inset-inline-end:2px","width:18px","height:18px","padding:0","border:0","border-radius:50%","background:rgba(15,23,42,.72)","color:#fff","font:12px/18px system-ui,sans-serif","cursor:pointer"].join(";");function ad(t,e){const n=document.createElement("button");return n.type="button",n.textContent="×",n.setAttribute("aria-label",t),n.setAttribute("style",id),n.addEventListener("click",e),n}function sd(t){const e=t._attachLang;let n=t._attachStrip;const r=t._attachments||[],o=t._files||[];if(0===r.length&&0===o.length)return n?.remove(),void(t._attachStrip=null);n||(n=document.createElement("div"),n.setAttribute("slot","above-composer"),n.setAttribute("style",ed),t.appendChild(n),t._attachStrip=n);const i="en"===e,a=o.map(e=>{const n=document.createElement("div");n.setAttribute("style",rd),n.title=e.name;const r=document.createElement("div");r.setAttribute("style",od),r.textContent=(e.name.split(".").pop()||"txt").slice(0,4);const o=document.createElement("div");o.setAttribute("style","min-width:0;overflow:hidden");const a=document.createElement("div");a.setAttribute("style","font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"),a.textContent=e.name;const s=document.createElement("div");var l;return s.setAttribute("style","color:#64748b"),s.textContent=(l=e.size||e.text.length)>=1024?`${Math.round(l/1024)} KB`:`${l} B`,o.append(a,s),n.append(r,o,ad(i?"Remove file":"הסרת קובץ",()=>Kc(t,e))),n}),s=r.map((e,n)=>{const r=document.createElement("div");r.setAttribute("style",nd);const o=document.createElement("img");return o.src=e.preview,o.alt="",o.setAttribute("style","width:100%;height:100%;object-fit:cover;display:block"),r.append(o,ad(i?"Remove image":"הסרת תמונה",()=>{t._attachments=(t._attachments||[]).filter((t,e)=>e!==n),sd(t)})),r});n.replaceChildren(...a,...s)}const ld={he:{title:"שפרו את הבקשה",busy:"משפר את הבקשה…",failed:"לא הצלחתי לשפר כרגע, נסו שוב",empty:"דף נחיתה לעסק שלי"},en:{title:"Improve my request",busy:"Improving your request…",failed:"Could not improve it right now, try again",empty:"A landing page for my business"}};function cd(t,e){const n=ld[e.lang]||ld.en;let r=null;const o=()=>t.shadowRoot?.querySelector("textarea");async function i(){if(!r||r.disabled||e.busy())return;const i=o(),a=String(t._draft??i?.value??"").trim()||n.empty;r.disabled=!0,r.classList.add("working");const s=i?.placeholder;i&&(i.placeholder=n.busy);try{const n=await e.improve(a);if(!n)throw new Error("empty");t._draft=n,i&&(i.value=n),t.requestUpdate?.(),requestAnimationFrame(()=>{const t=o();t&&(t.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),t.focus(),t.setSelectionRange(t.value.length,t.value.length))})}catch(t){return console.warn("[edit-chat] improve failed:",t),i&&(i.placeholder=n.failed),setTimeout(()=>{const t=o();t&&t.placeholder===n.failed&&(t.placeholder=s||"")},2600),r.disabled=!1,void r.classList.remove("working")}i&&(i.placeholder=s||""),r.disabled=!1,r.classList.remove("working")}const a=()=>{const e=t.shadowRoot;if(!e)return;if(!e.getElementById("cdtr-improve-styles")){const t=document.createElement("style");t.id="cdtr-improve-styles",t.textContent="\n .cdtr-improve { position: relative; }\n .cdtr-improve svg { display: block; }\n .cdtr-improve.working svg { animation: cdtr-improve-spin 1s linear infinite; }\n .cdtr-improve:not(:disabled):hover { color: #7c3aed; }\n @keyframes cdtr-improve-spin { to { transform: rotate(360deg); } }\n @media (prefers-reduced-motion: reduce) { .cdtr-improve.working svg { animation: none; } }\n",e.appendChild(t)}const o=e.querySelector(".tools");if(!o)return;if(r&&r.isConnected&&o.contains(r))return;r=r||(()=>{const t=document.createElement("button");return t.type="button",t.className="icon-btn cdtr-improve",t.title=n.title,t.setAttribute("aria-label",n.title),t.innerHTML='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3.5l1.8 4.7 4.7 1.8-4.7 1.8L12 16.5l-1.8-4.7L5.5 10l4.7-1.8z"/><path d="M18.5 15.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></svg>',t.addEventListener("click",i),t})();const a=o.querySelector(".spacer");o.insertBefore(r,a||null)},s=t.updated?.bind(t);t.updated=function(t){s?.(t),a()},Promise.resolve(t.updateComplete).then(a).catch(()=>{})}const dd=["createMailingList"];function pd(t){const e=t&&t.hostTools;return e&&"object"==typeof e?dd.filter(t=>"function"==typeof e[t]):[]}function hd(t,e){const n=t?.configure?.editorProps?.form;if(!n)return;const r={id:e.id,name:e.name,key:e.id,label:e.name};Array.isArray(n.mailingLists)?n.mailingLists.some(t=>String(t?.id??t?.key)===e.id)||n.mailingLists.push(r):n.mailingLists&&Array.isArray(n.mailingLists.items)?n.mailingLists.items.some(t=>String(t?.id??t?.key)===e.id)||n.mailingLists.items.push(r):n.mailingLists=[r]}async function ud(t,e,n){const r=e&&e.call_id;if(!r)return;const o=e.name,i=dd.includes(o)&&t?.hostTools&&t.hostTools[o];let a;if("function"!=typeof i)a={call_id:r,ok:!1,error:"This platform does not offer that action."};else try{const n=await function(t,e){let n;return Promise.race([t,new Promise((t,r)=>{n=setTimeout(()=>r(new Error("timeout")),e)})]).finally(()=>clearTimeout(n))}(Promise.resolve(i.call(t.hostTools,e.args||{})),55e3);if("createMailingList"===o){const o=n&&(n.id??n.key),i=null!=o&&""!==o?String(o):"";if(!i)throw new Error("The list was not created.");const s={id:i,name:String(n&&(n.name||n.label)||e.args?.name||i)};hd(t,s),a={call_id:r,ok:!0,result:s}}else a={call_id:r,ok:!0,result:n??null}}catch(t){const e=t&&"timeout"===t.message?"The platform did not answer in time.":String(t&&t.message||t||"failed");console.warn(`[edit-chat] host tool ${o} failed:`,t),a={call_id:r,ok:!1,error:e.slice(0,300)}}try{await n(a)}catch(t){console.warn("[edit-chat] host tool result not delivered:",t)}}var fd=a(3916);const md=/(?:https?:\/\/|www\.)[^\s<>"'`]+/i,gd=/[.,;:!?)\]}'"׳״”’]+$/,bd=new Set(["vimeo.com","player.vimeo.com","youtube.com","m.youtube.com","youtu.be","youtube-nocookie.com"]),yd=/\.(mp4|webm|mov|m4v|ogg|mp3|wav|png|jpe?g|gif|webp|svg|avif|pdf)$/i;function Ad(t){if("string"!=typeof t)return null;const e=md.exec(t);if(!e)return null;const n=e[0].replace(gd,"");let r=/^www\./i.test(n)?`https://${n}`:n;try{const t=new URL(r);if("http:"!==t.protocol&&"https:"!==t.protocol)return null;if(!t.hostname.includes("."))return null;if(function(t){const e=t.hostname.toLowerCase().replace(/^www\./,"");return bd.has(e)||yd.test(t.pathname)}(t))return null;r=t.toString()}catch{return null}return{url:r,rest:(t.slice(0,e.index)+t.slice(e.index+e[0].length)).replace(/\s+/g," ").trim()}}function wd(t){return"string"!=typeof t?0:t.replace(/<(script|style|noscript|template)\b[^>]*>[\s\S]*?<\/\1>/gi," ").replace(/<[^>]+>/g," ").replace(/&[a-z#0-9]+;/gi," ").replace(/\s+/g," ").trim().length}const xd=200;let vd=!1;vl.A.on(vl.q.ON_UNDO,()=>{vd=!0});const kd=(0,N.Ay)()?"http://127.0.0.1:8000/api/newsletter/chat-edit-v2":"https://studio.creaditor.ai/api/newsletter/chat-edit-v2",Cd=(0,N.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai",_d="/api/datastore/sessions/by-doc";function Ed(){return(0,T.zZ)()?"ai-page":"editor-panel"}const Sd="cdtr-edit:messages";function Md(t){return t?"":(0,T.zZ)()?`${Sd}:ai-page`:Sd}const Bd=[{id:"tighten",label:"קצר וחד יותר"},{id:"warmer",label:"הוסף חמימות"},{id:"cta",label:"חזק את הקריאה לפעולה"}],Td=[{id:"tighten",label:"Tighten the copy"},{id:"warmer",label:"Make it warmer"},{id:"cta",label:"Strengthen the CTA"}],Ld=[{id:"reviews",label:"הוסף ביקורות של לקוחות"},{id:"warmer",label:"שנה את הטון לחם ואישי יותר"},{id:"cta",label:"חזק את הכפתור הראשי"}],Id=[{id:"reviews",label:"Add customer reviews"},{id:"warmer",label:"Make the tone warmer and more personal"},{id:"cta",label:"Strengthen the main button"}],Od={he:"משווקטור",en:"Meshavektor"},Nd={he:"עצור",en:"Stop"},Hd={he:"חושב…",en:"Thinking…"},zd={he:t=>1===t?"בוצע שינוי אחד.":`בוצעו ${t} שינויים.`,en:t=>1===t?"Applied 1 change.":`Applied ${t} changes.`},Pd={he:t=>"\n\n⛔ נגמרו לכם הטוקנים באמצע העריכה, ולכן היא נעצרה. מה שכבר בוצע נשמר. יש להטעין יתרה כדי להמשיך."+(t?`\n${t}`:""),en:t=>"\n\n⛔ You ran out of tokens partway through, so the edit stopped here. What was already applied is kept. Top up your balance to continue."+(t?`\n${t}`:"")},Dd={he:t=>t>0?`\n\n⏳ הפעולה נעצרה באמצע כי היא הגיעה לתקרת האורך של תור בודד. ${1===t?"שינוי אחד שכבר בוצע נשמר":`${t} שינויים שכבר בוצעו נשמרו`} על הקנבס, אבל היא לא הסתיימה. אפשר לבקש להמשיך, או לפצל לבקשות קטנות יותר.`:"\n\n⏳ הפעולה נעצרה באמצע כי היא הגיעה לתקרת האורך של תור בודד, לפני שהספיקה לשנות משהו. הקנבס לא השתנה. אפשר לבקש להמשיך, או לפצל לבקשות קטנות יותר.",en:t=>t>0?`\n\nThe turn hit the per-turn ceiling and stopped partway. ${1===t?"1 change was":`${t} changes were`} applied and kept on the canvas, but it did not finish. Ask it to continue, or split the request into smaller steps.`:"\n\nThe turn hit the per-turn ceiling and stopped before it changed anything. The canvas was not modified. Ask it to continue, or split the request into smaller steps."},Rd={he:t=>`\n\n⚠️ ${1===t?"שינוי אחד לא הוחל":`${t} שינויים לא הוחלו`} על הקנבס. פרטים בקונסול (\`[edit-chat]\`).`,en:t=>`\n\n⚠️ ${1===t?"1 change was not applied":`${t} changes were not applied`} to the canvas. See the console (\`[edit-chat]\`) for details.`},jd={he:"\n\nℹ️ לא בוצע שינוי בקנבס בתור הזה.",en:"\n\nNo change was made to the canvas in this turn."},Fd={he:"⏹ העריכה הופסקה. שינויים שכבר בוצעו נשארו על הקנבס.",en:"⏹ Edit stopped. Any changes already applied are still on the canvas."},qd={he:{prefix:"⚠️ העריכה נכשלה",network:"לא ניתן להתחבר לשרת. בדקו את החיבור ונסו שוב.",auth:"פג תוקף ההרשאה. יש להתחבר מחדש.",generic:t=>`משהו השתבש: ${t}`},en:{prefix:"⚠️ Edit failed",network:"Could not connect to the server. Check your connection and try again.",auth:"Your session has expired. Please sign in again.",generic:t=>`Something went wrong: ${t}`}};function Ud(t,e){return t&&(t._turnError=!0),e}function Wd(t,e){let{isNetwork:n=!1,isAuth:r=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const o=qd[t]||qd.en;let i;return i=n?o.network:r?o.auth:o.generic("string"==typeof e?e:String(e)),`${o.prefix}\n\n${i}`}function Vd(t){t?._busyEl&&Fl(t,t._busyEl)}const Yd=new Set(["fetch_url","search_pexels","search_icons","read_page","read_element","find_in_page","screenshot","get_outline","get_component","get_business_profile","list_components_by_type","list_leaf_components","find_components_by_content","critique_newsletter"]),Gd={he:{propose_directions:"מצייר כיווני עיצוב…",generate_page:"בונה את הדף…",generate_section:"בונה סקשן…",adapt_section:"מתאים את הדף…",kit_apply_ops:"עורך את הדף…",read_page:"קורא את הדף…",read_element:"בודק את הדף…",find_in_page:"מחפש בדף…",screenshot:"מסתכל על הדף…",search_pexels:"מחפש תמונות…",search_icons:"מחפש אייקונים…",fetch_url:"קורא את הקישור…",get_outline:"סורק את מבנה הדף…",get_component:"בודק את הרכיב…",get_business_profile:"קורא את פרטי העסק…",list_components_by_type:"סורק את הדף…",list_leaf_components:"סורק את הדף…",find_components_by_content:"מחפש בדף…",critique_newsletter:"בוחן את העיצוב…",apply_patch_ops:"עורך את הדף…",format_text:"מעצב את הטקסט…",insert_section:"מוסיף סקשן…",replace_section:"מחליף סקשן…",delete_section:"מוחק סקשן…",create_mailing_list:"יוצר קבוצת דיוור…"},en:{propose_directions:"Drawing looks for you to pick from…",generate_page:"Building the page…",generate_section:"Building a section…",adapt_section:"Adapting the page…",kit_apply_ops:"Editing the page…",create_mailing_list:"Creating a mailing list…",read_page:"Reading the page…",read_element:"Checking the page…",find_in_page:"Searching the page…",screenshot:"Looking at the page…",search_pexels:"Finding photos…",search_icons:"Finding icons…",fetch_url:"Reading the link…",get_outline:"Scanning the page layout…",get_component:"Checking an element…",get_business_profile:"Reading your business details…",list_components_by_type:"Scanning the page…",list_leaf_components:"Scanning the page…",find_components_by_content:"Searching the page…",critique_newsletter:"Reviewing the design…",apply_patch_ops:"Editing the page…",format_text:"Formatting text…",insert_section:"Adding a section…",replace_section:"Replacing a section…",delete_section:"Removing a section…"}},Xd={he:{read:"בודק את זה",edit:"משנה את זה",found:"מצאתי"},en:{read:"Looking at this",edit:"Changing this",found:"Found"}};function Zd(t,e,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Xl(t),Vc(t),$l(t),uc(t),Sc(t),t._busyEl&&$d(t);const o=t.shadowRoot?.querySelector("textarea");o&&(o.disabled=!0,t._busyTextarea=o),t._busyButtons=[...t.shadowRoot?.querySelectorAll("button")||[]].filter(t=>!t.disabled&&!t.classList.contains("send")&&!t.classList.contains("cdtr-edit-stop"));for(const e of t._busyButtons)e.disabled=!0;var i,a;document.documentElement.classList.add("cdtr-ai-turn"),t._busyRemote=!!r.remote,r.remote||(i=rp(),a={lang:e,userText:r.userText||""},i&&(cl&&cl!==i&&wl(),cl=i,dl=a||null,gl("start",i,{info:dl}),clearInterval(pl),pl=setInterval(()=>gl("ping",i,{info:dl}),4e3)));const s=document.createElement("div");s.className="row assistant cdtr-edit-row",s.dir="he"===e?"rtl":"ltr";const l=document.createElement("div");l.className="bubble cdtr-edit-bubble",s.appendChild(l);const c=document.createElement("div");c.className="cdtr-edit-busy-head";const d=document.createElement("cdtr-ai-face");d.className="cdtr-edit-face",c.appendChild(d),t._turnError=!1,(0,Vt.L)("thinking");const p=document.createElement("span");p.className="cdtr-edit-busy-label",p.textContent=Hd[e]||Hd.en,c.appendChild(p);const h=document.createElement("span");h.className="cdtr-edit-elapsed",h.textContent="0:00",c.appendChild(h);const u=Date.now();if(t._busyTimer=setInterval(()=>{h.textContent=function(t){const e=Math.max(0,Math.floor(t/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}(Date.now()-u),s.isConnected||Vd(t)},1e3),!r.remote){const r=document.createElement("button");r.type="button",r.className="cdtr-edit-stop",r.textContent=Nd[e]||Nd.en,r.addEventListener("click",()=>{try{n?.abort()}catch{}}),t._abortTurn=()=>{try{n?.abort()}catch{}},c.appendChild(r)}l.appendChild(c);const f=document.createElement("div");f.className="cdtr-edit-thinking",f.setAttribute("dir","auto"),l.appendChild(f),t._thinkingEl=f,t._busyEl=s,t._busyBubble=l,t.classList.add("cdtr-edit-busy-on"),Vd(t),Promise.resolve(t.updateComplete).then(()=>Vd(t)).catch(()=>{})}function Qd(t,e){const n=t._thinkingEl;n&&t._busyEl&&(n.textContent=(n.textContent+e).replace(/\*\*/g,""),t._busyRemote||Al("thinking",e),t._busyBubble?.classList.add("has-thinking"),n.scrollTop=n.scrollHeight,Vd(t))}function Kd(t){const e=t._thinkingEl;e&&(t._busyRemote||Al("reset"),e.textContent="",t._busyBubble?.classList.remove("has-thinking"))}function Jd(t,e){const n=t?._busyEl?.querySelector(".cdtr-edit-busy-label");n&&e&&(n.textContent=e),n&&e&&!t._busyRemote&&Al("label",e)}function $d(t){t._busyEl&&(0,Vt.L)(t._turnError?"error":"happy"),t._busyTimer&&(clearInterval(t._busyTimer),t._busyTimer=null),t._busyEl&&(t._busyEl.remove(),t._busyEl=null),t._busyBubble=null,t._thinkingEl=null,t.classList?.remove("cdtr-edit-busy-on"),t._busyTextarea&&(t._busyTextarea.disabled=!1,t._busyTextarea=null);for(const e of t._busyButtons||[])e.disabled=!1;t._busyButtons=null,document.documentElement.classList.remove("cdtr-ai-turn"),(0,Vt.QG)([]),t._busyRemote||wl(),t._busyRemote=!1}const tp={he:"הבינה המלאכותית עובדת על הדף הזה בלשונית אחרת. אפשר להמשיך כשהיא תסיים.",en:"The AI is working on this page in another tab. You can continue when it finishes."};function ep(t,e){const n=rp(),r=xl(n);if(r===!!t._remoteLock)return;t._remoteLock=r;const o=t.shadowRoot?.querySelector("textarea");if(r){o&&(o.disabled=!0),t.placeholder=tp[e]||tp.en;const r=function(t){for(const e of hl.values())if(e.docId===t)return e.info;return null}(n);if(!t._editInFlight&&!t._busyEl){const n="en"===r?.lang?"en":"he"===r?.lang?"he":e;r?.userText&&t.appendMessage?.({role:"user",text:r.userText,ts:Date.now()}),Zd(t,n,null,{remote:!0})}return}t._busyRemote&&$d(t),o&&!t._busyEl&&(o.disabled=!1),t.placeholder=t._contextPlaceholder||"",t._editInFlight||lp(t)}function np(t,e){return!!xl(rp())&&(t.appendMessage?.({role:"assistant",text:tp[e]||tp.en,ts:Date.now()}),!0)}function rp(){try{const t=I.M.get("app","_id");return"string"==typeof t&&t.length>0?t:null}catch(t){return null}}function op(t,e,n){const r=()=>{t._pendingDirection=n,t._submitChip?.(e)};if(!t._editInFlight)return r();t._stoppedForPick=!0,t._abortTurn?.();const o=Date.now(),i=()=>{if(!t._editInFlight)return r();Date.now()-o>8e3||setTimeout(i,120)};setTimeout(i,120)}function ip(t){const e="string"==typeof t.content?t.content:"";return"assistant"===t.role?Gl(Jl(hc(e).text).text).text:e}function ap(t,e){const n=e.filter(t=>t&&("user"===t.role||"assistant"===t.role)).pop();if(!n||"assistant"!==n.role)return;const r=jl(t),o=n.attachments&&Array.isArray(n.attachments.directions)?n.attachments.directions:null;o&&o.length>0&&Tc(t,r,o,(e,n)=>op(t,e,n));const i=hc("string"==typeof n.content?n.content:"");null!==i.ask&&fc(t,r,i.ask,e=>t._submitChip?.(e),i.auto);const a=i.text,s=Jl(a);if(s.questions.length>0)return void tc(t,r,s.questions,e=>t._submitChip?.(e));const l=Gl(a);l.chips.length>0&&Zl(t,r,l.chips,l.kind,e=>t._submitChip?.(e))}async function sp(t){const e=await mp(L.Ay,{forceRefresh:!1});if(!e)throw new Error("no studio token");const n=await fetch(`${Cd}${t}`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${e}`}});if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function lp(t){const e=rp();if(!e)return;t.storageKey="";const n=t.messages||[],r=t._chatEpoch||0;let o=null;try{o=await mp(L.Ay,{forceRefresh:!1})}catch(t){return}if(!o)return;const i=`${Cd}${_d}?doc_id=${encodeURIComponent(e)}&surface=${Ed()}`;try{const e=await fetch(i,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${o}`}});if(!e.ok)return void console.warn(`[edit-chat] transcript load failed: HTTP ${e.status}`);const a=await e.json();t._sessionId="string"==typeof a?.session_id?a.session_id:null;const s=Array.isArray(a?.messages)?a.messages:[];if(0===s.length)return;if((t._chatEpoch||0)!==r)return;const l=s.filter(t=>t&&("user"===t.role||"assistant"===t.role)).map(t=>({role:t.role,text:ip(t),ts:"number"==typeof t.created_at?t.created_at:Date.now()})).filter(t=>t.text.length>0);t.messages=function(t,e,n){const r=e.length<=n.length&&e.every((t,e)=>n[e]===t)?n.slice(e.length):n;if(0===r.length)return t;const o=t=>`${t.role}\0${t.text}`;let i=Math.min(t.length,r.length);for(;i>0;){const e=t.slice(t.length-i).map(o),n=r.slice(0,i).map(o);if(e.every((t,e)=>t===n[e]))break;i--}return[...t,...r.slice(i)]}(l,n,t.messages||[]),0===n.length&&Promise.resolve(t.updateComplete).then(()=>ap(t,s)).catch(()=>{})}catch(t){console.warn("[edit-chat] transcript load failed:",t)}}const cp={he:{tokens:"טוקנים",low:"יתרה נמוכה",empty:"נגמרו הטוקנים"},en:{tokens:"tokens",low:"Low balance",empty:"Out of tokens"}};function dp(t){const e=Math.max(0,Math.round(t));if(e<1e3)return String(e);if(e<1e6){const t=e/1e3,n=t<10?t.toFixed(1).replace(/\.0$/,""):String(Math.round(t));if("1000"!==n)return`${n}K`}const n=e/1e6;return`${n<10?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}M`}const pp="cdtr-ai-balance";let hp=null;function up(t,e,n,r){if(!t)return;const o=t.querySelector(":scope > .cdtr-balance")||t.shadowRoot&&t.shadowRoot.querySelector(".cdtr-balance")||null;if("number"!=typeof n||Number.isNaN(n))return void o?.remove();r&&(t._balancePaymentUrl=r);const i=r||t._balancePaymentUrl||"";!function(){if(document.getElementById("cdtr-balance-styles"))return;const t=document.createElement("style");t.id="cdtr-balance-styles",t.textContent="\n .cdtr-balance {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 26px;\n padding: 0 8px;\n margin-inline-end: 2px;\n border-radius: 8px;\n border: 0;\n background: transparent;\n color: #6f676b;\n font-size: 12px;\n font-weight: 500;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n text-decoration: none;\n cursor: default;\n }\n .cdtr-balance.is-low { color: #8a5a00; background: #fbf4e6; }\n .cdtr-balance.is-empty { color: #a3261f; background: #fdf1f0; }\n /* Only clickable when there is somewhere to send them. */\n .cdtr-balance[href] { cursor: pointer; }\n .cdtr-balance[href]:hover { text-decoration: underline; text-underline-offset: 3px; }\n .cdtr-balance-dot {\n width: 6px; height: 6px; border-radius: 50%;\n background: currentColor; opacity: 0.55; flex: none;\n }\n ",document.head.appendChild(t)}();const a=cp[e]||cp.en,s=n<=0,l=!s&&n<4e4;!function(t){hp=t;try{window.dispatchEvent(new CustomEvent(pp,{detail:t}))}catch{}}({balance:n,url:i,low:l,empty:s,text:s?a.empty:dp(n),title:`${n.toLocaleString()} ${a.tokens}${l?` -- ${a.low}`:""}`});const c=!!i&&(l||s),d=o&&"A"===o.tagName!==c;d&&o.remove();let p=d?null:o;if(!p&&(p=document.createElement(c?"a":"span"),p.className="cdtr-balance",p.setAttribute("slot","header-extra"),t.appendChild(p),null===p.assignedSlot)){const e=t.shadowRoot&&t.shadowRoot.querySelector(".header-actions");if(!e)return p.remove(),void(t._balanceAnchorWarned||(t._balanceAnchorWarned=!0,console.warn("[edit-chat] balance pill: no header-extra slot and no .header-actions; skipping")));if(p.removeAttribute("slot"),e.prepend(p),!t.shadowRoot.getElementById("cdtr-balance-styles")){const e=document.getElementById("cdtr-balance-styles");e&&t.shadowRoot.appendChild(e.cloneNode(!0))}}p.classList.toggle("is-low",l),p.classList.toggle("is-empty",s),c&&(p.setAttribute("href",i),p.setAttribute("target","_blank"),p.setAttribute("rel","noopener noreferrer"));const h=s?a.empty:`${dp(n)} ${a.tokens}`;p.textContent="";const u=document.createElement("span");u.className="cdtr-balance-dot",p.appendChild(u),p.appendChild(document.createTextNode(h)),p.title=s?a.empty:`${n.toLocaleString()} ${a.tokens}${l?` -- ${a.low}`:""}`}function fp(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e="en"===t.lang?"en":"he",n=t.endpoint||kd,r=document.createElement("cdtr-chat");r.setAttribute("lang",e),function(){if(document.getElementById(Dl))return;const t=document.createElement("link");t.id=Dl,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Assistant:wght@400;500;600;700&family=Frank+Ruhl+Libre:wght@400;500&display=swap",document.head.appendChild(t)}(),r.setAttribute("variant","studio"),r.style.setProperty("--cdtr-chat-font","Arial, Helvetica, sans-serif"),r.style.setProperty("--cdtr-chat-display-font","Arial, Helvetica, sans-serif");const o=document.createElement("cdtr-ai-face");o.setAttribute("slot","avatar"),o.style.setProperty("--face-size","68px"),r.appendChild(o);let i=null;r.addEventListener("input",()=>{r._busyEl||((0,Vt.L)("listening"),clearTimeout(i),i=setTimeout(()=>{r._busyEl||(0,Vt.L)("idle")},1400))}),r.closable=!1,r.addEventListener("cdtr-chat:close",()=>(0,T.$7)()),Promise.resolve(r.updateComplete).then(()=>Wl(r)).catch(()=>{}),r.setAttribute("storage-key",Md(rp())),r.setAttribute("header","he"===e?"שיחה חדשה":"New conversation"),r.setAttribute("greeting","he"===e?`היי, אני ${Od.he}`:`Hi, I'm ${Od.en}`);const a="he"===e;let s=null;const l=t=>{r._contextPlaceholder=t,r._remoteLock||(r.placeholder=t)},c=()=>{const t=(0,T.zZ)()&&El(I.M.get(T.yS))?"new-page":(0,T.zZ)()?"page":"components";t!==s&&(s=t,"new-page"===t?(r.setAttribute("prompt",a?"מה בונים היום?":"What are we building today?"),l(a?"למשל: סטודיו פילאטיס בגבעתיים, שיעור ניסיון ב-49 ₪, וואטסאפ 050-1234567":"e.g. Pilates studio in Brooklyn, first class $15, WhatsApp +1 555 123 4567"),r.actions=[]):"page"===t?(r.setAttribute("prompt",a?"מה לשנות בדף?":"What should we change?"),l(""),r.actions=a?Ld:Id):(r.setAttribute("prompt",a?"מה לערוך?":"What should I edit?"),l(""),r.actions=a?Bd:Td))};var d;c(),I.M.connect(T.n6,c),I.M.connect(T.yS,c),d=t=>{t===rp()&&ep(r,e)},ml(),ul.add(d),function(t){ml(),fl.add(t)}((t,e,n)=>{if(t===rp()){if("doc"===e){if(!(0,T.zZ)()||!n||"string"!=typeof n.html)return;return ct(),o=n,tt.add(o),void I.M.set({[T.yS]:n})}var o;r._busyRemote&&("thinking"===e&&"string"==typeof n?Qd(r,n):"reset"===e?Kd(r):"label"===e&&"string"==typeof n&&Jd(r,n))}}),I.M.connect(T.yS,()=>{null!==cl&&r._busyEl&&!r._busyRemote&&Al("doc",I.M.get(T.yS))}),Promise.resolve(r.updateComplete).then(()=>ep(r,e)).catch(()=>{}),Zc(r,e);const p=async(t,n)=>{const o=I.M.get(T.yS),i=o?jt.imageSwapOps(o,n.key,t):null,a=i?Ip(T.o6,i):null;if(a&&a.applied>0){const t=jt.selectionContext(I.M.get(T.yS),n.key);return void(t&&I.M.set({kitSelection:{...n,...t}}))}r._submitChip?.(function(t,e){return ic(t).swapAi(e)}(jl(r,e),t))},h=()=>(0,T.zZ)()?I.M.get("kitSelection"):null;Cc(r,e,{getSelection:h,onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t),I.M.connect(T.cP,t)}}),function(t,e,n){let{getSelection:r,onChange:o,isBusy:i,swap:a}=n;if(!t)return;const s=()=>{const n=r(),o=ac()&&mc(n);let s=t._swapBtn;if(!o)return s?.remove(),void(t._swapBtn=null);s||(s=document.createElement("button"),s.type="button",s.setAttribute("slot","above-composer"),s.setAttribute("style",bc),s.addEventListener("click",async()=>{if(i())return;const t=r();if(!mc(t))return;const e=await sc();e&&await a(e,t)}),t.appendChild(s),t._swapBtn=s),s.dir="en"===e?"ltr":"rtl";const l=gc(n),c=document.createElement("span");if(c.textContent=ic(e).change,l){const t=document.createElement("img");t.alt="",t.src=l,t.setAttribute("style",yc),t.addEventListener("error",()=>t.remove()),s.style.paddingInlineStart="5px",s.replaceChildren(t,c)}else s.style.paddingInlineStart="12px",s.replaceChildren(c)};s(),o(s)}(r,e,{getSelection:h,onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t)},isBusy:()=>!!r._editInFlight,swap:p}),wc(0,e,{getSelection:h,isBusy:()=>!!r._editInFlight,swap:p,notify:t=>r.appendMessage?.({role:"assistant",text:t,ts:Date.now()})}),Pe(r,e,{getSelection:h,getDoc:()=>I.M.get(T.yS),onChange:t=>{I.M.connect("kitSelection",t),I.M.connect(T.n6,t)},onDocChange:t=>(I.M.connect(T.yS,t),()=>I.M.disconnect(t)),isBusy:()=>!!r._editInFlight,fields:()=>L.Ay?.configure?.editorProps?.form?.fields||[],mailingLists:()=>_p(L.Ay).formConfig?.mailingLists||[],hasFieldHook:t=>"function"==typeof L.Ay?.formHooks?.[t],approveField:(t,e)=>(0,fd.f)(t,e),addToCatalog:(t,e)=>{const n=L.Ay?.configure?.editorProps?.form;if(!n||!t)return;Array.isArray(n.fields)||(n.fields=[]);const r=n.fields.findIndex(n=>n===e||n&&null!=t.id&&n.id===t.id);-1===r?n.fields.push(t):n.fields[r]={...n.fields[r],...t}},createList:"function"==typeof L.Ay?.hostTools?.createMailingList?async t=>{const e=await L.Ay.hostTools.createMailingList({name:t,description:""}),n=e&&(e.id??e.key);if(null==n||""===n)return null;const r={id:String(n),name:String(e&&(e.name||e.label)||t)};return hd(L.Ay,r),r}:null,apply:t=>{const e=Ip(T.o6,t);if(!e||0===e.applied)return!1;const n=I.M.get("kitSelection"),r=n&&jt.selectionContext(I.M.get(T.yS),n.key);return r&&I.M.set({kitSelection:{...n,...r}}),!0}}),cd(r,{lang:e,busy:()=>!!r._editInFlight,improve:async t=>{const e=await mp(L.Ay,{forceRefresh:!1});if(!e)throw new Error("no studio token");const n=I.M.get(T.yS),r=I.M.get("kitSelection"),o=r&&(r.label||r.text)?`${r.label||""}${r.text?`: ${String(r.text).slice(0,300)}`:""}`:void 0,i=await fetch(`${Cd}/api/prompt-improve`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({text:t,page:n&&!El(n)?"existing":"new",...o?{selection:o.slice(0,400)}:{}})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const a=await i.json();return"string"==typeof a?.text?a.text:""}}),function(t,e){t._historyDeps=e}(r,{lang:e,request:sp,listPath:()=>{const t=rp();return t?`${_d}/list?doc_id=${encodeURIComponent(t)}&surface=${Ed()}&limit=30`:null},sessionPath:t=>`/api/datastore/sessions/${encodeURIComponent(t)}`,onOpen:(t,e)=>{r._chatEpoch=(r._chatEpoch||0)+1,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=t,r._newSession=!1,r.messages=e.filter(t=>t&&("user"===t.role||"assistant"===t.role)).map(t=>({role:t.role,text:ip(t),ts:"number"==typeof t.created_at?t.created_at:Date.now()})).filter(t=>t.text.length>0),Promise.resolve(r.updateComplete).then(()=>ap(r,e)).catch(()=>{})}}),r.setAttribute("header",Od[e]||Od.en);const u=()=>{!async function(t,e){try{const n=L.Ay,r=await mp(n);if(!r)return;const o=await fetch(`${Cd}/api/business-analyze/balance`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});if(!o.ok)return;const i=await o.json();up(t,e,i&&i.balance,i&&i.paymentUrl)}catch(t){console.warn("[edit-chat] balance probe failed; pill not shown",t)}}(r,e)};r.updateComplete&&"function"==typeof r.updateComplete.then?r.updateComplete.then(u).catch(u):setTimeout(u,0),r._refreshBalance=u,r.addEventListener("cdtr-chat:submit",t=>{if(r._editInFlight)return void console.log("[edit-chat] submit ignored: previous edit still streaming");const o=t?.detail?.text;if("string"!=typeof o||!o.trim())return;const i=r._pendingLinkText;if(r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),i)return r.appendMessage?.({role:"user",text:o.trim(),ts:Date.now()}),void vp(r,n,e,`${i}\n${o.trim()}`,{userBubbleShown:!0});const a="web"===I.M.get("config","channel")?function(t){return(t._files||[]).find(t=>!t.reference&&Xc(t.text))||null}(r):null;if(a)return void async function(t,e,n,r,o){const i=/[\u0590-\u05FF]/.test(r)||!r&&"he"===n,a=i?xp.he:xp.en;t.appendMessage?.({role:"user",text:r,ts:Date.now()});const s=()=>{o.reference=!0,vp(t,e,n,r,{userBubbleShown:!0})},l=()=>{if(wd(o.text)<200)return t.appendMessage?.({role:"assistant",text:a.shell,ts:Date.now()}),void s();Ft(o.text,""),Kc(t,o),console.log(`[edit-chat] page opened from attached ${o.name} (${o.text.length}ch)`),t.appendMessage?.({role:"assistant",text:a.opened(o.name),ts:Date.now()})},c=I.M.get(T.yS);if((0,T.zZ)()&&(!c||El(c)))return void l();t.appendMessage?.({role:"assistant",text:a.ask(o.name),ts:Date.now()}),Zl(t,n,[a.open,a.reference],"confirm",e=>{Xl(t),Vc(t),$l(t),uc(t),Sc(t),e===a.open?l():s()})}(r,n,e,o.trim(),a);const s="web"===I.M.get("config","channel")?Ad(o.trim()):null;s?async function(t,e,n,r,o){const i=/[\u0590-\u05FF]/.test(o.rest)||!o.rest&&"he"===n,a=i?wp.he:wp.en;let s=o.url;try{s=new URL(o.url).hostname.replace(/^www\./,"")}catch{}t.appendMessage?.({role:"user",text:r,ts:Date.now()});const l=async()=>{if(np(t,i?"he":"en"))return;t._editInFlight=!0;const l=new AbortController;let c;Zd(t,n,l,{userText:r}),Jd(t,a.opening);try{c=await async function(t,e){const n=async n=>{const r=await mp(L.Ay,{forceRefresh:n}),o={"Content-Type":"application/json",Accept:"application/json"};return r&&(o.Authorization=`Bearer ${r}`),fetch(`${Cd}${Ap}`,{method:"POST",headers:o,body:JSON.stringify({url:t}),signal:e})};try{let e=await n(!1);401===e.status&&(e=await n(!0));const r=await e.json().catch(()=>({}));return e.ok?"string"!=typeof r?.html?{ok:!1,reason:"the response had no page in it"}:{ok:!0,html:r.html,finalUrl:r.finalUrl||t}:{ok:!1,reason:r?.reason||`status ${e.status}`}}catch(t){return{ok:!1,reason:t?.message||String(t)}}}(o.url,l.signal)}finally{t._editInFlight=!1,t.busy=!1,$d(t)}if(!l.signal.aborted)if(c.ok)if(wd(c.html)<xd)t.appendMessage?.({role:"assistant",text:a.shell(s),ts:Date.now()});else{if(Ft(c.html,c.finalUrl),console.log(`[edit-chat] page copied from ${c.finalUrl} (${c.html.length}ch)`),!o.rest)return t.appendMessage?.({role:"assistant",text:a.opened(s),ts:Date.now()}),void Zl(t,n,[a.adapt],"options",e=>t._submitChip?.(e));vp(t,e,n,r,{userBubbleShown:!0})}else t.appendMessage?.({role:"assistant",text:a.failed(s,c.reason),ts:Date.now()})},c=I.M.get(T.yS);if((0,T.zZ)()&&(!c||El(c)))return void await l();t.appendMessage?.({role:"assistant",text:a.ask(s),ts:Date.now()}),t._pendingLinkText=r,Zl(t,n,[a.copy,a.useLink],"confirm",o=>{t._pendingLinkText=null,Xl(t),Vc(t),$l(t),uc(t),Sc(t),o===a.copy?l():vp(t,e,n,r,{userBubbleShown:!0})})}(r,n,e,o.trim(),s):vp(r,n,e,o.trim())}),r._submitChip=t=>{r._editInFlight||vp(r,n,e,t)},r.addEventListener("cdtr-chat:new",()=>{r._chatEpoch=(r._chatEpoch||0)+1,r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=null,r._newSession=!0});let f=Ed();return I.M.connect(T.n6,()=>{const t=Ed();if(t===f)return;f=t,r._chatEpoch=(r._chatEpoch||0)+1,r._pendingLinkText=null,Xl(r),Vc(r),$l(r),uc(r),Sc(r),r._sessionId=null,r._newSession=!1,r.messages=[];rp()?lp(r):r.storageKey=Md(null)}),r.addEventListener("cdtr-chat:action",t=>{if(r._editInFlight)return void console.log("[edit-chat] action ignored: previous edit still streaming");const o=t?.detail?.label;"string"==typeof o&&o&&vp(r,n,e,o)}),r}async function mp(t,e){const n=!(!e||!e.forceRefresh),r="function"==typeof t.studioTokenProvider?t.studioTokenProvider:null;if(r)try{const t=await r({forceRefresh:n});if("string"==typeof t&&t.length>0)return t}catch(t){console.warn("[edit-chat] studioTokenProvider threw; falling back to editor.studioToken.",t)}return"string"==typeof t.studioToken&&t.studioToken.length>0?t.studioToken:null}async function gp(t,e,n,r){const{forceRefresh:o=!1,onEvent:i=null,signal:a}=r||{},s=await mp(t,{forceRefresh:o});s||console.warn("[edit-chat] no auth token (neither editor.studioTokenProvider nor editor.studioToken yielded one); request will likely 401 from scopeGate."),o&&console.log("[edit-chat] retry attempt with refreshed token; token-present=",null!=s);const l={"Content-Type":"application/json",Accept:"text/event-stream, application/json"};s&&(l.Authorization=`Bearer ${s}`);let c=null;try{c=await fetch(e,{method:"POST",headers:l,body:JSON.stringify(n),signal:a})}catch(t){throw t}if((c.headers.get("content-type")||"").includes("text/event-stream")&&c.body&&i)return await async function(t,e){const n=t.getReader(),r=new TextDecoder;let o="";try{for(;;){const{done:t,value:i}=await n.read();if(t)break;let a;for(o+=r.decode(i,{stream:!0});-1!==(a=o.indexOf("\n\n"));){const t=o.slice(0,a);o=o.slice(a+2);let n,r="message",i="";for(const e of t.split("\n"))e.startsWith("event:")?r=e.slice(6).trim():e.startsWith("data:")&&(i+=(i?"\n":"")+e.slice(5).replace(/^ /,""));if(i){try{n=JSON.parse(i)}catch(t){console.warn("[edit-chat] sse data parse failed event="+r,t);continue}try{await e(r,n)}catch(t){console.warn("[edit-chat] sse handler threw event="+r,t)}}}}}finally{try{n.releaseLock()}catch{}}}(c.body,i),{resp:c,body:null,streamed:!0};let d=null;try{d=await c.json()}catch{d=null}return{resp:c,body:d,streamed:!1}}const bp=new Set(["edit","section","page","adapt"]);function yp(t){const e=function(t){return Array.isArray(t)?t.map(t=>{if(!t||"root"!==t.type)return t;const e=Object.prototype.hasOwnProperty.call(t,"aiDocParked"),n=t.props&&Object.prototype.hasOwnProperty.call(t.props,"aiDocParked");if(!e&&!n)return t;const{aiDocParked:r,...o}=t;if(!n)return o;const i={...t.props};return delete i.aiDocParked,{...o,props:i}}):t}((0,H.U2)());if(!bp.has(t))return e;const n=Array.isArray(e)?e:[],r=n.find(t=>t&&"root"===t.type)||n[0];if(!r)return e;const{aiDoc:o,...i}=r,a={...i.props||{}};return delete a.aiDoc,[{...i,props:a,children:[]}]}const Ap="/api/page-fetch",wp={he:{ask:t=>`להעתיק את הדף מ-${t} במקום הדף שעל הקנבס?`,opening:"פותח את הדף…",copy:"להעתיק את הדף",useLink:"לא, רק להשתמש בקישור",failed:(t,e)=>`לא הצלחתי לפתוח את ${t}: ${e}`,shell:t=>`הדף ב-${t} נבנה בדפדפן עם JavaScript, אז מה שמגיע ממנו ריק. אפשר לפתוח אותו בדפדפן, להעתיק את ה-HTML ולהדביק דרך Import HTML.`,opened:t=>`פתחתי את הדף מ-${t} כמו שהוא. מה לשנות בו?`,adapt:"תתאים את הדף לעסק שלי"},en:{ask:t=>`Copy the page from ${t} over the one on the canvas?`,opening:"Opening the page…",copy:"Copy the page",useLink:"No, just use the link",failed:(t,e)=>`I could not open ${t}: ${e}`,shell:t=>`The page at ${t} is built in the browser by JavaScript, so what comes back is empty. Open it in your browser, copy its HTML and paste it through Import HTML.`,opened:t=>`I opened the page from ${t} as it is. What should change?`,adapt:"Adapt this page to my business"}};const xp={he:{ask:t=>`להשתמש ב-${t} כדף שלך במקום הדף שעל הקנבס, או רק כהשראה?`,open:"זה הדף שלי",reference:"רק השראה",shell:"הדף הזה כמעט ריק (הוא נבנה עם JavaScript), אז אין מה לפתוח. אשתמש בו כהשראה.",opened:t=>`פתחתי את ${t} כדף שלך. מה לשנות בו?`},en:{ask:t=>`Use ${t} as your page, replacing the one on the canvas, or just as a reference?`,open:"This is my page",reference:"Just a reference",shell:"That page is almost empty (it is built by JavaScript), so there is nothing to open. I will use it as a reference.",opened:t=>`I opened ${t} as your page. What should change?`}};async function vp(t,e,n,r,o){if(np(t,/[\u0590-\u05FF]/.test(r)?"he":n))return;t._editInFlight=!0;const i=new AbortController;Zd(t,/[\u0590-\u05FF]/.test(r)?"he":n,i,{userText:r});try{return await async function(t,e,n,r,o,i){const a=jl(t,n),s=L.Ay,l=function(t){const e=(t._attachments||[]).map(t=>{let{media_type:e,b64:n}=t;return{media_type:e,b64:n}});return t._attachments=[],sd(t),e}(t),c=function(){if(!(0,T.zZ)())return{intent:"components"};const t=I.M.get(T.yS);if(El(t)){const e=Tp(t);return e?{intent:"page",anchorKey:e.key,anchorPos:e.pos,documentHasContent:!1}:{intent:"page"}}const e=Tp(t);if(!e)return{intent:"page"};const n=!t||"generated"!==t.origin,r=jt.sectionsOf(t).map(e=>({...e,content:jt.contentMap(t,e.key)||{text:[],images:[],links:[]}}));if(!n)return{intent:"page",anchorKey:e.key,anchorPos:e.pos,styleDigest:jt.styleDigest(t),documentHasContent:!0,...r.length>0?{sections:r}:{}};return{intent:r.length>0?"adapt":"section",anchorKey:e.key,anchorPos:e.pos,styleDigest:jt.styleDigest(t),documentHasContent:!0,...r.length>0?{sections:r}:{}}}(),d=yp(c.intent),p=Array.isArray(s.components)&&s.components[0]?.id?s.components[0].id:void 0;i?.userBubbleShown||t.appendMessage?.({role:"user",text:r,ts:Date.now()});t.busy=!0;const h=(t.messages||[]).map(t=>({role:t.role,content:t.text}));if(i?.userBubbleShown){for(;h.length>0&&"user"!==h[h.length-1].role;)h.pop();h[h.length-1]?.content!==r&&h.push({role:"user",content:r})}const u=rp(),f=I.M.get("config","channel"),m=I.M.get("kitSelection"),g="components"!==c.intent?await pc():[],b={messages:h,currentNewsletter:d,language:n,...p?{selectedComponentId:p}:{},...m?{kitSelection:m}:{},...u?{doc_id:u,surface:Ed()}:{},...u&&t._newSession?{new_session:!0}:{},...u&&!t._newSession&&t._sessionId?{session_id:t._sessionId}:{},...f?{channel:f}:{},...l.length>0?{attachments:l}:{},..."components"!==c.intent&&ac()?{canPickImages:!0}:{},...g.length>0?{galleryImages:g}:{},..."components"!==c.intent&&vd?{undone:!0}:{},..."components"!==c.intent&&Qc(t).length>0?{files:Qc(t)}:{},..."components"!==c.intent?kp():{},..."components"!==c.intent?_p(s):{},..."components"!==c.intent&&pd(s).length>0?{hostTools:pd(s)}:{},...t._pendingDirection?{direction:t._pendingDirection}:{},...c};t._pendingDirection=null,vd=!1;const y={counters:{text:0,marks:0,prop:0,removed:0,created:0,moved:0,skipped:0,kit:0},finalReply:"",finalSummary:"",sseError:null,outOfTokens:!1,paymentUrl:"",truncated:!1,directions:null};let A=!1;const w=async(r,o)=>{if("host_tool_call"!==r){if("directions"===r)return y.directions=Array.isArray(o&&o.cards)?o.cards:null,void(o&&o.partial&&y.directions&&y.directions.length>0&&Tc(t,jl(t),y.directions,(e,n)=>op(t,e,n)));if("ops"===r){const t=Array.isArray(o&&o.ops)?o.ops:[];if(0===t.length)return;const e=await Op(t);return y.counters.text+=e.text,y.counters.marks+=e.marks,y.counters.prop+=e.prop,y.counters.removed+=e.removed,y.counters.created+=e.created,y.counters.moved+=e.moved,y.counters.skipped+=e.skipped,void console.log(`[edit-chat] sse ops batch call_id=${o.call_id} count=${t.length}`)}if("kit_reset"===r){if("page"!==c.intent)return void console.warn("[edit-chat] kit_reset ignored: this turn is not a page build");const t=I.M.get(T.yS);return t?(I.M.set({[T.yS]:jt.clearAiDocBody(t)}),I.M.set({kitSelection:null}),void console.log("[edit-chat] kit_reset: page cleared for a rebuild")):void console.warn("[edit-chat] kit_reset ignored: there is no AI document")}if("kit_ops"===r){const t=Array.isArray(o&&o.ops)?o.ops:[],e=Ip(o&&o.componentId,t);return("page"===c.intent||"section"===c.intent)&&e.applied>0&&e.inserted>0&&(A=!0),y.counters.kit+=e.applied,void(e.reason?console.warn(`[edit-chat] kit_ops not applied call_id=${o&&o.call_id}: ${e.reason}`):console.log(`[edit-chat] sse kit_ops batch call_id=${o&&o.call_id} count=${e.applied}`))}if("thinking"===r){const e=o&&"string"==typeof o.delta?o.delta:"";if(!e)return;return void Qd(t,e)}if("text"===r){const e=o&&"string"==typeof o.delta?o.delta:"";if(!e)return;return void Qd(t,e)}if("text_reset"!==r){if("tool_start"===r||"tool_end"===r){const e=Array.isArray(o&&o.keys)?o.keys:null;if("tool_start"===r){const e="en"===jl(t)?"en":"he",n=Gd[e][o&&o.name]||Hd[e]||Hd.en;Jd(t,n),t._busyEl&&(0,Vt.L)("thinking",Yd.has(o&&o.name)?"research":"build")}if("tool_start"===r){const n=o&&"edit"===o.mode,r=Xd["en"===jl(t)?"en":"he"];(0,Vt.QG)(e||[],n?"edit":"read",n?r.edit:r.read)}else e&&e.length&&(0,Vt.QG)(e,"read",Xd["en"===jl(t)?"en":"he"].found);return}if("done"!==r)"error"!==r?"memory"!==r||function(t,e,n){(function(t){if(!t||"saved"!==t.action&&"forgotten"!==t.action)return!1;const e=t.memory;return!(!e||"string"!=typeof e.text||!e.text.trim())})(n)&&jc({action:n.action,memory:n.memory})}(0,jl(t),o):y.sseError={reason:o&&o.reason||"chat edit failed"};else if(o&&"string"==typeof o.session_id&&o.session_id&&(t._sessionId=o.session_id,t._newSession=!1),y.finalReply=o&&"string"==typeof o.reply?o.reply:"",y.finalSummary=o&&"string"==typeof o.summary?o.summary:"",y.outOfTokens=!(!o||!o.outOfTokens),y.truncated=!(!o||!o.truncated),y.paymentUrl=o&&"string"==typeof o.paymentUrl?o.paymentUrl:"",o&&"number"==typeof o.balance&&up(t,n,o.balance,y.paymentUrl),A&&(0,T.zZ)()){const t=I.M.get(T.yS);t&&(I.M.set({[T.yS]:jt.flattenAiDoc(t)}),I.M.set({kitSelection:null}))}}else Kd(t)}else await ud(s,o,async t=>{const n=await mp(s,{}),r=await fetch(`${e}/host-tool-result`,{method:"POST",headers:{"Content-Type":"application/json",...n?{Authorization:`Bearer ${n}`}:{}},body:JSON.stringify(t)});if(!r.ok)throw new Error(`host-tool-result ${r.status}`)})};let x,v,k=!1;try{let n=await gp(s,e,b,{allowProviderRefresh:!0,onEvent:w,signal:o.signal});!n.resp||401!==n.resp.status&&403!==n.resp.status||(console.warn(`[edit-chat] auth ${n.resp.status}; asking studioTokenProvider for a fresh token and retrying once.`),n=await gp(s,e,b,{allowProviderRefresh:!0,forceRefresh:!0,onEvent:w,signal:o.signal}),!n.resp||401!==n.resp.status&&403!==n.resp.status||t.dispatchEvent?.(new CustomEvent("cdtr-edit:auth-expired",{bubbles:!0,composed:!0,detail:{status:n.resp.status}}))),x=n.resp,v=n.body,k=n.streamed}catch(e){if(t.busy=!1,o.signal.aborted||"AbortError"===e?.name)return t._stoppedForPick?void(t._stoppedForPick=!1):void t.appendMessage?.({role:"assistant",text:Fd[a]||Fd.en,ts:Date.now()});const n=e&&("TypeError"===e.name||e.message?.includes("fetch"));return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,e,{isNetwork:n})),ts:Date.now()})}if(t.busy=!1,k){if(y.sseError)return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,y.sseError.reason)),ts:Date.now()});const e=y.counters,n=e.skipped>0?(Rd[a]||Rd.en)(e.skipped):"",r=y.outOfTokens?(Pd[a]||Pd.en)(y.paymentUrl):"",o=e.text+e.marks+e.prop+e.removed+e.created+e.moved+e.kit,i=y.truncated?(Dd[a]||Dd.en)(o):"",s=0!==o||0!==e.skipped||y.outOfTokens||y.truncated?"":jd[a]||jd.en,l=r||i||n;let c=l||s;const d=hc(y.finalReply);null!==d.ask&&(y.finalReply=d.text,fc(t,a,d.ask,e=>t._submitChip?.(e),d.auto),c=l);const p=Jl(y.finalReply);if(p.questions.length>0)return p.text.length>0&&t.appendMessage?.({role:"assistant",text:Gl(p.text).text+l,ts:Date.now()}),void tc(t,a,p.questions,e=>t._submitChip?.(e));const h=Gl(y.finalReply);if(y.directions&&y.directions.length>0&&(c=l,Tc(t,a,y.directions,(e,n)=>op(t,e,n))),h.chips.length>0)h.text.length>0&&t.appendMessage?.({role:"assistant",text:h.text+l,ts:Date.now()}),Zl(t,a,h.chips,h.kind,e=>t._submitChip?.(e));else if(y.finalReply.length>0)t.appendMessage?.({role:"assistant",text:y.finalReply+c,ts:Date.now()});else if(o>0){const e=(zd[a]||zd.en)(o);t.appendMessage?.({role:"assistant",text:e+c,ts:Date.now()})}else c&&t.appendMessage?.({role:"assistant",text:c.trim(),ts:Date.now()});return void console.log(`[edit-chat] applied ops (streamed): text=${e.text}, marks=${e.marks}, prop=${e.prop}, removed=${e.removed}, created=${e.created}, moved=${e.moved}, kit=${e.kit}, skipped=${e.skipped}; summary=${y.finalSummary}`)}if(!x||!x.ok||v&&v.error){const e=v&&v.reason||`HTTP ${x?x.status:"unknown"}`,n=x&&(401===x.status||403===x.status);return void t.appendMessage?.({role:"assistant",text:Ud(t,Wd(a,e,{isAuth:n})),ts:Date.now()})}const{reply:C,ops:_,summary:E}=v||{},S=Array.isArray(_)&&_.length>0,M=S?"":jd[n]||jd.en;"string"==typeof C&&C.length>0&&t.appendMessage?.({role:"assistant",text:C+M,ts:Date.now()});if(!S)return void console.log("[edit-chat] response had no ops; summary=",E);const B=await Op(_);console.log(`[edit-chat] applied ops: text=${B.text}, marks=${B.marks}, prop=${B.prop}, removed=${B.removed}, created=${B.created}, moved=${B.moved}, skipped=${B.skipped}; summary=${E}`)}(t,e,n,r,i,o)}finally{t._editInFlight=!1,t.busy=!1,$d(t)}}function kp(){const t=I.M.get(T.yS);if(!t)return{};try{const e=jt.renderAiDoc(t);return"string"==typeof e&&e.length>0?{page:e}:{}}catch{return{}}}const Cp=(t,e)=>"string"==typeof t||"number"==typeof t?String(t).replace(/\s+/g," ").trim().slice(0,e):"";function _p(t){const e=t?.configure?.editorProps?.form,n=Array.isArray(e?.fields)?e.fields:[],r=new Set((Array.isArray(e?.defaultFields)?e.defaultFields:[]).map(t=>String(t&&"object"==typeof t?t.id:t))),o=n.map(t=>{const e=Cp(t?.paramName||t?.id,80);if(!e)return null;const n=(Array.isArray(t.items)?t.items:Array.isArray(t.options)?t.options:[]).map(t=>{const e=Cp(t&&"object"==typeof t?t.value??t.id??t.label:t,60),n=Cp(t&&"object"==typeof t?t.label??t.name??e:t,60);return e?{label:n||e,value:e}:null}).filter(Boolean).slice(0,30);return{paramName:e,...Cp(t.label||t.name,80)?{label:Cp(t.label||t.name,80)}:{},...Cp(t.type,30)?{type:Cp(t.type,30)}:{},...Cp(t.inputType,30)?{inputType:Cp(t.inputType,30)}:{},...n.length>0?{options:n}:{},...r.has(String(t.id))?{isDefault:!0}:{}}}).filter(Boolean).slice(0,80);if(0===o.length)return{};const i=Array.isArray(e?.mailingLists)?e.mailingLists:e?.mailingLists?.items??[],a=(Array.isArray(i)?i:[]).map(t=>{const e=Cp(t?.id??t?.key,40);return e?{id:e,name:Cp(t.name??t.label??e,80)}:null}).filter(Boolean).slice(0,50);return{formConfig:{fields:o,...a.length>0?{mailingLists:a}:{}}}}const Ep=["div","main","article","form"],Sp=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Mp(t){return String(t&&t.name||"").toLowerCase()}function Bp(t){const e=[];for(const n of t||[])n&&"tag"===n.type&&"head"!==Mp(n)&&e.push(n);const n=e.filter(t=>"html"===Mp(t));if(!n.length)return e;const r=[];for(const t of n)r.push(...Bp(t.children));return r}function Tp(t){const e=t&&t.html?t.html:"";if(!e)return null;const n=jt.parse(e),r=new WeakMap,o=[],i=[];jt.walk(n,(t,e)=>{const n=!!e&&!!r.get(e),a=Mp(t),s=n||"head"===a;r.set(t,s),s||("body"===a&&o.push(t),"main"===a&&i.push(t))});const a=(t,e)=>{if(!t)return null;const n=Mp(t);if("html"===n||"head"===n)return null;if(r.get(t))return null;if("append"===e&&Sp.has(n))return null;const o=t.attribs&&t.attribs["data-k"];return o?{key:o,pos:e}:null},s=a(o[0],"append");if(s)return s;const l=a(i[0],"append");if(l)return l;const c=Bp(n);if(1===c.length&&Ep.includes(Mp(c[0]))){const t=a(c[0],"append");if(t)return t}return a(c[c.length-1],"after")}const Lp=150;function Ip(t,e){const{ops:n,dropped:r}=jt.normalizeIncomingOps(e),o=n.filter(t=>t&&"insert"===t.op).length;if(0===n.length)return{applied:0,inserted:0,dropped:r.length,reason:"no applicable ops in batch"};if(!t)return{applied:0,inserted:0,dropped:r.length,reason:"no componentId on the event"};if(t===T.o6){const t=I.M.get(T.yS);return t?(I.M.set({[T.yS]:jt.appendAiEditsOverManual(t,n)}),{applied:n.length,inserted:o,dropped:r.length,reason:""}):{applied:0,inserted:0,dropped:r.length,reason:"AI mode is on but there is no document"}}const i=L.Ay.getComponent?L.Ay.getComponent(t):null,a=Array.isArray(L.Ay.components)?L.Ay.components.find(e=>e&&e.id===t):null,s=(i&&i.kit?i:null)||(a&&a.kit?a:null)||i;if(!s)return{applied:0,inserted:0,dropped:r.length,reason:`component ${t} is not in this document`};const l=s.kit;return l&&"function"==typeof l.push?(l.push(...n),{applied:n.length,inserted:o,dropped:r.length,reason:""}):{applied:0,inserted:0,dropped:r.length,reason:`component ${t} has no mounted kit api`}}async function Op(t){const e=L.Ay,n={text:0,marks:0,prop:0,removed:0,created:0,moved:0,skipped:0};let r=new Set,o=0;const i=new Set;try{const n=e&&e.getComponents?e.getComponents():null;r=new Set(n?Object.keys(n):[]),o=r.size;const i=n?Object.values(n).filter(t=>t&&"root"===t.type).map(t=>t&&t.id):[],a=t.find(t=>t&&"create"===t.op);console.log(`[edit-chat] BATCH START total=${o} rootIds=${JSON.stringify(i)} firstParentId=${a&&a.parentId} firstParentInStore=${a?!!e.getComponent(a.parentId):"no-creates"}`)}catch(t){console.warn("[edit-chat] batch-start diagnostic failed",t)}let a=!0;for(const s of t){!a&&Lp>0&&await new Promise(t=>setTimeout(t,Lp)),a=!1;const t=e.store();if(s&&"string"==typeof s.op)try{if("updateText"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateText",s.id);continue}t.updateComponent(r,"text",{childNodes:s.value}),n.text++}else if("updateTextMarks"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateTextMarks",s.id);continue}t.updateComponent(r,"text",{childNodes:s.value}),n.marks++}else if("updateProp"===s.op){const r=e.getComponent(s.id);if(!r){n.skipped++,console.warn("[edit-chat] no live component for updateProp",s.id);continue}t.updateComponent(r,s.key,s.value),n.prop++}else if("remove"===s.op)t.removeComponent({componentId:s.id}),n.removed++;else if("create"===s.op){const a=s.body&&(s.body.id||s.body._id),l=e&&e.getComponents&&e.getComponents()||{},c=Object.keys(l).length,d=!!e.getComponent(s.parentId);let p;p=r.has(s.parentId)?"PRE-EXISTING":i.has(s.parentId)?"SELF-DECLARED":"PHANTOM",t.createComponent({parentId:s.parentId,index:s.index,body:s.body},{clone:!0});const h=e&&e.getComponents&&e.getComponents()||{},u=Object.keys(h).length,f=!!e.getComponent(a);let m=0;r.forEach(t=>{t in h&&m++}),i.add(a),console.log(`[edit-chat] CREATE type=${s.body&&s.body.type} id=${a} parentId=${s.parentId} idx=${s.index} parentInStore=${d} parentSource=${p} bodyInStoreAfter=${f} total=${c}->${u} initialSurvived=${m}/${o}`),n.created++}else"move"===s.op?(t.moveComponent({id:s.id,oldParentId:s.oldParentId,newParentId:s.newParentId,oldIndex:s.oldIndex,newIndex:s.newIndex}),n.moved++):(console.warn("[edit-chat] unknown op type:",s.op),n.skipped++)}catch(t){console.error(`[edit-chat] op dispatch FAILED op=${s.op} id=${s.id||s.body&&s.body.id||"?"}`,t,s),n.skipped++}else n.skipped++}return n}I.M.set({createEditChat:fp});const Np={mem_title:"Assistant memory",mem_intro:"What the assistant remembers about you. Edit or delete any line.",mem_group_business:"About the business (all pages)",mem_group_page:"About this page",mem_source_ai:"From chat",mem_source_user:"Added by you",mem_edit:"Edit",mem_delete:"Delete",mem_save:"Save",mem_cancel:"Cancel",mem_empty_group:"Nothing yet. The assistant saves lasting facts as you chat.",mem_too_long:"Up to {limit} characters.",mem_error:"Could not load the memory.",mem_retry:"Try again",mem_no_token:"Sign in to see what the assistant remembers.",mem_action_failed:"That did not work. Try again."};function Hp(t,e){const n=I.M.get("lang",t);let r="string"==typeof n&&n?n:Np[t]||t;if(e)for(const[t,n]of Object.entries(e))r=r.split(`{${t}}`).join(String(n));return r}const zp=["business","page"];class Pp extends S.WF{constructor(){super(),this._memories=[],this._limits={...Rc},this._loading=!1,this._error=!1,this._noToken=!1,this._editingId=null,this._busyId=null,this._notice={},this._loaded=!1,this._onStore=()=>{this._syncDir(),this.requestUpdate()},this._onChanged=()=>this._load({quiet:!0})}connectedCallback(){super.connectedCallback(),this._syncDir(),I.M.connect(["lang","langConfig"],this._onStore),window.addEventListener(Dc,this._onChanged),this._load()}disconnectedCallback(){I.M.disconnect(this._onStore),window.removeEventListener(Dc,this._onChanged),super.disconnectedCallback()}_syncDir(){this.setAttribute("dir",function(){const t=I.M.get("langConfig");return!(!t||"rtl"!==t.direction)}()?"rtl":"ltr")}async _load(){let{quiet:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&this._loaded||(this._loading=!0),!await async function(){return null!=await Fc({forceRefresh:!1})}())return this._noToken=!0,void(this._loading=!1);this._noToken=!1;const e=await async function(t){const e=t?`${Pc}?doc_id=${encodeURIComponent(t)}`:Pc,n=await Uc("GET",e),r=n.ok&&n.data&&Array.isArray(n.data.memories)?n.data.memories:[],o={...Rc,...n.ok&&n.data&&n.data.limits||{}};return{ok:n.ok,status:n.status,memories:r,limits:o}}(rp());this._loading=!1,e.ok?(this._error=!1,this._loaded=!0,this._memories=e.memories,this._limits=e.limits):this._loaded||(this._error=!0)}_group(t){return this._memories.filter(e=>e&&e.scope===t)}_setNotice(t,e){this._notice={...this._notice,[t]:e||""}}async _save(t,e){const n=(e.value||"").trim();if(!n)return;if(n===t.text)return void(this._editingId=null);if(n.length>this._limits.text)return void this._setNotice(t.scope,Hp("mem_too_long",{limit:this._limits.text}));this._setNotice(t.scope,""),this._busyId=t.id;const r=await async function(t,e){const n=await Uc("PATCH",`${Pc}/${encodeURIComponent(t)}`,{text:e});return{ok:n.ok,status:n.status,memory:n.data&&n.data.memory||null,error:n.data&&n.data.error||(n.ok?null:"request_failed")}}(t.id,n);return this._busyId=null,r.ok?(this._editingId=null,void(this._memories=this._memories.map(e=>e.id===t.id?r.memory||{...e,text:n}:e))):404===r.status?(this._editingId=null,void this._load({quiet:!0})):void this._setNotice(t.scope,Hp("mem_action_failed"))}async _delete(t){this._setNotice(t.scope,""),this._busyId=t.id;const e=await Wc(t.id);if(this._busyId=null,e.ok)return this._memories=this._memories.filter(e=>e.id!==t.id),void(this._editingId===t.id&&(this._editingId=null));this._setNotice(t.scope,Hp("mem_action_failed"))}_updateChars(t){const e=t.parentElement&&t.parentElement.querySelector(".chars");e&&(e.textContent=`${(t.value||"").length}/${this._limits.text}`)}_head(){return S.qy`<div class="head">
|
|
6359
6359
|
<span class="dot"></span><span class="title">${Hp("mem_title")}</span>
|
|
6360
6360
|
</div>
|
|
6361
6361
|
<div class="intro">${Hp("mem_intro")}</div>`}_source(t){const e="user"===t.source?Hp("mem_source_user"):Hp("mem_source_ai"),n=function(t){if("number"!=typeof t||!isFinite(t)||t<=0)return"";const e=I.M.get("language");try{return new Date(t).toLocaleDateString(e||void 0,{day:"numeric",month:"short",year:"numeric"})}catch{return new Date(t).toLocaleDateString()}}(t.updated_at||t.created_at);return n?`${e} · ${n}`:e}_record(t){const e=this._busyId===t.id;return this._editingId===t.id?S.qy`<div class="rec ${e?"busy":""}">
|