@cancia/toolbar 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cancia.d.ts +50 -0
- package/dist/cancia.iife.js +605 -0
- package/dist/cancia.js +2629 -0
- package/dist/cancia.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
"use strict";var Cancia=(()=>{var ye=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var Et=(e,t)=>{for(var n in t)ye(e,n,{get:t[n],enumerable:!0})},wt=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ht(t))!vt.call(e,r)&&r!==n&&ye(e,r,{get:()=>t[r],enumerable:!(o=xt(t,r))||o.enumerable});return e};var kt=e=>wt(ye({},"__esModule",{value:!0}),e);var dn={};Et(dn,{clearSession:()=>Ae,destroy:()=>ne,getValue:()=>U,init:()=>Be,onPendingChange:()=>F});var p={config:null,cmsData:{},pending:new Map,activeLang:"",editMode:!1,sessionToken:"",onLogout:null,schemas:{},activeListLocale:""};function Lt(e,t){return`${e}.${t}`}function U(e,t){let n=`${e}.${t}`,o=p.pending.get(n);return o?o.value:p.cmsData[n]!==void 0?p.cmsData[n]:""}function G(e,t,n){let o=Lt(e,t);p.pending.set(o,{key:e,lang:t,value:n})}function oe(){document.querySelectorAll("[data-cms]").forEach(e=>{if(e.dataset.cmsList!==void 0)return;let t=e.dataset.cms;if(!t)return;let n=p.cmsData[`${t}.${p.activeLang}`];if(n!==void 0){if(e.tagName==="IMG"){e.src=n;return}if(e.childElementCount>0){console.warn(`Cancia: skipping overlay for "${t}" \u2014 element has child elements (textContent would destroy them).`);return}e.textContent=n}})}function Oe(){for(let[e,{key:t,lang:n}]of p.pending){let o=p.cmsData[e]??"";document.querySelectorAll(`[data-cms="${t}"]`).forEach(r=>{r.tagName==="IMG"?r.src=o:r.textContent=o})}p.pending.clear()}function S(){let e={"Content-Type":"application/json"};return p.sessionToken&&(e.Authorization=`Bearer ${p.sessionToken}`),e}async function Re(){let{apiUrl:e,site:t}=p.config,n=await fetch(`${e}/api/cancia/content?site=${encodeURIComponent(t)}`,{headers:S()});if(!n.ok)throw new Error(`Cancia: failed to fetch content (${n.status})`);return n.json()}async function Ct(e,t,n){let{apiUrl:o,site:r}=p.config,a=await fetch(`${o}/api/cancia/save`,{method:"POST",headers:S(),body:JSON.stringify({key:e,lang:t,value:n,site:r})});if(!a.ok)throw new Error(`Cancia: failed to save (${a.status})`)}function Ue(e){return e instanceof Error&&e.message.includes("(401)")}function re(e,t){return new Promise((n,o)=>{let{apiUrl:r,site:a}=p.config,s=new FormData;s.append("file",e),s.append("site",a);let c=new XMLHttpRequest;c.open("POST",`${r}/api/cancia/upload`),p.sessionToken&&c.setRequestHeader("Authorization",`Bearer ${p.sessionToken}`),c.upload.addEventListener("progress",i=>{i.lengthComputable&&t?.(Math.round(i.loaded/i.total*100))}),c.addEventListener("load",()=>{if(c.status>=200&&c.status<300)try{n(JSON.parse(c.responseText).url)}catch{o(new Error("Cancia: invalid upload response"))}else o(new Error(`Cancia: failed to upload image (${c.status})`))}),c.addEventListener("error",()=>o(new Error("Cancia: upload network error"))),c.send(s)})}async function Ne(){let{apiUrl:e,site:t}=p.config,n=await fetch(`${e}/api/cancia/publish`,{method:"POST",headers:S(),body:JSON.stringify({site:t})});if(!n.ok)throw new Error(`Cancia: publish failed (${n.status})`)}async function De(){let{apiUrl:e}=p.config,t=await fetch(`${e}/api/cancia/schemas`,{headers:S()});if(!t.ok)throw new Error(`Cancia: failed to fetch schemas (${t.status})`);return(await t.json()).schemas}function ae(e){return e?`&locale=${encodeURIComponent(e)}`:""}async function je(e,t){let{apiUrl:n,site:o}=p.config,r=await fetch(`${n}/api/cancia/lists/${encodeURIComponent(e)}?site=${encodeURIComponent(o)}${ae(t)}`,{headers:S()});if(!r.ok)throw new Error(`Cancia: failed to fetch list "${e}" (${r.status})`);return(await r.json()).entries}async function _e(e){let{apiUrl:t,site:n}=p.config,o=await fetch(`${t}/api/cancia/lists/${encodeURIComponent(e)}/_translations?site=${encodeURIComponent(n)}`,{headers:S()});if(!o.ok)throw new Error(`Cancia: failed to fetch translations (${o.status})`);return(await o.json()).translations}async function qe(e,t,n,o){let{apiUrl:r,site:a}=p.config,s=await fetch(`${r}/api/cancia/lists/${encodeURIComponent(e)}?site=${encodeURIComponent(a)}${ae(n)}`,{method:"POST",headers:S(),body:JSON.stringify({data:t,id:o})});if(!s.ok){let i=await s.json().catch(()=>({}));throw new Error(i.error??`Cancia: failed to create entry (${s.status})`)}return(await s.json()).entry}async function Ve(e,t,n,o,r){let{apiUrl:a,site:s}=p.config,c=await fetch(`${a}/api/cancia/lists/${encodeURIComponent(e)}/${encodeURIComponent(t)}?site=${encodeURIComponent(s)}${ae(r)}`,{method:"PATCH",headers:S(),body:JSON.stringify({data:n,_rev:o})});if(!c.ok){let u=await c.json().catch(()=>({})),l=u.error??`Cancia: failed to update entry (${c.status})`;throw Object.assign(new Error(l),{code:u.code})}return(await c.json()).entry}async function Ye(e,t,n){let{apiUrl:o,site:r}=p.config,a=await fetch(`${o}/api/cancia/lists/${encodeURIComponent(e)}/${encodeURIComponent(t)}?site=${encodeURIComponent(r)}${ae(n)}`,{method:"DELETE",headers:S()});if(!a.ok)throw new Error(`Cancia: failed to delete entry (${a.status})`)}async function be(){let e=Array.from(p.pending.values()),t=await Promise.allSettled(e.map(({key:o,lang:r,value:a})=>Ct(o,r,a)));t.forEach((o,r)=>{if(o.status==="fulfilled"){let{key:a,lang:s}=e[r];p.pending.delete(`${a}.${s}`)}});let n=t.filter(o=>o.status==="rejected").length;if(n>0)throw new Error(`Cancia: ${n} save(s) failed`)}var ve="[data-cms], [data-cms-list]",ie=null,B=null,xe=[],_=null,T=null,M=null,Ke=!1;function We(){return p.config?.accentColor??"#6366f1"}function Qe(e){return e.dataset.cmsType==="image"||e.tagName==="IMG"?"image":"text"}function et(e){return e.dataset.cmsList?"list":"field"}function Tt(){if(Ke)return;Ke=!0;let e=document.createElement("style");e.textContent=`
|
|
2
|
+
@keyframes cancia-highlight-in {
|
|
3
|
+
from { opacity: 0; transform: scale(0.98); }
|
|
4
|
+
to { opacity: 1; transform: scale(1); }
|
|
5
|
+
}
|
|
6
|
+
@keyframes cancia-tooltip-in {
|
|
7
|
+
from { opacity: 0; transform: scale(0.95) translateY(3px); }
|
|
8
|
+
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
9
|
+
}
|
|
10
|
+
`,document.head.appendChild(e)}function Mt(){return T||(T=document.createElement("div"),T.dataset.canciaOverlay="1",T.style.cssText=`
|
|
11
|
+
position: fixed;
|
|
12
|
+
pointer-events: none !important;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
border-radius: 5px;
|
|
15
|
+
z-index: 2147483644;
|
|
16
|
+
will-change: top, left, width, height, opacity;
|
|
17
|
+
transition: top 0.08s cubic-bezier(0.16,1,0.3,1), left 0.08s cubic-bezier(0.16,1,0.3,1),
|
|
18
|
+
width 0.08s cubic-bezier(0.16,1,0.3,1), height 0.08s cubic-bezier(0.16,1,0.3,1);
|
|
19
|
+
`,document.body.appendChild(T)),T}function St(){return M||(M=document.createElement("div"),M.dataset.canciaTooltip="1",M.style.cssText=`
|
|
20
|
+
position: fixed;
|
|
21
|
+
pointer-events: none !important;
|
|
22
|
+
z-index: 2147483645;
|
|
23
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
24
|
+
font-size: 11px;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
letter-spacing: 0.02em;
|
|
27
|
+
color: #fff;
|
|
28
|
+
background: rgba(10,10,12,0.92);
|
|
29
|
+
backdrop-filter: blur(8px);
|
|
30
|
+
-webkit-backdrop-filter: blur(8px);
|
|
31
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
32
|
+
padding: 4px 8px;
|
|
33
|
+
border-radius: 6px;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
max-width: 260px;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
39
|
+
`,document.body.appendChild(M)),M}var he=null;function $t(e){if(!/^#[0-9a-f]{6}$/i.test(e))return"#059669";let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return`#${[n,o,t].map(a=>a.toString(16).padStart(2,"0")).join("")}`}var Ht=`<svg width="10" height="10" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round">
|
|
40
|
+
<path d="M2 4h10M2 7h7M2 10h5"/>
|
|
41
|
+
</svg>`,zt=`<svg width="10" height="10" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
42
|
+
<rect x="1" y="1" width="12" height="12" rx="2"/>
|
|
43
|
+
<circle cx="4.5" cy="4.5" r="1.2"/>
|
|
44
|
+
<path d="M1 9.5l3.5-3 2.5 2.5 2-1.5 3 3.5"/>
|
|
45
|
+
</svg>`,Pt=`<svg width="10" height="10" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
46
|
+
<rect x="1" y="2" width="3" height="3" rx="0.5"/>
|
|
47
|
+
<rect x="1" y="7.5" width="3" height="3" rx="0.5"/>
|
|
48
|
+
<path d="M6 3.5h7M6 9h7"/>
|
|
49
|
+
</svg>`;function tt(e,t=!1){let n=e.getBoundingClientRect(),o=et(e),r=o==="list"?$t(We()):We(),a=Mt(),s=St(),c=3;if(a.style.top=`${n.top-c}px`,a.style.left=`${n.left-c}px`,a.style.width=`${n.width+c*2}px`,a.style.height=`${n.height+c*2}px`,he!==e){he=e,a.style.border=`2px ${o==="list"?"dashed":"solid"} ${r}`,a.style.background=`${r}12`;let l,d,m;if(o==="list")l=Pt,d="list",m=`list: ${e.dataset.cmsList}`;else{let y=Qe(e);l=y==="image"?zt:Ht,d=y,m=e.dataset.cms??""}a.innerHTML=`
|
|
50
|
+
<div style="
|
|
51
|
+
position: absolute; top: -1px; left: -1px;
|
|
52
|
+
background: ${r}; color: #fff;
|
|
53
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
54
|
+
font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
|
|
55
|
+
padding: 2px 6px; border-radius: 3px 0 4px 0;
|
|
56
|
+
display: flex; align-items: center; gap: 4px;
|
|
57
|
+
line-height: 1;
|
|
58
|
+
">
|
|
59
|
+
${l}
|
|
60
|
+
${d}
|
|
61
|
+
</div>
|
|
62
|
+
`,s.textContent=m}a.style.display="block",t&&(a.style.animation="cancia-highlight-in 0.12s ease-out forwards"),s.style.display="block",t&&(s.style.animation="cancia-tooltip-in 0.1s ease-out forwards");let i=8,u=26;n.top-u-i>0?(s.style.top=`${n.top-u-i+c}px`,s.style.left=`${n.left-c}px`):(s.style.top=`${n.bottom+i-c}px`,s.style.left=`${n.left-c}px`)}function Ee(){he=null,T&&(T.style.display="none",T.style.animation="none"),M&&(M.style.display="none",M.style.animation="none")}function Xe(){_===null&&(_=requestAnimationFrame(()=>{_=null,B&&tt(B)}))}function Je(e){let t=e.target.closest(ve);t&&(B=t,t.style.cursor="pointer",tt(t,!0))}function Ge(e){let t=e.target.closest(ve);if(!t)return;let n=e.relatedTarget;n&&t.contains(n)||(t.style.cursor="",B===t&&(B=null,Ee()))}function Ze(e){let t=e.target.closest(ve);if(t)if(e.preventDefault(),e.stopPropagation(),Ee(),et(t)==="list"){let n=t.dataset.cmsList;ie?.({kind:"list",el:t,listName:n})}else{let n=t.dataset.cms;ie?.({kind:"field",el:t,key:n,fieldType:Qe(t)})}}function nt(e){Tt(),ie=e,document.addEventListener("mouseover",Je,!0),document.addEventListener("mouseout",Ge,!0),document.addEventListener("click",Ze,!0),window.addEventListener("scroll",Xe,{passive:!0,capture:!0}),xe=[()=>document.removeEventListener("mouseover",Je,!0),()=>document.removeEventListener("mouseout",Ge,!0),()=>document.removeEventListener("click",Ze,!0),()=>window.removeEventListener("scroll",Xe,!0)]}function we(){B&&(B.style.cursor="",B=null),_!==null&&(cancelAnimationFrame(_),_=null),Ee(),T?.remove(),T=null,M?.remove(),M=null,xe.forEach(e=>e()),xe=[],ie=null}var ke=new Set;function F(e){if(e)return ke.add(e),()=>ke.delete(e);ke.forEach(t=>t())}var se=null,V=null,Z=null,q=!1,ot=new WeakMap;function L(){return p.config?.accentColor??"#6366f1"}function It(e){let t=e.getBoundingClientRect(),n=window.scrollY,o=window.scrollX,r=320,a=260,s=10,c=t.left+o,i=t.bottom+n+s,u="top left";return t.bottom+a+s>window.innerHeight&&(i=t.top+n-a-s,u="bottom left"),c+r>window.innerWidth+o&&(c=window.innerWidth+o-r-s,u=u.replace("left","right")),c<o+s&&(c=o+s),{top:i,left:c,origin:u}}function rt(e,t){let n=document.createElement("div");n.style.cssText=`
|
|
63
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
64
|
+
margin-bottom: 14px;
|
|
65
|
+
`;let o=document.createElement("div");o.style.cssText="display: flex; flex-direction: column; gap: 1px; min-width: 0;";let r=document.createElement("span"),a=e.split(".");r.textContent=a[a.length-1].replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),r.style.cssText=`
|
|
66
|
+
font-size: 13px; font-weight: 600;
|
|
67
|
+
color: rgba(255,255,255,0.9);
|
|
68
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
69
|
+
`;let s=document.createElement("span");return s.textContent=e,s.style.cssText=`
|
|
70
|
+
font-size: 10px; font-family: "SF Mono", "Fira Code", ui-monospace, monospace;
|
|
71
|
+
color: rgba(255,255,255,0.22); letter-spacing: 0.03em;
|
|
72
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
73
|
+
`,o.appendChild(r),o.appendChild(s),n.appendChild(o),n.appendChild(Le(t)),n}function Bt(e,t,n){let o=p.config?.languages??["en"],r=p.activeLang||o[0],a=document.createElement("div");if(a.dataset.canciaPopup="1",at(a),a.appendChild(rt(e,n)),o.length>1){let d=document.createElement("div");d.style.cssText="display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.06);";let m=()=>{d.innerHTML="",o.forEach(y=>{let f=document.createElement("button");f.textContent=y.toUpperCase();let x=y===r;f.style.cssText=`
|
|
74
|
+
padding: 5px 10px 6px; border: none; border-bottom: 2px solid;
|
|
75
|
+
margin-bottom: -1px;
|
|
76
|
+
font-size: 11px; font-weight: 600; cursor: pointer; letter-spacing: 0.06em;
|
|
77
|
+
background: transparent;
|
|
78
|
+
border-bottom-color: ${x?L():"transparent"};
|
|
79
|
+
color: ${x?"#fff":"rgba(255,255,255,0.3)"};
|
|
80
|
+
transition: color 0.15s, border-color 0.15s;
|
|
81
|
+
`,f.addEventListener("mouseenter",()=>{x||(f.style.color="rgba(255,255,255,0.6)")}),f.addEventListener("mouseleave",()=>{x||(f.style.color="rgba(255,255,255,0.3)")}),f.addEventListener("click",()=>{let b=a.querySelector("textarea");if(b){let h=U(e,r),E=t.textContent?.trim()||"";b.value!==(h||E)&&G(e,r,b.value)}r=y,p.activeLang=y,oe(),m(),i()}),d.appendChild(f)})};m(),a.appendChild(d)}let s,c=()=>{let d=ot.get(s);d&&s.removeEventListener("input",d);let m=()=>{G(e,r,s.value),F(),t.textContent=s.value};ot.set(s,m),s.addEventListener("input",m)},i=(d=!1)=>{if(!d&&s){s.value=U(e,r)||t.textContent?.trim()||"",s.style.borderColor=`${L()}66`,s.style.background="rgba(255,255,255,0.05)",c();return}let m=a.querySelector("[data-cancia-footer]");s=document.createElement("textarea"),s.value=U(e,r)||t.textContent?.trim()||"",s.rows=4,s.placeholder="Enter text\u2026",s.style.cssText=`
|
|
82
|
+
width: 100%; box-sizing: border-box;
|
|
83
|
+
background: rgba(255,255,255,0.03); color: rgba(255,255,255,0.9);
|
|
84
|
+
border: 1px solid rgba(255,255,255,0.07); border-radius: 10px;
|
|
85
|
+
padding: 10px 12px;
|
|
86
|
+
font-size: 13px; font-family: inherit; resize: none; outline: none;
|
|
87
|
+
transition: border-color 0.18s, background 0.18s;
|
|
88
|
+
line-height: 1.55;
|
|
89
|
+
caret-color: ${L()};
|
|
90
|
+
`,s.addEventListener("focus",()=>{s.style.borderColor=`${L()}66`,s.style.background="rgba(255,255,255,0.05)"}),s.addEventListener("blur",()=>{s.style.borderColor="rgba(255,255,255,0.07)",s.style.background="rgba(255,255,255,0.03)"}),c(),m?a.insertBefore(s,m):a.appendChild(s),setTimeout(()=>s.focus(),80)};i(!0);let u=document.createElement("div");u.dataset.canciaFooter="1",u.style.cssText="display: flex; justify-content: flex-end; margin-top: 10px;";let l=Ce("Save",L());return l.dataset.canciaSave="1",l.title="Save (\u2318S)",l.addEventListener("click",()=>{let d=U(e,r),m=t.textContent?.trim()||"";s.value!==(d||m)&&G(e,r,s.value),F(),n()}),u.appendChild(l),a.appendChild(u),a}function Ft(e,t,n){let o=document.createElement("div");o.dataset.canciaPopup="1",at(o),o.appendChild(rt(e,n));let r=t.tagName==="IMG"?t.src:t.querySelector("img")?.src??"";if(r&&!r.startsWith("data:")){let f=document.createElement("div");f.style.cssText=`
|
|
91
|
+
border-radius: 10px; overflow: hidden; margin-bottom: 10px;
|
|
92
|
+
border: 1px solid rgba(255,255,255,0.06);
|
|
93
|
+
position: relative; height: 100px;
|
|
94
|
+
`;let x=document.createElement("img");x.src=r,x.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";let b=document.createElement("div");b.textContent="Current",b.style.cssText=`
|
|
95
|
+
position: absolute; bottom: 0; left: 0; right: 0;
|
|
96
|
+
font-size: 10px; color: rgba(255,255,255,0.45); letter-spacing: 0.04em;
|
|
97
|
+
padding: 16px 8px 6px;
|
|
98
|
+
background: linear-gradient(transparent, rgba(0,0,0,0.55));
|
|
99
|
+
`,f.appendChild(x),f.appendChild(b),o.appendChild(f)}let a=document.createElement("label");a.style.cssText=`
|
|
100
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
101
|
+
gap: 8px;
|
|
102
|
+
border: 1.5px dashed rgba(255,255,255,0.1); border-radius: 10px;
|
|
103
|
+
padding: 24px 20px;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
transition: border-color 0.18s, background 0.18s;
|
|
106
|
+
background: rgba(255,255,255,0.015);
|
|
107
|
+
`;let s=document.createElement("div");s.style.cssText="color: rgba(255,255,255,0.35); transition: color 0.18s;",s.innerHTML=`<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
108
|
+
<path d="M12 15V3m0 0L8 7m4-4l4 4M2 17l.621 2.485A2 2 0 004.561 21h14.878a2 2 0 001.94-1.515L22 17"/>
|
|
109
|
+
</svg>`;let c=document.createElement("div");c.style.cssText="text-align: center;",c.innerHTML=`
|
|
110
|
+
<div style="font-size:12px;font-weight:500;color:rgba(255,255,255,0.5);">Drop an image</div>
|
|
111
|
+
<div style="font-size:11px;color:rgba(255,255,255,0.25);margin-top:2px;">or click to browse</div>
|
|
112
|
+
`,a.appendChild(s),a.appendChild(c);let i=document.createElement("input");i.type="file",i.accept="image/*",i.style.display="none",a.appendChild(i);let u=document.createElement("div");u.style.cssText="margin-top: 8px; min-height: 18px;";let l=document.createElement("p");l.style.cssText="font-size: 11px; color: rgba(255,255,255,0.35); margin: 0; text-align: center; transition: color 0.2s;";let d=document.createElement("div");d.style.cssText=`
|
|
113
|
+
height: 2px; border-radius: 2px; background: rgba(255,255,255,0.05);
|
|
114
|
+
overflow: hidden; margin-top: 6px; display: none;
|
|
115
|
+
`;let m=document.createElement("div");m.style.cssText=`
|
|
116
|
+
height: 100%; border-radius: 2px; background: ${L()};
|
|
117
|
+
width: 0%; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
|
118
|
+
`,d.appendChild(m),u.appendChild(l),u.appendChild(d);let y=async f=>{if(!f.type.startsWith("image/")){l.textContent="Only image files are supported",l.style.color="#f87171";return}let x=10;if(f.size>x*1024*1024){l.textContent=`File too large (max ${x}MB)`,l.style.color="#f87171";return}a.style.borderColor=`${L()}55`,a.style.background=`${L()}0a`,s.style.color=L(),l.textContent="Uploading\u2026",l.style.color="rgba(255,255,255,0.45)",d.style.display="block",m.style.width="0%";try{let b=await re(f,h=>{m.style.width=`${h}%`});if(m.style.width="100%",G(e,p.activeLang,b),F(),t.tagName==="IMG"){let h=t;h.srcset="",h.src=b}else{let h=document.createElement("img");h.src=b,h.alt="",h.style.cssText="width:100%;height:100%;object-fit:cover;display:block;",h.dataset.cms=e,t.replaceWith(h)}setTimeout(()=>{l.textContent="Done",l.style.color="#4ade80",setTimeout(n,600)},200)}catch{d.style.display="none",l.textContent="Upload failed \u2014 try again",l.style.color="#f87171",a.style.borderColor="rgba(255,255,255,0.1)",a.style.background="rgba(255,255,255,0.015)",s.style.color="rgba(255,255,255,0.35)"}};return i.addEventListener("change",()=>{i.files?.[0]&&y(i.files[0])}),a.addEventListener("dragover",f=>{f.preventDefault(),q||(q=!0,a.style.borderColor=`${L()}88`,a.style.background=`${L()}0d`,s.style.color=L())}),a.addEventListener("dragleave",()=>{q=!1,a.style.borderColor="rgba(255,255,255,0.1)",a.style.background="rgba(255,255,255,0.015)",s.style.color="rgba(255,255,255,0.35)"}),a.addEventListener("drop",f=>{f.preventDefault(),q=!1,a.style.borderColor="rgba(255,255,255,0.1)",a.style.background="rgba(255,255,255,0.015)";let x=f.dataTransfer?.files[0];x&&y(x)}),a.addEventListener("mouseenter",()=>{q||(a.style.borderColor="rgba(255,255,255,0.18)",a.style.background="rgba(255,255,255,0.03)")}),a.addEventListener("mouseleave",()=>{q||(a.style.borderColor="rgba(255,255,255,0.1)",a.style.background="rgba(255,255,255,0.015)")}),o.appendChild(a),o.appendChild(u),o}function Le(e){let t=document.createElement("button");return t.style.cssText=`
|
|
119
|
+
display: flex; align-items: center; justify-content: center;
|
|
120
|
+
width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
|
|
121
|
+
background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
|
|
122
|
+
cursor: pointer; color: rgba(255,255,255,0.35); padding: 0;
|
|
123
|
+
transition: background 0.15s, color 0.15s;
|
|
124
|
+
`,t.innerHTML=`<svg width="9" height="9" viewBox="0 0 10 10" fill="none">
|
|
125
|
+
<path d="M1 1l8 8M9 1L1 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
126
|
+
</svg>`,t.addEventListener("mouseenter",()=>{t.style.background="rgba(255,255,255,0.08)",t.style.color="rgba(255,255,255,0.75)"}),t.addEventListener("mouseleave",()=>{t.style.background="rgba(255,255,255,0.04)",t.style.color="rgba(255,255,255,0.35)"}),t.addEventListener("click",e),t}function Ce(e,t){let n=document.createElement("button");return n.textContent=e,n.style.cssText=`
|
|
127
|
+
padding: 7px 16px; border-radius: 8px; border: none; cursor: pointer;
|
|
128
|
+
background: #fff; color: #0c0c0e;
|
|
129
|
+
font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
|
|
130
|
+
transition: opacity 0.15s, transform 0.1s cubic-bezier(0.2, 0, 0, 1);
|
|
131
|
+
`,n.addEventListener("mouseenter",()=>n.style.opacity="0.88"),n.addEventListener("mouseleave",()=>n.style.opacity="1"),n}function at(e){e.style.cssText=`
|
|
132
|
+
position: absolute;
|
|
133
|
+
z-index: 2147483646;
|
|
134
|
+
width: 320px;
|
|
135
|
+
background: rgba(14, 14, 16, 0.97);
|
|
136
|
+
backdrop-filter: blur(24px) saturate(180%);
|
|
137
|
+
-webkit-backdrop-filter: blur(24px) saturate(180%);
|
|
138
|
+
border: 1px solid rgba(255,255,255,0.07);
|
|
139
|
+
border-radius: 14px;
|
|
140
|
+
padding: 14px;
|
|
141
|
+
box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.5), 0 24px 64px rgba(0,0,0,0.4);
|
|
142
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
143
|
+
animation: cancia-popup-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
144
|
+
`}function it(e,t,n,o){$();let r=t==="image"?Ft(e,n,()=>{o(),$()}):Bt(e,n,()=>{o(),$()});document.body.appendChild(r),se=r;let{top:a,left:s,origin:c}=It(n);r.style.top=`${a}px`,r.style.left=`${s}px`,r.style.transformOrigin=c,V=i=>{r.contains(i.target)||($(),o())},setTimeout(()=>{V&&document.addEventListener("click",V,!0)},100),Z=i=>{i.key==="Escape"&&(i.preventDefault(),$(),o()),(i.metaKey||i.ctrlKey)&&i.key==="s"&&(i.preventDefault(),r.querySelector("[data-cancia-save]")?.click())},document.addEventListener("keydown",Z,!0)}function $(){if(V&&(document.removeEventListener("click",V,!0),V=null),Z&&(document.removeEventListener("keydown",Z,!0),Z=null),se){let e=se;se=null,e.style.animation="none",e.style.transition="opacity 0.18s cubic-bezier(0.4, 0, 1, 1), transform 0.18s cubic-bezier(0.4, 0, 1, 1)",e.style.opacity="0",e.style.transform="scale(0.96) translateY(3px)",setTimeout(()=>e.remove(),200)}}var At=2147483646,Ot=2147483646,z=null,le=null,st=!1,ce=null,de=null,pe=null,Me=null,Te=null,Se=null;function Rt(){if(st)return;st=!0;let e=document.createElement("style");e.textContent=`
|
|
145
|
+
@keyframes cancia-panel-in {
|
|
146
|
+
from { transform: translateX(100%); }
|
|
147
|
+
to { transform: translateX(0); }
|
|
148
|
+
}
|
|
149
|
+
@keyframes cancia-panel-out {
|
|
150
|
+
from { transform: translateX(0); }
|
|
151
|
+
to { transform: translateX(100%); }
|
|
152
|
+
}
|
|
153
|
+
@keyframes cancia-backdrop-in {
|
|
154
|
+
from { opacity: 0; }
|
|
155
|
+
to { opacity: 1; }
|
|
156
|
+
}
|
|
157
|
+
`,document.head.appendChild(e)}function Q(){return p.config?.accentColor??"#6366f1"}function H(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ut(e,t=120){if(typeof e!="string")return"";let n=e.trim();return n.length<=t?n:n.slice(0,t).trimEnd()+"\u2026"}function $e(){return p.config?.languages??[]}function Nt(e){let t=document.createElement("div");t.dataset.canciaListPanel="1",t.style.cssText=`
|
|
158
|
+
position: fixed;
|
|
159
|
+
top: 0; right: 0; bottom: 0;
|
|
160
|
+
width: min(420px, 100vw);
|
|
161
|
+
background: #fff;
|
|
162
|
+
color: #1a1a1d;
|
|
163
|
+
z-index: ${At};
|
|
164
|
+
box-shadow: -8px 0 32px rgba(0,0,0,0.18);
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
168
|
+
animation: cancia-panel-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
169
|
+
`,t.innerHTML=`
|
|
170
|
+
<header style="
|
|
171
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
172
|
+
padding: 16px 20px;
|
|
173
|
+
border-bottom: 1px solid #eaeaea;
|
|
174
|
+
">
|
|
175
|
+
<div>
|
|
176
|
+
<div style="font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #777;">List</div>
|
|
177
|
+
<div style="font-size: 17px; font-weight: 600; margin-top: 2px;">${H(e.label)}</div>
|
|
178
|
+
</div>
|
|
179
|
+
<button data-cancia-close style="
|
|
180
|
+
appearance: none; border: 0; background: transparent;
|
|
181
|
+
cursor: pointer; padding: 6px; border-radius: 6px;
|
|
182
|
+
color: #555; transition: background 0.12s, color 0.12s;
|
|
183
|
+
" aria-label="Close panel">
|
|
184
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
185
|
+
<path d="M4 4l10 10M14 4L4 14"/>
|
|
186
|
+
</svg>
|
|
187
|
+
</button>
|
|
188
|
+
</header>
|
|
189
|
+
<div data-cancia-tabs style="
|
|
190
|
+
display: flex; gap: 4px;
|
|
191
|
+
padding: 8px 16px 0;
|
|
192
|
+
border-bottom: 1px solid #f3f3f3;
|
|
193
|
+
overflow-x: auto;
|
|
194
|
+
"></div>
|
|
195
|
+
<div style="padding: 12px 20px; border-bottom: 1px solid #f3f3f3;">
|
|
196
|
+
<button data-cancia-add style="
|
|
197
|
+
appearance: none; border: 1px dashed ${Q()}; background: ${Q()}10;
|
|
198
|
+
color: ${Q()}; font-weight: 600; font-size: 13px;
|
|
199
|
+
padding: 10px 14px; border-radius: 8px; width: 100%; cursor: pointer;
|
|
200
|
+
display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
201
|
+
transition: background 0.12s;
|
|
202
|
+
">
|
|
203
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
204
|
+
<path d="M7 2v10M2 7h10"/>
|
|
205
|
+
</svg>
|
|
206
|
+
Add ${H(e.labelSingular.toLowerCase())}
|
|
207
|
+
</button>
|
|
208
|
+
</div>
|
|
209
|
+
<div data-cancia-entries style="
|
|
210
|
+
flex: 1; overflow-y: auto;
|
|
211
|
+
padding: 8px 12px 16px;
|
|
212
|
+
">
|
|
213
|
+
<div data-cancia-loading style="text-align: center; padding: 32px 12px; color: #888; font-size: 13px;">Loading\u2026</div>
|
|
214
|
+
</div>
|
|
215
|
+
`;let n=t.querySelector("[data-cancia-entries]"),o=t.querySelector("[data-cancia-tabs]");return{panel:t,body:n,tabsRow:o}}function Dt(e,t,n){e.innerHTML="";let o=$e();if(o.length<=1){e.style.display="none";return}e.style.display="flex";for(let r of o){let a=document.createElement("button"),s=r===t;a.style.cssText=`
|
|
216
|
+
appearance: none; border: 0; background: transparent;
|
|
217
|
+
font-family: inherit; font-size: 12px; font-weight: 600;
|
|
218
|
+
letter-spacing: 0.04em; text-transform: uppercase;
|
|
219
|
+
padding: 8px 10px 9px;
|
|
220
|
+
cursor: ${s?"default":"pointer"};
|
|
221
|
+
color: ${s?Q():"#777"};
|
|
222
|
+
border-bottom: 2px solid ${s?Q():"transparent"};
|
|
223
|
+
margin-bottom: -1px;
|
|
224
|
+
transition: color 0.12s, border-color 0.12s;
|
|
225
|
+
`,a.textContent=r,s||(a.addEventListener("mouseenter",()=>{a.style.color="#333"}),a.addEventListener("mouseleave",()=>{a.style.color="#777"}),a.addEventListener("click",()=>n(r))),e.appendChild(a)}}function jt(e,t,n,o,r,a){let s=new Map;for(let l of o)s.set(l.id,l);let c=o.map(l=>l.id),i=new Set(c);for(let l of r)i.has(l.id)||(c.push(l.id),i.add(l.id));let u=c.map(l=>{let d=s.get(l)??null,m=null;if(!d){let y=r.find(f=>f.id===l);y&&y.locales.length>0&&(m=y.locales[0])}return{id:l,locale:n,entry:d,translatedFrom:m}});if(u.length===0){e.innerHTML=`
|
|
226
|
+
<div style="text-align: center; padding: 40px 12px; color: #888; font-size: 13px;">
|
|
227
|
+
No entries yet. Click "Add ${H(t.labelSingular.toLowerCase())}" above to create one.
|
|
228
|
+
</div>
|
|
229
|
+
`;return}e.innerHTML="",u.forEach(l=>{let d=document.createElement("button"),m=l.entry===null;if(d.style.cssText=`
|
|
230
|
+
appearance: none; border: 1px solid transparent; background: ${m?"#fff8ee":"#fafafa"};
|
|
231
|
+
text-align: left; width: 100%;
|
|
232
|
+
padding: 12px 14px; border-radius: 8px; cursor: pointer;
|
|
233
|
+
margin-bottom: 6px;
|
|
234
|
+
transition: background 0.12s, border-color 0.12s, transform 0.12s;
|
|
235
|
+
display: block;
|
|
236
|
+
`,l.entry){let y=l.entry.data[t.titleField],f=typeof y=="string"&&y.trim().length>0?y:`(untitled ${t.labelSingular.toLowerCase()})`,x=t.bodyField?l.entry.data[t.bodyField]:void 0,b=Ut(x);d.innerHTML=`
|
|
237
|
+
<div style="font-weight: 600; font-size: 14px; color: #1a1a1d;">${H(f)}</div>
|
|
238
|
+
${b?`<div style="font-size: 12px; color: #666; margin-top: 4px; line-height: 1.4;">${H(b)}</div>`:""}
|
|
239
|
+
`,d.addEventListener("mouseenter",()=>{d.style.background="#f3f3f3",d.style.borderColor="#e3e3e3"}),d.addEventListener("mouseleave",()=>{d.style.background="#fafafa",d.style.borderColor="transparent"}),d.addEventListener("click",()=>Me?.(l.entry,n))}else{let y=l.translatedFrom,f=a.get(y)?.find(h=>h.id===l.id)??null,x=f?.data[t.titleField],b=typeof x=="string"&&x.trim().length>0?x:l.id;d.innerHTML=`
|
|
240
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
241
|
+
<span style="
|
|
242
|
+
font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
|
|
243
|
+
background: #f5b400; color: #fff;
|
|
244
|
+
padding: 2px 6px; border-radius: 4px;
|
|
245
|
+
">Not translated</span>
|
|
246
|
+
<span style="font-size: 11px; color: #888;">from ${H(y)}</span>
|
|
247
|
+
</div>
|
|
248
|
+
<div style="font-weight: 600; font-size: 14px; color: #6b5616; margin-top: 6px;">${H(b)}</div>
|
|
249
|
+
<div style="font-size: 11px; color: #b08800; margin-top: 4px;">Click to translate into ${H(n)}</div>
|
|
250
|
+
`,d.addEventListener("mouseenter",()=>{d.style.background="#fff2d5",d.style.borderColor="#f5d27a"}),d.addEventListener("mouseleave",()=>{d.style.background="#fff8ee",d.style.borderColor="transparent"}),d.addEventListener("click",()=>Se?.(l.id,f,n))}e.appendChild(d)})}async function lt(e){Y(),Rt();let t=document.createElement("div");t.dataset.canciaPanelBackdrop="1",t.style.cssText=`
|
|
251
|
+
position: fixed; inset: 0;
|
|
252
|
+
background: rgba(10,10,12,0.32);
|
|
253
|
+
z-index: ${Ot};
|
|
254
|
+
animation: cancia-backdrop-in 0.18s ease-out forwards;
|
|
255
|
+
`,t.addEventListener("click",()=>Y()),document.body.appendChild(t),le=t;let{panel:n,body:o,tabsRow:r}=Nt(e.schema);document.body.appendChild(n),z=n,ce=e.schema,de=o,pe=r,Me=e.onEditEntry,Te=e.onAddEntry,Se=e.onTranslateEntry;let a=$e(),s=e.initialLocale??p.activeLang??a[0]??"";p.activeListLocale=a.includes(s)?s:a[0]??s,n.querySelector("[data-cancia-close]")?.addEventListener("click",()=>Y()),n.querySelector("[data-cancia-add]")?.addEventListener("click",()=>Te?.(p.activeListLocale)),await K()}async function K(){if(!z||!ce||!de||!pe)return;let e=ce,t=de;Dt(pe,p.activeListLocale,async o=>{p.activeListLocale=o,await K()});try{let o=$e(),[r,...a]=await Promise.all([_e(e.name),...o.map(i=>je(e.name,i))]);if(!z)return;let s=new Map;o.forEach((i,u)=>s.set(i,a[u]??[]));let c=s.get(p.activeListLocale)??[];jt(t,e,p.activeListLocale,c,r,s)}catch(o){if(!z)return;t.innerHTML=`
|
|
256
|
+
<div style="text-align: center; padding: 32px 12px; color: #c0392b; font-size: 13px;">
|
|
257
|
+
Failed to load entries: ${H(o instanceof Error?o.message:String(o))}
|
|
258
|
+
</div>
|
|
259
|
+
`}}function Y(){if(z){z.style.animation="cancia-panel-out 0.18s cubic-bezier(0.7, 0, 0.84, 0) forwards";let e=z;setTimeout(()=>e.remove(),180),z=null}if(le){let e=le;e.style.opacity="0",e.style.transition="opacity 0.18s ease-out",setTimeout(()=>e.remove(),180),le=null}ce=null,de=null,pe=null,Me=null,Te=null,Se=null}function ct(){return z!==null}var _t=2147483647,qt=2147483646,X=null,ue=null,ee=null,dt=!1;function Vt(){if(dt)return;dt=!0;let e=document.createElement("style");e.textContent=`
|
|
260
|
+
@keyframes cancia-modal-in {
|
|
261
|
+
from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.985); }
|
|
262
|
+
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
263
|
+
}
|
|
264
|
+
@keyframes cancia-modal-out {
|
|
265
|
+
from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
266
|
+
to { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.985); }
|
|
267
|
+
}
|
|
268
|
+
.cancia-form-input:focus,
|
|
269
|
+
.cancia-form-textarea:focus,
|
|
270
|
+
.cancia-form-select:focus {
|
|
271
|
+
border-color: var(--cancia-accent-border, rgba(99,102,241,0.6));
|
|
272
|
+
background: rgba(255,255,255,0.05);
|
|
273
|
+
outline: none;
|
|
274
|
+
}
|
|
275
|
+
.cancia-form-input::placeholder,
|
|
276
|
+
.cancia-form-textarea::placeholder {
|
|
277
|
+
color: rgba(255,255,255,0.25);
|
|
278
|
+
}
|
|
279
|
+
.cancia-form-select option {
|
|
280
|
+
background: #15151a;
|
|
281
|
+
color: rgba(255,255,255,0.9);
|
|
282
|
+
}
|
|
283
|
+
.cancia-field-error {
|
|
284
|
+
color: #ff8786;
|
|
285
|
+
font-size: 11px;
|
|
286
|
+
margin-top: 5px;
|
|
287
|
+
line-height: 1.35;
|
|
288
|
+
}
|
|
289
|
+
`,document.head.appendChild(e)}function N(){return p.config?.accentColor??"#6366f1"}function Yt(){let e=N();return/^#[0-9a-f]{6}$/i.test(e)?`${e}99`:"rgba(99,102,241,0.6)"}function Kt(e){if(!e)return"";let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let n=o=>o.toString().padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Wt(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString()}var W=`
|
|
290
|
+
width: 100%; box-sizing: border-box;
|
|
291
|
+
background: rgba(255,255,255,0.03);
|
|
292
|
+
color: rgba(255,255,255,0.9);
|
|
293
|
+
border: 1px solid rgba(255,255,255,0.07);
|
|
294
|
+
border-radius: 8px;
|
|
295
|
+
padding: 8px 11px;
|
|
296
|
+
font-size: 13px;
|
|
297
|
+
font-family: inherit;
|
|
298
|
+
line-height: 1.5;
|
|
299
|
+
outline: none;
|
|
300
|
+
transition: border-color 0.18s, background 0.18s;
|
|
301
|
+
`;function Xt(e,t){let n=document.createElement("div");n.style.cssText="margin-bottom: 14px;";let o=document.createElement("label");o.style.cssText=`
|
|
302
|
+
display: flex; align-items: baseline; justify-content: space-between;
|
|
303
|
+
gap: 8px;
|
|
304
|
+
font-size: 11px; font-weight: 600;
|
|
305
|
+
color: rgba(255,255,255,0.75);
|
|
306
|
+
letter-spacing: 0.04em;
|
|
307
|
+
margin-bottom: 5px;
|
|
308
|
+
`;let r=document.createElement("span");if(r.textContent=e.label,e.required){let i=document.createElement("span");i.textContent=" *",i.style.color="rgba(255,135,134,0.8)",r.appendChild(i)}if(o.appendChild(r),n.appendChild(o),e.description){let i=document.createElement("div");i.style.cssText="font-size: 11px; color: rgba(255,255,255,0.35); margin-bottom: 6px; line-height: 1.4;",i.textContent=e.description,n.appendChild(i)}let a=document.createElement("div");a.className="cancia-field-error",a.style.display="none";let s=i=>{i?(a.textContent=i,a.style.display="block"):(a.textContent="",a.style.display="none")},c;switch(e.widget){case"textarea":{let i=document.createElement("textarea");i.className="cancia-form-textarea",i.style.cssText=`${W} resize: vertical; min-height: 110px; max-height: 320px; caret-color: ${N()};`,i.rows=5,e.placeholder&&(i.placeholder=e.placeholder),typeof t=="string"&&(i.value=t),n.appendChild(i),c=()=>i.value;break}case"checkbox":{let i=document.createElement("label");i.style.cssText="display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding: 6px 0;";let u=document.createElement("input");u.type="checkbox",u.style.cssText=`width: 16px; height: 16px; accent-color: ${N()};`,t===!0&&(u.checked=!0);let l=document.createElement("span");l.style.cssText="font-size: 13px; color: rgba(255,255,255,0.7);",l.textContent=e.placeholder??`Enable ${e.label.toLowerCase()}`,i.appendChild(u),i.appendChild(l),n.appendChild(i),c=()=>u.checked;break}case"select":{let i=document.createElement("select");if(i.className="cancia-form-select",i.style.cssText=`${W} appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2.5 3.75l2.5 2.5 2.5-2.5' stroke='rgba(255,255,255,0.4)' stroke-width='1.3' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer;`,!e.required){let u=document.createElement("option");u.value="",u.textContent="\u2014",i.appendChild(u)}for(let u of e.options??[]){let l=document.createElement("option");l.value=u,l.textContent=u,t===u&&(l.selected=!0),i.appendChild(l)}n.appendChild(i),c=()=>i.value===""?void 0:i.value;break}case"image":{let i=typeof t=="string"?t:"",u=i,l=document.createElement("div");l.style.cssText=`
|
|
309
|
+
display: flex; gap: 10px; align-items: stretch;
|
|
310
|
+
background: rgba(255,255,255,0.02);
|
|
311
|
+
border: 1px dashed rgba(255,255,255,0.1);
|
|
312
|
+
border-radius: 10px;
|
|
313
|
+
padding: 10px;
|
|
314
|
+
`;let d=document.createElement("div");d.style.cssText=`
|
|
315
|
+
width: 72px; height: 72px; flex-shrink: 0;
|
|
316
|
+
background: rgba(255,255,255,0.04) no-repeat center / cover;
|
|
317
|
+
border: 1px solid rgba(255,255,255,0.06);
|
|
318
|
+
border-radius: 6px;
|
|
319
|
+
display: flex; align-items: center; justify-content: center;
|
|
320
|
+
color: rgba(255,255,255,0.25);
|
|
321
|
+
`;let m=w=>{w?(d.style.backgroundImage=`url("${w.replace(/"/g,'\\"')}")`,d.innerHTML=""):(d.style.backgroundImage="",d.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>')};m(i);let y=document.createElement("div");y.style.cssText="flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px;";let f=document.createElement("input");f.type="file",f.accept="image/*",f.style.display="none";let x=document.createElement("div");x.style.cssText="display: flex; gap: 6px;";let b=document.createElement("button");b.type="button",b.style.cssText=`
|
|
322
|
+
appearance: none; cursor: pointer;
|
|
323
|
+
background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85);
|
|
324
|
+
border: 1px solid rgba(255,255,255,0.07);
|
|
325
|
+
font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
|
|
326
|
+
padding: 5px 10px; border-radius: 6px;
|
|
327
|
+
transition: background 0.15s;
|
|
328
|
+
`,b.textContent="Upload\u2026",b.addEventListener("mouseenter",()=>{b.style.background="rgba(255,255,255,0.1)"}),b.addEventListener("mouseleave",()=>{b.style.background="rgba(255,255,255,0.06)"}),b.addEventListener("click",()=>f.click());let h=document.createElement("button");h.type="button",h.style.cssText=`
|
|
329
|
+
appearance: none; cursor: pointer;
|
|
330
|
+
background: transparent; color: rgba(255,255,255,0.4);
|
|
331
|
+
border: 1px solid transparent;
|
|
332
|
+
font-size: 11px;
|
|
333
|
+
padding: 5px 8px; border-radius: 6px;
|
|
334
|
+
`,h.textContent="Clear",h.addEventListener("click",()=>{u="",E.value="",m("")}),x.appendChild(b),x.appendChild(h);let E=document.createElement("input");E.type="url",E.className="cancia-form-input",E.style.cssText=`${W} font-size: 11px; padding: 6px 9px;`,E.placeholder="https://\u2026 or upload",E.value=i,E.addEventListener("input",()=>{u=E.value.trim(),m(u)});let v=document.createElement("div");v.style.cssText="font-size: 10px; color: rgba(255,255,255,0.5); height: 12px;",y.appendChild(x),y.appendChild(E),y.appendChild(v),l.appendChild(d),l.appendChild(y),l.appendChild(f),n.appendChild(l),f.addEventListener("change",async()=>{let w=f.files?.[0];if(w){b.disabled=!0,v.style.color="rgba(255,255,255,0.5)";try{let g=await re(w,C=>{v.textContent=`Uploading\u2026 ${C}%`});u=g,E.value=g,m(g),v.textContent="Uploaded",setTimeout(()=>{v.textContent=""},1500)}catch(g){v.textContent=`Upload failed: ${g instanceof Error?g.message:String(g)}`,v.style.color="#ff8786"}finally{b.disabled=!1,f.value=""}}}),c=()=>u===""?void 0:u;break}case"datetime":{let i=document.createElement("input");i.type="datetime-local",i.className="cancia-form-input",i.style.cssText=`${W} color-scheme: dark; caret-color: ${N()};`,typeof t=="string"&&(i.value=Kt(t)),n.appendChild(i),c=()=>{let u=i.value.trim();if(u)return Wt(u)};break}case"number":{let i=document.createElement("input");i.type="number",i.className="cancia-form-input",i.style.cssText=`${W} caret-color: ${N()};`,e.min!==void 0&&(i.min=String(e.min)),e.max!==void 0&&(i.max=String(e.max)),typeof t=="number"?i.value=String(t):typeof t=="string"&&t!==""&&(i.value=t),n.appendChild(i),c=()=>{let u=i.value.trim();if(u==="")return;let l=Number(u);return Number.isNaN(l)?void 0:l};break}default:{let i=document.createElement("input");i.type=e.widget==="url"?"url":e.widget==="email"?"email":"text",i.className="cancia-form-input",i.style.cssText=`${W} caret-color: ${N()};`,e.placeholder&&(i.placeholder=e.placeholder),e.minLength!==void 0&&(i.minLength=e.minLength),e.maxLength!==void 0&&(i.maxLength=e.maxLength),typeof t=="string"&&(i.value=t),n.appendChild(i),c=()=>i.value;break}}return n.appendChild(a),{wrapper:n,fieldState:{field:e,getValue:c,setError:s}}}function Jt(e){let t={},n=!0;for(let o of e){let r=o.getValue();if(o.setError(null),o.field.required&&(r===void 0||r===""||r===null)){o.setError(`${o.field.label} is required`),n=!1;continue}if(typeof r=="string"){if(o.field.minLength!==void 0&&r.length<o.field.minLength){o.setError(`Must be at least ${o.field.minLength} character${o.field.minLength===1?"":"s"}`),n=!1;continue}if(o.field.maxLength!==void 0&&r.length>o.field.maxLength){o.setError(`Must be at most ${o.field.maxLength} characters`),n=!1;continue}}r!==void 0&&r!==""&&(t[o.field.name]=r)}return{data:t,ok:n}}function fe(e){P(),Vt();let t=e.entry!==null,n=!t&&(e.translateFromEntry??null)!==null;document.documentElement.style.setProperty("--cancia-accent-border",Yt());let o=document.createElement("div");o.dataset.canciaModalBackdrop="1",o.style.cssText=`
|
|
335
|
+
position: fixed; inset: 0;
|
|
336
|
+
background: rgba(8,8,10,0.55);
|
|
337
|
+
backdrop-filter: blur(3px);
|
|
338
|
+
-webkit-backdrop-filter: blur(3px);
|
|
339
|
+
z-index: ${qt};
|
|
340
|
+
opacity: 0;
|
|
341
|
+
transition: opacity 0.2s ease-out;
|
|
342
|
+
`,document.body.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1"}),ue=o;let r=document.createElement("div");r.dataset.canciaModal="1",r.style.cssText=`
|
|
343
|
+
position: fixed;
|
|
344
|
+
top: 50%; left: 50%;
|
|
345
|
+
transform: translate(-50%, -50%);
|
|
346
|
+
width: min(480px, calc(100vw - 32px));
|
|
347
|
+
max-height: min(680px, calc(100vh - 48px));
|
|
348
|
+
display: flex; flex-direction: column;
|
|
349
|
+
background: rgba(14, 14, 16, 0.97);
|
|
350
|
+
backdrop-filter: blur(24px) saturate(180%);
|
|
351
|
+
-webkit-backdrop-filter: blur(24px) saturate(180%);
|
|
352
|
+
border: 1px solid rgba(255,255,255,0.07);
|
|
353
|
+
border-radius: 14px;
|
|
354
|
+
box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.5), 0 24px 64px rgba(0,0,0,0.4);
|
|
355
|
+
z-index: ${_t};
|
|
356
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
357
|
+
color: rgba(255,255,255,0.9);
|
|
358
|
+
animation: cancia-modal-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
`,document.body.appendChild(r),X=r;let a=document.createElement("div");a.style.cssText=`
|
|
361
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
362
|
+
padding: 14px 16px 12px;
|
|
363
|
+
border-bottom: 1px solid rgba(255,255,255,0.06);
|
|
364
|
+
flex-shrink: 0;
|
|
365
|
+
`;let s=document.createElement("div");s.style.cssText="display: flex; flex-direction: column; gap: 2px; min-width: 0;";let c=document.createElement("span");c.style.cssText=`
|
|
366
|
+
font-size: 10px; font-weight: 600;
|
|
367
|
+
color: rgba(255,255,255,0.32);
|
|
368
|
+
letter-spacing: 0.08em; text-transform: uppercase;
|
|
369
|
+
`;let i=t?"Edit":n?"Translate":"New";c.textContent=`${i} ${e.schema.labelSingular.toLowerCase()} \xB7 ${e.locale}`;let u=document.createElement("span");u.style.cssText=`
|
|
370
|
+
font-size: 14px; font-weight: 600;
|
|
371
|
+
color: rgba(255,255,255,0.92);
|
|
372
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
373
|
+
`,u.textContent=e.schema.label,s.appendChild(c),s.appendChild(u),a.appendChild(s),a.appendChild(Le(()=>P())),r.appendChild(a);let l=document.createElement("div");l.style.cssText=`
|
|
374
|
+
padding: 14px 16px 4px;
|
|
375
|
+
overflow-y: auto;
|
|
376
|
+
flex: 1 1 auto;
|
|
377
|
+
min-height: 0;
|
|
378
|
+
`,r.appendChild(l);let d=document.createElement("div");d.style.cssText=`
|
|
379
|
+
display: none;
|
|
380
|
+
background: rgba(255,135,134,0.08);
|
|
381
|
+
color: #ff8786;
|
|
382
|
+
border: 1px solid rgba(255,135,134,0.18);
|
|
383
|
+
border-radius: 8px;
|
|
384
|
+
padding: 9px 11px;
|
|
385
|
+
font-size: 12px;
|
|
386
|
+
line-height: 1.4;
|
|
387
|
+
margin-bottom: 12px;
|
|
388
|
+
`,l.appendChild(d);function m(g){d.textContent=g,d.style.display="block"}function y(){d.textContent="",d.style.display="none"}if(n){let g=document.createElement("div");g.style.cssText=`
|
|
389
|
+
background: rgba(245,180,0,0.1);
|
|
390
|
+
color: #f5b400;
|
|
391
|
+
border: 1px solid rgba(245,180,0,0.25);
|
|
392
|
+
border-radius: 8px;
|
|
393
|
+
padding: 9px 11px;
|
|
394
|
+
font-size: 12px;
|
|
395
|
+
line-height: 1.4;
|
|
396
|
+
margin-bottom: 12px;
|
|
397
|
+
`;let C=e.translateFromEntry;g.textContent=`Translating from ${C.locale} into ${e.locale}. Fields are pre-filled from the source.`,l.appendChild(g)}let f=[],x=e.entry??e.translateFromEntry??null;for(let g of e.schema.fields){let C=x?.data[g.name],{wrapper:ge,fieldState:O}=Xt(g,C);l.appendChild(ge),f.push(O)}let b=document.createElement("div");b.style.cssText=`
|
|
398
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
399
|
+
gap: 10px;
|
|
400
|
+
padding: 12px 16px;
|
|
401
|
+
border-top: 1px solid rgba(255,255,255,0.06);
|
|
402
|
+
background: rgba(0,0,0,0.18);
|
|
403
|
+
flex-shrink: 0;
|
|
404
|
+
`;let h=document.createElement("div"),E=document.createElement("div");if(E.style.cssText="display: flex; gap: 8px;",t){let g=document.createElement("button");g.type="button",g.style.cssText=`
|
|
405
|
+
appearance: none; cursor: pointer;
|
|
406
|
+
background: transparent; border: 1px solid transparent;
|
|
407
|
+
color: #ff8786;
|
|
408
|
+
font-size: 12px; font-weight: 500;
|
|
409
|
+
padding: 6px 10px; border-radius: 7px;
|
|
410
|
+
transition: background 0.15s;
|
|
411
|
+
`,g.textContent="Delete",g.addEventListener("mouseenter",()=>{g.style.background="rgba(255,135,134,0.08)"}),g.addEventListener("mouseleave",()=>{g.style.background="transparent"}),g.addEventListener("click",async()=>{if(confirm(`Delete the ${e.locale} version of this ${e.schema.labelSingular.toLowerCase()}? This can't be undone.`)){g.disabled=!0;try{await Ye(e.schema.name,e.entry.id,e.locale),e.onSaved(),P()}catch(C){m(C instanceof Error?C.message:String(C)),g.disabled=!1}}}),h.appendChild(g)}let v=document.createElement("button");v.type="button",v.style.cssText=`
|
|
412
|
+
appearance: none; cursor: pointer;
|
|
413
|
+
background: rgba(255,255,255,0.04);
|
|
414
|
+
border: 1px solid rgba(255,255,255,0.07);
|
|
415
|
+
color: rgba(255,255,255,0.75);
|
|
416
|
+
font-size: 12px; font-weight: 500;
|
|
417
|
+
padding: 7px 14px; border-radius: 8px;
|
|
418
|
+
transition: background 0.15s, color 0.15s;
|
|
419
|
+
`,v.textContent="Cancel",v.addEventListener("mouseenter",()=>{v.style.background="rgba(255,255,255,0.08)",v.style.color="rgba(255,255,255,0.9)"}),v.addEventListener("mouseleave",()=>{v.style.background="rgba(255,255,255,0.04)",v.style.color="rgba(255,255,255,0.75)"}),v.addEventListener("click",()=>P());let w=Ce(t?"Save":"Create",N());w.addEventListener("click",async()=>{y();let{data:g,ok:C}=Jt(f);if(!C)return;w.disabled=!0,w.style.opacity="0.6";let ge=w.textContent;w.textContent=t?"Saving\u2026":"Creating\u2026";try{if(t)await Ve(e.schema.name,e.entry.id,g,e.entry._rev,e.locale);else{let O;if(e.fixedId)O=e.fixedId;else{let R=e.schema.slugField;O=R&&typeof g[R]=="string"?g[R]:void 0}await qe(e.schema.name,g,e.locale,O)}e.onSaved(),P()}catch(O){let R=O;R.message.includes("Validation failed")?m("Server-side validation failed. Check the fields above."):R.code==="REV_CONFLICT"?m("This entry was changed by someone else. Close and reopen to see the latest version."):m(R.message),w.disabled=!1,w.style.opacity="1",w.textContent=ge??(t?"Save":"Create")}}),E.appendChild(v),E.appendChild(w),b.appendChild(h),b.appendChild(E),r.appendChild(b),o.addEventListener("click",()=>P()),ee=g=>{g.key==="Escape"&&(g.stopPropagation(),P())},document.addEventListener("keydown",ee,!0),setTimeout(()=>{l.querySelector("input, textarea, select")?.focus()},90)}function P(){if(X){X.style.animation="cancia-modal-out 0.16s cubic-bezier(0.7, 0, 0.84, 0) forwards";let e=X;setTimeout(()=>e.remove(),160),X=null}if(ue){let e=ue;e.style.opacity="0",setTimeout(()=>e.remove(),180),ue=null}ee&&(document.removeEventListener("keydown",ee,!0),ee=null)}function pt(){return X!==null}var D=null,k=null,A=!1,te=null;function He(){return p.config?.accentColor??"#6366f1"}var ut=!1;function Gt(){if(ut)return;ut=!0;let e=document.createElement("style");e.textContent=`
|
|
420
|
+
@keyframes cancia-enter {
|
|
421
|
+
from { opacity: 0; transform: scale(0.5) rotate(90deg); }
|
|
422
|
+
to { opacity: 1; transform: scale(1) rotate(0deg); }
|
|
423
|
+
}
|
|
424
|
+
@keyframes cancia-exit {
|
|
425
|
+
from { opacity: 1; transform: scale(1); }
|
|
426
|
+
to { opacity: 0; transform: scale(0.8); }
|
|
427
|
+
}
|
|
428
|
+
@keyframes cancia-controls-in {
|
|
429
|
+
from { opacity: 0; filter: blur(8px); transform: scale(0.6); }
|
|
430
|
+
to { opacity: 1; filter: blur(0px); transform: scale(1); }
|
|
431
|
+
}
|
|
432
|
+
@keyframes cancia-controls-out {
|
|
433
|
+
from { opacity: 1; filter: blur(0px); transform: scale(1); }
|
|
434
|
+
to { opacity: 0; filter: blur(6px); transform: scale(0.5); }
|
|
435
|
+
}
|
|
436
|
+
@keyframes cancia-fade-in {
|
|
437
|
+
from { opacity: 0; transform: scale(0.94) translateY(5px); }
|
|
438
|
+
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
439
|
+
}
|
|
440
|
+
@keyframes cancia-popup-in {
|
|
441
|
+
from { opacity: 0; transform: scale(0.93); }
|
|
442
|
+
to { opacity: 1; transform: scale(1); }
|
|
443
|
+
}
|
|
444
|
+
@keyframes cancia-badge-pop {
|
|
445
|
+
0% { transform: scale(0); }
|
|
446
|
+
60% { transform: scale(1.25); }
|
|
447
|
+
100% { transform: scale(1); }
|
|
448
|
+
}
|
|
449
|
+
@keyframes cancia-icon-slide-in {
|
|
450
|
+
from { transform: translateY(-150%); }
|
|
451
|
+
to { transform: translateY(0); }
|
|
452
|
+
}
|
|
453
|
+
@keyframes cancia-tooltip-in {
|
|
454
|
+
from { opacity: 0; transform: translateX(-50%) translateY(4px); }
|
|
455
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
456
|
+
}
|
|
457
|
+
[data-cancia-toolbar] * { box-sizing: border-box; }
|
|
458
|
+
[data-cancia-toolbar] button:active:not(:disabled) { transform: scale(0.92) !important; }
|
|
459
|
+
[data-cancia-popup] * { box-sizing: border-box; }
|
|
460
|
+
[data-cancia-popup] button:active:not(:disabled) { transform: scale(0.94) !important; }
|
|
461
|
+
/* Protect stroke-based icons from host page "svg { fill: currentColor }" rules */
|
|
462
|
+
[data-cancia-toolbar] svg[fill="none"] { fill: none !important; }
|
|
463
|
+
[data-cancia-toolbar] svg[fill="none"] :not([fill]) { fill: none !important; }
|
|
464
|
+
[data-cancia-popup] svg[fill="none"] { fill: none !important; }
|
|
465
|
+
[data-cancia-popup] svg[fill="none"] :not([fill]) { fill: none !important; }
|
|
466
|
+
/* Reset cosmetic host CSS leaking into toolbar buttons */
|
|
467
|
+
[data-cancia-toolbar] :where(button) {
|
|
468
|
+
background: unset; border: unset; border-radius: unset; padding: unset;
|
|
469
|
+
margin: unset; color: unset; font-family: unset; font-weight: unset;
|
|
470
|
+
font-size: unset; line-height: unset; letter-spacing: unset;
|
|
471
|
+
box-shadow: unset; outline: unset; text-transform: unset;
|
|
472
|
+
}
|
|
473
|
+
`,document.head.appendChild(e)}var I=null,J=null,j=null,ze=!1;function Zt(){return I||(I=document.createElement("div"),I.style.cssText=`
|
|
474
|
+
position: fixed;
|
|
475
|
+
pointer-events: none;
|
|
476
|
+
z-index: 2147483646;
|
|
477
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
478
|
+
font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
|
|
479
|
+
color: #fff;
|
|
480
|
+
background: rgba(10,10,12,0.92);
|
|
481
|
+
backdrop-filter: blur(8px);
|
|
482
|
+
-webkit-backdrop-filter: blur(8px);
|
|
483
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
484
|
+
padding: 4px 8px; border-radius: 6px;
|
|
485
|
+
white-space: nowrap;
|
|
486
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
487
|
+
display: none;
|
|
488
|
+
`,document.body.appendChild(I)),I}function Qt(e,t){J&&(clearTimeout(J),J=null),j&&(clearTimeout(j),j=null);let n=()=>{ze=!0;let o=Zt();o.textContent=t,o.style.display="block",o.style.animation="cancia-tooltip-in 0.12s cubic-bezier(0.16,1,0.3,1) both";let r=e.getBoundingClientRect(),a=26,s=8;o.style.top=`${r.top-a-s}px`,o.style.left=`${r.left+r.width/2}px`};ze?n():j=setTimeout(n,400)}function Pe(){j&&(clearTimeout(j),j=null),J&&clearTimeout(J),J=setTimeout(()=>{ze=!1,I&&(I.style.display="none")},80)}function en(){Gt();let e=document.createElement("div");e.dataset.canciaToolbar="1",e.style.cssText=`
|
|
489
|
+
position: fixed;
|
|
490
|
+
bottom: 24px;
|
|
491
|
+
right: 24px;
|
|
492
|
+
z-index: 2147483647;
|
|
493
|
+
width: 44px;
|
|
494
|
+
height: 44px;
|
|
495
|
+
border-radius: 22px;
|
|
496
|
+
background: rgba(12, 12, 14, 0.92);
|
|
497
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
498
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
499
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
500
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
|
|
501
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
502
|
+
font-size: 13px;
|
|
503
|
+
color: #f0f0f0;
|
|
504
|
+
user-select: none;
|
|
505
|
+
cursor: pointer;
|
|
506
|
+
overflow: hidden;
|
|
507
|
+
display: flex;
|
|
508
|
+
align-items: center;
|
|
509
|
+
justify-content: center;
|
|
510
|
+
transition: width 0.45s cubic-bezier(0.19, 1, 0.22, 1), border-radius 0.45s cubic-bezier(0.19, 1, 0.22, 1);
|
|
511
|
+
animation: cancia-enter 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) both;
|
|
512
|
+
`;let t=document.createElement("div");t.style.cssText=`
|
|
513
|
+
position: absolute;
|
|
514
|
+
display: flex; align-items: center; justify-content: center;
|
|
515
|
+
color: rgba(255,255,255,0.7);
|
|
516
|
+
transition: opacity 0.15s, transform 0.15s cubic-bezier(0.2,0,0,1);
|
|
517
|
+
pointer-events: none;
|
|
518
|
+
`,t.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
519
|
+
<path d="M12 20h9"/>
|
|
520
|
+
<path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/>
|
|
521
|
+
</svg>`;let n=document.createElement("div");n.style.cssText=`
|
|
522
|
+
display: flex;
|
|
523
|
+
align-items: center;
|
|
524
|
+
gap: 0.375rem;
|
|
525
|
+
padding: 5px;
|
|
526
|
+
white-space: nowrap;
|
|
527
|
+
opacity: 0;
|
|
528
|
+
pointer-events: none;
|
|
529
|
+
transform-origin: right center;
|
|
530
|
+
`;let o=!1,r=me(`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
531
|
+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
|
|
532
|
+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
|
|
533
|
+
</svg>`,"Edit",()=>l());n.appendChild(r);let a=p.config?.hasDeployHook??!0,s=me(`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
534
|
+
<path d="M22 2L11 13"/>
|
|
535
|
+
<path d="M22 2L15 22l-4-9-9-4 20-7z"/>
|
|
536
|
+
</svg>`,a?"Publish":"Publish (no deploy hook configured)",()=>on(s));a||(s.disabled=!0,s.style.opacity="0.3",s.style.cursor="not-allowed"),n.appendChild(s);let c=me(`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
537
|
+
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
|
|
538
|
+
<path d="M16 17l5-5-5-5"/>
|
|
539
|
+
<path d="M21 12H9"/>
|
|
540
|
+
</svg>`,"Log out",()=>p.onLogout?.());n.appendChild(c),n.appendChild(rn());let i=me(`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round">
|
|
541
|
+
<path d="M6 6l12 12M18 6L6 18"/>
|
|
542
|
+
</svg>`,"Close",()=>gt(e,t,n));n.appendChild(i),e.appendChild(t),e.appendChild(n),e.addEventListener("click",()=>{A||tn(e,t,n)}),e.addEventListener("mouseenter",()=>{A||(e.style.background="rgba(24, 24, 28, 0.96)")}),e.addEventListener("mouseleave",()=>{e.style.background="rgba(12, 12, 14, 0.92)"}),F(()=>{let d=p.pending.size;d>0?an(d):Ie()});let u=null;function l(){o=!o,p.editMode=o;let d=r.querySelector("svg");o?(r.style.background=`${He()}22`,r.style.color=He(),d&&(d.style.stroke=He()),r.dataset.canciaTooltip="Stop editing (Esc)",nt(m=>{if(m.kind==="field"){it(m.key,m.fieldType,m.el,()=>{});return}let y=p.schemas[m.listName];if(!y){console.warn(`[cancia] No schema found for list "${m.listName}". Define it in src/cms/schemas.ts.`);return}lt({schema:y,onAddEntry:f=>{fe({schema:y,locale:f,entry:null,onSaved:()=>{K()}})},onEditEntry:(f,x)=>{fe({schema:y,locale:x,entry:f,onSaved:()=>{K()}})},onTranslateEntry:(f,x,b)=>{fe({schema:y,locale:b,entry:null,translateFromEntry:x,fixedId:f,onSaved:()=>{K()}})}})}),u=m=>{if(m.key==="Escape"&&!pt()){if(ct()){Y();return}document.querySelector("[data-cancia-popup]")||l()}},document.addEventListener("keydown",u,!0)):(r.style.background="transparent",r.style.color="rgba(255,255,255,0.85)",d&&(d.style.stroke=""),r.dataset.canciaTooltip="Edit",we(),$(),P(),Y(),u&&(document.removeEventListener("keydown",u,!0),u=null))}return e}function tn(e,t,n){A||(A=!0,te=o=>{o.key==="Escape"&&!document.querySelector("[data-cancia-popup]")&&!p.editMode&>(e,t,n)},document.addEventListener("keydown",te,!0),n.style.visibility="hidden",n.style.opacity="0",n.style.pointerEvents="none",e.style.width="max-content",e.style.borderRadius="100px",requestAnimationFrame(()=>{let o=e.scrollWidth;e.style.width="44px",n.style.visibility="",requestAnimationFrame(()=>{e.style.width=`${o}px`,e.style.borderRadius="100px",e.style.cursor="default",t.style.opacity="0",t.style.transform="scale(0.5) rotate(-90deg)",setTimeout(()=>{n.style.pointerEvents="auto",n.style.animation="cancia-controls-in 0.4s cubic-bezier(0.19, 1, 0.22, 1) both",n.style.opacity="1"},80)})}))}function gt(e,t,n){A&&(A=!1,Pe(),te&&(document.removeEventListener("keydown",te,!0),te=null),n.style.pointerEvents="none",n.style.animation="cancia-controls-out 0.15s cubic-bezier(0.4, 0, 1, 1) both",setTimeout(()=>{n.style.opacity="0",e.style.width="44px",e.style.borderRadius="22px",e.style.cursor="pointer",t.style.opacity="1",t.style.transform="scale(1) rotate(0deg)"},100))}async function nn(e){e&&(e.disabled=!0,e.style.opacity="0.5");try{await be(),mt("Saved","success")}catch(t){if(console.error(t),Ue(t)){ne();return}e&&(e.disabled=!1,e.style.opacity="1"),mt("Save failed","error")}}async function on(e){e.disabled=!0,e.style.opacity="0.5";try{p.pending.size>0&&await be(),await Ne(),ft("Published!","success")}catch(t){console.error(t),ft("Publish failed","error")}finally{e.disabled=!1,e.style.opacity="1"}}function ft(e,t){let n=document.createElement("div"),o=t==="success"?"#4ade80":"#f87171";n.style.cssText=`
|
|
543
|
+
position: fixed; bottom: 80px; right: 24px; z-index: 2147483647;
|
|
544
|
+
display: flex; align-items: center; gap: 8px;
|
|
545
|
+
background: rgba(12, 12, 14, 0.95);
|
|
546
|
+
backdrop-filter: blur(16px);
|
|
547
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
548
|
+
border-radius: 10px; padding: 10px 14px;
|
|
549
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
550
|
+
font-size: 13px; font-weight: 500; color: #f0f0f0;
|
|
551
|
+
box-shadow: 0 4px 24px rgba(0,0,0,0.4);
|
|
552
|
+
pointer-events: none;
|
|
553
|
+
animation: cancia-fade-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
554
|
+
`;let r=document.createElement("span");r.style.cssText=`width: 7px; height: 7px; border-radius: 50%; background: ${o}; flex-shrink: 0;`;let a=document.createElement("span");a.textContent=e,n.appendChild(r),n.appendChild(a),document.body.appendChild(n),setTimeout(()=>{n.style.transition="opacity 0.25s cubic-bezier(0.4,0,1,1), transform 0.25s cubic-bezier(0.4,0,1,1)",n.style.opacity="0",n.style.transform="translateY(4px)",setTimeout(()=>n.remove(),300)},2e3)}function me(e,t,n){let o=document.createElement("button");o.style.cssText=`
|
|
555
|
+
display: flex; align-items: center; justify-content: center;
|
|
556
|
+
width: 34px; height: 34px; border-radius: 50%;
|
|
557
|
+
border: none; background: transparent;
|
|
558
|
+
cursor: pointer; color: rgba(255,255,255,0.85); flex-shrink: 0; padding: 0;
|
|
559
|
+
transition: color 0.15s, background 0.15s, transform 0.1s cubic-bezier(0.2,0,0,1);
|
|
560
|
+
`,o.innerHTML=e;let r=o.querySelector("svg");return r&&(r.style.cssText="display:block;flex-shrink:0;overflow:visible;margin:auto;",r.setAttribute("stroke-width","1.5")),o.dataset.canciaTooltip=t,o.addEventListener("mouseenter",()=>{o.disabled||(o.style.background="rgba(255,255,255,0.1)",Qt(o,o.dataset.canciaTooltip??t))}),o.addEventListener("mouseleave",()=>{let a=p.config?.accentColor??"#6366f1";o.style.background.includes(a.slice(1,7))||(o.style.background="transparent"),Pe()}),o.addEventListener("click",a=>{a.stopPropagation(),Pe(),n()}),o}function rn(){let e=document.createElement("span");return e.style.cssText="width: 1px; height: 14px; background: rgba(255,255,255,0.08); flex-shrink: 0; margin: 0 1px;",e}function an(e){if(!k){k=document.createElement("div"),k.style.cssText=`
|
|
561
|
+
position: fixed;
|
|
562
|
+
bottom: 80px;
|
|
563
|
+
right: 24px;
|
|
564
|
+
z-index: 2147483646;
|
|
565
|
+
display: flex;
|
|
566
|
+
align-items: center;
|
|
567
|
+
justify-content: space-between;
|
|
568
|
+
gap: 12px;
|
|
569
|
+
background: rgba(12, 12, 14, 0.92);
|
|
570
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
571
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
572
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
573
|
+
border-radius: 12px;
|
|
574
|
+
padding: 0;
|
|
575
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 8px 32px rgba(0,0,0,0.4);
|
|
576
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
577
|
+
animation: cancia-fade-in 0.25s cubic-bezier(0.16,1,0.3,1) both;
|
|
578
|
+
width: max-content;
|
|
579
|
+
overflow: hidden;
|
|
580
|
+
`;let n=document.createElement("span");n.dataset.canciaPendingLabel="1",n.style.cssText="font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";let o=document.createElement("button");o.dataset.canciaSaveBtn="1",o.title="Save changes",o.style.cssText=`
|
|
581
|
+
padding: 5px 10px; border-radius: 7px; border: none; cursor: pointer;
|
|
582
|
+
background: #fff; color: #0c0c0e;
|
|
583
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
584
|
+
font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
|
|
585
|
+
transition: opacity 0.15s, transform 0.1s cubic-bezier(0.2,0,0,1);
|
|
586
|
+
flex-shrink: 0;
|
|
587
|
+
`,o.textContent="Save",o.addEventListener("mouseenter",()=>{o.style.opacity="0.85"}),o.addEventListener("mouseleave",()=>{o.style.opacity="1"}),o.addEventListener("click",i=>{i.stopPropagation(),nn(o)});let r=document.createElement("button");r.title="Discard changes",r.style.cssText=`
|
|
588
|
+
padding: 5px 10px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.1); cursor: pointer;
|
|
589
|
+
background: transparent; color: rgba(255,255,255,0.5);
|
|
590
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
591
|
+
font-size: 12px; font-weight: 500; letter-spacing: 0.01em;
|
|
592
|
+
transition: color 0.15s, border-color 0.15s;
|
|
593
|
+
flex-shrink: 0;
|
|
594
|
+
`,r.textContent="Discard",r.addEventListener("mouseenter",()=>{r.style.color="rgba(255,255,255,0.8)",r.style.borderColor="rgba(255,255,255,0.2)"}),r.addEventListener("mouseleave",()=>{r.style.color="rgba(255,255,255,0.5)",r.style.borderColor="rgba(255,255,255,0.1)"}),r.addEventListener("click",i=>{i.stopPropagation(),Oe(),$(),Ie()});let a=document.createElement("div");a.dataset.canciaPanelSlot="1",a.style.cssText="display:grid;place-items:center;overflow:hidden;";let s=document.createElement("div");s.dataset.canciaPanelRow="1",s.style.cssText=`
|
|
595
|
+
grid-area: 1/1; display: flex; align-items: center; gap: 6px;
|
|
596
|
+
padding: 7px 7px 7px 12px;
|
|
597
|
+
transition: transform 200ms cubic-bezier(0.785,0.135,0.15,0.86);
|
|
598
|
+
`,s.appendChild(n),s.appendChild(r),s.appendChild(o);let c=document.createElement("div");c.dataset.canciaPanelFlash="1",c.style.cssText=`
|
|
599
|
+
grid-area: 1/1; display: flex; align-items: center; gap: 7px;
|
|
600
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
601
|
+
font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.8); white-space: nowrap;
|
|
602
|
+
padding: 7px 12px;
|
|
603
|
+
transform: translateY(-150%);
|
|
604
|
+
transition: transform 200ms cubic-bezier(0.785,0.135,0.15,0.86);
|
|
605
|
+
`,a.appendChild(s),a.appendChild(c),k.appendChild(a),document.body.appendChild(k)}let t=k.querySelector("[data-cancia-pending-label]");t&&(t.textContent=`${e} unsaved change${e===1?"":"s"}`)}function mt(e,t){if(!k)return;let n=t==="success"?"#4ade80":"#f87171",o=k.querySelector("[data-cancia-panel-row]"),r=k.querySelector("[data-cancia-panel-flash]");!o||!r||(r.innerHTML=`<span style="width:7px;height:7px;border-radius:50%;background:${n};flex-shrink:0;display:block;"></span>${e}`,o.style.transform="translateY(150%)",r.style.transform="translateY(0)",setTimeout(()=>Ie(),1600))}function Ie(){if(!k)return;let e=k;k=null,e.style.transition="opacity 0.2s cubic-bezier(0.4,0,1,1), transform 0.2s cubic-bezier(0.4,0,1,1)",e.style.opacity="0",e.style.transform="translateY(4px)",setTimeout(()=>e.remove(),220)}function yt(){D||(A=!1,D=en(),document.body.appendChild(D))}function ne(){we(),$(),A=!1,I?.remove(),I=null,k?.remove(),k=null,D&&(D.style.animation="cancia-exit 0.25s cubic-bezier(0.4, 0, 1, 1) both",setTimeout(()=>{D?.remove(),D=null},260))}var Fe="cancia_session";function sn(){try{return sessionStorage.getItem(Fe)}catch{return null}}function ln(e){try{sessionStorage.setItem(Fe,e)}catch{}}function Ae(){try{sessionStorage.removeItem(Fe)}catch{}}async function cn(){let e=new URLSearchParams(window.location.search),t=e.get("cancia");if(!t)return null;e.delete("cancia");let n=e.toString(),o=window.location.pathname+(n?`?${n}`:"")+window.location.hash;window.history.replaceState(null,"",o);try{if((await fetch("/api/cancia/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t})})).ok)return ln(t),t}catch{}return console.warn("Cancia: magic link token is invalid or expired."),null}async function Be(e){p.config=e,p.activeLang=e.languages[0],window.__CANCIA_DATA__&&(p.cmsData=window.__CANCIA_DATA__);try{let t=await Re();p.cmsData=t}catch(t){if(!e.public&&t instanceof Error&&t.message.includes("401")){Ae(),console.warn("Cancia: session expired or invalid, toolbar not mounted.");return}console.warn("Cancia: could not fetch CMS content, using preloaded data.")}oe();try{p.schemas=await De()}catch{p.schemas={}}yt()}async function bt(){if(!window.__CANCIA__)return;if(window.__CANCIA__.public){Be(window.__CANCIA__);return}let e=await cn()??sn();e&&(p.sessionToken=e,p.onLogout=()=>{Ae(),ne()},Be(window.__CANCIA__))}typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",bt):bt());return kt(dn);})();
|