@joryio/web-sdk 1.4.0-beta.4 → 1.4.0-beta.6

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +11 -3
  2. package/dist/core/cards.d.ts +2 -1
  3. package/dist/core/cards.d.ts.map +1 -1
  4. package/dist/core/config.d.ts +1 -1
  5. package/dist/core/config.d.ts.map +1 -1
  6. package/dist/core/flags.d.ts +2 -1
  7. package/dist/core/flags.d.ts.map +1 -1
  8. package/dist/core/page-edits.d.ts +1 -1
  9. package/dist/core/page-edits.d.ts.map +1 -1
  10. package/dist/core/placements.d.ts +2 -1
  11. package/dist/core/placements.d.ts.map +1 -1
  12. package/dist/core/sdk-host-files.d.ts +1 -1
  13. package/dist/core/sdk-host-files.d.ts.map +1 -1
  14. package/dist/core/sdk.d.ts +4 -3
  15. package/dist/core/sdk.d.ts.map +1 -1
  16. package/dist/core/subscription.d.ts +6 -0
  17. package/dist/core/subscription.d.ts.map +1 -0
  18. package/dist/editor/editor-model.d.ts +13 -0
  19. package/dist/editor/editor-model.d.ts.map +1 -0
  20. package/dist/editor/editor-strings.d.ts +79 -0
  21. package/dist/editor/editor-strings.d.ts.map +1 -0
  22. package/dist/editor/editor-ui.d.ts +25 -0
  23. package/dist/editor/editor-ui.d.ts.map +1 -0
  24. package/dist/editor/visual-editor.d.ts +59 -8
  25. package/dist/editor/visual-editor.d.ts.map +1 -1
  26. package/dist/index.d.mts +10 -5
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/joryio-cards-ui.min.js +1 -1
  30. package/dist/joryio-cards-ui.min.js.map +1 -1
  31. package/dist/joryio-editor.min.js +2 -2
  32. package/dist/joryio-editor.min.js.map +1 -1
  33. package/dist/joryio-sw.js +1 -1
  34. package/dist/joryio.cjs.js +83 -46
  35. package/dist/joryio.min.js +2 -2
  36. package/dist/joryio.min.js.map +1 -1
  37. package/dist/joryio.mjs +83 -46
  38. package/dist/joryio.umd.js +83 -46
  39. package/package.json +1 -1
  40. package/src/core/cards.ts +10 -7
  41. package/src/core/config.ts +1 -1
  42. package/src/core/flags.ts +10 -4
  43. package/src/core/page-edits.ts +43 -22
  44. package/src/core/placements.ts +10 -7
  45. package/src/core/sdk-host-files.ts +15 -10
  46. package/src/core/sdk.ts +14 -9
  47. package/src/core/subscription.ts +27 -0
  48. package/src/editor/editor-model.ts +102 -0
  49. package/src/editor/editor-strings.ts +102 -0
  50. package/src/editor/editor-ui.ts +145 -0
  51. package/src/editor/visual-editor.ts +815 -105
  52. package/src/index.ts +2 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Joryio Web SDK v1.4.0-beta.4
2
+ * Joryio Web SDK v1.4.0-beta.6
3
3
  * (c) 2026 Joryio. All rights reserved.
4
4
  * @license Commercial - see https://github.com/joryio/joryio-web-sdk/blob/main/LICENSE
5
5
  */
