ghost 6.10.0 → 6.10.2

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.
@@ -1,4 +1,4 @@
1
- import{j as a,r as D,c as Vf,P as Lg,a as ns,u as Fg,b as ao,d as Va,e as Ug,f as zg,H as xt,g as Gr,S as Qa,h as ve,F as st,i as __,B as Ue,k as el,K as k_,l as Hg,m as M_,R as j_,I as E_,n as Zt,o as T_,p as Pt,M as _t,q as an,s as S_,T as Rn,t as ut,v as Bg,w as N_,x as ss,y as tl,N as _e,z as Je,A as A_,C as Wg,D as et,E as it,G as rl,L as ln,J as On,O as St,Q as Nt,U as oo,V as Qf,W as I_,X as as,Y as os,Z as bt,_ as kr,$ as C_,a0 as ih,a1 as rt,a2 as Ne,a3 as lh,a4 as ch,a5 as ot,a6 as qg,a7 as Yg,a8 as D_,a9 as gt,aa as Gg,ab as R_,ac as O_,ad as $_,ae as Xs,af as Ks,ag as Xr,ah as Xg,ai as P_,aj as $n,ak as Kg,al as L_,am as F_,an as U_,ao as z_,ap as Zg,aq as H_,ar as qi,as as uh,at as Yi,au as B_,av as Vg,aw as cn,ax as W_,ay as fh,az as dh,aA as q_,aB as Zs,aC as un,aD as on,aE as Qg,aF as Y_,aG as G_,aH as X_,aI as Jg,aJ as Jf,aK as K_,aL as Z_,aM as V_,aN as ts,aO as Q_,aP as Gi,aQ as ed,aR as J_,aS as td,aT as e2,aU as t2,aV as r2,aW as n2,aX as e0,aY as t0,aZ as rd,a_ as Ws,a$ as nd,b0 as s2,b1 as Ba,b2 as a2,b3 as o2,b4 as r0,b5 as n0,b6 as i2,b7 as l2,b8 as c2,b9 as ph,ba as s0,bb as a0,bc as o0,bd as If,be as u2,bf as f2,bg as d2,bh as p2,bi as nl,bj as h2,bk as sd,bl as i0,bm as l0,bn as hh,bo as dr,bp as c0,bq as m2,br as ad,bs as g2,bt as b2,bu as Ja,bv as u0,bw as x2,bx as v2,by as Cf,bz as w2,bA as Ys,bB as y2,bC as _2,bD as k2,bE as f0,bF as M2,bG as od,bH as j2,bI as id,bJ as Xi,bK as E2,bL as T2,bM as Df,bN as S2,bO as N2,bP as A2,bQ as d0,bR as I2,bS as p0,bT as C2,bU as D2,bV as R2,bW as O2,bX as $2,bY as P2,bZ as Nn,b_ as mh,b$ as gh,c0 as L2,c1 as F2}from"./index-CPcmd2_W.js";function U2(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const h0=({children:e,...n})=>a.jsx("div",{className:"flex h-full w-full flex-col px-8",...n,children:a.jsx("div",{className:"h-full w-full overflow-hidden rounded-t-[4px] shadow-sm",children:e})}),m0=({children:e,...n})=>a.jsx("div",{className:"flex h-[775px] w-[380px] flex-col rounded-3xl bg-white p-2 shadow-xl dark:bg-grey-900",...n,children:a.jsx("div",{className:"w-100 h-100 grow overflow-auto rounded-2xl border border-grey-100 dark:border-grey-950",children:e})});var sl="Checkbox",[z2]=Vf(sl),[H2,ld]=z2(sl);function B2(e){const{__scopeCheckbox:n,checked:s,children:o,defaultChecked:c,disabled:h,form:y,name:b,onCheckedChange:l,required:u,value:f="on",internal_do_not_use_render:p}=e,[m,v]=Fg({prop:s,defaultProp:c??!1,onChange:l,caller:sl}),[_,k]=D.useState(null),[M,T]=D.useState(null),A=D.useRef(!1),C=_?!!y||!!_.closest("form"):!0,O={checked:m,disabled:h,setChecked:v,control:_,setControl:k,name:b,form:y,value:f,hasConsumerStoppedPropagationRef:A,required:u,defaultChecked:Cn(c)?!1:c,isFormControl:C,bubbleInput:M,setBubbleInput:T};return a.jsx(H2,{scope:n,...O,children:W2(p)?p(O):o})}var g0="CheckboxTrigger",b0=D.forwardRef(({__scopeCheckbox:e,onKeyDown:n,onClick:s,...o},c)=>{const{control:h,value:y,disabled:b,checked:l,required:u,setControl:f,setChecked:p,hasConsumerStoppedPropagationRef:m,isFormControl:v,bubbleInput:_}=ld(g0,e),k=ao(c,f),M=D.useRef(l);return D.useEffect(()=>{const T=h?.form;if(T){const A=()=>p(M.current);return T.addEventListener("reset",A),()=>T.removeEventListener("reset",A)}},[h,p]),a.jsx(ns.button,{type:"button",role:"checkbox","aria-checked":Cn(l)?"mixed":l,"aria-required":u,"data-state":k0(l),"data-disabled":b?"":void 0,disabled:b,value:y,...o,ref:k,onKeyDown:Va(n,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Va(s,T=>{p(A=>Cn(A)?!0:!A),_&&v&&(m.current=T.isPropagationStopped(),m.current||T.stopPropagation())})})});b0.displayName=g0;var x0=D.forwardRef((e,n)=>{const{__scopeCheckbox:s,name:o,checked:c,defaultChecked:h,required:y,disabled:b,value:l,onCheckedChange:u,form:f,...p}=e;return a.jsx(B2,{__scopeCheckbox:s,checked:c,defaultChecked:h,disabled:b,required:y,onCheckedChange:u,name:o,form:f,value:l,internal_do_not_use_render:({isFormControl:m})=>a.jsxs(a.Fragment,{children:[a.jsx(b0,{...p,ref:n,__scopeCheckbox:s}),m&&a.jsx(_0,{__scopeCheckbox:s})]})})});x0.displayName=sl;var v0="CheckboxIndicator",w0=D.forwardRef((e,n)=>{const{__scopeCheckbox:s,forceMount:o,...c}=e,h=ld(v0,s);return a.jsx(Lg,{present:o||Cn(h.checked)||h.checked===!0,children:a.jsx(ns.span,{"data-state":k0(h.checked),"data-disabled":h.disabled?"":void 0,...c,ref:n,style:{pointerEvents:"none",...e.style}})})});w0.displayName=v0;var y0="CheckboxBubbleInput",_0=D.forwardRef(({__scopeCheckbox:e,...n},s)=>{const{control:o,hasConsumerStoppedPropagationRef:c,checked:h,defaultChecked:y,required:b,disabled:l,name:u,value:f,form:p,bubbleInput:m,setBubbleInput:v}=ld(y0,e),_=ao(s,v),k=Ug(h),M=zg(o);D.useEffect(()=>{const A=m;if(!A)return;const C=window.HTMLInputElement.prototype,$=Object.getOwnPropertyDescriptor(C,"checked").set,B=!c.current;if(k!==h&&$){const R=new Event("click",{bubbles:B});A.indeterminate=Cn(h),$.call(A,Cn(h)?!1:h),A.dispatchEvent(R)}},[m,k,h,c]);const T=D.useRef(Cn(h)?!1:h);return a.jsx(ns.input,{type:"checkbox","aria-hidden":!0,defaultChecked:y??T.current,required:b,disabled:l,name:u,value:f,form:p,...n,tabIndex:-1,ref:_,style:{...n.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_0.displayName=y0;function W2(e){return typeof e=="function"}function Cn(e){return e==="indeterminate"}function k0(e){return Cn(e)?"indeterminate":e?"checked":"unchecked"}const q2=({title:e,label:n,value:s,onChange:o,disabled:c,error:h,hint:y,checked:b,separator:l,testId:u})=>{const f=D.useId(),p=m=>{o(m===!0)};return a.jsxs("div",{children:[a.jsxs("div",{className:`flex flex-col gap-1 ${l&&"pb-2"}`,children:[e&&a.jsx(xt,{grey:!0,level:6,children:e}),a.jsxs("label",{className:`flex cursor-pointer items-start ${e&&"-mb-1 mt-1"}`,htmlFor:f,children:[a.jsx(x0,{className:"mt-0.5 flex h-4 w-4 cursor-pointer appearance-none items-center justify-center rounded-[3px] border border-solid border-grey-500 bg-white outline-none data-[state=checked]:border-black data-[state=indeterminate]:border-black data-[state=checked]:bg-black data-[state=indeterminate]:bg-black","data-testid":u,defaultChecked:b,disabled:c,id:f,value:s,onCheckedChange:p,children:a.jsx(w0,{children:a.jsx("svg",{fill:"none",height:"11",viewBox:"0 0 10 11",width:"10",children:a.jsx("path",{d:"M1 5.88889L4.6 9L9 1",stroke:"white",strokeLinecap:"round",strokeWidth:"2"})})})}),a.jsxs("div",{className:`ml-2 flex flex-col ${y&&"mb-2"}`,children:[a.jsx("span",{className:`inline-block text-[1.425rem] dark:text-white ${y&&"-mb-1"}`,children:n}),y&&a.jsx(Gr,{color:h?"red":"",children:y})]})]})]}),(l||h)&&a.jsx(Qa,{className:h?"border-red":""})]})},Rf=({title:e,checkboxes:n,hint:s,error:o})=>a.jsxs("div",{children:[e&&a.jsx(xt,{grey:!0,level:6,children:e}),a.jsx("div",{className:"mt-2 flex flex-col gap-1",children:n?.map(({key:c,...h})=>a.jsx(q2,{...h},c))}),a.jsx("div",{className:`flex flex-col ${s&&"mb-2"}`,children:s&&a.jsx(Gr,{color:o?"red":"",children:s})})]}),Y2=({hex:e,value:n,title:s,size:o="md",isSelected:c,onSelect:h})=>{const y=D.useRef(null),b=f=>{f.preventDefault(),h(n!==void 0?n:e)},l=e.length===4&&e[3]==="0"||e.length===8&&e.slice(6)==="00";let u="h-5 w-5";switch(o){case"lg":u="w-6 h-6";break}return a.jsx("button",{ref:y,className:ve("relative flex shrink-0 cursor-pointer items-center rounded-full border border-grey-300 dark:border-grey-800",u,c&&"outline outline-2 outline-green"),style:{backgroundColor:e},title:s,type:"button",onClick:b,children:l&&a.jsx("div",{className:"absolute left-0 top-0 z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})},M0=({title:e,value:n,swatches:s,swatchSize:o="md",onSwatchChange:c,onTogglePicker:h,isExpanded:y,picker:b=!0,containerClassName:l})=>{const u=s.find(p=>p.value===n||p.hex===n);l=ve("flex flex-col gap-3");const f=y||!b;return a.jsxs("div",{className:l,children:[e&&a.jsx(xt,{useLabelTag:!0,children:e}),a.jsxs("div",{className:"flex gap-1",children:[f&&a.jsx("div",{className:"flex items-center gap-1",children:s.map(({customContent:p,...m})=>p?a.jsx(D.Fragment,{children:p},m.title):a.jsx(Y2,{isSelected:u?.title===m.title,size:o,onSelect:c,...m},m.title))}),b&&a.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-250 dark:border-grey-800",type:"button",onClick:h,children:[a.jsx("div",{className:"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]"}),u&&a.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:u.hex},children:u.hex==="transparent"&&a.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})}),!u&&n&&a.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:n},children:n==="transparent"&&a.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})]})]})]})};function Vs(){return(Vs=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e}).apply(this,arguments)}function al(e,n){if(e==null)return{};var s,o,c={},h=Object.keys(e);for(o=0;o<h.length;o++)n.indexOf(s=h[o])>=0||(c[s]=e[s]);return c}function eo(e){var n=D.useRef(e),s=D.useRef(function(o){n.current&&n.current(o)});return n.current=e,s.current}var to=function(e,n,s){return n===void 0&&(n=0),s===void 0&&(s=1),e>s?s:e<n?n:e},Ka=function(e){return"touches"in e},Of=function(e){return e&&e.ownerDocument.defaultView||self},bh=function(e,n,s){var o=e.getBoundingClientRect(),c=Ka(n)?(function(h,y){for(var b=0;b<h.length;b++)if(h[b].identifier===y)return h[b];return h[0]})(n.touches,s):n;return{left:to((c.pageX-(o.left+Of(e).pageXOffset))/o.width),top:to((c.pageY-(o.top+Of(e).pageYOffset))/o.height)}},xh=function(e){!Ka(e)&&e.preventDefault()},j0=st.memo(function(e){var n=e.onMove,s=e.onKey,o=al(e,["onMove","onKey"]),c=D.useRef(null),h=eo(n),y=eo(s),b=D.useRef(null),l=D.useRef(!1),u=D.useMemo(function(){var v=function(M){xh(M),(Ka(M)?M.touches.length>0:M.buttons>0)&&c.current?h(bh(c.current,M,b.current)):k(!1)},_=function(){return k(!1)};function k(M){var T=l.current,A=Of(c.current),C=M?A.addEventListener:A.removeEventListener;C(T?"touchmove":"mousemove",v),C(T?"touchend":"mouseup",_)}return[function(M){var T=M.nativeEvent,A=c.current;if(A&&(xh(T),!(function(O,$){return $&&!Ka(O)})(T,l.current)&&A)){if(Ka(T)){l.current=!0;var C=T.changedTouches||[];C.length&&(b.current=C[0].identifier)}A.focus(),h(bh(A,T,b.current)),k(!0)}},function(M){var T=M.which||M.keyCode;T<37||T>40||(M.preventDefault(),y({left:T===39?.05:T===37?-.05:0,top:T===40?.05:T===38?-.05:0}))},k]},[y,h]),f=u[0],p=u[1],m=u[2];return D.useEffect(function(){return m},[m]),st.createElement("div",Vs({},o,{onTouchStart:f,onMouseDown:f,className:"react-colorful__interactive",ref:c,onKeyDown:p,tabIndex:0,role:"slider"}))}),cd=function(e){return e.filter(Boolean).join(" ")},E0=function(e){var n=e.color,s=e.left,o=e.top,c=o===void 0?.5:o,h=cd(["react-colorful__pointer",e.className]);return st.createElement("div",{className:h,style:{top:100*c+"%",left:100*s+"%"}},st.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},Yt=function(e,n,s){return n===void 0&&(n=0),s===void 0&&(s=Math.pow(10,n)),Math.round(s*e)/s},G2=function(e){return Q2($f(e))},$f=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Yt(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?Yt(parseInt(e.substring(6,8),16)/255,2):1}},X2=function(e){return V2(Z2(e))},K2=function(e){var n=e.s,s=e.v,o=e.a,c=(200-n)*s/100;return{h:Yt(e.h),s:Yt(c>0&&c<200?n*s/100/(c<=100?c:200-c)*100:0),l:Yt(c/2),a:Yt(o,2)}},Pf=function(e){var n=K2(e);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},Z2=function(e){var n=e.h,s=e.s,o=e.v,c=e.a;n=n/360*6,s/=100,o/=100;var h=Math.floor(n),y=o*(1-s),b=o*(1-(n-h)*s),l=o*(1-(1-n+h)*s),u=h%6;return{r:Yt(255*[o,b,y,y,l,o][u]),g:Yt(255*[l,o,o,b,y,y][u]),b:Yt(255*[y,y,l,o,o,b][u]),a:Yt(c,2)}},$i=function(e){var n=e.toString(16);return n.length<2?"0"+n:n},V2=function(e){var n=e.r,s=e.g,o=e.b,c=e.a,h=c<1?$i(Yt(255*c)):"";return"#"+$i(n)+$i(s)+$i(o)+h},Q2=function(e){var n=e.r,s=e.g,o=e.b,c=e.a,h=Math.max(n,s,o),y=h-Math.min(n,s,o),b=y?h===n?(s-o)/y:h===s?2+(o-n)/y:4+(n-s)/y:0;return{h:Yt(60*(b<0?b+6:b)),s:Yt(h?y/h*100:0),v:Yt(h/255*100),a:c}},J2=st.memo(function(e){var n=e.hue,s=e.onChange,o=cd(["react-colorful__hue",e.className]);return st.createElement("div",{className:o},st.createElement(j0,{onMove:function(c){s({h:360*c.left})},onKey:function(c){s({h:to(n+360*c.left,0,360)})},"aria-label":"Hue","aria-valuenow":Yt(n),"aria-valuemax":"360","aria-valuemin":"0"},st.createElement(E0,{className:"react-colorful__hue-pointer",left:n/360,color:Pf({h:n,s:100,v:100,a:1})})))}),e3=st.memo(function(e){var n=e.hsva,s=e.onChange,o={backgroundColor:Pf({h:n.h,s:100,v:100,a:1})};return st.createElement("div",{className:"react-colorful__saturation",style:o},st.createElement(j0,{onMove:function(c){s({s:100*c.left,v:100-100*c.top})},onKey:function(c){s({s:to(n.s+100*c.left,0,100),v:to(n.v-100*c.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+Yt(n.s)+"%, Brightness "+Yt(n.v)+"%"},st.createElement(E0,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:Pf(n)})))}),T0=function(e,n){if(e===n)return!0;for(var s in e)if(e[s]!==n[s])return!1;return!0},t3=function(e,n){return e.toLowerCase()===n.toLowerCase()||T0($f(e),$f(n))};function r3(e,n,s){var o=eo(s),c=D.useState(function(){return e.toHsva(n)}),h=c[0],y=c[1],b=D.useRef({color:n,hsva:h});D.useEffect(function(){if(!e.equal(n,b.current.color)){var u=e.toHsva(n);b.current={hsva:u,color:n},y(u)}},[n,e]),D.useEffect(function(){var u;T0(h,b.current.hsva)||e.equal(u=e.fromHsva(h),b.current.color)||(b.current={hsva:h,color:u},o(u))},[h,e,o]);var l=D.useCallback(function(u){y(function(f){return Object.assign({},f,u)})},[]);return[h,l]}var n3=typeof window<"u"?D.useLayoutEffect:D.useEffect,s3=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},vh=new Map,a3=function(e){n3(function(){var n=e.current?e.current.ownerDocument:document;if(n!==void 0&&!vh.has(n)){var s=n.createElement("style");s.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,vh.set(n,s);var o=s3();o&&s.setAttribute("nonce",o),n.head.appendChild(s)}},[])},o3=function(e){var n=e.className,s=e.colorModel,o=e.color,c=o===void 0?s.defaultColor:o,h=e.onChange,y=al(e,["className","colorModel","color","onChange"]),b=D.useRef(null);a3(b);var l=r3(s,c,h),u=l[0],f=l[1],p=cd(["react-colorful",n]);return st.createElement("div",Vs({},y,{ref:b,className:p}),st.createElement(e3,{hsva:u,onChange:f}),st.createElement(J2,{hue:u.h,onChange:f,className:"react-colorful__last-control"}))},i3={defaultColor:"000",toHsva:G2,fromHsva:function(e){return X2({h:e.h,s:e.s,v:e.v,a:1})},equal:t3},l3=function(e){return st.createElement(o3,Vs({},e,{colorModel:i3}))},c3=/^#?([0-9A-F]{3,8})$/i,u3=function(e){var n=e.color,s=n===void 0?"":n,o=e.onChange,c=e.onBlur,h=e.escape,y=e.validate,b=e.format,l=e.process,u=al(e,["color","onChange","onBlur","escape","validate","format","process"]),f=D.useState(function(){return h(s)}),p=f[0],m=f[1],v=eo(o),_=eo(c),k=D.useCallback(function(T){var A=h(T.target.value);m(A),y(A)&&v(l?l(A):A)},[h,l,y,v]),M=D.useCallback(function(T){y(T.target.value)||m(h(s)),_(T)},[s,h,y,_]);return D.useEffect(function(){m(h(s))},[s,h]),st.createElement("input",Vs({},u,{value:b?b(p):p,spellCheck:"false",onChange:k,onBlur:M}))},wh=function(e){return"#"+e},f3=function(e){var n=e.prefixed,s=e.alpha,o=al(e,["prefixed","alpha"]),c=D.useCallback(function(y){return y.replace(/([^0-9A-F]+)/gi,"").substring(0,s?8:6)},[s]),h=D.useCallback(function(y){return(function(b,l){var u=c3.exec(b),f=u?u[1].length:0;return f===3||f===6||!!l&&f===4||!!l&&f===8})(y,s)},[s]);return st.createElement(u3,Vs({},o,{escape:c,format:n?wh:void 0,process:wh,validate:h}))};const d3=({hexValue:e,eyedropper:n,clearButtonValue:s,containerClassName:o,onChange:c})=>{const h=D.useRef(null),y=D.useCallback(m=>{var v,_,k;m.stopPropagation();const M=(v=h.current)==null?void 0:v.querySelector("input");m.target!==M&&((k=(_=h.current)==null?void 0:_.querySelector("input"))==null||k.focus(),m.preventDefault())},[]),b=D.useRef(!1),l=D.useCallback(()=>{var m,v;b.current=!1,(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus(),document.removeEventListener("mouseup",l),document.removeEventListener("touchend",l)},[]),u=D.useCallback(()=>{b.current=!0,document.addEventListener("mouseup",l),document.addEventListener("touchend",l)},[l]),f=D.useCallback(m=>{if(m.preventDefault(),!window.EyeDropper)return;b.current=!0,document.body.style.setProperty("pointer-events","none"),new window.EyeDropper().open().then(_=>c?.(_.sRGBHex)).finally(()=>{var _,k;b.current=!1,document.body.style.removeProperty("pointer-events"),(k=(_=h.current)==null?void 0:_.querySelector("input"))==null||k.focus()})},[c]);D.useEffect(()=>{var m,v;(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus()},[]);const p=D.useCallback(()=>{var m,v;(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus()},[]);return o=ve("mt-2",o),a.jsxs("div",{className:o,onMouseDown:y,onTouchStart:y,children:[a.jsx(l3,{className:"w-full",color:e||"#ffffff",onChange:c,onMouseDown:u,onTouchStart:u}),a.jsxs("div",{className:"mt-3 flex gap-2",children:[a.jsxs("div",{ref:h,className:"peer relative order-2 flex h-10 w-full items-center",onClick:p,children:[a.jsx("span",{className:"absolute left-2 top-[9px] z-10 ml-1 mr-2 text-grey-700",children:"#"}),a.jsx(f3,{"aria-label":"Color value",className:"z-[1] w-full rounded-md border border-transparent bg-grey-150 p-2 pl-6 transition-all hover:bg-grey-100 focus:border-green focus:bg-white focus:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:bg-grey-900 dark:text-white dark:focus:bg-grey-925",color:e,onChange:c}),n&&!!window.EyeDropper&&a.jsx("button",{className:"absolute inset-y-0 right-3 z-50 my-auto h-4 w-4 p-[1px]",type:"button",onClick:f,children:a.jsx(__,{className:"h-full w-full"})})]}),s!==void 0&&a.jsx(Ue,{color:"grey",value:"Clear",onClick:()=>c?.(s)})]})]})},p3=D.createContext({colorPickers:[]}),yh=e=>e.length===4?e.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"):e,Yr=({testId:e,title:n,direction:s,value:o,hint:c,error:h,eyedropper:y,clearButtonValue:b,onChange:l,swatches:u=[],alwaysOpen:f=!1,debounceMs:p})=>{const[m,v]=D.useState(!1),[_,k]=D.useState(o),M=D.useContext(p3),T=D.useId();D.useEffect(()=>{k(B=>yh(B||"")===o?B:o)},[o]),D.useEffect(()=>(M.colorPickers.push({id:T,setExpanded:v}),()=>{M.colorPickers=M.colorPickers.filter(B=>B.id!==T)}),[M,T]),D.useEffect(()=>{if(m){M.colorPickers.filter(R=>R.id!==T).forEach(R=>R.setExpanded(!1));const B=()=>{v(!1)};return document.addEventListener("click",B),()=>{document.removeEventListener("click",B)}}},[M,T,m]);const A=D.useMemo(()=>l&&p?el(l,p):l,[p,l]),C=B=>{k(B),A?.(B?yh(B):null)};let O=a.jsx(M0,{isExpanded:m,swatches:u,value:_,onSwatchChange:B=>{C(B),v(!1)},onTogglePicker:()=>!f&&v(!m)});n&&(O=a.jsxs("div",{className:ve("flex w-full cursor-pointer items-start first:mt-0 dark:text-white",s==="rtl"&&"flex-row-reverse"),children:[a.jsx("div",{className:"shrink-0",children:O}),a.jsxs("div",{className:ve("flex-1",s==="rtl"?"pr-2":"pl-2",c?"mt-[-2px]":"mt-[1px]"),onClick:()=>!f&&v(!m),children:[n,c&&a.jsx("div",{className:`text-xs ${h?"text-red":"text-grey-700"}`,children:c})]})]}));const $=u.find(B=>B.value===_);return a.jsxs("div",{className:"flex-col","data-testid":e,onClick:B=>B.stopPropagation(),children:[O,(f||m)&&a.jsx(d3,{clearButtonValue:b,eyedropper:y,hexValue:$?.hex||_||void 0,onChange:C})]})},h3=({value:e,onChange:n,singleParagraph:s=!0,...o})=>{const c=D.useCallback(h=>{const b=new DOMParser().parseFromString(h,"text/html");b.querySelectorAll("*").forEach(u=>{u.style.removeProperty("white-space"),u.getAttribute("style")||u.removeAttribute("style")}),b.body.innerHTML!==e&&n?.(b.body.innerHTML)},[e,n]);return a.jsx(k_,{...o,singleParagraph:s,children:h=>a.jsx(h.HtmlOutputPlugin,{html:e,setHtml:c})})},ud=({title:e,hideTitle:n,error:s,hint:o,value:c,clearBg:h=!1,className:y="",containerClassName:b="",hintClassName:l="",unstyled:u=!1,...f})=>{const p=u?"":ve("flex min-h-[32px] items-center rounded-md border border-transparent py-1.5 md:min-h-[36px]",h?"bg-transparent":"bg-grey-150 px-3 dark:bg-grey-900",s?"border-red":"transition-all hover:bg-grey-100 has-[:focus]:border-green has-[:focus]:bg-white has-[:focus]:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:selection:bg-[rgba(88,101,116,0.99)] dark:hover:bg-grey-925 dark:has-[:focus]:bg-grey-950",e&&!n&&!h&&"mt-2",y);return a.jsxs("div",{className:`flex flex-col ${b}`,children:[e&&a.jsx(xt,{className:n?"sr-only":"",grey:!0,useLabelTag:!0,children:e}),a.jsx("div",{className:p,children:a.jsx(h3,{...f,value:c})}),o&&a.jsx(Gr,{className:l,color:s?"red":"",children:o})]})};var fd="Radio",[m3,S0]=Vf(fd),[g3,b3]=m3(fd),N0=D.forwardRef((e,n)=>{const{__scopeRadio:s,name:o,checked:c=!1,required:h,disabled:y,value:b="on",onCheck:l,form:u,...f}=e,[p,m]=D.useState(null),v=ao(n,M=>m(M)),_=D.useRef(!1),k=p?u||!!p.closest("form"):!0;return a.jsxs(g3,{scope:s,checked:c,disabled:y,children:[a.jsx(ns.button,{type:"button",role:"radio","aria-checked":c,"data-state":D0(c),"data-disabled":y?"":void 0,disabled:y,value:b,...f,ref:v,onClick:Va(e.onClick,M=>{c||l?.(),k&&(_.current=M.isPropagationStopped(),_.current||M.stopPropagation())})}),k&&a.jsx(C0,{control:p,bubbles:!_.current,name:o,value:b,checked:c,required:h,disabled:y,form:u,style:{transform:"translateX(-100%)"}})]})});N0.displayName=fd;var A0="RadioIndicator",I0=D.forwardRef((e,n)=>{const{__scopeRadio:s,forceMount:o,...c}=e,h=b3(A0,s);return a.jsx(Lg,{present:o||h.checked,children:a.jsx(ns.span,{"data-state":D0(h.checked),"data-disabled":h.disabled?"":void 0,...c,ref:n})})});I0.displayName=A0;var x3="RadioBubbleInput",C0=D.forwardRef(({__scopeRadio:e,control:n,checked:s,bubbles:o=!0,...c},h)=>{const y=D.useRef(null),b=ao(y,h),l=Ug(s),u=zg(n);return D.useEffect(()=>{const f=y.current;if(!f)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==s&&v){const _=new Event("click",{bubbles:o});v.call(f,s),f.dispatchEvent(_)}},[l,s,o]),a.jsx(ns.input,{type:"radio","aria-hidden":!0,defaultChecked:s,...c,tabIndex:-1,ref:b,style:{...c.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});C0.displayName=x3;function D0(e){return e?"checked":"unchecked"}var v3=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ol="RadioGroup",[w3]=Vf(ol,[Hg,S0]),R0=Hg(),O0=S0(),[y3,_3]=w3(ol),$0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,name:o,defaultValue:c,value:h,required:y=!1,disabled:b=!1,orientation:l,dir:u,loop:f=!0,onValueChange:p,...m}=e,v=R0(s),_=M_(u),[k,M]=Fg({prop:h,defaultProp:c??null,onChange:p,caller:ol});return a.jsx(y3,{scope:s,name:o,required:y,disabled:b,value:k,onValueChange:M,children:a.jsx(j_,{asChild:!0,...v,orientation:l,dir:_,loop:f,children:a.jsx(ns.div,{role:"radiogroup","aria-required":y,"aria-orientation":l,"data-disabled":b?"":void 0,dir:_,...m,ref:n})})})});$0.displayName=ol;var P0="RadioGroupItem",L0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,disabled:o,...c}=e,h=_3(P0,s),y=h.disabled||o,b=R0(s),l=O0(s),u=D.useRef(null),f=ao(n,u),p=h.value===c.value,m=D.useRef(!1);return D.useEffect(()=>{const v=k=>{v3.includes(k.key)&&(m.current=!0)},_=()=>m.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",_)}},[]),a.jsx(E_,{asChild:!0,...b,focusable:!y,active:p,children:a.jsx(N0,{disabled:y,required:h.required,checked:p,...l,...c,name:h.name,ref:f,onCheck:()=>h.onValueChange(c.value),onKeyDown:Va(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Va(c.onFocus,()=>{m.current&&u.current?.click()})})})});L0.displayName=P0;var k3="RadioGroupIndicator",F0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,...o}=e,c=O0(s);return a.jsx(I0,{...c,...o,ref:n})});F0.displayName=k3;var M3=$0,j3=L0,E3=F0;const T3=({id:e,title:n,options:s,onSelect:o,error:c,hint:h,selectedOption:y,separator:b})=>a.jsxs(M3,{defaultValue:y,name:e,onValueChange:o,children:[a.jsxs("div",{className:`flex flex-col gap-2 ${b&&"pb-2"}`,children:[n&&a.jsx(xt,{level:6,children:n}),s.map(l=>a.jsxs("label",{className:`flex cursor-pointer items-start ${n&&"-mb-1 mt-1"}`,htmlFor:l.value,children:[a.jsx(j3,{className:"relative float-left mt-[3px] h-4 w-4 min-w-[16px] appearance-none rounded-full border-2 border-solid border-grey-300 hover:cursor-pointer focus:shadow-none focus:outline-none focus:ring-0 data-[state=checked]:border-green data-[state=checked]:focus:border-green dark:border-grey-800 dark:text-white dark:data-[state=checked]:border-green dark:data-[state=checked]:focus:border-green",id:l.value,value:l.value,children:a.jsx(E3,{className:"flex h-full w-full items-center justify-center after:block after:h-[6px] after:w-[6px] after:rounded-full after:border-green after:bg-green after:content-[''] dark:after:border-green dark:after:bg-green"})}),a.jsxs("div",{className:`ml-2 flex flex-col ${l.hint&&"mb-2"}`,children:[a.jsx("span",{className:`inline-block text-md dark:text-white ${l.hint&&"-mb-1"}`,children:l.label}),l.hint&&a.jsx(Gr,{children:l.hint})]})]},l.value)),h&&a.jsx(Gr,{color:c?"red":"",children:h})]}),(b||c)&&a.jsx(Qa,{className:c?"border-red":""})]}),Ki=({children:e,gap:n="md",className:s})=>{let o="gap-3";switch(n){case"sm":o="gap-2";break;case"md":o="gap-3";break;case"lg":o="gap-4";break}return s=ve("flex flex-col",o,s),a.jsx("div",{className:s,children:e})},dd=({heading:e,children:n,className:s})=>(s=ve("w-full p-[8vmin] pt-5",s),a.jsxs("div",{className:s,children:[e&&a.jsx(xt,{className:"mb-8",children:e}),n]})),pd=({items:e,backIcon:n=!1,snapBackIcon:s=!0,onBack:o,containerClassName:c,itemClassName:h,activeItemClassName:y,separatorClassName:b})=>{const l=e.length;let u=0;return c=ve("flex items-center gap-2 text-sm",c),y=ve("font-bold",y),h=ve("text-sm",h),a.jsxs("div",{className:c,children:[n&&a.jsx(Ue,{className:s?"mr-1":"mr-6",icon:"arrow-left",iconColorClass:"dark:text-white",size:"sm",link:!0,onClick:o}),e.map(f=>{const p=u===l-1?a.jsx("span",{className:y,children:f.label}):a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`${h} ${f.onClick&&"-mx-1 cursor-pointer rounded-sm px-1 py-px hover:bg-grey-100 dark:hover:bg-grey-900"}`,type:"button",onClick:f.onClick,children:f.label},`bc-${u}`),a.jsx("span",{className:b,children:"/"})]});return u=u+1,p})]})},Qs=({testId:e,title:n,titleHeadingLevel:s=4,size:o="full",width:c,height:h,sidebar:y="",preview:b,dirty:l=!1,cancelLabel:u="Cancel",okLabel:f="OK",okColor:p="black",previewToolbar:m=!0,leftToolbar:v=!0,rightToolbar:_=!0,deviceSelector:k=!0,siteLink:M,previewToolbarURLs:T,previewBgColor:A="grey",selectedURL:C,previewToolbarTabs:O,previewToolbarBreadcrumbs:$,buttonsDisabled:B,sidebarButtons:R,sidebarHeader:V,sidebarPadding:K=!0,sidebarContentClasses:G,enableCMDS:W=!0,backDropClick:q,onCancel:se,onOk:J,afterClose:te,onSelectURL:Q,onSelectDesktopView:re,onSelectMobileView:be,onBreadcrumbsBack:Me})=>{const L=Zt(),{setGlobalDirtyState:fe}=T_();D.useEffect(()=>{fe(l)},[l,fe]),D.useEffect(()=>{if(J){const oe=je=>{(je.metaKey||je.ctrlKey)&&je.key==="s"&&(je.preventDefault(),J())};if(W)return window.addEventListener("keydown",oe),()=>{window.removeEventListener("keydown",oe)}}});const[de,F]=D.useState("desktop");if(de==="mobile"&&k?b=a.jsx(m0,{"data-testid":"preview-mobile",children:b}):de==="desktop"&&k&&(b=a.jsx(h0,{"data-testid":"preview-desktop",children:b})),m){let oe=a.jsx(a.Fragment,{});T?oe=a.jsx(Pt,{options:T,selectedOption:T.find(Ae=>Ae.value===C),onSelect:Ae=>Ae&&Q?.(Ae.value)}):O?oe=a.jsx(Rn,{border:!1,selectedTab:C,tabs:O,width:"wide",onTabChange:Q}):$&&(oe=a.jsx(pd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:$,separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:Me}));const je="text-black dark:text-green",Pe="text-grey-500 dark:text-grey-600",Le=[{icon:"laptop",label:"Desktop",hideLabel:!0,link:!0,size:"sm",iconColorClass:de==="desktop"?je:Pe,onClick:re||(()=>{F("desktop")})},{icon:"mobile",label:"Mobile",hideLabel:!0,link:!0,size:"sm",iconColorClass:de==="mobile"?je:Pe,onClick:be||(()=>{F("mobile")})}],ke=k&&a.jsx(an,{buttons:Le});let ae="";A==="grey"?ae="bg-grey-50 dark:bg-black":A==="greygradient"&&(ae="bg-gradient-to-tr from-white to-[#f9f9fa] dark:from-grey-950 dark:to-black");const Ee=ve("min-w-100 absolute inset-y-0 left-0 right-[400px] flex w-full grow flex-col overflow-y-auto",ae);let Se;M&&(Se=a.jsx("div",{className:"ml-3 border-l border-grey-400 dark:border-grey-800",children:a.jsxs("a",{className:"ml-3 flex items-center gap-1 text-sm",href:M,rel:"noopener noreferrer",target:"_blank",children:["View site ",a.jsx(ut,{name:"arrow-top-right",size:"xs"})]})})),b=a.jsxs("div",{className:Ee,children:[m&&a.jsxs("header",{className:"relative flex h-[80px] shrink-0 items-center justify-center px-8 py-5","data-testid":"design-toolbar",children:[v&&a.jsx("div",{className:"absolute left-8 flex h-full items-center",children:oe}),_&&a.jsxs("div",{className:"absolute right-8 flex h-full items-center",children:[ke,Se]})]}),a.jsx("div",{className:"flex grow items-center justify-center text-sm text-grey-400",children:b})]})}const z=[];return R||(z.push({key:"cancel-modal",label:u,onClick:se||(()=>{S_(l,()=>{L.remove(),te?.()})}),disabled:B}),z.push({key:"ok-modal",label:f,color:p,onClick:J,disabled:B})),a.jsx(_t,{afterClose:te,animate:!1,backDropClick:q,dirty:l,footer:!1,height:h,padding:!1,size:o,testId:e,title:"",width:c,hideXOnMobile:!0,children:a.jsxs("div",{className:"flex h-full grow",children:[a.jsx("div",{className:`relative hidden grow flex-col [@media(min-width:801px)]:!visible [@media(min-width:801px)]:!flex ${A==="grey"?"bg-grey-50":"bg-white dark:bg-black"}`,children:b}),y&&a.jsxs("div",{className:"relative flex h-full w-full flex-col border-l border-grey-100 dark:border-grey-900 [@media(min-width:801px)]:w-auto [@media(min-width:801px)]:basis-[400px]",children:[V||a.jsxs("div",{className:"flex max-h-[82px] items-center justify-between gap-3 px-7 py-6",children:[a.jsx(xt,{level:s,children:n}),R||a.jsx(an,{buttons:z})]}),a.jsx("div",{className:`${V?"":"absolute inset-x-0 bottom-0 top-[80px] grow"} ${K&&"p-7 pt-0"} flex flex-col justify-between overflow-y-auto ${G&&G}`,children:y})]})]})})},S3=({offset:e,onTrigger:n})=>{const s=D.useRef(null);return D.useEffect(()=>{const o=new IntersectionObserver(c=>{c[0].intersectionRatio<=0||n()});return s.current&&o.observe(s.current),()=>o.disconnect()},[n]),a.jsx("div",{ref:s,className:"absolute w-full",style:{bottom:e}})},U0=({trigger:e,triggerButtonProps:n,items:s,position:o="start",open:c,setOpen:h})=>(e||(e=a.jsx(Ue,{icon:"ellipsis",label:"Menu",hideLabel:!0,...n})),a.jsx(Bg,{open:c,position:o,setOpen:h,trigger:e,closeOnItemClick:!0,children:a.jsx("div",{className:"flex min-w-[160px] flex-col justify-stretch py-1",role:"none",children:s.map(y=>a.jsx("button",{className:`mx-1 block cursor-pointer rounded-[2.5px] px-4 py-1.5 text-left text-sm hover:bg-grey-100 dark:hover:bg-grey-925 ${y.destructive&&" text-red-500"}`,type:"button",onClick:b=>{y.onClick&&y.onClick(b)},children:y.label},y.id))})}));var z0=typeof global=="object"&&global&&global.Object===Object&&global,N3=typeof self=="object"&&self&&self.Object===Object&&self,fn=z0||N3||Function("return this")(),Gs=fn.Symbol,H0=Object.prototype,A3=H0.hasOwnProperty,I3=H0.toString,Wa=Gs?Gs.toStringTag:void 0;function C3(e){var n=A3.call(e,Wa),s=e[Wa];try{e[Wa]=void 0;var o=!0}catch{}var c=I3.call(e);return o&&(n?e[Wa]=s:delete e[Wa]),c}var D3=Object.prototype,R3=D3.toString;function O3(e){return R3.call(e)}var $3="[object Null]",P3="[object Undefined]",_h=Gs?Gs.toStringTag:void 0;function io(e){return e==null?e===void 0?P3:$3:_h&&_h in Object(e)?C3(e):O3(e)}function ro(e){return e!=null&&typeof e=="object"}var Zi=Array.isArray;function B0(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}var L3="[object AsyncFunction]",F3="[object Function]",U3="[object GeneratorFunction]",z3="[object Proxy]";function W0(e){if(!B0(e))return!1;var n=io(e);return n==F3||n==U3||n==L3||n==z3}var au=fn["__core-js_shared__"],kh=(function(){var e=/[^.]+$/.exec(au&&au.keys&&au.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function H3(e){return!!kh&&kh in e}var B3=Function.prototype,W3=B3.toString;function is(e){if(e!=null){try{return W3.call(e)}catch{}try{return e+""}catch{}}return""}var q3=/[\\^$.*+?()[\]{}|]/g,Y3=/^\[object .+?Constructor\]$/,G3=Function.prototype,X3=Object.prototype,K3=G3.toString,Z3=X3.hasOwnProperty,V3=RegExp("^"+K3.call(Z3).replace(q3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Q3(e){if(!B0(e)||H3(e))return!1;var n=W0(e)?V3:Y3;return n.test(is(e))}function J3(e,n){return e?.[n]}function Js(e,n){var s=J3(e,n);return Q3(s)?s:void 0}var Lf=Js(fn,"WeakMap"),e8=9007199254740991,t8=/^(?:0|[1-9]\d*)$/;function r8(e,n){var s=typeof e;return n=n??e8,!!n&&(s=="number"||s!="symbol"&&t8.test(e))&&e>-1&&e%1==0&&e<n}function q0(e,n){return e===n||e!==e&&n!==n}var n8=9007199254740991;function Y0(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=n8}function s8(e){return e!=null&&Y0(e.length)&&!W0(e)}var a8=Object.prototype;function o8(e){var n=e&&e.constructor,s=typeof n=="function"&&n.prototype||a8;return e===s}function i8(e,n){for(var s=-1,o=Array(e);++s<e;)o[s]=n(s);return o}var l8="[object Arguments]";function Mh(e){return ro(e)&&io(e)==l8}var G0=Object.prototype,c8=G0.hasOwnProperty,u8=G0.propertyIsEnumerable,f8=Mh((function(){return arguments})())?Mh:function(e){return ro(e)&&c8.call(e,"callee")&&!u8.call(e,"callee")};function d8(){return!1}var X0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jh=X0&&typeof module=="object"&&module&&!module.nodeType&&module,p8=jh&&jh.exports===X0,Eh=p8?fn.Buffer:void 0,h8=Eh?Eh.isBuffer:void 0,Ff=h8||d8,m8="[object Arguments]",g8="[object Array]",b8="[object Boolean]",x8="[object Date]",v8="[object Error]",w8="[object Function]",y8="[object Map]",_8="[object Number]",k8="[object Object]",M8="[object RegExp]",j8="[object Set]",E8="[object String]",T8="[object WeakMap]",S8="[object ArrayBuffer]",N8="[object DataView]",A8="[object Float32Array]",I8="[object Float64Array]",C8="[object Int8Array]",D8="[object Int16Array]",R8="[object Int32Array]",O8="[object Uint8Array]",$8="[object Uint8ClampedArray]",P8="[object Uint16Array]",L8="[object Uint32Array]",wt={};wt[A8]=wt[I8]=wt[C8]=wt[D8]=wt[R8]=wt[O8]=wt[$8]=wt[P8]=wt[L8]=!0;wt[m8]=wt[g8]=wt[S8]=wt[b8]=wt[N8]=wt[x8]=wt[v8]=wt[w8]=wt[y8]=wt[_8]=wt[k8]=wt[M8]=wt[j8]=wt[E8]=wt[T8]=!1;function F8(e){return ro(e)&&Y0(e.length)&&!!wt[io(e)]}function U8(e){return function(n){return e(n)}}var K0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Za=K0&&typeof module=="object"&&module&&!module.nodeType&&module,z8=Za&&Za.exports===K0,ou=z8&&z0.process,Th=(function(){try{var e=Za&&Za.require&&Za.require("util").types;return e||ou&&ou.binding&&ou.binding("util")}catch{}})(),Sh=Th&&Th.isTypedArray,Z0=Sh?U8(Sh):F8,H8=Object.prototype,B8=H8.hasOwnProperty;function W8(e,n){var s=Zi(e),o=!s&&f8(e),c=!s&&!o&&Ff(e),h=!s&&!o&&!c&&Z0(e),y=s||o||c||h,b=y?i8(e.length,String):[],l=b.length;for(var u in e)B8.call(e,u)&&!(y&&(u=="length"||c&&(u=="offset"||u=="parent")||h&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||r8(u,l)))&&b.push(u);return b}function q8(e,n){return function(s){return e(n(s))}}var Y8=q8(Object.keys,Object),G8=Object.prototype,X8=G8.hasOwnProperty;function K8(e){if(!o8(e))return Y8(e);var n=[];for(var s in Object(e))X8.call(e,s)&&s!="constructor"&&n.push(s);return n}function Z8(e){return s8(e)?W8(e):K8(e)}var no=Js(Object,"create");function V8(){this.__data__=no?no(null):{},this.size=0}function Q8(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}var J8="__lodash_hash_undefined__",ek=Object.prototype,tk=ek.hasOwnProperty;function rk(e){var n=this.__data__;if(no){var s=n[e];return s===J8?void 0:s}return tk.call(n,e)?n[e]:void 0}var nk=Object.prototype,sk=nk.hasOwnProperty;function ak(e){var n=this.__data__;return no?n[e]!==void 0:sk.call(n,e)}var ok="__lodash_hash_undefined__";function ik(e,n){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=no&&n===void 0?ok:n,this}function rs(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}rs.prototype.clear=V8;rs.prototype.delete=Q8;rs.prototype.get=rk;rs.prototype.has=ak;rs.prototype.set=ik;function lk(){this.__data__=[],this.size=0}function il(e,n){for(var s=e.length;s--;)if(q0(e[s][0],n))return s;return-1}var ck=Array.prototype,uk=ck.splice;function fk(e){var n=this.__data__,s=il(n,e);if(s<0)return!1;var o=n.length-1;return s==o?n.pop():uk.call(n,s,1),--this.size,!0}function dk(e){var n=this.__data__,s=il(n,e);return s<0?void 0:n[s][1]}function pk(e){return il(this.__data__,e)>-1}function hk(e,n){var s=this.__data__,o=il(s,e);return o<0?(++this.size,s.push([e,n])):s[o][1]=n,this}function dn(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}dn.prototype.clear=lk;dn.prototype.delete=fk;dn.prototype.get=dk;dn.prototype.has=pk;dn.prototype.set=hk;var so=Js(fn,"Map");function mk(){this.size=0,this.__data__={hash:new rs,map:new(so||dn),string:new rs}}function gk(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function ll(e,n){var s=e.__data__;return gk(n)?s[typeof n=="string"?"string":"hash"]:s.map}function bk(e){var n=ll(this,e).delete(e);return this.size-=n?1:0,n}function xk(e){return ll(this,e).get(e)}function vk(e){return ll(this,e).has(e)}function wk(e,n){var s=ll(this,e),o=s.size;return s.set(e,n),this.size+=s.size==o?0:1,this}function ls(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}ls.prototype.clear=mk;ls.prototype.delete=bk;ls.prototype.get=xk;ls.prototype.has=vk;ls.prototype.set=wk;function yk(e,n){for(var s=-1,o=n.length,c=e.length;++s<o;)e[c+s]=n[s];return e}function _k(){this.__data__=new dn,this.size=0}function kk(e){var n=this.__data__,s=n.delete(e);return this.size=n.size,s}function Mk(e){return this.__data__.get(e)}function jk(e){return this.__data__.has(e)}var Ek=200;function Tk(e,n){var s=this.__data__;if(s instanceof dn){var o=s.__data__;if(!so||o.length<Ek-1)return o.push([e,n]),this.size=++s.size,this;s=this.__data__=new ls(o)}return s.set(e,n),this.size=s.size,this}function Dn(e){var n=this.__data__=new dn(e);this.size=n.size}Dn.prototype.clear=_k;Dn.prototype.delete=kk;Dn.prototype.get=Mk;Dn.prototype.has=jk;Dn.prototype.set=Tk;function Sk(e,n){for(var s=-1,o=e==null?0:e.length,c=0,h=[];++s<o;){var y=e[s];n(y,s,e)&&(h[c++]=y)}return h}function Nk(){return[]}var Ak=Object.prototype,Ik=Ak.propertyIsEnumerable,Nh=Object.getOwnPropertySymbols,Ck=Nh?function(e){return e==null?[]:(e=Object(e),Sk(Nh(e),function(n){return Ik.call(e,n)}))}:Nk;function Dk(e,n,s){var o=n(e);return Zi(e)?o:yk(o,s(e))}function Ah(e){return Dk(e,Z8,Ck)}var Uf=Js(fn,"DataView"),zf=Js(fn,"Promise"),Hf=Js(fn,"Set"),Ih="[object Map]",Rk="[object Object]",Ch="[object Promise]",Dh="[object Set]",Rh="[object WeakMap]",Oh="[object DataView]",Ok=is(Uf),$k=is(so),Pk=is(zf),Lk=is(Hf),Fk=is(Lf),In=io;(Uf&&In(new Uf(new ArrayBuffer(1)))!=Oh||so&&In(new so)!=Ih||zf&&In(zf.resolve())!=Ch||Hf&&In(new Hf)!=Dh||Lf&&In(new Lf)!=Rh)&&(In=function(e){var n=io(e),s=n==Rk?e.constructor:void 0,o=s?is(s):"";if(o)switch(o){case Ok:return Oh;case $k:return Ih;case Pk:return Ch;case Lk:return Dh;case Fk:return Rh}return n});var $h=fn.Uint8Array,Uk="__lodash_hash_undefined__";function zk(e){return this.__data__.set(e,Uk),this}function Hk(e){return this.__data__.has(e)}function Vi(e){var n=-1,s=e==null?0:e.length;for(this.__data__=new ls;++n<s;)this.add(e[n])}Vi.prototype.add=Vi.prototype.push=zk;Vi.prototype.has=Hk;function Bk(e,n){for(var s=-1,o=e==null?0:e.length;++s<o;)if(n(e[s],s,e))return!0;return!1}function Wk(e,n){return e.has(n)}var qk=1,Yk=2;function V0(e,n,s,o,c,h){var y=s&qk,b=e.length,l=n.length;if(b!=l&&!(y&&l>b))return!1;var u=h.get(e),f=h.get(n);if(u&&f)return u==n&&f==e;var p=-1,m=!0,v=s&Yk?new Vi:void 0;for(h.set(e,n),h.set(n,e);++p<b;){var _=e[p],k=n[p];if(o)var M=y?o(k,_,p,n,e,h):o(_,k,p,e,n,h);if(M!==void 0){if(M)continue;m=!1;break}if(v){if(!Bk(n,function(T,A){if(!Wk(v,A)&&(_===T||c(_,T,s,o,h)))return v.push(A)})){m=!1;break}}else if(!(_===k||c(_,k,s,o,h))){m=!1;break}}return h.delete(e),h.delete(n),m}function Gk(e){var n=-1,s=Array(e.size);return e.forEach(function(o,c){s[++n]=[c,o]}),s}function Xk(e){var n=-1,s=Array(e.size);return e.forEach(function(o){s[++n]=o}),s}var Kk=1,Zk=2,Vk="[object Boolean]",Qk="[object Date]",Jk="[object Error]",eM="[object Map]",tM="[object Number]",rM="[object RegExp]",nM="[object Set]",sM="[object String]",aM="[object Symbol]",oM="[object ArrayBuffer]",iM="[object DataView]",Ph=Gs?Gs.prototype:void 0,iu=Ph?Ph.valueOf:void 0;function lM(e,n,s,o,c,h,y){switch(s){case iM:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case oM:return!(e.byteLength!=n.byteLength||!h(new $h(e),new $h(n)));case Vk:case Qk:case tM:return q0(+e,+n);case Jk:return e.name==n.name&&e.message==n.message;case rM:case sM:return e==n+"";case eM:var b=Gk;case nM:var l=o&Kk;if(b||(b=Xk),e.size!=n.size&&!l)return!1;var u=y.get(e);if(u)return u==n;o|=Zk,y.set(e,n);var f=V0(b(e),b(n),o,c,h,y);return y.delete(e),f;case aM:if(iu)return iu.call(e)==iu.call(n)}return!1}var cM=1,uM=Object.prototype,fM=uM.hasOwnProperty;function dM(e,n,s,o,c,h){var y=s&cM,b=Ah(e),l=b.length,u=Ah(n),f=u.length;if(l!=f&&!y)return!1;for(var p=l;p--;){var m=b[p];if(!(y?m in n:fM.call(n,m)))return!1}var v=h.get(e),_=h.get(n);if(v&&_)return v==n&&_==e;var k=!0;h.set(e,n),h.set(n,e);for(var M=y;++p<l;){m=b[p];var T=e[m],A=n[m];if(o)var C=y?o(A,T,m,n,e,h):o(T,A,m,e,n,h);if(!(C===void 0?T===A||c(T,A,s,o,h):C)){k=!1;break}M||(M=m=="constructor")}if(k&&!M){var O=e.constructor,$=n.constructor;O!=$&&"constructor"in e&&"constructor"in n&&!(typeof O=="function"&&O instanceof O&&typeof $=="function"&&$ instanceof $)&&(k=!1)}return h.delete(e),h.delete(n),k}var pM=1,Lh="[object Arguments]",Fh="[object Array]",Pi="[object Object]",hM=Object.prototype,Uh=hM.hasOwnProperty;function mM(e,n,s,o,c,h){var y=Zi(e),b=Zi(n),l=y?Fh:In(e),u=b?Fh:In(n);l=l==Lh?Pi:l,u=u==Lh?Pi:u;var f=l==Pi,p=u==Pi,m=l==u;if(m&&Ff(e)){if(!Ff(n))return!1;y=!0,f=!1}if(m&&!f)return h||(h=new Dn),y||Z0(e)?V0(e,n,s,o,c,h):lM(e,n,l,s,o,c,h);if(!(s&pM)){var v=f&&Uh.call(e,"__wrapped__"),_=p&&Uh.call(n,"__wrapped__");if(v||_){var k=v?e.value():e,M=_?n.value():n;return h||(h=new Dn),c(k,M,s,o,h)}}return m?(h||(h=new Dn),dM(e,n,s,o,c,h)):!1}function Q0(e,n,s,o,c){return e===n?!0:e==null||n==null||!ro(e)&&!ro(n)?e!==e&&n!==n:mM(e,n,s,o,Q0,c)}function gM(e,n){return Q0(e,n)}const zh=({className:e,children:n,colSpan:s,sticky:o=!1,...c})=>{const h=ve("!py-2 !pl-0 !pr-6 text-left align-top",o&&"sticky top-0 bg-white",c.onClick&&"hover:cursor-pointer",e);return a.jsx("th",{className:h,colSpan:s,...c,children:a.jsx(xt,{className:"whitespace-nowrap",level:6,children:n})})},J0=({left:e,center:n,right:s,sticky:o=!0,containerClassName:c,children:h})=>{const y=ve("z-50 h-22 min-h-[92px] p-8",!h&&"flex items-center justify-between gap-3",o&&"sticky top-0",c);if(!h){if(e){const b=ve("flex flex-auto items-center",s&&n&&"basis-1/3",!s&&n&&"basis-1/2");e=a.jsx("div",{className:b,children:e})}if(n){const b=ve("flex flex-auto items-center justify-center",e&&s&&"basis-1/3",(e&&!s||!e&&s)&&"basis-1/2");n=a.jsx("div",{className:b,children:n})}if(s){const b=ve("flex flex-auto items-center justify-end",e&&n&&"basis-1/3",!e&&n&&"basis-1/2");s=a.jsx("div",{className:b,children:s})}}return a.jsx("div",{className:y,children:h||a.jsxs(a.Fragment,{children:[e,n,s]})})},eb=({items:e,setItems:n,blank:s,canAddNewItem:o})=>{const[c,h]=D.useState(e.map((m,v)=>({item:m,id:v.toString()}))),[y,b]=D.useState(s);return D.useEffect(()=>{const m=c.map(({item:v})=>v);o(y)&&m.push(y),gM(JSON.parse(JSON.stringify(m)),JSON.parse(JSON.stringify(e)))||n(m)},[c,y,e,n,o]),{items:c,updateItem:(m,v)=>{const _=c.map(k=>k.id===m?{...k,item:v}:k);h(_),n(_.map(k=>k.item))},addItem:()=>{if(o(y)){const m=c.reduce((_,k)=>Math.max(_,parseInt(k.id)),0),v=c.concat({item:y,id:(m+1).toString()});h(v),n(v.map(_=>_.item)),b(s)}},removeItem:m=>{const v=c.filter(_=>_.id!==m);h(v),n(v.map(_=>_.item))},moveItem:(m,v)=>{if(m!==v){const _=c.findIndex(T=>T.id===m),k=v?c.findIndex(T=>T.id===v):0,M=N_(c,_,k);h(M),n(M.map(T=>T.item))}},newItem:y,setNewItem:b}},bM=({label:e,text:n="",hint:s,onRegenerate:o})=>{const[c,h]=D.useState(!1),y=()=>{navigator.clipboard.writeText(n),h(!0),setTimeout(()=>h(!1),2e3)},b=ve("group/api-keys relative -mt-1 mb-1 w-full overflow-hidden border-b border-transparent py-2 hover:border-grey-300 dark:hover:border-grey-600");return a.jsxs("div",{className:"mb-3 grid grid-cols-1",children:[e&&a.jsx(xt,{level:6,grey:!0,children:e}),a.jsxs("div",{className:b,children:[a.jsx("span",{children:n}),s,a.jsxs("div",{className:"visible absolute right-0 top-1/2 flex translate-y-[-50%] gap-1 bg-white pl-1 text-sm group-hover/api-keys:visible md:invisible dark:bg-black",children:[o&&a.jsx(Ue,{color:"outline",label:"Regenerate",size:"sm",onClick:o}),a.jsx(Ue,{color:"outline",label:c?"Copied":"Copy",size:"sm",onClick:y})]})]})]})},hd=({keys:e})=>a.jsx("div",{"data-testid":"api-keys",children:e.map(n=>a.jsx(bM,{...n},n.label))}),lo=({icon:e,title:n,detail:s,extra:o})=>a.jsxs("div",{className:"-mx-8 -mt-8 flex flex-col gap-4 bg-grey-75 p-8 md:flex-row dark:bg-grey-950",children:[a.jsx("div",{className:"size-14",children:e}),a.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-1 flex-col",children:[a.jsx("h3",{children:n}),a.jsx("div",{children:s}),o&&a.jsx("div",{className:"mt-4",children:o})]})]}),tb=ss({method:"POST",path:({integrationId:e,apiKeyId:n})=>`/integrations/${e}/api_key/${n}/refresh/`,body:({integrationId:e})=>({integrations:[{id:e}]}),updateQueries:{emberUpdateType:"createOrUpdate",dataType:tl,update:(e,n)=>n&&{...n,integrations:n.integrations.map(s=>e.integrations.find(({id:c})=>c===s.id)||s)}}}),xM=_e.create(()=>{const e=_e.useModal(),{updateRoute:n}=Je(),{zapierTemplates:s}=A_(),{data:{integrations:o}={integrations:[]}}=Wg(),{config:c}=et(),{mutateAsync:h}=tb(),y=it(),[b,l]=D.useState(!1),u=c.hostSettings?.limits?.customIntegrations?.disabled,f=o.find(({slug:v})=>v==="zapier"),p=f?.api_keys?.find(v=>v.type==="admin");D.useEffect(()=>{u&&n("integrations")},[u,n]);const m=()=>{!f||!p||(l(!1),_e.show(St,{title:"Regenerate Admin API Key",prompt:'You will need to locate the Ghost App within your Zapier account and click on "Reconnect" to enter the new Admin API Key.',okLabel:"Regenerate Admin API Key",onOk:async v=>{try{await h({integrationId:f.id,apiKeyId:p.id}),l(!0),v?.remove()}catch(_){y(_)}}}))};return a.jsxs(_t,{afterClose:()=>{n("integrations")},cancelLabel:"",footer:a.jsxs("div",{className:"mx-8 flex w-full items-center justify-between",children:[a.jsxs("a",{className:"mt-1 self-baseline text-sm font-bold",href:"https://zapier.com/apps/ghost/integrations?utm_medium=partner_api&utm_source=widget&utm_campaign=Widget",rel:"noopener noreferrer",target:"_blank",children:["View more Ghost integrations powered by ",a.jsx("span",{children:a.jsx(ut,{className:"relative top-[-2px] inline-block",name:"zapier-logo",size:24})})]}),a.jsx(Ue,{color:"black",label:"Close",onClick:()=>{e.remove()}})]}),okColor:"black",okLabel:"Close",testId:"zapier-modal",title:"",stickyFooter:!0,onOk:()=>{n("integrations"),e.remove()},children:[a.jsx(lo,{detail:"Automation for your favorite apps",extra:a.jsx("div",{className:"-mb-4 mt-1",children:a.jsx(hd,{keys:[{label:"Admin API key",text:p?.secret,hint:b?a.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:m},{label:"API URL",text:window.location.origin+rl().subdir}]})}),icon:a.jsx(ut,{name:"zapier",size:56}),title:"Zapier"}),a.jsx(ln,{children:s.map(v=>a.jsx(On,{action:a.jsx(Ue,{className:"whitespace-nowrap text-sm font-semibold text-[#FF4A00]",href:v.url,label:"Use this Zap",tag:"a",target:"_blank",link:!0,unstyled:!0}),bgOnHover:!1,className:"flex items-center gap-3 py-2 pl-3",title:a.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[a.jsxs("div",{className:"flex shrink-0 flex-nowrap items-center gap-2",children:[a.jsx("img",{className:"size-8 object-contain dark:invert",role:"presentation",src:v.ghostImage}),a.jsx(ut,{name:"arrow-right",size:"xs"}),a.jsx("img",{className:"size-8 object-contain",role:"presentation",src:v.appImage})]}),a.jsx("span",{className:"text-sm",children:v.title})]}),hideActions:!0}))})]})});function rb(e){const n="The URL must be in a format like https://www.threads.net/@yourUsername";if(!e)return"";if(e.startsWith("http")){if(!e.includes("threads.net")&&!e.includes("threads.com"))throw new Error(n);if(e=e.replace("threads.com","threads.net"),e.includes("www.")||(e=e.replace("https://","https://www.")),!Nt.isURL(e))throw new Error(n);if(!e.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(n);return e}if(!e.includes("/")){if(e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-zA-Z0-9._]+$/))throw new Error(n);return`https://www.threads.net/@${e}`}throw new Error(n)}const vM=e=>`https://www.threads.net/${e}`,wM=e=>{const n=e.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return n?`@${n}`:null},qs={INVALID_USERNAME:"Your Username is not a valid Bluesky Username",INVALID_URL:"The URL must be in a format like https://bsky.app/profile/yourUsername"};function nb(e){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(s=>s.test(e))}function Bf(e){let n=e.trim();return n.startsWith("@")&&(n=n.slice(1)),n.startsWith("did:plc:")?n.toLowerCase():n}function sb(e){if(!e)return"";let n;if(e.startsWith("http")||e.startsWith("www.")||e.includes("bsky.app")){if(!e.includes("bsky.app"))throw new Error(qs.INVALID_URL);const o=e.match(/bsky\.app\/profile\/@?([^/]+)/);if(!o)throw new Error(qs.INVALID_URL);n=Bf(o[1])}else n=Bf(e);if(!nb(n))throw new Error(qs.INVALID_USERNAME);const s=`https://bsky.app/profile/${n}`;if(!Nt.isURL(s))throw new Error(qs.INVALID_URL);return s}const yM=e=>{if(!e)throw new Error(qs.INVALID_USERNAME);let n=Bf(e);if(!nb(n))throw new Error(qs.INVALID_USERNAME);return`https://bsky.app/profile/${n}`},_M=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return n?`${n[1]}`:null},es={INVALID_URL:"The URL must be in a format like https://www.linkedin.com/in/yourUsername",INVALID_USERNAME:"Your Username is not a valid LinkedIn Username"},kM=["in","pub","company","school"],MM=/^[a-zA-Z0-9-]{3,100}$/,jM=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,ab=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,Wf=e=>e.trim().replace(/^@/,""),ob=e=>{if(/^(https?:\/\/|www\.)/.test(e)||e.includes("linkedin.com")){const o=e.match(ab);if(!o)throw new Error(es.INVALID_URL);if(o[0].length!==e.length)throw new Error(es.INVALID_USERNAME);const[,c,h,y]=o,b=Wf(y);if(c&&!/^[A-Z]{2}$/.test(c.toUpperCase()))throw new Error(es.INVALID_URL);return{regional:c,pathType:h,username:b}}const n=Wf(e),s=n.indexOf("/");if(s!==-1){const o=n.substring(0,s);if(kM.includes(o))return{pathType:o,username:n.substring(s+1)}}return{username:n}},ib=(e,n)=>(e==="pub"?jM:MM).test(n),lb=({regional:e,pathType:n,username:s})=>{const c=`https://${e?`${e.toLowerCase()}.`:"www."}linkedin.com/${n}/${s}`;if(!Nt.isURL(c))throw new Error(es.INVALID_URL);return c};function cb(e){if(!e)return"";const{regional:n,pathType:s="in",username:o}=ob(e);if(!ib(s,o))throw new Error(es.INVALID_USERNAME);return lb({regional:n,pathType:s,username:o})}const EM=e=>{if(!e)throw new Error(es.INVALID_USERNAME);const{regional:n,pathType:s="in",username:o}=ob(e);if(!ib(s,o))throw new Error(es.INVALID_USERNAME);return lb({regional:n,pathType:s,username:o})},TM=e=>{const n=e.match(ab);if(!n)return null;const[,,s,o]=n,c=Wf(o);return s==="in"?c:`${s}/${c}`};function ub(e){const n="The URL must be in a format like https://www.instagram.com/yourUsername",s="Your Username is not a valid Instagram Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("instagram.com")){if(!e.includes("instagram.com"))throw new Error(n);const h=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!h)throw new Error(n);o=h[1]}else o=e.startsWith("@")?e.slice(1):e;if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||o.includes("..")||o.length>30)throw new Error(s);const c=`https://www.instagram.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const SM=e=>{const n="Your Username is not a valid Instagram Username";if(!e)throw new Error(n);let s=e;if(s.startsWith("@")&&(s=s.slice(1)),!s.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||s.includes("..")||s.length>30)throw new Error(n);return`https://www.instagram.com/${s}`},NM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return n?`${n[1]}`:null};function fb(e){const n="The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId",s="Your Username is not a valid YouTube Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("youtube.com")){if(!e.includes("youtube.com"))throw new Error(n);const h=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!h)throw new Error(n);o=h[1]}else o=e;if(o.startsWith("@")){const h=o.slice(1);if(!h.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||h.includes("..")||h.length>30)throw new Error(s)}else if(o.startsWith("user/")){if(!o.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(s)}else if(o.startsWith("channel/")){if(!o.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(s)}else throw new Error(n);const c=`https://www.youtube.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const AM=e=>{const n="Your Username is not a valid YouTube Username";if(!e)throw new Error(n);if(e.startsWith("@")){const s=e.slice(1);if(!s.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||s.includes("..")||s.length>30)throw new Error(n)}else if(e.startsWith("user/")){if(!e.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(e.startsWith("channel/")){if(!e.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${e}`},IM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return n?n[1]:null};function db(e){const n="The URL must be in a format like https://www.tiktok.com/@yourUsername",s="Your Username is not a valid TikTok Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("tiktok.com")){if(!e.includes("tiktok.com"))throw new Error(n);const y=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!y)throw new Error(n);o=y[1]}else o=e.startsWith("@")?e:`@${e}`;const c=o.slice(1);if(!c.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||c.includes("..")||c.length<2||c.length>24)throw new Error(s);const h=`https://www.tiktok.com/${o}`;if(!Nt.isURL(h))throw new Error(n);return h}const CM=e=>{const n="Your Username is not a valid TikTok Username";if(!e)throw new Error(n);const s=e.startsWith("@")?e:`@${e}`,o=s.slice(1);if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||o.includes("..")||o.length<2||o.length>24)throw new Error(n);return`https://www.tiktok.com/${s}`},DM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return n?n[1]:null};function pb(e){const n="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!e)return"";let s=e;if(s=s.replace(/^https?:\/\//,""),s.match(/^@[^@]+@[^/]+$/)){const[o,c]=s.split("@").slice(1);if(!Nt.isFQDN(c))throw new Error(n);return`https://${c}/@${o}`}if(s.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[o,c]=s.split("/@");if(!Nt.isFQDN(o))throw new Error(n);if(c.includes("@")){const[,h]=c.split("@");if(!Nt.isFQDN(h))throw new Error(n)}return`https://${s}`}throw new Error(n)}const RM=e=>{const n="Your Username is not a valid Mastodon Username";if(!e)throw new Error(n);if(e.match(/^@[^@]+@[^/]+$/)){const[s,o]=e.split("@").slice(1);if(!Nt.isFQDN(o))throw new Error(n);return`https://${o}/@${s}`}if(e.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[s,o]=e.split("/@");if(!Nt.isFQDN(s))throw new Error(n);if(o.includes("@")){const[,c]=o.split("@");if(!Nt.isFQDN(c))throw new Error(n)}return`https://${e}`}throw new Error(n)},OM=e=>e.replace(/^https?:\/\//,""),$M=({tier:e})=>{const n=e?.type==="free",{updateRoute:s}=Je(),{mutateAsync:o}=Qf(),{mutateAsync:c}=I_(),{mutateAsync:h}=as(),[y,b]=st.useState(!!e?.trial_days),l=it(),{localSettings:u,siteData:f}=os(),[p]=bt(u,["portal_plans"]),m=JSON.parse(p?.toString()||"[]"),v={name:()=>_.name?void 0:"Enter a name for the tier",monthly_price:()=>_.type!=="free"?ih(_.monthly_price||0,_.currency,{allowZero:!1}):void 0,yearly_price:()=>_.type!=="free"?ih(_.yearly_price||0,_.currency,{allowZero:!1}):void 0},{formState:_,saveState:k,updateForm:M,handleSave:T,errors:A,clearError:C,okProps:O}=kr({initialState:{...e||{},trial_days:e?.trial_days?.toString()||"",currency:e?.currency||C_[0].isoCode,visibility:e?.visibility||"none",welcome_page_url:e?.welcome_page_url||null},savingDelay:500,savedDelay:500,onValidate:()=>{const G={};return Object.entries(v).forEach(([W,q])=>{G[W]=q?.()}),G},onSave:async()=>{const{trial_days:G,currency:W,...q}=_,se=q;if(se.benefits=se.benefits?.filter(J=>J),n||(se.currency=W,se.trial_days=parseInt(G)),e?.id?await o({...e,...se}):await c(se),n){const J=_.visibility==="public";let te=!1;m.includes("free")&&!J&&(m.splice(m.indexOf("free"),1),te=!0),!m.includes("free")&&J&&(m.push("free"),te=!0),te&&await h([{key:"portal_plans",value:JSON.stringify(m)}])}},onSaveError:l}),$=eb({items:_.benefits||[],setItems:G=>M(W=>({...W,benefits:G})),blank:"",canAddNewItem:G=>!!G}),B=G=>{G.target.checked?(b(!0),M(W=>({...W,trial_days:e?.trial_days?e?.trial_days.toString():"7"}))):(b(!1),M(W=>({...W,trial_days:"0"})))},R=D.useRef(!1);D.useEffect(()=>{R.current&&(v.monthly_price?.(),v.yearly_price?.()),R.current=!0},[_.currency]);const V=()=>{if(e){const G=e.active?"Archive tier":"Reactivate tier",W=e.active?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:["Members will no longer be able to subscribe to ",a.jsx("strong",{children:e.name})," and it will be removed from the list of available tiers in portal."]}),a.jsx("div",{children:"Existing members on this tier will remain unchanged. Offers using this tier will be disabled."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:["Reactivating ",a.jsx("strong",{children:e.name})," will re-enable it as an option in portal and allow new members to subscribe to this tier."]}),a.jsx("div",{children:"Existing members will remain unchanged."})]}),q=e.active?"Archive":"Reactivate";_e.show(St,{title:G,prompt:W,okLabel:q,cancelLabel:"Cancel",okColor:e.active?"red":"black",onOk:se=>{o({...e,active:!e.active}),se?.remove(),gt({type:"success",title:`Tier ${e.active?"archived":"reactivated"}`})}})}};let K={};return e&&(e.active&&e.type!=="free"?K={label:"Archive tier",color:"red",link:!0,onClick:V}:e.active||(K={label:"Reactivate tier",color:"green",link:!0,onClick:V})),a.jsx(_t,{afterClose:()=>{s("tiers")},buttonsDisabled:O.disabled,cancelLabel:"Close",dirty:k==="unsaved",leftButtonProps:K,okColor:O.color,okLabel:O.label||"Save",size:"lg",testId:"tier-detail-modal",title:e?e.active?"Edit tier":"Edit archived tier":"New tier",stickyFooter:!0,onOk:async()=>{await T({fakeWhenUnchanged:!0})},children:a.jsxs("div",{className:"-mb-8 mt-8 flex items-start gap-8",children:[a.jsxs("div",{className:"flex grow flex-col gap-8",children:[a.jsxs(rt,{marginBottom:!1,title:"Basic",grouped:!0,children:[a.jsx(Ne,{autoComplete:"off",error:!!A.name,hint:A.name,maxLength:191,placeholder:n?"Free":"Bronze",title:"Name",value:_.name||"",autoFocus:!0,onChange:G=>M(W=>({...W,name:G.target.value})),onKeyDown:()=>C("name")}),a.jsx(Ne,{autoComplete:"off",autoFocus:n,maxLength:191,placeholder:n?"Free preview":"Full access to premium content",title:"Description",value:_.description||"",onChange:G=>M(W=>({...W,description:G.target.value}))}),!n&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex flex-col gap-10 md:flex-row",children:[a.jsxs("div",{className:"basis-1/2",children:[a.jsxs("div",{className:"mb-1 flex h-6 items-center justify-between",children:[a.jsx(xt,{level:6,children:"Prices"}),a.jsx("div",{className:"-mr-2 w-[50px]",children:a.jsx(Pt,{border:!1,containerClassName:"font-medium",controlClasses:{menu:"w-18"},options:lh(),selectedOption:lh().flatMap(G=>G.options).find(G=>G.value===_.currency),size:"xs",clearBg:!0,isSearchable:!0,onSelect:G=>M(W=>({...W,currency:G?.value}))})})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(ch,{error:!!A.monthly_price,hint:A.monthly_price,placeholder:"5",rightPlaceholder:`${_.currency}/month`,title:"Monthly price",valueInCents:_.monthly_price||"",hideTitle:!0,onBlur:G=>G.target.value===""?M(W=>({...W,monthly_price:0})):null,onChange:G=>M(W=>({...W,monthly_price:G})),onKeyDown:()=>C("monthly_price")}),a.jsx(ch,{error:!!A.yearly_price,hint:A.yearly_price,placeholder:"50",rightPlaceholder:`${_.currency}/year`,title:"Yearly price",valueInCents:_.yearly_price||"",hideTitle:!0,onBlur:G=>G.target.value===""?M(W=>({...W,yearly_price:0})):null,onChange:G=>M(W=>({...W,yearly_price:G})),onKeyDown:()=>C("yearly_price")})]})]}),a.jsxs("div",{className:"basis-1/2",children:[a.jsx("div",{className:"mb-1 flex h-6 flex-col justify-center",children:a.jsx(ot,{checked:y,label:"Add a free trial",labelStyle:"heading",onChange:B})}),a.jsx(Ne,{disabled:!y,hint:a.jsxs("div",{className:"mt-1",children:["Members will be subscribed at full price once the trial ends. ",a.jsx("a",{className:"text-green",href:"https://ghost.org/help/free-trials/",rel:"noreferrer",target:"_blank",children:"Learn more"})]}),placeholder:"0",rightPlaceholder:"days",title:"Trial days",value:_.trial_days,hideTitle:!0,onChange:G=>M(W=>({...W,trial_days:G.target.value.replace(/[^\d]/,"")}))})]})]})}),a.jsx(qg,{baseUrl:f?.url,hint:`Redirect to this URL after signup ${n?"":" for premium membership"}`,maxLength:2e3,placeholder:f?.url,title:"Welcome page",value:_.welcome_page_url||null,nullable:!0,transformPathWithoutSlash:!0,onChange:G=>M(W=>({...W,welcome_page_url:G||null}))})]}),a.jsxs(rt,{gap:"none",title:"Benefits",grouped:!0,children:[a.jsx("div",{className:"-mt-3",children:a.jsx(Yg,{items:$.items,itemSeparator:!1,renderItem:({id:G,item:W})=>a.jsxs("div",{className:"relative flex w-full items-center gap-5",children:[a.jsx("div",{className:"absolute left-[-32px] top-[7px] flex size-6 items-center justify-center bg-white group-hover:hidden dark:bg-black",children:a.jsx(ut,{name:"check",size:"sm"})}),a.jsx(Ne,{maxLength:191,value:W,onChange:q=>$.updateItem(G,q.target.value)}),a.jsx(Ue,{className:"absolute right-1 top-1 z-10 opacity-0 group-hover:opacity-100",color:"grey",icon:"trash",size:"sm",onClick:()=>$.removeItem(G)})]}),onMove:$.moveItem})}),a.jsxs("div",{className:"relative mt-1 flex items-center gap-3",children:[a.jsx(ut,{className:"dark:text-white",name:"check",size:"sm"}),a.jsx(Ne,{className:"grow",containerClassName:"w-100",maxLength:191,placeholder:"Expert analysis",title:"New benefit",value:$.newItem,hideTitle:!0,onChange:G=>$.setNewItem(G.target.value),onKeyDown:G=>{G.key==="Enter"&&$.addItem()}}),a.jsx(Ue,{className:"absolute right-[5px] top-[5px] z-10",color:"green",icon:"add",iconColorClass:"text-white",label:"Add",size:"sm",hideLabel:!0,onClick:()=>$.addItem()})]})]})]}),a.jsx("div",{className:"sticky top-[96px] hidden shrink-0 basis-[380px] min-[920px]:!visible min-[920px]:!block",children:a.jsx(D_,{isFreeTier:n,tier:_})})]})})},PM=({params:e})=>{const{data:{tiers:n,isEnd:s}={},fetchNextPage:o}=oo();let c;return D.useEffect(()=>{e?.id&&!c&&!s&&o()},[o,s,e?.id,c]),e?.id&&(c=n?.find(({id:h})=>h===e?.id),!c)?null:a.jsx($M,{tier:c})},LM=_e.create(PM);var lu,Hh;function hb(){if(Hh)return lu;Hh=1;var e={};return lu=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...s)=>console.error("SEMVER",...s):()=>{},lu}var cu,Bh;function mb(){if(Bh)return cu;Bh=1;const e="2.0.0",n=256,s=Number.MAX_SAFE_INTEGER||9007199254740991,o=16,c=n-6;return cu={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:c,MAX_SAFE_INTEGER:s,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},cu}var Li={exports:{}},Wh;function FM(){return Wh||(Wh=1,(function(e,n){const{MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:c}=mb(),h=hb();n=e.exports={};const y=n.re=[],b=n.safeRe=[],l=n.src=[],u=n.safeSrc=[],f=n.t={};let p=0;const m="[a-zA-Z0-9-]",v=[["\\s",1],["\\d",c],[m,o]],_=M=>{for(const[T,A]of v)M=M.split(`${T}*`).join(`${T}{0,${A}}`).split(`${T}+`).join(`${T}{1,${A}}`);return M},k=(M,T,A)=>{const C=_(T),O=p++;h(M,O,T),f[M]=O,l[O]=T,u[O]=C,y[O]=new RegExp(T,A?"g":void 0),b[O]=new RegExp(C,A?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),k("MAINVERSION",`(${l[f.NUMERICIDENTIFIER]})\\.(${l[f.NUMERICIDENTIFIER]})\\.(${l[f.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${l[f.NUMERICIDENTIFIERLOOSE]})\\.(${l[f.NUMERICIDENTIFIERLOOSE]})\\.(${l[f.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${l[f.NONNUMERICIDENTIFIER]}|${l[f.NUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${l[f.NONNUMERICIDENTIFIER]}|${l[f.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASE",`(?:-(${l[f.PRERELEASEIDENTIFIER]}(?:\\.${l[f.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${l[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[f.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${m}+`),k("BUILD",`(?:\\+(${l[f.BUILDIDENTIFIER]}(?:\\.${l[f.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${l[f.MAINVERSION]}${l[f.PRERELEASE]}?${l[f.BUILD]}?`),k("FULL",`^${l[f.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${l[f.MAINVERSIONLOOSE]}${l[f.PRERELEASELOOSE]}?${l[f.BUILD]}?`),k("LOOSE",`^${l[f.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${l[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${l[f.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${l[f.XRANGEIDENTIFIER]})(?:\\.(${l[f.XRANGEIDENTIFIER]})(?:\\.(${l[f.XRANGEIDENTIFIER]})(?:${l[f.PRERELEASE]})?${l[f.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${l[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[f.XRANGEIDENTIFIERLOOSE]})(?:${l[f.PRERELEASELOOSE]})?${l[f.BUILD]}?)?)?`),k("XRANGE",`^${l[f.GTLT]}\\s*${l[f.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${l[f.GTLT]}\\s*${l[f.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${s}})(?:\\.(\\d{1,${s}}))?(?:\\.(\\d{1,${s}}))?`),k("COERCE",`${l[f.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",l[f.COERCEPLAIN]+`(?:${l[f.PRERELEASE]})?(?:${l[f.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",l[f.COERCE],!0),k("COERCERTLFULL",l[f.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${l[f.LONETILDE]}\\s+`,!0),n.tildeTrimReplace="$1~",k("TILDE",`^${l[f.LONETILDE]}${l[f.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${l[f.LONETILDE]}${l[f.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${l[f.LONECARET]}\\s+`,!0),n.caretTrimReplace="$1^",k("CARET",`^${l[f.LONECARET]}${l[f.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${l[f.LONECARET]}${l[f.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${l[f.GTLT]}\\s*(${l[f.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${l[f.GTLT]}\\s*(${l[f.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${l[f.GTLT]}\\s*(${l[f.LOOSEPLAIN]}|${l[f.XRANGEPLAIN]})`,!0),n.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${l[f.XRANGEPLAIN]})\\s+-\\s+(${l[f.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${l[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[f.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Li,Li.exports)),Li.exports}var uu,qh;function UM(){if(qh)return uu;qh=1;const e=Object.freeze({loose:!0}),n=Object.freeze({});return uu=o=>o?typeof o!="object"?e:o:n,uu}var fu,Yh;function zM(){if(Yh)return fu;Yh=1;const e=/^[0-9]+$/,n=(o,c)=>{if(typeof o=="number"&&typeof c=="number")return o===c?0:o<c?-1:1;const h=e.test(o),y=e.test(c);return h&&y&&(o=+o,c=+c),o===c?0:h&&!y?-1:y&&!h?1:o<c?-1:1};return fu={compareIdentifiers:n,rcompareIdentifiers:(o,c)=>n(c,o)},fu}var du,Gh;function HM(){if(Gh)return du;Gh=1;const e=hb(),{MAX_LENGTH:n,MAX_SAFE_INTEGER:s}=mb(),{safeRe:o,t:c}=FM(),h=UM(),{compareIdentifiers:y}=zM();class b{constructor(u,f){if(f=h(f),u instanceof b){if(u.loose===!!f.loose&&u.includePrerelease===!!f.includePrerelease)return u;u=u.version}else if(typeof u!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof u}".`);if(u.length>n)throw new TypeError(`version is longer than ${n} characters`);e("SemVer",u,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const p=u.trim().match(f.loose?o[c.LOOSE]:o[c.FULL]);if(!p)throw new TypeError(`Invalid Version: ${u}`);if(this.raw=u,this.major=+p[1],this.minor=+p[2],this.patch=+p[3],this.major>s||this.major<0)throw new TypeError("Invalid major version");if(this.minor>s||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>s||this.patch<0)throw new TypeError("Invalid patch version");p[4]?this.prerelease=p[4].split(".").map(m=>{if(/^[0-9]+$/.test(m)){const v=+m;if(v>=0&&v<s)return v}return m}):this.prerelease=[],this.build=p[5]?p[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(u){if(e("SemVer.compare",this.version,this.options,u),!(u instanceof b)){if(typeof u=="string"&&u===this.version)return 0;u=new b(u,this.options)}return u.version===this.version?0:this.compareMain(u)||this.comparePre(u)}compareMain(u){return u instanceof b||(u=new b(u,this.options)),this.major<u.major?-1:this.major>u.major?1:this.minor<u.minor?-1:this.minor>u.minor?1:this.patch<u.patch?-1:this.patch>u.patch?1:0}comparePre(u){if(u instanceof b||(u=new b(u,this.options)),this.prerelease.length&&!u.prerelease.length)return-1;if(!this.prerelease.length&&u.prerelease.length)return 1;if(!this.prerelease.length&&!u.prerelease.length)return 0;let f=0;do{const p=this.prerelease[f],m=u.prerelease[f];if(e("prerelease compare",f,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return y(p,m)}while(++f)}compareBuild(u){u instanceof b||(u=new b(u,this.options));let f=0;do{const p=this.build[f],m=u.build[f];if(e("build compare",f,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return y(p,m)}while(++f)}inc(u,f,p){if(u.startsWith("pre")){if(!f&&p===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const m=`-${f}`.match(this.options.loose?o[c.PRERELEASELOOSE]:o[c.PRERELEASE]);if(!m||m[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(u){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,p);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,p);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,p),this.inc("pre",f,p);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,p),this.inc("pre",f,p);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const m=Number(p)?1:0;if(this.prerelease.length===0)this.prerelease=[m];else{let v=this.prerelease.length;for(;--v>=0;)typeof this.prerelease[v]=="number"&&(this.prerelease[v]++,v=-2);if(v===-1){if(f===this.prerelease.join(".")&&p===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(m)}}if(f){let v=[f,m];p===!1&&(v=[f]),y(this.prerelease[0],f)===0?isNaN(this.prerelease[1])&&(this.prerelease=v):this.prerelease=v}break}default:throw new Error(`invalid increment argument: ${u}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return du=b,du}var pu,Xh;function BM(){if(Xh)return pu;Xh=1;const e=HM();return pu=(s,o,c=!1)=>{if(s instanceof e)return s;try{return new e(s,o)}catch(h){if(!c)return null;throw h}},pu}var WM=BM();const qM=Gg(WM);function Kh(e){if(!e)return"";const n=e.replace("+moya","");try{const o=qM(n,{includePrerelease:!0})?.prerelease;if(o&&o?.length>0){const h=String(o[0]).split("-")[1];return!h||!h.startsWith("g")?"":`https://github.com/TryGhost/Ghost/commit/${h.slice(1)}`}return`https://github.com/TryGhost/Ghost/releases/tag/v${n}`}catch{return""}}function YM(e,n){const s=!!e.match?.(/production/i);return!!(s&&n!=="mysql8"||!s&&n==="mysql5")}const GM=_e.create(({})=>{const{updateRoute:e}=Je();let s=et().config;const o=R_();function c(){return new Date().getFullYear()}function h(){return!!s.enableDeveloperExperiments}function y(){return!s.hostSettings?.siteId}return a.jsx(_t,{afterClose:()=>{e("")},cancelLabel:"",footer:a.jsx(a.Fragment,{}),topRightContent:"close",width:540,children:a.jsxs("div",{className:"flex flex-col gap-4 pb-7 text-sm",children:[a.jsx(O_,{className:"h-auto w-[120px] dark:invert"}),a.jsxs("div",{className:"mt-3 flex flex-col gap-1.5",children:[o?.message&&a.jsxs("div",{className:"gh-prose-links mb-4 rounded-sm border border-green p-5",children:[a.jsx("strong",{children:"Update available!"}),a.jsx("div",{dangerouslySetInnerHTML:{__html:o.message}})]}),Kh(s.version)&&a.jsxs("div",{children:[a.jsx("strong",{children:"Version:"})," ",a.jsx("a",{className:"text-green",href:Kh(s.version),rel:"noopener noreferrer",target:"_blank",children:s.version})]})||a.jsxs("div",{children:[a.jsx("strong",{children:"Version:"})," ",s.version]}),y()&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Environment:"})," ",s.environment]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Database:"})," ",s.database]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Mail:"})," ",s.mail?s.mail:"Native"]})]}),h()&&a.jsxs("div",{children:[a.jsx("strong",{children:"Developer experiments:"})," Enabled"]}),y()&&YM(s.environment,s.database)&&a.jsxs("div",{className:"text-red-500 dark:text-red-400",children:["You are running an unsupported database in production. Please ",a.jsx("a",{href:"https://ghost.org/docs/faq/supported-databases/",rel:"noopener noreferrer",target:"_blank",children:"upgrade to MySQL 8"}),"."]})]}),a.jsx(Qa,{}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"book-open",size:"sm"})," User documentation"]}),a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://forum.ghost.org/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"question-circle",size:"sm"})," Get help with Ghost"]}),a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/contributing/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"angle-brackets",size:"sm"})," Get involved"]})]}),a.jsx(Qa,{}),a.jsxs("p",{className:"max-w-[460px] text-xs",children:["Copyright © 2013 – ",c()," Ghost Foundation, released under the ",a.jsx("a",{className:"text-green",href:"https://github.com/TryGhost/Ghost/blob/main/LICENSE",rel:"noopener noreferrer",target:"_blank",children:"MIT license"}),". ",a.jsx("a",{className:"text-green",href:"https://ghost.org/",rel:"noopener noreferrer",target:"_blank",children:"Ghost"})," is a registered trademark of ",a.jsx("a",{className:"text-green",href:"https://ghost.org/trademark/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Foundation Ltd"}),"."]})]})})}),XM=()=>{const e=Zt(),{updateRoute:n}=Je(),[s,o]=D.useState(""),[c,h]=D.useState({name:""}),{mutateAsync:y}=$_(),b=Xs(),l=it();return D.useEffect(()=>{b?.isLimited("customIntegrations")&&b.errorIfWouldGoOverLimit("customIntegrations").catch(u=>{u instanceof Ks&&(_e.show(Xr,{prompt:u.message||"Your current plan doesn't support more custom integrations.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("integrations"))})},[b,e,n]),a.jsx(_t,{afterClose:()=>{n("integrations")},okColor:"black",okLabel:"Add",size:"sm",testId:"add-integration-modal",title:"Add integration",onOk:async()=>{if(!s){h({name:"Name is required"});return}try{const u=await y({name:s});e.remove(),n({route:`integrations/${u.integrations[0].id}`})}catch(u){l(u)}},children:a.jsx("div",{className:"mt-5",children:a.jsx(rt,{marginBottom:!1,marginTop:!1,children:a.jsx(Ne,{autoFocus:!0,error:!!c.name,hint:c.name,maxLength:191,placeholder:"Custom integration",title:"Name",value:s,onChange:u=>o(u.target.value),onInput:()=>{c.name&&h({name:""})}})})})})},KM=_e.create(XM),ZM=()=>{const e=Zt(),{updateRoute:n}=Je(),s=it(),[o,c]=D.useState(!0),[h,y]=D.useState(null),{data:b}=Xg({searchParams:{filter:"newsletters.status:active+email_disabled:0",limit:"1",page:"1",include:"newsletters,labels"}}),{mutateAsync:l}=P_(),{formState:u,updateForm:f,saveState:p,handleSave:m,errors:v,clearError:_}=kr({initialState:{name:"",description:"",optInExistingSubscribers:!0},onSave:async()=>{const T=await l({name:u.name,description:u.description,opt_in_existing:u.optInExistingSubscribers,feedback_enabled:!0});n({route:`newsletters/${T.newsletters[0].id}`})},onSaveError:s,onValidate:()=>{const T={};return u.name||(T.name="A name is required for your newsletter"),T}}),k=Xs();D.useEffect(()=>{if(!k){c(!1);return}k.errorIfWouldGoOverLimit("newsletters").catch(T=>{if(T instanceof Ks)y(T);else throw T}).finally(()=>{c(!1)})},[k]);const M=b?.meta?.pagination.total;return D.useEffect(()=>{h&&(_e.show(Xr,{prompt:h.message||"Your current plan doesn't support more newsletters.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("newsletters"))},[h,e,n]),o||h?null:a.jsx(_t,{afterClose:()=>{n("newsletters")},backDropClick:!1,okColor:"black",okDisabled:p==="saving",okLabel:"Create",okLoading:p==="saving",size:"sm",testId:"add-newsletter-modal",title:"Create newsletter",onOk:async()=>{await m()&&e.remove()},children:a.jsxs(rt,{marginBottom:!1,marginTop:!0,children:[a.jsx(Ne,{autoFocus:!0,error:!!v.name,hint:v.name,maxLength:191,placeholder:"Weekly roundup",title:"Name",value:u.name,onChange:T=>f(A=>({...A,name:T.target.value})),onKeyDown:()=>_("name")}),a.jsx($n,{maxLength:2e3,title:"Description",value:u.description,onChange:T=>f(A=>({...A,description:T.target.value}))}),a.jsx(ot,{checked:u.optInExistingSubscribers,direction:"rtl",hint:u.optInExistingSubscribers?`This newsletter will be available to all members. Your ${M===void 0?"":Kg(M)} existing subscriber${b?.meta?.pagination.total===1?"":"s"} will also be opted-in to receive it.`:"The newsletter will be available to all new members. Existing members won’t be subscribed, but may visit their account area to opt-in to future emails.",label:"Opt-in existing subscribers",labelStyle:"heading",onChange:T=>f(A=>({...A,optInExistingSubscribers:T.target.checked}))})]})})},VM=_e.create(ZM),QM=({recommendation:e,animate:n})=>{const s=Zt(),{updateRoute:o,route:c}=Je(),{mutateAsync:h}=L_(),y=it(),{formState:b,updateForm:l,handleSave:u,saveState:f,errors:p,clearError:m,setErrors:v}=kr({initialState:{...e},onSave:async T=>{await h(T),s.remove(),gt({title:"Recommendation added",type:"success"}),U_("Recommendation Added",{oneClickSubscribe:T.one_click_subscribe}),o("recommendations")},onSaveError:y,onValidate:T=>F_(T)});let _="Add",k=!1;f==="saving"?k=!0:f==="saved"&&(_="Added");let M={label:"Back",icon:"arrow-left",iconColorClass:"text-black dark:text-white",link:!0,size:"sm",onClick:()=>{f!=="saving"&&(s.remove(),_e.show(gb,{pathName:c,animate:!1,recommendation:{...b}}))}};return a.jsx(_t,{afterClose:()=>{o("recommendations")},animate:n??!0,backDropClick:!1,cancelLabel:"Cancel",dirty:!0,leftButtonProps:M,okColor:"black",okLabel:_,okLoading:k,size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",stickyFooter:!0,onCancel:()=>{f!=="saving"&&(s.remove(),o("recommendations"))},onOk:async()=>{if(f!=="saving"){Zg();try{await u({force:!0})}catch{gt({type:"error",title:"Something went wrong when adding this recommendation, please try again."})}}},children:a.jsx(z_,{clearError:m,errors:p,formState:b,setErrors:v,showURL:!1,updateForm:l})})},JM=_e.create(QM),Zh=e=>qi(e).save||"",ej=function(e,n){try{new URL(n).hostname.includes(".")?delete e.url:e.url="Enter a valid URL"}catch{e.url="Enter a valid URL"}return e},tj=({searchParams:e,recommendation:n,animate:s})=>{const[o,c]=D.useState(!1),h=Zt(),{updateRoute:y}=Je(),{mutateAsync:b}=H_(),l=n?"":e?.get("url")??"",{save:u}=l?qi(l):{save:""},f=st.useRef(!1),[p,m]=st.useState(!!u),{formState:v,updateForm:_,handleSave:k,errors:M,saveState:T,clearError:A}=kr({initialState:n??{title:"",url:u||"",description:"",excerpt:null,featured_image:null,favicon:null,one_click_subscribe:!1},onSave:async()=>{let O;O=new URL(v.url);const $=O.hostname.replace("www.",""),B={...v,url:O.toString()},{recommendations:R=[]}=await b(O);if(!R||R.length===0)return;const V=R[0];if(V.id)throw new uh("A recommendation with this URL already exists.");B.title=V.title??$,B.excerpt=V.excerpt??B.excerpt,B.featured_image=V.featured_image??B.featured_image??null,B.favicon=V.favicon??B.favicon??null,B.one_click_subscribe=V.one_click_subscribe??B.one_click_subscribe??!1,B.description=B.excerpt||null,h.remove(),_e.show(JM,{animate:!1,recommendation:B})},onValidate:()=>{const O={};return ej(O,v.url),p&&m(Object.keys(O).length===0),O}}),C=st.useCallback(async()=>{if(T!=="saving"){Zg();try{if(await k({force:!0}))return}catch(O){const $=O instanceof uh?O.message:"Something went wrong while checking this URL, please try again.";gt({type:"error",title:$})}p&&m(!1)}},[k,T,p,m]);return st.useEffect(()=>{p&&!f.current&&(f.current=!0,C())},[p,C]),D.useEffect(()=>{o&&(C(),c(!1))},[v]),p?a.jsx(_t,{afterClose:()=>{y("recommendations")},animate:s??!0,backDropClick:!1,footer:!1,header:!1,size:"sm",children:a.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:a.jsx(Yi,{})})}):a.jsxs(_t,{afterClose:()=>{y("recommendations")},animate:s??!0,backDropClick:!1,okColor:"black",okLabel:"Next",okLoading:T==="saving",size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",onOk:C,children:[a.jsxs("p",{className:"mt-4",children:["You can recommend ",a.jsx("strong",{children:"any site"})," your audience will find valuable, not just those published on Ghost."]}),a.jsx(rt,{marginBottom:!1,marginTop:!0,children:a.jsx(Ne,{autoFocus:!0,error:!!M.url,hint:M.url||a.jsxs(a.Fragment,{children:["Need inspiration? ",a.jsx("a",{className:"text-green",href:"https://www.ghost.org/explore",rel:"noopener noreferrer",target:"_blank",children:"Explore thousands of sites"})," to recommend"]}),maxLength:2e3,placeholder:"https://www.example.com",title:"URL",value:v.url,onBlur:()=>{const O=Zh(v.url);_($=>({...$,url:O}))},onChange:O=>{A?.("url"),_($=>({...$,url:O.target.value}))},onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),_($=>({...$,url:Zh(v.url)})),c(!0))}})})]})},gb=_e.create(tj);function rj(e,n){let s;return function(...c){const h=()=>{clearTimeout(s),e(...c)};clearTimeout(s),s=setTimeout(h,n)}}const md=({generateContent:e,className:n,height:s,width:o,parentClassName:c,testId:h,addDelay:y=!1})=>{const[b,l]=D.useState(0),u=[D.useRef(null),D.useRef(null)],[f,p]=D.useState(0);return D.useEffect(()=>{const m=b===0?1:0,v=u[m].current;if(v){e(v);const _=()=>{y?setTimeout(()=>{l(m)},500):l(m)};return v.addEventListener("load",_),()=>{v.removeEventListener("load",_)}}},[e]),D.useEffect(()=>{const m=u[b].current,v=rj(()=>{p(m?.contentWindow?.scrollY||0)},250);return m?.contentWindow?.addEventListener("scroll",v),()=>{m?.contentWindow?.removeEventListener("scroll",v)}},[b,u]),D.useEffect(()=>{const m=u[b].current;if(m)try{m.contentWindow?.scrollTo(0,f)}catch(v){B_(v)}},[f,b,u]),a.jsxs("div",{className:c,"data-testid":h,children:[a.jsx("iframe",{ref:u[0],className:`${n} ${b!==0?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":b===0,frameBorder:"0",height:s,title:"Buffered Preview 1",width:o}),a.jsx("iframe",{ref:u[1],className:`${n} ${b!==1?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":b===1,frameBorder:"0",height:s,title:"Buffered Preview 2",width:o})]})},nj=(e,n,s)=>{const o=new URLSearchParams;return o.append("announcement_bg",e||"accent"),o.append("announcement",n||""),s&&s.length>0&&o.append("announcement_vis",s?.join(",")||""),o.toString()},sj=({announcementBackgroundColor:e,announcementContent:n,url:s,visibility:o})=>{const c=D.useMemo(()=>o,[o?.join(",")]),h=D.useCallback(y=>{s&&fetch(s,{method:"POST",headers:{"Content-Type":"text/html;charset=utf-8","x-ghost-preview":nj(e,n,c),Accept:"text/plain"},mode:"cors",credentials:"include"}).then(b=>b.text()).then(b=>{const l="html { pointer-events: none; }",f=new DOMParser().parseFromString(b,"text/html"),p=f.querySelector("style"),m=p.innerHTML;p.innerHTML=`${m}
1
+ import{j as a,r as D,c as Vf,P as Lg,a as ns,u as Fg,b as ao,d as Va,e as Ug,f as zg,H as xt,g as Gr,S as Qa,h as ve,F as st,i as __,B as Ue,k as el,K as k_,l as Hg,m as M_,R as j_,I as E_,n as Zt,o as T_,p as Pt,M as _t,q as an,s as S_,T as Rn,t as ut,v as Bg,w as N_,x as ss,y as tl,N as _e,z as Je,A as A_,C as Wg,D as et,E as it,G as rl,L as ln,J as On,O as St,Q as Nt,U as oo,V as Qf,W as I_,X as as,Y as os,Z as bt,_ as kr,$ as C_,a0 as ih,a1 as rt,a2 as Ne,a3 as lh,a4 as ch,a5 as ot,a6 as qg,a7 as Yg,a8 as D_,a9 as gt,aa as Gg,ab as R_,ac as O_,ad as $_,ae as Xs,af as Ks,ag as Xr,ah as Xg,ai as P_,aj as $n,ak as Kg,al as L_,am as F_,an as U_,ao as z_,ap as Zg,aq as H_,ar as qi,as as uh,at as Yi,au as B_,av as Vg,aw as cn,ax as W_,ay as fh,az as dh,aA as q_,aB as Zs,aC as un,aD as on,aE as Qg,aF as Y_,aG as G_,aH as X_,aI as Jg,aJ as Jf,aK as K_,aL as Z_,aM as V_,aN as ts,aO as Q_,aP as Gi,aQ as ed,aR as J_,aS as td,aT as e2,aU as t2,aV as r2,aW as n2,aX as e0,aY as t0,aZ as rd,a_ as Ws,a$ as nd,b0 as s2,b1 as Ba,b2 as a2,b3 as o2,b4 as r0,b5 as n0,b6 as i2,b7 as l2,b8 as c2,b9 as ph,ba as s0,bb as a0,bc as o0,bd as If,be as u2,bf as f2,bg as d2,bh as p2,bi as nl,bj as h2,bk as sd,bl as i0,bm as l0,bn as hh,bo as dr,bp as c0,bq as m2,br as ad,bs as g2,bt as b2,bu as Ja,bv as u0,bw as x2,bx as v2,by as Cf,bz as w2,bA as Ys,bB as y2,bC as _2,bD as k2,bE as f0,bF as M2,bG as od,bH as j2,bI as id,bJ as Xi,bK as E2,bL as T2,bM as Df,bN as S2,bO as N2,bP as A2,bQ as d0,bR as I2,bS as p0,bT as C2,bU as D2,bV as R2,bW as O2,bX as $2,bY as P2,bZ as Nn,b_ as mh,b$ as gh,c0 as L2,c1 as F2}from"./index-DVmEWo2g.js";function U2(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const h0=({children:e,...n})=>a.jsx("div",{className:"flex h-full w-full flex-col px-8",...n,children:a.jsx("div",{className:"h-full w-full overflow-hidden rounded-t-[4px] shadow-sm",children:e})}),m0=({children:e,...n})=>a.jsx("div",{className:"flex h-[775px] w-[380px] flex-col rounded-3xl bg-white p-2 shadow-xl dark:bg-grey-900",...n,children:a.jsx("div",{className:"w-100 h-100 grow overflow-auto rounded-2xl border border-grey-100 dark:border-grey-950",children:e})});var sl="Checkbox",[z2]=Vf(sl),[H2,ld]=z2(sl);function B2(e){const{__scopeCheckbox:n,checked:s,children:o,defaultChecked:c,disabled:h,form:y,name:b,onCheckedChange:l,required:u,value:f="on",internal_do_not_use_render:p}=e,[m,v]=Fg({prop:s,defaultProp:c??!1,onChange:l,caller:sl}),[_,k]=D.useState(null),[M,T]=D.useState(null),A=D.useRef(!1),C=_?!!y||!!_.closest("form"):!0,O={checked:m,disabled:h,setChecked:v,control:_,setControl:k,name:b,form:y,value:f,hasConsumerStoppedPropagationRef:A,required:u,defaultChecked:Cn(c)?!1:c,isFormControl:C,bubbleInput:M,setBubbleInput:T};return a.jsx(H2,{scope:n,...O,children:W2(p)?p(O):o})}var g0="CheckboxTrigger",b0=D.forwardRef(({__scopeCheckbox:e,onKeyDown:n,onClick:s,...o},c)=>{const{control:h,value:y,disabled:b,checked:l,required:u,setControl:f,setChecked:p,hasConsumerStoppedPropagationRef:m,isFormControl:v,bubbleInput:_}=ld(g0,e),k=ao(c,f),M=D.useRef(l);return D.useEffect(()=>{const T=h?.form;if(T){const A=()=>p(M.current);return T.addEventListener("reset",A),()=>T.removeEventListener("reset",A)}},[h,p]),a.jsx(ns.button,{type:"button",role:"checkbox","aria-checked":Cn(l)?"mixed":l,"aria-required":u,"data-state":k0(l),"data-disabled":b?"":void 0,disabled:b,value:y,...o,ref:k,onKeyDown:Va(n,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Va(s,T=>{p(A=>Cn(A)?!0:!A),_&&v&&(m.current=T.isPropagationStopped(),m.current||T.stopPropagation())})})});b0.displayName=g0;var x0=D.forwardRef((e,n)=>{const{__scopeCheckbox:s,name:o,checked:c,defaultChecked:h,required:y,disabled:b,value:l,onCheckedChange:u,form:f,...p}=e;return a.jsx(B2,{__scopeCheckbox:s,checked:c,defaultChecked:h,disabled:b,required:y,onCheckedChange:u,name:o,form:f,value:l,internal_do_not_use_render:({isFormControl:m})=>a.jsxs(a.Fragment,{children:[a.jsx(b0,{...p,ref:n,__scopeCheckbox:s}),m&&a.jsx(_0,{__scopeCheckbox:s})]})})});x0.displayName=sl;var v0="CheckboxIndicator",w0=D.forwardRef((e,n)=>{const{__scopeCheckbox:s,forceMount:o,...c}=e,h=ld(v0,s);return a.jsx(Lg,{present:o||Cn(h.checked)||h.checked===!0,children:a.jsx(ns.span,{"data-state":k0(h.checked),"data-disabled":h.disabled?"":void 0,...c,ref:n,style:{pointerEvents:"none",...e.style}})})});w0.displayName=v0;var y0="CheckboxBubbleInput",_0=D.forwardRef(({__scopeCheckbox:e,...n},s)=>{const{control:o,hasConsumerStoppedPropagationRef:c,checked:h,defaultChecked:y,required:b,disabled:l,name:u,value:f,form:p,bubbleInput:m,setBubbleInput:v}=ld(y0,e),_=ao(s,v),k=Ug(h),M=zg(o);D.useEffect(()=>{const A=m;if(!A)return;const C=window.HTMLInputElement.prototype,$=Object.getOwnPropertyDescriptor(C,"checked").set,B=!c.current;if(k!==h&&$){const R=new Event("click",{bubbles:B});A.indeterminate=Cn(h),$.call(A,Cn(h)?!1:h),A.dispatchEvent(R)}},[m,k,h,c]);const T=D.useRef(Cn(h)?!1:h);return a.jsx(ns.input,{type:"checkbox","aria-hidden":!0,defaultChecked:y??T.current,required:b,disabled:l,name:u,value:f,form:p,...n,tabIndex:-1,ref:_,style:{...n.style,...M,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_0.displayName=y0;function W2(e){return typeof e=="function"}function Cn(e){return e==="indeterminate"}function k0(e){return Cn(e)?"indeterminate":e?"checked":"unchecked"}const q2=({title:e,label:n,value:s,onChange:o,disabled:c,error:h,hint:y,checked:b,separator:l,testId:u})=>{const f=D.useId(),p=m=>{o(m===!0)};return a.jsxs("div",{children:[a.jsxs("div",{className:`flex flex-col gap-1 ${l&&"pb-2"}`,children:[e&&a.jsx(xt,{grey:!0,level:6,children:e}),a.jsxs("label",{className:`flex cursor-pointer items-start ${e&&"-mb-1 mt-1"}`,htmlFor:f,children:[a.jsx(x0,{className:"mt-0.5 flex h-4 w-4 cursor-pointer appearance-none items-center justify-center rounded-[3px] border border-solid border-grey-500 bg-white outline-none data-[state=checked]:border-black data-[state=indeterminate]:border-black data-[state=checked]:bg-black data-[state=indeterminate]:bg-black","data-testid":u,defaultChecked:b,disabled:c,id:f,value:s,onCheckedChange:p,children:a.jsx(w0,{children:a.jsx("svg",{fill:"none",height:"11",viewBox:"0 0 10 11",width:"10",children:a.jsx("path",{d:"M1 5.88889L4.6 9L9 1",stroke:"white",strokeLinecap:"round",strokeWidth:"2"})})})}),a.jsxs("div",{className:`ml-2 flex flex-col ${y&&"mb-2"}`,children:[a.jsx("span",{className:`inline-block text-[1.425rem] dark:text-white ${y&&"-mb-1"}`,children:n}),y&&a.jsx(Gr,{color:h?"red":"",children:y})]})]})]}),(l||h)&&a.jsx(Qa,{className:h?"border-red":""})]})},Rf=({title:e,checkboxes:n,hint:s,error:o})=>a.jsxs("div",{children:[e&&a.jsx(xt,{grey:!0,level:6,children:e}),a.jsx("div",{className:"mt-2 flex flex-col gap-1",children:n?.map(({key:c,...h})=>a.jsx(q2,{...h},c))}),a.jsx("div",{className:`flex flex-col ${s&&"mb-2"}`,children:s&&a.jsx(Gr,{color:o?"red":"",children:s})})]}),Y2=({hex:e,value:n,title:s,size:o="md",isSelected:c,onSelect:h})=>{const y=D.useRef(null),b=f=>{f.preventDefault(),h(n!==void 0?n:e)},l=e.length===4&&e[3]==="0"||e.length===8&&e.slice(6)==="00";let u="h-5 w-5";switch(o){case"lg":u="w-6 h-6";break}return a.jsx("button",{ref:y,className:ve("relative flex shrink-0 cursor-pointer items-center rounded-full border border-grey-300 dark:border-grey-800",u,c&&"outline outline-2 outline-green"),style:{backgroundColor:e},title:s,type:"button",onClick:b,children:l&&a.jsx("div",{className:"absolute left-0 top-0 z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})},M0=({title:e,value:n,swatches:s,swatchSize:o="md",onSwatchChange:c,onTogglePicker:h,isExpanded:y,picker:b=!0,containerClassName:l})=>{const u=s.find(p=>p.value===n||p.hex===n);l=ve("flex flex-col gap-3");const f=y||!b;return a.jsxs("div",{className:l,children:[e&&a.jsx(xt,{useLabelTag:!0,children:e}),a.jsxs("div",{className:"flex gap-1",children:[f&&a.jsx("div",{className:"flex items-center gap-1",children:s.map(({customContent:p,...m})=>p?a.jsx(D.Fragment,{children:p},m.title):a.jsx(Y2,{isSelected:u?.title===m.title,size:o,onSelect:c,...m},m.title))}),b&&a.jsxs("button",{"aria-label":"Pick color",className:"relative size-6 cursor-pointer rounded-full border border-grey-250 dark:border-grey-800",type:"button",onClick:h,children:[a.jsx("div",{className:"absolute inset-0 rounded-full bg-[conic-gradient(hsl(360,100%,50%),hsl(315,100%,50%),hsl(270,100%,50%),hsl(225,100%,50%),hsl(180,100%,50%),hsl(135,100%,50%),hsl(90,100%,50%),hsl(45,100%,50%),hsl(0,100%,50%))]"}),u&&a.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:u.hex},children:u.hex==="transparent"&&a.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})}),!u&&n&&a.jsx("div",{className:"absolute inset-[3px] overflow-hidden rounded-full border border-white dark:border-grey-950",style:{backgroundColor:n},children:n==="transparent"&&a.jsx("div",{className:"absolute left-[3px] top-[3px] z-10 w-[136%] origin-left rotate-45 border-b border-b-red"})})]})]})]})};function Vs(){return(Vs=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e}).apply(this,arguments)}function al(e,n){if(e==null)return{};var s,o,c={},h=Object.keys(e);for(o=0;o<h.length;o++)n.indexOf(s=h[o])>=0||(c[s]=e[s]);return c}function eo(e){var n=D.useRef(e),s=D.useRef(function(o){n.current&&n.current(o)});return n.current=e,s.current}var to=function(e,n,s){return n===void 0&&(n=0),s===void 0&&(s=1),e>s?s:e<n?n:e},Ka=function(e){return"touches"in e},Of=function(e){return e&&e.ownerDocument.defaultView||self},bh=function(e,n,s){var o=e.getBoundingClientRect(),c=Ka(n)?(function(h,y){for(var b=0;b<h.length;b++)if(h[b].identifier===y)return h[b];return h[0]})(n.touches,s):n;return{left:to((c.pageX-(o.left+Of(e).pageXOffset))/o.width),top:to((c.pageY-(o.top+Of(e).pageYOffset))/o.height)}},xh=function(e){!Ka(e)&&e.preventDefault()},j0=st.memo(function(e){var n=e.onMove,s=e.onKey,o=al(e,["onMove","onKey"]),c=D.useRef(null),h=eo(n),y=eo(s),b=D.useRef(null),l=D.useRef(!1),u=D.useMemo(function(){var v=function(M){xh(M),(Ka(M)?M.touches.length>0:M.buttons>0)&&c.current?h(bh(c.current,M,b.current)):k(!1)},_=function(){return k(!1)};function k(M){var T=l.current,A=Of(c.current),C=M?A.addEventListener:A.removeEventListener;C(T?"touchmove":"mousemove",v),C(T?"touchend":"mouseup",_)}return[function(M){var T=M.nativeEvent,A=c.current;if(A&&(xh(T),!(function(O,$){return $&&!Ka(O)})(T,l.current)&&A)){if(Ka(T)){l.current=!0;var C=T.changedTouches||[];C.length&&(b.current=C[0].identifier)}A.focus(),h(bh(A,T,b.current)),k(!0)}},function(M){var T=M.which||M.keyCode;T<37||T>40||(M.preventDefault(),y({left:T===39?.05:T===37?-.05:0,top:T===40?.05:T===38?-.05:0}))},k]},[y,h]),f=u[0],p=u[1],m=u[2];return D.useEffect(function(){return m},[m]),st.createElement("div",Vs({},o,{onTouchStart:f,onMouseDown:f,className:"react-colorful__interactive",ref:c,onKeyDown:p,tabIndex:0,role:"slider"}))}),cd=function(e){return e.filter(Boolean).join(" ")},E0=function(e){var n=e.color,s=e.left,o=e.top,c=o===void 0?.5:o,h=cd(["react-colorful__pointer",e.className]);return st.createElement("div",{className:h,style:{top:100*c+"%",left:100*s+"%"}},st.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:n}}))},Yt=function(e,n,s){return n===void 0&&(n=0),s===void 0&&(s=Math.pow(10,n)),Math.round(s*e)/s},G2=function(e){return Q2($f(e))},$f=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Yt(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?Yt(parseInt(e.substring(6,8),16)/255,2):1}},X2=function(e){return V2(Z2(e))},K2=function(e){var n=e.s,s=e.v,o=e.a,c=(200-n)*s/100;return{h:Yt(e.h),s:Yt(c>0&&c<200?n*s/100/(c<=100?c:200-c)*100:0),l:Yt(c/2),a:Yt(o,2)}},Pf=function(e){var n=K2(e);return"hsl("+n.h+", "+n.s+"%, "+n.l+"%)"},Z2=function(e){var n=e.h,s=e.s,o=e.v,c=e.a;n=n/360*6,s/=100,o/=100;var h=Math.floor(n),y=o*(1-s),b=o*(1-(n-h)*s),l=o*(1-(1-n+h)*s),u=h%6;return{r:Yt(255*[o,b,y,y,l,o][u]),g:Yt(255*[l,o,o,b,y,y][u]),b:Yt(255*[y,y,l,o,o,b][u]),a:Yt(c,2)}},$i=function(e){var n=e.toString(16);return n.length<2?"0"+n:n},V2=function(e){var n=e.r,s=e.g,o=e.b,c=e.a,h=c<1?$i(Yt(255*c)):"";return"#"+$i(n)+$i(s)+$i(o)+h},Q2=function(e){var n=e.r,s=e.g,o=e.b,c=e.a,h=Math.max(n,s,o),y=h-Math.min(n,s,o),b=y?h===n?(s-o)/y:h===s?2+(o-n)/y:4+(n-s)/y:0;return{h:Yt(60*(b<0?b+6:b)),s:Yt(h?y/h*100:0),v:Yt(h/255*100),a:c}},J2=st.memo(function(e){var n=e.hue,s=e.onChange,o=cd(["react-colorful__hue",e.className]);return st.createElement("div",{className:o},st.createElement(j0,{onMove:function(c){s({h:360*c.left})},onKey:function(c){s({h:to(n+360*c.left,0,360)})},"aria-label":"Hue","aria-valuenow":Yt(n),"aria-valuemax":"360","aria-valuemin":"0"},st.createElement(E0,{className:"react-colorful__hue-pointer",left:n/360,color:Pf({h:n,s:100,v:100,a:1})})))}),e3=st.memo(function(e){var n=e.hsva,s=e.onChange,o={backgroundColor:Pf({h:n.h,s:100,v:100,a:1})};return st.createElement("div",{className:"react-colorful__saturation",style:o},st.createElement(j0,{onMove:function(c){s({s:100*c.left,v:100-100*c.top})},onKey:function(c){s({s:to(n.s+100*c.left,0,100),v:to(n.v-100*c.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+Yt(n.s)+"%, Brightness "+Yt(n.v)+"%"},st.createElement(E0,{className:"react-colorful__saturation-pointer",top:1-n.v/100,left:n.s/100,color:Pf(n)})))}),T0=function(e,n){if(e===n)return!0;for(var s in e)if(e[s]!==n[s])return!1;return!0},t3=function(e,n){return e.toLowerCase()===n.toLowerCase()||T0($f(e),$f(n))};function r3(e,n,s){var o=eo(s),c=D.useState(function(){return e.toHsva(n)}),h=c[0],y=c[1],b=D.useRef({color:n,hsva:h});D.useEffect(function(){if(!e.equal(n,b.current.color)){var u=e.toHsva(n);b.current={hsva:u,color:n},y(u)}},[n,e]),D.useEffect(function(){var u;T0(h,b.current.hsva)||e.equal(u=e.fromHsva(h),b.current.color)||(b.current={hsva:h,color:u},o(u))},[h,e,o]);var l=D.useCallback(function(u){y(function(f){return Object.assign({},f,u)})},[]);return[h,l]}var n3=typeof window<"u"?D.useLayoutEffect:D.useEffect,s3=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},vh=new Map,a3=function(e){n3(function(){var n=e.current?e.current.ownerDocument:document;if(n!==void 0&&!vh.has(n)){var s=n.createElement("style");s.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,vh.set(n,s);var o=s3();o&&s.setAttribute("nonce",o),n.head.appendChild(s)}},[])},o3=function(e){var n=e.className,s=e.colorModel,o=e.color,c=o===void 0?s.defaultColor:o,h=e.onChange,y=al(e,["className","colorModel","color","onChange"]),b=D.useRef(null);a3(b);var l=r3(s,c,h),u=l[0],f=l[1],p=cd(["react-colorful",n]);return st.createElement("div",Vs({},y,{ref:b,className:p}),st.createElement(e3,{hsva:u,onChange:f}),st.createElement(J2,{hue:u.h,onChange:f,className:"react-colorful__last-control"}))},i3={defaultColor:"000",toHsva:G2,fromHsva:function(e){return X2({h:e.h,s:e.s,v:e.v,a:1})},equal:t3},l3=function(e){return st.createElement(o3,Vs({},e,{colorModel:i3}))},c3=/^#?([0-9A-F]{3,8})$/i,u3=function(e){var n=e.color,s=n===void 0?"":n,o=e.onChange,c=e.onBlur,h=e.escape,y=e.validate,b=e.format,l=e.process,u=al(e,["color","onChange","onBlur","escape","validate","format","process"]),f=D.useState(function(){return h(s)}),p=f[0],m=f[1],v=eo(o),_=eo(c),k=D.useCallback(function(T){var A=h(T.target.value);m(A),y(A)&&v(l?l(A):A)},[h,l,y,v]),M=D.useCallback(function(T){y(T.target.value)||m(h(s)),_(T)},[s,h,y,_]);return D.useEffect(function(){m(h(s))},[s,h]),st.createElement("input",Vs({},u,{value:b?b(p):p,spellCheck:"false",onChange:k,onBlur:M}))},wh=function(e){return"#"+e},f3=function(e){var n=e.prefixed,s=e.alpha,o=al(e,["prefixed","alpha"]),c=D.useCallback(function(y){return y.replace(/([^0-9A-F]+)/gi,"").substring(0,s?8:6)},[s]),h=D.useCallback(function(y){return(function(b,l){var u=c3.exec(b),f=u?u[1].length:0;return f===3||f===6||!!l&&f===4||!!l&&f===8})(y,s)},[s]);return st.createElement(u3,Vs({},o,{escape:c,format:n?wh:void 0,process:wh,validate:h}))};const d3=({hexValue:e,eyedropper:n,clearButtonValue:s,containerClassName:o,onChange:c})=>{const h=D.useRef(null),y=D.useCallback(m=>{var v,_,k;m.stopPropagation();const M=(v=h.current)==null?void 0:v.querySelector("input");m.target!==M&&((k=(_=h.current)==null?void 0:_.querySelector("input"))==null||k.focus(),m.preventDefault())},[]),b=D.useRef(!1),l=D.useCallback(()=>{var m,v;b.current=!1,(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus(),document.removeEventListener("mouseup",l),document.removeEventListener("touchend",l)},[]),u=D.useCallback(()=>{b.current=!0,document.addEventListener("mouseup",l),document.addEventListener("touchend",l)},[l]),f=D.useCallback(m=>{if(m.preventDefault(),!window.EyeDropper)return;b.current=!0,document.body.style.setProperty("pointer-events","none"),new window.EyeDropper().open().then(_=>c?.(_.sRGBHex)).finally(()=>{var _,k;b.current=!1,document.body.style.removeProperty("pointer-events"),(k=(_=h.current)==null?void 0:_.querySelector("input"))==null||k.focus()})},[c]);D.useEffect(()=>{var m,v;(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus()},[]);const p=D.useCallback(()=>{var m,v;(v=(m=h.current)==null?void 0:m.querySelector("input"))==null||v.focus()},[]);return o=ve("mt-2",o),a.jsxs("div",{className:o,onMouseDown:y,onTouchStart:y,children:[a.jsx(l3,{className:"w-full",color:e||"#ffffff",onChange:c,onMouseDown:u,onTouchStart:u}),a.jsxs("div",{className:"mt-3 flex gap-2",children:[a.jsxs("div",{ref:h,className:"peer relative order-2 flex h-10 w-full items-center",onClick:p,children:[a.jsx("span",{className:"absolute left-2 top-[9px] z-10 ml-1 mr-2 text-grey-700",children:"#"}),a.jsx(f3,{"aria-label":"Color value",className:"z-[1] w-full rounded-md border border-transparent bg-grey-150 p-2 pl-6 transition-all hover:bg-grey-100 focus:border-green focus:bg-white focus:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:bg-grey-900 dark:text-white dark:focus:bg-grey-925",color:e,onChange:c}),n&&!!window.EyeDropper&&a.jsx("button",{className:"absolute inset-y-0 right-3 z-50 my-auto h-4 w-4 p-[1px]",type:"button",onClick:f,children:a.jsx(__,{className:"h-full w-full"})})]}),s!==void 0&&a.jsx(Ue,{color:"grey",value:"Clear",onClick:()=>c?.(s)})]})]})},p3=D.createContext({colorPickers:[]}),yh=e=>e.length===4?e.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"):e,Yr=({testId:e,title:n,direction:s,value:o,hint:c,error:h,eyedropper:y,clearButtonValue:b,onChange:l,swatches:u=[],alwaysOpen:f=!1,debounceMs:p})=>{const[m,v]=D.useState(!1),[_,k]=D.useState(o),M=D.useContext(p3),T=D.useId();D.useEffect(()=>{k(B=>yh(B||"")===o?B:o)},[o]),D.useEffect(()=>(M.colorPickers.push({id:T,setExpanded:v}),()=>{M.colorPickers=M.colorPickers.filter(B=>B.id!==T)}),[M,T]),D.useEffect(()=>{if(m){M.colorPickers.filter(R=>R.id!==T).forEach(R=>R.setExpanded(!1));const B=()=>{v(!1)};return document.addEventListener("click",B),()=>{document.removeEventListener("click",B)}}},[M,T,m]);const A=D.useMemo(()=>l&&p?el(l,p):l,[p,l]),C=B=>{k(B),A?.(B?yh(B):null)};let O=a.jsx(M0,{isExpanded:m,swatches:u,value:_,onSwatchChange:B=>{C(B),v(!1)},onTogglePicker:()=>!f&&v(!m)});n&&(O=a.jsxs("div",{className:ve("flex w-full cursor-pointer items-start first:mt-0 dark:text-white",s==="rtl"&&"flex-row-reverse"),children:[a.jsx("div",{className:"shrink-0",children:O}),a.jsxs("div",{className:ve("flex-1",s==="rtl"?"pr-2":"pl-2",c?"mt-[-2px]":"mt-[1px]"),onClick:()=>!f&&v(!m),children:[n,c&&a.jsx("div",{className:`text-xs ${h?"text-red":"text-grey-700"}`,children:c})]})]}));const $=u.find(B=>B.value===_);return a.jsxs("div",{className:"flex-col","data-testid":e,onClick:B=>B.stopPropagation(),children:[O,(f||m)&&a.jsx(d3,{clearButtonValue:b,eyedropper:y,hexValue:$?.hex||_||void 0,onChange:C})]})},h3=({value:e,onChange:n,singleParagraph:s=!0,...o})=>{const c=D.useCallback(h=>{const b=new DOMParser().parseFromString(h,"text/html");b.querySelectorAll("*").forEach(u=>{u.style.removeProperty("white-space"),u.getAttribute("style")||u.removeAttribute("style")}),b.body.innerHTML!==e&&n?.(b.body.innerHTML)},[e,n]);return a.jsx(k_,{...o,singleParagraph:s,children:h=>a.jsx(h.HtmlOutputPlugin,{html:e,setHtml:c})})},ud=({title:e,hideTitle:n,error:s,hint:o,value:c,clearBg:h=!1,className:y="",containerClassName:b="",hintClassName:l="",unstyled:u=!1,...f})=>{const p=u?"":ve("flex min-h-[32px] items-center rounded-md border border-transparent py-1.5 md:min-h-[36px]",h?"bg-transparent":"bg-grey-150 px-3 dark:bg-grey-900",s?"border-red":"transition-all hover:bg-grey-100 has-[:focus]:border-green has-[:focus]:bg-white has-[:focus]:shadow-[0_0_0_1px_rgba(48,207,67,1)] dark:selection:bg-[rgba(88,101,116,0.99)] dark:hover:bg-grey-925 dark:has-[:focus]:bg-grey-950",e&&!n&&!h&&"mt-2",y);return a.jsxs("div",{className:`flex flex-col ${b}`,children:[e&&a.jsx(xt,{className:n?"sr-only":"",grey:!0,useLabelTag:!0,children:e}),a.jsx("div",{className:p,children:a.jsx(h3,{...f,value:c})}),o&&a.jsx(Gr,{className:l,color:s?"red":"",children:o})]})};var fd="Radio",[m3,S0]=Vf(fd),[g3,b3]=m3(fd),N0=D.forwardRef((e,n)=>{const{__scopeRadio:s,name:o,checked:c=!1,required:h,disabled:y,value:b="on",onCheck:l,form:u,...f}=e,[p,m]=D.useState(null),v=ao(n,M=>m(M)),_=D.useRef(!1),k=p?u||!!p.closest("form"):!0;return a.jsxs(g3,{scope:s,checked:c,disabled:y,children:[a.jsx(ns.button,{type:"button",role:"radio","aria-checked":c,"data-state":D0(c),"data-disabled":y?"":void 0,disabled:y,value:b,...f,ref:v,onClick:Va(e.onClick,M=>{c||l?.(),k&&(_.current=M.isPropagationStopped(),_.current||M.stopPropagation())})}),k&&a.jsx(C0,{control:p,bubbles:!_.current,name:o,value:b,checked:c,required:h,disabled:y,form:u,style:{transform:"translateX(-100%)"}})]})});N0.displayName=fd;var A0="RadioIndicator",I0=D.forwardRef((e,n)=>{const{__scopeRadio:s,forceMount:o,...c}=e,h=b3(A0,s);return a.jsx(Lg,{present:o||h.checked,children:a.jsx(ns.span,{"data-state":D0(h.checked),"data-disabled":h.disabled?"":void 0,...c,ref:n})})});I0.displayName=A0;var x3="RadioBubbleInput",C0=D.forwardRef(({__scopeRadio:e,control:n,checked:s,bubbles:o=!0,...c},h)=>{const y=D.useRef(null),b=ao(y,h),l=Ug(s),u=zg(n);return D.useEffect(()=>{const f=y.current;if(!f)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==s&&v){const _=new Event("click",{bubbles:o});v.call(f,s),f.dispatchEvent(_)}},[l,s,o]),a.jsx(ns.input,{type:"radio","aria-hidden":!0,defaultChecked:s,...c,tabIndex:-1,ref:b,style:{...c.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});C0.displayName=x3;function D0(e){return e?"checked":"unchecked"}var v3=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ol="RadioGroup",[w3]=Vf(ol,[Hg,S0]),R0=Hg(),O0=S0(),[y3,_3]=w3(ol),$0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,name:o,defaultValue:c,value:h,required:y=!1,disabled:b=!1,orientation:l,dir:u,loop:f=!0,onValueChange:p,...m}=e,v=R0(s),_=M_(u),[k,M]=Fg({prop:h,defaultProp:c??null,onChange:p,caller:ol});return a.jsx(y3,{scope:s,name:o,required:y,disabled:b,value:k,onValueChange:M,children:a.jsx(j_,{asChild:!0,...v,orientation:l,dir:_,loop:f,children:a.jsx(ns.div,{role:"radiogroup","aria-required":y,"aria-orientation":l,"data-disabled":b?"":void 0,dir:_,...m,ref:n})})})});$0.displayName=ol;var P0="RadioGroupItem",L0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,disabled:o,...c}=e,h=_3(P0,s),y=h.disabled||o,b=R0(s),l=O0(s),u=D.useRef(null),f=ao(n,u),p=h.value===c.value,m=D.useRef(!1);return D.useEffect(()=>{const v=k=>{v3.includes(k.key)&&(m.current=!0)},_=()=>m.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",_)}},[]),a.jsx(E_,{asChild:!0,...b,focusable:!y,active:p,children:a.jsx(N0,{disabled:y,required:h.required,checked:p,...l,...c,name:h.name,ref:f,onCheck:()=>h.onValueChange(c.value),onKeyDown:Va(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Va(c.onFocus,()=>{m.current&&u.current?.click()})})})});L0.displayName=P0;var k3="RadioGroupIndicator",F0=D.forwardRef((e,n)=>{const{__scopeRadioGroup:s,...o}=e,c=O0(s);return a.jsx(I0,{...c,...o,ref:n})});F0.displayName=k3;var M3=$0,j3=L0,E3=F0;const T3=({id:e,title:n,options:s,onSelect:o,error:c,hint:h,selectedOption:y,separator:b})=>a.jsxs(M3,{defaultValue:y,name:e,onValueChange:o,children:[a.jsxs("div",{className:`flex flex-col gap-2 ${b&&"pb-2"}`,children:[n&&a.jsx(xt,{level:6,children:n}),s.map(l=>a.jsxs("label",{className:`flex cursor-pointer items-start ${n&&"-mb-1 mt-1"}`,htmlFor:l.value,children:[a.jsx(j3,{className:"relative float-left mt-[3px] h-4 w-4 min-w-[16px] appearance-none rounded-full border-2 border-solid border-grey-300 hover:cursor-pointer focus:shadow-none focus:outline-none focus:ring-0 data-[state=checked]:border-green data-[state=checked]:focus:border-green dark:border-grey-800 dark:text-white dark:data-[state=checked]:border-green dark:data-[state=checked]:focus:border-green",id:l.value,value:l.value,children:a.jsx(E3,{className:"flex h-full w-full items-center justify-center after:block after:h-[6px] after:w-[6px] after:rounded-full after:border-green after:bg-green after:content-[''] dark:after:border-green dark:after:bg-green"})}),a.jsxs("div",{className:`ml-2 flex flex-col ${l.hint&&"mb-2"}`,children:[a.jsx("span",{className:`inline-block text-md dark:text-white ${l.hint&&"-mb-1"}`,children:l.label}),l.hint&&a.jsx(Gr,{children:l.hint})]})]},l.value)),h&&a.jsx(Gr,{color:c?"red":"",children:h})]}),(b||c)&&a.jsx(Qa,{className:c?"border-red":""})]}),Ki=({children:e,gap:n="md",className:s})=>{let o="gap-3";switch(n){case"sm":o="gap-2";break;case"md":o="gap-3";break;case"lg":o="gap-4";break}return s=ve("flex flex-col",o,s),a.jsx("div",{className:s,children:e})},dd=({heading:e,children:n,className:s})=>(s=ve("w-full p-[8vmin] pt-5",s),a.jsxs("div",{className:s,children:[e&&a.jsx(xt,{className:"mb-8",children:e}),n]})),pd=({items:e,backIcon:n=!1,snapBackIcon:s=!0,onBack:o,containerClassName:c,itemClassName:h,activeItemClassName:y,separatorClassName:b})=>{const l=e.length;let u=0;return c=ve("flex items-center gap-2 text-sm",c),y=ve("font-bold",y),h=ve("text-sm",h),a.jsxs("div",{className:c,children:[n&&a.jsx(Ue,{className:s?"mr-1":"mr-6",icon:"arrow-left",iconColorClass:"dark:text-white",size:"sm",link:!0,onClick:o}),e.map(f=>{const p=u===l-1?a.jsx("span",{className:y,children:f.label}):a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`${h} ${f.onClick&&"-mx-1 cursor-pointer rounded-sm px-1 py-px hover:bg-grey-100 dark:hover:bg-grey-900"}`,type:"button",onClick:f.onClick,children:f.label},`bc-${u}`),a.jsx("span",{className:b,children:"/"})]});return u=u+1,p})]})},Qs=({testId:e,title:n,titleHeadingLevel:s=4,size:o="full",width:c,height:h,sidebar:y="",preview:b,dirty:l=!1,cancelLabel:u="Cancel",okLabel:f="OK",okColor:p="black",previewToolbar:m=!0,leftToolbar:v=!0,rightToolbar:_=!0,deviceSelector:k=!0,siteLink:M,previewToolbarURLs:T,previewBgColor:A="grey",selectedURL:C,previewToolbarTabs:O,previewToolbarBreadcrumbs:$,buttonsDisabled:B,sidebarButtons:R,sidebarHeader:V,sidebarPadding:K=!0,sidebarContentClasses:G,enableCMDS:W=!0,backDropClick:q,onCancel:se,onOk:J,afterClose:te,onSelectURL:Q,onSelectDesktopView:re,onSelectMobileView:be,onBreadcrumbsBack:Me})=>{const L=Zt(),{setGlobalDirtyState:fe}=T_();D.useEffect(()=>{fe(l)},[l,fe]),D.useEffect(()=>{if(J){const oe=je=>{(je.metaKey||je.ctrlKey)&&je.key==="s"&&(je.preventDefault(),J())};if(W)return window.addEventListener("keydown",oe),()=>{window.removeEventListener("keydown",oe)}}});const[de,F]=D.useState("desktop");if(de==="mobile"&&k?b=a.jsx(m0,{"data-testid":"preview-mobile",children:b}):de==="desktop"&&k&&(b=a.jsx(h0,{"data-testid":"preview-desktop",children:b})),m){let oe=a.jsx(a.Fragment,{});T?oe=a.jsx(Pt,{options:T,selectedOption:T.find(Ae=>Ae.value===C),onSelect:Ae=>Ae&&Q?.(Ae.value)}):O?oe=a.jsx(Rn,{border:!1,selectedTab:C,tabs:O,width:"wide",onTabChange:Q}):$&&(oe=a.jsx(pd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:$,separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:Me}));const je="text-black dark:text-green",Pe="text-grey-500 dark:text-grey-600",Le=[{icon:"laptop",label:"Desktop",hideLabel:!0,link:!0,size:"sm",iconColorClass:de==="desktop"?je:Pe,onClick:re||(()=>{F("desktop")})},{icon:"mobile",label:"Mobile",hideLabel:!0,link:!0,size:"sm",iconColorClass:de==="mobile"?je:Pe,onClick:be||(()=>{F("mobile")})}],ke=k&&a.jsx(an,{buttons:Le});let ae="";A==="grey"?ae="bg-grey-50 dark:bg-black":A==="greygradient"&&(ae="bg-gradient-to-tr from-white to-[#f9f9fa] dark:from-grey-950 dark:to-black");const Ee=ve("min-w-100 absolute inset-y-0 left-0 right-[400px] flex w-full grow flex-col overflow-y-auto",ae);let Se;M&&(Se=a.jsx("div",{className:"ml-3 border-l border-grey-400 dark:border-grey-800",children:a.jsxs("a",{className:"ml-3 flex items-center gap-1 text-sm",href:M,rel:"noopener noreferrer",target:"_blank",children:["View site ",a.jsx(ut,{name:"arrow-top-right",size:"xs"})]})})),b=a.jsxs("div",{className:Ee,children:[m&&a.jsxs("header",{className:"relative flex h-[80px] shrink-0 items-center justify-center px-8 py-5","data-testid":"design-toolbar",children:[v&&a.jsx("div",{className:"absolute left-8 flex h-full items-center",children:oe}),_&&a.jsxs("div",{className:"absolute right-8 flex h-full items-center",children:[ke,Se]})]}),a.jsx("div",{className:"flex grow items-center justify-center text-sm text-grey-400",children:b})]})}const z=[];return R||(z.push({key:"cancel-modal",label:u,onClick:se||(()=>{S_(l,()=>{L.remove(),te?.()})}),disabled:B}),z.push({key:"ok-modal",label:f,color:p,onClick:J,disabled:B})),a.jsx(_t,{afterClose:te,animate:!1,backDropClick:q,dirty:l,footer:!1,height:h,padding:!1,size:o,testId:e,title:"",width:c,hideXOnMobile:!0,children:a.jsxs("div",{className:"flex h-full grow",children:[a.jsx("div",{className:`relative hidden grow flex-col [@media(min-width:801px)]:!visible [@media(min-width:801px)]:!flex ${A==="grey"?"bg-grey-50":"bg-white dark:bg-black"}`,children:b}),y&&a.jsxs("div",{className:"relative flex h-full w-full flex-col border-l border-grey-100 dark:border-grey-900 [@media(min-width:801px)]:w-auto [@media(min-width:801px)]:basis-[400px]",children:[V||a.jsxs("div",{className:"flex max-h-[82px] items-center justify-between gap-3 px-7 py-6",children:[a.jsx(xt,{level:s,children:n}),R||a.jsx(an,{buttons:z})]}),a.jsx("div",{className:`${V?"":"absolute inset-x-0 bottom-0 top-[80px] grow"} ${K&&"p-7 pt-0"} flex flex-col justify-between overflow-y-auto ${G&&G}`,children:y})]})]})})},S3=({offset:e,onTrigger:n})=>{const s=D.useRef(null);return D.useEffect(()=>{const o=new IntersectionObserver(c=>{c[0].intersectionRatio<=0||n()});return s.current&&o.observe(s.current),()=>o.disconnect()},[n]),a.jsx("div",{ref:s,className:"absolute w-full",style:{bottom:e}})},U0=({trigger:e,triggerButtonProps:n,items:s,position:o="start",open:c,setOpen:h})=>(e||(e=a.jsx(Ue,{icon:"ellipsis",label:"Menu",hideLabel:!0,...n})),a.jsx(Bg,{open:c,position:o,setOpen:h,trigger:e,closeOnItemClick:!0,children:a.jsx("div",{className:"flex min-w-[160px] flex-col justify-stretch py-1",role:"none",children:s.map(y=>a.jsx("button",{className:`mx-1 block cursor-pointer rounded-[2.5px] px-4 py-1.5 text-left text-sm hover:bg-grey-100 dark:hover:bg-grey-925 ${y.destructive&&" text-red-500"}`,type:"button",onClick:b=>{y.onClick&&y.onClick(b)},children:y.label},y.id))})}));var z0=typeof global=="object"&&global&&global.Object===Object&&global,N3=typeof self=="object"&&self&&self.Object===Object&&self,fn=z0||N3||Function("return this")(),Gs=fn.Symbol,H0=Object.prototype,A3=H0.hasOwnProperty,I3=H0.toString,Wa=Gs?Gs.toStringTag:void 0;function C3(e){var n=A3.call(e,Wa),s=e[Wa];try{e[Wa]=void 0;var o=!0}catch{}var c=I3.call(e);return o&&(n?e[Wa]=s:delete e[Wa]),c}var D3=Object.prototype,R3=D3.toString;function O3(e){return R3.call(e)}var $3="[object Null]",P3="[object Undefined]",_h=Gs?Gs.toStringTag:void 0;function io(e){return e==null?e===void 0?P3:$3:_h&&_h in Object(e)?C3(e):O3(e)}function ro(e){return e!=null&&typeof e=="object"}var Zi=Array.isArray;function B0(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}var L3="[object AsyncFunction]",F3="[object Function]",U3="[object GeneratorFunction]",z3="[object Proxy]";function W0(e){if(!B0(e))return!1;var n=io(e);return n==F3||n==U3||n==L3||n==z3}var au=fn["__core-js_shared__"],kh=(function(){var e=/[^.]+$/.exec(au&&au.keys&&au.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function H3(e){return!!kh&&kh in e}var B3=Function.prototype,W3=B3.toString;function is(e){if(e!=null){try{return W3.call(e)}catch{}try{return e+""}catch{}}return""}var q3=/[\\^$.*+?()[\]{}|]/g,Y3=/^\[object .+?Constructor\]$/,G3=Function.prototype,X3=Object.prototype,K3=G3.toString,Z3=X3.hasOwnProperty,V3=RegExp("^"+K3.call(Z3).replace(q3,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Q3(e){if(!B0(e)||H3(e))return!1;var n=W0(e)?V3:Y3;return n.test(is(e))}function J3(e,n){return e?.[n]}function Js(e,n){var s=J3(e,n);return Q3(s)?s:void 0}var Lf=Js(fn,"WeakMap"),e8=9007199254740991,t8=/^(?:0|[1-9]\d*)$/;function r8(e,n){var s=typeof e;return n=n??e8,!!n&&(s=="number"||s!="symbol"&&t8.test(e))&&e>-1&&e%1==0&&e<n}function q0(e,n){return e===n||e!==e&&n!==n}var n8=9007199254740991;function Y0(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=n8}function s8(e){return e!=null&&Y0(e.length)&&!W0(e)}var a8=Object.prototype;function o8(e){var n=e&&e.constructor,s=typeof n=="function"&&n.prototype||a8;return e===s}function i8(e,n){for(var s=-1,o=Array(e);++s<e;)o[s]=n(s);return o}var l8="[object Arguments]";function Mh(e){return ro(e)&&io(e)==l8}var G0=Object.prototype,c8=G0.hasOwnProperty,u8=G0.propertyIsEnumerable,f8=Mh((function(){return arguments})())?Mh:function(e){return ro(e)&&c8.call(e,"callee")&&!u8.call(e,"callee")};function d8(){return!1}var X0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jh=X0&&typeof module=="object"&&module&&!module.nodeType&&module,p8=jh&&jh.exports===X0,Eh=p8?fn.Buffer:void 0,h8=Eh?Eh.isBuffer:void 0,Ff=h8||d8,m8="[object Arguments]",g8="[object Array]",b8="[object Boolean]",x8="[object Date]",v8="[object Error]",w8="[object Function]",y8="[object Map]",_8="[object Number]",k8="[object Object]",M8="[object RegExp]",j8="[object Set]",E8="[object String]",T8="[object WeakMap]",S8="[object ArrayBuffer]",N8="[object DataView]",A8="[object Float32Array]",I8="[object Float64Array]",C8="[object Int8Array]",D8="[object Int16Array]",R8="[object Int32Array]",O8="[object Uint8Array]",$8="[object Uint8ClampedArray]",P8="[object Uint16Array]",L8="[object Uint32Array]",wt={};wt[A8]=wt[I8]=wt[C8]=wt[D8]=wt[R8]=wt[O8]=wt[$8]=wt[P8]=wt[L8]=!0;wt[m8]=wt[g8]=wt[S8]=wt[b8]=wt[N8]=wt[x8]=wt[v8]=wt[w8]=wt[y8]=wt[_8]=wt[k8]=wt[M8]=wt[j8]=wt[E8]=wt[T8]=!1;function F8(e){return ro(e)&&Y0(e.length)&&!!wt[io(e)]}function U8(e){return function(n){return e(n)}}var K0=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Za=K0&&typeof module=="object"&&module&&!module.nodeType&&module,z8=Za&&Za.exports===K0,ou=z8&&z0.process,Th=(function(){try{var e=Za&&Za.require&&Za.require("util").types;return e||ou&&ou.binding&&ou.binding("util")}catch{}})(),Sh=Th&&Th.isTypedArray,Z0=Sh?U8(Sh):F8,H8=Object.prototype,B8=H8.hasOwnProperty;function W8(e,n){var s=Zi(e),o=!s&&f8(e),c=!s&&!o&&Ff(e),h=!s&&!o&&!c&&Z0(e),y=s||o||c||h,b=y?i8(e.length,String):[],l=b.length;for(var u in e)B8.call(e,u)&&!(y&&(u=="length"||c&&(u=="offset"||u=="parent")||h&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||r8(u,l)))&&b.push(u);return b}function q8(e,n){return function(s){return e(n(s))}}var Y8=q8(Object.keys,Object),G8=Object.prototype,X8=G8.hasOwnProperty;function K8(e){if(!o8(e))return Y8(e);var n=[];for(var s in Object(e))X8.call(e,s)&&s!="constructor"&&n.push(s);return n}function Z8(e){return s8(e)?W8(e):K8(e)}var no=Js(Object,"create");function V8(){this.__data__=no?no(null):{},this.size=0}function Q8(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}var J8="__lodash_hash_undefined__",ek=Object.prototype,tk=ek.hasOwnProperty;function rk(e){var n=this.__data__;if(no){var s=n[e];return s===J8?void 0:s}return tk.call(n,e)?n[e]:void 0}var nk=Object.prototype,sk=nk.hasOwnProperty;function ak(e){var n=this.__data__;return no?n[e]!==void 0:sk.call(n,e)}var ok="__lodash_hash_undefined__";function ik(e,n){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=no&&n===void 0?ok:n,this}function rs(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}rs.prototype.clear=V8;rs.prototype.delete=Q8;rs.prototype.get=rk;rs.prototype.has=ak;rs.prototype.set=ik;function lk(){this.__data__=[],this.size=0}function il(e,n){for(var s=e.length;s--;)if(q0(e[s][0],n))return s;return-1}var ck=Array.prototype,uk=ck.splice;function fk(e){var n=this.__data__,s=il(n,e);if(s<0)return!1;var o=n.length-1;return s==o?n.pop():uk.call(n,s,1),--this.size,!0}function dk(e){var n=this.__data__,s=il(n,e);return s<0?void 0:n[s][1]}function pk(e){return il(this.__data__,e)>-1}function hk(e,n){var s=this.__data__,o=il(s,e);return o<0?(++this.size,s.push([e,n])):s[o][1]=n,this}function dn(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}dn.prototype.clear=lk;dn.prototype.delete=fk;dn.prototype.get=dk;dn.prototype.has=pk;dn.prototype.set=hk;var so=Js(fn,"Map");function mk(){this.size=0,this.__data__={hash:new rs,map:new(so||dn),string:new rs}}function gk(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function ll(e,n){var s=e.__data__;return gk(n)?s[typeof n=="string"?"string":"hash"]:s.map}function bk(e){var n=ll(this,e).delete(e);return this.size-=n?1:0,n}function xk(e){return ll(this,e).get(e)}function vk(e){return ll(this,e).has(e)}function wk(e,n){var s=ll(this,e),o=s.size;return s.set(e,n),this.size+=s.size==o?0:1,this}function ls(e){var n=-1,s=e==null?0:e.length;for(this.clear();++n<s;){var o=e[n];this.set(o[0],o[1])}}ls.prototype.clear=mk;ls.prototype.delete=bk;ls.prototype.get=xk;ls.prototype.has=vk;ls.prototype.set=wk;function yk(e,n){for(var s=-1,o=n.length,c=e.length;++s<o;)e[c+s]=n[s];return e}function _k(){this.__data__=new dn,this.size=0}function kk(e){var n=this.__data__,s=n.delete(e);return this.size=n.size,s}function Mk(e){return this.__data__.get(e)}function jk(e){return this.__data__.has(e)}var Ek=200;function Tk(e,n){var s=this.__data__;if(s instanceof dn){var o=s.__data__;if(!so||o.length<Ek-1)return o.push([e,n]),this.size=++s.size,this;s=this.__data__=new ls(o)}return s.set(e,n),this.size=s.size,this}function Dn(e){var n=this.__data__=new dn(e);this.size=n.size}Dn.prototype.clear=_k;Dn.prototype.delete=kk;Dn.prototype.get=Mk;Dn.prototype.has=jk;Dn.prototype.set=Tk;function Sk(e,n){for(var s=-1,o=e==null?0:e.length,c=0,h=[];++s<o;){var y=e[s];n(y,s,e)&&(h[c++]=y)}return h}function Nk(){return[]}var Ak=Object.prototype,Ik=Ak.propertyIsEnumerable,Nh=Object.getOwnPropertySymbols,Ck=Nh?function(e){return e==null?[]:(e=Object(e),Sk(Nh(e),function(n){return Ik.call(e,n)}))}:Nk;function Dk(e,n,s){var o=n(e);return Zi(e)?o:yk(o,s(e))}function Ah(e){return Dk(e,Z8,Ck)}var Uf=Js(fn,"DataView"),zf=Js(fn,"Promise"),Hf=Js(fn,"Set"),Ih="[object Map]",Rk="[object Object]",Ch="[object Promise]",Dh="[object Set]",Rh="[object WeakMap]",Oh="[object DataView]",Ok=is(Uf),$k=is(so),Pk=is(zf),Lk=is(Hf),Fk=is(Lf),In=io;(Uf&&In(new Uf(new ArrayBuffer(1)))!=Oh||so&&In(new so)!=Ih||zf&&In(zf.resolve())!=Ch||Hf&&In(new Hf)!=Dh||Lf&&In(new Lf)!=Rh)&&(In=function(e){var n=io(e),s=n==Rk?e.constructor:void 0,o=s?is(s):"";if(o)switch(o){case Ok:return Oh;case $k:return Ih;case Pk:return Ch;case Lk:return Dh;case Fk:return Rh}return n});var $h=fn.Uint8Array,Uk="__lodash_hash_undefined__";function zk(e){return this.__data__.set(e,Uk),this}function Hk(e){return this.__data__.has(e)}function Vi(e){var n=-1,s=e==null?0:e.length;for(this.__data__=new ls;++n<s;)this.add(e[n])}Vi.prototype.add=Vi.prototype.push=zk;Vi.prototype.has=Hk;function Bk(e,n){for(var s=-1,o=e==null?0:e.length;++s<o;)if(n(e[s],s,e))return!0;return!1}function Wk(e,n){return e.has(n)}var qk=1,Yk=2;function V0(e,n,s,o,c,h){var y=s&qk,b=e.length,l=n.length;if(b!=l&&!(y&&l>b))return!1;var u=h.get(e),f=h.get(n);if(u&&f)return u==n&&f==e;var p=-1,m=!0,v=s&Yk?new Vi:void 0;for(h.set(e,n),h.set(n,e);++p<b;){var _=e[p],k=n[p];if(o)var M=y?o(k,_,p,n,e,h):o(_,k,p,e,n,h);if(M!==void 0){if(M)continue;m=!1;break}if(v){if(!Bk(n,function(T,A){if(!Wk(v,A)&&(_===T||c(_,T,s,o,h)))return v.push(A)})){m=!1;break}}else if(!(_===k||c(_,k,s,o,h))){m=!1;break}}return h.delete(e),h.delete(n),m}function Gk(e){var n=-1,s=Array(e.size);return e.forEach(function(o,c){s[++n]=[c,o]}),s}function Xk(e){var n=-1,s=Array(e.size);return e.forEach(function(o){s[++n]=o}),s}var Kk=1,Zk=2,Vk="[object Boolean]",Qk="[object Date]",Jk="[object Error]",eM="[object Map]",tM="[object Number]",rM="[object RegExp]",nM="[object Set]",sM="[object String]",aM="[object Symbol]",oM="[object ArrayBuffer]",iM="[object DataView]",Ph=Gs?Gs.prototype:void 0,iu=Ph?Ph.valueOf:void 0;function lM(e,n,s,o,c,h,y){switch(s){case iM:if(e.byteLength!=n.byteLength||e.byteOffset!=n.byteOffset)return!1;e=e.buffer,n=n.buffer;case oM:return!(e.byteLength!=n.byteLength||!h(new $h(e),new $h(n)));case Vk:case Qk:case tM:return q0(+e,+n);case Jk:return e.name==n.name&&e.message==n.message;case rM:case sM:return e==n+"";case eM:var b=Gk;case nM:var l=o&Kk;if(b||(b=Xk),e.size!=n.size&&!l)return!1;var u=y.get(e);if(u)return u==n;o|=Zk,y.set(e,n);var f=V0(b(e),b(n),o,c,h,y);return y.delete(e),f;case aM:if(iu)return iu.call(e)==iu.call(n)}return!1}var cM=1,uM=Object.prototype,fM=uM.hasOwnProperty;function dM(e,n,s,o,c,h){var y=s&cM,b=Ah(e),l=b.length,u=Ah(n),f=u.length;if(l!=f&&!y)return!1;for(var p=l;p--;){var m=b[p];if(!(y?m in n:fM.call(n,m)))return!1}var v=h.get(e),_=h.get(n);if(v&&_)return v==n&&_==e;var k=!0;h.set(e,n),h.set(n,e);for(var M=y;++p<l;){m=b[p];var T=e[m],A=n[m];if(o)var C=y?o(A,T,m,n,e,h):o(T,A,m,e,n,h);if(!(C===void 0?T===A||c(T,A,s,o,h):C)){k=!1;break}M||(M=m=="constructor")}if(k&&!M){var O=e.constructor,$=n.constructor;O!=$&&"constructor"in e&&"constructor"in n&&!(typeof O=="function"&&O instanceof O&&typeof $=="function"&&$ instanceof $)&&(k=!1)}return h.delete(e),h.delete(n),k}var pM=1,Lh="[object Arguments]",Fh="[object Array]",Pi="[object Object]",hM=Object.prototype,Uh=hM.hasOwnProperty;function mM(e,n,s,o,c,h){var y=Zi(e),b=Zi(n),l=y?Fh:In(e),u=b?Fh:In(n);l=l==Lh?Pi:l,u=u==Lh?Pi:u;var f=l==Pi,p=u==Pi,m=l==u;if(m&&Ff(e)){if(!Ff(n))return!1;y=!0,f=!1}if(m&&!f)return h||(h=new Dn),y||Z0(e)?V0(e,n,s,o,c,h):lM(e,n,l,s,o,c,h);if(!(s&pM)){var v=f&&Uh.call(e,"__wrapped__"),_=p&&Uh.call(n,"__wrapped__");if(v||_){var k=v?e.value():e,M=_?n.value():n;return h||(h=new Dn),c(k,M,s,o,h)}}return m?(h||(h=new Dn),dM(e,n,s,o,c,h)):!1}function Q0(e,n,s,o,c){return e===n?!0:e==null||n==null||!ro(e)&&!ro(n)?e!==e&&n!==n:mM(e,n,s,o,Q0,c)}function gM(e,n){return Q0(e,n)}const zh=({className:e,children:n,colSpan:s,sticky:o=!1,...c})=>{const h=ve("!py-2 !pl-0 !pr-6 text-left align-top",o&&"sticky top-0 bg-white",c.onClick&&"hover:cursor-pointer",e);return a.jsx("th",{className:h,colSpan:s,...c,children:a.jsx(xt,{className:"whitespace-nowrap",level:6,children:n})})},J0=({left:e,center:n,right:s,sticky:o=!0,containerClassName:c,children:h})=>{const y=ve("z-50 h-22 min-h-[92px] p-8",!h&&"flex items-center justify-between gap-3",o&&"sticky top-0",c);if(!h){if(e){const b=ve("flex flex-auto items-center",s&&n&&"basis-1/3",!s&&n&&"basis-1/2");e=a.jsx("div",{className:b,children:e})}if(n){const b=ve("flex flex-auto items-center justify-center",e&&s&&"basis-1/3",(e&&!s||!e&&s)&&"basis-1/2");n=a.jsx("div",{className:b,children:n})}if(s){const b=ve("flex flex-auto items-center justify-end",e&&n&&"basis-1/3",!e&&n&&"basis-1/2");s=a.jsx("div",{className:b,children:s})}}return a.jsx("div",{className:y,children:h||a.jsxs(a.Fragment,{children:[e,n,s]})})},eb=({items:e,setItems:n,blank:s,canAddNewItem:o})=>{const[c,h]=D.useState(e.map((m,v)=>({item:m,id:v.toString()}))),[y,b]=D.useState(s);return D.useEffect(()=>{const m=c.map(({item:v})=>v);o(y)&&m.push(y),gM(JSON.parse(JSON.stringify(m)),JSON.parse(JSON.stringify(e)))||n(m)},[c,y,e,n,o]),{items:c,updateItem:(m,v)=>{const _=c.map(k=>k.id===m?{...k,item:v}:k);h(_),n(_.map(k=>k.item))},addItem:()=>{if(o(y)){const m=c.reduce((_,k)=>Math.max(_,parseInt(k.id)),0),v=c.concat({item:y,id:(m+1).toString()});h(v),n(v.map(_=>_.item)),b(s)}},removeItem:m=>{const v=c.filter(_=>_.id!==m);h(v),n(v.map(_=>_.item))},moveItem:(m,v)=>{if(m!==v){const _=c.findIndex(T=>T.id===m),k=v?c.findIndex(T=>T.id===v):0,M=N_(c,_,k);h(M),n(M.map(T=>T.item))}},newItem:y,setNewItem:b}},bM=({label:e,text:n="",hint:s,onRegenerate:o})=>{const[c,h]=D.useState(!1),y=()=>{navigator.clipboard.writeText(n),h(!0),setTimeout(()=>h(!1),2e3)},b=ve("group/api-keys relative -mt-1 mb-1 w-full overflow-hidden border-b border-transparent py-2 hover:border-grey-300 dark:hover:border-grey-600");return a.jsxs("div",{className:"mb-3 grid grid-cols-1",children:[e&&a.jsx(xt,{level:6,grey:!0,children:e}),a.jsxs("div",{className:b,children:[a.jsx("span",{children:n}),s,a.jsxs("div",{className:"visible absolute right-0 top-1/2 flex translate-y-[-50%] gap-1 bg-white pl-1 text-sm group-hover/api-keys:visible md:invisible dark:bg-black",children:[o&&a.jsx(Ue,{color:"outline",label:"Regenerate",size:"sm",onClick:o}),a.jsx(Ue,{color:"outline",label:c?"Copied":"Copy",size:"sm",onClick:y})]})]})]})},hd=({keys:e})=>a.jsx("div",{"data-testid":"api-keys",children:e.map(n=>a.jsx(bM,{...n},n.label))}),lo=({icon:e,title:n,detail:s,extra:o})=>a.jsxs("div",{className:"-mx-8 -mt-8 flex flex-col gap-4 bg-grey-75 p-8 md:flex-row dark:bg-grey-950",children:[a.jsx("div",{className:"size-14",children:e}),a.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-1 flex-col",children:[a.jsx("h3",{children:n}),a.jsx("div",{children:s}),o&&a.jsx("div",{className:"mt-4",children:o})]})]}),tb=ss({method:"POST",path:({integrationId:e,apiKeyId:n})=>`/integrations/${e}/api_key/${n}/refresh/`,body:({integrationId:e})=>({integrations:[{id:e}]}),updateQueries:{emberUpdateType:"createOrUpdate",dataType:tl,update:(e,n)=>n&&{...n,integrations:n.integrations.map(s=>e.integrations.find(({id:c})=>c===s.id)||s)}}}),xM=_e.create(()=>{const e=_e.useModal(),{updateRoute:n}=Je(),{zapierTemplates:s}=A_(),{data:{integrations:o}={integrations:[]}}=Wg(),{config:c}=et(),{mutateAsync:h}=tb(),y=it(),[b,l]=D.useState(!1),u=c.hostSettings?.limits?.customIntegrations?.disabled,f=o.find(({slug:v})=>v==="zapier"),p=f?.api_keys?.find(v=>v.type==="admin");D.useEffect(()=>{u&&n("integrations")},[u,n]);const m=()=>{!f||!p||(l(!1),_e.show(St,{title:"Regenerate Admin API Key",prompt:'You will need to locate the Ghost App within your Zapier account and click on "Reconnect" to enter the new Admin API Key.',okLabel:"Regenerate Admin API Key",onOk:async v=>{try{await h({integrationId:f.id,apiKeyId:p.id}),l(!0),v?.remove()}catch(_){y(_)}}}))};return a.jsxs(_t,{afterClose:()=>{n("integrations")},cancelLabel:"",footer:a.jsxs("div",{className:"mx-8 flex w-full items-center justify-between",children:[a.jsxs("a",{className:"mt-1 self-baseline text-sm font-bold",href:"https://zapier.com/apps/ghost/integrations?utm_medium=partner_api&utm_source=widget&utm_campaign=Widget",rel:"noopener noreferrer",target:"_blank",children:["View more Ghost integrations powered by ",a.jsx("span",{children:a.jsx(ut,{className:"relative top-[-2px] inline-block",name:"zapier-logo",size:24})})]}),a.jsx(Ue,{color:"black",label:"Close",onClick:()=>{e.remove()}})]}),okColor:"black",okLabel:"Close",testId:"zapier-modal",title:"",stickyFooter:!0,onOk:()=>{n("integrations"),e.remove()},children:[a.jsx(lo,{detail:"Automation for your favorite apps",extra:a.jsx("div",{className:"-mb-4 mt-1",children:a.jsx(hd,{keys:[{label:"Admin API key",text:p?.secret,hint:b?a.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:m},{label:"API URL",text:window.location.origin+rl().subdir}]})}),icon:a.jsx(ut,{name:"zapier",size:56}),title:"Zapier"}),a.jsx(ln,{children:s.map(v=>a.jsx(On,{action:a.jsx(Ue,{className:"whitespace-nowrap text-sm font-semibold text-[#FF4A00]",href:v.url,label:"Use this Zap",tag:"a",target:"_blank",link:!0,unstyled:!0}),bgOnHover:!1,className:"flex items-center gap-3 py-2 pl-3",title:a.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center",children:[a.jsxs("div",{className:"flex shrink-0 flex-nowrap items-center gap-2",children:[a.jsx("img",{className:"size-8 object-contain dark:invert",role:"presentation",src:v.ghostImage}),a.jsx(ut,{name:"arrow-right",size:"xs"}),a.jsx("img",{className:"size-8 object-contain",role:"presentation",src:v.appImage})]}),a.jsx("span",{className:"text-sm",children:v.title})]}),hideActions:!0}))})]})});function rb(e){const n="The URL must be in a format like https://www.threads.net/@yourUsername";if(!e)return"";if(e.startsWith("http")){if(!e.includes("threads.net")&&!e.includes("threads.com"))throw new Error(n);if(e=e.replace("threads.com","threads.net"),e.includes("www.")||(e=e.replace("https://","https://www.")),!Nt.isURL(e))throw new Error(n);if(!e.match(/^https:\/\/www\.threads\.net\/@?[a-zA-Z0-9._]+$/))throw new Error(n);return e}if(!e.includes("/")){if(e.startsWith("@")&&(e=e.slice(1)),!e.match(/^[a-zA-Z0-9._]+$/))throw new Error(n);return`https://www.threads.net/@${e}`}throw new Error(n)}const vM=e=>`https://www.threads.net/${e}`,wM=e=>{const n=e.match(/(?:https:\/\/)(?:www\.)?(?:threads\.(?:com|net))(?:\/)?(?:#!\/)?@?([^/]*)/)?.[1];return n?`@${n}`:null},qs={INVALID_USERNAME:"Your Username is not a valid Bluesky Username",INVALID_URL:"The URL must be in a format like https://bsky.app/profile/yourUsername"};function nb(e){return[/^did:plc:[a-z2-7]{24}$/,/^[a-zA-Z0-9._]{1,15}$/,/^(?=.{1,191}$)[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$/].some(s=>s.test(e))}function Bf(e){let n=e.trim();return n.startsWith("@")&&(n=n.slice(1)),n.startsWith("did:plc:")?n.toLowerCase():n}function sb(e){if(!e)return"";let n;if(e.startsWith("http")||e.startsWith("www.")||e.includes("bsky.app")){if(!e.includes("bsky.app"))throw new Error(qs.INVALID_URL);const o=e.match(/bsky\.app\/profile\/@?([^/]+)/);if(!o)throw new Error(qs.INVALID_URL);n=Bf(o[1])}else n=Bf(e);if(!nb(n))throw new Error(qs.INVALID_USERNAME);const s=`https://bsky.app/profile/${n}`;if(!Nt.isURL(s))throw new Error(qs.INVALID_URL);return s}const yM=e=>{if(!e)throw new Error(qs.INVALID_USERNAME);let n=Bf(e);if(!nb(n))throw new Error(qs.INVALID_USERNAME);return`https://bsky.app/profile/${n}`},_M=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/@?([^/]*)/);return n?`${n[1]}`:null},es={INVALID_URL:"The URL must be in a format like https://www.linkedin.com/in/yourUsername",INVALID_USERNAME:"Your Username is not a valid LinkedIn Username"},kM=["in","pub","company","school"],MM=/^[a-zA-Z0-9-]{3,100}$/,jM=/^[a-zA-Z0-9-]{3,100}(?:\/[a-zA-Z0-9-]*)*$/,ab=/^(?:https?:\/\/)?(?:www\.)?(?:([a-z]{2})\.)?linkedin\.com\/(in|pub|company|school)\/([^?#]+)/i,Wf=e=>e.trim().replace(/^@/,""),ob=e=>{if(/^(https?:\/\/|www\.)/.test(e)||e.includes("linkedin.com")){const o=e.match(ab);if(!o)throw new Error(es.INVALID_URL);if(o[0].length!==e.length)throw new Error(es.INVALID_USERNAME);const[,c,h,y]=o,b=Wf(y);if(c&&!/^[A-Z]{2}$/.test(c.toUpperCase()))throw new Error(es.INVALID_URL);return{regional:c,pathType:h,username:b}}const n=Wf(e),s=n.indexOf("/");if(s!==-1){const o=n.substring(0,s);if(kM.includes(o))return{pathType:o,username:n.substring(s+1)}}return{username:n}},ib=(e,n)=>(e==="pub"?jM:MM).test(n),lb=({regional:e,pathType:n,username:s})=>{const c=`https://${e?`${e.toLowerCase()}.`:"www."}linkedin.com/${n}/${s}`;if(!Nt.isURL(c))throw new Error(es.INVALID_URL);return c};function cb(e){if(!e)return"";const{regional:n,pathType:s="in",username:o}=ob(e);if(!ib(s,o))throw new Error(es.INVALID_USERNAME);return lb({regional:n,pathType:s,username:o})}const EM=e=>{if(!e)throw new Error(es.INVALID_USERNAME);const{regional:n,pathType:s="in",username:o}=ob(e);if(!ib(s,o))throw new Error(es.INVALID_USERNAME);return lb({regional:n,pathType:s,username:o})},TM=e=>{const n=e.match(ab);if(!n)return null;const[,,s,o]=n,c=Wf(o);return s==="in"?c:`${s}/${c}`};function ub(e){const n="The URL must be in a format like https://www.instagram.com/yourUsername",s="Your Username is not a valid Instagram Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("instagram.com")){if(!e.includes("instagram.com"))throw new Error(n);const h=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]+)/);if(!h)throw new Error(n);o=h[1]}else o=e.startsWith("@")?e.slice(1):e;if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||o.includes("..")||o.length>30)throw new Error(s);const c=`https://www.instagram.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const SM=e=>{const n="Your Username is not a valid Instagram Username";if(!e)throw new Error(n);let s=e;if(s.startsWith("@")&&(s=s.slice(1)),!s.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,28}[a-zA-Z0-9_]$/)||s.includes("..")||s.length>30)throw new Error(n);return`https://www.instagram.com/${s}`},NM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?instagram\.com\/@?([^/]*)/);return n?`${n[1]}`:null};function fb(e){const n="The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId",s="Your Username is not a valid YouTube Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("youtube.com")){if(!e.includes("youtube.com"))throw new Error(n);const h=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]+)/);if(!h)throw new Error(n);o=h[1]}else o=e;if(o.startsWith("@")){const h=o.slice(1);if(!h.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||h.includes("..")||h.length>30)throw new Error(s)}else if(o.startsWith("user/")){if(!o.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(s)}else if(o.startsWith("channel/")){if(!o.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(s)}else throw new Error(n);const c=`https://www.youtube.com/${o}`;if(!Nt.isURL(c))throw new Error(n);return c}const AM=e=>{const n="Your Username is not a valid YouTube Username";if(!e)throw new Error(n);if(e.startsWith("@")){const s=e.slice(1);if(!s.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]{1,28}[a-zA-Z0-9]$/)||s.includes("..")||s.length>30)throw new Error(n)}else if(e.startsWith("user/")){if(!e.slice(5).match(/^[a-zA-Z0-9._-]{1,50}$/))throw new Error(n)}else if(e.startsWith("channel/")){if(!e.slice(8).match(/^UC[a-zA-Z0-9_-]{22}$/))throw new Error(n)}else throw new Error("The handle must be in a format like @yourUsername, user/yourUsername, or channel/yourChannelId");return`https://www.youtube.com/${e}`},IM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/((?:@|user\/|channel\/)[^/]*)/);return n?n[1]:null};function db(e){const n="The URL must be in a format like https://www.tiktok.com/@yourUsername",s="Your Username is not a valid TikTok Username";if(!e)return"";let o;if(e.startsWith("http")||e.startsWith("www.")||e.includes("tiktok.com")){if(!e.includes("tiktok.com"))throw new Error(n);const y=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]+)/);if(!y)throw new Error(n);o=y[1]}else o=e.startsWith("@")?e:`@${e}`;const c=o.slice(1);if(!c.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||c.includes("..")||c.length<2||c.length>24)throw new Error(s);const h=`https://www.tiktok.com/${o}`;if(!Nt.isURL(h))throw new Error(n);return h}const CM=e=>{const n="Your Username is not a valid TikTok Username";if(!e)throw new Error(n);const s=e.startsWith("@")?e:`@${e}`,o=s.slice(1);if(!o.match(/^[a-zA-Z0-9_][a-zA-Z0-9._]{0,22}[a-zA-Z0-9_]$/)||o.includes("..")||o.length<2||o.length>24)throw new Error(n);return`https://www.tiktok.com/${s}`},DM=e=>{const n=e.match(/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/(@[^/]*)/);return n?n[1]:null};function pb(e){const n="The URL must be in a format like @username@instance.tld or https://instance.tld/@username or https://website.com/@username@instance.tld";if(!e)return"";let s=e;if(s=s.replace(/^https?:\/\//,""),s.match(/^@[^@]+@[^/]+$/)){const[o,c]=s.split("@").slice(1);if(!Nt.isFQDN(c))throw new Error(n);return`https://${c}/@${o}`}if(s.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[o,c]=s.split("/@");if(!Nt.isFQDN(o))throw new Error(n);if(c.includes("@")){const[,h]=c.split("@");if(!Nt.isFQDN(h))throw new Error(n)}return`https://${s}`}throw new Error(n)}const RM=e=>{const n="Your Username is not a valid Mastodon Username";if(!e)throw new Error(n);if(e.match(/^@[^@]+@[^/]+$/)){const[s,o]=e.split("@").slice(1);if(!Nt.isFQDN(o))throw new Error(n);return`https://${o}/@${s}`}if(e.match(/^[^/]+\.[^/]+\/@[^/]+(@[^/]+)?$/)){const[s,o]=e.split("/@");if(!Nt.isFQDN(s))throw new Error(n);if(o.includes("@")){const[,c]=o.split("@");if(!Nt.isFQDN(c))throw new Error(n)}return`https://${e}`}throw new Error(n)},OM=e=>e.replace(/^https?:\/\//,""),$M=({tier:e})=>{const n=e?.type==="free",{updateRoute:s}=Je(),{mutateAsync:o}=Qf(),{mutateAsync:c}=I_(),{mutateAsync:h}=as(),[y,b]=st.useState(!!e?.trial_days),l=it(),{localSettings:u,siteData:f}=os(),[p]=bt(u,["portal_plans"]),m=JSON.parse(p?.toString()||"[]"),v={name:()=>_.name?void 0:"Enter a name for the tier",monthly_price:()=>_.type!=="free"?ih(_.monthly_price||0,_.currency,{allowZero:!1}):void 0,yearly_price:()=>_.type!=="free"?ih(_.yearly_price||0,_.currency,{allowZero:!1}):void 0},{formState:_,saveState:k,updateForm:M,handleSave:T,errors:A,clearError:C,okProps:O}=kr({initialState:{...e||{},trial_days:e?.trial_days?.toString()||"",currency:e?.currency||C_[0].isoCode,visibility:e?.visibility||"none",welcome_page_url:e?.welcome_page_url||null},savingDelay:500,savedDelay:500,onValidate:()=>{const G={};return Object.entries(v).forEach(([W,q])=>{G[W]=q?.()}),G},onSave:async()=>{const{trial_days:G,currency:W,...q}=_,se=q;if(se.benefits=se.benefits?.filter(J=>J),n||(se.currency=W,se.trial_days=parseInt(G)),e?.id?await o({...e,...se}):await c(se),n){const J=_.visibility==="public";let te=!1;m.includes("free")&&!J&&(m.splice(m.indexOf("free"),1),te=!0),!m.includes("free")&&J&&(m.push("free"),te=!0),te&&await h([{key:"portal_plans",value:JSON.stringify(m)}])}},onSaveError:l}),$=eb({items:_.benefits||[],setItems:G=>M(W=>({...W,benefits:G})),blank:"",canAddNewItem:G=>!!G}),B=G=>{G.target.checked?(b(!0),M(W=>({...W,trial_days:e?.trial_days?e?.trial_days.toString():"7"}))):(b(!1),M(W=>({...W,trial_days:"0"})))},R=D.useRef(!1);D.useEffect(()=>{R.current&&(v.monthly_price?.(),v.yearly_price?.()),R.current=!0},[_.currency]);const V=()=>{if(e){const G=e.active?"Archive tier":"Reactivate tier",W=e.active?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:["Members will no longer be able to subscribe to ",a.jsx("strong",{children:e.name})," and it will be removed from the list of available tiers in portal."]}),a.jsx("div",{children:"Existing members on this tier will remain unchanged. Offers using this tier will be disabled."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-6",children:["Reactivating ",a.jsx("strong",{children:e.name})," will re-enable it as an option in portal and allow new members to subscribe to this tier."]}),a.jsx("div",{children:"Existing members will remain unchanged."})]}),q=e.active?"Archive":"Reactivate";_e.show(St,{title:G,prompt:W,okLabel:q,cancelLabel:"Cancel",okColor:e.active?"red":"black",onOk:se=>{o({...e,active:!e.active}),se?.remove(),gt({type:"success",title:`Tier ${e.active?"archived":"reactivated"}`})}})}};let K={};return e&&(e.active&&e.type!=="free"?K={label:"Archive tier",color:"red",link:!0,onClick:V}:e.active||(K={label:"Reactivate tier",color:"green",link:!0,onClick:V})),a.jsx(_t,{afterClose:()=>{s("tiers")},buttonsDisabled:O.disabled,cancelLabel:"Close",dirty:k==="unsaved",leftButtonProps:K,okColor:O.color,okLabel:O.label||"Save",size:"lg",testId:"tier-detail-modal",title:e?e.active?"Edit tier":"Edit archived tier":"New tier",stickyFooter:!0,onOk:async()=>{await T({fakeWhenUnchanged:!0})},children:a.jsxs("div",{className:"-mb-8 mt-8 flex items-start gap-8",children:[a.jsxs("div",{className:"flex grow flex-col gap-8",children:[a.jsxs(rt,{marginBottom:!1,title:"Basic",grouped:!0,children:[a.jsx(Ne,{autoComplete:"off",error:!!A.name,hint:A.name,maxLength:191,placeholder:n?"Free":"Bronze",title:"Name",value:_.name||"",autoFocus:!0,onChange:G=>M(W=>({...W,name:G.target.value})),onKeyDown:()=>C("name")}),a.jsx(Ne,{autoComplete:"off",autoFocus:n,maxLength:191,placeholder:n?"Free preview":"Full access to premium content",title:"Description",value:_.description||"",onChange:G=>M(W=>({...W,description:G.target.value}))}),!n&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex flex-col gap-10 md:flex-row",children:[a.jsxs("div",{className:"basis-1/2",children:[a.jsxs("div",{className:"mb-1 flex h-6 items-center justify-between",children:[a.jsx(xt,{level:6,children:"Prices"}),a.jsx("div",{className:"-mr-2 w-[50px]",children:a.jsx(Pt,{border:!1,containerClassName:"font-medium",controlClasses:{menu:"w-18"},options:lh(),selectedOption:lh().flatMap(G=>G.options).find(G=>G.value===_.currency),size:"xs",clearBg:!0,isSearchable:!0,onSelect:G=>M(W=>({...W,currency:G?.value}))})})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(ch,{error:!!A.monthly_price,hint:A.monthly_price,placeholder:"5",rightPlaceholder:`${_.currency}/month`,title:"Monthly price",valueInCents:_.monthly_price||"",hideTitle:!0,onBlur:G=>G.target.value===""?M(W=>({...W,monthly_price:0})):null,onChange:G=>M(W=>({...W,monthly_price:G})),onKeyDown:()=>C("monthly_price")}),a.jsx(ch,{error:!!A.yearly_price,hint:A.yearly_price,placeholder:"50",rightPlaceholder:`${_.currency}/year`,title:"Yearly price",valueInCents:_.yearly_price||"",hideTitle:!0,onBlur:G=>G.target.value===""?M(W=>({...W,yearly_price:0})):null,onChange:G=>M(W=>({...W,yearly_price:G})),onKeyDown:()=>C("yearly_price")})]})]}),a.jsxs("div",{className:"basis-1/2",children:[a.jsx("div",{className:"mb-1 flex h-6 flex-col justify-center",children:a.jsx(ot,{checked:y,label:"Add a free trial",labelStyle:"heading",onChange:B})}),a.jsx(Ne,{disabled:!y,hint:a.jsxs("div",{className:"mt-1",children:["Members will be subscribed at full price once the trial ends. ",a.jsx("a",{className:"text-green",href:"https://ghost.org/help/free-trials/",rel:"noreferrer",target:"_blank",children:"Learn more"})]}),placeholder:"0",rightPlaceholder:"days",title:"Trial days",value:_.trial_days,hideTitle:!0,onChange:G=>M(W=>({...W,trial_days:G.target.value.replace(/[^\d]/,"")}))})]})]})}),a.jsx(qg,{baseUrl:f?.url,hint:`Redirect to this URL after signup ${n?"":" for premium membership"}`,maxLength:2e3,placeholder:f?.url,title:"Welcome page",value:_.welcome_page_url||null,nullable:!0,transformPathWithoutSlash:!0,onChange:G=>M(W=>({...W,welcome_page_url:G||null}))})]}),a.jsxs(rt,{gap:"none",title:"Benefits",grouped:!0,children:[a.jsx("div",{className:"-mt-3",children:a.jsx(Yg,{items:$.items,itemSeparator:!1,renderItem:({id:G,item:W})=>a.jsxs("div",{className:"relative flex w-full items-center gap-5",children:[a.jsx("div",{className:"absolute left-[-32px] top-[7px] flex size-6 items-center justify-center bg-white group-hover:hidden dark:bg-black",children:a.jsx(ut,{name:"check",size:"sm"})}),a.jsx(Ne,{maxLength:191,value:W,onChange:q=>$.updateItem(G,q.target.value)}),a.jsx(Ue,{className:"absolute right-1 top-1 z-10 opacity-0 group-hover:opacity-100",color:"grey",icon:"trash",size:"sm",onClick:()=>$.removeItem(G)})]}),onMove:$.moveItem})}),a.jsxs("div",{className:"relative mt-1 flex items-center gap-3",children:[a.jsx(ut,{className:"dark:text-white",name:"check",size:"sm"}),a.jsx(Ne,{className:"grow",containerClassName:"w-100",maxLength:191,placeholder:"Expert analysis",title:"New benefit",value:$.newItem,hideTitle:!0,onChange:G=>$.setNewItem(G.target.value),onKeyDown:G=>{G.key==="Enter"&&$.addItem()}}),a.jsx(Ue,{className:"absolute right-[5px] top-[5px] z-10",color:"green",icon:"add",iconColorClass:"text-white",label:"Add",size:"sm",hideLabel:!0,onClick:()=>$.addItem()})]})]})]}),a.jsx("div",{className:"sticky top-[96px] hidden shrink-0 basis-[380px] min-[920px]:!visible min-[920px]:!block",children:a.jsx(D_,{isFreeTier:n,tier:_})})]})})},PM=({params:e})=>{const{data:{tiers:n,isEnd:s}={},fetchNextPage:o}=oo();let c;return D.useEffect(()=>{e?.id&&!c&&!s&&o()},[o,s,e?.id,c]),e?.id&&(c=n?.find(({id:h})=>h===e?.id),!c)?null:a.jsx($M,{tier:c})},LM=_e.create(PM);var lu,Hh;function hb(){if(Hh)return lu;Hh=1;var e={};return lu=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...s)=>console.error("SEMVER",...s):()=>{},lu}var cu,Bh;function mb(){if(Bh)return cu;Bh=1;const e="2.0.0",n=256,s=Number.MAX_SAFE_INTEGER||9007199254740991,o=16,c=n-6;return cu={MAX_LENGTH:n,MAX_SAFE_COMPONENT_LENGTH:o,MAX_SAFE_BUILD_LENGTH:c,MAX_SAFE_INTEGER:s,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},cu}var Li={exports:{}},Wh;function FM(){return Wh||(Wh=1,(function(e,n){const{MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:c}=mb(),h=hb();n=e.exports={};const y=n.re=[],b=n.safeRe=[],l=n.src=[],u=n.safeSrc=[],f=n.t={};let p=0;const m="[a-zA-Z0-9-]",v=[["\\s",1],["\\d",c],[m,o]],_=M=>{for(const[T,A]of v)M=M.split(`${T}*`).join(`${T}{0,${A}}`).split(`${T}+`).join(`${T}{1,${A}}`);return M},k=(M,T,A)=>{const C=_(T),O=p++;h(M,O,T),f[M]=O,l[O]=T,u[O]=C,y[O]=new RegExp(T,A?"g":void 0),b[O]=new RegExp(C,A?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*"),k("NUMERICIDENTIFIERLOOSE","\\d+"),k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${m}*`),k("MAINVERSION",`(${l[f.NUMERICIDENTIFIER]})\\.(${l[f.NUMERICIDENTIFIER]})\\.(${l[f.NUMERICIDENTIFIER]})`),k("MAINVERSIONLOOSE",`(${l[f.NUMERICIDENTIFIERLOOSE]})\\.(${l[f.NUMERICIDENTIFIERLOOSE]})\\.(${l[f.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASEIDENTIFIER",`(?:${l[f.NONNUMERICIDENTIFIER]}|${l[f.NUMERICIDENTIFIER]})`),k("PRERELEASEIDENTIFIERLOOSE",`(?:${l[f.NONNUMERICIDENTIFIER]}|${l[f.NUMERICIDENTIFIERLOOSE]})`),k("PRERELEASE",`(?:-(${l[f.PRERELEASEIDENTIFIER]}(?:\\.${l[f.PRERELEASEIDENTIFIER]})*))`),k("PRERELEASELOOSE",`(?:-?(${l[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[f.PRERELEASEIDENTIFIERLOOSE]})*))`),k("BUILDIDENTIFIER",`${m}+`),k("BUILD",`(?:\\+(${l[f.BUILDIDENTIFIER]}(?:\\.${l[f.BUILDIDENTIFIER]})*))`),k("FULLPLAIN",`v?${l[f.MAINVERSION]}${l[f.PRERELEASE]}?${l[f.BUILD]}?`),k("FULL",`^${l[f.FULLPLAIN]}$`),k("LOOSEPLAIN",`[v=\\s]*${l[f.MAINVERSIONLOOSE]}${l[f.PRERELEASELOOSE]}?${l[f.BUILD]}?`),k("LOOSE",`^${l[f.LOOSEPLAIN]}$`),k("GTLT","((?:<|>)?=?)"),k("XRANGEIDENTIFIERLOOSE",`${l[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),k("XRANGEIDENTIFIER",`${l[f.NUMERICIDENTIFIER]}|x|X|\\*`),k("XRANGEPLAIN",`[v=\\s]*(${l[f.XRANGEIDENTIFIER]})(?:\\.(${l[f.XRANGEIDENTIFIER]})(?:\\.(${l[f.XRANGEIDENTIFIER]})(?:${l[f.PRERELEASE]})?${l[f.BUILD]}?)?)?`),k("XRANGEPLAINLOOSE",`[v=\\s]*(${l[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[f.XRANGEIDENTIFIERLOOSE]})(?:${l[f.PRERELEASELOOSE]})?${l[f.BUILD]}?)?)?`),k("XRANGE",`^${l[f.GTLT]}\\s*${l[f.XRANGEPLAIN]}$`),k("XRANGELOOSE",`^${l[f.GTLT]}\\s*${l[f.XRANGEPLAINLOOSE]}$`),k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${s}})(?:\\.(\\d{1,${s}}))?(?:\\.(\\d{1,${s}}))?`),k("COERCE",`${l[f.COERCEPLAIN]}(?:$|[^\\d])`),k("COERCEFULL",l[f.COERCEPLAIN]+`(?:${l[f.PRERELEASE]})?(?:${l[f.BUILD]})?(?:$|[^\\d])`),k("COERCERTL",l[f.COERCE],!0),k("COERCERTLFULL",l[f.COERCEFULL],!0),k("LONETILDE","(?:~>?)"),k("TILDETRIM",`(\\s*)${l[f.LONETILDE]}\\s+`,!0),n.tildeTrimReplace="$1~",k("TILDE",`^${l[f.LONETILDE]}${l[f.XRANGEPLAIN]}$`),k("TILDELOOSE",`^${l[f.LONETILDE]}${l[f.XRANGEPLAINLOOSE]}$`),k("LONECARET","(?:\\^)"),k("CARETTRIM",`(\\s*)${l[f.LONECARET]}\\s+`,!0),n.caretTrimReplace="$1^",k("CARET",`^${l[f.LONECARET]}${l[f.XRANGEPLAIN]}$`),k("CARETLOOSE",`^${l[f.LONECARET]}${l[f.XRANGEPLAINLOOSE]}$`),k("COMPARATORLOOSE",`^${l[f.GTLT]}\\s*(${l[f.LOOSEPLAIN]})$|^$`),k("COMPARATOR",`^${l[f.GTLT]}\\s*(${l[f.FULLPLAIN]})$|^$`),k("COMPARATORTRIM",`(\\s*)${l[f.GTLT]}\\s*(${l[f.LOOSEPLAIN]}|${l[f.XRANGEPLAIN]})`,!0),n.comparatorTrimReplace="$1$2$3",k("HYPHENRANGE",`^\\s*(${l[f.XRANGEPLAIN]})\\s+-\\s+(${l[f.XRANGEPLAIN]})\\s*$`),k("HYPHENRANGELOOSE",`^\\s*(${l[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[f.XRANGEPLAINLOOSE]})\\s*$`),k("STAR","(<|>)?=?\\s*\\*"),k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Li,Li.exports)),Li.exports}var uu,qh;function UM(){if(qh)return uu;qh=1;const e=Object.freeze({loose:!0}),n=Object.freeze({});return uu=o=>o?typeof o!="object"?e:o:n,uu}var fu,Yh;function zM(){if(Yh)return fu;Yh=1;const e=/^[0-9]+$/,n=(o,c)=>{if(typeof o=="number"&&typeof c=="number")return o===c?0:o<c?-1:1;const h=e.test(o),y=e.test(c);return h&&y&&(o=+o,c=+c),o===c?0:h&&!y?-1:y&&!h?1:o<c?-1:1};return fu={compareIdentifiers:n,rcompareIdentifiers:(o,c)=>n(c,o)},fu}var du,Gh;function HM(){if(Gh)return du;Gh=1;const e=hb(),{MAX_LENGTH:n,MAX_SAFE_INTEGER:s}=mb(),{safeRe:o,t:c}=FM(),h=UM(),{compareIdentifiers:y}=zM();class b{constructor(u,f){if(f=h(f),u instanceof b){if(u.loose===!!f.loose&&u.includePrerelease===!!f.includePrerelease)return u;u=u.version}else if(typeof u!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof u}".`);if(u.length>n)throw new TypeError(`version is longer than ${n} characters`);e("SemVer",u,f),this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease;const p=u.trim().match(f.loose?o[c.LOOSE]:o[c.FULL]);if(!p)throw new TypeError(`Invalid Version: ${u}`);if(this.raw=u,this.major=+p[1],this.minor=+p[2],this.patch=+p[3],this.major>s||this.major<0)throw new TypeError("Invalid major version");if(this.minor>s||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>s||this.patch<0)throw new TypeError("Invalid patch version");p[4]?this.prerelease=p[4].split(".").map(m=>{if(/^[0-9]+$/.test(m)){const v=+m;if(v>=0&&v<s)return v}return m}):this.prerelease=[],this.build=p[5]?p[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(u){if(e("SemVer.compare",this.version,this.options,u),!(u instanceof b)){if(typeof u=="string"&&u===this.version)return 0;u=new b(u,this.options)}return u.version===this.version?0:this.compareMain(u)||this.comparePre(u)}compareMain(u){return u instanceof b||(u=new b(u,this.options)),this.major<u.major?-1:this.major>u.major?1:this.minor<u.minor?-1:this.minor>u.minor?1:this.patch<u.patch?-1:this.patch>u.patch?1:0}comparePre(u){if(u instanceof b||(u=new b(u,this.options)),this.prerelease.length&&!u.prerelease.length)return-1;if(!this.prerelease.length&&u.prerelease.length)return 1;if(!this.prerelease.length&&!u.prerelease.length)return 0;let f=0;do{const p=this.prerelease[f],m=u.prerelease[f];if(e("prerelease compare",f,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return y(p,m)}while(++f)}compareBuild(u){u instanceof b||(u=new b(u,this.options));let f=0;do{const p=this.build[f],m=u.build[f];if(e("build compare",f,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return y(p,m)}while(++f)}inc(u,f,p){if(u.startsWith("pre")){if(!f&&p===!1)throw new Error("invalid increment argument: identifier is empty");if(f){const m=`-${f}`.match(this.options.loose?o[c.PRERELEASELOOSE]:o[c.PRERELEASE]);if(!m||m[1]!==f)throw new Error(`invalid identifier: ${f}`)}}switch(u){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",f,p);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",f,p);break;case"prepatch":this.prerelease.length=0,this.inc("patch",f,p),this.inc("pre",f,p);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",f,p),this.inc("pre",f,p);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const m=Number(p)?1:0;if(this.prerelease.length===0)this.prerelease=[m];else{let v=this.prerelease.length;for(;--v>=0;)typeof this.prerelease[v]=="number"&&(this.prerelease[v]++,v=-2);if(v===-1){if(f===this.prerelease.join(".")&&p===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(m)}}if(f){let v=[f,m];p===!1&&(v=[f]),y(this.prerelease[0],f)===0?isNaN(this.prerelease[1])&&(this.prerelease=v):this.prerelease=v}break}default:throw new Error(`invalid increment argument: ${u}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return du=b,du}var pu,Xh;function BM(){if(Xh)return pu;Xh=1;const e=HM();return pu=(s,o,c=!1)=>{if(s instanceof e)return s;try{return new e(s,o)}catch(h){if(!c)return null;throw h}},pu}var WM=BM();const qM=Gg(WM);function Kh(e){if(!e)return"";const n=e.replace("+moya","");try{const o=qM(n,{includePrerelease:!0})?.prerelease;if(o&&o?.length>0){const h=String(o[0]).split("-")[1];return!h||!h.startsWith("g")?"":`https://github.com/TryGhost/Ghost/commit/${h.slice(1)}`}return`https://github.com/TryGhost/Ghost/releases/tag/v${n}`}catch{return""}}function YM(e,n){const s=!!e.match?.(/production/i);return!!(s&&n!=="mysql8"||!s&&n==="mysql5")}const GM=_e.create(({})=>{const{updateRoute:e}=Je();let s=et().config;const o=R_();function c(){return new Date().getFullYear()}function h(){return!!s.enableDeveloperExperiments}function y(){return!s.hostSettings?.siteId}return a.jsx(_t,{afterClose:()=>{e("")},cancelLabel:"",footer:a.jsx(a.Fragment,{}),topRightContent:"close",width:540,children:a.jsxs("div",{className:"flex flex-col gap-4 pb-7 text-sm",children:[a.jsx(O_,{className:"h-auto w-[120px] dark:invert"}),a.jsxs("div",{className:"mt-3 flex flex-col gap-1.5",children:[o?.message&&a.jsxs("div",{className:"gh-prose-links mb-4 rounded-sm border border-green p-5",children:[a.jsx("strong",{children:"Update available!"}),a.jsx("div",{dangerouslySetInnerHTML:{__html:o.message}})]}),Kh(s.version)&&a.jsxs("div",{children:[a.jsx("strong",{children:"Version:"})," ",a.jsx("a",{className:"text-green",href:Kh(s.version),rel:"noopener noreferrer",target:"_blank",children:s.version})]})||a.jsxs("div",{children:[a.jsx("strong",{children:"Version:"})," ",s.version]}),y()&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Environment:"})," ",s.environment]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Database:"})," ",s.database]}),a.jsxs("div",{children:[a.jsx("strong",{children:"Mail:"})," ",s.mail?s.mail:"Native"]})]}),h()&&a.jsxs("div",{children:[a.jsx("strong",{children:"Developer experiments:"})," Enabled"]}),y()&&YM(s.environment,s.database)&&a.jsxs("div",{className:"text-red-500 dark:text-red-400",children:["You are running an unsupported database in production. Please ",a.jsx("a",{href:"https://ghost.org/docs/faq/supported-databases/",rel:"noopener noreferrer",target:"_blank",children:"upgrade to MySQL 8"}),"."]})]}),a.jsx(Qa,{}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"book-open",size:"sm"})," User documentation"]}),a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://forum.ghost.org/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"question-circle",size:"sm"})," Get help with Ghost"]}),a.jsxs("a",{className:"flex items-center gap-2 hover:text-grey-900 dark:hover:text-grey-400",href:"https://ghost.org/docs/contributing/",rel:"noopener noreferrer",target:"_blank",children:[a.jsx(ut,{name:"angle-brackets",size:"sm"})," Get involved"]})]}),a.jsx(Qa,{}),a.jsxs("p",{className:"max-w-[460px] text-xs",children:["Copyright © 2013 – ",c()," Ghost Foundation, released under the ",a.jsx("a",{className:"text-green",href:"https://github.com/TryGhost/Ghost/blob/main/LICENSE",rel:"noopener noreferrer",target:"_blank",children:"MIT license"}),". ",a.jsx("a",{className:"text-green",href:"https://ghost.org/",rel:"noopener noreferrer",target:"_blank",children:"Ghost"})," is a registered trademark of ",a.jsx("a",{className:"text-green",href:"https://ghost.org/trademark/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Foundation Ltd"}),"."]})]})})}),XM=()=>{const e=Zt(),{updateRoute:n}=Je(),[s,o]=D.useState(""),[c,h]=D.useState({name:""}),{mutateAsync:y}=$_(),b=Xs(),l=it();return D.useEffect(()=>{b?.isLimited("customIntegrations")&&b.errorIfWouldGoOverLimit("customIntegrations").catch(u=>{u instanceof Ks&&(_e.show(Xr,{prompt:u.message||"Your current plan doesn't support more custom integrations.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("integrations"))})},[b,e,n]),a.jsx(_t,{afterClose:()=>{n("integrations")},okColor:"black",okLabel:"Add",size:"sm",testId:"add-integration-modal",title:"Add integration",onOk:async()=>{if(!s){h({name:"Name is required"});return}try{const u=await y({name:s});e.remove(),n({route:`integrations/${u.integrations[0].id}`})}catch(u){l(u)}},children:a.jsx("div",{className:"mt-5",children:a.jsx(rt,{marginBottom:!1,marginTop:!1,children:a.jsx(Ne,{autoFocus:!0,error:!!c.name,hint:c.name,maxLength:191,placeholder:"Custom integration",title:"Name",value:s,onChange:u=>o(u.target.value),onInput:()=>{c.name&&h({name:""})}})})})})},KM=_e.create(XM),ZM=()=>{const e=Zt(),{updateRoute:n}=Je(),s=it(),[o,c]=D.useState(!0),[h,y]=D.useState(null),{data:b}=Xg({searchParams:{filter:"newsletters.status:active+email_disabled:0",limit:"1",page:"1",include:"newsletters,labels"}}),{mutateAsync:l}=P_(),{formState:u,updateForm:f,saveState:p,handleSave:m,errors:v,clearError:_}=kr({initialState:{name:"",description:"",optInExistingSubscribers:!0},onSave:async()=>{const T=await l({name:u.name,description:u.description,opt_in_existing:u.optInExistingSubscribers,feedback_enabled:!0});n({route:`newsletters/${T.newsletters[0].id}`})},onSaveError:s,onValidate:()=>{const T={};return u.name||(T.name="A name is required for your newsletter"),T}}),k=Xs();D.useEffect(()=>{if(!k){c(!1);return}k.errorIfWouldGoOverLimit("newsletters").catch(T=>{if(T instanceof Ks)y(T);else throw T}).finally(()=>{c(!1)})},[k]);const M=b?.meta?.pagination.total;return D.useEffect(()=>{h&&(_e.show(Xr,{prompt:h.message||"Your current plan doesn't support more newsletters.",onOk:()=>n({route:"/pro",isExternal:!0})}),e.remove(),n("newsletters"))},[h,e,n]),o||h?null:a.jsx(_t,{afterClose:()=>{n("newsletters")},backDropClick:!1,okColor:"black",okDisabled:p==="saving",okLabel:"Create",okLoading:p==="saving",size:"sm",testId:"add-newsletter-modal",title:"Create newsletter",onOk:async()=>{await m()&&e.remove()},children:a.jsxs(rt,{marginBottom:!1,marginTop:!0,children:[a.jsx(Ne,{autoFocus:!0,error:!!v.name,hint:v.name,maxLength:191,placeholder:"Weekly roundup",title:"Name",value:u.name,onChange:T=>f(A=>({...A,name:T.target.value})),onKeyDown:()=>_("name")}),a.jsx($n,{maxLength:2e3,title:"Description",value:u.description,onChange:T=>f(A=>({...A,description:T.target.value}))}),a.jsx(ot,{checked:u.optInExistingSubscribers,direction:"rtl",hint:u.optInExistingSubscribers?`This newsletter will be available to all members. Your ${M===void 0?"":Kg(M)} existing subscriber${b?.meta?.pagination.total===1?"":"s"} will also be opted-in to receive it.`:"The newsletter will be available to all new members. Existing members won’t be subscribed, but may visit their account area to opt-in to future emails.",label:"Opt-in existing subscribers",labelStyle:"heading",onChange:T=>f(A=>({...A,optInExistingSubscribers:T.target.checked}))})]})})},VM=_e.create(ZM),QM=({recommendation:e,animate:n})=>{const s=Zt(),{updateRoute:o,route:c}=Je(),{mutateAsync:h}=L_(),y=it(),{formState:b,updateForm:l,handleSave:u,saveState:f,errors:p,clearError:m,setErrors:v}=kr({initialState:{...e},onSave:async T=>{await h(T),s.remove(),gt({title:"Recommendation added",type:"success"}),U_("Recommendation Added",{oneClickSubscribe:T.one_click_subscribe}),o("recommendations")},onSaveError:y,onValidate:T=>F_(T)});let _="Add",k=!1;f==="saving"?k=!0:f==="saved"&&(_="Added");let M={label:"Back",icon:"arrow-left",iconColorClass:"text-black dark:text-white",link:!0,size:"sm",onClick:()=>{f!=="saving"&&(s.remove(),_e.show(gb,{pathName:c,animate:!1,recommendation:{...b}}))}};return a.jsx(_t,{afterClose:()=>{o("recommendations")},animate:n??!0,backDropClick:!1,cancelLabel:"Cancel",dirty:!0,leftButtonProps:M,okColor:"black",okLabel:_,okLoading:k,size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",stickyFooter:!0,onCancel:()=>{f!=="saving"&&(s.remove(),o("recommendations"))},onOk:async()=>{if(f!=="saving"){Zg();try{await u({force:!0})}catch{gt({type:"error",title:"Something went wrong when adding this recommendation, please try again."})}}},children:a.jsx(z_,{clearError:m,errors:p,formState:b,setErrors:v,showURL:!1,updateForm:l})})},JM=_e.create(QM),Zh=e=>qi(e).save||"",ej=function(e,n){try{new URL(n).hostname.includes(".")?delete e.url:e.url="Enter a valid URL"}catch{e.url="Enter a valid URL"}return e},tj=({searchParams:e,recommendation:n,animate:s})=>{const[o,c]=D.useState(!1),h=Zt(),{updateRoute:y}=Je(),{mutateAsync:b}=H_(),l=n?"":e?.get("url")??"",{save:u}=l?qi(l):{save:""},f=st.useRef(!1),[p,m]=st.useState(!!u),{formState:v,updateForm:_,handleSave:k,errors:M,saveState:T,clearError:A}=kr({initialState:n??{title:"",url:u||"",description:"",excerpt:null,featured_image:null,favicon:null,one_click_subscribe:!1},onSave:async()=>{let O;O=new URL(v.url);const $=O.hostname.replace("www.",""),B={...v,url:O.toString()},{recommendations:R=[]}=await b(O);if(!R||R.length===0)return;const V=R[0];if(V.id)throw new uh("A recommendation with this URL already exists.");B.title=V.title??$,B.excerpt=V.excerpt??B.excerpt,B.featured_image=V.featured_image??B.featured_image??null,B.favicon=V.favicon??B.favicon??null,B.one_click_subscribe=V.one_click_subscribe??B.one_click_subscribe??!1,B.description=B.excerpt||null,h.remove(),_e.show(JM,{animate:!1,recommendation:B})},onValidate:()=>{const O={};return ej(O,v.url),p&&m(Object.keys(O).length===0),O}}),C=st.useCallback(async()=>{if(T!=="saving"){Zg();try{if(await k({force:!0}))return}catch(O){const $=O instanceof uh?O.message:"Something went wrong while checking this URL, please try again.";gt({type:"error",title:$})}p&&m(!1)}},[k,T,p,m]);return st.useEffect(()=>{p&&!f.current&&(f.current=!0,C())},[p,C]),D.useEffect(()=>{o&&(C(),c(!1))},[v]),p?a.jsx(_t,{afterClose:()=>{y("recommendations")},animate:s??!0,backDropClick:!1,footer:!1,header:!1,size:"sm",children:a.jsx("div",{className:"flex flex-col items-center justify-center p-8",children:a.jsx(Yi,{})})}):a.jsxs(_t,{afterClose:()=>{y("recommendations")},animate:s??!0,backDropClick:!1,okColor:"black",okLabel:"Next",okLoading:T==="saving",size:"sm",testId:"add-recommendation-modal",title:"Add recommendation",onOk:C,children:[a.jsxs("p",{className:"mt-4",children:["You can recommend ",a.jsx("strong",{children:"any site"})," your audience will find valuable, not just those published on Ghost."]}),a.jsx(rt,{marginBottom:!1,marginTop:!0,children:a.jsx(Ne,{autoFocus:!0,error:!!M.url,hint:M.url||a.jsxs(a.Fragment,{children:["Need inspiration? ",a.jsx("a",{className:"text-green",href:"https://www.ghost.org/explore",rel:"noopener noreferrer",target:"_blank",children:"Explore thousands of sites"})," to recommend"]}),maxLength:2e3,placeholder:"https://www.example.com",title:"URL",value:v.url,onBlur:()=>{const O=Zh(v.url);_($=>({...$,url:O}))},onChange:O=>{A?.("url"),_($=>({...$,url:O.target.value}))},onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),_($=>({...$,url:Zh(v.url)})),c(!0))}})})]})},gb=_e.create(tj);function rj(e,n){let s;return function(...c){const h=()=>{clearTimeout(s),e(...c)};clearTimeout(s),s=setTimeout(h,n)}}const md=({generateContent:e,className:n,height:s,width:o,parentClassName:c,testId:h,addDelay:y=!1})=>{const[b,l]=D.useState(0),u=[D.useRef(null),D.useRef(null)],[f,p]=D.useState(0);return D.useEffect(()=>{const m=b===0?1:0,v=u[m].current;if(v){e(v);const _=()=>{y?setTimeout(()=>{l(m)},500):l(m)};return v.addEventListener("load",_),()=>{v.removeEventListener("load",_)}}},[e]),D.useEffect(()=>{const m=u[b].current,v=rj(()=>{p(m?.contentWindow?.scrollY||0)},250);return m?.contentWindow?.addEventListener("scroll",v),()=>{m?.contentWindow?.removeEventListener("scroll",v)}},[b,u]),D.useEffect(()=>{const m=u[b].current;if(m)try{m.contentWindow?.scrollTo(0,f)}catch(v){B_(v)}},[f,b,u]),a.jsxs("div",{className:c,"data-testid":h,children:[a.jsx("iframe",{ref:u[0],className:`${n} ${b!==0?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":b===0,frameBorder:"0",height:s,title:"Buffered Preview 1",width:o}),a.jsx("iframe",{ref:u[1],className:`${n} ${b!==1?"z-10 opacity-0":"z-20 opacity-100"}`,"data-visible":b===1,frameBorder:"0",height:s,title:"Buffered Preview 2",width:o})]})},nj=(e,n,s)=>{const o=new URLSearchParams;return o.append("announcement_bg",e||"accent"),o.append("announcement",n||""),s&&s.length>0&&o.append("announcement_vis",s?.join(",")||""),o.toString()},sj=({announcementBackgroundColor:e,announcementContent:n,url:s,visibility:o})=>{const c=D.useMemo(()=>o,[o?.join(",")]),h=D.useCallback(y=>{s&&fetch(s,{method:"POST",headers:{"Content-Type":"text/html;charset=utf-8","x-ghost-preview":nj(e,n,c),Accept:"text/plain"},mode:"cors",credentials:"include"}).then(b=>b.text()).then(b=>{const l="html { pointer-events: none; }",f=new DOMParser().parseFromString(b,"text/html"),p=f.querySelector("style"),m=p.innerHTML;p.innerHTML=`${m}
2
2
 
3
3
  ${l}`;let _=(f.doctype?new XMLSerializer().serializeToString(f.doctype):"")+f.documentElement.outerHTML;y.contentDocument?.open(),y.contentDocument?.write(_),y.contentDocument?.close()}).catch(()=>{})},[e,n,s,c]);return a.jsx(md,{addDelay:!0,className:"absolute size-[110%] origin-top-left scale-[.90909] bg-white max-[1600px]:size-[130%] max-[1600px]:scale-[.76923]",generateContent:h,height:"100%",parentClassName:"relative h-full w-full",testId:"announcement-bar-preview-iframe",width:"100%"})},aj=({announcementContent:e,announcementTextHandler:n,accentColor:s,announcementBackgroundColor:o,toggleColorSwatch:c,toggleVisibility:h,visibility:y=[],paidMembersEnabled:b,onBlur:l})=>{const u=[{label:"Public visitors",onChange:f=>{h("visitors",f)},value:"visitors",checked:y.includes("visitors")},{label:"Free members",onChange:f=>{h("free_members",f)},value:"free_members",checked:y.includes("free_members")},...b?[{label:"Paid members",onChange:f=>{h("paid_members",f)},value:"paid_members",checked:y.includes("paid_members")}]:[]];return a.jsxs(rt,{children:[a.jsx(ud,{nodes:"MINIMAL_NODES",placeholder:"Highlight breaking news, offers or updates",title:"Announcement",value:e,onBlur:l,onChange:n}),a.jsx(M0,{isExpanded:!1,picker:!1,swatches:[{hex:"#08090c",title:"Dark",value:"dark"},{hex:"#ffffff",title:"Light",value:"light"},{hex:s||"#ffdd00",title:"Accent",value:"accent"}],swatchSize:"lg",title:"Background color",value:o,onSwatchChange:f=>{f!==null&&c(f)},onTogglePicker:()=>{}}),a.jsx(Rf,{checkboxes:u,title:"Visibility"})]})},oj=()=>{const{siteData:e}=et(),{localSettings:n,updateSetting:s,handleSave:o,okProps:c}=os({savingDelay:500}),[h]=bt(n,["announcement_content"]),[y]=bt(n,["accent_color"]),[b]=bt(n,["announcement_background"]),[l]=bt(n,["announcement_visibility"]),[u]=bt(n,["paid_members_enabled"]),f=JSON.parse(l?.toString()||"[]"),{updateRoute:p}=Je(),[m,v]=D.useState("homepage"),_=R=>{s("announcement_background",R)},k=(R,V)=>{const K=f.indexOf(R);K===-1&&V?f.push(R):f.splice(K,1),s("announcement_visibility",JSON.stringify(f))},M=D.useRef(el(R=>{s("announcement_content",R)},500)),T=a.jsx(aj,{accentColor:y,announcementBackgroundColor:b,announcementContent:h,announcementTextHandler:R=>{M.current(R)},paidMembersEnabled:u,toggleColorSwatch:_,toggleVisibility:k,visibility:l,onBlur:()=>{}}),{data:{posts:[A]}={posts:[]}}=Vg({searchParams:{filter:"status:published",order:"published_at DESC",limit:"1",fields:"id,url"}});let C=[];A&&(C=[{id:"homepage",title:"Homepage"},{id:"post",title:"Post"}]);const O=R=>{C.length&&v(R)};let $=cn(e);switch(m){case"homepage":$=cn(e);break;case"post":$=A.url;break}const B=a.jsx(sj,{announcementBackgroundColor:b,announcementContent:h,url:$,visibility:f});return a.jsx(Qs,{afterClose:()=>{p("announcement-bar")},buttonsDisabled:c.disabled,cancelLabel:"Close",deviceSelector:!0,dirty:!1,okColor:c.color,okLabel:c.label||"Save",preview:B,previewBgColor:"greygradient",previewToolbarTabs:C,selectedURL:m,sidebar:T,testId:"announcement-bar-modal",title:"Announcement",titleHeadingLevel:5,onOk:async()=>{await o({fakeWhenUnchanged:!0})||gt({type:"error",message:"An error occurred while saving your changes. Please try again."})},onSelectURL:O})},ij=_e.create(oj),qf=[{label:"Global",options:[{value:"site.changed",label:"Site changed (rebuild)"}]},{label:"Posts",options:[{value:"post.added",label:"Post created"},{value:"post.deleted",label:"Post deleted"},{value:"post.edited",label:"Post updated"},{value:"post.published",label:"Post published"},{value:"post.published.edited",label:"Published post updated"},{value:"post.unpublished",label:"Post unpublished"},{value:"post.scheduled",label:"Post scheduled"},{value:"post.unscheduled",label:"Post unscheduled"},{value:"post.tag.attached",label:"Tag added to post"},{value:"post.tag.detached",label:"Tag removed from post"}]},{label:"Pages",options:[{value:"page.added",label:"Page created"},{value:"page.deleted",label:"Page deleted"},{value:"page.edited",label:"Page updated"},{value:"page.published",label:"Page published"},{value:"page.published.edited",label:"Published page updated"},{value:"page.unpublished",label:"Page unpublished"},{value:"page.tag.attached",label:"Tag added to page"},{value:"page.tag.detached",label:"Tag removed from page"}]},{label:"Tags",options:[{value:"tag.added",label:"Tag created"},{value:"tag.edited",label:"Tag updated"},{value:"tag.deleted",label:"Tag deleted"}]},{label:"Members",options:[{value:"member.added",label:"Member added"},{value:"member.edited",label:"Member updated"},{value:"member.deleted",label:"Member deleted"}]}],lj=e=>qf.flatMap(({options:s})=>s).find(s=>s.value===e)?.label,cj=ss({method:"POST",path:()=>"/webhooks/",body:e=>({webhooks:[e]}),updateQueries:{dataType:tl,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(s=>{const o=e.webhooks[0];return o.integration_id===s.id?{...s,webhooks:[...s.webhooks||[],o]}:s})}}}),uj=ss({method:"PUT",path:e=>`/webhooks/${e.id}/`,body:e=>({webhooks:[e]}),updateQueries:{dataType:tl,emberUpdateType:"createOrUpdate",update:(e,n)=>n&&{...n,integrations:n.integrations.map(s=>{var o;return{...s,webhooks:(o=s.webhooks)==null?void 0:o.map(c=>c.id===e.webhooks[0].id?e.webhooks[0]:c)}})}}}),fj=ss({method:"DELETE",path:e=>`/webhooks/${e}/`,updateQueries:{dataType:tl,emberUpdateType:"createOrUpdate",update:(e,n,s)=>({...n,integrations:n.integrations.map(o=>{var c;return{...o,webhooks:(c=o.webhooks)==null?void 0:c.filter(h=>h.id!==s)}})})}}),dj=({webhook:e,integrationId:n})=>{const s=Zt(),{mutateAsync:o}=cj(),{mutateAsync:c}=uj(),h=it(),{formState:y,updateForm:b,handleSave:l,errors:u,clearError:f}=kr({initialState:e||{},onSave:async()=>{y.id?await c(y):await o({...y,integration_id:n})},onSaveError:h,onValidate:()=>{const p={};return y.name||(p.name="Enter a name"),y.event||(p.event="Select an event"),y.target_url||(p.target_url="Enter a target URL"),y.target_url&&!Nt.isURL(y.target_url,{require_tld:!1})&&(p.target_url="Enter a valid URL"),p}});return a.jsx(_t,{okColor:"black",okLabel:e?"Update":"Add",size:"sm",testId:"webhook-modal",title:"Add webhook",formSheet:!0,onOk:async()=>{await l()&&s.remove()},children:a.jsx("div",{className:"mt-5",children:a.jsxs(rt,{marginBottom:!1,marginTop:!1,children:[a.jsx(Ne,{error:!!u.name,hint:u.name,maxLength:191,placeholder:"Custom webhook",title:"Name",value:y.name,onChange:p=>b(m=>({...m,name:p.target.value})),onKeyDown:()=>f("name")}),a.jsx(Pt,{error:!!u.event,hint:u.event,options:qf,prompt:"Select an event",selectedOption:qf.flatMap(p=>p.options).find(p=>p.value===y.event),testId:"event-select",title:"Event",hideTitle:!0,onSelect:p=>{b(m=>({...m,event:p?.value})),f("event")}}),a.jsx(Ne,{error:!!u.target_url,hint:u.target_url,maxLength:2e3,placeholder:"https://example.com",title:"Target URL",type:"url",value:y.target_url,onChange:p=>b(m=>({...m,target_url:p.target.value})),onKeyDown:()=>f("target_url")}),a.jsx(Ne,{maxLength:191,placeholder:"https://example.com",title:"Secret",value:y.secret||void 0,onChange:p=>b(m=>({...m,secret:p.target.value}))})]})})})},Vh=_e.create(dj),pj=({integration:e})=>{const{mutateAsync:n}=fj(),s=it(),o=c=>{_e.show(St,{title:"Are you sure?",prompt:"Deleting this webhook may prevent the integration from functioning.",okColor:"red",okLabel:"Delete Webhook",onOk:async h=>{try{await n(c),h?.remove(),gt({message:"Webhook deleted",type:"info"})}catch(y){s(y)}}})};return a.jsxs("div",{children:[a.jsxs(W_,{children:[a.jsxs(fh,{bgOnHover:!1,children:[a.jsxs(zh,{children:[e.webhooks?.length||0," ",e.webhooks?.length===1?"webhook":"webhooks"]}),a.jsx(zh,{children:"Last triggered"})]}),e.webhooks?.map(c=>a.jsxs(fh,{action:a.jsx(Ue,{color:"red",label:"Delete",link:!0,onClick:h=>{h?.stopPropagation(),o(c.id)}}),bgOnHover:!1,hideActions:!0,onClick:()=>{_e.show(Vh,{webhook:c,integrationId:e.id})},children:[a.jsxs(dh,{className:"w-3/4",children:[a.jsx("div",{className:"text-sm font-semibold",children:c.name}),a.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-1 text-xs leading-snug",children:[a.jsx("span",{className:"text-grey-600",children:"Event:"}),a.jsx("span",{children:lj(c.event)}),a.jsx("span",{className:"text-grey-600",children:"URL:"}),a.jsx("span",{className:"line-clamp-3 break-all",title:c.target_url,children:c.target_url})]})]}),a.jsx(dh,{className:"w-1/4 text-sm",children:c.last_triggered_at&&new Date(c.last_triggered_at).toLocaleString("default",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}))]}),a.jsx("div",{className:"mt-5",children:a.jsx(Ue,{color:"green",icon:"add",iconColorClass:"text-green",label:"Add webhook",size:"sm",link:!0,onClick:()=>{_e.show(Vh,{integrationId:e.id})}})})]})},hj=({integration:e})=>{const n=Zt(),{updateRoute:s}=Je(),{mutateAsync:o}=q_(),{mutateAsync:c}=tb(),{mutateAsync:h}=Zs(),y=it(),{formState:b,updateForm:l,handleSave:u,saveState:f,errors:p,clearError:m,okProps:v}=kr({initialState:e,savingDelay:500,savedDelay:500,onSave:async()=>{await o(b)},onSavedStateReset:()=>{s("integrations")},onSaveError:y,onValidate:()=>{const $={};return b.name||($.name="Enter integration title"),$}}),_=e.api_keys?.find($=>$.type==="admin"),k=e.api_keys?.find($=>$.type==="content"),[M,T]=D.useState(!1),[A,C]=D.useState(!1);D.useEffect(()=>{e.type!=="custom"&&(n.remove(),s("integrations"))},[e.type,n,s]);const O=($,B)=>{B(!1);const R=$.type==="content"?"Content":"Admin";_e.show(St,{title:`Regenerate ${R} API Key`,prompt:`You can regenerate ${R} API Key any time, but any scripts or applications using it will need to be updated.`,okLabel:`Regenerate ${R} API Key`,onOk:async V=>{try{await c({integrationId:e.id,apiKeyId:$.id}),B(!0),V?.remove()}catch(K){y(K)}}})};return a.jsxs(_t,{afterClose:()=>{s("integrations")},buttonsDisabled:v.disabled,cancelLabel:"Close",dirty:f==="unsaved",okColor:v.color,okLabel:v.label||"Save",size:"md",testId:"custom-integration-modal",title:b.name||"Custom integration",stickyFooter:!0,onOk:async()=>{await u({fakeWhenUnchanged:!0})},children:[a.jsxs("div",{className:"mt-7 flex w-full flex-col gap-7 md:flex-row",children:[a.jsx("div",{children:a.jsx(un,{height:"100px",id:"custom-integration-icon",imageURL:b.icon_image||void 0,width:"100px",onDelete:()=>l($=>({...$,icon_image:null})),onUpload:async $=>{try{const B=on(await h({file:$}));l(R=>({...R,icon_image:B}))}catch(B){const R=B;R.response.status===415&&(R.message="Unsupported file type"),y(R)}},children:"Upload icon"})}),a.jsx("div",{className:"flex grow flex-col",children:a.jsxs(rt,{children:[a.jsx(Ne,{error:!!p.name,hint:p.name,maxLength:191,title:"Title",value:b.name,onChange:$=>l(B=>({...B,name:$.target.value})),onKeyDown:()=>m("name")}),a.jsx(Ne,{maxLength:2e3,title:"Description",value:b.description||"",onChange:$=>l(B=>({...B,description:$.target.value}))}),a.jsx(hd,{keys:[{label:"Content API key",text:k?.secret,hint:A?a.jsx("div",{className:"text-green",children:"Content API Key was successfully regenerated"}):void 0,onRegenerate:()=>k&&O(k,C)},{label:"Admin API key",text:_?.secret,hint:M?a.jsx("div",{className:"text-green",children:"Admin API Key was successfully regenerated"}):void 0,onRegenerate:()=>_&&O(_,T)},{label:"API URL",text:window.location.origin+rl().subdir}]})]})})]}),a.jsx("div",{children:a.jsx(pj,{integration:e})})]})},mj=({params:e})=>{const{data:{integrations:n}={}}=Wg(),s=n?.find(({id:o})=>o===e?.id);return s?a.jsx(hj,{integration:s}):null},gj=_e.create(mj),bj=({problem:e})=>{const[n,s]=D.useState(!1),o=()=>{s(!n)};return a.jsx(On,{title:a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[e?.fatal?a.jsx("strong",{children:"Fatal: "}):a.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),a.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),a.jsx("div",{className:"absolute -right-4 top-1",children:a.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>o()})})]}),n?a.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[a.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),a.jsx(xt,{level:6,children:"Affected files:"}),a.jsx("ul",{className:"mt-1",children:e.failures.map(c=>a.jsxs("li",{children:[a.jsx("code",{children:c.ref}),c.message?`: ${c.message}`:""]}))})]}):null]}),hideActions:!0,separator:!0})},xj=({title:e,prompt:n,fatalErrors:s,onRetry:o})=>{let c=null;return s&&(c=a.jsx("div",{className:"mt-10",children:a.jsx(ln,{title:"Errors",children:s.map(h=>typeof h.details=="object"&&h.details.errors&&h.details.errors.length>0?h.details.errors.map(y=>a.jsx(bj,{problem:y})):typeof h.details=="string"?a.jsx(On,{title:h.details}):null)})})),a.jsx(Qg,{cancelLabel:"Close",okColor:"black",okLabel:"Retry",prompt:a.jsxs(a.Fragment,{children:[n,c]}),title:e,onOk:o})},bb=_e.create(xj),gd=()=>{const e=Y_(),s=!e.data?.themes[0]?.warnings?.some(c=>c.code==="GS051-CUSTOM-FONTS"),o=D.useCallback(()=>{e.refetch()},[e]);return{supportsCustomFonts:s,refreshActiveThemeData:o}};function vj(e){let n=e.package?.name||e.name;return G_(e)?n+=" (default)":X_(e)?n+=" (legacy)":e.package?.name!==e.name&&(n=a.jsxs("span",{className:"text-sm md:text-base",children:[n," ",a.jsxs("span",{className:"text-grey-600",children:["(",e.name,")"]})]})),Jg(e)&&(n=a.jsxs("span",{className:"text-sm font-bold md:text-base",children:[n," — ",a.jsx("span",{className:"text-green",children:" Active"})]})),n}function wj(e){return e.package?.version||"1.0"}const yj=({theme:e})=>{const{mutateAsync:n}=Jf(),{mutateAsync:s}=K_(),{refreshActiveThemeData:o}=gd(),c=it(),h=async()=>{try{await n(e.name),o(),gt({title:"Theme activated",type:"success",message:a.jsxs("div",{children:[a.jsx("span",{className:"capitalize",children:e.name})," is now your active theme"]})})}catch(p){let m=null;p instanceof ts&&p.response?.status===422&&p.data?.errors?m=p.data.errors:c(p);let v="Invalid Theme",_=a.jsx(a.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});m&&_e.show(bb,{title:v,prompt:_,fatalErrors:m,onRetry:async k=>{k?.remove(),h()}})}},y=async()=>{const{apiRoot:p}=rl();V_(`${p}/themes/${e.name}/download`)},b=async()=>{_e.show(St,{title:"Are you sure you want to delete this?",prompt:a.jsxs(a.Fragment,{children:["You are about to delete ",a.jsxs("strong",{children:['"',e.name,'".']})," This is permanent! We warned you, k? Maybe download"," ",a.jsx("span",{className:"cursor-pointer text-green-500",onClick:()=>{y()},children:"your theme before continuing"})]}),okLabel:"Delete",okRunningLabel:"Deleting",okColor:"red",onOk:async p=>{try{await s(e.name),p?.remove()}catch(m){c(m)}}})};let l=[];Jg(e)||l.push(a.jsx(Ue,{className:"ml-2",color:"green",label:"Activate",link:!0,onClick:h},"activate"));let u=[{id:"download",label:"Download",onClick:y}];Z_(e)&&u.push({id:"delete",label:"Delete",onClick:b});const f={iconColorClass:"text-base",size:"sm"};return a.jsxs("div",{className:"-mr-3 flex items-center gap-4",children:[l,a.jsx(U0,{items:u,position:"end",triggerButtonProps:f})]})},_j=({themes:e})=>(e.sort((n,s)=>n.active&&!s.active?-1:!n.active&&s.active?1:n.package?.name&&s.package?.name?n.package.name.localeCompare(s.package.name):n.name.localeCompare(s.name)),a.jsx(ln,{pageTitle:"Installed themes",children:e.map(n=>{const s=vj(n),o=wj(n);return a.jsx(On,{action:a.jsx(yj,{theme:n}),detail:o,id:`theme-${n.name}`,separator:!1,testId:"theme-list-item",title:s},n.name)})})),kj=({themes:e})=>a.jsx(dd,{children:a.jsx(_j,{themes:e})}),Mj="/ghost/assets/footer-marketplace-bg-BpIYEF6z.png",jj=3e3,Qh=e=>e.variants&&e.variants.length>0,hu=e=>{const n=[{category:e.category,previewUrl:e.previewUrl,image:e.image}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},Ej=({onSelectTheme:e})=>{const n=Q_(),[s,o]=D.useState(null),[c,h]=D.useState(0),y=b=>{o(b),h(b!==null&&Qh(b)&&hu(b).length>1?1:0)};return D.useEffect(()=>{if(s===null)return;const b=setInterval(()=>{h((c+1)%(hu(s).length||0))},jj);return()=>clearInterval(b)},[s,c]),a.jsxs(dd,{heading:"Themes",children:[a.jsx("div",{className:"mt-[6vmin] grid grid-cols-1 gap-[6vmin] sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",children:n.map(b=>{const l=Qh(b),u=hu(b),f=s===b;return a.jsxs("button",{className:"flex cursor-pointer flex-col gap-3 text-left",type:"button",onClick:()=>{e?.(b)},children:[a.jsx("div",{className:"relative w-full bg-grey-100 shadow-md transition-all duration-500 hover:scale-[1.05]",onMouseEnter:()=>y(b),onMouseLeave:()=>y(null),children:l?a.jsx(a.Fragment,{children:u.map((p,m)=>a.jsx("img",{alt:`${b.name} Theme - ${p.category}`,className:ve("size-full object-contain opacity-0 transition-opacity duration-500",{"opacity-100":m===c&&f||!f&&m===0,relative:m===c,absolute:m!==c,"left-0":m!==c,"top-0":m!==c}),src:p.image},`theme-variant-${p.category.toLowerCase()}`))}):a.jsx("img",{alt:`${b.name} Theme`,className:"size-full object-contain",src:b.image})}),a.jsxs("div",{className:"relative mt-3",children:[a.jsx(xt,{level:4,children:b.name}),l?u.map((p,m)=>a.jsx("span",{className:ve("absolute left-0 translate-y-px text-sm text-grey-700 opacity-0",{"opacity-100":m===c&&f||!f&&m===0}),children:p.category})):a.jsx("span",{className:"text-sm text-grey-700",children:b.category})]})]},b.name)})}),a.jsxs("div",{className:"mx-[-8vmin] mb-[-8vmin] mt-[8vmin] bg-black px-[8vmin] py-16 text-center text-lg text-white",style:{background:`#15171a url(${Mj}) 100% 100% / 35vw no-repeat`},children:["Find and buy third-party, premium themes from independent developers in the ",a.jsx("a",{className:"inline-block font-semibold text-lime",href:"https://ghost.org/themes/",rel:"noopener noreferrer",target:"_blank",children:"Ghost Marketplace →"})]})]})},Jh=({problem:e})=>{const[n,s]=D.useState(!1);return a.jsx(On,{title:a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`${e.level==="error"?"before:bg-red":"before:bg-yellow"} relative px-4 text-sm before:absolute before:left-0 before:top-1.5 before:block before:size-2 before:rounded-full before:content-['']`,children:[a.jsx("strong",{children:e.level==="error"?"Error: ":"Warning: "}),a.jsx("span",{dangerouslySetInnerHTML:{__html:e.rule}}),a.jsx("div",{className:"absolute -right-4 top-1",children:a.jsx(Ue,{color:"green",icon:n?"chevron-down":"chevron-right",iconColorClass:"text-grey-700",size:"sm",link:!0,onClick:()=>s(!n)})})]}),n?a.jsxs("div",{className:"mt-2 px-4 text-[13px] leading-8",children:[a.jsx("div",{dangerouslySetInnerHTML:{__html:e.details},className:"mb-4"}),a.jsx(xt,{level:6,children:"Affected files:"}),a.jsx("ul",{className:"mt-1",children:e.failures.map(o=>a.jsxs("li",{children:[a.jsx("code",{children:o.ref}),o.message?`: ${o.message}`:""]}))})]}):null]}),hideActions:!0,separator:!0})},Tj=({title:e,prompt:n,installedTheme:s,onActivate:o})=>{const{mutateAsync:c}=Jf(),{refreshActiveThemeData:h}=gd(),y=it();let b=null;s&&s.gscan_errors&&(b=a.jsx("div",{className:"mt-6",children:a.jsx(ln,{hint:a.jsxs(a.Fragment,{children:["Highly recommended to fix, functionality ",a.jsx("strong",{children:"could"})," be restricted"]}),title:"Errors",children:s.gscan_errors?.map(f=>a.jsx(Jh,{problem:f}))})}));let l=null;s&&s.warnings&&(l=a.jsx("div",{className:"mt-10",children:a.jsx(ln,{title:"Warnings",children:s.warnings?.map(f=>a.jsx(Jh,{problem:f}))})}));let u=`Activate${s.gscan_errors?.length?" with errors":""}`;return s.active&&(u="OK"),a.jsx(Qg,{cancelLabel:"Close",okColor:"black",okLabel:u,okRunningLabel:"Activating...",prompt:a.jsxs(a.Fragment,{children:[n,b,l]}),title:e,onOk:async f=>{if(!s.active)try{const m=(await c(s.name)).themes[0];h(),gt({title:"Theme activated",type:"success",message:a.jsxs("div",{children:[a.jsx("span",{className:"capitalize",children:m.name})," is now your active theme."]})})}catch(p){y(p)}o?.(),f?.remove()}})},xb=_e.create(Tj),em=e=>e.variants&&e.variants.length>0,tm=e=>{const n=[{image:e.image,category:e.category,previewUrl:e.previewUrl}];return e.variants&&e.variants.length>0&&n.push(...e.variants),n},rm=e=>e.category.toLowerCase(),Sj=({selectedTheme:e,isInstalling:n,installedTheme:s,onBack:o,onInstall:c})=>{const[h,y]=D.useState("desktop"),[b,l]=D.useState(void 0);if(!e)return null;let u=e.previewUrl;const f=tm(e).map(k=>({label:k.category,value:rm(k)}));em(e)&&(b===void 0&&l(f[0]),u=tm(e).find(k=>rm(k)===b?.value)?.previewUrl||u);let p=`Install ${e.name}`;n?p="Installing...":Gi(e)&&!s?.active?p=`Activate ${e.name}`:s&&(p=`Update ${e.name}`);const m=()=>{c?.()},v=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pd,{activeItemClassName:"hidden md:!block md:!visible",containerClassName:"whitespace-nowrap",itemClassName:"hidden md:!block md:!visible",items:[{label:"Change theme",onClick:o},{label:e.name}],separatorClassName:"hidden md:!block md:!visible",backIcon:!0,onBack:o}),em(e)?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hidden md:!visible md:!block",children:"–"}),a.jsx(Pt,{border:!1,containerClassName:"text-sm font-bold",controlClasses:{menu:"w-24"},fullWidth:!1,options:f,selectedOption:b,clearBg:!0,onSelect:k=>{l(k||void 0)}})]}):null]}),_=a.jsxs("div",{className:"flex justify-end gap-8",children:[a.jsx(an,{buttons:[{icon:"laptop",iconColorClass:h==="desktop"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("desktop")}},{icon:"mobile",iconColorClass:h==="mobile"?"text-black dark:text-green":"text-grey-500 dark:text-grey-600",link:!0,size:"sm",onClick:()=>{y("mobile")}}]}),a.jsx(Ue,{color:"green",disabled:n,label:n?"Installing...":p,onClick:m})]});return a.jsxs("div",{className:"absolute inset-0 z-[100]",children:[a.jsx(J0,{containerClassName:"bg-grey-50 dark:bg-black z-[100]",left:v,right:_,sticky:!1}),a.jsx("div",{className:"flex h-[calc(100%-92px)] grow flex-col items-center justify-center bg-grey-50 dark:bg-black",children:h==="desktop"?a.jsx(h0,{children:a.jsx("iframe",{className:"size-full",src:u,title:"Theme preview"})}):a.jsx(m0,{children:a.jsx("iframe",{className:"size-full",src:u,title:"Theme preview"})})})]})},Nj=({onUpload:e})=>{const n=Zt();return a.jsx("div",{className:"-mb-6",children:a.jsx(t2,{id:"theme-upload",onUpload:s=>{n.remove(),e(s)},children:a.jsx("div",{className:"cursor-pointer bg-grey-75 p-10 text-center dark:bg-grey-950",children:"Click to select or drag & drop zip file"})})})},Aj=({currentTab:e,setCurrentTab:n,themes:s})=>{const o=Zt(),{updateRoute:c}=Je(),{mutateAsync:h}=e2(),{checkThemeLimitError:y,isThemeLimited:b}=td(),l=it(),[u,f]=D.useState(),[p,m]=D.useState(!1);D.useEffect(()=>{(async()=>{if(b){const O=await y(".");f({enabled:!1,error:O||"Your current plan doesn't support uploading custom themes."})}else f({enabled:!0})})()},[y,b]);const v=()=>{c("/")},_=async C=>{const O=C?.name.replace(/\.zip$/,""),$=s.map(B=>B.name);Gi({name:O})?_e.show(St,{title:"Upload failed",cancelLabel:"Cancel",okLabel:"",prompt:a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["The default ",a.jsx("strong",{children:O})," theme cannot be overwritten."]}),a.jsx("p",{children:"Rename your zip file and try again."})]}),onOk:async B=>{B?.remove()}}):$.includes(O)?_e.show(St,{title:"Overwrite theme",prompt:a.jsxs(a.Fragment,{children:["The theme ",a.jsx("strong",{children:O})," already exists. Do you want to overwrite it?"]}),okLabel:"Overwrite",cancelLabel:"Cancel",okRunningLabel:"Overwriting...",okColor:"red",onOk:async B=>{m(!0);const R=$.indexOf(O);s.splice(R,1),await k({file:C,onActivate:v}),m(!1),n("installed"),B?.remove()}}):(n("installed"),k({file:C,onActivate:v}))},k=async({file:C,onActivate:O})=>{let $,B=null;try{m(!0),$=await h({file:C}),m(!1)}catch(G){m(!1),G instanceof ts&&G.response?.status===422&&G.data?.errors?B=G.data.errors:l(G)}if(B&&!$){let G="Invalid Theme",W=a.jsx(a.Fragment,{children:"This theme is invalid and cannot be activated. Fix the following errors and re-upload the theme"});_e.show(bb,{title:G,prompt:W,fatalErrors:B,onRetry:async()=>{o?.remove(),T()}})}if(!$)return;const R=$.themes[0];let V="Upload successful",K=a.jsxs(a.Fragment,{children:[a.jsx("strong",{children:R.name})," uploaded"]});if(R.active||(K=a.jsxs(a.Fragment,{children:[K," ","Do you want to activate it now?"]})),R?.gscan_errors?.length||R.warnings?.length){const G=R?.gscan_errors?.length;V=`Upload successful with ${G?"errors":"warnings"}`,K=a.jsxs(a.Fragment,{children:["The theme ",a.jsxs("strong",{children:['"',R.name,'"']})," was installed but we detected some ",G?"errors":"warnings","."]}),R.active||(K=a.jsxs(a.Fragment,{children:[K,"You are still able to activate and use the theme but it is recommended to fix these ",G?"errors":"warnings"," before you do so."]}))}_e.show(xb,{title:V,prompt:K,installedTheme:R,onActivate:O})},M=a.jsx("div",{className:"hidden md:!visible md:!block",children:a.jsx(Rn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})}),T=()=>{u&&(u.enabled?_e.show(St,{title:"Upload theme",prompt:a.jsx(Nj,{onUpload:_}),okLabel:"",formSheet:!1}):_e.show(Xr,{title:"Upgrade to enable custom themes",prompt:u.error||a.jsxs(a.Fragment,{children:["Your current plan only supports official themes. You can install them from the ",a.jsx("a",{href:"https://ghost.org/marketplace/",children:"Ghost theme marketplace"}),"."]}),onOk:()=>c({route:"/pro",isExternal:!0})}))},A=a.jsx("div",{className:"flex items-center gap-14",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ue,{label:"Close",onClick:()=>{o.remove(),v()}}),a.jsx(Ue,{color:"black",label:"Upload theme",loading:p,onClick:T})]})});return a.jsxs(a.Fragment,{children:[a.jsx(J0,{containerClassName:"bg-white dark:bg-black",left:M,right:A}),a.jsx("div",{className:"px-[8vmin] md:hidden",children:a.jsx(Rn,{border:!1,selectedTab:e,tabs:[{id:"official",title:"Official themes"},{id:"installed",title:"Installed"}],onTabChange:C=>{n(C)}})})]})},Ij=({currentTab:e,onSelectTheme:n,themes:s})=>{switch(e){case"official":return a.jsx(Ej,{onSelectTheme:n});case"installed":return a.jsx(kj,{themes:s})}return null},nm=({source:e,themeRef:n})=>{const[s,o]=D.useState("official"),[c,h]=D.useState(null),[y,b]=D.useState("desktop"),[l,u]=D.useState(!1),[f,p]=D.useState(!1),[m,v]=D.useState(!1),{updateRoute:_}=Je(),k=Zt(),{data:{themes:M}={}}=ed(),{mutateAsync:T}=J_(),{mutateAsync:A}=Jf(),{checkThemeLimitError:C}=td(),O=it(),$=V=>{h(V)};if(D.useEffect(()=>{v(!0)},[]),D.useEffect(()=>{(async()=>{if(e&&n&&!f&&m){const K=n.split("/")[1];if(await C(K)){k.remove();return}let W="Install Theme";const q=M?.map(re=>re.name)||[];let se=q.includes(K.toLowerCase());const J=q.indexOf(K.toLowerCase()),te=M?.[J];let Q=a.jsxs(a.Fragment,{children:["By clicking below, ",a.jsx("strong",{children:K})," will automatically be activated as the theme for your site.",se&&a.jsxs(a.Fragment,{children:[a.jsx("br",{}),a.jsx("br",{}),"This will overwrite your existing version of ",a.jsx("strong",{children:K}),te?.active?" which is your active theme":"",". All custom changes will be lost."]})]});_e.show(St,{title:W,prompt:Q,okLabel:"Install",cancelLabel:"Cancel",okRunningLabel:"Installing...",okColor:"black",onOk:async re=>{let be;p(!0);try{se&&M&&M.splice(J,1),be=await T(n),be?.themes[0]&&(await A(be.themes[0].name),gt({title:"Theme activated",type:"success",message:a.jsxs("div",{children:[a.jsx("span",{className:"capitalize",children:be.themes[0].name})," is now your active theme"]})})),re?.remove(),_("")}catch(Me){O(Me)}}})}})()},[n,e,T,O,A,_,M,f,C,k,m]),!M)return;let B,R;if(c){B=M.find(K=>K.name.toLowerCase()===c.name.toLowerCase()),R=async()=>{const K=await C(c.name);if(K){_e.show(Xr,{prompt:K,onOk:()=>_({route:"/pro",isExternal:!0})});return}return B&&!Gi(c)?new Promise(G=>{_e.show(St,{title:"Overwrite theme",prompt:a.jsxs(a.Fragment,{children:["This will overwrite your existing version of ",c.name,B?.active?", which is your active theme":"",". All custom changes will be lost."]}),okLabel:"Overwrite",okRunningLabel:"Installing...",cancelLabel:"Cancel",okColor:"red",onOk:async W=>{W?.remove(),await V(),G()}})}):V()};const V=async()=>{let K="Success",G=a.jsx(a.Fragment,{});if(Gi(c))K="Activate theme",G=a.jsxs(a.Fragment,{children:["By clicking below, ",a.jsx("strong",{children:c.name})," will automatically be activated as the theme for your site."]});else{u(!0);let W;try{W=await T(c.ref)}catch(se){O(se)}finally{u(!1)}if(!W)return;const q=W.themes[0];if(K="Success",G=a.jsxs(a.Fragment,{children:[a.jsx("strong",{children:q.name})," has been successfully installed."]}),q.active||(G=a.jsxs(a.Fragment,{children:[G," ","Do you want to activate it now?"]})),q.gscan_errors?.length||q.warnings?.length){const se=q.gscan_errors?.length;K=`Installed with ${se?"errors":"warnings"}`,G=a.jsxs(a.Fragment,{children:["The theme ",a.jsxs("strong",{children:['"',q.name,'"']})," was installed successfully but we detected some ",se?"errors":"warnings","."]}),q.active||(G=a.jsxs(a.Fragment,{children:[G,"You are still able to activate and use the theme but it is recommended to contact the theme developer fix these ",se?"errors":"warnings"," before you do so."]}))}B=q}_e.show(xb,{title:K,prompt:G,installedTheme:B,onActivate:()=>{_("")}})}}return a.jsx(_t,{afterClose:()=>{_("")},animate:!1,cancelLabel:"",footer:!1,padding:!1,size:"full",testId:"theme-modal",title:"",scrolling:!0,onCancel:()=>{k.remove(),_("")},children:a.jsx("div",{className:"flex h-full justify-between",children:a.jsxs("div",{className:"grow",children:[c&&a.jsx(Sj,{installedTheme:B,isInstalling:l,selectedTheme:c,onBack:()=>{h(null)},onClose:()=>{_("")},onInstall:R}),a.jsx(Aj,{currentTab:s,modal:k,previewMode:y,selectedTheme:c,setCurrentTab:o,setPreviewMode:b,setSelectedTheme:h,themes:M}),!c&&a.jsx(Ij,{currentTab:s,themes:M,onSelectTheme:$})]})})})},Cj=({children:e,to:n,classNames:s})=>{const o=n||document.body;if(!o)return a.jsx(a.Fragment,{children:e});const c=h=>{h.stopPropagation()};return r2.createPortal(a.jsx("div",{className:s,onMouseDown:c,children:a.jsx("div",{children:e})}),o)};var Dj=Object.defineProperty,Rj=(e,n,s)=>n in e?Dj(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,jt=(e,n,s)=>Rj(e,typeof n!="symbol"?n+"":n,s),vb={exports:{}},qa={};/**
4
4
  * @license React