6
- !function(){"use strict";function t(t){if("string"!=typeof t)return!1;const e=t.trim();if(!e||e.length>500)return!1;if(/[{};<@]/.test(e)||e.includes("/*")||e.includes("*/"))return!1;if(/[\u0000-\u001f\u007f]/.test(e))return!1;try{"undefined"!=typeof document&&document.createDocumentFragment().querySelector(e)}catch(t){return!1}return!0}const e=/\/joryio(?:\.umd)?(?:\.min)?\.js$/;function i(t){if(!t||"string"!=typeof t)return null;let i;try{i=new URL(t)}catch(t){return null}return"https:"===i.protocol&&e.test(i.pathname)?`${i.origin}${i.pathname.replace(/[^/]*$/,"")}`:null}!function(){if("undefined"==typeof document)return null;try{const t=document.currentScript,e=i(t&&t.src);if(e||t&&t.src)return e;const n=document.querySelectorAll("script[src]");for(let t=n.length-1;t>=0;t--){const e=i(n[t].src);if(e)return e}}catch(t){}}();const n="__joryioEditor",o=["data-joryio-id","data-testid","data-test","data-qa","data-cy","data-id","name"],r=/^[a-z0-9][a-z0-9_]{0,63}$/,s=(t,e,i)=>{try{const n=t.querySelectorAll(e);return 1===n.length&&n[0]===i}catch(t){return!1}};class c{constructor(t,e,i,n=()=>{}){this.dashboardOrigin=t,this.opener=e,this.logger=i,this.onStop=n,this.listeners=[],this.highlight=null,this.panel=null,this.selected=null,this.active=!1}start(){if(this.active)return;this.active=!0;const t=t=>{const e=t.data;e&&"string"==typeof e.type&&t.origin===this.dashboardOrigin&&t.source===this.opener&&"joryio:editor-close"===e.type&&this.stop()};window.addEventListener("message",t),this.listeners.push(()=>window.removeEventListener("message",t)),this.activate()}isActive(){return this.active}stop(){var t,e;if(this.active){this.send({type:"joryio:editor-closed"}),this.active=!1;for(const t of this.listeners.splice(0))t();null===(t=this.highlight)||void 0===t||t.remove(),null===(e=this.panel)||void 0===e||e.remove(),this.highlight=this.panel=null,this.selected=null;try{this.onStop()}catch(t){this.logger.debug("Joryio editor stop callback failed",t)}}}send(t){if(this.active)try{this.opener.postMessage(t,this.dashboardOrigin)}catch(t){}}activate(){const t=document,e=t.createElement("div");e.setAttribute("data-joryio-editor","highlight"),e.style.cssText="position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #14b8a6;background:rgba(20,184,166,.12);border-radius:3px;display:none";const i=t.createElement("div");i.setAttribute("data-joryio-editor","panel"),i.style.cssText="position:fixed;left:16px;right:16px;bottom:16px;z-index:2147483647;max-width:560px;margin:0 auto;background:#0f172a;color:#fff;font:14px/1.4 system-ui,sans-serif;padding:12px 14px;border-radius:10px;box-shadow:0 8px 30px rgba(0,0,0,.3)",i.textContent="Joryio editor - click an element on the page. Esc to finish.",t.body.appendChild(e),t.body.appendChild(i),this.highlight=e,this.panel=i;const n=t=>t instanceof Element&&!!t.closest("[data-joryio-editor]"),o=t=>{this.selected||n(t.target)||this.outline(t.target instanceof Element?t.target:null)},r=t=>{n(t.target)||(t.preventDefault(),t.stopPropagation(),t.target instanceof Element&&this.select(t.target))},s=t=>{"Escape"===t.key&&(this.selected?this.unselect():this.stop())};t.addEventListener("mousemove",o,!0),t.addEventListener("click",r,!0),t.addEventListener("keydown",s,!0),this.listeners.push(()=>t.removeEventListener("mousemove",o,!0),()=>t.removeEventListener("click",r,!0),()=>t.removeEventListener("keydown",s,!0)),this.send({type:"joryio:editor-active",url:`${location.origin}${location.pathname}`})}outline(t){if(!this.highlight)return;if(!t||t===document.body||t===document.documentElement)return void(this.highlight.style.display="none");const e=t.getBoundingClientRect();Object.assign(this.highlight.style,{display:"block",top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`})}unselect(){this.selected=null,this.panel&&(this.panel.textContent="Joryio editor - click an element on the page. Esc to finish.")}select(e){const i=function(e){const i=e.ownerDocument;if(!i)return null;const n=t=>{if((e=t.id)&&e.length<=64&&!/\d{4,}/.test(e)&&!/^(ember|react|radix|headlessui|mui)[-_:]/i.test(e)&&!/:/.test(e)){const e=`#${function(t){const e=globalThis.CSS;if(e&&"function"==typeof e.escape)return e.escape(t);let i="";for(let e=0;e<t.length;e++){const n=t[e],o=t.charCodeAt(e);0===o?i+="�":/[0-9]/.test(n)&&(0===e||1===e&&"-"===t[0])?i+=`\\${o.toString(16)} `:/[A-Za-z0-9_-]/.test(n)||o>=128?i+=n:i+=`\\${n}`}return i}(t.id)}`;if(s(i,e,t))return e}var e;for(const e of o){const n=t.getAttribute(e);if(!n||n.length>100)continue;const o=`${t.tagName.toLowerCase()}[${e}="${n.replace(/["\\]/g,"\\$&")}"]`;if(s(i,o,t))return o}return null},r=n(e);if(r)return t(r)?r:null;const c=[];let a=e;for(;a&&a!==i.body&&a!==i.documentElement;){const t=c.length?n(a):null;if(t){c.unshift(t);break}const e=a.tagName.toLowerCase(),o=a.parentElement,r=o?Array.from(o.children).filter(t=>t.tagName===a.tagName):[];c.unshift(r.length>1?`${e}:nth-of-type(${r.indexOf(a)+1})`:e),a=o,a===i.body&&c.unshift("body")}const l=c.join(" > ");return l&&t(l)&&s(i,l,e)?l:null}(e);if(!this.panel)return;if(!i)return void(this.panel.textContent="This element has no stable selector. Choose its parent or another element.");this.selected=e,this.outline(e);const n=this.panel;n.textContent="";const r=(t,e=!1)=>{const i=document.createElement("div");i.textContent=t,e&&(i.style.cssText="font-family:ui-monospace,monospace;font-size:12px;opacity:.8;word-break:break-all;margin:4px 0 8px"),n.appendChild(i)};r(`<${e.tagName.toLowerCase()}> ${(e.textContent||"").trim().slice(0,60)}`),r(i,!0);const c=document.createElement("input");c.setAttribute("data-joryio-editor","value"),c.style.cssText="width:100%;box-sizing:border-box;padding:6px 8px;border-radius:6px;border:0;margin-bottom:8px;color:#0f172a",c.placeholder="New text, https:// address or placement key",n.appendChild(c);const a=document.createElement("div");a.style.cssText="display:flex;flex-wrap:wrap;gap:6px";const l={replace_text:"Replace text",replace_image:"Replace image",replace_link:"Replace link",hide:"Hide",insert_placement:"Insert placement after"};for(const t of function(t){const e=[];return"IMG"!==t.tagName&&(t.textContent||"").trim()&&e.push("replace_text"),"IMG"===t.tagName&&e.push("replace_image"),"A"===t.tagName&&e.push("replace_link"),e.push("hide","insert_placement"),e}(e)){const n=document.createElement("button");n.type="button",n.textContent=l[t],n.setAttribute("data-joryio-op",t),n.style.cssText="padding:6px 10px;border-radius:6px;border:0;background:#14b8a6;color:#fff;cursor:pointer",n.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),this.pick(e,i,t,c.value.trim())}),a.appendChild(n)}n.appendChild(a)}pick(t,e,i,n){const o={type:"joryio:editor-pick",selector:e,operation:i,tag:t.tagName.toLowerCase(),text:(t.textContent||"").trim().slice(0,200)};let s=null;if("hide"===i?s=o:"replace_text"===i?s=n||o.text?Object.assign(Object.assign({},o),{value:(n||o.text).slice(0,2e3)}):null:"replace_image"===i||"replace_link"===i?s=function(t){if("string"!=typeof t)return!1;const e=t.trim();return!(!e||e.length>2048)&&!/[\u0000-\u001f\u007f\s]/.test(e)&&/^https?:\/\/[^/?#\s]+/i.test(e)}(n)?Object.assign(Object.assign({},o),{value:n}):null:"insert_placement"===i&&(s=r.test(n)?Object.assign(Object.assign({},o),{placementKey:n,position:"after"}):null),!s){if(this.panel){const t=document.createElement("div");t.style.cssText="margin-top:6px;color:#fca5a5",t.textContent="insert_placement"===i?"Enter a placement key (lowercase letters, digits, _).":"Enter an address starting with https:// (or http://).",this.panel.appendChild(t)}return!1}return this.send(s),this.unselect(),!0}}const a={version:1,start({dashboardOrigin:t,opener:e,logger:i,onStop:n}){const o=new c(t,e,i,n);return o.start(),{stop:()=>o.stop()}}};"undefined"==typeof window||window[n]||(window[n]=a)}();
6
+ !function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const t=["before","after","prepend","append","replace"],e=/^[a-z0-9][a-z0-9_]{0,63}$/;function i(t){if("string"!=typeof t)return!1;const e=t.trim();if(!e||e.length>500)return!1;if(/[{};<@]/.test(e)||e.includes("/*")||e.includes("*/"))return!1;if(/[\u0000-\u001f\u007f]/.test(e))return!1;try{"undefined"!=typeof document&&document.createDocumentFragment().querySelector(e)}catch(t){return!1}return!0}function n(t){if("string"!=typeof t)return!1;const e=t.trim();return!(!e||e.length>2048)&&!/[\u0000-\u001f\u007f\s]/.test(e)&&/^https?:\/\/[^/?#\s]+/i.test(e)}const o=/\/joryio(?:\.umd)?(?:\.min)?\.js$/;function s(t){if(!t||"string"!=typeof t)return null;let e;try{e=new URL(t)}catch(t){return null}return"https:"===e.protocol&&o.test(e.pathname)?`${e.origin}${e.pathname.replace(/[^/]*$/,"")}`:null}!function(){if("undefined"==typeof document)return null;try{const t=document.currentScript,e=s(t&&t.src);if(e||t&&t.src)return e;const i=document.querySelectorAll("script[src]");for(let t=i.length-1;t>=0;t--){const e=s(i[t].src);if(e)return e}}catch(t){}}();const r="joryio:editor-pick",a="__joryioEditor",l={title:"Joryio editor",variant:"Variant {name}",hintPoint:"Point at anything on the page",hintEditing:"Editing · changes show live",editsOne:"1 edit",editsMany:"{n} edits",noEdits:"No edits yet.",undo:"Undo last edit",undoOffline:"Undo is available once the Joryio dashboard is connected",saveReturn:"Save & return to Joryio",clickToEdit:"click to edit",helpTitle:"Not the right box?",helpUp:"Select the section around it",helpDown:"Select something inside it",helpClickKey:"Click",helpClick:"Edit this one",dismiss:"Dismiss",page:"Page",up:"Select the element around it",down:"Select the first element inside it",matchOne:"1 match on page",matchMany:"Matches {n} - all will change",matchNone:"Not found",whatToDo:"What do you want to do?",actText:"Change text",actLink:"Change link",actImage:"Change image",actHide:"Hide it",actSlot:"Add content slot",noText:"No text here",notLink:"Not a link",notImage:"Not an image",newText:"New text",was:'Was: "{value}"',insert:"Insert",fallback:"If a value is missing",fallbackHelp:"Shown to visitors we don't know yet.",newLink:"New link address",newImage:"New image address",urlBad:"Enter an address starting with https:// (or http://).",hideNote:"The {kind} is removed for people in this campaign's audience. Everyone else still sees it.",hiddenFor:"Hidden for this audience",slotName:"Slot name",savedAs:"Saved as",slotHelp:"Filled by a Placement campaign or a journey step.",slotEmpty:"Enter a name for the slot.",where:"Where",posBefore:"Above it",posAfter:"Below it",posReplace:"Instead of it",posPrepend:"Inside, at the start",posAppend:"Inside, at the end",slotPreview:"Content slot",css:"CSS selector",cssHelp:"For developers. Matches {n} on this page.",cssBad:"Not a selector this page can use.",cancel:"Cancel",save:"Save · {action}",noSelector:"This element has no stable selector. Choose the element around it (arrow up) or another one.",kHeading:"Heading",kText:"Text",kLink:"Link",kButton:"Button",kImage:"Image",kList:"List",kSection:"Section",kMain:"Main",kHeader:"Header",kFooter:"Footer",kNav:"Navigation",kForm:"Form",kElement:"Element"};function c(t,e={}){return t.replace(/\{(\w+)\}/g,(t,i)=>i in e?String(e[i]):t)}const d=/\{\{-?([\s\S]*?)-?\}\}/g,p=/\|\s*default\s*:\s*("[^"]*"|'[^']*'|[^|}]*?)\s*(?=\||$)/,h=t=>t.trim().replace(/^(["'])([\s\S]*)\1$/,"$2");function u(t){const e=[],i=new RegExp(d.source,"g");let n;for(;n=i.exec(t||"");){const t=n[1].trim(),i=p.exec(t);e.push({expr:t,fallback:i?h(i[1]):null})}return e}function f(t){const e=u(t);if(!e.length)return null;const i=e.filter(t=>null!==t.fallback)[0];return i?i.fallback:""}const x=t=>t.includes('"')?`'${t.replace(/'/g,"")}'`:`"${t}"`;function b(t,e,i){const n=e?`user.custom.${t}`:`user.${t}`;return i?`{{ ${n} | default: ${x(i)} }}`:`{{ ${n} }}`}function g(t){return(t||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64).replace(/_+$/,"")}function m(t,e=!1){let i=(t||"").toLowerCase();if(e){const t=i.trim().split(/[\s>+~]+/).filter(Boolean),e=/^[a-z][a-z0-9]*/.exec(t[t.length-1]||"");i=e?e[0]:""}return/^h[1-6]$/.test(i)?"kHeading":/^(p|span|strong|em|small|label|blockquote|b|i)$/.test(i)?"kText":"a"===i?"kLink":"button"===i?"kButton":"img"===i||"picture"===i?"kImage":/^(ul|ol|li)$/.test(i)?"kList":"main"===i?"kMain":"header"===i?"kHeader":"footer"===i?"kFooter":"nav"===i?"kNav":"form"===i?"kForm":/^(section|div|article|aside)$/.test(i)?"kSection":"kElement"}function k(t,e,...i){const n=document.createElement(t);for(const[t,i]of Object.entries(e||{}))void 0!==i&&!1!==i&&n.setAttribute(t,!0===i?"":i);for(const t of i)null!=t&&!1!==t&&n.appendChild("string"==typeof t?document.createTextNode(t):t);return n}const y="http://www.w3.org/2000/svg",w={text:["M4 7V5h16v2M9 19h6M12 5v14"],link:["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71","M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],image:["M3 5h18v14H3z","m3 16 5-5 4 4 3-3 6 6","M15.5 8.5h.01"],hide:["M9.88 9.88a3 3 0 1 0 4.24 4.24","M10.73 5.08A10.4 10.4 0 0 1 12 5c7 0 10 7 10 7a13.2 13.2 0 0 1-1.67 2.68","M6.61 6.61A13.5 13.5 0 0 0 2 12s3 7 10 7a9.7 9.7 0 0 0 5.39-1.61","m2 2 20 20"],slot:["M3 3h18v18H3z","M7 9h10v6H7z"],undo:["M3 7v6h6","M21 17a9 9 0 0 0-15-6.7L3 13"],up:["m18 15-6-6-6 6"],down:["m6 9 6 6 6-6"],cursor:["m4 4 7.07 17 2.51-7.39L21 11.07z"],code:["m16 18 6-6-6-6M8 6l-6 6 6 6"],chevron:["m9 18 6-6-6-6"],check:["M20 6 9 17l-5-5"],close:["M18 6 6 18M6 6l12 12"]};function v(t,e=15){const i=document.createElementNS(y,"svg");for(const[t,n]of Object.entries({width:String(e),height:String(e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.9","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"}))i.setAttribute(t,n);for(const e of w[t]){const t=document.createElementNS(y,"path");t.setAttribute("d",e),i.appendChild(t)}return i}const j='Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif',F='ui-monospace,"SF Mono",Menlo,monospace',A=`.s,.x{font:12.5px/1.4 ${j};border-radius:10px;padding:14px 16px;text-align:center}.s{border:2px dashed #7A6CFF;background:#F4F2FF;color:#4C3FD1}.s b{font-weight:700}.s code{font-family:${F}}.s div{font-size:11.5px;color:#6B5FD9;margin-top:3px}.x{border:1.5px dashed #F04438;background:#FEF3F2;color:#B42318;text-align:start;padding:10px 12px;font-size:12px}`,$=`\n*{box-sizing:border-box}\n.r{font:13px/1.4 ${j};color:#242B3A;-webkit-font-smoothing:antialiased}\nbutton{font:inherit;color:inherit;cursor:pointer}\nbutton:disabled{cursor:not-allowed}\nbutton:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid #31D6C8;outline-offset:1px}\n.box{position:fixed;pointer-events:none;border:2px dashed #00A99A;background:rgba(0,169,154,.07);border-radius:4px;display:none}\n.box.sel{border-style:solid;background:rgba(0,169,154,.04)}\n.chip{position:absolute;bottom:100%;inset-inline-start:-2px;margin-bottom:2px;background:#00A99A;color:#fff;font-size:11px;font-weight:600;padding:3px 8px;border-radius:6px 6px 6px 0;white-space:nowrap;max-width:60vw;overflow:hidden;text-overflow:ellipsis}\n.help{position:fixed;top:16px;inset-inline-end:16px;width:240px;background:#fff;border:1px solid #E5EAF2;border-radius:10px;box-shadow:0 8px 24px rgba(10,18,64,.14);padding:10px 12px}\n.help h3{margin:0 0 6px;font-size:11px;font-weight:700;color:#6B7280;letter-spacing:.5px;text-transform:uppercase}\n.help .row{display:flex;align-items:center;gap:8px;font-size:12px;padding:3px 0}\n.kbd{min-width:38px;text-align:center;font-size:11px;font-weight:600;border:1px solid #E5EAF2;border-radius:5px;padding:1px 5px;background:#F8FAFC}\n.help .x{position:absolute;top:6px;inset-inline-end:6px;border:0;background:none;color:#8990A8;padding:2px;display:grid}\n.dock{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:6px;background:#071342;color:#fff;border-radius:14px;padding:7px 7px 7px 14px;box-shadow:0 12px 32px rgba(10,18,64,.35);white-space:nowrap;max-width:calc(100vw - 24px)}\n.r.open .dock{left:calc(50% - 190px)}\n.r.open[dir=rtl] .dock{left:calc(50% + 190px)}\n.logo{width:22px;height:22px;border-radius:6px;background:#fff;color:#071342;display:grid;place-items:center;font-weight:800;font-size:13px;flex:none}\n.name{font-size:12.5px;font-weight:600;margin-inline-start:4px;overflow:hidden;text-overflow:ellipsis;max-width:200px}\n.sub{font-size:12px;color:#A8AEC1;overflow:hidden;text-overflow:ellipsis;max-width:220px}\n.sep{width:1px;height:22px;background:#2A3366;margin:0 8px;flex:none}\n.hint{font-size:12px;color:#C9CEDD;display:inline-flex;align-items:center;gap:6px}\n.hint svg{color:#31D6C8}\n.db{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border-radius:8px;border:0;background:#1B245A;color:#fff;font-size:12.5px;font-weight:600}\n.ib{height:32px;width:32px;border-radius:8px;border:0;background:transparent;color:#fff;display:grid;place-items:center}\n.ib:disabled{color:#4A527A}\n.go{height:32px;padding:0 14px;border-radius:8px;border:0;background:#31D6C8;color:#071342;font-size:12.5px;font-weight:700}\n.pop{position:absolute;bottom:calc(100% + 10px);left:0;right:0;min-width:280px;max-height:50vh;overflow:auto;background:#fff;color:#242B3A;border-radius:12px;border:1px solid #E5EAF2;box-shadow:0 12px 32px rgba(10,18,64,.18);padding:6px;white-space:normal}\n.pop .e{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;background:none;border-radius:8px;font-size:12.5px;text-align:start}\n.pop .e:hover{background:#F8FAFC}\n.pop .empty{padding:12px;font-size:12.5px;color:#6B7280}\n.num{width:20px;height:20px;border-radius:99px;background:#071342;color:#fff;font-size:11px;font-weight:700;display:grid;place-items:center;flex:none}\n.panel{position:fixed;top:0;bottom:0;inset-inline-end:0;width:380px;max-width:100vw;background:#fff;border-inline-start:1px solid #E5EAF2;box-shadow:-8px 0 24px rgba(10,18,64,.06);display:flex;flex-direction:column}\n.hd{padding:16px 18px 14px;border-bottom:1px solid #E5EAF2}\n.crumbs{display:flex;align-items:center;flex-wrap:wrap;gap:4px;font-size:11.5px;color:#6B7280;margin-bottom:6px}\n.crumbs svg{color:#A8AEC1}\n.crumb{border:0;background:transparent;color:#6B7280;font-weight:500;font-size:11.5px;padding:2px 6px;border-radius:5px}\n.crumb.cur{background:#E5F9F6;color:#0F766E;font-weight:600}\n.nav{margin-inline-start:auto;display:flex;gap:2px}\n.nav button{border:1px solid #E5EAF2;background:#fff;border-radius:6px;width:24px;height:22px;display:grid;place-items:center;color:#3A4060;padding:0}\n.nav button:disabled{opacity:.4}\n.tr{display:flex;align-items:center;gap:10px}\n.title{font-size:17px;font-weight:700;color:#0A1240;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n.pill{margin-inline-start:auto;display:inline-flex;align-items:center;gap:4px;font-size:11.5px;font-weight:600;padding:3px 8px;border-radius:999px;white-space:nowrap;flex:none}\n.pill.ok{background:#E5F9F6;color:#0F766E}\n.pill.many{background:#FFF7E6;color:#92400E}\n.pill.none{background:#FEF3F2;color:#B42318}\n.bd{padding:16px 18px;overflow:auto;flex:1}\n.lbl{display:block;font-size:12.5px;font-weight:600;color:#242B3A;margin-bottom:8px}\n.tiles{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:18px}\n.tile{display:flex;align-items:center;gap:9px;padding:10px 11px;border-radius:10px;text-align:start;background:#fff;border:1.5px solid #E5EAF2;color:#3A4060}\n.tile[aria-checked=true]{background:#E5F9F6;border-color:#00C8B7;color:#0F766E}\n.tile.slot[aria-checked=true]{background:#F4F2FF;border-color:#7A6CFF;color:#4C3FD1}\n.tile:disabled{opacity:.55}\n.tile b{display:block;font-size:12.5px;font-weight:600;color:#0A1240}\n.tile small{display:block;font-size:10.5px;color:#6B7280}\n.fr{display:flex;align-items:baseline;margin-bottom:8px}\n.fr .lbl{margin:0}\n.was{margin-inline-start:auto;font-size:11.5px;color:#6B7280;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:55%}\ntextarea,input{width:100%;font:inherit;font-size:13.5px;color:#0F1424;padding:10px 12px;border-radius:10px;border:1.5px solid #E5EAF2;background:#fff;outline:none}\ntextarea{line-height:1.5;resize:vertical;border-color:#00C8B7}\ninput{height:40px;padding:0 12px}\ninput.slotin{border-color:#7A6CFF}\ninput.mono{font-family:${F};font-size:12px;height:36px;background:#F8FAFC;border-width:1px}\n.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px;align-items:center}\n.chips span{font-size:11.5px;color:#6B7280;margin-inline-end:2px}\n.vc{font-family:${F};font-size:11.5px;padding:3px 8px;border-radius:6px;border:1px solid #E5EAF2;background:#F8FAFC;color:#3A4060}\n.help2{font-size:11.5px;color:#6B7280;margin-top:5px}\n.err{font-size:11.5px;color:#B42318;margin-top:5px}\n.mt{margin-top:14px}\n.note{background:#FFF7E6;border:1px solid #FCD34D;border-radius:10px;padding:10px 12px;font-size:12.5px;color:#92400E;line-height:1.5}\n.key{font-family:${F};color:#4C3FD1;background:#F4F2FF;padding:1px 6px;border-radius:4px}\n.seg{display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px;background:#F3F5FA;border-radius:9px;padding:3px}\n.seg button{border:0;background:transparent;border-radius:7px;padding:6px 4px;font-size:12px;color:#3A4060}\n.seg button[aria-checked=true]{background:#fff;color:#0A1240;font-weight:600;box-shadow:0 1px 2px rgba(10,18,64,.08)}\n.css{margin-top:20px;display:inline-flex;align-items:center;gap:6px;border:0;background:transparent;padding:0;color:#6B7280;font-size:12px}\n.ft{padding:12px 18px;border-top:1px solid #E5EAF2;display:flex;gap:10px;background:#F8FAFC}\n.cancel{height:38px;padding:0 14px;border-radius:10px;border:1px solid #E5EAF2;background:#fff;color:#242B3A;font-size:13px;font-weight:600}\n.save{flex:1;height:38px;border-radius:10px;border:0;background:#071342;color:#fff;font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.save:disabled{opacity:.45}\n@media (max-width:760px){.r.open .dock{display:none}.help{display:none}}\n`,E=["data-joryio-id","data-testid","data-test","data-qa","data-cy","data-id","name"],z=/^[a-z0-9][a-z0-9_]{0,63}$/,O=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,_=2e3,S="jry_editor_help_dismissed",C=t=>!!t&&!!t.closest("[data-joryio-editor]");function M(t){if(!i(t))return[];try{return Array.from(document.querySelectorAll(t)).filter(t=>!C(t))}catch(t){return[]}}const B=(t,e,i)=>{try{const n=Array.from(t.querySelectorAll(e)).filter(t=>!C(t));return 1===n.length&&n[0]===i}catch(t){return!1}};const N=["text","link","image","hide","slot"],I={text:"replace_text",link:"replace_link",image:"replace_image",hide:"hide",slot:"insert_placement"},D={replace_text:"text",replace_link:"link",replace_image:"image",hide:"hide",insert_placement:"slot"},H={text:"actText",link:"actLink",image:"actImage",hide:"actHide",slot:"actSlot"},L={text:"text",link:"link",image:"image",hide:"hide",slot:"slot"},T=[["before","posBefore"],["after","posAfter"],["replace","posReplace"],["prepend","posPrepend"],["append","posAppend"]],P=(t,e)=>"string"==typeof t?t.trim().slice(0,e):"",R=t=>(t&&t.textContent||"").replace(/\s+/g," ").trim();class U{constructor(t,e,i,n=()=>{}){this.dashboardOrigin=t,this.opener=e,this.logger=i,this.onStop=n,this.listeners=[],this.active=!1,this.host=null,this.root=null,this.wrap=null,this.hoverBox=null,this.selBox=null,this.dock=null,this.panel=null,this.help=null,this.hovered=null,this.selected=null,this.draft=null,this.showCss=!1,this.popOpen=!1,this.edits=[],this.history=[],this.synced=!1,this.t=Object.assign({},l),this.dir="ltr",this.ctx={campaignName:"",variantName:"",attributes:[],placements:[],sample:{}},this.previewUndo=[],this.originals=new WeakMap}start(){if(this.active)return;this.active=!0;const t=t=>{const e=t.data;e&&"string"==typeof e.type&&t.origin===this.dashboardOrigin&&t.source===this.opener&&("joryio:editor-close"===e.type?this.stop():"joryio:editor-context"===e.type?this.applyContext(e):"joryio:editor-focus"===e.type&&this.focusEdit(e.id))};window.addEventListener("message",t),this.listeners.push(()=>window.removeEventListener("message",t)),this.activate()}isActive(){return this.active}editList(){return this.edits.slice()}stop(){var t;if(this.active){this.send({type:"joryio:editor-closed"}),this.active=!1;for(const t of this.listeners.splice(0))t();this.clearPreview(),null===(t=this.host)||void 0===t||t.remove(),this.host=this.root=this.wrap=this.hoverBox=this.selBox=this.dock=this.panel=this.help=null,this.selected=this.hovered=null,this.draft=null;try{this.onStop()}catch(t){this.logger.debug("Joryio editor stop callback failed",t)}}}send(t){if(this.active)try{this.opener.postMessage(t,this.dashboardOrigin)}catch(t){}}activate(){const t=document,e=t.createElement("joryio-editor");e.setAttribute("data-joryio-editor","root"),e.setAttribute("style","all:initial !important;position:fixed !important;top:0 !important;left:0 !important;width:0 !important;height:0 !important;z-index:2147483647 !important;display:block !important");const i=e.attachShadow({mode:"closed"});i.appendChild(k("style",null,$));const n=k("div",{class:"r",dir:this.dir});this.hoverBox=k("div",{class:"box","data-j":"hover"}),this.selBox=k("div",{class:"box sel","data-j":"selected"}),n.append(this.hoverBox,this.selBox),i.appendChild(n),t.documentElement.appendChild(e),this.host=e,this.root=i,this.wrap=n;const o=e=>{const i=e.target instanceof Element?e.target:null;C(i)||(this.hovered=i&&i!==t.body&&i!==t.documentElement?i:null,this.place(this.hoverBox,this.hovered===this.selected?null:this.hovered,!0))},s=e=>{C(e.target instanceof Element?e.target:null)||(e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&e.target!==t.body&&e.target!==t.documentElement&&this.select(e.target))},r=t=>{if("Escape"!==t.key){if(!C(t.target instanceof Element?t.target:null)&&("ArrowUp"===t.key||"ArrowDown"===t.key)){const e=this.selected||this.hovered;if(!e)return;t.preventDefault(),t.stopPropagation(),this.move("ArrowUp"===t.key?"up":"down",e)}}else this.popOpen?this.togglePop(!1):this.panel?this.cancel():this.stop()},a=()=>{this.place(this.hoverBox,this.hovered===this.selected?null:this.hovered,!0),this.place(this.selBox,this.selected)};t.addEventListener("mousemove",o,!0),t.addEventListener("click",s,!0),t.addEventListener("keydown",r,!0),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),this.listeners.push(()=>t.removeEventListener("mousemove",o,!0),()=>t.removeEventListener("click",s,!0),()=>t.removeEventListener("keydown",r,!0),()=>window.removeEventListener("scroll",a,!0),()=>window.removeEventListener("resize",a)),this.renderDock(),this.renderHelp(),this.send({type:"joryio:editor-active",url:`${location.origin}${location.pathname}`})}applyContext(o){var s;this.synced=!0,this.t=function(t){const e=Object.assign({},l);if(t&&"object"==typeof t)for(const i of Object.keys(l)){const n=t[i];"string"==typeof n&&n.trim()&&n.length<=500&&(e[i]=n)}return e}(o.strings),this.dir="rtl"===o.dir?"rtl":"ltr",null===(s=this.wrap)||void 0===s||s.setAttribute("dir",this.dir);const r=(t,e,i)=>(Array.isArray(t)?t:[]).map(e).filter(t=>null!==t).slice(0,i);if(this.ctx={campaignName:P(o.campaignName,120),variantName:P(o.variantName,60),attributes:r(o.attributes,t=>t&&"string"==typeof t.name&&O.test(t.name)?{name:t.name,custom:!0===t.custom}:null,40),placements:r(o.placements,t=>t&&"string"==typeof t.key&&z.test(t.key)?{key:t.key,name:P(t.name,80)}:null,40),sample:{}},o.sample&&"object"==typeof o.sample)for(const[t,e]of Object.entries(o.sample).slice(0,100))/^user\.[A-Za-z0-9_.]{1,80}$/.test(t)&&"string"==typeof e&&(this.ctx.sample[t]=e.slice(0,200));Array.isArray(o.edits)&&(this.edits=r(o.edits,o=>function(o){if(!o||"object"!=typeof o||"string"!=typeof o.id||!i(o.selector))return null;const s=Object.assign({id:o.id,selector:o.selector.trim()},!0===o.personalized?{personalized:!0}:{});switch(o.operation){case"hide":return Object.assign(Object.assign({},s),{operation:"hide"});case"replace_text":return"string"==typeof o.value&&o.value.length<=2e3?Object.assign(Object.assign({},s),{operation:"replace_text",value:o.value}):null;case"replace_image":case"replace_link":return n(o.value)?Object.assign(Object.assign({},s),{operation:o.operation,value:o.value.trim()}):null;case"insert_placement":return"string"==typeof o.placementKey&&e.test(o.placementKey)?Object.assign(Object.assign({},s),{operation:"insert_placement",placementKey:o.placementKey,position:t.includes(o.position)?o.position:"after"}):null;default:return null}}(o),100).map(t=>{const{personalized:e}=t,i=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(i[n[o]]=t[n[o]])}return i}(t,["personalized"]);return i}),this.history=[]),this.renderPreview(),this.renderDock(),this.renderHelp(),this.draft&&this.renderPanel(),"string"==typeof o.focusId&&this.focusEdit(o.focusId)}place(t,e,i=!1){if(!t)return;if(!e||!e.isConnected)return void(t.style.display="none");const n=e.getBoundingClientRect();Object.assign(t.style,{display:"block",top:n.top-2+"px",left:n.left-2+"px",width:`${n.width+4}px`,height:`${n.height+4}px`}),t.textContent="";const o=`${this.t[m(e.tagName)]} · ${e.tagName.toLowerCase()}`;t.appendChild(k("span",{class:"chip","data-j":"label"},i?`${o} - ${this.t.clickToEdit}`:o))}move(t,e){const i="up"===t?e.parentElement:Array.from(e.children).filter(t=>!C(t))[0]||null;i&&i!==document.body&&i!==document.documentElement&&this.select(i)}select(t,e){if(!this.active)return;this.selected=t,this.hovered=null,this.place(this.hoverBox,null),this.place(this.selBox,t),this.popOpen=!1;const n=e?e.selector:function(t){const e=t.ownerDocument;if(!e)return null;const n=t=>{if((i=t.id)&&i.length<=64&&!/\d{4,}/.test(i)&&!/^(ember|react|radix|headlessui|mui)[-_:]/i.test(i)&&!/:/.test(i)){const i=`#${function(t){const e=globalThis.CSS;if(e&&"function"==typeof e.escape)return e.escape(t);let i="";for(let e=0;e<t.length;e++){const n=t[e],o=t.charCodeAt(e);0===o?i+="�":/[0-9]/.test(n)&&(0===e||1===e&&"-"===t[0])?i+=`\\${o.toString(16)} `:/[A-Za-z0-9_-]/.test(n)||o>=128?i+=n:i+=`\\${n}`}return i}(t.id)}`;if(B(e,i,t))return i}var i;for(const i of E){const n=t.getAttribute(i);if(!n||n.length>100)continue;const o=`${t.tagName.toLowerCase()}[${i}="${n.replace(/["\\]/g,"\\$&")}"]`;if(B(e,o,t))return o}return null},o=n(t);if(o)return i(o)?o:null;const s=[];let r=t;for(;r&&r!==e.body&&r!==e.documentElement;){const t=s.length?n(r):null;if(t){s.unshift(t);break}const i=r.tagName.toLowerCase(),o=r.parentElement,a=o?Array.from(o.children).filter(t=>t.tagName===r.tagName):[];s.unshift(a.length>1?`${i}:nth-of-type(${a.indexOf(r)+1})`:i),r=o,r===e.body&&s.unshift("body")}const a=s.join(" > ");return a&&i(a)&&B(e,a,t)?a:null}(t)||"";this.showCss=!n,this.draft=e?this.draftOf(e):this.newDraft(t,n),this.renderPanel(),this.renderDock(),this.renderHelp(),this.renderPreview()}enabled(t,e){return!e||("text"===t?"IMG"!==e.tagName&&!!this.orig(e).text:"link"===t?"A"===e.tagName:"image"!==t||"IMG"===e.tagName)}newDraft(t,e){const i=this.orig(t),n="IMG"===t.tagName?"image":this.enabled("text",t)?"text":"A"===t.tagName?"link":"hide";return{action:n,text:i.text.slice(0,_),url:("image"===n?i.src:i.href)||"",slotName:"",position:"after",selector:e,editingId:null,touched:!1}}draftOf(t){const e=D[t.operation];return{action:e,text:"replace_text"===t.operation&&t.value||"",url:("link"===e||"image"===e)&&t.value||"",slotName:t.placementKey||"",position:t.position||"after",selector:t.selector,editingId:t.id,touched:!0}}orig(t){return this.originals.get(t)||{text:R(t),href:t.getAttribute("href"),src:t.getAttribute("src")}}focusEdit(t){const e=this.edits.filter(e=>e.id===t)[0];if(!e||!this.active)return!1;const i=M(e.selector)[0]||null;if(i){try{i.scrollIntoView({block:"center"})}catch(t){}this.select(i,e)}else this.selected=null,this.place(this.selBox,null),this.draft=this.draftOf(e),this.showCss=!0,this.renderPanel(),this.renderDock(),this.renderHelp(),this.renderPreview();return!0}draftEdit(t){const e={id:t.editingId||"",selector:t.selector.trim()};if(!i(e.selector))return null;const o=I[t.action];if("hide"===t.action)return Object.assign(Object.assign({},e),{operation:o});if("text"===t.action)return t.text.trim()&&t.text.length<=_?Object.assign(Object.assign({},e),{operation:o,value:t.text}):null;if("link"===t.action||"image"===t.action)return n(t.url)?Object.assign(Object.assign({},e),{operation:o,value:t.url.trim()}):null;const s=g(t.slotName);return z.test(s)?Object.assign(Object.assign({},e),{operation:o,placementKey:s,position:t.position}):null}save(){var t,e;const i=this.draft,n=i&&this.draftEdit(i);if(!i||!n)return;const o=this.selected||M(n.selector)[0]||null;this.pick(o,n.selector,n.operation,null!==(e=null!==(t=n.value)&&void 0!==t?t:n.placementKey)&&void 0!==e?e:"",{id:i.editingId||void 0,position:n.position})}pick(t,e,o,s,a={}){const l=a.id||`e${Math.random().toString(36).slice(2,10).padEnd(8,"0")}`,c=t?t.tagName.toLowerCase():"",d=t?this.orig(t).text.slice(0,200):"";let p=null;if(i(e)){const t={id:l,selector:e.trim()};if("hide"===o)p=Object.assign(Object.assign({},t),{operation:o});else if("replace_text"===o)p=(s||d)&&(s||d).length<=_?Object.assign(Object.assign({},t),{operation:o,value:s||d}):null;else if("replace_image"===o||"replace_link"===o)p=n(s)?Object.assign(Object.assign({},t),{operation:o,value:s.trim()}):null;else if("insert_placement"===o){const e=g(s);p=z.test(e)?Object.assign(Object.assign({},t),{operation:o,placementKey:e,position:a.position||"after"}):null}}if(!p)return!1;const h=Object.assign(Object.assign({type:r},p),{tag:c,text:d});this.send(h);const u=this.edits.map(t=>t.id).indexOf(l);return this.history.push({id:l,before:u>=0?this.edits[u]:null}),u>=0?this.edits[u]=p:this.edits.push(p),this.closePanel(),!0}cancel(){this.closePanel()}closePanel(){var t,e;this.draft=null,this.selected=null,null===(t=this.panel)||void 0===t||t.remove(),this.panel=null,null===(e=this.wrap)||void 0===e||e.classList.remove("open"),this.place(this.selBox,null),this.renderPreview(),this.renderDock(),this.renderHelp()}undo(){if(!this.synced)return!1;const t=this.history.pop();if(!t)return!1;const e=this.edits.map(t=>t.id).indexOf(t.id);if(t.before){e>=0&&(this.edits[e]=t.before);const i=t.before;this.send(Object.assign(Object.assign({type:r},i),{tag:"",text:""}))}else e>=0&&this.edits.splice(e,1),this.send({type:"joryio:editor-remove",id:t.id});return this.draft?this.closePanel():(this.renderPreview(),this.renderDock()),!0}done(){this.send({type:"joryio:editor-done"}),this.stop();try{this.opener.focus()}catch(t){}try{window.close()}catch(t){}}clearPreview(){for(const t of this.previewUndo.splice(0).reverse())try{t()}catch(t){}}renderPreview(){if(this.clearPreview(),!this.active)return;const t=this.draft,e=t?this.draftEdit(t):null,i=[];for(const n of this.edits)i.push(t&&t.editingId===n.id&&e||n);t&&!t.editingId&&e&&t.touched&&i.push(e);for(const t of i)for(const e of M(t.selector).slice(0,50))this.applyPreview(t,e);this.selected&&this.place(this.selBox,this.selected)}previewNode(t){const e=document.createElement("joryio-editor-preview");e.setAttribute("data-joryio-editor","preview"),e.setAttribute("style","all:initial !important;display:block !important;margin:10px 0 !important");const i=e.attachShadow({mode:"open"});return i.appendChild(k("style",null,A)),t(i),e}applyPreview(t,e){this.originals.has(e)||this.originals.set(e,{text:R(e),href:e.getAttribute("href"),src:e.getAttribute("src")});const i=this.previewUndo,n=(t,n)=>{const o=e.getAttribute(t);null===n?e.removeAttribute(t):e.setAttribute(t,n),i.push(()=>null===o?e.removeAttribute(t):e.setAttribute(t,o))},o=()=>{const t=e.style;if(!t)return;const n=t.getPropertyValue("display"),o=t.getPropertyPriority("display");t.setProperty("display","none","important"),i.push(()=>n?t.setProperty("display",n,o):t.removeProperty("display"))},s=(t,n)=>{const o=e.parentNode;"before"===n&&o?o.insertBefore(t,e):"after"!==n&&"replace"!==n||!o?"prepend"===n?e.insertBefore(t,e.firstChild):e.appendChild(t):o.insertBefore(t,e.nextSibling),i.push(()=>t.parentNode&&t.parentNode.removeChild(t))};switch(t.operation){case"replace_text":{const n=Array.from(e.childNodes);e.textContent=(r=t.value||"",a=this.ctx.sample,(r||"").replace(new RegExp(d.source,"g"),(t,e)=>{const i=e.trim(),n=i.split("|")[0].trim(),o=p.exec(i);return Object.prototype.hasOwnProperty.call(a,n)&&""!==a[n]?a[n]:o&&h(o[1])?h(o[1]):`[${n.replace(/^user\.(custom\.)?/,"")}]`})),i.push(()=>{e.textContent="";for(const t of n)e.appendChild(t)});break}case"replace_link":n("href",t.value||null);break;case"replace_image":n("srcset",null),n("src",t.value||null);break;case"hide":{const t=`${this.t[m(e.tagName)]} "${this.orig(e).text.slice(0,40)}"`;s(this.previewNode(e=>e.appendChild(k("div",{class:"x"},`${this.t.hiddenFor}: ${t}`))),"after"),o();break}case"insert_placement":{const e=t.position||"after";s(this.previewNode(e=>e.appendChild(k("div",{class:"s"},k("b",null,`${this.t.slotPreview} · `),k("code",null,t.placementKey||""),k("div",null,this.t.slotHelp)))),e),"replace"===e&&o();break}}var r,a}renderHelp(){var t;null===(t=this.help)||void 0===t||t.remove(),this.help=null;let e=!1;try{e="1"===localStorage.getItem(S)}catch(t){}if(e||this.draft||!this.wrap)return;const i=this.t,n=(t,e)=>k("div",{class:"row"},k("span",{class:"kbd"},t),e),o=k("button",{class:"x",type:"button","aria-label":i.dismiss,title:i.dismiss,"data-j":"help-dismiss"},v("close",13));o.addEventListener("click",()=>{var t;try{localStorage.setItem(S,"1")}catch(t){}null===(t=this.help)||void 0===t||t.remove(),this.help=null}),this.help=k("div",{class:"help","data-j":"help",role:"note"},o,k("h3",null,i.helpTitle),n("↑",i.helpUp),n("↓",i.helpDown),n(i.helpClickKey,i.helpClick)),this.wrap.appendChild(this.help)}editTitle(t){const e=M(t.selector)[0],i=this.t[e?m(e.tagName):m(t.selector,!0)];return`${this.t[H[D[t.operation]]]} · ${i}`}togglePop(t){this.popOpen=t,this.renderDock()}renderDock(){var t;if(!this.wrap)return;const e=this.t;null===(t=this.dock)||void 0===t||t.remove();const i=this.edits.length,n=[this.ctx.variantName?c(e.variant,{name:this.ctx.variantName}):"",location.pathname||"/"].filter(Boolean).join(" · "),o=k("button",{class:"db",type:"button","aria-expanded":String(this.popOpen),"data-j":"edits"},1===i?e.editsOne:c(e.editsMany,{n:i}),v(this.popOpen?"down":"up",11));o.addEventListener("click",()=>this.togglePop(!this.popOpen));const s=this.synced&&this.history.length>0,r=k("button",{class:"ib",type:"button","aria-label":e.undo,title:this.synced?e.undo:e.undoOffline,disabled:!s,"data-j":"undo"},v("undo",14));r.addEventListener("click",()=>this.undo());const a=k("button",{class:"go",type:"button","data-j":"done"},e.saveReturn);a.addEventListener("click",()=>this.done());const l=k("div",{class:"dock","data-j":"dock",role:"toolbar","aria-label":e.title},k("span",{class:"logo","aria-hidden":"true"},"J"),k("span",{class:"name","data-j":"campaign"},this.ctx.campaignName||e.title),k("span",{class:"sub"},`· ${n}`),k("span",{class:"sep"}),k("span",{class:"hint","data-j":"hint"},v("cursor",13),this.draft?e.hintEditing:e.hintPoint),k("span",{class:"sep"}),o,r,a);if(this.popOpen){const t=k("div",{class:"pop","data-j":"edit-list",role:"menu"});i||t.appendChild(k("div",{class:"empty"},e.noEdits)),this.edits.forEach((e,i)=>{const n=k("button",{class:"e",type:"button",role:"menuitem","data-j":"edit-item","data-edit-id":e.id},k("span",{class:"num"},String(i+1)),this.editTitle(e));n.addEventListener("click",()=>this.focusEdit(e.id)),t.appendChild(n)}),l.appendChild(t)}this.dock=l,this.wrap.appendChild(l)}renderPanel(){var t;const e=this.draft;if(!e||!this.wrap)return;const n=this.t,o=this.selected;null===(t=this.panel)||void 0===t||t.remove(),this.wrap.classList.add("open");const s=k("div",{class:"crumbs","data-j":"crumbs"});if(o){const t=[];for(let e=o;e&&e!==document.body&&e!==document.documentElement;e=e.parentElement)t.unshift(e);const e=t.slice(-3),i=(t,e,i)=>{const n=k("button",{class:i?"crumb cur":"crumb",type:"button","data-j":"crumb","aria-current":i?"true":void 0,disabled:!e},t);return e&&!i&&n.addEventListener("click",()=>this.select(e)),n};s.appendChild(i(n.page,null,!1));for(const t of e)s.append(v("chevron",9),i(n[m(t.tagName)],t,t===o));const r=k("button",{type:"button","aria-label":n.up,title:n.up,"data-j":"up",disabled:!o.parentElement||o.parentElement===document.body},v("up",12));r.addEventListener("click",()=>this.move("up",o));const a=k("button",{type:"button","aria-label":n.down,title:n.down,"data-j":"down",disabled:!Array.from(o.children).some(t=>!C(t))},v("down",12));a.addEventListener("click",()=>this.move("down",o)),s.appendChild(k("span",{class:"nav"},r,a))}const r=n[o?m(o.tagName):m(e.selector,!0)],a=o?"IMG"===o.tagName?o.getAttribute("alt")||"":this.orig(o).text:"",l=k("div",{class:"title","data-j":"title"},a?`${r} "${a.slice(0,40)}"`:r),d=k("span",{class:"pill","data-j":"matches"}),p=k("div",{class:"hd"},s,k("div",{class:"tr"},l,d)),h=k("div",{class:"tiles",role:"radiogroup","aria-label":n.whatToDo});for(const t of N){const i=e.action===t,s=i||this.enabled(t,o),r=s?"":"link"===t?n.notLink:"image"===t?n.notImage:n.noText,a=k("button",{class:"slot"===t?"tile slot":"tile",type:"button",role:"radio","aria-checked":String(i),disabled:!s,"data-j":`action-${t}`},v(L[t]),k("span",null,k("b",null,n[H[t]]),r?k("small",null,r):null));a.addEventListener("click",()=>{this.draft&&this.draft.action!==t&&(this.draft.action=t,this.draft.touched=!0,"link"!==t&&"image"!==t||!o||(this.draft.url=("image"===t?this.orig(o).src:this.orig(o).href)||""),this.renderPanel(),this.renderPreview())}),h.appendChild(a)}const u=k("div",{"data-j":"fields"}),f=k("button",{class:"save",type:"button","data-j":"save"}),x=()=>{const t=!!this.draftEdit(e);f.disabled=!t,f.textContent=c(n.save,{action:n[H[e.action]]});const i=M(e.selector).length;d.className="pill "+(1===i?"ok":i>1?"many":"none"),d.textContent=1===i?n.matchOne:i>1?c(n.matchMany,{n:i}):n.matchNone},b=()=>{e.touched=!0,x(),this.renderPreview()};this.renderFields(u,e,o,b);const g=k("button",{class:"css",type:"button","aria-expanded":String(this.showCss),"data-j":"css-toggle"},v("code",13),n.css,v(this.showCss?"up":"down",10));g.addEventListener("click",()=>{this.showCss=!this.showCss,this.renderPanel()});const y=k("div",{class:"bd"},k("span",{class:"lbl"},n.whatToDo),h,u,g);if(this.showCss){const t=k("input",{class:"mono",dir:"ltr","aria-label":n.css,spellcheck:"false","data-j":"selector"});t.value=e.selector;const o=k("div",{class:"help2"}),s=()=>{const t=i(e.selector);o.className=t?"help2":"err",o.textContent=e.selector.trim()?t?c(n.cssHelp,{n:M(e.selector).length}):n.cssBad:n.noSelector};t.addEventListener("input",()=>{e.selector=t.value,s(),b()}),s(),y.append(k("div",{class:"mt"},t,o))}const w=k("button",{class:"cancel",type:"button","data-j":"cancel"},n.cancel);w.addEventListener("click",()=>this.cancel()),f.addEventListener("click",()=>this.save());const j=k("aside",{class:"panel","data-j":"panel",role:"dialog","aria-label":n.whatToDo},p,y,k("div",{class:"ft"},w,f));x(),this.panel=j,this.wrap.appendChild(j)}renderFields(t,e,i,o){const s=this.t;t.textContent="";const r=t=>t?k("span",{class:"was",title:t},c(s.was,{value:t.slice(0,60)})):null;if("text"===e.action){const n=k("textarea",{rows:"3",dir:"auto","data-j":"text","aria-label":s.newText});n.value=e.text;const a=k("div",{"data-j":"fallback-box"}),l=()=>{a.textContent="";const t=f(e.text);if(null===t)return;const i=k("input",{dir:"auto","data-j":"fallback","aria-label":s.fallback});i.value=t,i.addEventListener("input",()=>{var t,s;e.text=(t=e.text,s=i.value,(t||"").replace(new RegExp(d.source,"g"),(t,e)=>{const i=e.trim().replace(new RegExp(p.source,"g"),"").trim();return s?`{{ ${i} | default: ${x(s)} }}`:`{{ ${i} }}`})),n.value=e.text,o()}),a.append(k("div",{class:"mt"},k("label",{class:"lbl"},s.fallback),i,k("div",{class:"help2"},s.fallbackHelp)))};let c=u(e.text).length>0;n.addEventListener("input",()=>{e.text=n.value;const t=u(e.text).length>0;t!==c&&(c=t,l()),o()});const h=k("div",{class:"chips","data-j":"chips"},k("span",null,s.insert)),g=this.ctx.attributes.length?this.ctx.attributes:[{name:"firstName",custom:!1},{name:"lastName",custom:!1}];for(const t of g.slice(0,12)){const i=k("button",{class:"vc",type:"button","data-j":"chip"},t.name);i.addEventListener("click",()=>{const i=b(t.name,t.custom,f(e.text)||null);e.text=e.text?`${e.text.replace(/\s+$/,"")} ${i}`:i,n.value=e.text,c||(c=!0,l()),o()}),h.appendChild(i)}t.append(k("div",{class:"fr"},k("label",{class:"lbl"},s.newText),r(i?this.orig(i).text:null)),n,h,a),l()}else if("link"===e.action||"image"===e.action){const a=k("input",{type:"url",dir:"ltr",inputmode:"url",placeholder:"https://","data-j":"url","aria-label":"link"===e.action?s.newLink:s.newImage});a.value=e.url;const l=k("div",{class:"err"}),c=()=>l.textContent=e.url.trim()&&!n(e.url)?s.urlBad:"";a.addEventListener("input",()=>{e.url=a.value,c(),o()}),c();const d=i?"image"===e.action?this.orig(i).src:this.orig(i).href:null;t.append(k("div",{class:"fr"},k("label",{class:"lbl"},"link"===e.action?s.newLink:s.newImage),r(d)),a,l)}else if("hide"===e.action){const n=s[i?m(i.tagName):m(e.selector,!0)].toLowerCase();t.appendChild(k("div",{class:"note","data-j":"hide-note"},c(s.hideNote,{kind:n})))}else{const i=k("input",{class:"slotin",dir:"auto","data-j":"slot-name","aria-label":s.slotName,maxlength:"80"});i.value=e.slotName;const n=k("span",{class:"key","data-j":"slot-key"}),r=k("div",{class:"help2"}),a=()=>{const t=g(e.slotName);n.textContent=t||"-",r.textContent="",r.append(`${s.savedAs} `,n,t?"":` · ${s.slotEmpty}`)};if(i.addEventListener("input",()=>{e.slotName=i.value,a(),o()}),a(),t.append(k("label",{class:"lbl"},s.slotName),i,r),this.ctx.placements.length){const n=k("div",{class:"chips","data-j":"placements"});for(const t of this.ctx.placements.slice(0,12)){const s=k("button",{class:"vc",type:"button",title:t.name||t.key,"data-j":"placement"},t.key);s.addEventListener("click",()=>{e.slotName=t.key,i.value=t.key,a(),o()}),n.appendChild(s)}t.appendChild(n)}t.appendChild(k("div",{class:"help2"},s.slotHelp));const l=k("div",{class:"seg",role:"radiogroup","aria-label":s.where,"data-j":"positions"});for(const[t,i]of T){const n=k("button",{type:"button",role:"radio","aria-checked":String(e.position===t),"data-j":`pos-${t}`},s[i]);n.addEventListener("click",()=>{e.position=t;for(const t of Array.from(l.children))t.setAttribute("aria-checked",String(t===n));o()}),l.appendChild(n)}t.append(k("div",{class:"mt"},k("span",{class:"lbl"},s.where),l))}}}const J={version:1,start({dashboardOrigin:t,opener:e,logger:i,onStop:n}){const o=new U(t,e,i,n);return o.start(),{stop:()=>o.stop()}}};"undefined"==typeof window||window[a]||(window[a]=J)}();
7
7
  //# sourceMappingURL=joryio-editor.min.js.map