1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4911],{32932:function(e,t,n){let i,r,l;n.d(t,{$rW:function(){return jt},AY8:function(){return lV.AY},Ahg:function(){return kZ},BoV:function(){return d6},C8M:function(){return U7},Cnp:function(){return p0},Cw0:function(){return hA},Dab:function(){return UM},Dqo:function(){return UN},Dr7:function(){return fC},E6V:function(){return Ns},EyJ:function(){return bG},F2f:function(){return U0},FMn:function(){return ub},GWp:function(){return Bu},H7Z:function(){return xS},HD0:function(){return cu},H__:function(){return UJ},Hdz:function(){return V_},IIC:function(){return gN},INm:function(){return Ng},I_y:function(){return Nu},LPT:function(){return pG},LZ8:function(){return co},L_b:function(){return fY},Lky:function(){return Iw},MUX:function(){return d5},NEx:function(){return Nn},NuZ:function(){return ca},P08:function(){return UI},Q3k:function(){return R7},QMc:function(){return gb},RgL:function(){return cr},Sis:function(){return Bp},UMU:function(){return VR},Uy$:function(){return cc},YG6:function(){return pK},YtX:function(){return U4},Z2j:function(){return lV.Z2},Z7x:function(){return function e(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(n(t,i)){if("array"===t.type){"unchanged"!==t.action&&t.items.forEach(t=>{var r;let l="object"===t.diff.type&&(null==(r=t.diff.toValue)?void 0:r._key),a=l?{_key:l}:void 0===t.toIndex?t.fromIndex||0:t.toIndex;e(t.diff,n,i.concat(a))});return}if("object"===t.type){"unchanged"!==t.action&&Object.keys(t.fields).forEach(r=>{let l=t.fields[r];e(l,n,i.concat(r))});return}"string"===t.type&&"unchanged"!==t.action&&t.segments.forEach(t=>{e(t,n,i)})}}},ZDM:function(){return hE},_2T:function(){return fB},a3k:function(){return Nv},ap5:function(){return UQ},cFj:function(){return Ib},cWh:function(){return Ij},clL:function(){return Bc},d9t:function(){return No},duV:function(){return uv},e8h:function(){return uc},eLL:function(){return fX},ek8:function(){return d8},euX:function(){return yu},feb:function(){return lV.fe},fm0:function(){return mz},hHf:function(){return VA},iav:function(){return Nd},jbM:function(){return ue},jr5:function(){return p1},kJL:function(){return cd},kNp:function(){return yn},kqP:function(){return mC},kwM:function(){return bB},l$t:function(){return cq},m85:function(){return Ni},mEJ:function(){return yw},mPO:function(){return cm},nqf:function(){return Fe},nuD:function(){return Nf},oUE:function(){return uM},ogX:function(){return fF},pt$:function(){return function e(t,n,i){var r;if(0===n.length)return{...t||{},value:i};let[l,...a]=n,o=(0,lV.Fd)(l)?l._key:String(l),s=null!=(r=null==t?void 0:t.children)?r:{};return{value:null==t?void 0:t.value,children:{...s,[o]:e(s[o]||{},a,i)}}}},qGk:function(){return gs},quP:function(){return yo},quX:function(){return lV.qu},qyu:function(){return cn},r8Q:function(){return be},rq_:function(){return UY},t2O:function(){return VS},vSY:function(){return VM},va7:function(){return gO},vsM:function(){return ci},xJ:function(){return Nj},xMr:function(){return pY},z12:function(){return lV.z1},z1O:function(){return Nl},zEW:function(){return Nm}});var a,o,s,d,c,u,p,h,f,m,g,x,v,b,y,j,w,k,C,_,S,T,E,P,A,O,z,M,I,R,F,D,Z,L,q,N,V,U,B,K,H,W,$,X,G,Y,J,Q,ee,et,en,ei,er,el,ea,eo,es,ed,ec,eu,ep,eh,ef,em,eg,ex,ev,eb,ey,ej,ew,ek,eC,e_,eS,eT,eE,eP,eA,eO,ez,eM,eI,eR,eF,eD,eZ,eL,eq,eN,eV,eU,eB,eK,eH,eW,e$,eX,eG,eY,eJ,eQ,e0,e1,e2,e3,e4,e5,e6,e8,e9,e7,te,tt,tn,ti,tr,tl,ta,to,ts,td,tc,tu,tp,th,tf,tm,tg,tx,tv,tb,ty,tj,tw,tk,tC,t_,tS,tT,tE,tP,tA,tO,tz,tM,tI,tR,tF,tD,tZ,tL,tq,tN,tV,tU,tB,tK,tH,tW,t$,tX,tG,tY,tJ,tQ,t0,t1,t2,t3,t4,t5,t6,t8,t9,t7,ne,nt,nn,ni,nr,nl,na,no,ns,nd,nc,nu,np,nh,nf,nm,ng,nx,nv,nb,ny,nj,nw,nk,nC,n_,nS,nT,nE,nP,nA,nO,nz,nM,nI,nR,nF,nD,nZ,nL,nq,nN,nV,nU,nB,nK,nH,nW,n$,nX,nG,nY,nJ,nQ,n0,n1,n2,n3,n4,n5,n6,n8,n9,n7,ie,it,ii,ir,il,ia,io,is,id,ic,iu,ip,ih,im,ig,ix,iv,ib,iy,ij,iw,ik,iC,i_,iS,iT,iE,iP,iA,iO,iz,iM,iI,iR,iF,iD,iZ,iL,iq,iN,iV,iU,iB,iK,iH,iW,i$,iX,iG,iY,iJ,iQ,i0,i1,i2,i3,i4,i5,i6,i8,i9,i7,re,rt,rn,ri,rr,rl,ra,ro,rs,rd,rc,ru,rp,rh,rf,rm,rg,rx,rv,rb,ry,rj,rw,rk,rC,r_,rS,rT,rE,rP,rA,rO,rz,rM,rI,rR,rF,rD,rZ,rL,rq,rN,rV,rU,rB,rK,rH,rW,r$,rX,rG,rY,rJ,rQ,r0,r1,r2,r3,r4,r5,r6,r8,r9,r7,le,lt,ln,li,lr,ll,la,lo,ls,ld,lc,lu,lp,lh,lf,lm,lg,lx,lv,lb,ly,lj,lw,lk,lC,l_,lS,lT,lE,lP,lA,lO,lz,lM,lI,lR,lF,lD,lZ,lL,lq,lN,lV=n(42930),lU=n(85893),lB=n(66996),lK=n(67294),lH=n(69590),lW=n.n(lH),l$=n(23279),lX=n.n(l$),lG=n(47252),lY=n(11636),lJ=n(28440),lQ=n(32817),l0=n(69243),l1=n(22401),l2=n(82649),l3=n(23071),l4=n(19917),l5=n(83610),l6=n(6222),l8=n(9653),l9=n(19293),l7=n(1545),ae=n(40317),at=n(40052),an=n(9141),ai=n(82976),ar=n(86515),al=n(37991),aa=n(36861),ao=n(30743),as=n(42006),ad=n(29127),ac=n(53741),au=n(79878),ap=n(34978),ah=n(56542),af=n(94975),am=n(68515),ag=n(98430),ax=n(48902),av=n(83505),ab=n(74727),ay=n(5014),aj=n(44367),aw=n(30062),ak=n(46297),aC=n(77270),a_=n(65583),aS=n(51313),aT=n(91458),aE=n(92574),aP=n(93833),aA=n(47753),aO=n(40148),az=n(30218),aM=n(63428),aI=n(71932),aR=n(56890),aF=n(9132),aD=n(25631),aZ=n(42965),aL=n(48848),aq=n(58550),aN=n(58796),aV=n(18446),aU=n.n(aV),aB=n(58354),aK=n(23493),aH=n.n(aK),aW=n(15437),a$=n(89734),aX=n.n(a$),aG=n(1014),aY=n(60754),aJ=n(38993),aQ=n.n(aJ),a0=n(40168),a1=n(933),a2=n(63416),a3=n(94184),a4=n.n(a3),a5=n(98235),a6=n(59864),a8=n(55379),a9=n(67021),a7=n(88306),oe=n.n(a7),ot=n(21827),on=n(47037),oi=n.n(on),or=n(18029),ol=n.n(or),oa=n(35706),oo=n(42076),os=n(30222),od=n(50361),oc=n.n(od),ou=n(27361),op=n.n(ou),oh=n(42298),of=n(85564),om=n.n(of),og=n(45578),ox=n.n(og),ov=n(73955),ob=n.n(ov),oy=n(43703),oj=n(86298),ow=n(8230),ok=n(77349),oC=n(13956),o_=n(3151),oS=n(49160),oT=n(34176),oE=n(16218),oP=n(11640),oA=n(44749),oO=n(4543),oz=n(37042),oM=n(23855),oI=n(39159),oR=n(61436),oF=n(42699),oD=n(313),oZ=n(92311),oL=n(83894),oq=n(69119),oN=n(42063),oV=n(46038),oU=n(28366),oB=n(18717),oK=n(55250),oH=n(57278),oW=n(31397),o$=n(69295),oX=n(29383),oG=n(76972),oY=n(69690),oJ=n(11699),oQ=n(3982),o0=n(6803),o1=n.n(o0),o2=n(81548),o3=n(39693),o4=n.n(o3),o5=n(25325),o6=n.n(o5),o8=n(24350),o9=n.n(o8),o7=n(43174),se=n.n(o7),st=n(7334),sn=n.n(st),si=n(93386),sr=n.n(si),sl=n(44908),sa=n.n(sl),so=n(58748),ss=n.n(so),sd=n(59242),sc=n.n(sd),su=n(92742),sp=n.n(su),sh=n(25934),sf=n(57557),sm=n.n(sf),sg=n(75472),sx=n.n(sg),sv=n(52027),sb=n(98434),sy=n(57122),sj=n(60814),sw=n(1106),sk=n(76566),sC=n.n(sk),s_=n(7739),sS=n.n(s_),sT=n(76590),sE=n(29043),sP=n(17423),sA=n(45587),sO=n(60887),sz=n(24285),sM=n(32339),sI=n(2141),sR=n(99119),sF=n(68630),sD=n.n(sF),sZ=n(48403),sL=n.n(sZ),sq=n(26642),sN=n.n(sq),sV=n(90634),sU=n.n(sV),sB=n(13311),sK=n.n(sB),sH=n(96026
1),sW=n.n(sH),s$=n(989),sX=n.n(s$),sG=n(84596),sY=n.n(sG),sJ=n(78718),sQ=n.n(sJ),s0=n(63706),s1=n.n(s0),s2=n(91966),s3=n.n(s2),s4=n(6557),s5=n.n(s4),s6=n(52628),s8=n.n(s6),s9=n(28092),s7=n(85092),de=n(34167),dt=n(80979),dn=n(76356),di=n(75175),dr=n(31103),dl=n(53416),da=n(95534),ds=n.n(da),dd=n(45933),dc=n.n(dd),du=n(54087),dp=n.n(du),dh=n(83508),df=n(18156),dm=n(41609),dg=n.n(dm),dx=n(9095),dv=n(18612),db=n.n(dv),dy=n(6979),dj=n.n(dy),dw=n(36155),dk=n.n(dw),dC=n(45950),d_=n.n(dC),dS=n(96412),dT=n.n(dS),dE=n(4979),dP=n.n(dE),dA=n(82717),dO=n(3522),dz=n.n(dO);n(20745);var dM=n(38063),dI=n(21137),dR=n(97762),dF=n(12023),dD=n(51526),dZ=n(11700),dL=n.n(dZ),dq=n(13218),dN=n.n(dq),dV=n(30998),dU=n.n(dV),dB=n(66678),dK=n.n(dB);function dH(e){return"function"==typeof e?e():e}let dW=()=>void 0,d$=!1,dX=e=>{d$||console.warn(Error('No context provided for reporter. Make sure that the component calling "useReporter('.concat(e,', ...)", is wrapped in a <Tracker> element'))),d$=!0},dG={add:dX,update:dX,remove:dX,subscribe:()=>(d$||console.warn(Error('No context provided for reporter. Make sure that the component calling "useReportedValues()", is wrapped inside a <Tracker> element')),d$=!0,()=>{}),read:function(){return d$||console.warn(Error('No context provided for reporter. Make sure that the component calling "useReportedValues()", is wrapped inside a <Tracker> element')),d$=!0,[]}},dY=0,dJ=()=>++dY;function dQ(){let e=lK.createContext(dG),t=function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.is,{add:r,update:l,remove:a}=lK.useContext(e),o=lK.useRef();lK.useLayoutEffect(()=>{if(null===t)return dW;let e=dH(n);return r(t,e),o.current=e,()=>{a(t)}},[r,t,a,n]),lK.useLayoutEffect(()=>{let e=dH(n);void 0===o.current||i(o.current,e)||null===t||l(t,e),o.current=e})};return{Tracker:function(t){let n=lK.useMemo(()=>(function(){let e=new Map,{publish:t,subscribe:n}=(0,lG.Z)(),i=lX()(t,10,{trailing:!0}),r=()=>Array.from(e.entries());return{add:function(t,n){e.has(t),e.set(t,n),i(r())},remove:function(t){e.has(t),e.delete(t),i(r())},update:function(t,n){e.has(t),e.set(t,n),i(r())},read:r,subscribe:n}})(),[]);return(0,lU.jsx)(e.Provider,{value:n,children:t.children})},useReportedValues:function(){let t=lK.useContext(e),[n,i]=lK.useState(t.read());return lK.useLayoutEffect(()=>(i(t.read()),t.subscribe(i)),[t]),n},useReporter:t,useAutoIdReporter:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object.is;return t("element-".concat(lK.useRef(dJ()).current),e,n)}}}let d0=dQ(),d1=d0.Tracker,d2=d0.useReportedValues,d3=d0.useReporter,d4=(0,lK.createContext)({isReviewChangesOpen:!1,onOpenReviewChanges:()=>void 0,onSetFocus:()=>void 0}),d5=e=>{let t=lK.useRef(null),{onSetFocus:n}=lK.useContext(d4),[i,r]=lK.useState(!1),l=lK.useCallback(()=>{r(!0)},[]),a=lK.useCallback(()=>{r(!1)},[]);d3("change-".concat(lB.BB(e.path)),()=>({element:t.current,path:e.path,isChanged:!0,hasFocus:!1,hasHover:i,hasRevertHover:e.hasHover}),lW());let o=(0,lK.useCallback)(t=>{var i;i=e.path,t.stopPropagation(),n(i)},[n,e.path]);return(0,lU.jsx)("div",{ref:t,onClick:o,onMouseLeave:a,onMouseEnter:l,children:e.children})};function d6(e){let t=(0,lK.useRef)(e);return aU()(t.current,e)||(t.current=e),t.current}function d8(e,t){let n=[t,!0],i={type:"tuple",tuple:n};return function(t){let r=d6(t),l=(0,lJ.m2)(()=>(0,lQ.of)(r).pipe((0,ap.w)(t=>(0,l0.z)((0,lQ.of)({type:"loading"}),e(t).pipe((0,ad.U)(e=>({type:"value",value:e}))))),(0,ah.R)((e,t)=>{let[n]=e;return"loading"===t.type?[n,!0]:[t.value,!1]},n),(0,ac.x)((e,t)=>{let[n,i]=e,[r,l]=t;return n===r&&i===l}),(0,ad.U)(e=>({type:"tuple",tuple:e})),(0,au.K)(e=>(0,lQ.of)({type:"error",error:e}))),[r],i);if("error"===l.type)throw l.error;return l.tuple}}function d9(e){return null!=e}let d7="".concat("drafts",".");function ce(e){return e.startsWith(d7)}function ct(e){return{draftId:cn(e),publishedId:ci(e)}}function cn(e){return ce(e)?e:d7+e}function ci(e){return ce(e)?e.slice(d7.length):e}function cr(e){let t=e.reduce((e,t)=>{let n=ci(t._id),i=e.get(n);return i||(i={id:n,type:t._type,published:void 0,draft:void 0},e.set(n,i)),i[n===t._id?"published":"draft"]=t,e},new Map);return Array.from(t.values())}function cl(e){return cr(e).map(e=>e.draft||e.published).filter(d9)}let ca=Object.freeze({}),co=Object.freeze([]),cs=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self;if(void 0!==n.g)return n.g;throw Error("@sanity/ui: could not locate global scope")}();function cd(e){return Array.isArray(e)}function cc(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function cu(e){return"string"==typeof e}let cp="object"==typeof document&&"object"==typeof window&&window.ResizeObserver?window.ResizeObserver:aB.do,ch=(()=>{let e=(0,lG.Z)(),t=new cp(t=>e.publish(t));return{observe:(n,i,r)=>{let l=e.subscribe(e=>{let t=e.find(e=>e.target===n);t&&i(t)});return t.observe(n,r),()=>{l(),t.unobserve(n)}}}})(),cf=["sanity.imageAsset","sanity.fileAsset"];function cm(e){return"document"===e.type&&!("document"===e.type&&cf.includes(e.name))}let cg=["match","in","asc","desc","true","false","null"],cx=/^[a-zA-Z_][a-zA-Z0-9_]*$/,cv=e=>!cx.test(e)||cg.includes(e),cb=e=>'["'.concat(e,'"]'),cy=e=>"@".concat(cb(e)),cj=e=>Array.isArray(e)&&0===e.length,cw=e=>{let t="";for(let n=0;n<e.length;n++){let i=e[n];if(cj(i)){t+="[]";continue}if("number"==typeof i){t+="[".concat(i,"]");continue}let r=0===n,l=cv(i);t=l?r?cy(i):"".concat(t).concat(cb(i)):r?i:"".concat(t,".").concat(i)}return t},ck="undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0),cC={isLoading:!0,value:void 0,error:null};function c_(e,t){let n=void 0===t?cC:{isLoading:!1,value:t,error:null};return(0,lJ.m2)(()=>e.pipe(e=>e.pipe((0,ad.U)(e=>({isLoading:!1,value:e,error:null})),(0,au.K)(e=>(0,lQ.of)({isLoading:!1,value:void 0,error:e})))),[e],n)}function cS(e,t){return null!==e&&e.roles.some(e=>
1e.name===t)}var cT=Object.freeze,cE=Object.defineProperty,cP=(e,t)=>cT(cE(e,"raw",{value:cT(t||e.slice())}));let cA=aW.ZP.div(e=>{let{changed:t,disabled:n,isReviewChangeOpen:i}=e;return n?(0,aW.iv)(eS||(eS=cP(["\n "," {\n display: none;\n }\n "])),cz):(0,aW.iv)(eP||(eP=cP(["\n --change-bar-offset: 2px;\n\n display: flex;\n position: relative;\n\n @media (hover: hover) {\n &:hover {\n z-index: 10;\n }\n }\n\n /* hide when field is not changed */\n ","\n\n /* hide hover effect when review changes is open */\n ","\n "])),!t&&(0,aW.iv)(eT||(eT=cP(["\n "," {\n opacity: 0;\n pointer-events: none;\n }\n "])),cz),i&&(0,aW.iv)(eE||(eE=cP(["\n "," {\n opacity: 0;\n }\n "])),cI))}),cO=aW.ZP.div(eA||(eA=cP(["\n flex-grow: 1;\n min-width: 0;\n"]))),cz=aW.ZP.div(eO||(eO=cP(["\n position: relative;\n opacity: 1;\n transition: opacity 100ms;\n z-index: ",";\n"])),e=>{let{$zIndex:t}=e;return t}),cM=aW.ZP.div(e=>{let{theme:t}=e,n=t.sanity.color.spot.yellow,i=t.sanity.media[0];return(0,aW.iv)(ez||(ez=cP(["\n position: absolute;\n top: 0;\n left: var(--change-bar-offset);\n width: 2px;\n bottom: 0;\n background-color: ",";\n border-radius: 1px;\n\n @media (min-width: ","px) {\n display: unset;\n }\n "])),n,i)}),cI=aW.ZP.button(e=>{let{theme:t,$withHoverEffect:n}=e,i=t.sanity.color.spot.yellow;return(0,aW.iv)(eI||(eI=cP(["\n appearance: none;\n border: 0;\n outline: 0;\n display: block;\n padding: 0;\n background: transparent;\n opacity: 0;\n position: absolute;\n height: 100%;\n cursor: pointer;\n pointer-events: all;\n left: calc(-0.25rem + var(--change-bar-offset));\n width: 1rem;\n transition: opacity ","ms;\n\n &:focus {\n border: 0;\n outline: 0;\n }\n\n &:after {\n content: '';\n width: 16px;\n height: calc(100% + 14px);\n display: block;\n position: absolute;\n top: -7px;\n left: -3px;\n border-radius: 8px;\n background: ",";\n }\n\n &:focus {\n border: 0;\n outline: 0;\n }\n\n ","\n "])),250,i,n&&(0,aW.iv)(eM||(eM=cP(["\n @media (hover: hover) {\n &:hover {\n opacity: 0.2;\n }\n }\n "]))))});function cR(e){let{children:t,disabled:n,hasFocus:i,isChanged:r,withHoverEffect:l=!0}=e,[a,o]=(0,lK.useState)(!1),{onOpenReviewChanges:s,isReviewChangesOpen:d}=lK.useContext(d4),{zIndex:c}=(0,lY.sJ)(),u=(0,lK.useCallback)(()=>o(!0),[]),p=(0,lK.useCallback)(()=>o(!1),[]),h=(0,lK.useMemo)(()=>n||!r?null:(0,lU.jsxs)(cz,{"data-testid":"change-bar",$zIndex:c,children:[(0,lU.jsx)(cM,{"data-testid":"change-bar__marker"}),(0,lU.jsx)(cI,{"aria-label":"Review changes","data-testid":"change-bar__button",onClick:d?void 0:s,onMouseEnter:u,onMouseLeave:p,tabIndex:-1,type:"button",$withHoverEffect:l})]}),[n,r,c,d,s,u,p,l]);return(0,lU.jsxs)(cA,{changed:r,"data-testid":"change-bar-wrapper",disabled:n,focus:i,hover:a,isReviewChangeOpen:d,children:[(0,lU.jsx)(cO,{"data-testid":"change-bar__field-wrapper",children:t}),h]})}let cF=(0,lK.memo)(function(e){let{children:t,disabled:n,hasFocus:i,isChanged:r,onMouseEnter:l,onMouseLeave:a,path:o=co,withHoverEffect:s,...d}=e,c=(0,lY.sJ)(),[u,p]=(0,lK.useState)(!1),h=(0,lK.useCallback)(e=>{null==l||l(e),p(!0)},[l]),f=(0,lK.useCallback)(e=>{null==a||a(e),p(!1)},[a]),m=(0,lK.useRef)(null);return d3(n?null:"field-".concat(lB.BB(o)),()=>({element:m.current,path:o,isChanged:r,hasFocus:i,hasHover:u,zIndex:c.zIndex}),lW()),(0,lU.jsx)("div",{...d,ref:m,onMouseEnter:h,onMouseLeave:f,children:(0,lU.jsx)(cR,{hasFocus:i,isChanged:r,disabled:n,withHoverEffect:s,children:t})})});function cD(e){let{children:t,hasFocus:n,isChanged:i,path:r,withHoverEffect:l,...a}=e;return(0,lU.jsx)(cF,{...a,path:r,hasFocus:n,isChanged:i,withHoverEffect:l,children:t})}lK.createContext({path:[],fullPath:[],focusPath:[],isChanged:!1});let cZ=lK.createContext(null),cL=()=>void 0,cq=lK.forwardRef(function(e,t){let{as:n="div",onScroll:i,...r}=e,l=(0,lY.ts)(t),a=(0,lK.useContext)(cZ),o=(0,lK.useMemo)(()=>(0,lG.Z)(),[]);return(0,lK.useEffect)(()=>i?o.subscribe(i):cL,[o,i]),(0,lK.useEffect)(()=>a?o.subscribe(a.publish):cL,[a,o]),(0,lK.useEffect)(()=>{let e=e=>{o.publish(e)},t=l.current;if(t)return t.addEventListener("scroll",e,{passive:!0,capture:!0}),()=>{t.removeEventListener("scroll",e)}},[o,l]),(0,lU.jsx)(cZ.Provider,{value:o,children:lK.createElement(n,{ref:l,"data-testid":"scroll-container",...r})})});function cN(e){let{onScroll:t,children:n}=e;return!function(e){let t=lK.useContext(cZ);lK.useEffect(()=>null==t?void 0:t.subscribe(e),[e,t])}(t),(0,lU.jsx)(lU.Fragment,{children:n})}function cV(e,t,n){let i;let r=t.slice(t.indexOf("-")+1)||"[]",l=lB.mL(r),a="".concat(e,"-").concat(lB.BB(l));if(n.has(a))return n.get(a);for(let[t,r]of n){if(!("path"in r)||!t.startsWith(e))continue;let n=lB.eh(l,r.path),a=r.path[r.path.length-1],o=n===r.path.length-1&&(0,lV.fU)(a);if(0!==n&&(n===r.path.length||o)&&(i=r,n===l.length))break}return i}function cU(e){let t=getComputedStyle(e).overflow;return t.includes("auto")||t.includes("scroll")}function cB(e){let t=e.element,n=t;
1for(;!function(e){let t=e.scrollHeight!==e.offsetHeight||e.scrollWidth!==e.offsetWidth;return t&&cU(e)}(n);)if(!(n=n.parentElement))return;n.scroll({top:n.scrollTop+e.rect.top-e.bounds.top+-15,left:0,behavior:"smooth"})}let cK=(e,t)=>{let n={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth},i={top:0,left:0,height:e.offsetHeight,width:e.offsetWidth},r=!1,l=e;for(;l&&l!==t&&t.contains(l);)r&&(n.top+=l.offsetTop,n.left+=l.offsetLeft),cU(l)&&(n.top=l.offsetTop,n.height=l.offsetHeight,n.left=l.offsetLeft,n.width=l.offsetWidth,r=!0),i.top+=l.offsetTop-l.scrollTop,i.left+=l.offsetLeft-l.scrollLeft,l=l.offsetParent;return{rect:i,bounds:n}};function cH(e,t,n){return["M ".concat(e-4," ").concat(t-4*n," "),"L ".concat(e," ").concat(t),"L ".concat(e+4," ").concat(t-4*n)].join("")}function cW(e,t){return"M".concat(e," ").concat(t)}function c$(e,t){return"L".concat(e," ").concat(t)}function cX(e,t,n,i){return"Q".concat(e," ").concat(t," ").concat(n," ").concat(i)}function cG(e,t){let n=e.top+e.height/2,i=e.top+e.height<t.top+2,r=e.top>t.top+t.height-2;return{bounds:t,left:e.left,top:n,centerY:n,startY:e.top+8,endY:e.top+e.height-8,isAbove:i,isBelow:r,outOfBounds:i||r}}var cY=Object.freeze,cJ=Object.defineProperty,cQ=(e,t)=>cY(cJ(e,"raw",{value:cY(t||e.slice())}));aW.ZP.rect(eR||(eR=cQ(["\n stroke: #ccc;\n fill: none;\n pointer-events: none;\n stroke-linecap: round;\n"])));let c0=aW.ZP.path(e=>{let{theme:t}=e,n=t.sanity.color.spot.yellow;return(0,aW.iv)(eF||(eF=cQ(["\n fill: none;\n pointer-events: none;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke: ",";\n "])),n)}),c1=aW.ZP.path(e=>{let{theme:t}=e,n=t.sanity.color.spot.yellow;return(0,aW.iv)(eD||(eD=cQ(["\n fill: none;\n pointer-events: stroke;\n stroke: ",";\n cursor: pointer;\n stroke-linecap: round;\n stroke-linejoin: round;\n opacity: 0;\n\n &:hover {\n opacity: 0.2;\n }\n "])),n)}),c2=(0,aW.ZP)(function(e){let{bounds:t,...n}=e,i=Math.max(t.left,e.left),r=Math.max(e.top,t.top),l=Math.max(0,e.height-(r-e.top)),a=Math.max(0,e.width-(i-e.left));return(0,lU.jsx)("rect",{...n,x:i,y:r,height:l,width:a})})(e=>{let{theme:t}=e,n=t.sanity.color.spot.yellow;return(0,aW.iv)(eZ||(eZ=cQ(["\n stroke: none;\n pointer-events: none;\n fill: ",";\n "])),n)}),c3=(0,lK.memo)(function(e){let{from:t,to:n}=e,i=function(e){let t={top:e.from.bounds.top+12,bottom:e.from.bounds.top+e.from.bounds.height-12,left:e.from.bounds.left,right:e.from.bounds.left+e.from.bounds.width,width:e.from.bounds.width,height:e.from.bounds.height-24},n=cG(e.from.rect,t);n.left=e.from.rect.left+e.from.rect.width+1;let i={top:e.to.bounds.top+12,bottom:e.to.bounds.top+e.to.bounds.height-12,left:e.to.bounds.left,right:e.to.bounds.left+e.to.bounds.width,width:e.to.bounds.width,height:e.to.bounds.height-24},r=cG(e.to.rect,i),l=Math.max(r.startY,n.startY);return n.top=Math.min(l,n.endY),n.top<i.top?n.top=Math.min(i.top,n.endY):n.top>i.bottom&&(n.top=Math.max(i.bottom,n.startY)),r.top=Math.min(l,r.endY),r.top<t.top?r.top=Math.min(t.top,r.endY):r.top>t.bottom&&(r.top=Math.max(t.bottom,r.startY)),n.top=Math.min(Math.max(n.top,t.top),t.bottom),r.top=Math.min(Math.max(r.top,i.top),i.bottom),{from:n,to:r}}({from:t,to:n});if(i.from.outOfBounds&&i.to.outOfBounds)return null;let r=function(e){let{from:t,to:n}=e,{left:i,top:r}=t,{left:l,top:a}=n,o=[],s=Math.min(4,Math.abs(r-a)/2);return t.isAbove?o.push(cW(i+8,r-12+2),c$(i+8,r-4),cX(i+8,r,i+8+4,r)):t.isBelow?o.push(cW(i+8,r+12-2),c$(i+8,r+4),cX(i+8,r,i+8+4,r)):o.push(cW(i,r)),n.isAbove?r<n.bounds.top?o.push(c$(n.bounds.left-8-s,r),cX(n.bounds.left-8,r,n.bounds.left-8,r+s),c$(n.bounds.left-8,a-s),cX(n.bounds.left-8,a,n.bounds.left-8+s,a),c$(n.bounds.left+8-4,a),cX(n.bounds.left+8,a,n.bounds.left+8,a-4),c$(n.bounds.left+8,a-12+2)):o.push(c$(n.bounds.left+8-4,r),cX(n.bounds.left+8,r,n.bounds.left+8,r-4),c$(n.bounds.left+8,a-12+2)):n.isBelow?r>n.bounds.top+n.bounds.height?o.push(c$(n.bounds.left-8-s,r),cX(n.bounds.left-8,r,n.bounds.left-8,r-s),c$(n.bounds.left-8,a+s),cX(n.bounds.left-8,a,n.bounds.left-8+s,a),c$(n.bounds.left+8-4,a),cX(n.bounds.left+8,a,n.bounds.left+8,a+4),c$(n.bounds.left+8,a+12-2)):o.push(c$(n.bounds.left+8-4,r),cX(n.bounds.left+8,r,n.bounds.left+8,r+4),c$(n.bounds.left+8,a+12-2)):r<a?o.push(c$(n.bounds.left+8-s,r),cX(n.bounds.left+8,r,n.bounds.left+8,r+s),c$(n.bounds.left+8,a-s),cX(n.bounds.left+8,a,n.bounds.left+8+s,a),c$(l,a)):o.push(c$(n.bounds.left+8-s,r),cX(n.bounds.left+8,r,n.bounds.left+8,r-s),c$(n.bounds.left+8,a+s),cX(n.bounds.left+8,a,n.bounds.left+8+s,a),c$(l,a)),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e.join(t)}(o)}(i);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(c1,{d:r,strokeWidth:16}),(0,lU.jsx)(c0,{d:r,strokeWidth:2}
1),(0,lU.jsx)(c2,{top:n.rect.top,left:n.rect.left,height:n.rect.height,width:2,bounds:n.bounds}),i.from.isAbove&&(0,lU.jsx)(c0,{d:cH(i.from.left+8,i.from.bounds.top-12+2,-1),strokeWidth:2}),i.from.isBelow&&(0,lU.jsx)(c0,{d:cH(i.from.left+8,i.from.bounds.top+i.from.bounds.height+12-2,1),strokeWidth:2}),i.to.isAbove&&(0,lU.jsx)(c0,{d:cH(i.to.bounds.left+8,i.to.bounds.top-12+2,-1),strokeWidth:2}),i.to.isBelow&&(0,lU.jsx)(c0,{d:cH(i.to.bounds.left+8,i.to.bounds.top+i.to.bounds.height+12-2,1),strokeWidth:2}),!1]})});var c4=Object.freeze,c5=Object.defineProperty;let c6=aW.ZP.svg(eL||(eL=c4(c5(a=["\n pointer-events: none;\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n"],"raw",{value:c4(a.slice())}))));function c8(e,t,n,i){let r=[],l=[];for(let n of e){if(!("changePanel"!==n[0])||!n[1].isChanged)continue;let[e,i]=n;if(e===t||i.hasHover){r.push(n);continue}if(i.hasFocus){l.push(n);continue}}let a=r.length>0,o=(a?r:l).map(e=>{let[t]=e,i=cV("field",t,n),r=cV("change",t,n);return i&&r?{field:{id:t,...i},change:{id:t,...r}}:null}).filter(d9).map(e=>{let{field:t,change:n}=e;return{hasHover:t.hasHover||n.hasHover,hasFocus:t.hasFocus,hasRevertHover:n.hasRevertHover,field:{...t,...cK(t.element,i)},change:{...n,...cK(n.element,i)}}});return{connectors:o,isHoverConnector:a}}function c9(e){let{rootElement:t,onSetFocus:n}=e,[i,r]=lK.useState(null),l=d2(),a=(0,lK.useMemo)(()=>new Map(l),[l]),[{connectors:o},s]=(0,lK.useState)(()=>c8(l,i,a,t)),d=(0,lK.useMemo)(()=>aX()(o,e=>0-e.field.path.length).slice(0,1),[o]),c=(0,lK.useCallback)(()=>{s(c8(l,i,a,t))},[a,l,i,t]);return(0,lK.useEffect)(()=>ch.observe(t,c),[t,c]),(0,lU.jsx)(cN,{onScroll:c,children:(0,lU.jsx)(c6,{style:{zIndex:d[0]&&d[0].field.zIndex},children:d.map(e=>{let{field:t,change:i}=e;return i?(0,lU.jsx)(c7,{field:t,change:i,onSetFocus:n,setHovered:r},t.id):null})})})}function c7(e){let{change:t,field:n,onSetFocus:i,setHovered:r}=e,l=(0,lK.useCallback)(()=>{cB(n),cB(t),i(n.path)},[n,t,i]),a=(0,lK.useCallback)(()=>r(n.id),[n,r]),o=(0,lK.useCallback)(()=>r(null),[r]),s=(0,lK.useMemo)(()=>({rect:{left:n.rect.left+2,top:n.rect.top,height:n.rect.height,width:n.rect.width},bounds:n.bounds}),[n.bounds,n.rect]),d=(0,lK.useMemo)(()=>({rect:t.rect,bounds:t.bounds}),[t.bounds,t.rect]);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)("g",{onClick:l,onMouseEnter:a,onMouseLeave:o,children:(0,lU.jsx)(c3,{from:s,to:d})}),!1]})}let ue=function(e){let{children:t,className:n,isReviewChangesOpen:i,onOpenReviewChanges:r,onSetFocus:l,...a}=e,[o,s]=lK.useState(),d=(0,lK.useMemo)(()=>({isReviewChangesOpen:i,onOpenReviewChanges:r,onSetFocus:l}),[i,r,l]);return(0,lU.jsx)(d4.Provider,{value:d,children:(0,lU.jsx)(d1,{children:(0,lU.jsxs)(cq,{...a,ref:s,className:n,children:[t,o&&(0,lU.jsx)(c9,{rootElement:o,onSetFocus:l})]})})})};function ut(e){let{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,l=0-i.offset,a=t?t.bg:"var(--card-bg-color)";return[l>0&&"inset 0 0 0 ".concat(l,"px var(--card-focus-ring-color)"),n&&"inset 0 0 0 ".concat(n.width,"px ").concat(n.color),l<0&&"0 0 0 ".concat(0-l,"px ").concat(a),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}var un=Object.freeze,ui=Object.defineProperty,ur=(e,t)=>un(ui(e,"raw",{value:un(t||e.slice())}));let ul="a,button",ua=aW.ZP.div(e=>{let{theme:t,offset:n}=e;return(0,aW.iv)(eq||(eq=ur(["\n bottom: ","px;\n border-radius: ",";\n left: ","px;\n pointer-events: none;\n position: absolute;\n right: ","px;\n top: ","px;\n z-index: 2;\n\n ",":focus-visible & {\n box-shadow: ",";\n }\n "])),-n,(0,lY.hO)(t.sanity.radius[1]),-n,-n,-n,us,ut({base:t.sanity.color.base,focusRing:t.sanity.focusRing}))}),uo=aW.ZP.div(eN||(eN=ur(["\n bottom: 0;\n display: none;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: 1;\n\n @media (hover: hover) {\n &[data-enabled='true'] {\n display: block;\n }\n }\n"]))),us=(0,aW.ZP)(lY.xu)(eV||(eV=ur(["\n height: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: auto;\n overscroll-behavior: contain;\n width: 100%;\n"]))),ud=(0,aW.ZP)(lY.xu).attrs(e=>{let{$height:t}=e;return{style:{height:"".concat(t,"px")}}})(eU||(eU=ur(["\n position: relative;\n width: 100%;\n"]))),uc=(0,lK.forwardRef)(function(e,t){let{activeItemDataAttr:n="data-active",ariaLabel:i,ariaMultiselectable:r=!1,autoFocus:l,canReceiveFocus:a,fixedHeight:o,focusRingOffset:s=0,getItemDisabled:d,getItemKey:c,getItemSelected:u,initialIndex:p,initialScrollAlign:h="start",inputElement:f,itemHeight:m,items:g,onEndReached:x,onEndReachedIndexOffset:v=0,onlyShowSelectionWhenActive:b,overscan:y,renderItem:j,wrapAround:w=!0,...k}=e,C=(0,lK.useRef)(!1),_=(0,lK.useRef)((0,lK.useId)()),S=(0,lK.useRef)(null!=p?p:0),[T,E]=(0,lK.useState)(null),[P,A]=(0,lK.useState)(!1),[O,z]=(0,lK.useState)(null),[M,I]=(0,lK.useState)(null),R=(0,lK.useCallback)(e=>{if(!x)return;let[t]=[...e.getVirtualItems()].reverse();if(!t)return;let n=t.index>=g.length-v-1;n&&C.current&&x()},[x,g.length,v]),F=(0,aG.MG)({count:g.length,getItemKey:c,getScrollElement:()=>M,estimateSize:()=>
1m,onChange:R,overscan:y}),D=(0,lK.useMemo)(()=>{let e=-1;return g.reduce((t,n,i)=>{var r,l;let a=null!=(r=null==d?void 0:d(i))&&r,o=null!=(l=null==u?void 0:u(i))&&l;return a||(e+=1),t[i]={activeIndex:a?null:e,disabled:a,selected:o},t},[])},[d,u,g]),Z=(0,lK.useMemo)(()=>D.filter(e=>!e.disabled).length,[D]),L=(0,lK.useCallback)(e=>null==O?void 0:O.setAttribute("data-enabled",(!e).toString()),[O]),q=(0,lK.useCallback)(e=>"".concat(_.current,"-item-").concat(e),[]),N=(0,lK.useCallback)(()=>"".concat(_.current,"-children"),[]),V=(0,lK.useCallback)(()=>{let e=[f,M].some(e=>document.activeElement===e);if(b&&!e&&!P)return;let t=Array.from((null==T?void 0:T.children)||[]);null==t||t.forEach(e=>{var t,i,r;let l=Number(null==(t=e.dataset)?void 0:t.index),a=null==(i=D[l])?void 0:i.activeIndex;null==(r=e.querySelector(ul))||r.toggleAttribute(n,a===S.current)})},[n,null==T?void 0:T.children,P,f,D,b,M]),U=(0,lK.useCallback)(()=>{let e=Array.from((null==T?void 0:T.children)||[]);null==e||e.forEach(e=>{var t;null==(t=e.querySelector(ul))||t.toggleAttribute(n,!1)})},[n,null==T?void 0:T.children]),B=(0,lK.useMemo)(()=>aH()(V,200),[V]),K=(0,lK.useCallback)(()=>{let e=null==S?void 0:S.current;g.length>0?(null==f||f.setAttribute("aria-activedescendant",q(e)),null==M||M.setAttribute("aria-activedescendant",q(e))):(null==f||f.removeAttribute("aria-activedescendant"),null==M||M.removeAttribute("aria-activedescendant"))},[q,f,g.length,M]),H=(0,lK.useCallback)(()=>{var e,t;let n=null==T?void 0:T.parentElement;if(T&&n){let i=n.getBoundingClientRect().top-T.getBoundingClientRect().top;return null!=(t=null==(e=F.getVirtualItemForOffset(i))?void 0:e.index)?t:-1}return -1},[T,F]),W=(0,lK.useCallback)(e=>{let{index:t,scrollAlign:n,scrollIntoView:i=!0}=e;if(S.current=t,K(),V(),i){let e=D.findIndex(e=>e.activeIndex===t);e>-1&&F.scrollToIndex(e,n?{align:n}:{})}},[K,D,V,F]),$=(0,lK.useCallback)(e=>{let t=-1,n=Z-1;if("next"===e){let e=w?0:n;t=S.current<Z-1?S.current+1:e}if("previous"===e){let e=w?n:0;t=S.current>0?S.current-1:e}W({index:t,scrollIntoView:!0}),L(!1)},[Z,L,W,w]),X=(0,lK.useCallback)(e=>{switch(e){case"input":null==f||f.focus();break;case"list":null==M||M.focus()}},[f,M]),G=(0,lK.useCallback)(()=>{null==f||f.focus()},[f]),Y=(0,lK.useCallback)(()=>{null==M||M.focus()},[M]),J=(0,lK.useCallback)(e=>()=>{W({index:e,scrollIntoView:!1})},[W]),Q=(0,lK.useCallback)(()=>{V()},[V]),ee=(0,lK.useCallback)(e=>t=>{let n=Array.from((null==T?void 0:T.children)||[]);if(n.length&&("ArrowDown"===t.key&&(t.preventDefault(),X(e),$("next")),"ArrowUp"===t.key&&(t.preventDefault(),X(e),$("previous")),"Enter"===t.key)){t.preventDefault(),X(e);let i=n.find(e=>Number(e.dataset.index)===D.findIndex(e=>e.activeIndex===S.current));if(i){let e=null==i?void 0:i.querySelector(ul);null==e||e.click()}}},[null==T?void 0:T.children,X,D,$]),et=(0,lK.useCallback)(e=>ee("input")(e),[ee]),en=(0,lK.useCallback)(e=>ee("list")(e),[ee]),ei=(0,lK.useCallback)(()=>{b&&(V(),A(!0))},[b,V]),er=(0,lK.useCallback)(()=>{b&&(U(),A(!1))},[U,b]);(0,lK.useImperativeHandle)(t,()=>({focusInputElement(){G()},focusListElement(){Y()},getTopIndex:()=>
1H(),scrollToIndex(e){W({index:e}),L(!0)}}),[L,G,Y,H,W]),(0,lK.useEffect)(()=>{void 0===p||C.current||W({index:p,scrollAlign:h,scrollIntoView:!0}),C.current=!0},[p,h,b,W]),(0,lK.useEffect)(()=>{function e(){L(!0)}return null==M||M.addEventListener("mousemove",e),null==M||M.addEventListener("wheel",e,{passive:!0}),()=>{null==M||M.removeEventListener("mousemove",e),null==M||M.removeEventListener("wheel",e)}},[L,M]),(0,lK.useEffect)(()=>(null==f||f.addEventListener("focus",Q),null==f||f.addEventListener("keydown",et),null==M||M.addEventListener("focus",Q),null==M||M.addEventListener("keydown",en),()=>{null==f||f.removeEventListener("focus",Q),null==f||f.removeEventListener("keydown",et),null==M||M.removeEventListener("focus",Q),null==M||M.removeEventListener("keydown",en)}),[a,Q,ee,et,en,U,f,V,M]),(0,lK.useEffect)(()=>{K()},[K,g]),(0,lK.useEffect)(()=>{let e=new MutationObserver(B);return T&&e.observe(T,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[T,B]),(0,lK.useEffect)(()=>{null==f||f.setAttribute("aria-autocomplete","list"),null==f||f.setAttribute("aria-expanded","true"),null==f||f.setAttribute("aria-controls",N()),null==f||f.setAttribute("role","combobox")},[N,f]),(0,lK.useEffect)(()=>{l&&X(l)},[l,a,Y,G,X]);let el=a?0:-1;return(0,lU.jsxs)(us,{id:N(),onMouseEnter:ei,onMouseLeave:er,ref:I,sizing:"border",tabIndex:el,...k,children:[a&&(0,lU.jsx)(ua,{offset:s}),(0,lU.jsx)(uo,{"aria-hidden":"true","data-enabled":!0,ref:z}),F&&(0,lU.jsx)(ud,{$height:F.getTotalSize(),"aria-label":i,"aria-multiselectable":r,flex:1,ref:E,role:"listbox",children:F.getVirtualItems().map(e=>{let t=e.index,{activeIndex:n,disabled:i,selected:l}=D[t],a=j(g[t],{activeIndex:n,disabled:i,selected:l,virtualIndex:t}),s=(0,lK.cloneElement)(a,{tabIndex:-1}),d="number"!=typeof n||i?{}:{"aria-posinset":n+1,...r?{"aria-selected":l.toString()}:{},"aria-setsize":Z,id:q(n),role:"option",onMouseEnter:J(n)};return(0,lU.jsx)("div",{"data-index":t,ref:o?void 0:F.measureElement,style:{flex:1,...o?{height:"".concat(e.size,"px")}:{},left:0,position:"absolute",top:0,transform:"translateY(".concat(e.start,"px)"),width:"100%"},tabIndex:-1,...d,children:s},e.key)})})]})}),uu=new WeakMap,up=0;function uh(e){let t=uu.get(e);if(t)return t;let n="".concat(e.name||e.displayName||"<anonymous>","-").concat(up++);return uu.set(e,n),n}let uf=(0,lK.memo)(function(e){let{hook:t,args:n,id:i,onNext:r,onReset:l,onRequestUpdate:a}=e,o=t({...n,onComplete:()=>{l(i)}});return(0,lK.useEffect)(()=>(r(i,o),a(),()=>{r(i,null),a()}),function(e){let t=(0,lK.useRef)(void 0);return aQ()(e,t.current)||(t.current=e),[t.current]}(o)),null},(e,t)=>e.args===t.args),um="undefined"==typeof requestIdleCallback?e=>{let t=Date.now();return setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,Date.now()-t)})},1)}:requestIdleCallback,ug="undefined"==typeof cancelIdleCallback?e=>clearTimeout(e):cancelIdleCallback,ux={trailing:!0};function uv(e){let{hooks:t,args:n,children:i,onReset:r}=e,l=(0,lK.useRef)({}),[a,o]=(0,lK.useState)(0),[s,d]=(0,lK.useState)({}),c=(0,lK.useRef)(null),u=(0,lK.useCallback)(()=>{c.current&&ug(c.current),c.current=um(()=>{c.current=null,o(e=>e+1)})},[]),p=function(e,t,n){let i=(0,lK.useMemo)(()=>aH()(e,t,n),[e,n,t]);return i}(u,60,ux),h=(0,lK.useCallback)((e,t)=>{if(null===t)delete l.current[e];else{let n=l.current[e];l.current[e]={...n,value:t}}},[]),f=(0,lK.useCallback)(e=>{d(t=>({...t,[e]:(t[e]||0)+1})),r&&r()},[r]),m=(0,lK.useMemo)(()=>t.map(e=>uh(e)),[t]),g=(0,lK.useMemo)(()=>m.map(e=>{var t;return null==(t=l.current[e])?void 0:t.value}).filter(d9),[m,a]);return(0,lU.jsxs)(lU.Fragment,{children:[t.map(e=>{let t=uh(e),i=s[t]||0;return(0,lU.jsx)(uf,{hook:e,id:t,args:n,onNext:h,onRequestUpdate:p,onReset:f},"".concat(t,"-").concat(i))}),i({states:g})]})}function ub(e){var t,n;let{currentUser:i,title:r="Insufficient permissions",operationLabel:l="access this feature"}=e,a=(null==i?void 0:i.roles)||[],o=1!==a.length;return(0,lU.jsxs)(lY.xu,{padding:2,children:[(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.vaB,{})}),(0,lU.jsx)(lY.xv,{weight:"semibold",children:r})]}),(0,lU.jsx)(lY.gF,{marginTop:4,children:(0,lU.jsx)(lY.xv,{size:1,children:0===a.length?(0,lU.jsxs)(lU.Fragment,{children:["You have no role that grants
1you permission to ",l]}):(0,lU.jsxs)(lU.Fragment,{children:["Your role",o&&"s"," ",(t=a.map(e=>(0,lU.jsx)("code",{children:e.title},e.name)),n=(0,lU.jsx)(lU.Fragment,{children:", "}),t.reduce((e,t)=>null===e?[t]:[...e,n,t],null))," ","do",o||"es"," not have permissions to ",l]})})})]})}let uy=(0,aW.ZP)(lY.W2)(e=>{let{theme:t}=e,{container:n,media:i}=t.sanity;return(0,lY.Lt)(i,e.$width,e=>({width:"auto"===e?"none":(0,lY.hO)(n[e]),maxWidth:"100%"}))}),uj=lK.forwardRef(function(e,t){let{width:n,...i}=e,r=(0,lY.Q5)(n);return(0,lU.jsx)(uy,{...i,"data-ui":"PopoverContainer",$width:r,ref:t})});var uw=Object.freeze,uk=Object.defineProperty,uC=(e,t)=>uw(uk(e,"raw",{value:uw(t||e.slice())}));let u_=(0,aW.ZP)(lY.J2)(()=>(0,aW.iv)(eB||(eB=uC(["\n // Make the popover scrollable if it overflows the viewport\n [data-ui='Popover__wrapper'] {\n overflow: auto;\n }\n "])))),uS=(0,aW.ZP)(lY.mh)(e=>{let t=e.theme.sanity.radius[3];return(0,aW.iv)(eK||(eK=uC(["\n position: sticky;\n top: 0;\n width: 100%;\n background: var(--card-bg-color);\n border-bottom: 1px solid var(--card-border-color);\n border-top-left-radius: ","px;\n border-top-right-radius: ","px;\n "])),t,t)});function uT(e){let{children:t,header:n,onClose:i,referenceElement:r,containerRef:l,width:a}=e,o=(0,lK.useCallback)(()=>{i(),null==r||r.focus()},[i,r]),s=(0,lU.jsx)(uj,{width:a,children:(0,lU.jsx)(a2.ZP,{autoFocus:!0,children:(0,lU.jsxs)(lY.Kq,{ref:l,children:[(0,lU.jsx)(uS,{children:(0,lU.jsx)(lY.xu,{padding:2,paddingLeft:3,children:(0,lU.jsxs)(lY.kC,{align:"center",gap:2,children:[(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.xv,{textOverflow:"ellipsis",weight:"semibold",children:n})}),(0,lU.jsx)(lY.zx,{icon:a0.Two,mode:"bleed",onClick:o})]})})}),t]})})});return(0,lU.jsx)(u_,{portal:!0,constrainSize:!0,content:s,open:!0,referenceElement:r})}var uE=Object.freeze,uP=Object.defineProperty,uA=(e,t)=>uE(uP(e,"raw",{value:uE(t||e.slice())}));let uO=(0,aW.ZP)(lY.Zb)(()=>(0,aW.iv)(eH||(eH=uA(["\n /* this is a hack to avoid layout jumps while previews are loading\n there's probably better ways of solving this */\n min-height: 35px;\n\n /* TextWithTone uses its own logic to set color, and we therefore need */\n /* to override this logic in order to set the correct color in different states */\n &[data-selected],\n &[data-pressed],\n &:active {\n [data-ui='TextWithTone'] {\n color: inherit;\n }\n }\n "])))),uz=(0,lK.createContext)({selected:!1}),uM=(0,lK.forwardRef)(function(e,t){let{children:n,selected:i,as:r,...l}=e;return(0,lU.jsx)(uO,{"data-ui":"PreviewCard",...l,forwardedAs:r,ref:t,selected:i,children:(0,lU.jsx)(uz.Provider,{value:{selected:i},children:n})})}),uI={block:{width:33,height:33},blockImage:{width:600,height:400},default:{width:35,height:35},detail:{width:75,height:75},inline:{width:15,height:15},media:{width:160,height:160}},uR={block:31,blockImage:45,default:33,detail:45,inline:15,media:45};var uF=Object.freeze,uD=Object.defineProperty,uZ=(e,t)=>uF(uD(e,"raw",{value:uF(t||e.slice())}));let uL=aW.ZP.span(e=>{let{$dimensions:t,$layout:n,$radius:i,$responsive:r}=e,l=t.width||0,a=t.width||0,o=uR[n];return(0,aW.iv)(eW||(eW=uZ(["\n position: relative;\n width: ",";\n height: ",";\n min-width: ",";\n border-radius: ",";\n display: flex;\n overflow: hidden;\n overflow: clip;\n align-items: center;\n justify-content: center;\n\n & img {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n object-fit: contain;\n border-radius: inherit;\n }\n\n & svg {\n display: block;\n font-size: calc(21 / 16 * 1em);\n }\n\n & [data-sanity-icon] {\n display: block;\n font-size: calc(",' / 16 * 1em);\n }\n\n /*\n NOTE on why we canât use the ":after" pseudo-element:\n The thing is we only want the shadow when then <MediaWrapper> contains\n something else than <svg> â icons should not have the shadow.\n This is why we use the "*:not(svg) + span" selector to target only that\n situation to render the shadow.\n */\n & *:not(svg) + span {\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n box-shadow: inset 0 0 0 1px var(--card-fg-color);\n opacity: 0.2;\n border-radius: inherit;\n }\n '])),r?"100%":(0,lY.hO)(l),r?"100%":(0,lY.hO)(a),r?void 0:(0,lY.hO)(l),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[i])},o)});function uq(e){let{border:t=!0,dimensions:n,layout:i,media:r,radius:l=1,responsive:a=!1,styles:o}=e;return(0,lU.jsxs)(uL,{$dimensions:n,$layout:i,$radius:l,$responsive:a,className:null==o?void 0:o.media,"data-testid":"Media",children:[function(e){let{dimensions:t,layout:n,media:i,styles:r}=e;return(0,a6.isValidElementType)(i)?(0,lK.createElement)(i,{dimensions:t,layout:n}):"string"==typeof i?(0,lU.jsx)(lY.xv,{as:"span",className:null==r?void 0:r.mediaString,children:i}):(0,lK.isValidElement)(i)?i:null}({dimensions:n,layout:i,media:r}),t&&(0,lU.jsx)("span",{})]})}
1function uN(e,t,n){return"string"==typeof e?e:(0,a6.isValidElementType)(e)?(0,lK.createElement)(e,{layout:t}):e||n}uL.displayName="MediaWrapper";var uV=Object.freeze,uU=Object.defineProperty,uB=(e,t)=>uV(uU(e,"raw",{value:uV(t||e.slice())}));let uK={...uI.default,aspect:1,fit:"crop",dpr:(0,a5.x)()},uH=(0,aW.ZP)(lY.kC)(e$||(e$=uB(["\n height: ",";\n"])),(0,lY.hO)(uI.default.height)),uW=(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1})(eX||(eX=uB(["\n max-width: ",";\n width: 80%;\n"])),(0,lY.hO)(160)),u$=(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1,size:1})(eG||(eG=uB(["\n max-width: ",";\n width: 60%;\n"])),(0,lY.hO)(120));function uX(e){let{title:t,subtitle:n,media:i,status:r,isPlaceholder:l,children:a,styles:o}=e,s=a4()(null==o?void 0:o.root,!!n&&(null==o?void 0:o.hasSubtitle)),d=r&&(0,lU.jsx)(lY.xu,{className:null==o?void 0:o.status,"data-testid":"default-preview__status",paddingLeft:3,paddingRight:1,children:uN(r,"default")});return l?(0,lU.jsxs)(uH,{align:"center",className:null==o?void 0:o.placeholder,"data-testid":"default-preview",children:[!1!==i&&(0,lU.jsx)(lY.Od,{animated:!0,marginRight:2,radius:2,style:uI.default}),(0,lU.jsxs)(lY.Kq,{"data-testid":"default-preview__heading",flex:1,paddingLeft:!1===i?1:2,paddingRight:r?0:1,space:2,children:[(0,lU.jsx)(uW,{}),(0,lU.jsx)(u$,{})]}),d]}):(0,lU.jsxs)(uH,{align:"center",className:s,"data-testid":"default-preview",children:[!1!==i&&void 0!==i&&(0,lU.jsx)(uq,{dimensions:uK,layout:"default",media:i,styles:o}),(0,lU.jsxs)(lY.Kq,{className:null==o?void 0:o.heading,"data-testid":"default-preview__header",flex:1,paddingLeft:i?2:1,paddingRight:r?0:1,space:2,children:[(0,lU.jsxs)(lY.xv,{className:null==o?void 0:o.title,style:{color:"inherit"},textOverflow:"ellipsis",children:[t&&uN(t,"default"),!t&&(0,lU.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})]}),n&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",className:null==o?void 0:o.subtitle,children:uN(n,"default")}),a&&(0,lU.jsx)("div",{className:null==o?void 0:o.children,children:a})]}),d]})}var uG=Object.freeze,uY=Object.defineProperty,uJ=(e,t)=>uG(uY(e,"raw",{value:uG(t||e.slice())}));let uQ=(0,aW.ZP)(lY.kC).attrs({align:"center"})(eY||(eY=uJ(["\n height: ",";\n"])),(0,lY.hO)(uI.detail.height)),u0=(0,aW.ZP)(lY.xu)(eJ||(eJ=uJ(["\n white-space: nowrap;\n"]))),u1=(0,aW.ZP)(lY.Od).attrs({animated:!0,radius:2})(eQ||(eQ=uJ(["\n width: ",";\n height: ",";\n"])),(0,lY.hO)(uI.detail.width),(0,lY.hO)(uI.detail.height)),u2=(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1})(e0||(e0=uJ(["\n max-width: ","; /* 80% of 200px */\n width: 80%;\n"])),(0,lY.hO)(160)),u3=(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1,size:1})(e1||(e1=uJ(["\n max-width: ","; /* 60% of 200px */\n width: 60%;\n"])),(0,lY.hO)(120)),u4=(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1,size:1})(e2||(e2=uJ(["\n max-width: ","; /* 90% of 200px */\n width: 90%;\n"])),(0,lY.hO)(180)),u5=(0,aW.ZP)(lY.xv)(e=>{let{theme:t}=e,{fonts:n}=t.sanity,i=n.text.sizes[1],r=2*i.lineHeight;return(0,aW.iv)(e3||(e3=uJ(["\n & > span {\n max-height: ",";\n\n /* Multi-line text overflow */\n display: -webkit-box;\n overflow: hidden;\n overflow: clip;\n text-overflow: ellipsis;\n -webkit-line-clamp: ",";\n -webkit-box-orient: vertical;\n }\n "])),(0,lY.hO)(r),2)}),u6={...uI.detail,fit:"crop",aspect:1,dpr:(0,a5.x)()};var u8=Object.freeze,u9=Object.defineProperty,u7=(e,t)=>u8(u9(e,"raw",{value:u8(t||e.slice())}));let pe=aW.ZP.svg(e4||(e4=u7(["\n width: ","px;\n height: ","px;\n transform: rotate(-90deg);\n"])),43,43),pt=aW.ZP.circle(e=>{let{theme:t}=e,{color:n}=t.sanity;return(0,aW.iv)(e5||(e5=u7(["\n fill: none;\n stroke: ",";\n stroke-width: ","px;\n "])),a8.VG.gray[n.dark?900:100].hex,3)}),pn=aW.ZP.circle(e=>{let{theme:t}=e,{color:n}=t.sanity;return(0,aW.iv)(e6||(e6=u7(["\n fill: none;\n stroke: ",";\n stroke-width: ","px;\n transition: stroke-dashoffset 75ms;\n "])),a8.VG.blue[n.dark?400:500].hex,3)});function pi(e){let{value:t}=e,n=2*Math.PI*20,i="".concat(21.5," ").concat(21.5," ").concat(43," ").concat(43);return(0,lU.jsxs)(pe,{viewBox:i,children:[(0,lU.jsx)(pt,{cx:43,cy:43,r:20}),(0,lU.jsx)(pn,{cx:43,cy:43,r:20,style:{strokeDasharray:n,strokeDashoffset:"".concat((100-Math.min(Math.max(t,0),100))/100*n,"px")}})]})}var pr=Object.freeze,pl=Object.defineProperty,pa=(e,t)=>pr(pl(e,"raw",{value:pr(t||e.slice())}));let po=(0,aW.ZP)(lY.Zb)(e8||(e8=pa(["\n overflow: hidden;\n overflow: clip;\n"]))),ps=(0,aW.ZP)(lY.Zb)(e=>{let{theme:t}
1=e,{color:n}=t.sanity;return(0,aW.iv)(e9||(e9=pa(["\n height: ","rem;\n background: ",";\n transition: transform 75ms;\n "])),.5,a8.VG.blue[n.dark?400:500].hex)});function pd(e){let{value:t}=e;return(0,lU.jsx)(po,{radius:5,children:(0,lU.jsx)(ps,{radius:5,style:{transform:"translate3d(".concat(t-100,"%, 0, 0)")}})})}var pc=Object.freeze,pu=Object.defineProperty,pp=(e,t)=>pc(pu(e,"raw",{value:pc(t||e.slice())}));let ph=(0,aW.ZP)(lY.xu)(e7||(e7=pp(["\n position: relative;\n"]))),pf=(0,aW.ZP)(lY.kC).attrs({align:"center",justify:"center"})(te||(te=pp(["\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n"]))),pm=(0,aW.ZP)(lY.Od).attrs({animated:!0,radius:2})(tt||(tt=pp(["\n width: 100%;\n height: 100%;\n"]))),pg=(0,aW.ZP)(lY.kC).attrs({align:"center",justify:"center"})(tn||(tn=pp(["\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n\n &:before {\n background-color: var(--card-bg-color);\n opacity: 0.75;\n content: '';\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n }\n\n > svg {\n position: relative;\n z-index: 2;\n }\n"]))),px=(0,aW.ZP)(lY.Kq).attrs({padding:2,space:2})(ti||(ti=pp(["\n max-width: ",";\n"])),(0,lY.hO)(200)),pv={...uI.media,aspect:1,fit:"crop",dpr:(0,a5.x)()};var pb=Object.freeze,py=Object.defineProperty,pj=(e,t)=>pb(py(e,"raw",{value:pb(t||e.slice())}));let pw=(0,aW.ZP)(lY.kC).attrs({align:"center"})(tr||(tr=pj(["\n box-shadow: 0 0 0 1px var(--card-border-color);\n height: ",";\n white-space: nowrap;\n position: relative;\n z-index: 1;\n"])),(0,lY.hO)(uI.block.height)),pk=(0,aW.ZP)(lY.Zb)(tl||(tl=pj(["\n position: relative;\n padding-bottom: ","%;\n\n & > span {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n"])),e=>{let{$ratio:t}=e;return t}),pC=(0,aW.ZP)(lY.xu).attrs({overflow:"hidden"})(ta||(ta=pj(["\n border-radius: ","px;\n"])),e=>{let{theme:t}=e;return t.sanity.radius[1]}),p_={...uI.blockImage,fit:"fillmax",dpr:(0,a5.x)()},pS=e=>{let{height:t,width:n}=e;return t&&n?t/n*100:1};var pT=Object.freeze,pE=Object.defineProperty;let pP={...uI.block,aspect:1,fit:"crop",dpr:(0,a5.x)()},pA=(0,aW.ZP)(lY.kC).attrs({align:"center"})(to||(to=pT(pE(o=["\n min-height: ",";\n"],"raw",{value:pT(o.slice())}))),(0,lY.hO)(uI.block.height));var pO=Object.freeze,pz=Object.defineProperty,pM=(e,t)=>pO(pz(e,"raw",{value:pO(t||e.slice())}));let pI=aW.ZP.span(ts||(ts=pM(["\n display: inline-flex;\n align-items: center;\n vertical-align: top;\n height: calc(1em - 1px);\n max-width: 100%;\n"]))),pR=aW.ZP.span(td||(td=pM(["\n position: relative;\n display: inline-block;\n width: calc(1em - 1px);\n height: calc(1em - 1px);\n min-width: calc(1em - 1px);\n\n & img {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: ",";\n }\n\n & img + span {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n box-shadow: inset 0 0 0 1px var(--card-fg-color);\n opacity: 0.2;\n border-radius: ",";\n }\n\n & svg {\n display: block;\n font-size: calc(14 / 16 * 1em);\n margin: 1px 0;\n\n &[data-sanity-icon] {\n font-size: calc(18 / 16 * 1em);\n margin: calc(1px + (2 / 18 * -1em)) 0;\n }\n }\n"])),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[1])},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[1])}),pF=(0,aW.ZP)(lY.xv).attrs({forwardedAs:"span"})(e=>{let{theme:t}=e,n=t.sanity.fonts.text,i=n.sizes[1];return(0,aW.iv)(tc||(tc=pM(["\n font-size: calc("," / 16 * 1em);\n font-weight: ",";\n box-sizing: border-box;\n display: inline-block;\n vertical-align: top;\n line-height: ",";\n padding-left: 0.5em;\n padding-right: calc(0.5em - 2px);\n min-width: 0;\n\n & > span {\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n }\n "])),i.fontSize,n.weights.medium,i.lineHeight/i.fontSize)}
1),pD={...uI.inline,fit:"crop",aspect:1,dpr:(0,a5.x)()};var pZ=Object.freeze,pL=Object.defineProperty,pq=(e,t)=>pZ(pL(e,"raw",{value:pZ(t||e.slice())}));uI.default,(0,a5.x)(),(0,aW.ZP)(lY.xu)(tu||(tu=pq(["\n height: 100%;\n\n a {\n color: currentColor;\n text-decoration: none;\n }\n\n svg[data-sanity-icon] {\n margin: 0;\n }\n"]))),(0,aW.ZP)(lY.kC).attrs({align:"center"})(tp||(tp=pq(["\n height: ",";\n"])),(0,lY.hO)(uI.default.height)),(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1})(th||(th=pq(["\n max-width: ",";\n width: 80%;\n"])),(0,lY.hO)(160)),(0,aW.ZP)(lY.Qr).attrs({animated:!0,radius:1,size:1})(tf||(tf=pq(["\n max-width: ",";\n width: 60%;\n"])),(0,lY.hO)(120));let pN=["aria-hidden","disabled","href"];function pV(e){let{direction:t="horizontal",initialFocus:n,loop:i=!0,navigation:r=["arrows"],pause:l=!1,rootElement:a}=e,[o,s]=(0,lK.useState)(-1),[d,c]=(0,lK.useState)([]),u=d.length,p=u-1,h="horizontal"===t?"ArrowRight":"ArrowDown",f="horizontal"===t?"ArrowLeft":"ArrowUp",m=(0,lK.useCallback)(()=>{if(a){let e=[...a.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter(e=>!e.hasAttribute("disabled")&&"true"!==e.getAttribute("aria-hidden"));c(e)}},[a]),g=(0,lK.useCallback)(e=>{s(e)},[]),x=(0,lK.useCallback)(e=>{if(l)return;let t=()=>{e.preventDefault(),s(e=>{let t=(e+p)%u;return i||t!==p?t:e})},n=()=>{e.preventDefault(),s(e=>{let t=(e+1)%u;return i||0!==t?t:e})};"Tab"===e.key&&r.includes("tab")&&(e.shiftKey?t():n()),r.includes("arrows")&&(e.key===f&&t(),e.key===h&&n())},[l,f,r,h,p,u,i]);(0,lK.useEffect)(()=>{m()},[m,n,t]),(0,lK.useEffect)(()=>{let e=new MutationObserver(m);return a&&e.observe(a,{childList:!0,subtree:!0,attributeFilter:pN}),()=>{e.disconnect()}},[d,m,a]),(0,lK.useEffect)(()=>{var e;if(d.forEach((e,t)=>{t===o?(e.setAttribute("tabIndex","0"),e.setAttribute("aria-selected","true"),e.focus(),e.onfocus=()=>g(t),e.onblur=()=>g(-1)):(e.setAttribute("tabIndex","-1"),e.setAttribute("aria-selected","false"),e.onfocus=()=>g(t))}),-1===o&&d){let t="last"===n?p:0;null==(e=d[t])||e.setAttribute("tabIndex","0")}},[d,o,g,n,p]),(0,lK.useEffect)(()=>(null==a||a.addEventListener("keydown",x),()=>{null==a||a.removeEventListener("keydown",x)}),[x,a])}let pU=(0,aW.ZP)(lY.xu)({position:"relative"}),pB=aW.ZP.div({position:"absolute",top:-4,right:-4,width:6,height:6,borderRadius:3,boxShadow:"0 0 0 1px var(--card-bg-color)"}),pK=(0,lK.forwardRef)(function(e,t){let{disabled:n,fontSize:i,hotkey:r,icon:l,label:a,mode:o="bleed",space:s=3,text:d,tone:c,tooltip:u,...p}=e,h=(0,lY.Fg)(),f=c&&h.sanity.color.solid[c],m=(0,lK.useMemo)(()=>({backgroundColor:null==f?void 0:f.enabled.bg}),[f]),g="object"==typeof n?(0,lU.jsx)(lY.xv,{size:1,children:n.reason}):(0,lU.jsxs)(lY.kC,{align:"center",gap:2,style:{lineHeight:0},children:[(0,lU.jsx)(lY.xv,{size:1,children:a}),r&&(0,lU.jsx)(lY.p8,{fontSize:0,keys:r,style:{margin:-4}})]});return(0,lU.jsx)(lY.u,{padding:2,placement:"bottom",...u,content:g,disabled:!a,portal:!0,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.zx,{"data-ui":"StatusButton",...p,"aria-label":a,disabled:!!n,mode:o,ref:t,children:(0,lU.jsxs)(lY.kC,{gap:s,children:[(0,lU.jsxs)(pU,{children:[(0,lU.jsxs)(lY.xv,{size:i,children:[(0,lK.isValidElement)(l)&&l,(0,a6.isValidElementType)(l)&&(0,lK.createElement)(l)]}),c&&(0,lU.jsx)(pB,{style:m})]}),d&&(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.xv,{size:i,children:d})})]})})})})});var pH=Object.freeze,pW=Object.defineProperty,p$=(e,t)=>pH(pW(e,"raw",{value:pH(t||e.slice())}));let pX=(0,aW.ZP)(lY.xv)(e=>{let{$tone:t,theme:n}=e,i=n.sanity.color.muted[t];return(0,aW.iv)(tm||(tm=p$(["\n &:not([data-muted]) {\n --card-fg-color: ",";\n }\n\n &[data-dimmed] {\n opacity: 0.3;\n }\n "])),i?i.enabled.fg:void 0)}),pG=lK.forwardRef(function(e,t){let{tone:n,dimmed:i,muted:r,...l}=e;return(0,lU.jsx)(pX,{"data-ui":"TextWithTone","data-dimmed":i?"":void 0,"data-muted":r?"":void 0,$tone:n,muted:r,ref:t,...l})}),pY=(0,lK.forwardRef)(function(e,t){let{children:n,content:i,disabled:r,...l}=e;return(0,lU.jsx)(lY.u,{...l,content:i,disabled:r||!i,padding:2,ref:t,children:(0,lU.jsx)("div",{children:n})})}),pJ=(0,lK.forwardRef)((e,t)=>{let{push:n}=(0,lY.pm)();return(0,lK.useImperativeHandle)(t,()=>({push:n})),null});pJ.displayName="ImperativeToast";let pQ=(0,lK.createContext)({navbar:200,navbarPopover:5e5,navbarDialog:500001,pane:100,paneHeader:[110,15e3],paneFooter:[120,2e4],paneResizer:[130,25e3],popover:200,modal:200,movingItem:1e4,drawershade:1e6,drawer:1000001,fullscreen:12e5,toast:[100,11e3],portal:200,dropdown:200,navbarFixed:1010,fullscreenEdit:1050,popoverBackgroun
1d:1060,tooltip:200,modalBackground:2e3,spinner:3e3});function p0(){return(0,lK.useContext)(pQ)}function p1(e){let{children:t,zOffset:n}=e,i=p0(),r=i[n];return(0,lU.jsx)(lY.li,{zOffset:r,children:t})}let p2=(0,lK.createContext)(null);function p3(e){let{children:t}=e,n=(0,lK.useMemo)(()=>{let e=new Map,t={};return{get:n=>{let{namespace:i,dependencies:r}=n,l=r.map(e=>null===e?t:e),a=e.get(i);return null==a?void 0:a.get(l)},set:n=>{let{namespace:i,dependencies:r,value:l}=n,a=e.get(i)||function(){let e=new WeakMap,t=new WeakMap;function n(e){return Array.from(new Set(e)).map(e=>[function(e){let n=t.get(e);if(n)return n;let i=Array.from({length:10}).map(()=>Math.floor(255*Math.random()).toString(16).padStart(2,"0")).join("");return t.set(e,i),i}(e),e]).sort((e,t)=>{let[n]=e,[i]=t;return n.localeCompare(i,"en")}).map(e=>{let[,t]=e;return t})}return{get:function(t){return function e(t,n){if(!t.length)return;let[i,...r]=t,l=n.get(i);if(l)return r.length?e(r,l.next):l.value}(n(t),e)},set:function(t,i){!function e(t,n,i){if(!t.length)return;let[r,...l]=t,a=n.get(r)||{type:"multi-key-weak-map-node",value:void 0,next:new WeakMap};if(n.set(r,a),!l.length){a.value=i;return}e(l,a.next,i)}(n(t),e,i)}}}(),o=r.map(e=>null===e?t:e);e.set(i,a),a.set(o,l)}}},[]);return(0,lU.jsx)(p2.Provider,{value:n,children:t})}function p4(){let e=(0,lK.useContext)(p2);if(!e)throw Error("Could not find `cache` context");return e}var p5=Object.defineProperty,p6=(e,t,n)=>t in e?p5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p8=(e,t,n)=>(p6(e,"symbol"!=typeof t?t+"":t,n),n);class p9 extends Error{constructor(e){let{projectId:t}=e;super("CorsOriginError"),p8(this,"projectId"),this.projectId=t}}let p7=(()=>{let e="__tmp_supports_local_storage";try{if("undefined"==typeof localStorage)return!1;return localStorage.setItem(e,"---"),localStorage.removeItem(e),!0}catch(e){return!1}})(),he={};function ht(e,t){p7?localStorage[e]=t:he[e]=t}function hn(e){p7?localStorage.removeItem(e):delete he[e]}let hi=/sid=([^&]{20,})&?/,hr=function(){if("undefined"==typeof window||"object"!=typeof window.location)return null;let e=window.location.hash,[,t]=e.match(hi)||[];if(!t)return null;let n=e.replace(hi,""),i=new URL(window.location.href);return i.hash=n.length>1?n:"",history.replaceState(null,"",i),t}(),hl=()=>{let e=hr;return e&&(hr=null),e};var ha=Object.freeze,ho=Object.defineProperty,hs=(e,t)=>ha(ho(e,"raw",{value:ha(t||e.slice())}));let hd=aW.ZP.svg(e=>{let{theme:t}=e,{fg:n}=t.sanity.color.base;return(0,aW.iv)(tg||(tg=hs(["\n fill: ",";\n "])),n)}),hc={google:()=>(0,lU.jsxs)("svg",{width:"1em",height:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",children:[(0,lU.jsx)("path",{d:"M11 24a13 13 0 0 1 .66-4.08l-7.4-5.66a22.18 22.18 0 0 0 0 19.49l7.4-5.67A13 13 0 0 1 11 24z",fill:"#fbbc05"}),(0,lU.jsx)("path",{d:"M24 11a12.72 12.72 0 0 1 8.1 2.9l6.4-6.4a22 22 0 0 0-34.24 6.75l7.4 5.66A13 13 0 0 1 24 11z",fill:"#ea4335"}),(0,lU.jsx)("path",{d:"M24 37a13 13 0 0 1-12.34-8.92l-7.4 5.66A21.93 21.93 0 0 0 24 46a21 21 0 0 0 14.33-5.48l-7-5.44A13.59 13.59 0 0 1 24 37zm-12.35-8.93l-7.4 5.67 7.4-5.66z",fill:"#34a853"}),(0,lU.jsx)("path",{d:"M44.5 20H24v8.5h11.8a9.91 9.91 0 0 1-4.49 6.58l7 5.44C42.37 36.76 45 31.17 45 24a18.25 18.25 0 0 0-.5-4z",fill:"#4285f4"})]}),github:()=>(0,lU.jsx)(hd,{width:"1em",height:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 438.55 438.55",children:(0,lU.jsx)("path",{d:"M409.13 114.57a218.32 218.32 0 0 0-79.8-79.8Q278.94 5.36 219.27 5.36T109.21 34.77a218.29 218.29 0 0 0-79.8 79.8Q0 165 0 224.63q0 71.67 41.83 128.91t108.06 79.23q7.71 1.43 11.42-2a11.17 11.17 0 0 0 3.69-8.57q0-.86-.14-15.42t-.14-25.41l-6.57 1.14a83.77 83.77 0 0 1-15.85 1 120.73 120.73 0 0 1-19.84-2 44.34 44.34 0 0 1-19.11-8.51 36.23 36.23 0 0 1-12.56-17.6l-2.86-6.57a71.34 71.34 0 0 0-9-14.56q-6.14-8-12.42-10.85l-2-1.43a21 21 0 0 1-3.71-3.43 15.66 15.66 0 0 1-2.57-4q-.86-2 1.43-3.29C61.2 310.42 64 310 68 310l5.71.85q5.71 1.14 14.13 6.85a46.08 46.08 0 0 1 13.85 14.84q6.57 11.71 15.85 17.85t18.7 6.14a81.19 81.19 0 0 0 16.27-1.42 56.78 56.78 0 0 0 12.85-4.29q2.57-19.14 14-29.41a195.49 195.49 0 0 1-29.36-5.13 116.52 116.52 0 0 1-26.83-11.14 76.86 76.86 0 0 1-23-19.13q-9.14-11.42-15-30t-5.8-42.81q0-34.55 22.56-58.82-10.57-26 2-58.24 8.28-2.57 24.55 3.85t23.84 11q7.57 4.56 12.13 7.71a206.2 206.2 0 0 1 109.64 0l10.85-6.85a153.65 153.65 0 0 1 26.26-12.56q15.13-5.71 23.13-3.14 12.84 32.26 2.28 58.24 22.55 24.27 22.56 58.82 0 24.27-5.85 43t-15.12 30a79.82 79.82 0 0 1-23.13 19 116.74 116.74 0 0 1-26.84 11.14 195.29 195.29 0 0 1-29.23 5.07q14.8 12.84 14.81 40.58v60.2a11.37 11.37 0 0 0 3.57 8.56q3.57 3.42 11.28 2 66.24-22 108.07-79.23t41.83-128.91q-.03-59.62-29.43-110.05z"})}),custom:function(e){let{provider:t}=e;return t.logo?(0,lU.jsx)("img",{src:t.logo,alt:"Logo for ".concat(t.name)}):void 0}};async function hu(e){let{client:t,mode:n,providers:i=[]}=e;if("replace"===n&&Array.isArray(i))return i;let{providers:r}=await t.request({uri:"/auth/providers"});return"function"==typeof i?i(r):0===i.length?r:"replace"===n?i:r.filter(e=>i.some(t=>
1t.url!==e.url)).concat(i)}function hp(e){let{loginMethod:t="dual",projectId:n,url:i,basePath:r}=e,l=new URLSearchParams;return l.set("origin","".concat(window.location.origin).concat(r)),l.set("projectId",n),"token"===t?l.set("withSid","true"):l.set("type",t),"".concat(i,"?").concat(l)}let hh=e=>{if(!e)throw Error("Invalid project id");return"__studio_auth_token_".concat(e)},hf=e=>{try{var t;let n=(t=hh(e),p7?localStorage[t]:he[t]);if(n){let{token:e}=JSON.parse(n);if(e&&"string"==typeof e)return e}}catch(e){console.error(e)}return null},hm=e=>{try{hn(hh(e))}catch(e){console.error(e)}},hg=e=>{let{token:t,projectId:n}=e;try{ht(hh(n),JSON.stringify({token:t,time:new Date().toISOString()}))}catch(e){console.error(e)}},hx=async(e,t)=>{var n;try{let t=await e.request({uri:"/users/me",withCredentials:!0,tag:"users.get-current"});return"string"==typeof(null==t?void 0:t.id)?t:null}catch(r){if(401===r.statusCode)return hm(e.config().projectId||""),t(null),null;let i=await e.request({uri:"/ping",withCredentials:!1,tag:"cors-check"}).then(()=>!0,()=>!1);if(i)throw new p9({projectId:null==(n=e.config())?void 0:n.projectId});if(r.isNetworkError&&!r.message&&r.request&&r.request.url){let e=new URL(r.request.url).host;throw Error("Unknown network error attempting to reach ".concat(e))}throw r}},hv=oe()(function(e){let{clientFactory:t,projectId:n,dataset:i,apiHost:r,loginMethod:l="dual",...a}=e,{broadcast:o,messages:s}=function(e){let t="undefined"==typeof window?(0,lQ.of)():(0,l1.R)(window,"storage"),n="__studio_local_storage_messaging_".concat(e),i=new l2.x,r=(0,l3.T)(i,t.pipe((0,af.h)(e=>e.key===n),(0,ad.U)(e=>e.newValue),(0,af.h)(d9),(0,ad.U)(e=>JSON.parse(e)))).pipe((0,am.d)(1));return{messages:r,broadcast:function(e){try{ht(n,JSON.stringify(e)),hn(n),i.next(e)}catch(e){}}}}("dual_mode_auth_".concat(n)),d=null!=t?t:a9.eI,c=s.pipe((0,ag.O)("dual"
1===l?hf(n):null)),u={};r?u.apiHost=r:"undefined"!=typeof __SANITY_STAGING__&&!0===__SANITY_STAGING__&&(u.apiHost="https://api.sanity.work");let p=c.pipe((0,ad.U)(e=>d({projectId:n,dataset:i,apiVersion:"2021-06-07",useCdn:!1,...e&&{token:e},withCredentials:!0,requestTagPrefix:"sanity.studio",ignoreBrowserTokenWarning:!0,allowReconfigure:!1,...u})),(0,ap.w)(e=>(0,l4.P)(async()=>{let t=await hx(e,o);return{currentUser:t,client:e,authenticated:!!t}})),(0,ac.x)((e,t)=>aU()(e.currentUser,t.currentUser)),(0,am.d)(1));async function h(){let e;let t=hl();if(!t){o("cookie"===l?null:hf(n));return}let r=d({projectId:n,dataset:i,useCdn:!0,withCredentials:!0,apiVersion:"2021-06-07",requestTagPrefix:"sanity.studio",...u});if(("dual"===l||"cookie"===l)&&(e=await hx(r,o)),e||"cookie"===l){o(null);return}let a=await f(r,t);o(null!=a?a:null)}async function f(e,t){let{token:i}=await e.request({method:"GET",uri:"/auth/fetch",query:{sid:t},tag:"auth.fetch-token"});return hg({token:i,projectId:n}),i}async function m(){let e=d({projectId:n,dataset:i,useCdn:!0,withCredentials:!0,apiVersion:"2021-06-07",requestTagPrefix:"sanity.studio",...u});hm(n),await e.request({uri:"/auth/logout",method:"POST"}),o(null)}let g=function(e){let{getClient:t,loginMethod:n,redirectOnSingle:i,...r}=e,l=d8(t);return function(e){let{projectId:t,basePath:a}=e,[o,s]=(0,lK.useState)(null),[d,c]=(0,lK.useState)(null);if(d)throw d;let[u]=l();(0,lK.useEffect)(()=>{u&&hu({client:u,...r}).then(s).catch(c)},[u]);let p=i&&(null==o?void 0:o.length)===1&&(null==o?void 0:o[0])&&hp({loginMethod:n,projectId:t,url:o[0].url,basePath:a}),h=!o||p;return((0,lK.useEffect)(()=>{p&&(window.location.href=p)},[p]),h)?(0,lU.jsxs)(lY.kC,{align:"center",direction:"column",gap:4,justify:"center",padding:6,sizing:"border",children:[(0,lU.jsx)(lY.xv,{muted:!0,children:"Loadingâ¦"}),(0,lU.jsx)(lY.$j,{muted:!0})]}):(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(lY.X6,{align:"center",size:1,children:"Choose login provider"}),(0,lU.jsx)(lY.Kq,{space:2,children:o.map((e,i)=>(0,lU.jsx)(lY.zx,{as:"a",icon:hc[e.name],href:hp({loginMethod:n,projectId:t,url:e.url,basePath:a}),mode:"ghost",text:e.title},"".concat(e.url,"_").concat(i)))})]})}}({...a,getClient:()=>p.pipe((0,ad.U)(e=>e.client)),loginMethod:l});return{handleCallbackUrl:h,token:c,state:p,LoginComponent:g,logout:m}},function e(t){return"object"!=typeof t||null===t?"".concat(t):JSON.stringify(Object.fromEntries(Object.entries(t).sort((e,t)=>{let[n]=e,[i]=t;return n.localeCompare(i,"en")}).map(t=>{let[n,i]=t;return[n,e(i)]})))});function hb(e){return"google"===e?"Google":"github"===e?"GitHub":"sanity"===e?"Sanity":(null==e?void 0:e.startsWith("saml-"))?"SAML/SSO":void 0}let hy="undefined"==typeof window?(0,lQ.of)({}):(0,l1.R)(window,"online"),hj="undefined"==typeof window?(0,lQ.of)({}):(0,l1.R)(window,"offline"),hw=e=>100*Math.pow(2,e),hk={type:"connecting"},hC=(0,ot.E)(),h_=hC[0];hC[1];let hS=e=>{let{error:t,isOffline:n,attemptNo:i,retryAt:r}=e;return{type:"error",error:t,attemptNo:i,isOffline:n,retryAt:r}},hT=(0,aW.vJ)(e=>{let{theme:t}=e,{color:n,fonts:i}=t.sanity;return{html:{backgroundColor:n.base.bg},"#sanity":{fontFamily:i.text.family}}});function hE(e){return e}function hP(e){let t=["projectId"in e&&"`projectId` not allowed in plugin configuration","dataset"in e&&"`dataset` not allowed in plugin configuration"].filter(oi());if(t.length)throw Error("Invalid plugin configuration:\n".concat(t.map(e=>" ".concat(e)).join("\n")))}function hA(e){return"function"==typeof e?t=>{let n=e(t);return hP(n),n}:(hP(e),()=>e)}let hO=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.unstable_fieldActions;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `document.unstable_fieldActions` to be an array or a function, but received ".concat(typeof r))},hz=[];var hM=Object.defineProperty,hI=(e,t,n)=>t in e?hM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hR=(e,t,n)=>(hI(e,"symbol"!=typeof t?t+"":t,n),n);let hF=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};hR(this,"message"),hR(this,"paths"),hR(this,"children"),hR(this,"operation"),this.message=e,this.paths=t.paths||[],this.children=t.children,this.operation=t.operation}cloneWithMessage(t){return new e(t,{paths:this.paths,children:this.children,operation:this.operation})}};function hD(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];
1return e.reduce((e,t,n)=>{let i=typeof t;if("number"===i)return"".concat(e,"[").concat(t,"]");if("string"===i)return"".concat(e).concat(0===n?"":".").concat(t);if((0,lV.fU)(t))return"".concat(e,'[_key=="').concat(t._key,'"]');throw Error('Unsupported path segment "'.concat(t,'"'))},"")}function hZ(e){return null!==e||void 0!==e}function hL(e,t,n){var i;if(!n)throw Error("missing context");if(!0===e)return[];if(Array.isArray(e))return e.flatMap(e=>hL(e,t,n)).filter(hZ);if("string"==typeof e)return hL(new hF(e),t,n);if(!(e instanceof hF)){if("string"!=typeof(null==e?void 0:e.message))throw Error("".concat(hD(n.path),": Validator must return 'true' if valid or an error message as a string on errors"));return hL(new hF(e.message,e),t,n)}return(null==(i=e.paths)?void 0:i.length)?[].concat(e.paths.map(i=>({path:(n.path||[]).concat(i),level:t||"error",item:e}))):[{level:t||"error",item:e,path:n.path||[]}]}let hq={}.toString,hN=[Object,Function,Array,String,Boolean,Number,Date,RegExp,Error];function hV(e){let t=hq.call(e).slice(8,-1);if(null==e)return t.toLowerCase();let n=e.constructor;return n&&!function(e){for(let t=0;t<hN.length;t++)if(hN[t]===e)return!0;return!1}(n)?n.name:t}function hU(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!hU(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!=Array.isArray(t))return!1;if(e&&t&&"object"==typeof e&&"object"==typeof t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Date!=t instanceof Date)return!1;if(e instanceof RegExp&&t instanceof RegExp)return e.toString()==t.toString();if(e instanceof RegExp!=t instanceof RegExp)return!1;for(let e=0;e<n.length;e++)if("_key"!==n[e]&&!Object.prototype.hasOwnProperty.call(t,n[e]))return!1;for(let i=0;i<n.length;i++){let r=n[i];if("_key"!==r&&!hU(e[r],t[r]))return!1}return!0}return!1}let hB=e=>{var t;let n;return n=e.message?e.message:1===e.results.length?null==(t=e.results[0])?void 0:t.item.message:"[".concat(e.results.map(e=>e.item.message).join(" - ".concat(e.operation," - ")),"]"),new hF(n,{children:e.results.length>1?e.results:void 0,operation:e.operation})},hK={type:(e,t,n)=>{let i=hV(t);return i===e||"undefined"===i||n||'Expected type "'.concat(e,'", got "').concat(i,'"')},presence:(e,t,n)=>void 0!==t||"required"!==e||n||"Value is required",all:async(e,t,n,i)=>{let r=await Promise.all(e.map(e=>e.validate(t,i))),l=r.flat();return!l.length||hB({message:n,results:l,operation:"AND"})},either:async(e,t,n,i)=>{let r=await Promise.all(e.map(e=>e.validate(t,i))),l=r.flat();return l.length<e.length||hB({message:n,results:l,operation:"OR"})},valid:(e,t,n)=>{let i=typeof t;if("undefined"===i)return!0;let r=("number"===i||"string"===i)&&"".concat(t),l=r&&r.length>30?"".concat(r.slice(0,30),"â¦"):r;return!!e.some(e=>hU(e,t))||n||(r?'Value "'.concat(l,'" did not match any allowed values'):"Value did not match any allowed values")},custom:async(e,t,n,i)=>{let r;let l=setTimeout(()=>{console.warn("Custom validator at ".concat(hD(i.path)," has taken more than ").concat(5e3,"ms to respond"))},5e3);try{r=await e(t,i)}finally{clearTimeout(l)}return"string"==typeof r&&n||r}},hH={...hK,presence:(e,t,n)=>"required"!==e||"boolean"==typeof t||n||"Required"},hW=/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,h$={...hK,integer:(e,t,n)=>!!Number.isInteger(t)||n||"Must be an integer",precision:(e,t,n)=>{if(void 0===t)return!0;let i=t.toString().match(hW),r=Math.max((i[1]?i[1].length:0)-(i[2]?parseInt(i[2],10):0),0);return!(r>e)||n||"Max precision is ".concat(e)},min:(e,t,n)=>t>=e||n||"Must be greater than or equal ".concat(e),max:(e,t,n)=>t<=e||n||"Must be less than or equal ".concat(e),greaterThan:(e,t,n)=>t>e||n||"Must be greater than ".concat(e),lessThan:(e,t,n)=>t<e||n||"Must be less than ".concat(e)},hX="http://sanity",hG=e=>/^\.*\//.test(e),hY=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,hJ={...hK,min:(e,t,n)=>!t||t.length>=e||n||"Must be at least ".concat(e," characters long"),max:(e,t,n)=>!t||t.length<=e||n||"Must be at most ".concat(e," characters long"),length:(e,t,n)=>(t||"").length===e||n||"Must be exactly ".concat(e," characters long"),uri:(e,t,n)=>{let i;let r=t||"",{options:l}=e,{allowCredentials:a,relativeOnly:o}=l,s=l.allowRelative||o;try{i=s?new URL(r,hX):new URL(r)}catch(e){return n||"Not a valid URL"}if(o&&i.origin!==hX)return n||"Only relative URLs are allowed";if(!s&&i.origin===hX&&hG(r))return n||"Relative URLs are not allowed";if(!a&&(i.username||i.password))return n||"Username/password not allowed";let d=i.protocol.replace(/:$/,""),c=l.scheme.some(e=>e.test(d));return!!c||n||"Does not match allowed protocols/schemes"}
1,stringCasing:(e,t,n)=>{let i=t||"";return"uppercase"===e&&i!==i.toLocaleUpperCase()?n||"Must be all uppercase letters":"lowercase"!==e||i===i.toLocaleLowerCase()||n||"Must be all lowercase letters"},presence:(e,t,n)=>"required"!==e||!!t||n||"Required",regex:(e,t,n)=>{let{pattern:i,name:r,invert:l}=e,a=r||'"'.concat(i.toString(),'"'),o=t||"";i.lastIndex=0;let s=i.test(o);return(!!l||!!s)&&(!l||!s)||n||(l?"Should not match ".concat(a,"-pattern"):"Does not match ".concat(a,"-pattern"))},email:(e,t,n)=>{let i="".concat(t||"").trim();return!!(!i||hY.test(i))||n||"Must be a valid email address"}},hQ={...hK,min:(e,t,n)=>!t||t.length>=e||n||"Must have at least ".concat(e," items"),max:(e,t,n)=>!t||t.length<=e||n||"Must have at most ".concat(e," items"),length:(e,t,n)=>!t||t.length===e||n||"Must have exactly ".concat(e," items"),presence:(e,t,n)=>"required"!==e||!!t||n||"Required",valid:(e,t,n)=>{if(void 0===t)return!0;let i=[];for(let n=0;n<t.length;n++){let r=t[n];if(e.some(e=>hU(e,r)))continue;let l=r&&r._key?{_key:r._key}:n;i.push([l])}return 0===i.length||new hF(n||"Value did not match any allowed values",{paths:i})},unique:(e,t,n)=>{let i=[];if(!t)return!0;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=t[e],l=t[n];hU(r,l)&&(-1===i.indexOf(e)&&i.push(e),-1===i.indexOf(n)&&i.push(n))}let r=i.map(e=>{let n=t[e],i=n&&n._key?{_key:n._key}:e;return[i]});return!(i.length>0)||new hF(n||"Can't be a duplicate",{paths:r})}},h0=["_key","_type","_weak"],h1={...hK,presence:(e,t,n)=>{if("required"!==e)return!0;let i=t&&Object.keys(t).filter(e=>!h0.includes(e));return void 0!==t&&(!i||0!==i.length)||n||"Required"},reference:async(e,t,n,i)=>{if(!t)return!0;if(!(0,lV.Yk)(t))return n||"Must be a reference to a document";let{type:r,getDocumentExists:l}=i;if(!r)throw Error("`type` was not provided in validation context");if("weak"in r&&r.weak)return!0;if(!l)throw Error("`getDocumentExists` was not provided in validation context");let a=await l({id:t._ref});return!!a||"This reference must be published"},assetRequired:(e,t,n)=>{if(!t||!t.asset||!t.asset._ref){let t=e.assetType||"Asset";return n||"".concat(t," required")}return!0}};function h2(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let h3=/^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/,h4=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,i="yyyy-MM-dd";return n&&n.dateFormat&&(i=n.dateFormat),"date"===e||(n&&n.timeFormat?i+=" ".concat(n.timeFormat):i+=" HH:mm"),(0,oh.Z)(new Date(t),i)};function h5(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;if("now"===e)return new Date;let n=new Date(e),i=isNaN(n.getTime());if(i&&t)throw Error('Unable to parse "'.concat(e,'" to a date'));return i?null:n}let h6={...hK,type:(e,t,n)=>{let i="".concat(t);return!!(!i||h3.test(t))||n||"Must be a valid ISO-8601 formatted date string"},min:(e,t,n,i)=>{let r=h5(t);if(!r||!t||r>=h5(e,!0))return!0;if(!i.type)throw Error("`type` was not provided in validation context.");let l=h2(i.type.options)?i.type.options:{},a=h4(i.type.name,e,l);return n||"Must be at or after ".concat(a)},max:(e,t,n,i)=>{let r=h5(t);if(!r||!t||r<=h5(e,!0))return!0;if(!i.type)throw Error("`type` was not provided in validation context.");let l=h2(i.type.options)?i.type.options:{},a=h4(i.type.name,e,l);return n||"Must be at or before ".concat(a)}};var h8=Object.defineProperty,h9=(e,t,n)=>t in e?h8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h7=(e,t,n)=>(h9(e,"symbol"!=typeof t?t+"":t,n),n);let fe={Boolean:hH,Number:h$,String:hJ,Array:hQ,Object:h1,Date:h6},ft=e=>e&&e.type?ft(e.type):e,fn=e=>"object"==typeof e&&!!e&&e.type===fa.FIELD_REF,fi=[],fr=Symbol("FIELD_REF"),fl=["Array","Boolean","Date","Number","Object","String"],fa=(tx=class{constructor(e){h7(this,"_type"),h7(this,"_level"),h7(this,"_required"),h7(this,"_typeDef"),h7(this,"_message"),h7(this,"_rules",[]),h7(this,"_fieldRules"),h7(this,"valueOfField",tx.valueOfField.bind(tx)),this._typeDef=e,this.reset()}_mergeRequired(e){return"required"===this._required||"required"===e._required?"required":"optional"===this._required||"optional"===e._required?"optional":void 0}error(e){let t=this.clone();return t._level="error",t._message=e||void 0,t}warning(e){let t=this.clone();return t._level="warning",t._message=e||void 0,t}info(e){let t=this.clone();return t._level="info",t._message=e||void 0,t}reset(){return this._type=this._type||void 0,this._rules=(this._rules||[]).filter(e=>"type"===e.flag),this._message=void 0,this._required=void 0,this._level="error",this._fieldRules=void 0,this}isRequired(){return"required"===this._required}clone(){let e=new tx;return e._type=this._type,e._message=this._message,e._required=this._required,e._rules=oc()(this._rules),e._level=this._level,e._fieldRules=this._fieldRules,e._typeDef=this._typeDef,e}cloneWithRules(e){let t=this.clone(),n=new Set;
1return e.forEach(e=>{"type"===e.flag&&(t._type=e.constraint),n.add(e.flag)}),t._rules=t._rules.filter(e=>{let t=["type","uri","email"].includes(e.flag),i=n.has(e.flag);return!(t&&i)}).concat(e),t}merge(e){if(this._type&&e._type&&this._type!==e._type)throw Error("merge() failed: conflicting types");let t=this.cloneWithRules(e._rules);return t._type=this._type||e._type,t._message=this._message||e._message,t._required=this._mergeRequired(e),t._level="error"===this._level?e._level:this._level,t}type(e){let t="".concat(e.slice(0,1).toUpperCase()).concat(e.slice(1));if(!fl.includes(t))throw Error('Unknown type "'.concat(e,'"'));let n=this.cloneWithRules([{flag:"type",constraint:t}]);return n._type=t,n}all(e){return this.cloneWithRules([{flag:"all",constraint:e}])}either(e){return this.cloneWithRules([{flag:"either",constraint:e}])}optional(){let e=this.cloneWithRules([{flag:"presence",constraint:"optional"}]);return e._required="optional",e}required(){let e=this.cloneWithRules([{flag:"presence",constraint:"required"}]);return e._required="required",e}custom(e){return this.cloneWithRules([{flag:"custom",constraint:e}])}min(e){return this.cloneWithRules([{flag:"min",constraint:e}])}max(e){return this.cloneWithRules([{flag:"max",constraint:e}])}length(e){return this.cloneWithRules([{flag:"length",constraint:e}])}valid(e){let t=Array.isArray(e)?e:[e];return this.cloneWithRules([{flag:"valid",constraint:t}])}integer(){return this.cloneWithRules([{flag:"integer"}])}precision(e){return this.cloneWithRules([{flag:"precision",constraint:e}])}positive(){return this.cloneWithRules([{flag:"min",constraint:0}])}negative(){return this.cloneWithRules([{flag:"lessThan",constraint:0}])}greaterThan(e){return this.cloneWithRules([{flag:"greaterThan",constraint:e}])}lessThan(e){return this.cloneWithRules([{flag:"lessThan",constraint:e}])}uppercase(){return this.cloneWithRules([{flag:"stringCasing",constraint:"uppercase"}])}lowercase(){return this.cloneWithRules([{flag:"stringCasing",constraint:"lowercase"}])}regex(e,t,n){var i,r;let l="string"==typeof t?t:null!=(i=null==t?void 0:t.name)?i:null==n?void 0:n.name,a="string"!=typeof t&&(null!=(r=null==t?void 0:t.invert)?r:null==n?void 0:n.invert);return this.cloneWithRules([{flag:"regex",constraint:{pattern:e,name:l,invert:a||!1}}])}email(){return this.cloneWithRules([{flag:"email"}])}uri(e){let t=(null==e?void 0:e.scheme)||["http","https"],n=Array.isArray(t)?t:[t];if(!n.length)throw Error("scheme must have at least 1 scheme specified");let i={options:{scheme:n.map(e=>{if(!(e instanceof RegExp)&&"string"!=typeof e)throw Error("scheme must be a RegExp or a String");return"string"==typeof e?new RegExp("^".concat(e.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g,"\\$&"),"$")):e}),allowRelative:(null==e?void 0:e.allowRelative)||!1,relativeOnly:(null==e?void 0:e.relativeOnly)||!1,allowCredentials:(null==e?void 0:e.allowCredentials)||!1}};return this.cloneWithRules([{flag:"uri",constraint:i}])}unique(){return this.cloneWithRules([{flag:"unique"}])}reference(){return this.cloneWithRules([{flag:"reference"}])}fields(e){if("Object"!==this._type)throw Error("fields() can only be called on an object type");let t=this.cloneWithRules([]);return t._fieldRules=e,t}assetRequired(){let e;let t=ft(this._typeDef);return e=t&&["image","file"].includes(t.name)?"image"===t.name?"Image":"File":"Asset",this.cloneWithRules([{flag:"assetRequired",constraint:{assetType:e}}])}async validate(e,t){if(!t)throw Error("missing context");let n=null==e;if(n&&"optional"===this._required)return fi;let i=void 0===this._required&&n?this._rules.filter(e=>"custom"===e.flag):this._rules,r=this._type&&fe[this._type]||hK,l=await Promise.all(i.map(async n=>{let i;if(void 0===n.flag)throw Error('Invalid rule, did not contain "flag"-property');let l=r[n.flag];if(!l){let e=this._type?'type "'.concat(this._type,'"'):"rule without declared type";throw Error('Validator for flag "'.concat(n.flag,'" not found for ').concat(e))}let a="constraint"in n?n.constraint:null;fn(a)&&(a=op()(t.parent,a.path));try{i=await l(a,e,this._message,t)}catch(n){let e=new hF("".concat(hD(t.path),": Exception occurred while validating value: ").concat(n.message));return hL(e,"error",t)}return hL(i,this._level,t)}));return l.flat()}},h7(tx,"FIELD_REF",fr),h7(tx,"array",e=>new tx(e).type("Array")),h7(tx,"object",e=>new tx(e).type("Object")),h7(tx,"string",e=>new tx(e).type("String")),h7(tx,"number",e=>new tx(e).type("Number")),h7(tx,"boolean",e=>new tx(e).type("Boolean")),h7(tx,"dateTime",e=>new tx(e).type("Date")),h7(tx,"valueOfField",e=>({type:fr,path:e})),tx),fo="undefined"==typeof window?void 0:window,fs=(null==fo?void 0:fo.requestIdleCallback)||function(e,t){let n=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,Date.now()-n)})},0)},fd=(null==fo?void 0:fo.cancelIdleCallback)||function(e){return window.clearTimeout(e)},fc=oe()(function(e){console.warn(["Slug field at path ".concat(e," is within an array and cannot be automatically checked for uniqueness"),'If you need to check for uniqueness, provide your own "isUnique" method',"To disable this message, set `disableArrayWarning: true` on the slug `options` field"].join("\n"))});
1function fu(e){return e.reduce((e,t,n)=>{let i="number"==typeof t,r=(0,lV.fU)(t),l=i||r?"[]":"".concat(0===n?"":".").concat(t);return"".concat(e).concat(l)},"")}let fp=(e,t)=>{let{getClient:n,document:i,path:r,type:l}=t,a=null==l?void 0:l.options;if(!i)throw Error("`document` was not provided in validation context.");if(!r)throw Error("`path` was not provided in validation context.");let o=(null==a?void 0:a.disableArrayWarning)||!1,{published:s,draft:d}=function(e){let t=0===e.indexOf("drafts.");return{published:t?e.slice(7):e,draft:t?e:"drafts.".concat(e)}}(i._id),c=i._type,u=fu(r.concat("current"));!o&&u.includes("[]")&&fc(fu(r));let p=["_type == $docType","!(_id in [$draft, $published])","".concat(u," == $slug")].join(" && ");return n({apiVersion:"2022-09-09"}).fetch("!defined(*[".concat(p,"][0]._id)"),{docType:c,draft:d,published:s,slug:e},{tag:"validation.slug-is-unique"})},fh=async(e,t)=>{var n;if(!e)return!0;if("object"!=typeof e)return"Slug must be an object";let i=e.current;if(!i)return"Slug must have a value";let r=null==(n=null==t?void 0:t.type)?void 0:n.options,l=(null==r?void 0:r.isUnique)||fp,a={...t,parent:t.parent,type:t.type,defaultIsUnique:fp},o=await l(i,a);return!!o||"Slug is already in use"},ff={array:!0,boolean:!0,date:!0,number:!0,object:!0,string:!0},fm=e=>e in ff;function fg(e,t){let n=e;fm(t.jsonType)&&(n=n.type(t.jsonType));let i=(null==t?void 0:t.options)&&"object"==typeof t.options&&"list"in t.options&&t.options.list;return(Array.isArray(i)&&(n=n.valid(i.map(e=>"object"===t.jsonType&&function e(t){return!!t&&("fields"in t||!t.type?!!("fields"in t&&Array.isArray(t.fields))&&t.fields.some(e=>"value"===e.name):e(t.type))}(t)?e:void 0===e.value?e:e.value))),"datetime"===t.name||"date"===t.name)?n.type("Date"):"url"===t.name?n.uri():"slug"===t.name?n.custom(fh):"reference"===t.name?n.reference():"email"===t.name?n.email():n}function fx(e){if(!e)return[];let t=e.validation;if(Array.isArray(t))return t.flatMap(t=>fx({...e,validation:t}));if(t instanceof fa)return[t];let n=Object.values((function e(t,n){if(!t||n.has(t))return[];n.add(t);let i=t.type?e(t.type,n):[];return[...i,t]})(e,new Set).reduce((e,t)=>(e[t.name]=t,e),{})).reduce(fg,new fa(e));return t?fx({...e,validation:t(n)}):[n]}let fv=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),fb=e=>null!=e,fy=[],fj=e=>"error"===e.severity,fw=[{name:"sanity.assetSourceData",title:"Asset Source Data",type:"object",fields:[{name:"name",title:"Source name",description:"A canonical name for the source this asset is originating from",type:"string"},{name:"id",title:"Asset Source ID",description:"The unique ID for the asset within the originating source so you can programatically find back to it",type:"string"},{name:"url",title:"Asset information URL",description:"A URL to find more information about this asset in the originating source",type:"string"}]},{title:"Slug",name:"slug",type:"object",fields:[{name:"current",title:"Current slug",type:"string"},{name:"source",title:"Source field",type:"string",hidden:!0}]},{title:"Geographical Point",name:"geopoint",type:"object",fields:[{name:"lat",type:"number",title:"Latitude"},{name:"lng",type:"number",title:"Longitude"},{name:"alt",type:"number",title:"Altitude"}]},{name:"sanity.imageAsset",title:"Image",type:"document",fieldsets:[{name:"system",title:"System fields",description:"These fields are managed by the system and not editable"}],fields:[{name:"originalFilename",type:"string",title:"Original file name",readOnly:!0},{name:"label",type:"string",title:"Label"},{name:"title",type:"string",title:"Title"},{name:"description",type:"string",title:"Description"},{name:"altText",type:"string",title:"Alternative text"},{name:"sha1hash",type:"string",title:"SHA1 hash",readOnly:!0,fieldset:"system"},{name:"extension",type:"string",readOnly:!0,title:"File extension",fieldset:"system"},{name:"mimeType",type:"string",readOnly:!0,title:"Mime type",fieldset:"system"},{name:"size",type:"number",title:"File size in bytes",readOnly:!0,fieldset:"system"},{name:"assetId",type:"string",title:"Asset ID",readOnly:!0,fieldset:"system"},{name:"uploadId",type:"string",readOnly:!0,hidden:!0,fieldset:"system"},{name:"path",type:"string",title:"Path",readOnly:!0,fieldset:"system"},{name:"url",type:"string",title:"Url",readOnly:!0,fieldset:"system"},{name:"metadata",type:"sanity.imageMetadata",title:"Metadata"},{name:"source",type:"sanity.assetSourceData",title:"Source",readOnly:!0,fieldset:"system"}],preview:{select:{id:"_id",title:"originalFilename",mimeType:"mimeType",size:"size"},prepare:e=>({title:e.title||"string"==typeof e.path&&e.path.split("/").slice(-1)[0],media:{asset:{_ref:e.id}},subtitle:"".concat(e.mimeType," (").concat((Number(e.size)/1024/1024).toFixed(2)," MB)")})},orderings:[{title:"File size",name:"fileSizeDesc",by:[{field:"size",direction:"desc"}]}]},{name:"sanity.fileAsset",title:"File",type:"document",fieldsets:[{name:"system",title:"System fields",description:"These fields are managed by the system and not editable"}],fields:[{name:"originalFilename",type:"string",title:"Original file name",readOnly:!0},{name:"label",type:"string",title:"Label"},{name:"title",type:"string",title:"Title"},{name:"description",type:"string",title:"Description"},{name:"altText",type:"string",title:"Alternative text"},{name:"sha1hash",type:"string",title:"SHA1 hash",readOnly:!0,fieldset:"system"},{name:"extension",type:"string",title:"File extension",readOnly:!0,fieldset:"system"},{name:"mimeType",type:"string",title:"Mime type",readOnly:!0,fieldset:"system"},{name:"size",type:"number",title:"File size in bytes",readOnly:!0,fieldset:"system"},{name:"assetId",type:"string",title:"Asset ID",readOnly:!0,fieldset:"system"},{name:"path",type:"string",title:"Path",readOnly:!0,fieldset:"system"},{name:"url",type:"string",title:"Url",readOnly:!0,fieldset:"system"},{name:"source",type:"sanity.assetSourceData",title:"Source",readOnly:!0,fieldset:"system"}],preview:{select:{title:"originalFilename",path:"path",mimeType:"mimeType",size:"size"},prepare:e=>({title:e.title||e.path.split("/").slice(-1)[0],subtitle:"".concat(e.mimeType," (").concat((e.size/1024/1024).toFixed(2)," MB)")})},orderings:[{title:"File size",name:"fileSizeDesc",by:[{field:"size",direction:"desc"}]}]},{name:"sanity.imageCrop",title:"Image crop",type:"object",fields:[{name:"top",type:"number"},{name:"bottom",type:"number"},{name:"left",type:"number"},{name:"right",type:"number"}]},{name:"sanity.imageHotspot",title:"Image hotspot",type:"object",fields:[{name:"x",type:"number"},{name:"y",type:"number"},{name:"height",type:"number"},{name:"width",type:"number"}]},{name:"sanity.imageMetadata",title:"Image metadata",type:"object",fieldsets:[{name:"extra",title:"Extra metadataâ¦",options:{collapsable:!0}}],fields:[{name:"location",type:"geopoint"},{name:"dimensions",title:"Dimensions",type:"sanity.imageDimensions",fieldset:"extra"},{name:"palette",type:"sanity.imagePalette",title:"Palette",fieldset:"extra"},{name:"lqip",title:"LQIP (Low-Quality Image Placeholder)",type:"string",readOnly:!0}
1,{name:"blurHash",title:"BlurHash",type:"string",readOnly:!0},{name:"hasAlpha",title:"Has alpha channel",type:"boolean",readOnly:!0},{name:"isOpaque",title:"Is opaque",type:"boolean",readOnly:!0}]},{name:"sanity.imageDimensions",type:"object",title:"Image dimensions",fields:[{name:"height",type:"number",title:"Height",readOnly:!0},{name:"width",type:"number",title:"Width",readOnly:!0},{name:"aspectRatio",type:"number",title:"Aspect ratio",readOnly:!0}]},{name:"sanity.imagePalette",title:"Image palette",type:"object",fields:[{name:"darkMuted",type:"sanity.imagePaletteSwatch",title:"Dark Muted"},{name:"lightVibrant",type:"sanity.imagePaletteSwatch",title:"Light Vibrant"},{name:"darkVibrant",type:"sanity.imagePaletteSwatch",title:"Dark Vibrant"},{name:"vibrant",type:"sanity.imagePaletteSwatch",title:"Vibrant"},{name:"dominant",type:"sanity.imagePaletteSwatch",title:"Dominant"},{name:"lightMuted",type:"sanity.imagePaletteSwatch",title:"Light Muted"},{name:"muted",type:"sanity.imagePaletteSwatch",title:"Muted"}]},{name:"sanity.imagePaletteSwatch",title:"Image palette swatch",type:"object",fields:[{name:"background",type:"string",title:"Background",readOnly:!0},{name:"foreground",type:"string",title:"Foreground",readOnly:!0},{name:"population",type:"number",title:"Population",readOnly:!0},{name:"title",type:"string",title:"String",readOnly:!0}]}];function fk(e){return"string"==typeof e.title?e.title:e.type?fk(e.type):e.name||e.jsonType}let fC={apiVersion:"2022-09-09"};var f_=Object.freeze,fS=Object.defineProperty;let fT=(0,aW.ZP)(lY.mh)(tv||(tv=f_(fS(s=["\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n"],"raw",{value:f_(s.slice())}))));function fE(){return(0,lU.jsx)(fT,{children:(0,lU.jsx)(lY.kC,{height:"fill",align:"center",justify:"center",children:(0,lU.jsx)(lY.$j,{})})})}function fP(e){let{text:t}=e;return(0,lU.jsxs)(lY.kC,{direction:"row",justify:"center",align:"center",children:[(0,lU.jsx)(lY.$j,{}),(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(lY.xv,{children:t})})]})}let fA={referringDocuments:[],isLoading:!0},fO=()=>(0,lK.createElement)(lK.Fragment);function fz(e){let{options:t}=Iw().__internal,{defaultComponent:n,pick:i}=e;return(0,lK.useMemo)(()=>{let e=[...RY(t,[])];e.reverse();let r=e.map(e=>{let{config:t}=e;return i(t)}),l=r.filter(Boolean);return e=>{let t=e=>(0,lK.createElement)(n,e);for(let e of l){let n=t;t=t=>(0,lK.createElement)(e,{...t,renderDefault:n})}return t({...e,renderDefault:fO})}},[n,t,i])}function fM(e,t){return t.name===e||!!(t.type&&fM(e,t.type))}let fI={default:uX,media:function(e){let{media:t,mediaDimensions:n=pv,children:i,isPlaceholder:r,progress:l=-1,subtitle:a,title:o,withBorder:s=!0,withRadius:d=!0}=e,c=n.aspect||1,u=(0,lK.useMemo)(()=>({paddingBottom:"".concat(100/c,"%")}),[c]),p=(0,lK.useMemo)(()=>o&&a?(0,lU.jsxs)(px,{children:[o&&(0,lU.jsx)(lY.xv,{align:"center",size:1,weight:"semibold",children:uN(o,"media")}),a&&(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:uN(a,"media")})]}):null,[a,o]);return(0,lU.jsxs)(ph,{"data-testid":"media-preview",overflow:"hidden",flex:1,children:[(0,lU.jsx)("div",{style:u}),(0,lU.jsx)(lY.u,{content:p,disabled:!p,placement:"top",portal:!0,children:(0,lU.jsxs)(pf,{children:[r?(0,lU.jsx)(pm,{}):(0,lU.jsx)(uq,{border:s,dimensions:n,layout:"media",media:t,radius:d?1:0,responsive:!0}),"number"==typeof l&&l>-1&&(0,lU.jsx)(pg,{children:(0,lU.jsx)(pi,{value:l})})]})}),i]})},detail:function(e){let{title:t,subtitle:n,description:i,mediaDimensions:r=u6,media:l,status:a,children:o,isPlaceholder:s}=e,d=a&&(0,lU.jsx)(u0,{marginLeft:3,paddingRight:1,children:uN(a,"detail")});return s?(0,lU.jsxs)(uQ,{"data-testid":"detail-preview",children:[!1!==l&&(0,lU.jsx)(u1,{"data-testid":"detail-preview__media"}),(0,lU.jsxs)(lY.xu,{flex:1,paddingLeft:!1===l?1:2,children:[(0,lU.jsxs)(lY.kC,{align:"center","data-testid":"detail-preview__header",children:[(0,lU.jsxs)(lY.Kq,{flex:1,space:2,children:[(0,lU.jsx)(u2,{}),(0,lU.jsx)(u3,{})]}),d]}),i&&(0,lU.jsx)(lY.xu,{marginTop:3,children:(0,lU.jsx)(u4,{})})]})]}):(0,lU.jsxs)(uQ,{"data-testid":"detail-preview",children:[!1!==l&&(0,lU.jsx)(uq,{dimensions:r,layout:"detail",media:l}),(0,lU.jsxs)(lY.xu,{flex:1,paddingLeft:!1===l?1:2,children:[(0,lU.jsxs)(lY.kC,{align:"center","data-testid":"detail-preview__header",children:[(0,lU.jsxs)(lY.Kq,{flex:1,space:2,children:[(0,lU.jsxs)(lY.xv,{textOverflow:"ellipsis",style:{color:"inherit"},children:[t&&uN(t,"detail"),!t&&(0,lU.jsx)(lU.Fragment,{children:"Untitled"})]}),n&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:uN(n,"detail")})]}),d]}),i&&(0,lU.jsx)(lY.xu,{marginTop:3,children:(0,lU.jsx)(u5,{muted:!0,size:1,children:uN(i,"detail")})})]}),o]})},inline:function(e){let{title:t,fallbackTitle:n="Untitled",media:i,mediaDimensions:r=pD}=e;return(0,lU.jsxs)(pI,{"data-testid":"inline-preview",children:[i&&(0,lU.jsxs)(pR,{"data-testid":"inline-preview-media",children:[(0,a6.isValidElementType)(i)?(0,lK.createElement)(i,{layout:"inline",dimensions:r}):"string"==typeof i?(0,lU.jsx)("div",{children:i}):i,(0,lU.jsx)("span",{})]}),(0,lU.jsx)(pF,{"data-testid":"inline-preview-title",size:1,children:uN(t,"inline",n)})]})},block:function(e){let{actions:t,title:n,subtitle:i,description:r,mediaDimensions:l
1=pP,media:a,status:o,children:s}=e;return(0,lU.jsxs)(lY.Kq,{"data-testid":"block-preview",space:1,children:[(0,lU.jsxs)(pA,{"data-testid":"block-preview__header",children:[a&&(0,lU.jsx)(uq,{dimensions:l,layout:"block",media:a}),(0,lU.jsxs)(lY.xu,{flex:1,paddingLeft:a?2:1,children:[(0,lU.jsx)(lY.xv,{size:1,textOverflow:"ellipsis",weight:"semibold",children:n?uN(n,"block"):"Untitled"}),i&&(0,lU.jsx)(lY.xu,{marginTop:2,children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:uN(i,"block")})}),r&&(0,lU.jsx)(lY.xu,{marginTop:3,children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:uN(r,"block")})})]}),(0,lU.jsxs)(lY.kC,{gap:1,paddingLeft:1,children:[o&&(0,lU.jsx)(lY.xu,{paddingX:2,paddingY:3,children:uN(o,"block")}),t]})]}),s&&(0,lU.jsx)("div",{"data-testid":"block-preview__children",children:s})]})},blockImage:function(e){let{actions:t,title:n,subtitle:i,description:r,fallbackTitle:l="Untitled",mediaDimensions:a=p_,media:o,children:s,status:d}=e;return(0,lU.jsxs)(pC,{children:[(0,lU.jsxs)(lY.Kq,{children:[(0,lU.jsxs)(pw,{paddingLeft:2,paddingRight:1,paddingY:1,children:[(0,lU.jsxs)(lY.Kq,{flex:1,space:2,children:[(n||l)&&(0,lU.jsx)(lY.xv,{size:1,textOverflow:"ellipsis",weight:"semibold",children:n?uN(n,"block"):l}),i&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:uN(i,"block")})]}),(0,lU.jsxs)(lY.kC,{gap:1,paddingLeft:1,children:[d&&(0,lU.jsx)(lY.xu,{paddingX:2,paddingY:3,children:uN(d,"block")}),t]})]}),(0,lU.jsx)(pk,{$ratio:pS(a),__unstable_checkered:!0,display:"flex",sizing:"border",tone:"inherit",children:(0,lU.jsx)(uq,{border:!1,dimensions:a,layout:"blockImage",media:o,radius:0,responsive:!0})})]}),r&&(0,lU.jsx)(lY.xu,{paddingX:2,paddingY:3,children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:uN(r,"block")})}),s&&(0,lU.jsx)("div",{children:s})]})}};function fR(){return(0,lU.jsx)(a0.$lS,{className:"sanity-studio__preview-fallback-icon"})}function fF(e){let{icon:t,layout:n,media:i,imageUrl:r,title:l,...a}=e,o=Ni(fC),s=(0,lK.useMemo)(()=>o1()(o),[o]),d=(0,lK.useCallback)(e=>{let{dimensions:t}=e;return(0,lU.jsx)("img",{alt:cu(l)?l:void 0,referrerPolicy:"strict-origin-when-cross-origin",src:s.image(i).width(t.width||100).height(t.height||100).fit(t.fit).dpr(t.dpr||1).url()||""})},[s,i,l]),c=(0,lK.useCallback)(()=>(0,lK.createElement)(t||fR),[t]),u=(0,lK.useMemo)(()=>!1!==t&&((0,a6.isValidElementType)(i)||(0,lK.isValidElement)(i)?i:(0,o2.JZ)(i)?d:cu(r)?(0,lU.jsx)("img",{src:r,alt:cu(l)?l:void 0,referrerPolicy:"strict-origin-when-cross-origin"}):c),[t,r,i,c,d,l]),p=(0,lK.useMemo)(()=>({...a,media:u,title:l}),[u,a,l]),h=fI[n||"default"];return(0,lK.createElement)(h,p)}let fD="undefined"==typeof window?l7.E:(0,l1.R)(window,"resize").pipe((0,am.d)(1)),fZ="undefined"==typeof window?l7.E:(0,l1.R)(window,"scroll",{passive:!0,capture:!0}).pipe((0,am.d)(1)),fL="undefined"==typeof window?l7.E:(0,l1.R)(window,"orientationchange").pipe((0,am.d)(1)),fq="undefined"!=typeof window&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in IntersectionObserverEntry.prototype&&("isIntersecting"in IntersectionObserverEntry.prototype||Object.defineProperty(IntersectionObserverEntry.prototype,"isIntersecting",{get(){return this.intersectionRatio>0}}),1)?function(){let e=new l2.x,t=new IntersectionObserver(t=>{t.forEach(t=>{e.next(t)})},{threshold:0,rootMargin:"".concat(150,"px")});return function(n){return new l9.y(e=>(t.observe(n),e.next(),()=>t.unobserve(n))).pipe((0,ay.z)(()=>e.asObservable()),(0,af.h)(e=>e.target===n),(0,ad.U)(e=>({isIntersecting:e.isIntersecting})))}}():function(e){let t=()=>{var t,n;return t=e.getBoundingClientRect(),n={left:0,right:window.innerWidth,top:0,bottom:window.innerHeight},t.left<=n.right+150&&t.right>=n.left-150&&t.top<=n.bottom+150&&t.bottom>=n.top-150};return(0,l3.T)((0,lQ.of)(t()),fD,fZ,fL).pipe((0,ad.U)(t),(0,ad.U)(e=>({isIntersecting:e})))},fN="undefined"==typeof window?l7.E:(0,l1.R)(document,"visibilitychange").pipe((0,am.d)(1)),fV={isLoading:!0},fU={isLoading:!1};function fB(e){let{enabled:t=!0,ordering:n,schemaType:i,value:r}=e||{},{observeForPreview:l}=UY();return(0,lJ.m2)(()=>t&&r&&i?l(r,i,{ordering:n}).pipe((0,ad.U)(e=>({isLoading:!1,value:e.snapshot||void 0})),(0,au.K)(e=>(0,lQ.of)({isLoading:!1,error:e}))):(0,lQ.of)(fU),[t,l,n,i,r],fV)}function fK(e){return cu(e)?e:void 0}function fH(e){let{layout:t,value:n,component:i,style:r,schemaType:l,skipVisibilityCheck:a,...o}=e,[s,d]=(0,lK.useState)(null),c=function(e){let{element:t,hideDelay:n=0}=e,[i,r]=(0,lK.useState)(!1);return(0,lK.useEffect)(()=>
1{if(!t)return;let e=(0,l0.z)((0,lQ.of)(!document.hidden),fN.pipe((0,ad.U)(e=>{var t;return e.target instanceof Document&&!(null==(t=null==e?void 0:e.target)?void 0:t.hidden)}))).pipe((0,ac.x)()),i=fq(t).pipe((0,ad.U)(e=>e.isIntersecting)),l=e.pipe((0,ap.w)(e=>e?i:(0,lQ.of)(!1)),(0,ap.w)(e=>e?(0,lQ.of)(!0):(0,lQ.of)(!1).pipe((0,ak.g)(n))),(0,ac.x)()),a=l.subscribe(r);return()=>a.unsubscribe()},[t,n]),i}({element:a?null:s,hideDelay:2e3}),u=fB({enabled:a||c,schemaType:l,value:n}),p=(0,lK.useMemo)(()=>({...r,minWidth:(null==r?void 0:r.minWidth)||1,minHeight:(null==r?void 0:r.minHeight)||1}),[r]),h=(0,lK.useMemo)(()=>(function(e){var t,n;if(!cc(e))return;let i="number"==typeof e.progress?e.progress:0,r=fK(e.initiated||e.createdAt),l=fK(e.updated||e.updatedAt),a=fK(null==(t=null==e?void 0:e.file)?void 0:t.name),o=fK(null==(n=null==e?void 0:e.file)?void 0:n.type),s=fK(e.previewImage);if(r&&l&&a&&o)return{progress:i,createdAt:r,updatedAt:l,file:{name:a,type:o},previewImage:s}})(null==n?void 0:n._upload),[n]),f=(0,lK.useMemo)(()=>{var e,t;return(null==h?void 0:h.previewImage)?(0,lU.jsx)("img",{alt:"The image currently being uploaded",src:h.previewImage}):(null==(e=null==u?void 0:u.value)?void 0:e.media)?null==(t=null==u?void 0:u.value)?void 0:t.media:l.icon},[u,l,h]);return(0,lU.jsx)("div",{ref:d,style:p,children:(0,lK.createElement)(i,{...o,...(null==u?void 0:u.value)||{},media:f,error:null==u?void 0:u.error,isPlaceholder:null==u?void 0:u.isLoading,layout:t,schemaType:l})})}function fW(e){let t=null==e?void 0:e.select;if(t)return Object.values(t).map(e=>String(e).split("."))}let f$=e=>!0===e.liveEdit;function fX(e,t,n,i){let r=f$(t)?(0,lQ.of)({snapshot:null}):e.observeForPreview({_type:"reference",_ref:cn(n)},t),l=e.observeForPreview({_type:"reference",_ref:ci(n)},t);return(0,ae.a)([r,l]).pipe((0,ad.U)(e=>{let[t,n]=e;return{draft:t.snapshot?{title:i,...t.snapshot||{}}:null,isLoading:!1,published:n.snapshot?{title:i,...n.snapshot||{}}:null}}),(0,ag.O)({draft:null,isLoading:!0,published:null}))}let fG=e=>({title:(0,lU.jsx)("em",{children:e.title?String(e.title):"Missing document"}),subtitle:(0,lU.jsx)("em",{children:e.title?"Missing document ID: ".concat(e._id):"Document ID: ".concat(e._id)}),media:()=>(0,lU.jsx)(a0.foC,{})}),fY=e=>{let{value:t,draft:n,published:i}=e,r=n||i;return r?s1()({},r,t,(e,t)=>void 0===t?e:t):fG(t)},fJ=["_id","_rev","_type"],fQ=[...fJ,"_key"],f0={available:!0,reason:"READABLE"},f1={available:!1,reason:"PERMISSION_DENIED"},f2={available:!1,reason:"NOT_FOUND"},f3={title:"Invalid preview config",subtitle:"Check the error log in the console",media:(0,lU.jsx)(a0.foC,{})};function f4(e){return Object.keys(e)}let f5=["_id","_type","_upload","_createdAt","_updatedAt"],f6=[],f8=(r={},{add:(e,t,n)=>{r[e.name]||(r[e.name]=[]),r[e.name].push({error:n,type:e,value:t})},getAll:()=>r,clear(){r={}}}),f9=lX()(()=>{let e=f8.getAll(),t=om()(Object.keys(e).map(t=>{let n=e[t];return ox()(n,e=>e.error.message)})),n=t.length;0!==n&&(console.groupCollapsed("%cHeads up! Got ".concat(1===n?"error":"".concat(n," errors")," while preparing data for preview. Click for details."),"color: #ff7e7c"),Object.keys(e).forEach(t=>{let n=e[t],i=n[0];console.group('Check the preview config for schema type "'.concat(t,'": %o'),i.type.preview);let r=ox()(n,e=>e.error.message);r.forEach(e=>{var t;if("returnValueError"===e.error.type){let n="function"==typeof(null==(t=e.type.preview)?void 0:t.prepare),{value:i,error:r}=e;console.log("Encountered an invalid ".concat(n?"return value when calling prepare(%o)":"value targeted by preview.select",":"),i),console.error(r)}if("prepareError"===e.error.type){let{value:t,error:n}=e;console.log("Encountered an error when calling prepare(%o):",t),console.error(n)}}),console.groupEnd()}),console.groupEnd(),f8.clear())},1e3),f7=e=>t=>{let n=typeof t;return null===t||"undefined"===n||"string"===n||"number"===n||"boolean"===n?f6:[mn("returnValueError",Error('The "'.concat(e,'" field should be a string, number, boolean, undefined or null, instead saw ').concat(mt(t))))]},me={media:()=>f6,title:f7("title"),subtitle:f7("subtitle"),description:f7("description"),imageUrl:f7("imageUrl"),date:f7("date")};function mt(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(cc(e)){let n=Object.keys(e),i=n.length>3?"...":"";return"".concat(t?"object with keys ":"","{").concat(n.slice(0,3).join(", ")).concat(i,"}")}if(Array.isArray(e)){let n=e.length>3?"...":"";return"".concat(t?"array with ":"","[").concat(e.map(e=>
1mt(e,!1))).concat(n,"]")}return"the ".concat(typeof e," ").concat(e)}function mn(e,t){return Object.assign(t,{type:e})}function mi(e,t){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=null==(n=e.preview)?void 0:n.prepare;try{return{returnValue:r?r(t,i):f4(t).reduce((e,n)=>{let i=t[n];return{...e,[n]:Array.isArray(i)&&(0===i.length||i.some(lV.DG))?function(e){let t=Array.isArray(e)&&e.find(lV.DG);return t&&t.children?t.children.filter(lV.NG).map(e=>e.text).join(""):""}(i):i}},{}),errors:f6}}catch(e){return{returnValue:null,errors:[mn("prepareError",e)]}}}function mr(e,t,n){return e.errors.forEach(e=>f8.add(t,n,e)),f9(),f3}function ml(e,t){var n,i,r,l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o="function"==typeof(null==(n=t.preview)?void 0:n.prepare),s=(null==(i=t.preview)?void 0:i.select)||{},d=Object.keys(s),c=d.reduce((n,i)=>{var r;let l="fields"in t?t:null,a=s[i],d=null==(r=null==l?void 0:l.fields)?void 0:r.find(e=>e.name===a),c=d&&function(e){if(!function(e){let t=!!e.options&&"object"==typeof e.options&&e.options;if(!t||!("list"in t))return!1;let n=t.list;return Array.isArray(n)}(e))return;let t=e.options.list;return t.map(e=>(0,lV.n4)(e)?e:{title:e,value:e})}(d.type);if(!o&&c){let t=c&&c.find(t=>t.value===op()(e,s[i]));n[i]=t?t.value:op()(e,s[i])}else n[i]=op()(e,s[i]);return n},{}),u=mi(t,c,a);if(u.errors.length>0)return mr(u,t,c);let p={...r=mi(t,c,a),errors:[...r.errors||[],...(l=r.returnValue,sD()(l)&&null!==l?Object.entries(l).reduce((e,t)=>{let[n,i]=t;return[...e,...function(e,t){if(void 0===t)return f6;let n=me[e];return n&&n(t)||f6}(n,i)]},f6):[mn("returnValueError",Error("Invalid return value. Expected a plain object with at least a 'title' field, instead saw ".concat(mt(l))))])]};return p.errors.length>0?mr(p,t,c):{...sQ()(e,f5),...u.returnValue}}function ma(e,t){let n;let i={},r=0;return function(){for(var e=arguments.length,a=Array(e),o=0;o<e;o++)a[o]=arguments[o];return new l9.y(e=>{clearTimeout(n),n=setTimeout(l,t);let o={args:a,observer:e,completed:!1},s=r++;return i[s]=o,()=>{o.completed=!0}})};function l(){let t=i;i={};let n=Object.keys(t).filter(e=>{let n=t[e];return n&&!n.completed});if(0===n.length)return;let r=n.map(e=>{let n=t[e];return n&&n.args}).filter(d9);e(r).subscribe({next(e){e.forEach((i,r)=>{let l=t[n[r]];l&&!l.completed&&l.observer.next(e[r])})},complete(){n.forEach(e=>{let n=t[e];n&&!n.completed&&n.observer.complete()})},error(e){n.forEach(n=>{let i=t[n];i&&!i.completed&&i.observer.error(e)})}})}}function mo(e,t){return e.push(...t),e}function ms(e,t){function n(e){return t({_ref:e}
1,[["_rev"]]).pipe((0,ad.U)(e=>cc(e)&&!!("_rev"in e&&(null==e?void 0:e._rev))),(0,ac.x)(),(0,ap.w)(t=>t?(0,lQ.of)(f0):i(e)))}let i=ma(function(e){let t=[...new Set(om()(e))];return(0,at.D)(function(e){let t=[],n=0,i=[];for(let r of e)n+r.length+1>=11164&&(i.push(t),t=[],n=0),n+=r.length+1,t.push(r);return i.includes(t)||i.push(t),i}(t)).pipe((0,ay.z)(r,10),(0,aC.u)(mo,[]),(0,ad.U)(n=>e.map(e=>{let[i]=e;return n[t.indexOf(i)]})))},1);function r(t){return(0,l4.P)(()=>{let n={uri:e.getDataUrl("doc",t.join(",")),json:!0,query:{excludeContent:"true"},tag:"preview.documents-availability"};return e.observable.request(n).pipe((0,ad.U)(e=>{let n=o9()(e.omitted||[],e=>e.id);return t.map(e=>{let t=n[e];if(!t)return f0;if("existence"===t.reason)return f2;if("permission"===t.reason)return f1;throw Error('Unexpected reason for omission: "'.concat(t.reason,'"'))})}))})}return{observeDocumentPairAvailability:function(e){let t=cn(e),i=ci(e);return(0,ae.a)([n(t),n(i)]).pipe((0,ac.x)(aQ()),(0,ad.U)(e=>{let[t,n]=e;return{draft:t,published:n}}))}}}function md(e){return JSON.stringify(e)}let mc=e=>cv(e)?'"'.concat(e,'": @').concat(cb(e)):e;function mu(e){let{ids:t,fields:n}=e,i=[...fJ,...n];return"*[_id in [".concat(t.map(md).join(","),"]][0...").concat(t.length,"]{").concat(i.map(mc).join(","),"}")}let mp=e=>e,mh=e=>!!(e.type&&"document"===e.type.name),mf=e=>e.name.startsWith("sanity."),mm=e=>e.getTypeNames().map(t=>e.get(t)).filter(d9).filter(e=>mh(e)).filter(e=>!mf(e)),mg=(e,t)=>{let{phrases:n,words:i}=function(e){let t=sa()(e.map(sn())),[n,i]=se()(t,e=>/^".*"$/.test(e));return{phrases:sa()(n).map(sn()).map(mv),words:sa()(i.map(sn()))}}(e),[r,l]=function(e,t){let n=t.toLowerCase().trim(),i=0,r=0;return e.forEach(e=>{n.includes(e)&&(i+=e.length/n.length,r+=e.length)}),1===i?[1,"[Phrase] Exact match"]:[i/2,"[Phrase] Matched ".concat(r," of ").concat(n.length," characters")]}(n,t),[a,o]=function(e,t){let n=sa()(o4()(ss()(sn()(t)))),i=o6()(e,n),r=sr()(n,e),l=i.length/r.length;return 1===l?[1,"[Word] Exact match"]:[l/2,"[Word] Matched ".concat(i.length," of ").concat(r.length," terms: [").concat(i.join(", "),"]")]}(i,t);return[r+a,[o,l].join(", ")]},mx=e=>"string"==typeof e?e:JSON.stringify(e);function mv(e){return e.replace(/^"(.*)"$/,"$1")}let mb=/([^!@#$%^&*(),\\/?";:{}|[\]+<>\s-])+/g,my=/(^[.]+)|([.]+$)/,mj=sc()([om(),sr(),o4()]);function mw(e,t){let n=!1,i=e.map(e=>({typeName:e.name,paths:e.__experimental_search.map(e=>{let i=e.path.map(e=>"number"==typeof e&&(n=!0,t)?[]:e);return{weight:e.weight,path:cw(i),mapWith:e.mapWith}})}));return{specs:i,hasIndexedPaths:n}}let mk=e=>{let{mapWith:t,path:n}=e;return t?"".concat(t,"(").concat(n,")"):n};function mC(e){var t,n;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{filter:r,params:l,tag:a}=i,{specs:o,hasIndexedPaths:s}=mw(e.types,!1),d=function(e){let t=[],n=e.replace(/("[^"]*")/g,e=>ss()(e).length>1?(t.push(e),""):e),i=t.map(e=>sp()(sn()(e))),r=sa()(o4()((sn()(n).match(mb)||[]).map(e=>e.replace(my,""))));return[...i,...r]}(e.query),c=s?mw(e.types,!0).specs:o,u=["_type in $__types",!1===i.includeDrafts&&"!(_id in path('drafts.**'))",...function(e,t){let n=mj(t.map(e=>(e.paths||[]).map(e=>mk(e)))),i=e.map((e,t)=>n.map(e=>"".concat(e," match $t").concat(t))).filter(e=>e.length>0);return i.map(e=>"(".concat(e.join(" || "),")"))}(d,c),r?"(".concat(r,")"):"",e.filter?"(".concat(e.filter,")"):""].filter(Boolean),p=o.map(e=>{let t='_type == "'.concat(e.typeName,'" => '),n="{ ".concat(e.paths.map((e,t)=>'"w'.concat(t,'": ').concat(mk(e)))," }");return"".concat(t).concat(n)}),h=((null==i?void 0:i.sort)||[{field:"_id",direction:"asc"}]).map(e=>[e.mapWith?"".concat(e.mapWith,"(").concat(e.field,")"):e.field,(e.direction||"").toLowerCase()].map(e=>e.trim()).filter(Boolean).join(" ")).join(","),f=["_type","_id"],m=p.length>0?"...select(".concat(p.join(",\n"),")"):"",g=f.join(", ")+(m?", ".concat(m):""),x="*[".concat(u.join(" && "),"]")+"| order(".concat(h,")")+"[$__offset...$__limit]"+"{".concat(g,"}");if(null==i?void 0:i.__unstable_extendedProjection){let e=null==i?void 0:i.__unstable_extendedProjection,t=f.concat(e).join(", ");x=["*[".concat(u.join(" && "),"]{").concat(t,"}"),"order(".concat(h,")[$__offset...$__limit]{").concat(g,"}")].join("|")}let v=["findability-mvi:".concat(4)].concat((null==i?void 0:i.comments)||[]).map(e=>"// ".concat(e)).join("\n"),b=v?"".concat(v,"\n").concat(x):x,y=null!=(t=null==i?void 0:i.offset)?t:0,j=(null!=(n=null==i?void 0:i.limit)?n:1e3)+y;return{query:b,params:{...m_(d),__types:o.map(e=>e.typeName),__limit:j,__offset:y,...l||{}},options:{tag:a},searchSpec:o,terms:d}}let m_=e=>
1e.reduce((e,t,n)=>(e["t".concat(n)]="".concat(t,"*"),e),{});function mS(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l="string"==typeof i?{query:i,types:e}:i.types.length?i:{...i,types:e},{query:a,params:o,options:s,searchSpec:d,terms:c}=mC(l,{...n,...r});return t.observable.fetch(a,o,s).pipe(n.unique?(0,ad.U)(cl):(0,as.b)(),(0,ad.U)(e=>(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=o9()(e,e=>e.typeName);return t.map((e,r)=>{var l;let a=i[e._type],o=null==(l=a.paths||[])?void 0:l.map((t,i)=>{let r=mx(e["w".concat(i)]);if(!r)return{path:t.path,score:0,why:"No match"};let[l,a]=mg(n,r);return{path:t.path,score:l*t.weight,why:"".concat(a," (*").concat(t.weight,")")}}),s=o.reduce((e,t)=>e+t.score,0);return{hit:e,resultIndex:t.length-r,score:s,stories:o}})})(d,e,c)),(null==r?void 0:r.skipSortByScore)?(0,as.b)():(0,ad.U)(e=>aX()(e,e=>-e.score)))}}let mT={available:!0,reason:"READABLE"},mE={available:!1,reason:"PERMISSION_DENIED"},mP={available:!1,reason:"NOT_FOUND"};function mA(e,t,n){let{publishedId:i,draftId:r}=ct(t),l=e.unstable_observeDocumentPairAvailability(t);return l.pipe((0,ap.w)(l=>{if(!l.draft.available&&!l.published.available){let e="PERMISSION_DENIED"===l.draft.reason||"PERMISSION_DENIED"===l.published.reason?mE:mP;return(0,lQ.of)({id:t,type:void 0,availability:e,preview:{draft:void 0,published:void 0}})}let a={_type:"reference",_ref:r},o={_type:"reference",_ref:i},s=(0,ae.a)([e.observeDocumentTypeFromId(r),e.observeDocumentTypeFromId(i)]).pipe((0,ad.U)(e=>{let[t,n]=e;return t||n}));return s.pipe((0,ap.w)(s=>{if(!s)return(0,lQ.of)({id:t,type:void 0,availability:{available:!0,reason:"READABLE"},preview:{draft:void 0,published:void 0}});let d=n.to.find(e=>e.name===s);if(!d)return(0,lQ.of)({id:t,type:s,availability:{available:!0,reason:"READABLE"},preview:{draft:void 0,published:void 0}});let c=[...fW(null==d?void 0:d.preview)||[],["_updatedAt"],["_createdAt"]],u=e.observePaths(a,c).pipe((0,ad.U)(e=>e?{_id:r,...ml(e,d)}:void 0),(0,ag.O)(void 0)),p=e.observePaths(o,c).pipe((0,ad.U)(e=>e?{_id:i,...ml(e,d)}:void 0),(0,ag.O)(void 0)),h=(0,ae.a)([u,p]).pipe((0,ad.U)(e=>{let[t,n]=e;return{draft:t,published:n}}));return h.pipe((0,ad.U)(e=>{let t=l.draft.available||l.published.available?mT:"PERMISSION_DENIED"===l.draft.reason||"PERMISSION_DENIED"===l.published.reason?mE:mP;return{type:s,id:i,availability:t,preview:{draft:cc(e.draft)?e.draft:void 0,published:cc(e.published)?e.published:void 0}}}))}))}))}function mO(e,t,n,i){let r=mS(n.to,e,i);return r(t,{includeDrafts:!0}).pipe((0,ad.U)(e=>e.map(e=>e.hit)),(0,ad.U)(cr),(0,ad.U)(e=>e.slice(0,100)),(0,ay.z)(t=>{var n;return(0===(n=t.filter(e=>!e.draft||!e.published).map(e=>e.draft?e.id:cn(e.id))).length?(0,lQ.of)([]):e.observable.fetch("*[_id in $ids]._id",{ids:n},{tag:"get-counterpart-ids"})).pipe((0,ad.U)(e=>t.map(t=>{let n=cn(t.id);return{id:t.id,type:t.type,draft:t.draft||e.includes(n)?{_id:n,_type:t.type}:void 0,published:t.published||e.includes(t.id)?{_id:t.id,_type:t.type}:void 0}})))}))}function mz(){let e=[];return{publish(t){for(let n of e)n(t)},subscribe:t=>(e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)})}}let mM=Symbol.for("sanity.patch");function mI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{patchType:mM,type:"setIfMissing",path:t,value:e}}function mR(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{patchType:mM,type:"insert",path:n,position:t,items:e}}function mF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{patchType:mM,type:"set",path:t,value:e}}function mD(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{patchType:mM,type:"unset",path:e}}var mZ=Object.defineProperty,mL=(e,t,n)=>t in e?mZ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mq=(e,t,n)=>(mL(e,"symbol"!=typeof t?t+"":t,n),n);class mN{constructor(e){mq(this,"patches"),this.patches=e}static from(e){return e instanceof mN?e:new mN(Array.isArray(e)?om()(e):[e])}prepend(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return mN.from([...om()(t),...this.patches])}append(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return mN.from([...this.patches,...om()(t)])}prefixAll(e){return mN.from(this.patches.map(t=>({...t,path:[e,...t.path]})))}}var mV=Object.freeze,mU=Object.defineProperty;let mB={warning:"caution",error:"critical"},mK=(0,aW.ZP)(lY.xu)(tb||(tb=mV(mU(d=["\n border-top: 1px solid var(--card-border-color);\n"],"raw",{value:mV(d.slice())}))));function mH(e){let{children:t,status:n="warning",suffix:i,title:r,...l}=e;return(0,lU.jsxs)(lY.Zb,{radius:2,tone:mB[n],...l,"data-ui":"Alert",children:[(0,lU.jsxs)(lY.kC,{padding:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsxs)(lY.xv,{size:1,children:["warning"===n&&(0,lU.jsx)(a0.foC,{}),"error"===n&&(0,lU.jsx)(a0.uIy,{})]})}),(0,lU.jsxs)(lY.xu,{flex:1,marginLeft:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:r}),t&&(0,lU.jsx)(lY.xu,{marginTop:3,children:t})]})]}),i&&(0,lU.jsx)(mK,{children:i})]})}function mW(e,t){let n=(0,lK.useRef)(t||null);return(0,lK.useEffect)(()=>{n.current=e},[e]),n.current}function m$(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:aQ(),i=mW(e);(0,lK.useEffect)(()=>{n(i,e)||t(i,e)},[t,e,i,n])}function mX(e,t){(0,lK.useEffect)(()=>{let n=n=>{let i=n.target;if(i instanceof HTMLElement){if(e.some(e=>{var t;return null==(t=e.current)?void 0:t.contains(i)}))return;t(n)}};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}let mG=(0,lK.createContext)(null);function mY(){let e=(0,lK.useContext)(mG);if(!e)throw Error("FormBuilder: missing context value");return e}let mJ={constrainSize:!0,portal:!0};function mQ(e){let{schemaType:t,readOnly:n,children:i,onValueCreate:r,onItemAppend:l}=e,a=(0,lK.useId)(),o=(0,lK.useCallback)(e=>{let t=r(e);l(t)},[r,l]),s=lK.useCallback(()=>{o(t.of[0])},[t,o]);return n?(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsx)(lY.xu,{padding:2,sizing:"border",children:(0,lU.jsx)(lY.xv,{size:1,children:"This field is read-only"})}),children:(0,lU.jsx)(lY.rj,{children:(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",disabled:!0,text:1===t.of.length?"Add item":"Add item..."})})}):(0,lU.jsxs)(lY.rj,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[1===t.of.length?(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",onClick:s,text:"Add item"}):(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",text:"Add itemâ¦"}),id:a||"",menu:(0,lU.jsx)(lY.v2,{children:t.of.map((e,t)=>{var n,i;let r=(0,lV.dD)(e)&&1===(e.to||[]).length&&e.to[0].icon,l=e.icon||(null==(n=e.type)?void 0:n.icon)||r;return(0,lU.jsx)(lY.sN,{text:e.title||(null==(i=e.type)?void 0:i.name),onClick:()=>o(e),icon:l},t)})}),popover:mJ}),i]})}var m0=Object.freeze,m1=Object.defineProperty,m2=(e,t)=>m0(m1(e,"raw",{value:m0(t||e.slice())}));let m3=e=>"error"===e?(0,lU.jsx)(a0.uIy,{}):"warning"===e?(0,lU.jsx)(a0.foC,{}):(0,lU.jsx)(a0.hQ6,{}),m4=(0,aW.ZP)(lY.xv)(e=>{let{theme:t}=e;return(0,aW.iv)(ty||(ty=m2(["\n &[data-info] {\n color: ",";\n }\n\n &[data-warning] {\n color: ",";\n }\n\n &[data-error] {\n color: ",";\n }\n "])),t.sanity.color.muted.primary.enabled.fg,t.sanity.color.muted.caution.enabled.fg,t.sanity.color.muted.critical.enabled.fg)});function m5(e){let{markers:t,validation:n,renderCustomMarkers:i}=e,{CustomMarkers:r}=mY().__internal.components;return 0===t.length&&0===n.length?null:(0,lU.jsxs)(lY.Kq,{space:1,children:[n.length>0&&n.map((e,t)=>{let{message:i,level:r}=e;return(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{marginRight:2,marginBottom:t+1===n.length?0:2,children:(0,lU.jsx)(m4,{size:1,"data-error":"error"===r?"":void 0,"data-warning":"warning"===r?"":void 0,"data-info":"info"===r?"":void 0,children:m3(r)})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:i||"Error"})})]},"validationItem-".concat(t))}),t.length>0&&(0,lU.jsxs)(lY.xu,{marginTop:n.length>0?3:0,children:[i&&i(t),!i&&(0,lU.jsx)(r,{markers:t})]})]})}function m6(){return(0,lU.jsxs)(lY.xv,{size:1,children:["This is a example custom marker, please implement ",(0,lU.jsx)("code",{children:"renderCustomMarkers"})," function."]})}let m8=lK.createContext(null),m9=(0,lK.memo)(function(e){let t=(0,lK.useRef)(e);t.current=e;let n=(0,lK.useCallback)(e=>{var n,i,r;return null!=(r=null==(i=null==(n=t.current)?void 0:n.transformPatches)?void 0:i.call(n,e))?r:[]},[t]),i=(0,lK.useCallback)(e=>{t.current.onChange(e)},[]),r=(0,lK.useCallback)(e=>{t.current.onPathFocus(e)},[]),l=(0,lK.useCallback)(e=>{t.current.onPathBlur(e)},[]),a=(0,lK.useCallback)(e=>{t.current.onPathOpen(e)},[]),o=(0,lK.useCallback)((e,n)=>{t.current.onSetPathCollapsed(e,n)},[]),s=(0,lK.useCallback)((e,n)=>{t.current.onSetFieldSetCollapsed(e,n)},[]),d=(0,lK.useCallback)((e,n)=>{t.current.onFieldGroupSelect(e,n)},[]),c=(0,lK.useMemo)(()=>
1({transformPatches:n,onChange:i,onPathFocus:r,onPathBlur:l,onPathOpen:a,onSetPathCollapsed:o,onSetFieldSetCollapsed:s,onFieldGroupSelect:d}),[i,d,l,r,a,s,o,n]);return(0,lU.jsx)(m8.Provider,{value:c,children:e.children})});function m7(){let e=(0,lK.useContext)(m8);if(!e)throw Error("Form context not provided");return e}function ge(e,t){return function e(t,n,i){if(t===n)return t;if(i.has(n)||null==t||null==n)return n;let r=typeof t,l=typeof n;if(r!==l)return n;if(Array.isArray(n)){i.add(n);let r=t.length===n.length,l=[];for(let a=0;a<n.length;a++){let o=e(t[a],n[a],i);o!==t[a]&&(r=!1),l[a]=o}return r?t:l}if("object"==typeof n){i.add(n);let r=Object.keys(n),l=Object.keys(t).length===r.length,a={};for(let o of r){let r=e(t[o],n[o],i);r!==t[o]&&(l=!1),a[o]=r}return l?t:a}return n}(e,t,new WeakSet)}let gt=(0,lK.createContext)([]);function gn(e){return(0,lU.jsx)(gt.Provider,{value:e.presence,children:e.children})}function gi(e,t){let n=function(){let e=(0,lK.useContext)(gt);if(!e)throw Error("Form context not provided");return e}(),i=(0,lK.useRef)(n),r=ge(i.current,n.filter(n=>(0,lB.Ny)(e,n.path)&&(t||!(0,lB.Xy)(e,n.path))));return i.current=r,r}let gr=(0,lK.createContext)([]);function gl(e){return(0,lU.jsx)(gr.Provider,{value:e.validation,children:e.children})}function ga(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=function(){let e=(0,lK.useContext)(gr);if(!e)throw Error("Form context not provided");return e}();return(0,lK.useMemo)(()=>n.filter(n=>(0,lB.Ny)(e,n.path)&&(t||!(0,lB.Xy)(e,n.path))).map(e=>({message:e.item.message,level:e.level,path:e.path})),[t,e,n])}let go=(0,lK.createContext)({actions:[],hovered:!1,onMouseEnter:()=>void 0,onMouseLeave:()=>void 0});function gs(){return(0,lK.useContext)(go)}function gd(e){let{action:t}=e,n=(0,lK.useCallback)(()=>{t.onAction()},[t]),i="object"==typeof t.disabled&&(0,lU.jsx)(lY.xv,{size:1,children:t.disabled.reason});return(0,lU.jsx)(pY,{content:i,placement:"left",children:(0,lU.jsx)(lY.sN,{disabled:!!t.disabled,fontSize:1,icon:t.icon,iconRight:t.iconRight||(t.selected?a0.KML:void 0),onClick:n,padding:3,pressed:t.selected,space:3,text:t.title,tone:t.tone})})}let gc={placement:"right",fallbackPlacements:["top","bottom"]};function gu(e){let{group:t}=e;return t.expanded?(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{padding:2,paddingBottom:1,children:(0,lU.jsx)(lY.__,{muted:!0,size:0,children:t.title})}),t.children.map((e,n)=>{var i;return(0,lU.jsx)(gp,{action:e,isFirst:0===n,prevIsGroup:(null==(i=t.children[n-1])?void 0:i.type)==="group"},n)})]}):(0,lU.jsx)(lY.kS,{fontSize:1,icon:t.icon,padding:3,popover:gc,space:3,text:t.title,tone:t.tone,children:t.children.map((e,n)=>{var i;return(0,lU.jsx)(gp,{action:e,isFirst:0===n,prevIsGroup:(null==(i=t.children[n-1])?void 0:i.type)==="group"},n)})})}function gp(e){let{action:t,isFirst:n,prevIsGroup:i}=e;return"divider"===t.type?(0,lU.jsx)(lY.R,{}):"group"===t.type?(0,lU.jsxs)(lU.Fragment,{children:[!n&&(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(gu,{group:t})]}):(0,lU.jsxs)(lU.Fragment,{children:[i&&(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(gd,{action:t})]})}let gh={placement:"top"};function gf(e){return"renderAsButton"in e&&e.renderAsButton}let gm=(0,lK.memo)(function(e){let{focused:t,nodes:n}=e,{hovered:i}=gs(),[r,l]=(0,lK.useState)(!1),a=(0,lK.useCallback)(()=>l(!0),[]),o=(0,lK.useCallback)(()=>l(!1),[]),s=(0,lK.useMemo)(()=>n.filter(gf),[n]),d=(0,lK.useMemo)(()=>n.filter(e=>!gf(e)),[n]),c=(0,lK.useMemo)(()=>{let e=d.length;if(0===e||e>1)return d;let t=d[0];return"group"===t.type?[{...t,expanded:!0}]:d},[d]),u=(0,lK.useMemo)(()=>[...s,...c.length?[{type:"group",children:c,icon:a0.zGg,title:"Field actions"}]:[]],[s,c]),p=(0,lK.useMemo)(()=>({height:25,lineHeight:0,display:r||t||i?void 0:"none"}),[t,i,r]);return(0,lU.jsx)(lY.kC,{gap:1,style:p,children:u.map((e,t)=>(0,lU.jsx)(gg,{node:e,onOpen:a,onClose:o,open:r},t))})}),gg=(0,lK.memo)(function(e){let{node:t,onOpen:n,onClose:i,open:r}=e;return"divider"===t.type?(0,lU.jsx)(lY.Zb,{borderLeft:!0,flex:"none"}):"action"===t.type?(0,lU.jsx)(pK,{fontSize:1,icon:t.icon,label:r?void 0:t.title,mode:ck?"bleed":"ghost",onClick:t.onAction,padding:2,tooltip:gh}):(0,lU.jsx)(gv,{node:t,onOpen:n,onClose:i,open:r})}),gx={constrainSize:!0,placement:"right",portal:!0,fallbackPlacements:["top","bottom"]};
1function gv(e){let{node:t,onOpen:n,onClose:i,open:r}=e;return(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(pK,{fontSize:1,icon:t.icon,label:r?void 0:t.title,mode:ck?"bleed":"ghost",padding:2,tooltip:gh}),id:(0,lK.useId)(),menu:(0,lU.jsx)(lY.v2,{children:t.children.map((e,n)=>{var i;return(0,lU.jsx)(gp,{action:e,isFirst:0===n,prevIsGroup:(null==(i=t.children[n-1])?void 0:i.type)==="group"},n)})}),onOpen:n,onClose:i,popover:gx})}let gb=(0,lK.memo)(function(e){let{actions:t,documentId:n,documentType:i,onActions:r,path:l,schemaType:a}=e,o=t.length,s=(0,lK.useRef)(o),[d,c]=(0,lK.useState)(()=>Array.from(Array(o))),u=(0,lK.useRef)(d),p=(0,lK.useCallback)((e,t)=>{c(n=>{let i=[...n];return i[e]=t,i})},[]);return(0,lK.useEffect)(()=>{u.current!==d&&(u.current=d,r(function e(t){return t.filter(Boolean).filter(e=>!("hidden"in e)||!0!==e.hidden).map(t=>"group"===t.type?{...t,children:e(t.children)}:t)}(d)))},[d,r]),(0,lK.useEffect)(()=>{if(s.current!==o){let e=Array.from(Array(o));for(let t=0;t<o;t++)e[t]=u.current[t];s.current=o,c(e),u.current=e}},[o]),(0,lU.jsx)(lU.Fragment,{children:t.map((e,t)=>(0,lU.jsx)(gy,{action:e,index:t,documentId:n,documentType:i,path:l,schemaType:a,setFieldAction:p},t))})}),gy=(0,lK.memo)(function(e){let{action:t,documentId:n,documentType:i,index:r,path:l,schemaType:a,setFieldAction:o}=e,s=d6(t.useAction({documentId:n,documentType:i,path:l,schemaType:a}));return(0,lK.useEffect)(()=>{o(r,s)},[r,s,o]),null}),gj=(0,lK.createContext)(null);function gw(){let e=(0,lK.useContext)(gj);if(!e)throw Error("UserColorManager: missing context value");return e}let gk=["green","red","gray"],gC=a8.mE.filter(e=>!gk.includes(e)),g_=e=>{let t="dark"===e;return{background:t?"900":"100",border:t?"700":"300",text:t?"200":"700"}},gS=e=>{let{background:t,border:n,text:i}=g_(e);return gC.reduce((e,r)=>(e[r]={name:r,background:a8.VG[r][t].hex,border:a8.VG[r][n].hex,text:a8.VG[r][i].hex,tints:a8.VG[r]},e),{})},gT=e=>{let{background:t,border:n,text:i}=g_(e);return{name:"gray",background:a8.VG.gray[t].hex,border:a8.VG.gray[n].hex,text:a8.VG.gray[i].hex,tints:a8.VG.gray}};function gE(e){let{children:t,manager:n}=e,{scheme:i}=Ff(),r=(0,lK.useMemo)(()=>n||function(e){let t;let{anonymousColor:n,colors:i,currentUserColor:r,scheme:l}=e,a=i||gS(l),o=n||gT(l),s=r||"purple";if(!a.hasOwnProperty(s))throw Error("'colors' must contain 'currentUserColor' (".concat(s,")"));let d=Object.keys(a),c=new Map,u=new Map,p=d.reduce((e,t)=>(e[t]=0,e),{}),h=new Map;return(null==e?void 0:e.userStore)&&e.userStore.me.subscribe(e=>{var n;t=n=e?e.id:null,p[s]+=n?1:-1}),{get:function(e){return e?a[f(e)]:o},listen:function(e){let t=c.get(e);if(t)return t;let n=f(e);return t=new l9.y(t=>{let i=a[n];return t.next(i),()=>{c.delete(e),h.delete(e),p[n]--}}).pipe((0,am.d)({refCount:!0})),c.set(e,t),t}};function f(e){let n,i;if(e===t)return s;let r=h.get(e);if(r)return r;let l=u.get(e);if(l&&(0===p[l]||!d.find(e=>0===p[e])))return m(e,l);let a=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return d[Math.abs(t)%d.length]}(e);return 0===p[a]?m(e,a):m(e,(n=1/0,i=[],d.forEach(e=>{let t=p[e];t===n?i.push(e):t<n&&(n=t,i=[e])}),l&&i.includes(l)?l:i[0]))}function m(e,t){return h.set(e,t),u.set(e,t),p[t]++,t}}({scheme:i}),[n,i]);return(0,lU.jsx)(gj.Provider,{value:r,children:t})}let gP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gA=/_key\s*==\s*['"](.*)['"]/;function gO(e){if(!Array.isArray(e))throw Error("Path is not an array");return e.reduce((e,t,n)=>{let i=typeof t;if("number"===i)return"".concat(e,"[").concat(t,"]");if("string"===i)return"".concat(e).concat(0===n?"":".").concat(t);if((0,lV.Fd)(t)&&t._key)return"".concat(e,'[_key=="').concat(t._key,'"]');if(Array.isArray(t)){let[n,i]=t;return"".concat(e,"[").concat(n,":").concat(i,"]")}throw Error("Unsupported path segment `".concat(JSON.stringify(t),"`"))},"")}function gz(e,t){let n=t[0];if(!n)return e;let i=t.slice(1);if((0,lV.dw)(n))return gz(Array.isArray(e)?e[n]:void 0,i);if((0,lV.Fd)(n))return gz(Array.isArray(e)?e.find(e=>e._key===n._key):void 0,i);if("string"==typeof n)return gz(cc(e)?e[n]:void 0,i);throw Error("Unknown segment type ".concat(JSON.stringify(n)))}function gM(e){return(0,lV.dw)(e)?Number(e.replace(/[^\d]/g,"")):(0,lV.Fd)(e)?function(e){let t=e.match(gA);if(!t)throw Error("Invalid key segment");return{_key:t[1]}}(e):(0,lV.lo)(e)?function(e){let[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}function gI(e,t){return e.length===t.length&&e.every((e,n)=>{let i=t[n];return(0,lV.Fd)(e)&&(0,lV.Fd)(i)?e._key===i._key:(0,lV.dw)(e)?Number(e)===Number(i):(0,lV.lo)(e)&&(0,lV.lo)(i)?e[0]===i[0]&&e[1]===i[1]:e===i})}function gR(e){return(0,lV.fU)(e)?e._key:void 0}function gF(e){let t=gR(e);return t?{_key:t}:void 0}function gD(e,t){return e.get((null==t?void 0:t.author)||null)}function gZ(e,t){let n=Array.isArray(t)?t:function(e){let t=e.match(gP);if(!t)throw Error("Invalid path string");return t.map(gM)}(t);return function(e,t){let n=function e(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(0===n.length)return t;let r=n[0],l=n.slice(1);if((0,lV.lo)(r))throw Error("Index tuples are not supported in diff paths");if((0,lV.dw)(r)||(0,lV.Fd)(r)){let n=(0,lV.dw)(r)?"at index ".concat(r):"with key ".concat(r._key);if("array"!==t.type){"Failed to get item ".concat(n," at path ").concat(gO(i)," (not an array)");return}let a=t.items.find((0,lV.dw)(r)?e=>e.toIndex===r:e=>(function(e,t){let n=e.diff;return"object"===n.type&&!!n.toValue&&n.toValue._key===t})(e,r));if(!a){"Failed to get item ".concat(n," at path ").concat(gO(i)," (item missing)");return}return e(a.diff,l,i.concat(r))}if("object"!==t.type){"Failed to get property ".concat(r," at path ").concat(gO(i)," (not an object)");return}let a=t.fields[r];if(void 0===a){"Failed to get property ".concat(r," at path ").concat(gO(i)," (field did not exist)");return}return e(a,l,i.concat(r))}(e,t);if(n&&"unchanged"!==n.action)return n.annotation||void 0}(e,n)}function gL(e){let t=gw();return gD(t,e)}function gq(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=gw(),i=(0,lK.useMemo)(()=>gZ(e,t),[e,t]);return(0,lK.useMemo)(()=>gD(n,i),[i,n])}function gN(e){if("diff"in e){let{diff:t,path:n=[],...i}=e,r=gZ(t,n);return(0,lU.jsx)(gV,{...i,annotations:r?[r]:[]})}return(0,lU.jsx)(gV,{...e})}function gV(e){let{annotations:t,children:n,description:i="Changed",...r}=e;if(!t)return n;let l=(0,lU.jsxs)(lY.Kq,{padding:3,space:2,children:[(0,lU.jsx)(lY.__,{size:1,style:{textTransform:"uppercase"},children:i}),(0,lU.jsx)(lY.Kq,{space:2,children:t.map((e,t)=>(0,lU.jsx)(gU,{annotation:e},t))})]});return(0,lU.jsx)(p1,{zOffset:"paneFooter",children:(0,lU.jsx)(lY.u,{content:l,portal:!0,allowedAutoPlacements:["top","bottom"],...r,children:n})})}function gU(e){let{annotation:t}=e,{author:n,timestamp:i}=t,[r]=Ny(n),l=gL(t),a=Ng(i,{minimal:!0});return(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsxs)(lY.kC,{align:"center",paddingRight:3,style:{backgroundColor:l.background,color:l.text,borderRadius:"calc(23px / 2)"},children:[(0,lU.jsx)(U4,{user:n}),(0,lU.jsx)(lY.gF,{paddingLeft:2,children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,style:{color:l.text},children:r?r.displayName:"Loadingâ¦"})})]}),(0,lU.jsx)(lY.xv,{as:"time",muted:!0,size:1,dateTime:i,children:a})]})}var gB=Object.freeze,gK=Object.defineProperty;let gH=(0,aW.ZP)(lY.Zb)(tj||(tj=gB(gK(c=["\n --diff-card-radius: ",";\n --diff-card-bg-color: ",";\n\n max-width: 100%;\n position: relative;\n border-radius: var(--diff-card-radius);\n\n &:not(del) {\n text-decoration: none;\n }\n\n &[data-hover] {\n &::after {\n content: '';\n display: block;\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n &:hover {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n\n &::after {\n bottom: -3px;\n border-top: 1px solid var(---diff-card-bg-color);\n border-bottom: 2px solid currentColor;\n border-bottom-left-radius: var(--diff-card-radius);\n border-bottom-right-radius: var(--diff-card-radius);\n }\n }\n\n [data-from-to-layout]:hover & {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n\n &::after {\n bottom: -3px;\n border-top: 1px solid var(---diff-card-bg-color);\n border-bottom: 2px solid currentColor;\n border-bottom-left-radius: var(--diff-card-radius);\n border-bottom-right-radius: var(--diff-card-radius);\n }\n }\n }\n"],"raw",{value:gB(c.slice())}))),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[2])},e=>{let{theme:t}=e;return t.sanity.color.card.enabled.bg}),gW=[],g$=(0,lK.forwardRef)(function(e,t){let{annotation:n,as:i="div",children:r,className:l,diff:a,disableHoverEffect:o,path:s=gW,style:d={},tooltip:c,...u}=e,p=(0,lK.useMemo)(()=>n||gZ(a,s),[n,a,s]),h=gL(p),f=(0,lU.jsx)(gH,{...u,as:i,className:l,"data-hover":o||!p?void 0:"",ref:t,radius:1,style:{...d,backgroundColor:h.background,color:h.text},children:r});return c&&p?(0,lU.jsx)(gN,{annotations:[p],description:c&&"object"==typeof c&&c.description,children:f}):f});var gX=Object.freeze,gG=Object.defineProperty,gY=(e,t)=>
1gX(gG(e,"raw",{value:gX(t||e.slice())}));let gJ=aW.ZP.div(tw||(tw=gY(["\n border-radius: ",";\n padding: ",";\n"])),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[2])},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.space[1])}),gQ=(0,aW.ZP)(lY.xv)(tk||(tk=gY(["\n &:not([hidden]) {\n color: inherit;\n }\n"])));function g0(e){let{change:t,segment:n}=e;if("string"==typeof n)return(0,lU.jsx)(lY.xu,{style:n.length>30?{maxWidth:100}:{},children:(0,lU.jsx)(lY.xv,{title:n,size:1,weight:"semibold",textOverflow:"ellipsis",children:n})});let{hasMoved:i,fromIndex:r,toIndex:l,annotation:a}=n,o=void 0===r,s=void 0===l;if(o)return(0,lU.jsx)(g1,{annotation:a,change:t,toIndex:l});if(s)return(0,lU.jsx)(g2,{annotation:a,fromIndex:r});if(i&&void 0!==l&&void 0!==r)return(0,lU.jsx)(g3,{annotation:a,fromIndex:r,toIndex:l});let d=(l||0)+1;return(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsxs)(lY.xv,{size:1,weight:"semibold",children:["#",d]})})}function g1(e){let{annotation:t,change:n,toIndex:i=0}=e,r=i+1,l=(0,lU.jsxs)(lU.Fragment,{children:["#",r]}),a=(null==n?void 0:n.diff)?gZ(n.diff,[]):void 0,o=a||t;return o?(0,lU.jsx)(g$,{annotation:o,tooltip:{description:"Added in position ".concat(r)},as:gJ,children:(0,lU.jsx)(gQ,{size:1,weight:"semibold",forwardedAs:"ins",style:{textDecoration:"none"},children:l})}):(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:l})}function g2(e){let{annotation:t,fromIndex:n=0}=e,i=n+1;return(0,lU.jsx)(g$,{annotation:t||null,as:gJ,tooltip:{description:"Removed from position ".concat(i)},children:(0,lU.jsxs)(gQ,{size:1,weight:"semibold",forwardedAs:"del",children:["#",i]})})}function g3(e){let{annotation:t,fromIndex:n,toIndex:i}=e,r=i-n,l=r<0?"â":"â",a=Math.abs(r),o="Moved ".concat(a," position").concat(1===a?"":"s"," ").concat(r<0?"up":"down");return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsxs)(gQ,{size:1,weight:"semibold",children:["#",i+1]})}),(0,lU.jsx)(g$,{annotation:t,as:gJ,tooltip:{description:o},children:(0,lU.jsxs)(gQ,{size:1,weight:"semibold",children:[l,Math.abs(r)]})})]})}function g4(e){let{change:t,titlePath:n}=e;return(0,lU.jsx)(lY.Oo,{separator:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"/"}),children:n.map((e,n)=>{let i="string"==typeof e||!t||t.showIndex;return i?(0,lU.jsx)(g0,{change:t,segment:e},n):null})})}let g5=e=>{let{checkProperty:t=!1,checkPropertyKey:n,document:i,parent:r,value:l}=e,a=d6(l),o=Nj(),s=function(e,t,n){let{currentUser:i,document:r,parent:l,value:a}=n,o=(0,lK.useRef)(!1);return(0,lK.useMemo)(()=>{var n;let s=!1;if("boolean"==typeof e||void 0===e)return e||!1;try{s=e({document:r,parent:l,value:a,currentUser:i})}catch(e){return console.error("An error occurred while running the callback from `".concat(t,"`: ").concat(e.message)),!1}return cc(n=s)&&"function"==typeof(null==n?void 0:n.then)&&!o.current?(console.warn("The `".concat(t,"` option is either a promise or a promise returning function. Async callbacks for `").concat(t,"` option is not currently supported.")),!1):(void 0===s&&console.warn("The `".concat(t,"` option is or returned `undefined`. `").concat(t,"` should return a boolean.")),s)},[e,r,l,a,i,t])}(t,n,{currentUser:o,document:i,parent:r,value:a});return s},g6=(0,lK.createContext)({path:[]});function g8(e,t){let{jsonType:n}=t,i=Array.isArray(e)?"array":typeof e;if(null!==e&&"undefined"!==i){var r;if(i!==n)return{message:"Value is ".concat(i,", expected ").concat(n),value:e};if("object"===t.jsonType&&null!==(r=e)&&!Array.isArray(r)&&"object"==typeof r)for(let n of t.fields){let t=g8(e[n.name],n.type);if(t)return t}}}function g9(e,t){let n=(0,lV.ay)(t)?t._type:Array.isArray(t)?"array":null===t?"null":typeof t,i=e.of.find(e=>e.name===n);return i||(1===e.of.length?e.of[0]:void 0)}let g7=[["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï "],["ï¡","ï¢"],["ï£","ï¤"],["ï¥","ï¦"],["ï§","ï¨"],["ï©","ïª"],["ï«","ï¬"],["ï®","ï¯"],["ï°","ï±"],["ï²","ï³"],["ï´","ïµ"],["ï¶","ï·"],["ï¸","ï¹"],["ïº","ï»"],["ï¼","ï½"],["ï¾","ï¿"],["ï","ï"],["ï","ï"],["ï","ï
"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"]],xe=[["ï","ï"],["ï","ï"],["ï","ï
"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï","ï"],["ï ","ï¡"]],xt=["ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï","ï ","ï¡","ï¢","ï£","ï¤","ï¥","ï¦","ï§","ï¨","ï©","ïª","ï«","ï¬","ï","ï®","ï¯","ï°","ï±","ï²","ï³","ï´","ïµ","ï¶","ï·","ï¸","ï¹","ïº","ï»","ï¼","ï½","ï¾","ï¿"],xn=new sv.diff_match_patch,xi=xe.map(e=>e[0]).concat(g7.map(e=>e[0])),xr=xe.map(e=>e[1]).concat(g7.map(e=>e[1])),xl=xi.concat(xr).concat(xt).concat("ï").concat("â "),xa=RegExp("".concat(xl.join("|")),"g"),xo=RegExp("".concat(xl.join("|"),"|\n"),"g");function xs(e){return"object"===e.jsonType&&"block"===e.name}function xd(e,t){let n=e.fields.children;return n.items.filter(e=>e.diff.isChanged&&(e.diff.toValue===t||e.diff.fromValue===t)).map(e=>e.diff).map(e=>e)[0]}function xc(e,t){let n=e.find(e=>"children"===e.name),i=n&&n.type&&"array"===n.type.jsonType&&n.type.of.find(e=>e.name===t._type)||void 0;return i}function xu(e){return e.decorators?sx()(e.decorators,["value"],["asc"]):[]}function xp(e,t){return xu(t).some(t=>t.value===e)}function xh(e,t,n,i,r){return t?t.children.map(t=>{var l;let a=(0,lV.NG)(t)?null==(l=t.text)?void 0:l.replace(xa,""):"";if((0,lV.NG)(t)){let r=xm(e,t),l=null==r?void 0:r.fields.text;l&&l.toValue===t.text&&"string"===l.type&&"unchanged"!==l.action&&(a=l.segments.filter(e=>"removed"!==e.action).map(e=>
1e.text.replace(xa,"")).join("â ")),t.marks&&t.marks.forEach(e=>{let t=!!n[e];t?a="".concat(n[e][0]).concat(a).concat(n[e][1]):i[e]&&(a="".concat(i[e][0]).concat(a).concat(i[e][1]))})}else a=r[t._key];return"".concat("ï").concat(a)}).join(""):""}function xf(e){let t=[...e.toValue?e.toValue.children.filter(e=>"span"!==e._type):[]],n=e.fromValue?e.fromValue.children.filter(e=>"span"!==e._type):[];return n.forEach(e=>{t.some(t=>e._key===t._key)||t.push(e)}),sx()(t,["_key"],["asc"])}function xm(e,t){let n=e.fields.children&&"unchanged"!==e.fields.children.action&&"array"===e.fields.children.type&&e.fields.children.items.find(e=>e.diff&&"object"===e.diff.type&&("removed"===e.diff.action?e.diff.fromValue&&e.diff.fromValue._key===t._key:(e.diff.toValue&&e.diff.toValue._key)===t._key));if(n)return n.diff}function xg(e){return e&&aU()(Object.keys(e),["_key","_type"])||!1}function xx(e){let t=[...e.toValue&&e.toValue.markDefs?e.toValue.markDefs:[]],n=e.fromValue&&e.fromValue.markDefs?e.fromValue.markDefs:[];return n.forEach(e=>{t.some(t=>e._key===t._key)||t.push(e)}),sx()(t,["_key"],["asc"])}let xv=[];function xb(e){let{checked:t,color:n}=e;return(0,lU.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 17 17",xmlns:"http://www.w3.org/2000/svg",fill:null==n?void 0:n.background,children:[(0,lU.jsx)("rect",{x:"0",y:"0",width:"17",height:"17",rx:"2.5"}),void 0===t&&(0,lU.jsx)("path",{d:"M4.07996 8.5H12.92",stroke:null==n?void 0:n.text,strokeWidth:"2"}),t&&(0,lU.jsx)("path",{d:"M3.5 8L7 11.5L13.5 5",stroke:null==n?void 0:n.text,strokeWidth:"2"})]})}function xy(e){let{checked:t,color:n}=e;return(0,lU.jsxs)("svg",{width:"38",height:"22",viewBox:"0 0 38 22",xmlns:"http://www.w3.org/2000/svg",children:[(0,lU.jsx)("rect",{width:"38",height:"22",rx:"11",fill:t?null==n?void 0:n.border:null==n?void 0:n.background}),void 0===t&&(0,lU.jsx)("rect",{x:"11",y:"3",width:"16",height:"16",rx:"8",fill:"white"}),t&&(0,lU.jsx)("rect",{x:"18",y:"3",width:"16",height:"16",rx:"8",fill:"white"}),"boolean"==typeof t&&!t&&(0,lU.jsx)("rect",{x:"4",y:"3",width:"16",height:"16",rx:"8",fill:"white"})]})}var xj=Object.freeze,xw=Object.defineProperty;let xk=aW.ZP.div(tC||(tC=xj(xw(u=["\n display: inline-block;\n word-wrap: break-word;\n"],"raw",{value:xj(u.slice())})))),xC=function(e){let{value:t,schemaType:n}=e;return(0,lU.jsx)(lY.xu,{as:xk,paddingX:2,paddingY:1,children:function(e,t){let{options:n,name:i}=t,r=(null==n?void 0:n.dateFormat)||"YYYY-MM-DD",l=(null==n?void 0:n.timeFormat)||"HH:mm";return sb.W(new Date(e),"date"===i?r:"".concat(r," ").concat(l))}(t,n)})},x_=e=>{let{diff:t,schemaType:n}=e;return(0,lU.jsx)(bj,{align:"center",diff:t,layout:"grid",previewComponent:xC,schemaType:n})},xS=(0,lK.createContext)(null);function xT(){let e=(0,lK.useContext)(xS);if(!e)throw Error("DocumentChange: missing context value");return e}function xE(e){let[t,n]=(0,lK.useState)(void 0),i=Ni(fC);return(0,lK.useEffect)(()=>{if(!e)return;let t=i.observable.getDocument(e).subscribe(n);return()=>{t.unsubscribe()}},[i,e]),e?t:void 0}var xP=Object.freeze,xA=Object.defineProperty;let xO=aW.ZP.div(t_||(t_=xP(xA(p=["\n ","\n &:not([hidden]) {\n display: inline-block;\n }\n\n [data-number='positive'] {\n color: var(--size-diff-positive);\n }\n\n [data-number='negative'] {\n color: var(--size-diff-negative);\n }\n"],"raw",{value:xP(p.slice())}))),e=>{let{theme:t}=e;return"\n --size-diff-positive: ".concat(t.sanity.color.solid.positive.enabled.bg,";\n --size-diff-negative: ").concat(t.sanity.color.solid.critical.enabled.bg,";\n ")});function xz(e,t){let n=(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e)||[]).slice(1).map(e=>parseInt(e,16)).concat(t);return"rgba(".concat(n.join(", "),")")}function xM(e){let{crop:t,diff:n,hash:i,hotspot:r,width:l=100,height:a=100,...o}=e,s=gq(n,"crop"),d=gq(n,"hotspot");return(0,lU.jsxs)("svg",{...o,fill:"none",width:l,height:a,viewBox:"0 0 ".concat(l," ").concat(a),children:[(0,lU.jsx)("defs",{children:t&&r&&(0,lU.jsxs)("mask",{id:"mask-hotspot-".concat(i),children:[(0,lU.jsx)("rect",{x:0,y:0,width:l,height:a,fill:"#fff"}),(0,lU.jsx)(xR,{hotspot:r,fill:"#000",offset:1,width:l,height:a,stroke:"#000",strokeWidth:3})]})}),t&&(0,lU.jsx)(gN,{diff:n,path:"crop",description:"Crop changed",children:(0,lU.jsx)("g",{children:(0,lU.jsx)(xI,{crop:t,fill:xz
1(s.border,.25),mask:r?"url(#mask-hotspot-".concat(i,")"):void 0,stroke:s.border,strokeWidth:1,width:l,height:a})})}),r&&(0,lU.jsx)(gN,{diff:n,path:"hotspot",description:"Hotspot changed",children:(0,lU.jsx)("g",{children:(0,lU.jsx)(xR,{hotspot:r,fill:xz(d.border,.25),stroke:d.border,strokeWidth:1,width:l,height:a})})})]})}function xI(e){let{crop:t,width:n,height:i,...r}=e,l={x:t.left*n,y:t.top*i,width:(1-t.right-t.left)*n,height:(1-t.bottom-t.top)*i};return(0,lU.jsx)("rect",{...r,...l,style:{vectorEffect:"non-scaling-stroke"}})}function xR(e){let{hotspot:t,offset:n=0,width:i,height:r,...l}=e,a={cx:t.x*i,cy:t.y*r,rx:t.width/2*i+n,ry:t.height/2*r+n};return(0,lU.jsx)("ellipse",{...l,...a,style:{vectorEffect:"non-scaling-stroke"}})}var xF=Object.freeze,xD=Object.defineProperty,xZ=(e,t)=>xF(xD(e,"raw",{value:xF(t||e.slice())}));let xL=["originalFilename"],xq=()=>(0,lU.jsx)(lY.Zb,{flex:1,tone:"transparent",padding:4,radius:2,height:"stretch",children:(0,lU.jsx)(lY.kC,{align:"center",justify:"center",height:"fill",children:(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:"(no image)"})})}),xN=aW.ZP.div(tS||(tS=xZ(["\n height: 100%;\n max-height: 190px;\n position: relative;\n\n /* Ideally the checkerboard component currently in the form builder should be made available and used here */\n background-color: ",";\n background-image: linear-gradient(45deg, "," 25%, transparent 25%),\n linear-gradient(-45deg, "," 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, "," 75%),\n linear-gradient(-45deg, transparent 75%, "," 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n\n &::after {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n box-shadow: inset 0 0 0 1px var(--card-border-color);\n pointer-events: none;\n }\n\n &[data-changed] {\n opacity: 0.45;\n }\n"])),a8.VG.gray[100].hex,a8.VG.gray[50].hex,a8.VG.gray[50].hex,a8.VG.gray[50].hex,a8.VG.gray[50].hex),xV=aW.ZP.img(tT||(tT=xZ(["\n display: block;\n flex: 1;\n min-height: 0;\n object-fit: contain;\n width: 100%;\n height: 100%;\n\n &[data-action='removed'] {\n opacity: 0.45;\n }\n"]))),xU=aW.ZP.div(tE||(tE=xZ(["\n svg {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n"])));function xB(e){var t,n,i,r;let{id:l,action:a,diff:o,hotspot:s,crop:d,is:c}=e,u=Ni(fC),[p,h]=lK.useState(),{value:f}=function(e,t){let n=UY(),i=(0,lK.useMemo)(()=>e?n.observePaths({_type:"reference",_ref:e},t):(0,lQ.of)(void 0),[e,n,t]);return c_(i)}(l,xL),m=(0,o2.pz)(l),g=(0,lK.useMemo)(()=>o1()(u),[u]),x=null===f,v=f&&f.originalFilename||"Untitled",b=g.image(l).height(190).dpr(function(){let e=Math.ceil(window.devicePixelRatio||1);return Math.min(3,Math.max(1,e))}()).fit("max"),y=(null==(n=null==(t=o.fromValue)?void 0:t.asset)?void 0:n._ref)!==(null==(r=null==(i=o.toValue)?void 0:i.asset)?void 0:r._ref),j="changed"===a?void 0:a;return(0,lU.jsxs)(lY.kC,{direction:"column",height:"fill",flex:1,children:[(0,lU.jsx)(lY.xu,{flex:1,padding:2,paddingBottom:0,children:(0,lU.jsxs)(lY.kC,{as:xN,direction:"column","data-changed":"from"===c&&y?"":void 0,"data-error":p?"":void 0,children:[!x&&!p&&(0,lU.jsx)(xV,{src:b.toString()||"",alt:v,"data-action":j,onError:h,width:m.width,height:m.height}),(x||p)&&(0,lU.jsx)(lY.xu,{paddingY:5,children:(0,lU.jsx)(lY.xv,{size:1,muted:!0,align:"center",children:x?"Image is deleted":"Error loading image"})}),(0,lU.jsx)(xU,{children:(0,lU.jsx)(xM,{crop:d&&!(0,o2.aM)(d)?d:void 0,diff:o,hash:function(e){let t=0;if(0==e.length)return t.toString();for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);t=(t<<5)-t+i,t&=t}return t.toString()}("".concat(b.toString()||"","-").concat(c)),hotspot:s&&!(0,o2.Rq)(s)?s:void 0,width:m.width,height:m.height})})]})}),(0,lU.jsx)(b8,{title:v,icon:a0.XBm,markRemoved:y&&"from"===c,children:j?(0,lU.jsx)("div",{children:j}):(0,lU.jsxs)("div",{children:[m.width," \xd7 ",m.height]})})]})}let xK=["asset","crop","hotspot"],xH={flex:1};var xW=Object.freeze,x$=Object.defineProperty;let xX=aW.ZP.div(tP||(tP=xW(x$(h=["\n display: inline-block;\n word-break: break-all;\n"],"raw",{value:xW(h.slice())})))),xG=e=>{let{value:t}=e;return(0,lU.jsx)(lY.xu,{as:xX,paddingX:2,paddingY:1,children:t})};var xY=Object.freeze,xJ=Object.defineProperty;let xQ=aW.ZP.blockquote(tA||(tA=xY(xJ(f=["\n margin: 0;\n"],"raw",{value:xY(f.slice())}))));function x0(e){let{children:t}=e;return(0,lU.jsx)("div",{children:(0,lU.jsx)(xQ,{children:t})})}var x1=Object.freeze,x2=Object.defineProperty;let x3={h1:2,h2:1,h3:0,h4:0,h5:0,h6:0},x4=(0,aW.ZP)(lY.X6)(tO||(tO=x1(x2(m=["\n &:not([hidden]) {\n display: inline;\n text-transform: none;\n margin: 0;\n\n &::before,\n &::after {\n content: unset;\n }\n }\n"],"raw",{value:x1(m.slice())}))));function x5(e){let{style:t,children:n}=e;return(0,lU.jsx)(x4,{size:x3[t],children:n})}var x6=Object.freeze,x8=Object.defineProperty;let x9=aW.ZP.div(tz||(tz=x6(x8(g=["\n text-transform: none;\n white-space: wrap;\n overflow-wrap: break-word;\n margin: 0;\n"],"raw",{value:x6(g.slice())}))));function x7(e){let{children:t}=e;return(0,lU.jsx)(x9,{children:t})}let ve=[];function vt(e){var t,n,i;let r;let{diff:l,block:a,children:o}=e,s=gq(l,ve),{path:d}=(0,lK.useContext)(g6),{onSetFocus:c}=(0,lK.useContext)(d4),u="removed"===l.action,p=o,h=(0,lK.useCallback)(e=>{e.stopPropagation(),u||c(d)},[d,u,c]);if(p="blockquote"===a.style?(0,lU.jsx)(x0,{children:p}):a.style&&(0,lV.DG)(a)&&a.style&&["h1","h2","h3","h4","h5","h6"].includes(a.style)?(0,lU.jsx)(x5,{style:a.style,children:p}):(0,lU.jsx)(x7,{children:p}),"changed"===l.origin.action&&l.origin.fields.style&&"changed"===l.origin.fields.style.action&&l.origin.fields.style.annotation){r=null==(n=null==(t=null==l?void 0:l.origin)?void 0:t.fromValue)?void 0:n.style;let e=s?{background:s.background,color:s.text}:{};p=(0,lU.jsx)(lY.Zb,{padding:3,border:!0,radius:2,style:{borderStyle:"dotted"},"diff-block-action":l.action,"data-block-note":"changed_from_style_".concat(r||"undefined"),children:(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(gN,{annotations:[null==(i=l.origin.fields.style)?void 0:i.annotation],diff:l.origin.fields.style,children:(0,lU.jsxs)(lY.xv,{size:0,children:["Changed block style from '",r,"' to '",a.style,"'"]})}),(0,lU.jsx)(lY.xu,{style:e,children:p})]})})}return(0,lU.jsx)("div",{onClick:h,"data-diff-block-action":l.action,"data-block-note":"changed_from_style_".concat(r||"undefined"),children:p})}var vn=Object.freeze,vi=Object.defineProperty,vr=(e,t)=>vn(vi(e,"raw",{value:vn(t||e.slice())}));let vl=(0,aW.ZP)(lY.xu)(tM||(tM=vr(["\n &:not([hidden]) {\n display: inline;
1\n align-items: center;\n\n &[data-changed] {\n cursor: pointer;\n }\n }\n"]))),va=(0,aW.ZP)(lY.xv)(tI||(tI=vr(["\n &:not([hidden]) {\n display: inline;\n color: inherit;\n }\n"]))),vo=(0,aW.ZP)(lY.xu)(tR||(tR=vr(["\n &:not([hidden]) {\n display: inline-flex;\n align-items: center;\n\n ",' [data-ui="Text"] {\n opacity: 0.5;\n }\n }\n'])),vl),vs=(0,aW.ZP)(lY.xu)(tF||(tF=vr(["\n min-width: 160px;\n max-height: 40vh;\n overflow-y: auto;\n"])));var vd=Object.freeze,vc=Object.defineProperty;let vu=aW.ZP.div(tD||(tD=vd(vc(x=["\n text-decoration: none;\n display: inline;\n position: relative;\n border: 0;\n padding: 0;\n border-bottom: 2px dotted currentColor;\n box-shadow: inset 0 0 0 1px var(--card-border-color);\n white-space: nowrap;\n align-items: center;\n background-color: color(var(--card-fg-color) a(10%));\n\n &[data-changed] {\n cursor: pointer;\n }\n\n &[data-removed] {\n text-decoration: line-through;\n }\n\n &:hover "," {\n opacity: 1;\n }\n"],"raw",{value:vd(x.slice())}))),vo);function vp(e){let{children:t,diff:n,object:i,schemaType:r,path:l,...a}=e;return r?n&&"unchanged"!==n.action?(0,lU.jsx)(vh,{...a,diff:n,object:i,schemaType:r,path:l,children:t}):(0,lU.jsx)(vu,{children:t}):(0,lU.jsx)(vu,{...a,children:"Unknown schema type"})}function vh(e){let{diff:t,children:n,object:i,schemaType:r,path:l,...a}=e,{onSetFocus:o}=(0,lK.useContext)(d4),{path:s}=(0,lK.useContext)(g6),[d,c]=(0,lK.useState)(null),u=gq(t,[]),p=(0,lK.useMemo)(()=>u?{background:u.background,color:u.text}:{},[u]),h="removed"===t.action,[f,m]=(0,lK.useState)(!1),g=i&&xg(i),x=(0,lK.useMemo)(()=>[l[0]].concat(["markDefs",{_key:i._key}]),[i._key,l]),v=(0,lK.useMemo)(()=>s.slice(0,s.findIndex(e=>(0,lV.Fd)(e)&&e._key===i._key)),[s,i._key]),b=(0,lK.useMemo)(()=>v.concat(l),[l,v]),y=(0,lK.useMemo)(()=>v.concat(x),[x,v]),j="field-".concat((0,lB.BB)(y)),w=d2(),k=(0,lK.useMemo)(()=>w.filter(e=>{let[t]=e;return t.startsWith(j)}).length>0,[j,w]);(0,lK.useEffect)(()=>{!f&&k&&(m(!0),o(y))},[k,y,o,f]);let C=(0,lK.useCallback)(e=>{e.stopPropagation(),m(!0),h||(e.preventDefault(),o(b),setTimeout(()=>o(y),10))},[b,h,y,o]),_=(0,lK.useCallback)(()=>{k||m(!1)},[k]);(0,lY.O8)(_,[d]);let S="unchanged"!==t.action&&t.annotation||null,T=(0,lK.useMemo)(()=>S?[S]:[],[S]),E=(0,lU.jsx)(g6.Provider,{value:{path:y},children:(0,lU.jsx)(vs,{padding:3,children:(0,lU.jsxs)("div",{children:[g&&(0,lU.jsxs)(lY.__,{size:1,muted:!0,children:["Empty ",r.title]}),!g&&(0,lU.jsx)(bG,{diff:t,schemaType:r})]})})});return(0,lU.jsx)(vu,{...a,onClick:C,style:p,"data-changed":"","data-removed":"removed"===t.action?"":void 0,children:(0,lU.jsx)(lY.J2,{content:E,open:f,ref:c,portal:!0,children:(0,lU.jsx)(vo,{paddingLeft:1,children:(0,lU.jsx)(gN,{annotations:T,description:"".concat(t.action," annotation"),children:(0,lU.jsxs)(vl,{style:{display:"inline-flex"},children:[(0,lU.jsx)("span",{children:n}),(0,lU.jsx)(lY.kC,{align:"center",paddingX:1,children:(0,lU.jsx)(va,{size:0,children:(0,lU.jsx)(a0.v4q,{})})})]})})})})})}var vf=Object.freeze,vm=Object.defineProperty;let vg=aW.ZP.span(tZ||(tZ=vf(vm(v=["\n display: inline;\n ","\n"],"raw",{value:vf(v.slice())}))),e=>{let{theme:t,decoration:n}=e;switch(n){case"strong":return"font-weight: bold;";case"em":return"font-style: italic;";case"underline":return"text-decoration: underline;";case"overline":return"text-decoration: overline;";case"strike-through":return"text-decoration: line-through;";case"code":return"\n font-family: ".concat(t.sanity.fonts.code.family,";\n background: ").concat(t.sanity.color.muted.default.enabled.bg,";\n ");default:return""}});function vx(e){let{mark:t,children:n}=e;return(0,lU.jsx)(vg,{decoration:t,children:n})}var vv=Object.freeze,vb=Object.defineProperty;let vy=(0,aW.ZP)(lY.Zb)(tL||(tL=vv(vb(b=["\n &:not([hidden]) {\n display: inline;\n cursor: pointer;\n white-space: nowrap;\n align-items: center;\n\n &[data-removed] {\n text-decoration: line-through;\n }\n\n "," {\n display: inline-flex;\n }\n }\n"],"raw",{value:vv(b.slice())}))),vl);function vj(e){let{diff:t,object:n,schemaType:i,...r}=e;return i?t?(0,lU.jsx)(vw,{...r,diff:t,object:n,schemaType:i}):(0,lU.jsx)(vy,{children:(0,lU.jsx)(zB,{schemaType:i,value:n,layout:"inline"})}):(0,lU.jsxs)(vy,{...r,border:!0,radius:1,children:["Unknown schema type: ",n._type]})}function vw(e){let{diff:t,object:n,path:i,schemaType:r,...l}=e,{path:a}=(0,lK.useContext)(g6),{onSetFocus:o}=(0,lK.useContext)(d4),s=gq(t,[]),d=(0,lK.useMemo)(()=>s?{background:s.background,color:s.text}:{},[s]),[c,u]=(0,lK.useState)(!1),p=n&&xg(n),h="removed"===t.action,f=
1a.slice(0,a.findIndex(e=>(0,lV.Fd)(e)&&e._key===n._key)),m=f.concat(i),g="field-".concat((0,lB.BB)(m)),x=d2(),v=x.filter(e=>{let[t]=e;return t.startsWith(g)}).length>0,b=a.slice(0,-1).concat(i).concat([lB.Zg]);(0,lK.useEffect)(()=>{v&&(u(!0),o(b))},[b,v,o]);let y=(0,lK.useCallback)(e=>{if(e.stopPropagation(),u(!0),!h){o(b);return}e.preventDefault()},[b,h,o]),j=(0,lK.useCallback)(()=>{u(!1)},[]),w=(0,lU.jsx)(g6.Provider,{value:{path:m},children:(0,lU.jsx)(vk,{diff:t,emptyObject:p,onClose:j,schemaType:r})}),k="unchanged"!==t.action&&t.annotation||null,C=k?[k]:[];return(0,lU.jsx)(vy,{...l,onClick:y,style:d,"data-removed":"removed"===t.action?"":void 0,border:!0,radius:2,children:(0,lU.jsx)(lY.J2,{content:w,open:c,portal:!0,children:(0,lU.jsx)(vo,{children:(0,lU.jsx)(gN,{annotations:C,description:"".concat(t.action," inline object"),children:(0,lU.jsxs)(vl,{children:[(0,lU.jsx)(zB,{schemaType:r,value:n,layout:"inline"}),(0,lU.jsx)(lY.kC,{align:"center",paddingX:1,children:(0,lU.jsx)(va,{size:0,children:(0,lU.jsx)(a0.v4q,{})})})]})})})})})}function vk(e){let{diff:t,emptyObject:n,onClose:i,schemaType:r}=e,[l,a]=(0,lK.useState)(null),o=(0,lK.useCallback)(()=>{i()},[i]);return(0,lY.O8)(o,[l]),(0,lU.jsxs)(vs,{ref:a,padding:3,children:[n&&(0,lU.jsxs)(lY.__,{size:1,muted:!0,children:["Empty ",r.title]}),!n&&(0,lU.jsx)(bG,{diff:t,schemaType:r})]})}function vC(e){let{diff:t,childDiff:n,children:i,path:r,segment:l,...a}=e,o=t||n,s=o&&"unchanged"!==o.action&&"unchanged"!==l.action;return s?(0,lU.jsx)(v_,{...a,childDiff:n,diff:t,segment:l,path:r,children:i}):(0,lU.jsx)(vl,{children:i})}function v_(e){let{diff:t,childDiff:n,children:i,path:r,segment:l,...a}=e,{onSetFocus:o}=lK.useContext(d4),{path:s}=lK.useContext(g6),d=(0,lK.useMemo)(()=>r.slice(-2,1)[0],[r]),c=t&&"removed"===t.action,u=s.slice(0,s.findIndex(e=>(0,lV.Fd)(e)&&(0,lV.Fd)(d)&&e._key===d._key)),p=u.concat(r),h=(0,lK.useCallback)(e=>{e.stopPropagation(),c||(e.preventDefault(),o(p))},[p,c,o]),f=t&&t.segments.find(e=>e.text===l.text),m=f||t||n,g=m&&"unchanged"!==m.action&&m.annotation||null,x=g&&"unchanged"!==l.action?(0,lU.jsx)(g$,{annotation:g,as:"removed"===l.action?"del":"ins",tooltip:{description:"".concat(ol()(l.action)," text")},children:i}):null;return(0,lU.jsx)(vl,{...a,onClick:h,"data-changed":"",children:(0,lU.jsx)("span",{children:(0,lU.jsx)(lU.Fragment,{children:x||i})})})}let vS=xe.map(e=>e[0]),vT=xe.map(e=>e[1]),vE=g7.map(e=>e[0]),vP=g7.map(e=>e[1]),vA=vS.concat(vE),vO=vT.concat(vP),vz=vS.concat(vT),vM=RegExp("".concat(vz.concat(vO).join("|")),"g");function vI(e){let{diff:t,schemaType:n}=e,i=t.origin.toValue||t.origin.fromValue,r=(0,lK.useMemo)(()=>t.origin.toValue?xf(t.origin):[],[t.origin]),l=(0,lK.useCallback)(e=>{let l=xc(n.fields,e),a=[];if(l){let e;a=xu(l);let o=t.fields.children,s=o.items[0].diff&&"object"===o.items[0].diff.type&&"string"===o.items[0].diff.fields.text.type&&o.items[0].diff.fields.text.segments||[],d=[],c={};if(1===i.children.length&&"span"===i.children[0]._type&&"string"==typeof i.children[0].text&&""===i.children[0].text&&"unchanged"!==t.origin.action&&("added"===t.origin.action||"removed"===t.origin.action)){let e=xd(t.origin,i.children[0])||t.origin;if(e&&"unchanged"!==e.action)return(0,lU.jsx)(g$,{annotation:e.annotation,as:"removed"===e.action?"del":"ins",tooltip:{description:"".concat(ol()(e.action)," empty text")},children:(0,lU.jsx)("span",{children:"â²"})},"empty-block-".concat(i._key))}let u=-1,p=-1,h=[],f=xx(t.origin);return s.forEach(o=>{var s,m,g,x,v,b,y;p++;let j=xt.includes(o.text),w=vA.includes(o.text),k=vO.includes(o.text),C="ï"===o.text,_="removed"===o.action;if(C)!_&&u++;else if(w||k){if(w&&vE.includes(o.text)){let e=f[vE.indexOf(o.text)];e&&h.push({mark:e._key,symbols:[o.text,vP[vE.indexOf(o.text)]],object:e})}k&&vP.includes(o.text)&&(e=h.pop())}else if(j){let e=xt.findIndex(e=>e===o.text),l=null==(s=r[e])?void 0:s._key,a=r[e];if(l){let e=xc(n.fields,a),r=xd(t.origin,a);d.push((0,lU.jsx)(vj,{object:a,path:[{_key:i._key},"children",{_key:a._key}],diff:r,schemaType:e},"inline-object-".concat(a._key)))}}else if(o.text){let n=i.children[u]||(null==(x=t.origin.fromValue)?void 0:x.children.find(e=>e.text&&e.text.match(o.text.replace(/[-[\]{}
1()*+?.,\\^$|#\s]/g,"\\$&")))),r=n&&xm(t.origin,n);if(!n)throw Error("Could not find child");let s=(null==(m=null==r?void 0:r.fields)?void 0:m.text)?null==(g=null==r?void 0:r.fields)?void 0:g.text:void 0,f=(0,lU.jsx)(vC,{diff:s,path:[{_key:i._key},"children",{_key:n._key}],childDiff:r,segment:o,children:function(e){let{diff:t,child:n,decoratorTypes:i,seg:r,segIndex:l,spanSchemaType:a}=e;if("\n"===r.text)return(0,lU.jsx)("br",{});let o=(0,lU.jsx)("span",{children:r.text.replace(/ /g,"â")},"text-".concat(l)),s=n&&xm(t.origin,n),d=(0,lV.NG)(n)&&n.marks||[];return s&&(o=function(e){var t;let{activeMarks:n,decoratorTypes:i,diff:r,children:l,seg:a,segIndex:o,spanDiff:s,spanSchemaType:d}=e,c=(0,lU.jsx)("span",{children:l},"text-segment-".concat(o)),u=r.origin.fromValue&&r.fromValue&&r.fromValue.children[0].text||"",p=s&&"unchanged"!==s.action&&s.annotation||void 0,h=null==(t=null==s?void 0:s.fields)?void 0:t.marks,f=h&&"unchanged"!==h.action&&h.annotation||p,m=[],g=u.split("ï").filter(e=>!!e).join(""),x=g.substring(0,g.indexOf(a.text)+a.text.length),v=x.substring(0,x.indexOf(a.text)),b=[],y=[...v.matchAll(vM)];return y.forEach(e=>{var t;let n=e[0],r=xe.concat(g7).find(e=>e.indexOf(n)>-1);if(r){let e=n===r[0],l=(null==(t=i[e?vS.indexOf(n):vT.indexOf(n)])?void 0:t.value)||n,a=v.lastIndexOf(n)>v.lastIndexOf(r[1]);a&&b.push(l)}}),m=sC()(n,sa()(b)),f&&m.length>0&&m.some(e=>xp(e,d))&&(c=(0,lU.jsx)(g$,{annotation:f,as:"ins",tooltip:{description:"Changed formatting"},children:c},"diffcard-annotation-".concat(o,"-").concat(m.join("-")))),c}({activeMarks:d,decoratorTypes:i,diff:t,children:o,seg:r,segIndex:l,spanDiff:s,spanSchemaType:a})),d&&d.length>0&&d.forEach(e=>{xp(e,a)&&(o=(0,lU.jsx)(vx,{mark:e,children:o},"decorator-".concat(e,"-").concat(n._key,"-").concat(l)))}),o}({diff:t,child:n,decoratorTypes:a,seg:o,segIndex:p,spanSchemaType:l})},"text-".concat(n._key,"-").concat(p));if(h.length>0&&h.forEach(e=>{c[e.mark]=c[e.mark]||[],c[e.mark].push(f)}),e){let r="annotation-".concat(e.object._key),a=d[d.length-1];if(a&&a.key!==r){let a=(v=t.origin,b=e.mark,v.fields.markDefs&&v.fields.markDefs.isChanged&&"array"===v.fields.markDefs.type&&(null==(y=v.fields.markDefs.items.find(e=>e.diff&&"object"===e.diff.type&&(e.diff.toValue&&e.diff.toValue._key&&e.diff.toValue._key===b||e.diff.fromValue&&e.diff.fromValue._key&&e.diff.fromValue._key===b)))?void 0:y.diff)||void 0),o=e&&l.annotations&&l.annotations.find(t=>e&&e.object&&t.name===e.object._type);d.push((0,lU.jsx)(vp,{object:e.object,diff:a,path:[{_key:i._key},"children",{_key:n._key}],schemaType:o,children:(0,lU.jsx)(lU.Fragment,{children:c[e.mark]})},r))}e=void 0}0===h.length&&d.push(f)}}),lK.createElement("div",{key:i._key},...d)}throw Error("'span' schemaType not found")},[i,t,r,n]);return(0,lU.jsx)(vt,{block:t.displayValue,diff:t,children:(0,lU.jsx)(lU.Fragment,{children:(t.displayValue.children||[]).map(e=>l(e))})})}var vR=Object.freeze,vF=Object.defineProperty;let vD=aW.ZP.div(tq||(tq=vR(vF(y=["\n word-wrap: break-word;\n"],"raw",{value:vR(y.slice())})))),vZ=e=>{let{value:t,schemaType:n}=e;return(0,lU.jsx)(lY.xu,{as:vD,padding:2,children:(0,lU.jsx)(zB,{schemaType:n,value:t,layout:"default"})})};var vL=Object.freeze,vq=Object.defineProperty;let vN=aW.ZP.div(tN||(tN=vL(vq(j=["\n display: inline-block;\n word-break: break-all;\n white-space: pre-wrap;\n"],"raw",{value:vL(j.slice())})))),vV=e=>{let{value:t}=e;return(0,lU.jsx)(lY.xu,{as:vN,paddingX:2,paddingY:1,children:t})};var vU=Object.freeze,vB=Object.defineProperty;let vK=aW.ZP.div(tV||(tV=vU(vB(w=["\n white-space: pre-wrap;\n word-wrap: break-word;\n"],"raw",{value:vU(w.slice())})))),vH={block:e=>{let{diff:t,schemaType:n}=e,i=(0,lK.useMemo)(()=>(function(e,t){let n="removed"===e.action?e.fromValue:e.toValue,i={...e,origin:e,displayValue:n};if(n){let r={},l={},a={},o=xc(t.fields,{_key:"bogus",_type:"span"});o&&xu(o).forEach((e,t)=>{l[e.value]=xe[t]});let s=xx(i.origin);s.forEach((e,t)=>{r[e._key]=g7[t]});let d=xf(i.origin);d.forEach((e,t)=>{a[e._key]=xt[t]});let c=xh(i.origin,i.fromValue,l,r,a),u=xh(i.origin,i.toValue,l,r,a),p={...n,children:[{_type:"span",_key:"pseudoSpanKey",text:u,marks:[]}]},h={displayValue:n,children:[{_type:"span",_key:"pseudoSpanKey",text:c,marks:[]}]},f={origin:e,action:"changed",type:"object",displayValue:p,fromValue:h,toValue:p,isChanged:!0,fields:{children:{action:"changed",type:"array",isChanged:!0,items:[{diff:{action:"changed",type:"object",isChanged:!0,fields:{text:{type:"string",action:"changed",isChanged:!0,fromValue:c,toValue:u,segments:(function(e,t){let n=[],i=xn.diff_main(e,t);xn.diff_cleanupEfficiency(i);let r=0,l=0;for(let[a,o]of i)switch(a){case sv.DIFF_EQUAL:n.push({type:"stringSegment",action:"unchanged",text:o}),r+=o.length,l+=o.length;break;
1case sv.DIFF_DELETE:n.push({type:"stringSegment",action:"removed",text:e.substring(r,r+o.length),annotation:null}),r+=o.length;break;case sv.DIFF_INSERT:n.push({type:"stringSegment",action:"added",text:t.substring(l,l+o.length),annotation:null}),l+=o.length}return om()(n.map(e=>{let t=[];if(e.text.length>1){let n=[...e.text.matchAll(xo)],i=-1;n.forEach(r=>{let l=r.index||0;l>i&&(t.push({...e,text:e.text.substring(i+1,l)}),t.push({...e,text:r[0]})),r===n[n.length-1]&&t.push({...e,text:e.text.substring(l+1)}),i=l}),0===n.length&&t.push(e)}else t.push(e);return t}))})(c,u).map(e=>({...e,..."unchanged"!==i.action&&i.annotation?{annotation:i.annotation}:{}}))}},fromValue:h.children[0],toValue:p.children[0]},annotation:null,fromIndex:0,toIndex:0,hasMoved:!1}],fromValue:h.children,toValue:p.children}}};return f}throw Error("Can not display this diff")})(t,n),[t,n]);return(0,lU.jsx)("div",{"data-diff-action":t.action,children:(0,lU.jsx)(vI,{diff:i,schemaType:n})})},boolean:{component:e=>{let{diff:t,schemaType:n}=e,{fromValue:i,toValue:r}=t,{title:l,options:a}=n,o=(null==a?void 0:a.layout)==="checkbox"?xb:xy,s=gq(t,[]),d=null!=r;return(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(gN,{diff:t,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(o,{checked:i,color:s}),d&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{marginX:2,children:(0,lU.jsx)(ba,{})}),(0,lU.jsx)(o,{checked:r,color:s})]})]})}),d&&l&&(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:l})})]})},showHeader:!1},date:x_,datetime:x_,file:e=>{let{diff:t,schemaType:n}=e,{fromValue:i,toValue:r,fields:l}=t,a=null==i?void 0:i.asset,o=null==r?void 0:r.asset,s=xE(null==a?void 0:a._ref),d=xE(null==o?void 0:o._ref),c=Object.entries(l).filter(e=>{let[t,n]=e;return n.isChanged&&"_type"!==t}).map(e=>{let[t]=e;return t}),u=c.includes("asset"),p=n.fields.filter(e=>"asset"!==e.name&&c.includes(e.name)).map(e=>e.name),h=(null==s?void 0:s.size)&&s.size/1e3/1e3,f=(null==d?void 0:d.size)&&d.size/1e3/1e3,m=h&&f?Math.round((f-h)/h*100):0,g=h?h.toFixed(2):void 0,x=f?f.toFixed(2):void 0,v=(0,lK.useMemo)(()=>({display:"block",flex:1}),[]),b=s&&(0,lU.jsx)(g$,{as:"del",diff:t,path:"asset._ref",style:v,children:(0,lU.jsx)(b8,{title:s.originalFilename||"Untitled",icon:a0.$lS,children:(0,lU.jsx)(lY.xv,{size:0,style:{color:"inherit"},children:"".concat(g,"MB")})})}),y=d&&(0,lU.jsx)(g$,{as:"ins",diff:t,path:"asset._ref",style:v,children:(0,lU.jsx)(b8,{title:d.originalFilename||"Untitled",icon:a0.$lS,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xv,{size:0,style:{color:"inherit"},children:"".concat(x,"MB")}),0!==m&&(0,lU.jsx)(lY.Zb,{radius:2,padding:1,as:xO,marginLeft:2,children:(0,lU.jsxs)(lY.xv,{size:0,"data-number":m>0?"positive":"negative",children:[m>0&&"+",m,"%"]})})]})})}),j=(0,lU.jsxs)(lU.Fragment,{children:[b&&!y&&(0,lU.jsx)(gN,{diff:t,path:"asset._ref",description:"Removed",children:b}),b&&y&&(0,lU.jsx)(gN,{diff:t,path:"asset._ref",children:(0,lU.jsx)(bb,{from:b,layout:"grid",to:y})}),!b&&y&&(0,lU.jsx)(gN,{diff:t,path:"asset._ref",description:"Added",children:y})]});return(0,lU.jsxs)(lU.Fragment,{children:[u&&j,p.length>0&&(0,lU.jsx)(lY.xu,{marginTop:u?4:3,children:(0,lU.jsx)(bG,{diff:t,schemaType:n,fields:p})})]})},image:e=>{var t,n;let{diff:i,schemaType:r}=e,{fromValue:l,toValue:a,fields:o,isChanged:s}=i,d=null==(t=null==l?void 0:l.asset)?void 0:t._ref,c=null==(n=null==a?void 0:a.asset)?void 0:n._ref,u=gZ(i,["asset","_ref"]),p=Object.keys(o).filter(e=>o[e].isChanged&&"_type"!==e),h=r.fields.filter(e=>!xK.includes(e.name)&&p.includes(e.name)).map(e=>e.name),f="changed";!d&&c?f="added":!c&&d&&(f="removed");let m=p.includes("asset"),g=p.includes("crop"),x=p.includes("hotspot"),v=g||x,b=m||v,y=v&&!m,j=l&&d?(0,lU.jsx)(g$,{annotation:u,style:xH,children:(0,lU.jsx)(xB,{is:"from",id:d,diff:i,action:f,hotspot:y&&x?l.hotspot:void 0,crop:y&&g?l.crop:void 0})}):(0,lU.jsx)(xq,{}),w=a&&c?(0,lU.jsx)(g$,{annotation:u,style:xH,children:(0,lU.jsx)(xB,{is:"to",id:c,diff:i,hotspot:y&&x?a.hotspot:void 0,crop:y&&g?a.crop:void 0})}):(0,lU.jsx)(xq,{});if(!j&&!w)return(0,lU.jsx)(lY.Zb,{padding:4,radius:2,tone:"transparent",children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,align:"center",children:"Image not set"})});if(!s)return c?(0,lU.jsx)(g$,{annotation:u,style:xH,children:(0,lU.jsx)(xB,{id:c,is:"to",diff:i})}):null;let k=(0,lU.jsx)(bb,{align:"center",from:j,layout:"grid",to:w});return(0,lU.jsxs)(lU.Fragment,{children:[b&&(m?(0,lU.jsx)(gN,{annotations:u?[u]:[],description:"".concat(f[0].toUpperCase()).concat(f.slice(1)),children:k}):k),h.length>0&&(0,lU.jsx)(lY.xu,{marginTop:b?4:3,children:(0,lU.jsx)(bG,{diff:i,schemaType:r,fields:h})})]})},number:e=>{let{diff:t,schemaType:n}=e;return(0,lU.jsx)(bj,{diff:t,schemaType:n,previewComponent:xG,layout:"inline"})},reference:e=>{let{diff:t,schemaType:n}=e;return(0,lU.jsx)(bj,{align:"center",diff:t,layout:"grid",path:"_ref",previewComponent:vZ,schemaType:n})},string:e=>{let{diff:t,schemaType:n}=e,{options:i}=n;return(null==i?void 0:i.list)?(0,lU.jsx)(bj,{diff:t,previewComponent:vV,schemaType:n}
1):(0,lU.jsx)(vK,{children:(0,lU.jsx)(b3,{diff:t})})}};function vW(e,t){var n;let i=e;for(;i;){let e=(null==(n=null==i?void 0:i.components)?void 0:n.diff)||function(e,t){let n;for(let i of xv){if("function"!=typeof i){console.error("Diff component resolver is not a function: ",i);continue}if(n=i({schemaType:e,parentSchemaType:t}))return n}}(i,t)||vH[i.name];if(e)return e;i=i.type}let r=["date","datetime"].includes(e.name),l=r?e.name:e.jsonType;return vH[l]}function v$(e){return"field"===e.type}function vX(e){return null!=e&&""!==e}function vG(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},l=vW(e,r.parentSchema);if(!l){if("object"===e.jsonType&&"object"===t.type)return vY(e,t,n,i,r);if("array"===e.jsonType&&"array"===t.type)return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=t.items.filter(e=>e.hasMoved&&e.fromIndex!==e.toIndex||"unchanged"!==e.diff.action);if(0===r.length)return[];let l=e.of.some(xs),a=r.reduce((r,a)=>{var o;let s="added"===(o=a.diff).action?{toType:g9(e,o.toValue)}:"changed"===o.action?{fromType:g9(e,o.fromValue),toType:g9(e,o.toValue)}:"removed"===o.action?{fromType:g9(e,o.fromValue)}:{toType:g9(e,o.toValue)},d=s.toType||s.fromType;if(!d)return console.warn("Could not determine schema type for item at %s",gO(n)),r;let c=gF(a.diff.fromValue)||gF(a.diff.toValue)||t.items.indexOf(a),u=n.concat(c),p={itemDiff:a,parentDiff:t,parentSchema:e},h=i.concat({hasMoved:a.hasMoved,toIndex:a.toIndex,fromIndex:a.fromIndex,annotation:"unchanged"===a.diff.action?a.annotation:a.diff.annotation}),f=vG(d,a.diff,u,h,p).map(e=>("field"===e.type&&gI(u,e.path)&&(e.itemDiff=a),e));return l&&f.filter(v$).forEach((e,t,n)=>{e.showHeader=1===n.length,e.showIndex=a.fromIndex!==a.toIndex&&a.hasMoved}),0===f.length?r.push(...vJ(d,a.diff,u,h,p)):r.push(...f),r},[]);return a.length>1?[{type:"group",key:gO(n)||"root",path:n,titlePath:i,changes:vQ(a,i.length),schemaType:e}]:a}(e,t,n,i)}return vJ(e,t,n,i,r)}function vY(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},l=[],a={...r,parentSchema:e},o=e.fieldsets||e.fields.map(e=>({single:!0,field:e}));for(let e of o)e.single?l.push(...function(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},{fieldFilter:l,...a}=r,o=t.fields[e.name];if(!o||!o.isChanged||l&&!l.includes(e.name))return[];let s=n.concat([e.name]),d=i.concat([e.type.title||e.name]);return vG(e.type,o,s,d,a)}(e.field,t,n,i,a)):l.push(...function(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},{fields:l,name:a,title:o,readOnly:s,hidden:d}=e,{fieldFilter:c,...u}=r,p=i.concat([o||a]),h=[];for(let e of l){let i=t.fields[e.name];if(!i||!i.isChanged||c&&!c.includes(e.name))continue;let r=n.concat([e.name]),l=p.concat([e.type.title||e.name]);h.push(...vG({readOnly:s,hidden:d,...e.type},i,r,l,u))}return h.length<2?h:[{type:"group",key:gO(n)||"root",fieldsetName:a,path:n,titlePath:p,changes:vQ(h,p.length),readOnly:s,hidden:d}]}(e,t,n,i,a));return l.length<2?l:[{type:"group",key:gO(n)||"root",path:n,titlePath:i,changes:vQ(l,i.length),schemaType:e}]}function vJ(e,t,n,i){let r,l,{itemDiff:a,parentDiff:o,parentSchema:s}=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},{fromValue:d,toValue:c,type:u}=t;if("array"===u&&v0(d)&&v0(c))return[];void 0!==d&&(r=g8(d,e)),r||void 0===c||(r=g8(c,e));let p=!0,h=vW(e,s);return h&&"function"==typeof h?l=h:h&&(l=h.component,p=void 0===h.showHeader?p:h.showHeader),[{type:"field",diff:t,path:n,error:r,itemDiff:a,parentDiff:o,titlePath:i,schemaType:e,showHeader:p,showIndex:!0,key:gO(n)||"root",diffComponent:r?void 0:l,parentSchema:s}]}function vQ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.map(e=>(e.titlePath=e.titlePath.slice(t),e))}function v0(e){return Array.isArray(e)&&0===e.length||null==e}let v1=e=>"field"===e.type&&"added"===e.diff.action,v2=e=>{if("group"!==e.type)return[e];let t=[];
1return e.changes.forEach(e=>{t.push(...v2(e))}),t},v3=(e,t)=>{if(t.length>=e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0},v4=(e,t)=>{let n=e[t],i=gR(n);if(i)return{_key:i};let r=Array.isArray(e);return r?parseInt(t,10):t},v5={diffMatchPatch:{enabled:!1}};function v6(e,t,n){if(!t)return;let i=[];if("group"===e.type){let r=v2(e),l=r.filter(v1);r.filter(e=>!v1(e)).forEach(e=>v6(e,t,n)),i.push(...v8(t,l.map(e=>e.path)))}else"added"===e.diff.action?i.push(...v8(t,[e.path])):"field"===e.type&&e.itemDiff&&e.parentDiff&&"array"===e.parentDiff.type&&e.itemDiff.hasMoved?i.push(...function(e,t,n){let i;let r=n.slice(0,-1),{parentValue:l,fromIndex:a,fromValue:o}=function(e,t){if(e.fromValue&&"number"==typeof t.fromIndex){let n=e.fromValue[t.fromIndex];return{parentValue:e.fromValue,fromIndex:t.fromIndex,fromValue:n}}throw Error("Failed to find item at index ".concat(t.fromIndex))}(t,e);if(0===a)i={before:gO([...r,0])};else{let e=a-1,t=gF(l[e]),n=t||e;i={after:gO([...r,n])}}return[{unset:[gO(n)]},{insert:{...i,items:[o]}}]}(e.itemDiff,e.parentDiff,e.path)):i.push(...function(e,t,n){let i=(0,sE.C)(e.toValue,e.fromValue,v5,n),r=i.filter(e=>"insert"===e.op).map(e=>{let{after:t,items:n}=e;return{insert:{after:gO(t),items:n}}}),l=i.filter(e=>"unset"===e.op).reduce((e,t)=>e.concat(gO(t.path)),[]),a=new Set,o=[],s=!1,d=i.filter(e=>"set"===e.op).reduce((e,n)=>(s=!0,o.push(...function(e,t,n){let i=t.fromValue,r=t.toValue,l=[];for(let t=1;t<=e.length;t++){let a=e.slice(0,t),o=gO(a);if(n.has(o))continue;let s=e[t],d=(0,lV.Fd)(s)||(0,lV.dw)(s),c=gz(i,a),u=v9(c);if(d&&Array.isArray(c)&&!gz(r,e.slice(0,t+1))){let e=function(e,t){return"number"==typeof t||(0,lV.Fd)(t)?"number"==typeof t?t:e.findIndex(e=>(0,lV.fU)(e)&&e._key===t._key):-1}(c,s),n=c[e-1],r=gz(i,a.concat(s)),d=(0,lV.fU)(n)?{_key:n._key}:e-1,u=gO(a.concat(e<1?0:d));l.push({setIfMissing:{[o]:[]}}),l.push({insert:{after:u,items:[v9(r)]}}),t++;continue}void 0!==u&&(n.add(o),l.push({setIfMissing:{[o]:u}}))}return l}(n.path,t,a)),e[gO(n.path)]=n.value,e),{});return[...o,...r,...l.length>0?[{unset:l}]:[],...s?[{set:d}]:[]]}(e.diff,t,e.path));n.patch.execute(i)}function v8(e,t){let n=[];for(let i=0;i<t.length;i++){let r=n.some(e=>v3(t[i],e));r||n.push(function(e,t,n){let i=e.toValue;return function e(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3?arguments[3]:void 0;if(n.length<=0){if(!r)throw Error("Root has no ancestor");return r}let l=n.slice(0,-1),a=gz(t,l),o=[l,...i.filter(e=>!v3(e,l))];return!function e(t,n,i){let r=null==i?void 0:i.some(e=>gO(e)===gO(n)),l=Array.isArray(t)&&t.length<=0;return r||null==t||l||"object"==typeof t&&null!==t&&Object.keys(t).length<=0||function(t,n,i){if(!cc(t)||!Array.isArray(t))return!1;for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||"_type"===r||"_key"===r)continue;let l=[...n,v4(t,r)];if(!e(t[r],l,i))return!1}return!0}(t,n,i)}(a,l,i)?n:e(t,l,o,r)}(i,t,n)}(e,t[i],t))}return[{unset:[...new Set(n.map(gO))]}]}function v9(e){if(Array.isArray(e))return[];if("object"!=typeof e||null===e)return;let t={};return(0,lV.fU)(e)&&(t._key=e._key),(0,lV.ay)(e)&&(t._type=e._type),t}let v7=(0,lK.createContext)(null),be=!1;var bt=Object.defineProperty,bn=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bi=(e,t,n)=>(bn(e,"symbol"!=typeof t?t+"":t,n),n);class br extends lK.Component{constructor(){super(...arguments),bi(this,"state",{})}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error("Error rendering diff component: "),console.error(e)}render(){let{error:e}=this.state;return e?(0,lU.jsx)(lY.Zb,{padding:3,radius:2,tone:"critical",children:(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.uIy,{})}),(0,lU.jsxs)(lY.xu,{paddingLeft:3,children:[(0,lU.jsx)(lY.xv,{as:"h3",size:1,weight:"medium",children:"Rendering the changes to this field caused an error"}),be&&(0,lU.jsx)(lY.xu,{marginTop:2,children:(0,lU.jsx)(lY.xv,{as:"p",size:1,children:"Check the developer console for more information"})})]})]})}):this.props.children}}let bl={down:a0.veu,right:a0.LZ3};function ba(e){let{direction:t="right",...n}=e,i=bl[t];return(0,lU.jsx)(lY.xv,{muted:!0,size:1,...n,children:(0,lK.createElement)(i)})}var bo=Object.freeze,bs=Object.defineProperty,bd=(e,t)=>bo(bs(e,"raw",{value:bo(t||e.slice())}));let bc=aW.ZP.pre(tU||(tU=bd(["\n overflow-x: auto;\n position: relative;\n"]))),bu=aW.ZP.div(tB||(tB=bd(["\n position: absolute;\n top: 0;\n right: 0;\n"])));function bp(e){let{children:t,as:n,change:i,...r}=e,l=(0,lK.useRef)(!1),[a,o]=(0,lK.useState)(!1),s=(0,lK.useCallback)(()=>o(e=>!e),[o]),d=(0,lK.useCallback)(()=>l.current=!0,[]),c=(0,lK.useCallback)(()=>l.current=!1,[l]);return(0,lK.useEffect)(()=>{function e(e){let{metaKey:t,key:n}=e;t&&"i"===n&&l.current&&s()}return window.addEventListener("keydown",e,!1),()=>window.removeEventListener("keydown",e,!1)},[s]),(0,lU.jsx)(lY.xu,{as:n,onMouseEnter:d,onMouseLeave:c,...r,children:a?(0,lU.jsx)(bf,{change:i}):t})}let bh=e=>{let{title:t}=e;return(0,lU.jsx)(lY.xu,{padding:3,display:"inline-block",as:bu,children:(0,lU.jsx)(lY.__,{size:1,muted:!0,children:t})})};function bf(e){var t,n,i;let{change:r}=e;return(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.Zb,{padding:3,tone:"transparent",as:bc,radius:1,children:[(0,lU.jsx)(bh,{title:"meta"}),(0,lU.jsx)(lY.EK,{language:"json",size:1,children:function(e){let t=[];
1return Object.entries(e).forEach(e=>{let[n,i]=e;null!=i&&t.push("".concat(n,": ").concat(i))}),t.join("\n")}({path:gO(r.path),fromIndex:null==(t=r.itemDiff)?void 0:t.fromIndex,toIndex:null==(n=r.itemDiff)?void 0:n.toIndex,hasMoved:null==(i=r.itemDiff)?void 0:i.hasMoved,action:r.diff.action,isChanged:r.diff.isChanged})})]}),(0,lU.jsxs)(lY.Zb,{as:bc,tone:"critical",padding:3,radius:1,children:[(0,lU.jsx)(bh,{title:"from"}),(0,lU.jsx)(lY.EK,{language:"json",size:1,children:bm(r.diff.fromValue)})]}),(0,lU.jsx)(lY.Zb,{children:(0,lU.jsx)(ba,{direction:"down",align:"center"})}),(0,lU.jsxs)(lY.Zb,{as:bc,tone:"positive",padding:3,radius:1,children:[(0,lU.jsx)(bh,{title:"to"}),(0,lU.jsx)(lY.EK,{language:"json",size:1,children:bm(r.diff.toValue)})]})]})}function bm(e){return void 0===e?"undefined":JSON.stringify(e,null,2)}let bg={flexShrink:0},bx={alignItems:"stretch"},bv={top:"flex-start",center:"center",bottom:"flex-end",default:"flex-start"},bb=(0,lK.forwardRef)(function(e,t){let{align:n="top",layout:i="inline",from:r,to:l,style:a,...o}=e,s=(0,lY.Fg)(),d="inline"===i?lY.kC:lY.rj,c=(0,lK.useMemo)(()=>({...a,..."inline"===i?{maxWidth:"100%",display:"inline-flex"}:{gridTemplateColumns:"minmax(0, 1fr) ".concat((0,lY.hO)(s.sanity.space[5])," minmax(0, 1fr)")}}),[i,a,s]),u="inline"===i?bg:bx;return(0,lU.jsxs)(d,{...o,ref:t,style:c,"data-from-to-layout":!0,children:[r&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.kC,{align:bv[n],style:u,children:r}),(0,lU.jsx)(lY.kC,{align:"center",justify:"center",padding:2,children:(0,lU.jsx)(ba,{})})]}),(0,lU.jsx)(lY.kC,{align:bv[n],style:u,children:l})]})}),by={flex:1,minWidth:0,display:"block",whiteSpace:"break-spaces"};function bj(e){let{align:t,cardClassName:n,diff:i,layout:r,path:l,previewComponent:a,schemaType:o}=e,{action:s}=i,d=function(e){let t=vX(e.fromValue),n=vX(e.toValue);return!t&&n?"Added":!n&&t?"Removed":"Changed"}(i);if("unchanged"===s)return(0,lU.jsx)(g$,{className:n,style:by,children:(0,lK.createElement)(a,{schemaType:o,value:i.toValue})});let c=void 0!==i.fromValue&&null!==i.fromValue&&(0,lU.jsx)(g$,{as:"del",className:n,diff:i,path:l,style:by,children:(0,lK.createElement)(a,{schemaType:o,value:i.fromValue})}),u=void 0!==i.toValue&&null!==i.toValue&&(0,lU.jsx)(g$,{as:"ins",className:n,diff:i,path:l,style:by,children:(0,lK.createElement)(a,{schemaType:o,value:i.toValue})});return c&&!u?(0,lU.jsx)(gN,{description:d,diff:i,path:l,children:c}):!c&&u?(0,lU.jsx)(gN,{description:d,diff:i,path:l,children:u}):(0,lU.jsx)(gN,{description:d,diff:i,path:l,children:(0,lU.jsx)(bb,{align:t,from:c,layout:r,to:u})})}let bw=e=>{let{value:t,schemaType:n}=e;return(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(zB,{schemaType:n,value:t,layout:"default"})})},bk=e=>{let{diff:t,schemaType:n}=e;return(0,lU.jsx)(bj,{diff:t,schemaType:n,previewComponent:bw,layout:"grid"})};var bC=Object.freeze,b_=Object.defineProperty;let bS=(0,aW.ZP)(lY.zx)(tK||(tK=bC(b_(k=["\n [data-ui='Text'] {\n font-weight: normal;\n }\n\n div[data-ui='Box'] {\n display: none;\n }\n\n &:not([data-disabled='true']):hover,\n &:not([data-disabled='true']):focus {\n --card-fg-color: ",";\n --card-bg-color: transparent;\n --card-border-color: transparent;\n\n div[data-ui='Box'] {\n display: block;\n }\n }\n"],"raw",{value:bC(k.slice())}))),e=>{let{theme:t}=e;return t.sanity.color.solid.critical.enabled.bg}),bT=(0,lK.forwardRef)(function(e,t){let{selected:n,...i}=e;return(0,lU.jsx)(bS,{icon:a0.V13,selected:n,text:"Revert changes",mode:"bleed",padding:1,fontSize:1,space:2,ref:t,...i})});function bE(e){let{error:t}=e;return(0,lU.jsx)(lY.Zb,{tone:"critical",padding:3,children:(0,lU.jsxs)(lY.kC,{align:"flex-start",children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.uIy,{})})}),(0,lU.jsx)(lY.xu,{flex:1,paddingLeft:3,children:(0,lU.jsxs)(lY.xv,{size:1,as:"p",children:["Value error: ",t.message]})})]})})}var bP=Object.freeze,bA=Object.defineProperty,bO=(e,t)=>bP(bA(e,"raw",{value:bP(t||e.slice())}));let bz=aW.ZP.div(tH||(tH=bO(["\n --field-change-error: ",";\n &[data-revert-all-changes-hover] [data-revert-all-hover]::before {\n border-left: 2px solid var(--field-change-error);\n }\n"])),e=>{let{theme:t}=e;return t.sanity.color.solid.critical.enabled.bg}),bM=aW.ZP.div(tW||(tW=bO(["\n --field-change-error: ",";\n --diff-inspect-padding-xsmall: ",";\n --diff-inspect-padding-small: ",";\n\n position: relative;\n padding: var(--diff-inspect-padding-xsmall) 0 var(--diff-inspect-padding-xsmall)\n var(--diff-inspect-padding-small);\n\n &::before {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n border-left: 1px solid var(--card-border-color);\n }\n\n &[data-error]:hover::before,\n &[data-revert-field-hover]:hover::before {\n border-left: 2px solid var(--field-change-error);\n }\n"])),e=>{let{theme:t}=e;return t.sanity.color.solid.critical.enabled.bg},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.space[1])},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.space[2])}),bI=(0,aW.ZP)(lY.J2)(t$||(t$=bO(["\n /* hides the popover when the target of it has left the visible part of the window.\n without it, the popover will be on top of the headers (document title & changes)\n and footers (changed notifications, publish button etc)*/\n &[data-popper-reference-hidden='true'] {\n display: none;\n }\n"])));function bR(e){var t,n;let{change:i,hidden:r,readOnly:l}=e,a=null!=(t=function(){let e=(0,lK.useContext)(v7);return e&&e.readOnly||null}())?t:l,o=i.diffComponent||bk,{documentId:s,schemaType:d,rootDiff:c,isComparingCurrent:u,FieldWrapper:p=lK.Fragment}=xT(),h=No(s,d.name),[f,m]=(0,lK.useState)(!1),[g,x]=(0,lK.useState)(!1),[v,b]=(0,lK.useState)(null),[y,j]=VA({id:s,type:d.name,permission:"update"}),w=(0,lK.useCallback)(()=>{v6(i,c,h)},[i,c,h]),k=(0,lK.useCallback)(()=>{m(!0)},[]),C=lK.useCallback(()=>{m(!1)},[]),_=(0,lK.useCallback)(()=>{x(!0)},[]),S=(0,lK.useCallback)(()=>{x(!1)},[]),T=(0,lK.useCallback)(()=>m(!1),[]);(0,lY.O8)(T,[v]);let E=(null==(n=i.parentSchema)?void 0:n.jsonType)==="array",P=E?i.path.slice(0,-1):i.path,A=(0,lK.useMemo)(()=>r?null:(0,lU.jsxs)(lY.Kq,{space:1,as:bz,children:[i.showHeader&&(0,lU.jsx)(g4,{change:i,titlePath:i.titlePath}),(0,lU.jsx)(p,{path:P,hasHover:g,children:(0,lU.jsxs)(bp,{change:i,as:bM,"data-revert-field-hover":g?"":void 0,"data-error":i.error?"":void 0,"data-revert-all-hover":!0,children:[i.error?(0,lU.jsx)(bE,{error:i.error}):(0,lU.jsx)(br,{children:(0,lU.jsx)(g6.Provider,{value:{path:i.path},children:(0,lU.jsx)(o,{diff:i.diff,schemaType:i.schemaType})})}),u&&!j&&(null==y?void 0:y.granted)&&(0,lU.jsx)(bI,{content:(0,lU.jsxs)(lY.xu,{padding:3,sizing:"border",children:["Are you sure you want to revert the changes?",(0,lU.jsxs)(lY.rj,{columns:2,gap:2,marginTop:2,children:[(0,lU.jsx)(lY.zx,{mode:"ghost",onClick:C,children:(0,lU.jsx)(lY.xv,{align:"center",children:"Cancel"})}),(0,lU.jsx)(lY.zx,{tone:"critical",onClick:w,children:(0,lU.jsx)(lY.xv,{align:"center",children:"Revert change"})})]})]}),open:f,portal:!0,placement:"left",ref:b,children:(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(bT,{onClick:k,onMouseEnter:_,onMouseLeave:S,selected:f,disabled:a,"data-testid":"single-change-revert-button-".concat(null==i?void 0:i.key)})})})]})})]}),[i,C,a,f,o,p,r,_,S,w,k,u,j,y,g,P]);return A}var bF=Object.freeze,bD=Object.defineProperty,bZ=(e,t)=>bF(bD(e,"raw",{value:bF(t||e.slice())}));let bL=aW.ZP.div(tX||(tX=bZ(["\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n"]))),bq=aW.ZP.div(tG||(tG=bZ(["\n --field-change-error: ",";\n --diff-inspect-padding-xsmall: ",";\n --diff-inspect-padding-small: ",";\n\n position: relative;\n padding: var(--diff-inspect-padding-xsmall) var(--diff-inspect-padding-small);\n\n &::before {\n content: '';\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n border-left: 1px solid var(--card-border-color);\n }\n\n &[data-error]:hover::before,\n &[data-revert-group-hover]:hover::before,\n &[data-revert-all-groups-hover]::before {\n border-left: 2px solid var(--field-change-error);\n }\n"])),e=>{let{theme:t}=e;return t.sanity.color.solid.critical.enabled.bg},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.space[1])},e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.space[2])}),bN=(0,aW.ZP)(lY.J2)(tY||(tY=bZ(["\n /* hides the popover when the target of it has left the visible part of the window.\n without it, the popover will be on top of the headers (document title & changes)\n and footers (changed notifications, publish button etc)*/\n &[data-popper-reference-hidden='true'] {\n display: none;\n }\n"])));function bV(e){let{change:t,readOnly:n,hidden:i,...r}=e,{titlePath:l,changes:a,path:o}=t,{path:s}=(0,lK.useContext)(g6),{documentId:d,schemaType:c,FieldWrapper:u,rootDiff:p,isComparingCurrent:h}=xT(),f=a.every(e=>
1v$(e)&&xs(e.schemaType)),m=gI(s,o),[g,x]=function(){let e=(0,lK.useRef)(null),[t,n]=(0,lK.useState)(!1);return(0,lK.useEffect)(()=>{let t=e.current;if(!t)return()=>void 0;let i=()=>n(!0),r=()=>n(!1);return t.addEventListener("mouseover",i),t.addEventListener("mouseout",r),()=>{t.removeEventListener("mouseover",i),t.removeEventListener("mouseout",r)}},[]),[e,t]}(),v=No(d,c.name),[b,y]=(0,lK.useState)(!1),[j,w]=(0,lK.useState)(null),[k,C]=VA({id:d,type:c.name,permission:"update"}),_=(0,lK.useCallback)(()=>v6(t,p,v),[t,p,v]),S=(0,lK.useCallback)(()=>{y(!0)},[]),T=(0,lK.useCallback)(()=>{y(!1)},[]);(0,lY.O8)(()=>y(!1),[j]);let E=(0,lK.useMemo)(()=>i?null:(0,lU.jsxs)(lY.Kq,{space:1,as:bq,"data-revert-group-hover":x?"":void 0,"data-portable-text":f?"":void 0,children:[(0,lU.jsx)(lY.Kq,{as:bL,space:5,children:a.map(e=>(0,lU.jsx)(bU,{change:e,readOnly:n,hidden:i},e.key))}),h&&!C&&(null==k?void 0:k.granted)&&(0,lU.jsx)(bN,{content:(0,lU.jsxs)(lY.xu,{children:["Are you sure you want to revert the changes?",(0,lU.jsxs)(lY.rj,{columns:2,gap:2,marginTop:2,children:[(0,lU.jsx)(lY.zx,{mode:"ghost",onClick:T,children:(0,lU.jsx)(lY.xv,{align:"center",children:"Cancel"})}),(0,lU.jsx)(lY.zx,{tone:"critical",onClick:_,children:(0,lU.jsx)(lY.xv,{align:"center",children:"Revert change"})})]})]}),portal:!0,padding:4,placement:"left",open:b,ref:w,children:(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(bT,{onClick:S,ref:g,selected:b,disabled:n,"data-testid":"group-change-revert-button-".concat(t.fieldsetName)})})})]}),[a,T,b,n,t.fieldsetName,_,S,i,h,x,C,f,k,g]);return i?null:(0,lU.jsxs)(lY.Kq,{space:1,...r,children:[(0,lU.jsx)(g4,{titlePath:l}),m||!u?E:(0,lU.jsx)(u,{hasHover:x,path:t.path,children:E})]})}function bU(e){var t,n;let{change:i,hidden:r,readOnly:l}=e,{value:a}=xT(),o=g5({document:a,checkProperty:r||(null==(t=i.schemaType)?void 0:t.hidden),checkPropertyKey:"hidden",value:"field"===i.type?i.diff.toValue:void 0}),s=g5({document:a,checkProperty:l||(null==(n=i.schemaType)?void 0:n.readOnly),checkPropertyKey:"readOnly",value:"field"===i.type?i.diff.toValue:void 0});return o?null:"field"===i.type?(0,lU.jsx)(bR,{change:i,readOnly:s}):"group"===i.type?(0,lU.jsx)(bV,{change:i,"data-testid":"group-change-".concat(i.fieldsetName),readOnly:s}):(0,lU.jsxs)(lY.xv,{children:["Unknown change type: ",(0,lU.jsx)("code",{children:i.type||"undefined"})]})}function bB(){return(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",as:"h3",children:"There are no changes"}),(0,lU.jsx)(lY.xv,{as:"p",size:1,muted:!0,children:"Edit the document or select an older version in the timeline to see a list of changes appear in this panel."})]})}var bK=Object.freeze,bH=Object.defineProperty,bW=(e,t)=>bK(bH(e,"raw",{value:bK(t||e.slice())}));let b$=aW.ZP.div(tJ||(tJ=bW(["\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n"]))),bX=(0,aW.ZP)(lY.J2)(tQ||(tQ=bW(["\n /* hides the popover when the target of it has left the visible part of the window.\n without it, the popover will be on top of the headers (document title & changes)\n and footers (changed notifications, publish button etc)*/\n &[data-popper-reference-hidden='true'] {\n display: none;\n }\n"])));function bG(e){let{diff:t,fields:n,schemaType:i}=e,{documentId:r,isComparingCurrent:l,value:a}=xT(),o=No(r,i.name),{path:s}=(0,lK.useContext)(g6),d=0===s.length,[c,u]=(0,lK.useState)(!1),[p,h]=(0,lK.useState)(!1),f=g5({document:a,value:void 0,checkProperty:i.readOnly,checkPropertyKey:"readOnly"});if("object"!==i.jsonType)throw Error("Only object schema types are allowed in ChangeList");let[m,g]=VA({id:r,type:i.name,permission:"update"}),x=(0,lK.useMemo)(()=>vY(i,t,s,[],{fieldFilter:n}),[i,n,s,t]),v=(0,lK.useMemo)(()=>n&&0===n.length?[]:1===x.length&&"group"===x[0].type&&0===x[0].path.length?x[0].changes:x,[x,n]),b=x[0],y=(0,lK.useCallback)(()=>{v6(b,t,o),u(!1)},[b,t,o]),j=(0,lK.useCallback)(()=>{u(!0)},[]),w=(0,lK.useCallback)(()=>{h(!0)},[]),k=(0,lK.useCallback)(()=>{h(!1)},[]),C=(0,lK.useCallback)(()=>{u(!1)},[]),[_,S]=(0,lK.useState)(null),T=(0,lK.useCallback)(()=>u(!1),[]);if((0,lY.O8)(T,[_]),0===v.length)return d?(0,lU.jsx)(bB,{}):null;let E=d&&v.length>1;return(0,lU.jsx)(lY.Zb,{children:(0,lU.jsxs)(lY.Kq,{space:5,children:[(0,lU.jsx)(lY.Kq,{as:b$,space:5,children:v.map(e=>(0,lU.jsx)("div",{children:(0,lU.jsx)(bU,{change:e,"data-revert-all-changes-hover":p?"":void 0,readOnly:f||(null==e?void 0:e.readOnly),hidden:null==e?void 0:e.hidden},e.key)},e.key))}),E&&l&&!g&&(null==m?void 0:m.granted)&&(0,lU.jsx)(bX,{content:(0,lU.jsxs)(lY.xu,{children:["Are you sure you want to revert all ",v.length," changes?",(0,lU.jsxs)(lY.rj,{columns:2,gap:2,marginTop:2,children:[(0,lU.jsx)(lY.zx,{mode:"ghost",text:"Cancel",onClick:C}),(0,lU.jsx)(lY.zx,{tone:"critical",text:"Revert all",onClick:y}
1)]})]}),open:c,padding:4,placement:"left",portal:!0,ref:S,children:(0,lU.jsx)(lY.Kq,{children:(0,lU.jsx)(lY.zx,{tone:"critical",mode:"ghost",text:"Revert all changes",icon:a0.V13,onClick:j,onMouseEnter:w,onMouseLeave:k,disabled:f})})})]})})}var bY=Object.freeze,bJ=Object.defineProperty,bQ=(e,t)=>bY(bJ(e,"raw",{value:bY(t||e.slice())}));let b0=aW.ZP.span(t0||(t0=bQ(["\n border-radius: ",";\n"])),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[1])}),b1=(0,aW.ZP)(lY.xv)(t1||(t1=bQ(["\n &:not([hidden]) {\n display: inline;\n line-height: calc(1.25em + 2px);\n }\n\n &:hover {\n background-color: none !important;\n background-image: linear-gradient(\n to bottom,\n var(--card-bg-color) 0,\n var(--card-bg-color) 33.333%,\n currentColor 33.333%,\n currentColor 100%\n );\n background-size: 1px 3px;\n background-repeat: repeat-x;\n background-position-y: bottom;\n padding-bottom: 3px;\n box-shadow: 0 0 0 1px var(--card-bg-color);\n z-index: 1;\n }\n"])));function b2(e){let{segment:t}=e,{text:n}=t;return"added"===t.action?(0,lU.jsx)(g$,{annotation:t.annotation,disableHoverEffect:!0,tooltip:{description:"Added"},as:b0,children:(0,lU.jsx)(b1,{as:"ins",style:{textDecoration:"none"},children:n})}):"removed"===t.action?(0,lU.jsx)(g$,{annotation:t.annotation,as:b0,disableHoverEffect:!0,tooltip:{description:"Removed"},children:(0,lU.jsx)(b1,{as:"del",children:n})}):(0,lU.jsx)(lY.Zb,{as:"span",radius:2,style:{display:"inline"},children:n})}function b3(e){let{diff:t}=e;return(0,lU.jsx)(lU.Fragment,{children:(t.segments||[]).map((e,t)=>(0,lU.jsx)(b2,{segment:e},t))})}var b4=Object.freeze,b5=Object.defineProperty;let b6=(0,aW.ZP)(lY.xv)(t2||(t2=b4(b5(C=["\n color: inherit;\n"],"raw",{value:b4(C.slice())}))));function b8(e){let{title:t,action:n,icon:i,children:r,markRemoved:l}=e;return(0,lU.jsxs)(lY.kC,{padding:2,align:"center",children:[i&&(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(b6,{size:4,forwardedAs:l?"del":"div",children:(0,lK.createElement)(i)})}),(0,lU.jsxs)(lY.Kq,{space:2,paddingLeft:2,children:[(0,lU.jsx)(b6,{size:1,weight:"semibold",forwardedAs:l?"del":"h3",textOverflow:"ellipsis",children:t}),n&&(0,lU.jsx)("div",{children:n}),(0,lU.jsx)(b6,{size:0,textOverflow:"ellipsis",children:r})]})]})}var b9=Object.freeze,b7=Object.defineProperty;aW.ZP.div(t3||(t3=b9(b7(_=["\n display: inline-block;\n word-break: break-all;\n white-space: pre-wrap;\n"],"raw",{value:b9(_.slice())}))));let ye=(0,lK.createContext)({hoveredStack:[],onMouseEnter:()=>void 0,onMouseLeave:()=>void 0});function yt(){return(0,lK.useContext)(ye)}function yn(e){let{actions:t,children:n,path:i}=e,{onMouseEnter:r,onMouseLeave:l}=yt(),a=yt().hoveredStack[0],o=ck||!!a&&gO(i)===a,s=(0,lK.useCallback)(()=>{r(i)},[r,i]),d=(0,lK.useCallback)(()=>{l(i)},[l,i]),c=(0,lK.useMemo)(()=>({actions:t,hovered:o,onMouseEnter:s,onMouseLeave:d}),[t,s,d,o]);return(0,lU.jsx)(go.Provider,{value:c,children:n})}function yi(e){let{children:t}=e,[n,i]=(0,lK.useState)([]),r=(0,lK.useCallback)(e=>{let t=gO(e);i(e=>e.includes(t)?e:[t,...e])},[]),l=(0,lK.useCallback)(e=>{let t=gO(e);i(e=>e.includes(t)?e.filter(e=>e!==t):e)},[]),a=(0,lK.useMemo)(()=>({hoveredStack:n,onMouseEnter:r,onMouseLeave:l}),[r,l,n]);return(0,lU.jsx)(ye.Provider,{value:a,children:t})}let yr={publish:()=>void 0,subscribe:()=>(console.warn("No patch channel provided to form-builder. If you need input based patch updates, please provide one"),()=>void 0)};function yl(e){let{__internal_fieldActions:t=co,__internal_patchChannel:n=yr,autoFocus:i,changesOpen:r,children:l,collapsedFieldSets:a,collapsedPaths:o,file:s,filterField:d,focusPath:c,focused:u,groups:p,id:h,image:f,members:m,onChange:g,onFieldGroupSelect:x,onPathBlur:v,onPathFocus:b,onPathOpen:y,onSetFieldSetCollapsed:j,onSetPathCollapsed:w,presence:k,readOnly:C,renderAnnotation:_,renderBlock:S,renderField:T,renderInlineBlock:E,renderInput:P,renderItem:A,renderPreview:O,schemaType:z,unstable:M,validation:I,value:R}=e,F=(0,lK.useRef)(R);(0,lK.useEffect)(()=>{F.current=R},[R]);let D=(0,lK.useMemo)(()=>({patchChannel:n,components:{ArrayFunctions:mQ,CustomMarkers:(null==M?void 0:M.
1CustomMarkers)||m6,Markers:(null==M?void 0:M.Markers)||m5},field:{actions:t},file:{assetSources:s.assetSources,directUploads:(null==s?void 0:s.directUploads)!==!1},filterField:d||(()=>!0),image:{assetSources:f.assetSources,directUploads:(null==f?void 0:f.directUploads)!==!1},getDocument:()=>F.current,onChange:g}),[t,s.assetSources,null==s?void 0:s.directUploads,d,f.assetSources,null==f?void 0:f.directUploads,g,n,null==M?void 0:M.CustomMarkers,null==M?void 0:M.Markers]),Z=(0,lK.useMemo)(()=>({__internal:D,autoFocus:i,changesOpen:r,collapsedFieldSets:a,collapsedPaths:o,focusPath:c,focused:u,groups:p,id:h,members:m,readOnly:C,renderAnnotation:_,renderBlock:S,renderField:T,renderInlineBlock:E,renderInput:P,renderItem:A,renderPreview:O,schemaType:z,value:R}),[D,i,r,a,o,R,c,u,p,h,m,C,_,S,T,E,P,A,O,z]);return(0,lU.jsx)(mG.Provider,{value:Z,children:(0,lU.jsx)(m9,{onChange:g,onFieldGroupSelect:x,onPathBlur:v,onPathFocus:b,onPathOpen:y,onSetPathCollapsed:w,onSetFieldSetCollapsed:j,children:(0,lU.jsx)(gn,{presence:k,children:(0,lU.jsx)(gl,{validation:I,children:(0,lU.jsx)(yi,{children:l})})})})})}function ya(e){let{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,children:l,collapsedFieldSets:a,collapsedPaths:o,focusPath:s,focused:d,groups:c,id:u,members:p,onChange:h,onPathBlur:f,onPathFocus:m,onPathOpen:g,onFieldGroupSelect:x,onSetPathCollapsed:v,onSetFieldSetCollapsed:b,presence:y,readOnly:j,schemaType:w,validation:k,value:C}=e,{file:_,image:S}=Iw().form,T=fz({defaultComponent:zP,pick:zF}),E=fz({defaultComponent:zA,pick:zD}),P=zU(),A=fz({defaultComponent:zO,pick:zL}),O=fz({defaultComponent:zM,pick:zq}),z=fz({defaultComponent:zI,pick:zN}),M=fz({defaultComponent:zR,pick:zV}),I=(0,lK.useCallback)(e=>(0,lU.jsx)(T,{...e}),[T]),R=(0,lK.useCallback)(e=>(0,lU.jsx)(E,{...e}),[E]),F=(0,lK.useCallback)(e=>(0,lU.jsx)(A,{...e}),[A]),D=(0,lK.useCallback)(e=>(0,lU.jsx)(fH,{component:P,...e}),[P]),Z=(0,lK.useCallback)(e=>(0,lU.jsx)(O,{...e}),[O]),L=(0,lK.useCallback)(e=>(0,lU.jsx)(z,{...e}),[z]),q=(0,lK.useCallback)(e=>(0,lU.jsx)(M,{...e}),[M]);return(0,lU.jsx)(yl,{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:a,collapsedPaths:o,file:_,focusPath:s,focused:d,groups:c,id:u,image:S,members:p,onChange:h,onPathBlur:f,onPathFocus:m,onPathOpen:g,onFieldGroupSelect:x,onSetPathCollapsed:v,onSetFieldSetCollapsed:b,presence:y,readOnly:j,renderAnnotation:q,renderBlock:Z,renderField:R,renderInlineBlock:L,renderInput:I,renderItem:F,renderPreview:D,schemaType:w,validation:k,value:C,children:l})}function yo(e){let{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:l,collapsedPaths:a,focusPath:o,focused:s,groups:d,id:c,members:u,onChange:p,onPathBlur:h,onPathFocus:f,onPathOpen:m,onFieldGroupSelect:g,onSetFieldSetCollapsed:x,onSetPathCollapsed:v,presence:b,readOnly:y,schemaType:j,validation:w,value:k}=e;return(0,lU.jsx)(ya,{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:l,collapsedPaths:a,focusPath:o,focused:s,groups:d,id:c,members:u,onChange:p,onPathBlur:h,onPathFocus:f,onPathOpen:m,onFieldGroupSelect:g,onSetPathCollapsed:v,onSetFieldSetCollapsed:x,presence:b,validation:w,readOnly:y,schemaType:j,value:k,children:(0,lU.jsx)(ys,{})})}function ys(){let{focusPath:e,focused:t,groups:n,id:i,members:r,readOnly:l,renderAnnotation:a,renderBlock:o,renderField:s,renderInlineBlock:d,renderInput:c,renderItem:u,renderPreview:p,schemaType:h,value:f}=mY(),{onChange:m,onFieldGroupSelect:g,onPathBlur:x,onPathFocus:v,onPathOpen:b,onSetFieldSetCollapsed:y,onSetPathCollapsed:j}=m7(),w=(0,lK.useCallback)(e=>j([e],!0),[j]),k=(0,lK.useCallback)(e=>j([e],!1),[j]),C=(0,lK.useCallback)(()=>x(co),[x]),_=(0,lK.useCallback)(()=>v(co),[v]),S=(0,lK.useCallback)(e=>m(mN.from(e)),[m]),T=(0,lK.useRef)(null),E=(0,lK.useCallback)(e=>g(co,e),[g]),P=(0,lK.useCallback)(e=>b([e]),[b]),A=(0,lK.useCallback)(()=>b([]),[b]),O=(0,lK.useCallback)(e=>y([e],!0),[y]),z=(0,lK.useCallback)(e=>y([e],!1),[y]),M={focusPath:e,elementProps:{ref:T,id:i,onBlur:C,onFocus:_},changed:r.some(e=>"field"===e.kind&&e.field.changed),focused:t,groups:n,id:i,level:0,members:r,onChange:S,onFieldClose:A,onFieldCollapse:w,onFieldSetCollapse:O,onFieldExpand:k,onFieldSetExpand:z,onPathFocus:v,onFieldOpen:P,onFieldGroupSelect:E,path:co,presence:co,readOnly:l,renderAnnotation:a,renderBlock:o,renderField:s,renderInlineBlock:d,renderInput:c,renderItem:u,renderPreview:p,schemaType:h,validation:co,value:f};return(0,lU.jsx)(lU.Fragment,{children:c(M)})}let yd=(0,lK.createContext)({});function yc(){return(0,lK.useContext)(yd)}function yu(e){let{children:t,activePath:n,EditReferenceLinkComponent:i,onEditReference:r,initialValueTemplateItems:l}=e,a=(0,lK.useMemo)(()=>({activePath:n,EditReferenceLinkComponent:i,onEditReference:r,initialValueTemplateItems:l}),[n,i,r,l]);return(0,lU.jsx)(yd.Provider,{value:a,children:t})}function yp(e,t){return m$(t,(0,lK.useCallback)((t,n)=>{e.current&&!t&&n&&(0,sP.Z)(e.current,{scrollMode:"always"})},[e]))}(0,lK.createContext)(null);let yh=()=>
1{if(l)return l;l=[];for(let e=0;e<256;++e)l[e]=(e+256).toString(16).substring(1);return l};function yf(e){let t=yh();return(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=new Uint8Array(e);return(0,sw.Z)(t),t})(e).reduce((e,n)=>e+t[n],"").slice(0,e)}var ym=Object.freeze,yg=Object.defineProperty,yx=(e,t)=>ym(yg(e,"raw",{value:ym(t||e.slice())}));let yv={portal:!0},yb=(0,aW.ZP)(lY.Zb)(e=>{var t;let{theme:n,$selected:i}=e,{color:r}=n.sanity;return(0,aW.iv)(t4||(t4=yx(["\n --card-bg-color: inherit;\n --card-fg-color: inherit;\n --card-hairline-hard-color: ",";\n "])),i?null==(t=r.selectable)?void 0:t.default.pressed.border:void 0)}),yy=(0,aW.ZP)(lY.xu)(t5||(t5=yx(["\n max-width: 150px;\n"]))),yj=e=>1===e.length?"".concat(e[0].user.displayName," is editing this document"):e.length>1?"".concat(e.length," people are editing this document right now"):void 0;function yw(e){let{presence:t}=e,{color:n}=(0,aW.Fg)().sanity,i=n.dark?"light":"dark",{selected:r}=function(){let e=(0,lK.useContext)(uz);if(!e)throw Error("PreviewCard: missing context value");return e}(),l=(0,lK.useMemo)(()=>Array.from(new Set(t.map(e=>e.user.id))).map(e=>t.find(t=>t.user.id===e)).filter(d9),[t]),a=(0,lK.useMemo)(()=>(0,lU.jsx)(yy,{padding:2,children:(0,lU.jsx)(lY.xv,{align:"center",size:1,children:yj(l)})}),[l]);return(0,lU.jsx)(lY.u,{content:a,...yv,children:(0,lU.jsx)(yb,{scheme:r?i:void 0,$selected:r,children:(0,lU.jsx)(lY.Jh,{maxLength:2,"aria-label":yj(l),children:l.map(e=>(0,lU.jsx)(U4,{user:e.user},e.user.id))})})})}let yk=[0,.25,.75,1],yC=(e,t)=>{let n=e.length>t?t-1:t,i=Math.max(0,e.length-n);return[e.slice(0,i),e.slice(i)]};var y_=Object.freeze,yS=Object.defineProperty,yT=(e,t)=>y_(yS(e,"raw",{value:y_(t||e.slice())}));let yE=(0,aW.ZP)(lY.kC)(t6||(t6=yT(["\n & > div:first-child {\n flex: 1;\n min-width: 0;\n }\n"]))),yP=(0,aW.ZP)(lY.kC)(t8||(t8=yT(["\n height: 23px;\n min-width: 23px;\n vertical-align: top;\n"]))),yA=lK.createContext([]);function yO(e){let{children:t,items:n}=e,i=(0,lK.useMemo)(()=>(0,lU.jsx)(lY.Kq,{padding:1,children:n.map(e=>(0,lU.jsxs)(lY.kC,{align:"center",gap:2,padding:1,children:[(0,lU.jsx)("div",{children:(0,lU.jsx)(U4,{user:e.user,status:"online"})}),(0,lU.jsx)(lY.xv,{size:1,children:e.user.displayName})]},e.user.id))}),[n]);return(0,lU.jsx)(lY.u,{content:i,placement:"top",portal:"documentScrollElement",children:t})}let{Tracker:yz,useReporter:yM,useReportedValues:yI}=dQ(),yR=(0,lK.memo)(function(e){let{presence:t,position:n="inside",animateArrowFrom:i="inside",maxAvatars:r=3,stack:l=!0}=e,a=ox()(t||[],e=>e.user.id),o=aX()(a,e=>e.lastActiveAt),[s,d]=l?yC(o,r):[[],o],c=[...d.reverse().map(e=>({key:e.user.id,element:(0,lU.jsx)(U4,{animateArrowFrom:i,position:n,status:"online",user:e.user})})),s.length>=2?{key:"counter",element:(0,lU.jsx)(lY.p2,{count:s.length})}:null].filter(Boolean),u=4+19*r,p=Math.min(4+19*a.length,u);return(0,lU.jsxs)(yE,{justify:"flex-end",style:{width:u},children:[(0,lU.jsx)("div",{}),(0,lU.jsx)(yO,{items:a,children:(0,lU.jsx)(yP,{direction:"row-reverse",style:{width:p},children:c.map((e,t)=>e&&(0,lU.jsx)("div",{style:{position:"absolute",transform:"translate3d(".concat(-(19*t),"px, 0px, 0px)"),transitionProperty:"transform",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.85, 0, 0.15, 1)",zIndex:100-t},children:e.element},e.key))})})]})}),yF=function(e){let t=(0,lK.useContext)(yA),{presence:n=t,maxAvatars:i=3}=e,r=lK.useRef(null);yM((0,lK.useId)(),()=>({presence:n,element:r.current,maxAvatars:i}));let l=4+19*e.maxAvatars;return(0,lU.jsx)(yE,{justify:"flex-end",ref:r,style:{minWidth:l,minHeight:23}})},yD=e=>{let t=new l2.x,n=new IntersectionObserver(e=>{e.forEach(e=>{t.next(e)})},e);return{observe:e=>new l9.y(i=>{let r=t.pipe((0,af.h)(t=>t.target===e)).subscribe(i);return n.observe(e),()=>{r.unsubscribe(),n.unobserve(e)}})}},yZ=e=>{let{onIntersection:t,io:n,id:i,...r}=e,l=lK.useRef(null);return lK.useEffect(()=>{let e=l.current;if(!e)return;
1let r=n.observe(e).pipe((0,as.b)(e=>t(i,e))).subscribe();return()=>r.unsubscribe()},[n,i,t]),(0,lU.jsx)("div",{ref:l,...r})};var yL=Object.freeze,yq=Object.defineProperty,yN=(e,t)=>yL(yq(e,"raw",{value:yL(t||e.slice())}));let yV=aW.ZP.div(t9||(t9=yN(["\n position: relative;\n"]))),yU=aW.ZP.div(t7||(t7=yN(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 13;\n"]))),yB=(0,aW.iv)(ne||(ne=yN(["\n overflow: hidden;\n overflow: clip;\n pointer-events: none;\n position: absolute;\n"]))),yK=(0,aW.ZP)(yZ)(e=>{let{$debug:t,margins:n}=e;return(0,aW.iv)(nt||(nt=yN(["\n ","\n\n z-index: 100;\n position: sticky;\n height: 1px;\n top: ",";\n background-color: ",";\n "])),yB,n?"".concat(n[0]-1,"px"):void 0,t?"red":"none")}),yH=(0,aW.ZP)(yZ)(e=>{let{$debug:t}=e;return(0,aW.iv)(ni||(ni=yN(["\n ","\n\n visibility: none;\n\n ","\n "])),yB,t&&(0,aW.iv)(nn||(nn=yN(["\n background: rgba(255, 0, 0, 0.25);\n outline: 1px solid #00b;\n visibility: visible;\n "]))))}),yW=(0,aW.ZP)(yZ)(e=>{let{$debug:t}=e;return(0,aW.iv)(nr||(nr=yN(["\n ","\n\n position: sticky;\n bottom: -1px;\n height: 1px;\n background-color: ",";\n "])),yB,t?"blue":"transparent")}),y$=e=>"".concat(e,"px"),yX=e=>0-e,yG=(0,lK.forwardRef)(function(e,t){let{regions:n,render:i,children:r,margins:l}=e,a=(0,lK.useRef)(null),o=(0,lK.useMemo)(()=>l,[JSON.stringify(l)]),s=(0,lK.useMemo)(()=>yD({rootMargin:o.map(yX).map(y$).join(" "),threshold:yk}),[o]),[d,c]=(0,lK.useState)({}),u=(0,lK.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]),p=d["::top"],h=d["::bottom"],f=(0,lK.useMemo)(()=>p&&h?n.filter(e=>{var t;return(null==(t=e.presence)?void 0:t.length)>0}).map(e=>{let t=d[e.id];if(!t)return null;let{bottom:n,top:i}=t.boundingClientRect,r=t.boundingClientRect.top<p.boundingClientRect.bottom,l=t.boundingClientRect.top<h.boundingClientRect.top,a=t.isIntersecting?i-(t.intersectionRect.top-23):r?-p.boundingClientRect.bottom:h.boundingClientRect.top,o=t.isIntersecting?-(n-(t.intersectionRect.bottom+23)):l?h.boundingClientRect.top:-p.boundingClientRect.bottom;return{distanceTop:a,distanceBottom:o,region:e,position:a<=8?"top":o<=8?"bottom":"inside"}}).filter(Boolean):[],[h,d,n,p]);return(0,lU.jsxs)(yV,{ref:t,children:[(0,lU.jsx)(yK,{$debug:!1,io:s,id:"::top",onIntersection:u,margins:o}),(0,lU.jsx)("div",{children:r}),(0,lU.jsx)(yU,{ref:a,children:a.current&&i(f,a.current.offsetWidth)}),n.map(e=>{let t=0===e.rect.width;return(0,lU.jsx)(yH,{$debug:!1,io:s,onIntersection:u,id:e.id,style:{width:t?1:e.rect.width,left:e.rect.left-(t?1:0),top:e.rect.top-23,height:e.rect.height+46}},e.id)}),(0,lU.jsx)(yW,{$debug:!1,id:"::bottom",io:s,onIntersection:u})]})}),yY={transitionProperty:"transform",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.85, 0, 0.15, 1)"},yJ=e=>e.top+e.height,yQ=e=>sx()(e,e=>e.region.rect.top),y0=(e,t)=>e+t,y1=e=>e.reduce(y0,0),y2=e=>{let{height:t,...n}=e;return(0,lU.jsx)("div",{style:{height:Math.max(0,t),...null==n?void 0:n.style}})},y3=[0,0,0,0],y4=(e,t)=>{let n=e,i=-n.scrollTop,r=0;for(;n&&n!==t;)i+=n.offsetTop-n.scrollTop,r+=n.offsetLeft,n=n.offsetParent instanceof HTMLElement?n.offsetParent:null;return{top:i,left:r}};function y5(e){let{children:t,margins:n=y3}=e,i=yI(),r=lK.useRef(null),l=lK.useMemo(()=>{var e;return r.current?(e=r.current,i.map(t=>{var n;let[i,r]=t;return{...r,id:i,rect:{...y4(n=r.element,e),width:n.offsetWidth,height:n.offsetHeight}}})):y6},[i]),a=lK.useCallback((e,t)=>{let i=function(e){let t=yQ(e).map((e,t,n)=>{var i;let r=null==(i=n[t-1])?void 0:i.region.rect,l=r?yJ(r):0;return{...e,spacerHeight:e.region.rect.top-l}}),n={top:[],inside:[],bottom:[],...sS()(t,e=>e.position)};return{top:yQ(n.top).map((e,t,n)=>({...e,indent:n.slice(t+1).reduce((e,t)=>e+t.region.rect.width,0)})),inside:yQ(n.inside).map(e=>({...e,indent:0})),bottom:yQ(n.bottom).map((e,t,n)=>({...e,indent:n.slice(0,t).reduce((e,t)=>e+t.region.rect.width,0)}))}}(e.filter(e=>e.region.presence.length>0)),r=y1(i.top.map(e=>e.region.rect.height+e.spacerHeight)),l=y1([...i.inside,...i.bottom].map(e=>e.region.rect.height+e.spacerHeight)),a=i.inside.reduce((e,t)=>
1{let{distanceTop:n,distanceBottom:i}=t;return{nearTop:e.nearTop+(n<=20?t.region.presence.length:0),nearBottom:e.nearBottom+(i<=20?t.region.presence.length:0)}},{nearTop:0,nearBottom:0});return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(y8,{closeCount:a.nearTop,margins:n,position:"top",regionsWithIntersectionDetails:i.top}),(0,lU.jsx)(y2,{height:r}),(0,lU.jsx)(y9,{containerWidth:t,regionsWithIntersectionDetails:i.inside}),(0,lU.jsx)(y2,{height:l}),(0,lU.jsx)(y8,{closeCount:a.nearBottom,margins:n,position:"bottom",regionsWithIntersectionDetails:i.bottom})]})},[n]);return(0,lU.jsx)(yG,{ref:r,margins:n,regions:l,render:a,children:t})}let y6=[],y8=(0,lK.memo)(function(e){let{closeCount:t,margins:n,position:i,regionsWithIntersectionDetails:r}=e,l="top"===i?1:-1,a=(0,lK.useMemo)(()=>r.length?om()(aX()(r,e=>e.region.rect.top*l).map(e=>e.region.presence||y6)):y6,[l,r]),[o,s,d,c]=n,u=(c||0)+(a.length>0?-(19*t):0)-s,p="top"===i?o:d,h=(0,lK.useMemo)(()=>({zIndex:2,position:"sticky",display:"flex",flexDirection:"column",alignItems:"flex-end",...yY,transform:"translate3d(".concat(u,"px, 0px, 0px)"),top:5+p,bottom:5+p}),[u,p]);return(0,lU.jsx)("div",{"data-dock":i,style:h,children:(0,lU.jsx)(yR,{position:i,maxAvatars:3,presence:a})},"sticky-".concat(i))});function y9(e){let{regionsWithIntersectionDetails:t,containerWidth:n}=e;return(0,lU.jsx)(lU.Fragment,{children:t.map(e=>{let t=e.region.rect.left,{distanceTop:i,distanceBottom:r}=e,l=i<=20,a=r<=20,o=n-t-e.region.rect.width,{presence:s,maxAvatars:d}=e.region;return(0,lU.jsx)(lK.Fragment,{children:(0,lU.jsx)("div",{style:{zIndex:2,position:"absolute",pointerEvents:"all",...yY,left:t,transform:"translate3d(".concat(l||a?o:0,"px, 0px, 0px)"),height:e.region.rect.height,top:e.region.rect.top},children:(0,lU.jsx)(y7,{value:()=>"â¤".concat(i," | ").concat(r,"â¤"),children:(0,lU.jsx)(yR,{stack:!l&&!a,position:l?"top":a?"bottom":"inside",maxAvatars:d,presence:s})})})},e.region.id)})})}let y7=e=>e.children,je=[0,0,0,0],jt=function(e){let{children:t,margins:n}=e;return(0,lU.jsx)(yz,{children:(0,lU.jsx)(y5,{margins:n||je,children:t})})};var jn=Object.freeze,ji=Object.defineProperty;let jr=[],jl={error:a8.VG.red[500].hex,warning:a8.VG.yellow[500].hex,info:a8.VG.blue[500].hex},ja={error:(0,lU.jsx)(a0.uIy,{"data-testid":"input-validation-icon-error"}),warning:(0,lU.jsx)(a0.foC,{"data-testid":"input-validation-icon-warning"}),info:(0,lU.jsx)(a0.hQ6,{"data-testid":"input-validation-icon-info"})},jo=(0,aW.ZP)(lY.Kq)(nl||(nl=jn(ji(S=["\n max-width: 200px;\n"],"raw",{value:jn(S.slice())}))));function js(e){let{validation:t=jr,__unstable_showSummary:n,fontSize:i,placement:r="top"}=e,l=t.filter(e=>"error"===e.level),a=t.filter(e=>"warning"===e.level),o=t.filter(e=>"info"===e.level),s=l.length>0,d=a.length>0,c=o.length>0,u=(0,lK.useMemo)(()=>s?ja.error:d?ja.warning:c?ja.info:void 0,[s,c,d]),p=(0,lK.useMemo)(()=>s?jl.error:d?jl.warning:c?jl.info:void 0,[s,c,d]);return(0,lU.jsx)(lY.u,{content:(0,lU.jsxs)(jo,{padding:3,space:3,children:[n&&(0,lU.jsx)(jc,{validation:t}),!n&&(0,lU.jsx)(lU.Fragment,{children:t.map((e,t)=>(0,lU.jsx)(jd,{validation:e},t))})]}),portal:!0,placement:r,fallbackPlacements:["bottom","right","left"],children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.xv,{muted:!0,size:i,weight:"semibold",style:{color:p},children:u})})})}function jd(e){let{validation:t}=e,n=(0,lK.useMemo)(()=>"error"===t.level?ja.error:"warning"===t.level?ja.warning:"info"===t.level?ja.info:void 0,[t]),i=(0,lK.useMemo)(()=>"error"===t.level?jl.error:"warning"===t.level?jl.warning:"info"===t.level?jl.info:void 0,[t]);return(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{marginRight:2,children:(0,lU.jsx)(lY.xv,{size:1,style:{color:i},children:n})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.xv,{size:1,children:t.message})})]})}function jc(e){let{validation:t}=e,n=t.filter(e=>"error"===e.level),i=t.filter(e=>"warning"===e.level),r=n.length,l=i.length,a=r&&"".concat(r," ").concat("error".concat(1===r?"":"s")),o=l&&"".concat(l," ").concat("warning".concat(1===l?"":"s"));return(0,lU.jsxs)(lY.xv,{size:1,children:[a||"",r>0&&l>0&&(0,lU.jsx)(lU.Fragment,{children:" and "}),o||""]})}let ju=[],jp=(0,lK.memo)(function(e){let{description:t,inputId:n,title:i,validation:r=ju}=e,l=r.length>0;return(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xv,{as:"label",htmlFor:n,weight:"semibold",size:1,children:i||(0,lU.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})}),l&&(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(js,{fontSize:1,validation:r})})]}),t&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:t})]})}),jh=(0,aW.ZP)(lY.kC)({lineHeight:1}),jf=(0,lK.memo)(function(e){let{__unstable_actions:t,__unstable_presence:n,description:i,inputId:r,title:l,validation:a}=e;return(0,lU.jsxs)(jh,{align:"flex-end",children:[(0,lU.jsx)(lY.xu,{flex:1,paddingY:2,children:(0,lU.jsx)(jp,{validation:a,description:i,inputId:r,title:l})}),n&&n.length>0&&(0,lU.jsx)(lY.xu,{flex:"none",children:(0,lU.jsx)(yF,{maxAvatars:4,presence:n})}),t&&(0,lU.jsx)(lY.xu,{flex:"none",marginLeft:3,children:t})]})}),jm=(0,lK.memo)(function(e){let{validation:t,__unstable_headerActions:n,__unstable_presence:i,children:r,description:l,inputId:a,level:o,title:s,...d}=e;return(0,lU.jsxs)(lY.Kq,{...d,"data-level":o,space:1,children:[s&&(0,lU.jsx)(jf,{__unstable_actions:n,validation:t,__unstable_presence:i,description:l,inputId:a,title:s}),(0,lU.jsx)("div",{children:r})]})});var jg=Object.freeze,jx=Object.defineProperty,jv=(e,t)=>jg(jx(e,"raw",{value:jg(t||e.slice())}));let jb=aW.ZP.legend(na||(na=jv(["\n /* See: https://thatemil.com/blog/2015/01/03/reset-your-fieldset/ */\n padding: 0;\n display: table;\n"]))),jy=(0,aW.ZP)(lY.kC).attrs({forwardedAs:"button"})(e=>{let{theme:t}=e,{focusRing:n,radius:i}=t.sanity,{base:r}=t.sanity.color;return(0,aW.iv)(no||(no=jv(["\n appearance: none;\n border: 0;\n background: none;\n color: inherit;\n -webkit-font-smoothing: inherit;\n font: inherit;\n outline: none;\n border-radius: ",";\n position: relative;\n\n &:not([hidden]) {\n display: flex;\n }\n\n &:focus {\n box-shadow: ",";\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n\n /* Added to increase the hit area of the collapsible fieldset */\n &::after {\n content: '';\n position: absolute;\n top: -10px;\n right: -10px;\n bottom: -10px;\n left: -10px;\n }
1\n "])),(0,lY.hO)(i[1]),ut({base:r,focusRing:n}))}),jj=(0,aW.ZP)(lY.xu)(ns||(ns=jv(["\n width: 9px;\n height: 9px;\n margin-right: 3px;\n\n & svg {\n transition: transform 100ms;\n }\n"]))),jw=(0,lK.memo)(function(e){let{collapsed:t,collapsible:n,onClick:i,title:r}=e,l=(0,lU.jsx)(lY.xv,{weight:"semibold",size:1,children:r||(0,lU.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})});return n?(0,lU.jsx)(jb,{children:(0,lU.jsxs)(jy,{type:"button",onClick:i,children:[(0,lU.jsx)(jj,{children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:(0,lU.jsx)(a0.tgp,{style:{transform:"rotate(".concat(t?"0":"90deg",") translate3d(0, 0, 0)")}})})}),l]})}):(0,lU.jsx)(jb,{children:l})});var jk=Object.freeze,jC=Object.defineProperty,j_=(e,t)=>jk(jC(e,"raw",{value:jk(t||e.slice())}));let jS=(0,aW.ZP)(lY.xu).attrs({forwardedAs:"fieldset"})(nd||(nd=j_(["\n border: none;\n\n /* See: https://thatemil.com/blog/2015/01/03/reset-your-fieldset/ */\n body:not(:-moz-handler-blocked) & {\n display: table-cell;\n }\n"]))),jT=(0,aW.ZP)(lY.kC)({lineHeight:1}),jE=(0,aW.ZP)(lY.xu)(e=>{let{$borderLeft:t,theme:n}=e,{focusRing:i,radius:r}=n.sanity,{base:l}=n.sanity.color;return(0,aW.iv)(nc||(nc=j_(["\n outline: none;\n border-left: ",";\n border-radius: ",";\n\n &:focus {\n box-shadow: ",";\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n "])),t?"1px solid var(--card-border-color)":void 0,(0,lY.hO)(r[1]),ut({base:l,focusRing:{...i,offset:2}}))}),jP=[],jA=(0,lK.forwardRef)(function(e,t){let{__unstable_headerActions:n,validation:i=jP,__unstable_presence:r=jP,children:l,collapsible:a,columns:o,description:s,level:d=0,onFocus:c,onCollapse:u,onExpand:p,collapsed:h,tabIndex:f,title:m,...g}=e,x=i.length>0,v=(0,lY.ts)(t),b=(0,lK.useCallback)(e=>{let t=v.current;t===e.target&&c&&c(e)},[v,c]),y=(0,lK.useCallback)(()=>h?null==p?void 0:p():null==u?void 0:u(),[h,u,p]),j=(0,lK.useMemo)(()=>h?null:(0,lU.jsx)(lY.rj,{columns:o,gapX:4,gapY:5,children:"function"==typeof l?l():l}),[l,h,o]);return(0,lU.jsxs)(jS,{"data-level":d,...g,children:[m&&(0,lU.jsxs)(jT,{align:"flex-end",children:[(0,lU.jsx)(lY.xu,{flex:1,paddingY:2,children:(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(jw,{collapsed:!!h,collapsible:a,onClick:a?y:void 0,title:m}),x&&(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(js,{fontSize:1,validation:i})})]}),s&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:s})]})}),r.length>0&&(0,lU.jsx)(lY.xu,{flex:"none",children:(0,lU.jsx)(yF,{maxAvatars:4,presence:r})}),n&&(0,lU.jsx)(lY.xu,{flex:"none",marginLeft:1,children:n})]}),(0,lU.jsx)(jE,{$borderLeft:d>0,hidden:h,marginTop:1,paddingLeft:0===d?0:3,onFocus:"number"==typeof f&&f>-1?b:void 0,ref:v,tabIndex:f,children:!h&&j})]})});var jO=Object.freeze,jz=Object.defineProperty;let jM=aW.ZP.div(nu||(nu=jO(jz(T=["\n display: flex;\n justify-content: flex-end;\n box-sizing: border-box;\n min-height: var(--avatar-height);\n width: 77px;\n margin-left: var(--small-padding);\n\n &[data-max-avatars='1'] {\n max-width: 23px;\n }\n\n &[data-position='top'] {\n align-self: flex-start;\n }\n\n &[data-position='bottom'] {\n align-self: flex-end;\n }\n"],"raw",{value:jO(T.slice())}))));function jI(e){let{children:t,maxAvatars:n,position:i="bottom"}=e;return(0,lU.jsx)(jM,{"data-max-avatars":n,"data-position":i,children:t})}var jR=Object.freeze,jF=Object.defineProperty;let jD=(0,aW.ZP)(lY.zx)(np||(np=jR(jF(E=["\n cursor: ",";\n"],"raw",{value:jR(E.slice())}))),e=>e.grid?"move":"ns-resize"),jZ=lK.createContext(null),jL=function(e){let t=(0,lK.useContext)(jZ),{listeners:n,attributes:i}=(0,sA.nB)({id:t});return(0,lU.jsx)(jD,{icon:a0.VVU,mode:"bleed","data-ui":"DragHandleButton",...i,...e,...n})},jq=e=>t=>{let{containerNodeRect:n,draggingNodeRect:i,transform:r}=t;return i&&n?function(e,t,n,i){let r={...e},l=i.y||0,a=i.x||0;return t.top+r.y<=n.top+l?r.y=n.top-t.top+l:t.bottom+r.y>=n.top+n.height-l&&(r.y=n.top+n.height-t.bottom-l),t.left+r.x<=n.left-a?r.x=n.left-t.left+a:t.right+r.x>=n.left+n.width+a&&(r.x=n.left+n.width-t.right+a),r}(r,i,n,e):r};var jN=Object.freeze,jV=Object.defineProperty,jU=(e,t)=>jN(jV(e,"raw",{value:jN(t||e.slice())}));let jB="moving",jK=(0,aW.ZP)(lY.xu)(nf||(nf=jU(["\n ","\n"])),e=>e.$moving&&(0,aW.iv)(nh||(nh=jU(["\n z-index: 10000;\n /* prevents hover-effects etc on the dragged element */\n pointer-events: none;\n "])))),jH={threshold:{x:0,y:.02}},jW={coordinateGetter:sA.is},j$={duration:200,easing:"ease"},jX=(0,lK.memo)(function(e){let{items:t,axis:n,onItemMove:i,onItemMoveStart:r,onItemMoveEnd:l,children:a,...o}=e,s=(0,sO.Dy)((0,sO.VT)(sO.we),(0,sO.VT)(sO.Lg,jW)),d=(0,lK.useCallback)(e=>{var t,n,r,a;let{active:o,over:s}=e;o.id!==(null==s?void 0:s.id)&&(null==i||i({fromIndex:null==(n=null==(t=o.data.current)?void 0:t.sortable)?void 0:n.index,toIndex:null==(a=null==(r=null==s?void 0:s.data.current)?void 0:r.sortable)?void 0:a.index})),null==l||l()},[i,l]),c=(0,lK.useMemo)(()=>[jq({y:4}),...n?["x"===n?sM.K7:sM.DL]:[]],[n]);return(0,lU.jsx)(sO.LB,{sensors:s,autoScroll:jH,modifiers:c,collisionDetection:sO.pE,onDragEnd:d,onDragStart:r,children:(0,lU.jsx)(sA.Fo,{items:t,strategy:n?"x"===n?sA.PG:sA.qw:void 0,children:(0,lU.jsx)(lY.rj,{...o,children:a})})})}),jG=(0,lK.forwardRef)(function(e,t){let{id:n,children:i,disableTransition:r}=e,{setNodeRef:l,transform:a,transition:o,active:s}=(0,sA.nB)({id:n,transition:r?null:j$}),d=n===(null==s?void 0:s.id),c=(0,lK.useMemo)(()=>({transform:sz.ux.Translate.toString(a),transition:o,pointerEvents:s?"
1none":void 0}),[a,o,s]),u=(0,lK.useCallback)(e=>{l(e),"function"==typeof t?t(e):t&&(t.current=e)},[t,l]);return(0,lU.jsx)(jK,{ref:u,style:c,$moving:d,className:d?jB:"","data-index":e["data-index"],children:i})});function jY(e){let{onItemMove:t,onItemMoveEnd:n,onItemMoveStart:i,sortable:r,...l}=e,a=(0,lK.useCallback)(e=>{null==t||t(e)},[t]);return r?(0,lU.jsx)(jX,{onItemMove:a,onItemMoveStart:i,onItemMoveEnd:n,...l}):(0,lU.jsx)(lY.rj,{...l})}let jJ=(0,lK.forwardRef)(function(e,t){let{sortable:n,...i}=e;return(0,lU.jsx)(jZ.Provider,{value:e.id,children:n?(0,lU.jsx)(jG,{ref:t,...i}):(0,lU.jsx)(jK,{ref:t,...i})})});var jQ=Object.freeze,j0=Object.defineProperty;let j1=(0,aW.ZP)(lY.Zb)(nm||(nm=jQ(j0(P=["\n position: relative;\n border: 1px solid transparent;\n transition: border-color 250ms;\n\n ."," & {\n border-color: var(--card-shadow-umbra-color);\n box-shadow: 0 0 0 0, 0 8px 17px 2px var(--card-shadow-umbra-color),\n 0 3px 14px 2px var(--card-shadow-penumbra-color),\n 0 5px 5px -3px var(--card-shadow-ambient-color);\n }\n\n &:hover {\n border-color: var(--card-shadow-umbra-color);\n }\n\n &[aria-selected='true'] {\n border-color: var(--card-focus-ring-color);\n }\n"],"raw",{value:jQ(P.slice())}))),jB);function j2(e){let{validation:t,selected:n,tone:i,presence:r,focused:l,children:a,dragHandle:o,menu:s,footer:d}=e,c=(0,lK.useRef)(null);return m$(l,(e,t)=>{var n;!e&&t&&(null==(n=c.current)||n.focus())}),(0,lU.jsx)(j1,{ref:c,selected:n,"aria-selected":n,radius:2,padding:1,tone:i,children:(0,lU.jsxs)(lY.Kq,{space:1,children:[(0,lU.jsxs)(lY.kC,{align:"center",children:[o&&(0,lU.jsx)(lY.xu,{marginRight:1,paddingY:1,children:(0,lU.jsx)(jL,{paddingX:1,paddingY:3})}),(0,lU.jsx)(lY.xu,{flex:1,children:a}),(r||t||s)&&(0,lU.jsxs)(lY.kC,{align:"center",marginLeft:1,children:[r&&(0,lU.jsx)(lY.xu,{marginLeft:1,children:r}),t&&(0,lU.jsx)(lY.xu,{marginLeft:1,children:t}),s]})]}),d]})})}var j3=Object.freeze,j4=Object.defineProperty,j5=(e,t)=>j3(j4(e,"raw",{value:j3(t||e.slice())}));let j6=aW.ZP.button(ng||(ng=j5(["\n display: block;\n -webkit-font-smoothing: inherit;\n appearance: none;\n font: inherit;\n background: none;\n width: 100%;\n text-align: left;\n border: 0;\n margin: 0;\n padding: 0;\n outline: none;\n"]))),j8=(0,aW.ZP)(a0.tgp)(nx||(nx=j5(["\n transform: ",";\n"])),e=>e.open?"rotate(90deg)":""),j9=(0,aW.ZP)(lY.kC)(nv||(nv=j5(["\n cursor: default;\n"]))),j7=(0,aW.ZP)(lY.xu)(nb||(nb=j5(["\n & > div > svg {\n transform: rotate(0);\n transition: transform 100ms;\n }\n\n &[data-open] > div > svg {\n transform: rotate(90deg);\n }\n"])));function we(e){let{children:t,open:n,icon:i,title:r="Details",...l}=e,[a,o]=(0,lK.useState)(n||!1),s=(0,lK.useCallback)(()=>o(e=>!e),[]);return(0,lK.useEffect)(()=>o(n||!1),[n]),(0,lU.jsxs)(lY.xu,{...l,children:[(0,lU.jsx)(j6,{type:"button",onClick:s,children:(0,lU.jsx)(j9,{align:"center",children:(0,lU.jsxs)(lY.gF,{children:[(0,lU.jsx)(j7,{"data-open":a?"":void 0,children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(j8,{open:a})})}),i&&(0,lU.jsx)(lY.xu,{marginLeft:1,children:i}),(0,lU.jsx)(lY.xu,{flex:1,marginLeft:1,children:(0,lU.jsx)(lY.xv,{size:1,weight:"medium",children:r})})]})})}),(0,lU.jsx)(lY.xu,{hidden:!a,marginTop:3,children:t})]})}let wt={warning:"caution",error:"critical",info:"positive"},wn={warning:(0,lU.jsx)(a0.foC,{}),error:(0,lU.jsx)(a0.uIy,{}),info:(0,lU.jsx)(a0.hQ6,{})};function wi(e){let{children:t,status:n="warning",title:i,...r}=e;return(0,lU.jsx)(lY.Zb,{radius:2,tone:wt[n],...r,"data-ui":"Alert",children:(0,lU.jsx)(lY.kC,{padding:1,children:t&&(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(we,{icon:wn[n],title:i,children:(0,lU.jsx)(lY.xu,{marginLeft:3,marginTop:3,children:t})})})})})}function wr(e){return(0,lV.m$)(e)?"object"===e.name?{}:{_type:e.name}:(0,lV.jB)(e)?[]:"string"===e.jsonType?"":"number"===e.jsonType?0:"boolean"!==e.jsonType&&void 0}function wl(e){if(!(0,lV.m$)(e))throw Error('Invalid item type: "'.concat(e.type,'". Default array input can only contain objects (for now)'));return{...wr(e),_key:(0,sy.E2)(12)}}let wa={portal:!0,tone:"default",placement:"left",constrainSize:!0},wo=(0,lK.memo)(function(e){let{types:t,onInsert:n}=e;return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(ws,{pos:"before",types:t,onInsert:n,text:"Add item before",icon:a0.ySV}),(0,lU.jsx)(ws,{pos:"after",types:t,onInsert:n,text:"Add item after",icon:a0.oty})]})});function ws(e){let{types:t,onInsert:n,pos:i,text:r,icon:l}=e;return(null==t?void 0:t.length)===1?(0,lU.jsx)(lY.sN,{text:r,icon:l,onClick:()=>n(i,t[0])},i):(0,lU.jsx)(lY.kS,{text:r,popover:wa,children:null==t?void 0:t.map(e=>(0,lU.jsx)(lY.sN,{icon:e.icon,text:e.title,onClick:()=>n(i,e)},e.name))},i)}let wd={isLoading:!0,result:void 0,error:void 0,retry:()=>void 0},wc={isLoading:!1,result:void 0,error:void 0,retry:()=>void 0};function wu(e,t){let n=(0,lK.useMemo)(()=>new l2.x,[]),i=(0,lK.useMemo)(()=>n.asObservable(),[n]),r=(0,lK.useCallback)(()=>{n.next({type:"retry"})},[n]),l=(0,lJ.m2)(()=>(0,l0.z)((0,lQ.of)(null),i).pipe((0,ad.U)(()=>e),(0,aS.b)(e=>e?t(e).pipe((0,ad.U)(e=>({isLoading:!1,result:e,error:void 0,retry:r})),(0,ag.O)(wd),(0,au.K)(e=>(console.error(e),(0,lQ.of)({isLoading:!1,result:void 0,error:e,retry:r})))):(0,lQ.of)(wc))),[t,e,i,r],wd),a=mW(e,e);return e&&a!==e?wd:l}function wp(e){let{time:t}=e;!function(e){let[t,n]=(0,lK.useReducer)(e=>e+1,0);(0,lK.useEffect)(()=>{let t=setInterval(n,e);return()=>clearInterval(t)},[e])}(1e3);let n=(0,sI.Z)(new Date(t));return(0,lU.jsxs)("span",{title:n,children:[n," ago"]})}function wh(e){var t,n,i,r;let{id:l,layout:a,preview:o,refType:s,renderPreview:d,showTypeLabel:c}=e,u=(0,lY.Ur)(),p=UN(l),h=(null==(t=o.draft)?void 0:t._id)||(null==(n=o.published)?void 0:n._id)||l,f=(0,lK.useMemo)(()=>({_id:h,_type:s.name}),[h,s.name]),m=(0,lK.useMemo)(()=>({layout:a,schemaType:s,value:f}),[a,f,s]);return(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{flex:1,children:d(m)}),(0,lU.jsx)(lY.xu,{paddingLeft:3,children:(0,lU.jsxs)(lY.gF,{space:3,children:[c&&(0,lU.jsx)(lY.__,{size:1,muted:!0,children:s.title}),p&&p.length>0&&(0,lU.jsx)(yw,{presence:p}),(0,lU.jsxs)(lY.gF,{space:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:(null==(i=o.published)?void 0:i._updatedAt)?(0,lU.jsxs)(lU.Fragment,{children:["Published ",(0,lU.jsx)(wp,{time:o.published._updatedAt})]}):(0,lU.jsx)(lU.Fragment,{children:"Not published"})})}),children:(0,lU.jsx)(pG,{tone:"default"===u.tone?"positive":"default",size:1,dimmed:!o.published,muted:!o.published,children:(0,lU.jsx)(a0.EI4,{})})})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:(null==(r=o.draft)?void 0:r._updatedAt)?(0,lU.jsxs)(lU.Fragment,{children:["Edited ",(0,lU.jsx)(wp,{time:o.draft._updatedAt})]}):(0,lU.jsx)(lU.Fragment,{children:"No unpublished edits"})})}),children:(0,lU.jsx)(pG,{tone:"default"===u.tone?"caution":"default",size:1,dimmed:!o.draft,muted:!o.draft,children:(0,lU.jsx)(a0.dY8,{})})})})]})]})})]})}function wf(e){var t,n,i,r,l,a;let{referenceInfo:o,renderPreview:s,type:d,value:c,showTypeLabel:u}=e;if(o.isLoading||o.error)return(0,lU.jsx)(fF,{isPlaceholder:!0});if((null==(t=o.result)?void 0:t.availability.reason)==="NOT_FOUND"&&c._strengthenOnPublish){let e=d.to.find(e=>{var t;return e.name===(null==(t=null==c?void 0:c._strengthenOnPublish)?void 0:t.type)});if(!e)return(0,lU.jsx)(wg,{documentId:c._ref,actualType:null==(n=c._strengthenOnPublish)?void 0:n.type,declaredTypes:d.to.map(e=>e.name)}
1);let t=(null==(i=c._strengthenOnPublish)?void 0:i.type)?{_id:c._ref,_type:null==(r=c._strengthenOnPublish)?void 0:r.type}:c;return(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{flex:1,children:s({layout:"default",schemaType:e,value:t,skipVisibilityCheck:!0})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.gF,{space:4,children:u&&(0,lU.jsx)(lY.__,{size:1,muted:!0,children:e.title})})})]})}let p=o.result.availability,h="NOT_FOUND"===p.reason,f="PERMISSION_DENIED"===p.reason;if(f||h)return(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsx)(lY.kC,{align:"center",children:(0,lU.jsx)(lY.xu,{flex:1,paddingY:2,children:(0,lU.jsx)(lY.xv,{muted:!0,children:"Document unavailable"})})})}),f||h?(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:h?(0,lU.jsxs)(wm,{title:"Not found",icon:a0.BHU,children:["The referenced document does not exist",(0,lU.jsx)("br",{}),"(id: ",(0,lU.jsx)("code",{children:c._ref}),")"]}):(0,lU.jsx)(wm,{title:"Insufficient permissions",icon:a0.vaB,children:"The referenced document could not be accessed due to insufficient permissions"}),children:(0,lU.jsx)(pG,{tone:"default",children:(0,lU.jsx)(a0.BHU,{})})})}):null]});let m=null==(l=o.result)?void 0:l.type,g=d.to.find(e=>e.name===m);return g?(0,lU.jsx)(wh,{id:c._ref,layout:"default",preview:null==(a=o.result)?void 0:a.preview,refType:g,renderPreview:s,showTypeLabel:u}):(0,lU.jsx)(wg,{documentId:c._ref,actualType:m||"<unknown>",declaredTypes:d.to.map(e=>e.name)})}function wm(e){let t=e.icon;return(0,lU.jsxs)(lY.kC,{padding:3,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(t,{})})}),(0,lU.jsxs)(lY.xu,{flex:1,marginLeft:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:e.title}),(0,lU.jsx)(lY.xu,{marginTop:3,children:(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:e.children})})]})]})}function wg(e){return(0,lU.jsxs)(lY.kC,{align:"center",justify:"flex-start",children:[(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsx)(lY.kC,{align:"center",children:(0,lU.jsx)(lY.xu,{flex:1,paddingY:2,children:(0,lU.jsx)(lY.xv,{muted:!0,children:"Document of invalid type"})})})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsxs)(lY.Kq,{space:3,padding:3,children:[(0,lU.jsxs)(lY.xv,{size:1,children:["Referenced document (",(0,lU.jsx)("code",{children:e.documentId}),") is of type"," ",(0,lU.jsx)("code",{children:e.actualType}),"."]}),(0,lU.jsxs)(lY.xv,{size:1,children:["According to the schema, referenced documents can only be of type"," ",wx(e.declaredTypes.map(e=>(0,lU.jsx)("code",{children:e},e)),"or"),"."]})]}),children:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(pG,{tone:"default",children:(0,lU.jsx)(a0.BHU,{})})})})})]})}let wx=(e,t)=>{if(1===e.length)return e[0];if(2===e.length)return[e[0],(0,lU.jsxs)(lK.Fragment,{children:[" ",t," "]},"comma"),e[1]];let n=e.slice(0,-1);return[...n.map((e,t)=>(0,lU.jsxs)(lK.Fragment,{children:[e,", "]},t)),(0,lU.jsxs)(lK.Fragment,{children:[t," ",e[e.length-1]]},"last")]};var wv=Object.freeze,wb=Object.defineProperty;let wy=(0,aW.ZP)(lY.Zb)(ny||(ny=wv(wb(A=["\n /* this is a hack to avoid layout jumps while previews are loading\n there's probably better ways of solving this */\n min-height: 35px;\n position: relative;\n\n /* TextWithTone uses its own logic to set color, and we therefore need */\n /* to override this logic in order to set the correct color in different states */\n &[data-selected],\n &[data-pressed],\n &:active {\n [data-ui='TextWithTone'] {\n color: inherit;\n }\n }\n"],"raw",{value:wv(A.slice())})))),wj=(0,lK.forwardRef)(function(e,t){let{documentType:n,as:i,...r}=e,l=n?"a":void 0,a=n?i:"div";return(0,lU.jsx)(wy,{...r,"data-as":l,documentType:n,forwardedAs:a,ref:t})}),ww=(0,lK.createContext)(null);function wk(e){let{menuRef:t,containerRef:n}=e;return(0,lU.jsx)(ww.Provider,{value:{menuRef:t,containerRef:n},children:e.children})}let wC={portal:!0,tone:"default"},w_={position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.6};function wS(e){var t,n,i,r,l,a,o,s,d,c,u;let{schemaType:p,parentSchemaType:h,path:f,readOnly:m,onRemove:g,value:x,open:v,onInsert:b,presence:y,validation:j,inputId:w,changed:k,focused:C,children:_,inputProps:{onCh
1ange:S,focusPath:T,onPathFocus:E,renderPreview:P,elementProps:A}}=e,O=!m&&(null==(t=h.options)?void 0:t.sortable)!==!1,z=h.of,M=(0,lK.useRef)(null),I=(0,lK.useRef)(null),R=(0,lK.useRef)(null),{EditReferenceLink:F,getReferenceInfo:D,selectedState:Z,isCurrentDocumentLiveEdit:L}=EI({path:f,schemaType:p,value:x});yp(M,v),m$(C,(e,t)=>{var n;!e&&t&&M.current&&(null==(n=M.current)||n.focus())});let q=e.validation.some(e=>"error"===e.level),N=e.validation.some(e=>"warning"===e.level),V=x._resolvingInitialValue,U=(0,lK.useCallback)(()=>{b({items:[{...x,_key:yf()}],position:"after"})},[b,x]),B=(0,lK.useCallback)((e,t)=>{b({items:[{...wl(t),_key:yf()}],position:e})},[b]),K=wu(null==x?void 0:x._ref,D),H=x._ref,W=(null==(n=K.result)?void 0:n.type)||(null==(i=null==x?void 0:x._strengthenOnPublish)?void 0:i.type),$=H&&(null==(a=null==(l=null==(r=K.result)?void 0:r.preview)?void 0:l.published)?void 0:a._id),X=(0,lK.useCallback)(()=>{S([!0===p.weak?mF(!0,["_weak"]):mD(["_weak"]),mD(["_strengthenOnPublish"])])},[S,p.weak]),G=W?p.to.find(e=>e.name===W):void 0,Y="pressed"===Z,J="selected"===Z,Q=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:m,hasErrors:q,hasWarnings:N}),ee=!H||"_ref"===T[0],et=(0,lK.useMemo)(()=>(0,lK.forwardRef)(function(e,t){return(0,lU.jsx)(a1.nR,{...e,intent:"edit",params:{id:null==x?void 0:x._ref,type:null==G?void 0:G.name},target:"_blank",rel:"noopener noreferrer",ref:t})}),[null==G?void 0:G.name,null==x?void 0:x._ref]),en=(0,lK.useCallback)(()=>{H&&ee?E([]):E(["_ref"])},[H,ee,E]),ei=(0,lK.useMemo)(()=>m?null:(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{paddingY:3,paddingX:2,mode:"bleed",icon:a0.zGg}),id:"".concat(w,"-menuButton"),menu:(0,lU.jsxs)(lY.v2,{ref:I,children:[!m&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:g}),(0,lU.jsx)(lY.sN,{text:H&&ee?"Cancel replace":"Replace",icon:H&&ee?a0.Two:a0.bnu,onClick:en}),(0,lU.jsx)(lY.sN,{text:"Duplicate",icon:a0.TIy,onClick:U}),(0,lU.jsx)(wo,{onInsert:B,types:z})]}),!m&&!ee&&H&&(0,lU.jsx)(lY.R,{}),!ee&&H&&(0,lU.jsx)(lY.sN,{as:et,"data-as":"a",text:"Open in new tab",icon:a0.buG})]}),popover:wC})}),[m,w,g,H,ee,en,U,B,z,et]),er=(0,lK.useCallback)(()=>{S(!0===p.weak?mF(!0,["_weak"]):mD(["_weak"]))},[S,p]),el=(null==x?void 0:x._weak)?"weak":"strong",ea=!0===p.weak?"weak":"strong",eo=H&&!K.isLoading&&(null==x?void 0:x._strengthenOnPublish),es=!K.isLoading&&(null==(o=K.result)?void 0:o.availability.available)&&H&&el!==ea&&!eo,ed=(null==(s=K.result)?void 0:s.preview.draft)||(null==(d=K.result)?void 0:d.preview.published),ec=(0,lU.jsxs)(lU.Fragment,{children:[L&&$&&x._strengthenOnPublish&&(0,lU.jsx)(wi,{padding:1,title:p.weak?"Finalize reference":"Convert to strong reference",status:"info","data-testid":"alert-reference-published",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:[(0,lU.jsx)("strong",{children:null==(u=null==(c=K.result)?void 0:c.preview.published)?void 0:u.title})," is published and this reference should now be"," ",p.weak?(0,lU.jsx)(lU.Fragment,{children:"finalized"}):(0,lU.jsx)(lU.Fragment,{children:"converted to a strong reference"}),"."]}),(0,lU.jsx)(lY.zx,{onClick:X,text:(0,lU.jsx)(lU.Fragment,{children:"Convert to strong reference"}),tone:"positive"})]})}),es&&(0,lU.jsx)(wi,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,lU.jsx)("em",{children:el}),", but according to the current schema it should be"," ",(0,lU.jsxs)("em",{children:[ea,"."]})]}),(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:p.weak?(0,lU.jsxs)(lU.Fragment,{children:["It will not be possible to delete the"," ",(null==ed?void 0:ed.title)?(0,lU.jsxs)(lU.Fragment,{children:['"',null==ed?void 0:ed.title,'"-document']}):(0,lU.jsx)(lU.Fragment,{children:"referenced document"})," ","without first removing this reference."]}):(0,lU.jsxs)(lU.Fragment,{children:["This makes it possible to delete the"," ",(null==ed?void 0:ed.title)?(0,lU.jsxs)(lU.Fragment,{children:['"',null==ed?void 0:ed.title,'"-document']}):(0,lU.jsx)(lU.Fragment,{children:"referenced document"}
1)," ","without first deleting this reference, leaving this field referencing a nonexisting document."]})}),(0,lU.jsx)(lY.zx,{onClick:er,text:(0,lU.jsxs)(lU.Fragment,{children:["Convert to ",ea," reference"]}),tone:"caution"})]})}),K.error&&(0,lU.jsx)(wi,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["Error: ",K.error.message]}),(0,lU.jsx)(lY.zx,{onClick:K.retry,text:(0,lU.jsx)(lU.Fragment,{children:"Retry"}),tone:"primary"})]})})]}),eu=(0,lU.jsx)(wk,{menuRef:I,containerRef:R,children:(0,lU.jsx)(j2,{dragHandle:O,presence:!ee&&y.length>0&&(0,lU.jsx)(yF,{presence:y,maxAvatars:1}),validation:!ee&&j.length>0&&(0,lU.jsx)(js,{validation:j}),menu:ei,footer:ee?void 0:ec,tone:ee?void 0:Q,focused:C,children:ee?(0,lU.jsx)(lY.xu,{padding:1,ref:R,children:(0,lU.jsx)(jA,{title:p.title,description:p.description,__unstable_presence:y,validation:j,children:_})}):(0,lU.jsxs)(wj,{as:F,tone:"inherit",radius:2,documentId:null==x?void 0:x._ref,documentType:null==G?void 0:G.name,disabled:V,paddingX:2,paddingY:1,__unstable_focusRing:!0,selected:J,pressed:Y,"data-selected":!!J||void 0,"data-pressed":!!Y||void 0,...A,children:[(0,lU.jsx)(wf,{value:x,referenceInfo:K,renderPreview:P,type:p}),V&&(0,lU.jsx)(lY.Zb,{style:w_,tone:"transparent",radius:2,as:lY.kC,justify:"center",children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"center",padding:3,children:[(0,lU.jsx)(lY.xu,{marginX:3,children:(0,lU.jsx)(lY.$j,{muted:!0})}),(0,lU.jsx)(lY.xv,{children:"Resolving initial valueâ¦"})]})})]})})});return(0,lU.jsx)(cD,{path:f,isChanged:k,hasFocus:!!C,children:(0,lU.jsx)(lY.xu,{paddingX:1,children:eu})})}function wT(e){return(0,lV.m$)(e.schemaType)}function wE(e){return(0,lV.jB)(e.schemaType)}function wP(e){return void 0!==e._key?e:{...e,_key:yf(12)}}function wA(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}let wO=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4,t=[],n=[],i=new l2.x;return function r(l){return new l9.y(a=>{if(t.length>=e)return(n.push(l),i.asObservable().pipe((0,aT.P)(e=>e===l))).pipe((0,ay.z)(r)).subscribe(a);let o=l.subscribe(a);return t.push(o),()=>{wA(t,o),wA(n,l),o.unsubscribe(),function(){for(;n.length>0&&t.length<e;)i.next(n.shift())}()}})}}(t);return function(){return(0,at.D)(n(e(...arguments)))}}(function(e,t,n){var i;let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},l=r.metadata,a=r.storeOriginalFilename,{label:o,title:s,description:d,creditLine:c,source:u}=r;return(i=n,window.crypto&&window.crypto.subtle&&window.FileReader?new l9.y(e=>{let t=new FileReader;return t.onload=()=>{e.next(t.result),e.complete()},t.onerror=t=>{e.error(t)},t.readAsArrayBuffer(i),()=>{t.abort()}}).pipe((0,ay.z)(e=>crypto.subtle.digest("SHA-1",e)),(0,ad.U)(wR)):(0,lQ.of)(null)).pipe((0,au.K)(()=>(0,lQ.of)(null)),(0,ay.z)(n=>{var i;return n?(i="sanity.".concat(t,"Asset"),e.observable.fetch("*[_type == $documentType && sha1hash == $hash][0]",{documentType:i,hash:n},{tag:"asset.find-duplicate"})):(0,lQ.of)(null)}),(0,ay.z)(i=>i?(0,lQ.of)({type:"complete",id:i._id,asset:i}):e.observable.assets.upload(t,n,{tag:"asset.upload",extract:l,preserveFilename:a,label:o,title:s,description:d,creditLine:c,source:u}).pipe((0,ad.U)(e=>"response"===e.type?{type:"complete",id:e.body.document._id,asset:e.body.document}:e))))},4),wz=(e,t,n)=>wO(e,"image",t,n),wM=(e,t,n)=>wO(e,"file",t,n);function wI(e,t){return e.observePaths({_type:"reference",_ref:t},["originalFilename","url","metadata","label","title","description","creditLine","source","size"])}function wR(e){return Array.prototype.map.call(new Uint8Array(e),e=>"00".concat(e.toString(16)).slice(-2)).join("")}let wF=/(invalid image format)|(No exif data)/i;function wD(e){return[5,6,7,8].indexOf(e)>-1}function wZ(e,t,n){let i=e.getContext("2d");null==i||i.translate(t?e.width:0,n?e.height:0),null==i||i.scale(t?-1:1,n?-1:1)}let wL=[{op:"none",degrees:0},{op:"flip-x",degrees:0},{op:"none",degrees:180},{op:"flip-y",degrees:0},{op:"flip-x",degrees:90},{op:"none",degrees:90},{op:"flip-x",degrees:-90},{op:"none",degrees:-90}],wq=["top-left","top-right","bottom-right","bottom-left","left-top","right-top","right-bottom","left-bottom"],wN="_upload",wV=mD([wN]);function wU(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:"uploadProgress",patches:e}}let wB=wU([wV]);function wK(e){let t=new Date().toISOString(),n={progress:2,createdAt:t,updatedAt:t,file:{name:e.name,type:e.type}};return wU([mF(n,[wN])])}
1function wH(e,t,n){let i=wM(e,t,n).pipe((0,ad.U)(e=>"complete"===e.type?wU([mF({_type:"reference",_ref:e.asset._id},["asset"]),mF(100,[wN,"progress"]),mF(new Date().toISOString(),[wN,"updated"])]):wU([mF(e.percent,[wN,"progress"]),mF(new Date().toISOString(),[wN,"updated"])])));return(0,l0.z)((0,lQ.of)(wK(t)),i,(0,lQ.of)(wB))}let wW=[{type:"image",accepts:"image/*",upload:(e,t,n,i)=>(function(e,t,n){let i=wz(e,t,n).pipe((0,af.h)(e=>"download"!==e.stage),(0,ad.U)(e=>({...e,progress:2+e.percent/100*98})),(0,ad.U)(e=>"complete"===e.type?wU([mF({_type:"reference",_ref:e.asset._id},["asset"]),mF(100,[wN,"progress"]),mF(new Date().toISOString(),[wN,"updatedAt"])]):wU([mF(e.percent,[wN,"progress"]),mF(new Date().toISOString(),[wN,"updatedAt"])]))),r=(0,at.D)(new l9.y(e=>{let n=new window.FileReader;return n.onerror=t=>e.error(t),n.onload=()=>{e.next(n.result),e.complete()},n.readAsArrayBuffer(t.slice(0,128e3)),()=>n.abort()})).pipe((0,ad.U)(e=>sN()(e)),(0,au.K)(e=>(wF.test(e.message)||console.warn("Exif read failed, continuing anyway: ".concat(e.message)),(0,lQ.of)({})))).pipe((0,ay.z)(e=>{var n,i;return n=e.orientation||"top-left",(i=window.URL.createObjectURL(t),new l9.y(e=>{let t=new window.Image;return t.onerror=()=>{e.error(Error('Could not load image from url "'.concat(i,'". Image may be of an unsupported format')))},t.onload=()=>{e.next(t),e.complete()},t.src=i,()=>{}})).pipe((0,ay.z)(e=>new l9.y(t=>{let i=wq.indexOf(n)+1,r=function(e,t){let n=wL[t-1],i=e.height/e.width;e.width=120/i,e.height=e.width*i;let r=document.createElement("canvas"),l=r.getContext("2d");if(wD(t)?(r.height=e.width,r.width=e.height):(r.width=e.width,r.height=e.height),"flip-x"===n.op&&wZ(r,!0,!1),"flip-y"===n.op&&wZ(r,!1,!0),n.degrees&&(function(e,t){let n=t.x,i=t.y,r=(t.degrees||0)*(Math.PI/180);null==e||e.translate(n,i),null==e||e.rotate(r),null==e||e.translate(-n,-i)}(l,{degrees:n.degrees,x:r.width/2,y:r.height/2}),wD(t))){let e=r.width-r.height;null==l||l.translate(e/2,-e/2)}return null==l||l.drawImage(e,0,0,e.width,e.height),r}(e,i);t.next(r.toDataURL("image/jpeg",.1)),t.complete()})))}),(0,au.K)(e=>(console.warn('Image preprocessing failed for "%s" with the error: %s',t.name,e.message),(0,lQ.of)(null))),(0,af.h)(Boolean),(0,ad.U)(e=>wU([mF(e,[wN,"previewImage"])])));return(0,l0.z)((0,lQ.of)(wK(t)),(0,l3.T)(i,r),(0,lQ.of)(wB))})(e,t,i)},{type:"string",accepts:"text/*",upload:(e,t,n,i)=>wH(e,t,i).pipe((0,ad.U)(e=>({type:"uploadProgress",patches:[mF(e)]})))},{type:"file",accepts:"",upload:(e,t,n,i)=>wH(e,t,i)}].map((e,t)=>({...e,priority:t}));function w$(e,t){if(!e||!t)return!0;let n=Array.isArray(t)?t:t.split(","),i=e.name||"",r=(e.type||"").toLowerCase(),l=r.replace(/\/.*$/,"");return n.some(e=>{let t=e.trim().toLowerCase();return"."===t.charAt(0)?i.toLowerCase().endsWith(t):t.endsWith("/*")?l===t.replace(/\/.*$/,""):r===t})}function wX(e,t){return wW.find(n=>{var i;return fM(n.type,e)&&w$(t,n.accepts)&&w$(t,(null==(i=e.options)?void 0:i.accept)||"")})||null}let wG=["_key","_type","_weak"];function wY(e){return Object.keys(e).every(e=>wG.includes(e))}let wJ=(e,t)=>{let n=(0,sy.wq)(t);return e.of.find(e=>e.name===n)};function wQ(e,t,n){return(0,at.D)(e).pipe((0,ay.z)(e=>{let i={_key:e._key};return(0,lQ.of)(wJ(t,e)).pipe((0,ay.z)(e=>e?(0,lQ.of)(e):l7.E),(0,ay.z)(t=>wY(e)&&n?(0,l0.z)((0,lQ.of)({type:"patch",patches:[mF(!0,[i,"_resolvingInitialValue"])]}),(0,l4.P)(()=>n(t,e)).pipe((0,af.h)(d9),(0,ad.U)(e=>{var t;return{type:"patch",patches:(t=[i],Object.entries(e).map(e=>{let[n,i]=e;return mF(i,[...t,n])}))}}),(0,au.K)(n=>(0,lQ.of)({type:"error",error:n,item:e,schemaType:t}))),(0,lQ.of)({type:"patch",patches:[mD([i,"_resolvingInitialValue"])]})):l7.E))}))}let w0="before",w1="after";function w2(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce((e,t)=>e.concat(t),[])}let w3=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),w4={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},inc:(e,t)=>e+t,dec:(e,t)=>e-t},w5=Object.keys(w4),w6=new sv.diff_match_patch,w8={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>
1void 0===e?t:e,unset(e,t){},diffMatchPatch:(e,t)=>w6.patch_apply(w6.patch_fromText(t),e)[0]},w9=Object.keys(w8);function w7(e,t){return t.reduce(function e(t,n){let i=Array.isArray(t)?function(t,n){let i=t.slice();if(0===n.path.length){if("setIfMissing"===n.type){if(!Array.isArray(n.value))throw Error("Cannot set value of an array to a non-array");return void 0===t?n.value:t}if("set"===n.type){if(!Array.isArray(n.value))throw Error("Cannot set value of an array to a non-array");return n.value}if("unset"===n.type)return;if("move"===n.type){if(!n.value||!w3(n.value,"from")||!w3(n.value,"to"))throw Error('Invalid value of \'move\' patch. Expected a value with "from" and "to" indexes, instead got: '.concat(JSON.stringify(n.value)));return function(e,t,n){let i=e.slice(),r=i[t];return i.splice(t,1),i.splice(n,0,r),i}(i,n.value.from,n.value.to)}throw Error("Invalid array operation: ".concat(n.type))}let[r,...l]=n.path,a=function(e,t){if("number"==typeof t)return t;let n=dU()(e,t);return -1!==n&&n}(t,r);if(!1===a)return i;if(0===l.length){if("insert"===n.type){let{position:e,items:i}=n;return function(e,t,n){if(t!==w0&&t!==w1)throw Error('Invalid position "'.concat(t,'", must be either ').concat(w0," or ").concat(w1));for(var i=arguments.length,r=Array(i>3?i-3:0),l=3;l<i;l++)r[l-3]=arguments[l];let a=w2(...r);if(0===e.length)return a;let o=e.length,s=Math.abs((o+n)%o)%o,d="after"===t?s+1:s,c=e.slice();return c.splice(d,0,...w2(a)),c}(t,e,a,i)}if("unset"===n.type){if("number"!=typeof a)throw Error('Expected array index to be a number, instead got "'.concat(a,'"'));return i.splice(a,1),i}}return i[a]=e(i[a],{...n,path:l}),i}(t,n):oi()(t)?function(e,t){if(!w9.includes(t.type))throw Error('Received patch of unsupported type: "'.concat(JSON.stringify(t.type),'" for string. This is most likely a bug.'));if(t.path.length>0)throw Error('Cannot apply deep operations on string values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));return w8[t.type](e,t.value)}(t,n):dN()(t)?function(t,n){let i=dK()(t);if(0===n.path.length){if("set"===n.type){if(!dN()(n.value))throw Error("Cannot set value of an object to a non-object");return n.value}if("unset"===n.type)return;if("setIfMissing"===n.type)return void 0===t?n.value:t;throw Error("Invalid object operation: ".concat(n.type))}let[r,...l]=n.path;if("string"!=typeof r)throw Error("Expected field name to be a string, instad got: ".concat(r));return 0===l.length&&"unset"===n.type?sm()(i,r):(i[r]=e(i[r],{...n,path:l}),i)}(t,n):function(e,t){if(!w5.includes(t.type))throw Error('Received patch of unsupported type "'.concat(t.type,'" for primitives. This is most likely a bug.'));if(t.path.length>0)throw Error('Cannot apply deep operations on primitive values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.map(e=>JSON.stringify(e)).join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));return w4[t.type](e,t.value)}(t,n);return i},e)}function ke(e){let t=d6(e),{value:n}=mY();return gz(n,t)}function kt(){let e=ke(["_id"]);if("string"==typeof e)return ci(e)}function kn(e){let{onPathBlur:t,onPathFocus:n,onChange:i,onSetPathCollapsed:r,onSetFieldSetCollapsed:l,onPathOpen:a,onFieldGroupSelect:o}=m7(),{member:s,renderAnnotation:d,renderBlock:c,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=mY().__internal,x=kt(),[v,b]=(0,lK.useState)([]),y=(0,lK.useRef)(),j=(0,lK.useRef)({});m$(s.field.focused,(e,t)=>{var n;!e&&t&&(null==(n=y.current)||n.focus())});let w=(0,lK.useCallback)(e=>{e.currentTarget===e.target&&e.currentTarget===y.current&&n(s.field.path)},[s.field.path,n]),k=(0,lK.useCallback)(e=>{e.currentTarget===e.target&&e.currentTarget===y.current&&t(s.field.path)},[s.field.path,t]),C=(0,lK.useRef)(s.field.value);(0,lK.useEffect)(()=>{C.current=s.field.value},[s.field.value]);let _=(0,lK.useCallback)(e=>{let t=mN.from(e).patches,n=t.some(e=>"unset"===e.type&&1===e.path.length);if(n&&(C.current=w7(C.current||[],t),Array.isArray(C.current)&&!C.current.length)){i(mN.from(mD([s.name])));return}i(mN.from(e).prepend(mI([])).prefixAll(s.name))},[i,s.name,C]),S=VE(),T=(0,lY.pm)(),E=(0,lK.useCallback)(()=>{r(s.field.path,!0)},[r,s.field.path]),P=(0,lK.useCallback)(()=>{r(s.field.path,!1)},[r,s.field.path]),A=(0,lK.useCallback)(e=>{r(s.field.path.concat({_key:e}),!0)},[r,s.field.path]),O=(0,lK.useCallback)(e=>{r(s.field.path.concat({_key:e}),!1)},[r,s.field.path]),z=(0,lK.useCallback)(e=>{a(e),r(e,!1)},[a,r]),M=(0,lK.useCallback)(()=>{a(s.field.path),r(s.field.path,!0)},[a,s.field.path,r]),I=(0,lK.useCallback)(e=>{if(0===e.items.length)throw Error("Insert event should include at least one item");let t=e.items.map(e=>wP(e));_(mN.from([mR(t,e.position,[e.referenceItem])]));let i=t[0]._key,r=[...s.field.path,{_key:i}];n(r);let l=!1!==e.open;e.skipInitialValue?l&&z(r):wQ(t,s.field.schemaType,S).pipe((0,as.b)(e=>{"patch"===e.type?_(e.patches):T.push({title:"Could not resolve initial value",description:"Unable to resolve initial value for type: ".concat(e.schemaType.title,": ").concat(e.error.message,"."),status:"error"})})).subscribe({complete:()=>{l&&z(r)}})},[_,z,s.field.path,s.field.schemaType,n,S,T]),R=(0,lK.useCallback)(e=>
1{let t=s.field.value,n=null==t?void 0:t[e.fromIndex],i=null==t?void 0:t[e.toIndex];if(e.fromIndex!==e.toIndex){if(!(null==n?void 0:n._key)||!(null==i?void 0:i._key)){console.error("Neither the item you are moving nor the item you are moving to have a key. Cannot continue.");return}_([mD([{_key:n._key}]),mR([n],e.fromIndex>e.toIndex?"before":"after",[{_key:i._key}])])}},[_,s.field.value]),F=(0,lK.useCallback)(e=>{_([mI([]),mR([wP(e)],"before",[0])])},[_]),D=(0,lK.useCallback)(e=>{_([mI([]),mR([wP(e)],"after",[-1])])},[_]),Z=(0,lK.useCallback)(e=>{j.current[e]&&(j.current[e].unsubscribe(),delete j.current[e]),_([mD([{_key:e}])])},[_]),L=(0,lK.useCallback)(e=>{n(s.field.path.concat(e))},[s.field.path,n]),q=(0,lK.useMemo)(()=>({onBlur:k,onFocus:w,id:s.field.id,ref:y}),[k,w,s.field.id]),N=Ni(fC),V=mY(),U=V.__internal.image.directUploads,B=V.__internal.file.directUploads,K=(0,lK.useCallback)((e,t)=>fM("image",e)&&!U||fM("file",e)&&!B?null:wX(e,t),[B,U]),H=(0,lK.useCallback)(e=>{let{file:t,schemaType:n,uploader:i}=e,r=wl(n),l=r._key;I({items:[r],position:"after",referenceItem:-1,open:!1});let a=i.upload(N,t,n).pipe((0,ad.U)(e=>mN.from(e.patches||[]).prefixAll({_key:l})),(0,as.b)(e=>_(e.patches)));j.current={...j.current,[l]:a.subscribe()}},[N,_,I]),W=(0,lK.useMemo)(()=>({level:s.field.level,members:s.field.members,value:s.field.value,readOnly:s.field.readOnly,schemaType:s.field.schemaType,changed:s.field.changed,id:s.field.id,onItemExpand:O,onItemCollapse:A,onItemClose:M,onItemOpen:z,focusPath:s.field.focusPath,focused:s.field.focused,path:s.field.path,onChange:_,onInsert:I,onItemMove:R,onItemRemove:Z,onItemAppend:D,onItemPrepend:F,onPathFocus:L,resolveInitialValue:S,onUpload:H,resolveUploader:K,validation:s.field.validation,presence:s.field.presence,renderAnnotation:d,renderBlock:c,renderInlineBlock:p,renderInput:h,renderField:u,renderItem:f,renderPreview:m,elementProps:q}),[s.field.level,s.field.members,s.field.value,s.field.readOnly,s.field.schemaType,s.field.changed,s.field.id,s.field.focusPath,s.field.focused,s.field.path,s.field.validation,s.field.presence,O,A,M,z,_,I,R,Z,D,F,L,S,H,K,d,c,p,h,u,f,m,q]),$=(0,lK.useMemo)(()=>h(W),[W,h]),X=(0,lK.useMemo)(()=>({actions:v.length>0?(0,lU.jsx)(gm,{focused:s.field.focused,nodes:v}):void 0,name:s.name,index:s.index,level:s.field.level,value:s.field.value,title:s.field.schemaType.title,description:s.field.schemaType.description,collapsible:s.collapsible,collapsed:s.collapsed,changed:s.field.changed,onCollapse:E,onExpand:P,schemaType:s.field.schemaType,inputId:s.field.id,path:s.field.path,presence:s.field.presence,validation:s.field.validation,children:$,inputProps:W}),[v,s.name,s.index,s.field.focused,s.field.level,s.field.value,s.field.schemaType,s.field.id,s.field.path,s.field.presence,s.field.changed,s.field.validation,s.collapsible,s.collapsed,E,P,$,W]);return(0,lU.jsxs)(m9,{onFieldGroupSelect:o,onChange:_,onSetFieldSetCollapsed:l,onSetPathCollapsed:r,onPathOpen:a,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,lU.jsx)(gb,{actions:g,documentId:x,documentType:s.field.schemaType.name,onActions:b,path:s.field.path,schemaType:s.field.schemaType}),(0,lU.jsx)(yn,{actions:v,path:s.field.path,children:(0,lK.useMemo)(()=>u(X),[X,u])})]})}function ki(e,t,n){return(0,lV.J1)(e)&&"string"==typeof n&&Number(n)===t?n:String(null!=t?t:"")}function kr(e){let{member:t,renderInput:n,renderField:i}=e,{field:{actions:r}}=mY().__internal,l=kt(),[a,o]=(0,lK.useState)([]),s=(0,lK.useRef)(),[d,c]=(0,lK.useState)(),{onPathBlur:u,onPathFocus:p,onChange:h}=m7();(0,lK.useEffect)(()=>{var e;t.field.focused&&(null==(e=s.current)||e.focus())},[t.field.focused]);let f=(0,lK.useCallback)(()=>{u(t.field.path)},[t.field.path,u]),m=(0,lK.useCallback)(()=>{p(t.field.path)},[t.field.path,p]),g=(0,lK.useCallback)(e=>{h(mN.from(e).prefixAll(t.name))},[h,t.name]),x=(0,lK.useCallback)(e=>{let n=e.currentTarget.value;if((0,lV.J1)(t.field.schemaType)){if((n=e.currentTarget.valueAsNumber)>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)return}else(0,lV.EG)(t.field.schemaType)&&(n=e.currentTarget.checked);let i=""===n||"number"==typeof n&&isNaN(n);(0,lV.J1)(t.field.schemaType)&&c(i?void 0:e.currentTarget.value),h(mN.from(i?mD():mF(n)).prefixAll(t.name))},[t.name,t.field.schemaType,h]),v=(0,lK.useMemo)(()=>t.field.validation.filter(e=>"error"===e.level).map(e=>e.message).join("\n"),[t.field.validation])||void 0,b=(0,lK.useMemo)(()=>
1({onBlur:f,onFocus:m,id:t.field.id,ref:s,onChange:x,value:ki(t.field.schemaType,t.field.value,d),readOnly:!!t.field.readOnly,placeholder:t.field.schemaType.placeholder}),[f,m,x,t.field.id,t.field.readOnly,t.field.schemaType,t.field.value,d]),y=(0,lK.useMemo)(()=>({value:t.field.value,readOnly:t.field.readOnly,schemaType:t.field.schemaType,changed:t.field.changed,id:t.field.id,path:t.field.path,focused:t.field.focused,level:t.field.level,onChange:g,validation:t.field.validation,presence:t.field.presence,validationError:v,elementProps:b}),[t.field.value,t.field.readOnly,t.field.schemaType,t.field.changed,t.field.id,t.field.path,t.field.focused,t.field.level,t.field.validation,t.field.presence,g,v,b]),j=(0,lK.useMemo)(()=>n(y),[y,n]),w=(0,lK.useMemo)(()=>({actions:a.length>0?(0,lU.jsx)(gm,{focused:t.field.focused,nodes:a}):void 0,name:t.name,index:t.index,level:t.field.level,value:t.field.value,schemaType:t.field.schemaType,title:t.field.schemaType.title,description:t.field.schemaType.description,inputId:t.field.id,path:t.field.path,validation:t.field.validation,presence:t.field.presence,children:j,changed:t.field.changed,inputProps:y}),[a,t.field.focused,t.field.level,t.field.value,t.field.schemaType,t.field.id,t.field.path,t.field.validation,t.field.presence,t.field.changed,t.name,t.index,j,y]);return(0,lU.jsxs)(lU.Fragment,{children:[l&&r.length>0&&(0,lU.jsx)(gb,{actions:r,documentId:l,documentType:t.field.schemaType.name,onActions:o,path:t.field.path,schemaType:t.field.schemaType}),(0,lU.jsx)(yn,{actions:a,path:t.field.path,children:i(w)})]})}let kl=function(e){let{onPathBlur:t,onPathFocus:n,onChange:i,onPathOpen:r,onSetPathCollapsed:l,onSetFieldSetCollapsed:a,onFieldGroupSelect:o}=m7(),{member:s,renderAnnotation:d,renderBlock:c,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=mY().__internal,x=kt(),[v,b]=(0,lK.useState)([]),y=(0,lK.useRef)(),j=(0,lK.useRef)(s.field.value);(0,lK.useEffect)(()=>{j.current=s.field.value},[s.field.value]),m$(s.field.focused,(e,t)=>{var n;!e&&t&&(null==(n=y.current)||n.focus())});let w=(0,lK.useCallback)(()=>{t(s.field.path)},[s.field.path,t]),k=(0,lK.useCallback)(()=>{n(s.field.path)},[s.field.path,n]),C=(0,lK.useCallback)(e=>{n(s.field.path.concat(e))},[s.field.path,n]),_=(0,lK.useCallback)(e=>{let t=0===s.field.path.length;if(!t){let t=mN.from(e).patches;if(j.current=w7(j.current||{},t),j.current&&(0,sy.Sm)(j.current)){i(mN.from(mD([s.name])));return}}i(mN.from(e).prepend(mI(wr(s.field.schemaType))).prefixAll(s.name))},[i,s,j]),S=(0,lK.useCallback)(()=>{l(s.field.path,!0)},[l,s.field.path]),T=(0,lK.useCallback)(()=>{l(s.field.path,!1)},[l,s.field.path]),E=(0,lK.useCallback)(e=>{l(s.field.path.concat(e),!0)},[l,s.field.path]),P=(0,lK.useCallback)(e=>{l(s.field.path.concat(e),!1)},[l,s.field.path]),A=(0,lK.useCallback)(e=>{r(s.field.path.concat(e))},[r,s.field.path]),O=(0,lK.useCallback)(()=>{r(s.field.path)},[r,s.field.path]),z=(0,lK.useCallback)(e=>{a(s.field.path.concat(e),!1)},[a,s.field.path]),M=(0,lK.useCallback)(e=>{a(s.field.path.concat(e),!0)},[a,s.field.path]),I=(0,lK.useCallback)(()=>{r(s.field.path)},[r,s.field.path]),R=(0,lK.useCallback)(()=>{r(s.field.path.slice(0,-1))},[r,s.field.path]),F=(0,lK.useCallback)(e=>{o(s.field.path,e)},[o,s.field.path]),D=(0,lK.useMemo)(()=>({onBlur:w,onFocus:k,id:s.field.id,ref:y}),[w,k,s.field.id]),Z=(0,lK.useMemo)(()=>({elementProps:D,level:s.field.level,members:s.field.members,value:s.field.value,readOnly:s.field.readOnly,validation:s.field.validation,presence:s.field.presence,schemaType:s.field.schemaType,changed:s.field.changed,id:s.field.id,onFieldGroupSelect:F,onFieldOpen:A,onFieldClose:O,onFieldCollapse:E,onFieldExpand:P,onFieldSetExpand:z,onFieldSetCollapse:M,onPathFocus:C,path:s.field.path,focusPath:s.field.focusPath,focused:s.field.focused,groups:s.field.groups,onChange:_,renderAnnotation:d,renderBlock:c,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}),[D,s.field.level,s.field.members,s.field.value,s.field.readOnly,s.field.validation,s.field.presence,s.field.schemaType,s.field.changed,s.field.id,s.field.path,s.field.focusPath,s.field.focused,s.field.groups,F,A,O,E,P,z,M,C,_,d,c,u,p,h,f,m]),L=(0,lK.useMemo)(()=>h(Z),[Z,h]),q=(0,lK.useMemo)(()=>({actions:v.length>0?(0,lU.jsx)(gm,{focused:s.field.focused,nodes:v}):void 0,name:s.name,index:s.index,level:s.field.level,value:s.field.value,validation:s.field.validation,presence:s.field.presence,title:s.field.schemaType.title,de
1scription:s.field.schemaType.description,collapsible:s.collapsible,collapsed:s.collapsed,onCollapse:S,onExpand:T,open:s.open,changed:s.field.changed,onOpen:I,onClose:R,schemaType:s.field.schemaType,inputId:s.field.id,path:s.field.path,children:L,inputProps:Z}),[v,s.field.focused,s.field.level,s.field.value,s.field.validation,s.field.presence,s.field.schemaType,s.field.changed,s.field.id,s.field.path,s.name,s.index,s.collapsible,s.collapsed,s.open,S,T,I,R,L,Z]);return(0,lU.jsxs)(m9,{onFieldGroupSelect:o,onChange:_,onSetFieldSetCollapsed:a,onPathOpen:r,onSetPathCollapsed:l,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,lU.jsx)(gb,{actions:g,documentId:x,documentType:s.field.schemaType.name,onActions:b,path:s.field.path,schemaType:s.field.schemaType}),(0,lU.jsx)(yn,{actions:v,path:s.field.path,children:(0,lK.useMemo)(()=>u(q),[q,u])})]})};function ka(e){let{onPathBlur:t,onPathFocus:n,onChange:i,onPathOpen:r,onSetPathCollapsed:l,onSetFieldSetCollapsed:a,onFieldGroupSelect:o}=m7(),{member:s,renderAnnotation:d,renderBlock:c,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=mY().__internal,x=kt(),[v,b]=(0,lK.useState)([]),y=(0,lK.useRef)(),j=(0,lK.useRef)(),w=Ni(fC);m$(s.field.focused,(e,t)=>{var n;!e&&t&&(null==(n=y.current)||n.focus())});let k=(0,lK.useCallback)(e=>{e.currentTarget===e.target&&e.currentTarget===y.current&&n(s.field.path)},[s.field.path,n]),C=(0,lK.useCallback)(e=>{e.currentTarget===e.target&&e.currentTarget===y.current&&t(s.field.path)},[s.field.path,t]),_=(0,lK.useCallback)(e=>{let t=mN.from(e).patches,n=t.some(e=>"unset"===e.type&&1===e.path.length);if(n){let e=w7(s.field.value||[],t);if(Array.isArray(e)&&!e.length){i(mN.from(mD([s.name])));return}}i(mN.from(e).prepend(mI([])).prefixAll(s.name))},[i,s.name,s.field.value]),S=(0,lK.useCallback)(e=>{l(s.field.path,e)},[l,s.field.path]),T=(0,lK.useCallback)(()=>{l(s.field.path,!0)},[l,s.field.path]),E=(0,lK.useCallback)(()=>{l(s.field.path,!1)},[l,s.field.path]),P=(0,lK.useCallback)(e=>{_(0===e.length?mD():mF(e))},[_]),A=(0,lK.useCallback)(e=>{let{value:t=[]}=s.field;e.fromIndex!==e.toIndex&&P(function(e,t,n){let i=e.slice(),r=i[t];return i.splice(t,1),i.splice(n,0,r),i}(t,e.fromIndex,e.toIndex))},[s.field,P]),O=(0,lK.useCallback)(e=>{let{value:t=[]}=s.field;P(t.concat(e))},[s.field,P]),z=(0,lK.useCallback)(e=>{let{value:t=[]}=s.field;P([e].concat(t||[]))},[s.field,P]),M=(0,lK.useCallback)(e=>{let{value:t=[]}=s.field,n=e.referenceIndex+("before"===e.position?-1:0);P(function(e,t,n){let i=t.slice();return i.splice(e+1,0,...n),i}(n,t,e.items))},[s.field,P]),I=(0,lK.useCallback)(e=>{_(mD([e]))},[_]),R=(0,lK.useCallback)(e=>{n(s.field.path.concat([e]))},[s.field.path,n]),F=(0,lK.useMemo)(()=>({onBlur:C,onFocus:k,id:s.field.id,ref:y}),[C,k,s.field.id]),D=(0,lK.useMemo)(()=>{var e;return e=s.field.schemaType.of,{priority:0,accepts:"text/*",type:"string",upload:(t,n)=>new l9.y(e=>{let t=new FileReader;return t.onerror=t=>e.error(t),t.onload=()=>{e.next(t.result),e.complete()},t.readAsText(n,"utf-8"),()=>{t.abort()}}).pipe((0,ad.U)(t=>null==t?void 0:t.split(/[\n\r]/).map(t=>{var n;let i,r,l;return n=t,i=!1,r=!1,l=!1,(e.forEach(e=>{(0,lV.EG)(e)&&(i=!0),(0,lV.aj)(e)&&(l=!0),(0,lV.J1)(e)&&(r=!0)}),i&&("true"===n||"false"===n))?"true"===n:r&&/^\d+$/.test(n)?Number(n):l?n:void 0}).filter(e=>void 0!==e)),(0,af.h)(e=>Array.isArray(e)),(0,ad.U)(e=>({type:"uploadProgress",patches:[mR(e,"after",[-1])]})))}},[s.field.schemaType.of]),Z=(0,lK.useCallback)((e,t)=>w$(t,"text/*")?D:null,[D]),L=(0,lK.useCallback)(e=>{let{file:t,schemaType:n,uploader:i}=e,r=i.upload(w,t,n).pipe((0,ad.U)(e=>mN.from(e.patches||[])),(0,as.b)(e=>_(e.patches)));j.current&&j.current.unsubscribe(),j.current=r.subscribe()},[w,_]),q=(0,lK.useMemo)(()=>({level:s.field.level,members:s.field.members,value:s.field.value,readOnly:s.field.readOnly,onSetCollapsed:S,schemaType:s.field.schemaType,changed:s.field.changed,id:s.field.id,elementProps:F,path:s.field.path,focusPath:s.field.focusPath,focused:s.field.focused,onChange:_,onInsert:M,onMoveItem:A,onItemRemove:I,onItemAppend:O,onItemPrepend:z,validation:s.field.validation,presence:s.field.presence,resolveUploader:Z,onUpload:L,renderAnnotation:d,renderBlock:c,renderInlineBlock:p,renderInput:h,renderItem:f,onIndexFocus:R,renderPreview:m}),[s.field.level,s.field.members,s.field.value,s.field.readOnly,s.field.schemaType,s.field.changed,s.field.id,s.field.path,s.field.focusPath,s.field.focused,s.field.validation,s.field.presence,S,F,_,M,A,I,O,z,Z,L,d,
1c,p,h,f,R,m]),N=(0,lK.useMemo)(()=>h(q),[q,h]),V=(0,lK.useMemo)(()=>({actions:v.length>0?(0,lU.jsx)(gm,{focused:s.field.focused,nodes:v}):void 0,name:s.name,index:s.index,level:s.field.level,value:s.field.value,title:s.field.schemaType.title,description:s.field.schemaType.description,collapsible:s.collapsible,collapsed:s.collapsed,onExpand:E,changed:s.field.changed,onCollapse:T,schemaType:s.field.schemaType,inputId:s.field.id,path:s.field.path,presence:s.field.presence,validation:s.field.validation,children:N,inputProps:q}),[v,s.field.focused,s.field.level,s.field.value,s.field.schemaType,s.field.changed,s.field.id,s.field.path,s.field.presence,s.field.validation,s.name,s.index,s.collapsible,s.collapsed,E,T,N,q]);return(0,lU.jsxs)(m9,{onFieldGroupSelect:o,onChange:_,onPathOpen:r,onSetFieldSetCollapsed:a,onSetPathCollapsed:l,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,lU.jsx)(gb,{actions:g,documentId:x,documentType:s.field.schemaType.name,onActions:b,path:s.field.path,schemaType:s.field.schemaType}),(0,lU.jsx)(yn,{actions:v,path:s.field.path,children:(0,lK.useMemo)(()=>u(V),[V,u])})]})}function ko(e){return(0,lV.m$)(e.field.schemaType)}function ks(e){return(0,lV.jB)(e.field.schemaType)&&e.field.schemaType.of.every(e=>(0,lV.m$)(e))}let kd=(0,lK.memo)(function(e){let{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:l,renderInput:a,renderItem:o,renderPreview:s}=e;return ko(t)?(0,lU.jsx)(kl,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:l,renderInput:a,renderItem:o,renderPreview:s}):(0,lV.jB)(t.field.schemaType)&&t.field.schemaType.of.every(e=>(0,lV.jp)(e))?(0,lU.jsx)(ka,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInput:a,renderInlineBlock:l,renderItem:o,renderPreview:s}):ks(t)?(0,lU.jsx)(kn,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:l,renderInput:a,renderItem:o,renderPreview:s}):(0,lU.jsx)(kr,{member:t,renderField:r,renderInput:a})}),kc=["yes","true","1"],ku=["false","no","false","0","null"],kp=kc.concat(ku),kh={string:{number:{test:Number,convert:Number},boolean:{test:e=>kp.includes(e.toLowerCase()),convert:e=>kc.includes(e.toLowerCase())||!ku.includes(e.toLowerCase())},richDate:{test:e=>(0,oR.Z)(e),convert:e=>({_type:"richDate",local:(function(e){let t=new Date(e.getTime()+6e4*e.getTimezoneOffset()),n=e.getTimezoneOffset()/60,i=e.getHours();return t.setHours(i-n),t})(new Date(e)).toJSON(),utc:new Date(e).toJSON(),timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}return null}(),offset:new Date().getTimezoneOffset()})}},date:{richDate:{test:e=>"date"===(e&&e._type),convert:e=>Object.assign({},e,{_type:"richDate"})}},richDate:{datetime:{test:e=>e&&e.utc,convert:e=>e.utc}},number:{string:{test:()=>!0,convert:String},boolean:{test:()=>!0,convert:Number}},boolean:{string:{test:()=>!0,convert:e=>e?"Yes":"No"},number:{test:()=>!0,convert:Number}}};function kf(e){let{value:t,targetType:n,onChange:i}=e,r=(0,lK.useMemo)(()=>({...t,_type:n}),[n,t]),l=(0,lK.useCallback)(()=>i(mN.from(mI(n,["_type"])),r),[r,i,n]);return(0,lU.jsx)(lY.zx,{onClick:l,text:(0,lU.jsxs)(lU.Fragment,{children:["Convert to ",(0,lU.jsx)("code",{children:n})]})})}function km(e){let{value:t,onChange:n,validTypes:i}=e,r=(0,lK.useMemo)(()=>({...t,_type:i[0]}),[i,t]),l=(0,lK.useCallback)(()=>n(mN.from(mD()),r),[r,n]);return(0,lU.jsx)(lY.zx,{onClick:l,tone:"critical",text:"Unset value"})}function kg(e){let{validTypes:t,value:n,onChange:i}=e,r=Nu(),l=1===t.length,a=r.has(t[0]);return(0,lU.jsx)(mH,{status:"warning",title:(0,lU.jsxs)(lU.Fragment,{children:["Property value missing ",(0,lU.jsx)("code",{children:"_type"})]}),children:(0,lU.jsx)(we,{open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["Encountered an object value without a ",(0,lU.jsx)("code",{children:"_type"})," property."]}),l&&!a&&(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["Either remove the ",(0,lU.jsx)("code",{children:"name"})," property of the object declaration, or set"," ",(0,lU.jsx)("code",{children:"_type"})," property on items."]}),!l&&(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"The following types are valid here according to schema:"}),!l&&(0,lU.jsx)(lY.Kq,{as:"ul",space:2,children:t.map(e=>(0,lU.jsx)(lY.xv,{as:"li",muted:!0,size:1,children:(0,lU.jsx)("code",{children:e})},e))}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsxs)(lY.xv,{as:"h4",weight:"semibold",size:1,children:["Current value (",(0,lU.jsx)("code",{children:"object"}),"):"]}),(0,lU.jsx)(lY.Zb,{border:!0,overflow:"auto",padding:2,radius:2,tone:"inherit",children:(0,lU.jsx)(lY.EK,{language:"json",children:JSON.stringify(n,null,2)})})]}),(0,lU.jsxs)(lY.rj,{columns:[1,2,2],gap:1,children:[l&&(0,lU.jsx)(kf,{onChange:i,targetType:t[0],value:n}),(0,lU.jsx)(km,{onChange:i,validTypes:t,value:n})]})]})})})}let kx=(0,lK.forwardRef)((e,t)=>{let{value:n,actualType:i,validTypes:r,onChange:l}=e;(0,lK.useImperativeHandle)(t,()=>({focus:()=>void 0}));let a=(0,lK.useCallback)(()=>{l(mN.from(mD()))},[l]),o=(0,lK.useCallback)(e=>{l(mN.from(mF(e)))},[l]),s=(0,lK.useMemo)(()=>i in kh?Object.keys(kh[i]).filter(e=>r.includes(e)).map(e=>({from:i,to:e,...kh[i][e]})).filter(e=>e.test(n)):[],[n,i,r]);if(sD()(n)&&!("_type"in n))return(0,lU.jsx)(kg,{value:n,validTypes:r,onChange:l});let d=(0,lU.jsx)(lY.Kq,{padding:2,children:(0,lU.jsx)(lY.zx,{onClick:a,tone:"critical",text:"Reset value"})});return(0,lU.jsxs)(mH,{status:"error",suffix:d,title:(0,lU.jsx)(lU.Fragment,{children:"Invalid property value"}),children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"The property value is stored as a value type that does not match the expected type."}),(0,lU.jsx)(we,{marginTop:4,open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:(0,lU.jsxs)(lY.Kq,{space:3,children:[1===r.length&&(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["The value of this property must be of type ",(0,lU.jsx)("code",{children:r[0]})," according to the schema."]}),1===r.length&&(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Mismatching value types typically occur when the schema has recently been changed."}),1!==r.length&&(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Only the following types are valid here according to schema:"}),1!==r.length&&(0,lU.jsx)(lY.Kq,{as:"ul",space:2,children:r.map(e=>(0,lU.jsx)(lY.xv,{as:"li",children:(0,lU.jsx)("code",{children:e})},e))}
1),(0,lU.jsxs)(lY.Kq,{marginTop:2,space:2,children:[(0,lU.jsxs)(lY.xv,{size:1,weight:"semibold",children:["The current value (",(0,lU.jsx)("code",{children:i}),")"]}),(0,lU.jsx)(lY.Zb,{border:!0,padding:2,radius:2,tone:"inherit",children:(0,lU.jsx)(lY.EK,{language:"json",size:1,children:JSON.stringify(n,null,2)})})]}),s.length>0&&(0,lU.jsx)(lY.Kq,{space:1,children:s.map(e=>(0,lU.jsx)(kv,{converter:e,onConvert:o,value:n},"".concat(e.from,"-").concat(e.to)))})]})})]})});function kv(e){let{converter:t,onConvert:n,value:i}=e,r=(0,lK.useCallback)(()=>n(t.convert(i)),[t,n,i]);return(0,lU.jsx)(lY.zx,{onClick:r,text:(0,lU.jsxs)(lU.Fragment,{children:["Convert to ",(0,lU.jsx)("code",{children:t.to})]})})}function kb(e){let{error:t,onChange:n}=e,i=(0,lK.useCallback)(()=>{n(mN.from((t.value||[]).map((e,t)=>mI((0,sy.E2)(),[t,"_key"]))))},[t.value,n]);return(0,lU.jsx)(jm,{title:t.schemaType.title,description:t.schemaType.description,children:(0,lU.jsxs)(mH,{status:"warning",suffix:(0,lU.jsx)(lY.Kq,{padding:2,children:(0,lU.jsx)(lY.zx,{onClick:i,text:"Add missing keys",tone:"caution"})}),title:(0,lU.jsx)(lU.Fragment,{children:"Missing keys"}),children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Some items in the list are missing their keys. This must be fixed in order to edit the list."}),(0,lU.jsx)(we,{marginTop:4,open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This usually happens when items are created using an API client, and the"," ",(0,lU.jsx)("code",{children:"_key"})," property has not been included."]}),(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["The value of the ",(0,lU.jsx)("code",{children:"_key"})," property must be a unique string."]})]})})]})})}function ky(e){let{error:t,onChange:n}=e,i=(0,lK.useCallback)(()=>{n(mN.from((t.duplicates||[]).map(e=>{let[t,n]=e;return mF("".concat(n,"_deduped_").concat(t),[t,"_key"])})))},[t.duplicates,n]);return(0,lU.jsx)(jm,{title:t.schemaType.title,description:t.schemaType.description,children:(0,lU.jsxs)(mH,{status:"warning",suffix:(0,lU.jsx)(lY.Kq,{padding:2,children:(0,lU.jsx)(lY.zx,{onClick:i,text:"Generate unique keys",tone:"caution"})}),title:(0,lU.jsx)(lU.Fragment,{children:"Non-unique keys"}),children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Several items in this list share the same identifier (key). Every item must have an unique identifier."}),(0,lU.jsx)(we,{marginTop:4,open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This usually happens when items are created using an API client, and the"," ",(0,lU.jsx)("code",{children:"_key"})," property of each elements has been generated non-uniquely."]}),(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["The value of the ",(0,lU.jsx)("code",{children:"_key"})," property must be a unique string."]})]})})]})})}function kj(e){let{error:t,onChange:n}=e;return(0,lU.jsx)(jm,{title:t.schemaType.title,description:t.schemaType.description,children:(0,lU.jsxs)(mH,{status:"error",suffix:(0,lU.jsx)(lY.Kq,{padding:2,children:(0,lU.jsx)(lY.zx,{onClick:()=>{let e=(t.value||[]).flatMap((e,t)=>sD()(e)?[]:[t]).reverse(),i=e.map(e=>mD([e]));n(mN.from(i))},text:"Remove non-object values",tone:"critical"})}),title:(0,lU.jsx)(lU.Fragment,{children:"Invalid list values"}),children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Some items in this list are not objects. This must be fixed in order to edit the list."}),(0,lU.jsx)(we,{marginTop:4,open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:(0,lU.jsx)(lY.Kq,{space:3,children:(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"This usually happens when items are created using an API client, or when a custom input component has added invalid data to the list."})})})]})})}function kw(e){let{member:t}=e,{onChange:n}=m7(),i=(0,lK.useCallback)(e=>{n(mN.from(e).prefixAll(t.fieldName))},[n,t.fieldName]);return"INCOMPATIBLE_TYPE"===t.error.type?(0,lU.jsx)(kx,{value:t.error.value,onChange:i,actualType:t.error.resolvedValueType,validTypes:[t.error.expectedSchemaType.n
1ame]}):"MISSING_KEYS"===t.error.type?(0,lU.jsx)(kb,{error:t.error,onChange:i}):"DUPLICATE_KEYS"===t.error.type?(0,lU.jsx)(ky,{error:t.error,onChange:i}):"MIXED_ARRAY"===t.error.type?(0,lU.jsx)(kj,{onChange:i,error:t.error}):(0,lU.jsxs)(lY.xu,{children:["Unexpected error: ",e.member.error.type]})}kx.displayName="InvalidValueInput";let kk=(0,lK.memo)(function(e){var t;let{member:n,renderAnnotation:i,renderBlock:r,renderField:l,renderInlineBlock:a,renderInput:o,renderItem:s,renderPreview:d}=e,{onSetFieldSetCollapsed:c}=m7(),u=(0,lK.useCallback)(()=>{c(n.fieldSet.path,!0)},[n.fieldSet.path,c]),p=(0,lK.useCallback)(()=>{c(n.fieldSet.path,!1)},[n.fieldSet.path,c]);return(0,lU.jsx)(jA,{title:n.fieldSet.title||sL()(n.fieldSet.name),description:n.fieldSet.description,level:n.fieldSet.level,collapsible:n.fieldSet.collapsible,collapsed:n.fieldSet.collapsed,onCollapse:u,onExpand:p,columns:null==(t=null==n?void 0:n.fieldSet)?void 0:t.columns,"data-testid":"fieldset-".concat(n.fieldSet.name),children:n.fieldSet.members.map(e=>"error"===e.kind?(0,lU.jsx)(kw,{member:e},n.key):(0,lU.jsx)(kd,{member:e,renderAnnotation:i,renderBlock:r,renderField:l,renderInlineBlock:a,renderInput:o,renderItem:s,renderPreview:d},e.key))})});function kC(e){let t=(0,lK.useRef)(),{member:n,renderAnnotation:i,renderBlock:r,renderField:l,renderInlineBlock:a,renderInput:o,renderItem:s,renderPreview:d}=e,{onPathBlur:c,onPathFocus:u,onChange:p,onPathOpen:h,onSetPathCollapsed:f,onSetFieldSetCollapsed:m,onFieldGroupSelect:g}=m7(),x=VE();m$(n.item.focused,(e,n)=>{var i;!e&&n&&(null==(i=t.current)||i.focus())});let v=(0,lK.useCallback)(()=>{p(mN.from([mD([{_key:n.key}])]))},[n.key,p]),b=(0,lK.useCallback)(e=>{h(e),f(e,!1)},[h,f]),y=(0,lY.pm)(),j=(0,lK.useCallback)(e=>{if(0===e.items.length)throw Error("Insert event should include at least one item");let t=e.items.map(e=>wP(e));p(mN.from([mR(t,e.position,[{_key:n.key}])]));let i=t[0]._key,r=n.item.path.slice(0,-1),l=[...r,{_key:i}];u(l);let a=!1!==e.open;e.skipInitialValue?a&&b(l):wQ(t,n.parentSchemaType,x).pipe((0,as.b)(e=>{"patch"===e.type?p(mN.from(e.patches)):y.push({title:"Could not resolve initial value",description:"Unable to resolve initial value for type: ".concat(e.schemaType.title,": ").concat(e.error.message,"."),status:"error"})})).subscribe({complete:()=>{a&&b(l)}})},[b,n.item.path,n.key,n.parentSchemaType,p,u,x,y]),w=(0,lK.useCallback)(()=>{c(n.item.path)},[n.item.path,c]),k=(0,lK.useCallback)(()=>{u(n.item.path)},[n.item.path,u]),C=(0,lK.useCallback)(e=>{u(n.item.path.concat(e))},[n.item.path,u]),_=(0,lK.useCallback)(e=>{p(mN.from(e).prepend(mI(wr(n.item.schemaType))).prefixAll({_key:n.key}))},[p,n.item.schemaType,n.key]),S=(0,lK.useCallback)(()=>{f(n.item.path,!0)},[f,n.item.path]),T=(0,lK.useCallback)(()=>{f(n.item.path,!1)},[f,n.item.path]),E=(0,lK.useCallback)(e=>{f(n.item.path.concat(e),!0)},[f,n.item.path]),P=(0,lK.useCallback)(e=>{f(n.item.path.concat(e),!1)},[f,n.item.path]),A=(0,lK.useCallback)(()=>{h(n.item.path)},[h,n.item.path]),O=(0,lK.useCallback)(e=>{h(n.item.path.concat(e))},[h,n.item.path]),z=(0,lK.useCallback)(e=>{m(n.item.path.concat(e),!1)},[m,n.item.path]),M=(0,lK.useCallback)(e=>{m(n.item.path.concat(e),!0)},[m,n.item.path]),I=(0,lK.useCallback)(()=>{h(n.item.path)},[h,n.item.path]),R=!n.item.value||wY(n.item.value),F=(0,lK.useCallback)(()=>{R&&v();let e=n.item.path.slice(0,-1);h(e),u(e)},[R,h,n.item.path,u,v]),D=(0,lK.useCallback)(e=>{g(n.item.path,e)},[g,n.item.path]),Z=(0,lK.useMemo)(()=>({onBlur:w,onFocus:k,id:n.item.id,ref:t}),[w,k,n.item.id]),L=(0,lK.useMemo)(()=>({changed:n.item.changed,focusPath:n.item.focusPath,focused:n.item.focused,groups:n.item.groups,id:n.item.id,level:n.item.level,members:n.item.members,onChange:_,onFieldClose:A,onFieldCollapse:E,onFieldSetCollapse:M,onFieldExpand:P,onFieldSetExpand:z,onFieldGroupSelect:D,onPathFocus:C,onFieldOpen:O,path:n.item.path,presence:n.item.presence,readOnly:n.item.readOnly,renderAnnotation:i,renderBlock:r,renderField:l,renderInlineBlock:a,renderInput:o,renderItem:s,renderPreview:d,schemaType:n.item.schemaType,validation:n.item.validation,value:n.item.value,elementProps:Z}),[Z,_,A,E,M,P,z,C,O,D,n.item.changed,n.item.focusPath,n.item.focused,n.item.groups,n.item.id,n.item.level,n.item.members,n.item.path,n.item.presence,n.item.readOnly,n.item.schemaType,n.item.validation,n.item.value,i,r,l,a,o,s,d]),q=(0,lK.useMemo)(()=>o(L),[L,o]),N=(0,lK.useMemo)(()=>({key:n.key,index:n.index,level:n.item.level,value:n.item.value,title:n.item.schemaType.title,de
1scription:n.item.schemaType.description,collapsible:n.collapsible,collapsed:n.collapsed,schemaType:n.item.schemaType,parentSchemaType:n.parentSchemaType,onInsert:j,onRemove:v,presence:n.item.presence,validation:n.item.validation,open:n.open,onOpen:I,onClose:F,onExpand:T,onCollapse:S,readOnly:n.item.readOnly,focused:n.item.focused,onFocus:k,onBlur:w,inputId:n.item.id,path:n.item.path,children:q,changed:n.item.changed,inputProps:L}),[n.key,n.index,n.item.level,n.item.value,n.item.schemaType,n.parentSchemaType,n.item.presence,n.item.validation,n.item.readOnly,n.item.focused,n.item.id,n.item.path,n.item.changed,n.collapsible,n.collapsed,n.open,j,v,I,F,T,S,k,w,q,L]);return(0,lU.jsx)(m9,{onFieldGroupSelect:g,onChange:_,onPathOpen:h,onSetFieldSetCollapsed:m,onSetPathCollapsed:f,onPathBlur:c,onPathFocus:u,children:(0,lK.useMemo)(()=>s(N),[N,s])})}function k_(e){switch(e.jsonType){case"string":return"";case"number":return -0;case"boolean":return!1;default:throw Error('Unable to create value from type "'.concat(e.jsonType,'"'))}}function kS(e){let t=(0,lK.useRef)(),{member:n,renderItem:i,renderInput:r}=e,[l,a]=(0,lK.useState)(),{onPathBlur:o,onPathFocus:s,onChange:d}=m7();m$(n.item.focused,(e,n)=>{var i;!e&&n&&(null==(i=t.current)||i.focus())});let c=(0,lK.useCallback)(e=>{o(n.item.path)},[n.item.path,o]),u=(0,lK.useCallback)(e=>{s(n.item.path)},[n.item.path,s]),p=(0,lK.useCallback)(e=>{d(mN.from(e).prefixAll(n.index))},[d,n.index]),h=(0,lK.useCallback)(e=>{let t=e.currentTarget.value;if((0,lV.J1)(n.item.schemaType)){if((t=e.currentTarget.valueAsNumber)>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)return}else(0,lV.EG)(n.item.schemaType)&&(t=e.currentTarget.checked);let i=""===t||"number"==typeof t&&isNaN(t);(0,lV.J1)(n.item.schemaType)&&a(i?void 0:e.currentTarget.value),p(mF(i?k_(n.item.schemaType):t))},[p,n.item.schemaType]),f=(0,lK.useMemo)(()=>{var e,i;return{onBlur:c,onFocus:u,id:n.item.id,ref:t,onChange:h,value:(e=n.item.schemaType,Object.is(i=n.item.value,-0)?"":ki(e,i,l)),readOnly:!!n.item.readOnly,placeholder:n.item.schemaType.placeholder}},[c,u,h,n.item.id,n.item.readOnly,n.item.schemaType,n.item.value,l]),m=(0,lK.useMemo)(()=>({changed:n.item.changed,level:n.item.level,value:n.item.value,readOnly:n.item.readOnly,schemaType:n.item.schemaType,id:n.item.id,path:n.item.path,focused:n.item.focused,onChange:p,validation:n.item.validation,presence:n.item.presence,elementProps:f}),[n.item.changed,n.item.level,n.item.value,n.item.readOnly,n.item.schemaType,n.item.id,n.item.path,n.item.focused,n.item.validation,n.item.presence,p,f]),g=(0,lK.useMemo)(()=>r(m),[m,r]),x=(0,lK.useCallback)(()=>{d(mN.from([mD([n.index])]))},[n.index,d]),v=(0,lK.useCallback)(e=>{d(mN.from([mR(e.items,e.position,[n.index])]))},[n.index,d]),b=(0,lK.useMemo)(()=>({key:n.key,index:n.index,level:n.item.level,value:n.item.value,title:n.item.schemaType.title,description:n.item.schemaType.description,schemaType:n.item.schemaType,parentSchemaType:n.parentSchemaType,onInsert:v,onRemove:x,presence:n.item.presence,validation:n.item.validation,readOnly:n.item.readOnly,focused:n.item.focused,onFocus:u,onBlur:c,inputId:n.item.id,path:n.item.path,children:g}),[n.key,n.index,n.item.level,n.item.value,n.item.schemaType,n.item.presence,n.item.validation,n.item.readOnly,n.item.focused,n.item.id,n.item.path,n.parentSchemaType,v,x,u,c,g]);return(0,lU.jsx)(lU.Fragment,{children:(0,lK.useMemo)(()=>i(b),[b,i])})}var kT=Object.freeze,kE=Object.defineProperty;let kP=(0,aW.ZP)(lY.Zb)(nj||(nj=kT(kE(O=["\n max-width: ","px;\n"],"raw",{value:kT(O.slice())}))),e=>{let{theme:t}=e;return t.sanity.container[1]});function kA(e){let{value:t,onFocus:n,vertical:i,...r}=e,[l,a]=lK.useState(!1),[o,s]=lK.useState(null);(0,lY.O8)(()=>a(!1),[o]);let d=lK.useCallback(e=>{("Escape"===e.key||"Tab"===e.key)&&a(!1)},[]),c=(0,lK.useCallback)(()=>{a(e=>!e)},[]),u=(0,sy.wq)(t);return(0,lU.jsx)(lY.J2,{open:l,ref:s,onKeyDown:d,portal:!0,constrainSize:!0,tone:"default",content:(0,lU.jsx)(kP,{margin:1,padding:3,onKeyDown:d,tabIndex:0,overflow:"auto",children:(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsxs)(lY.xv,{weight:"semibold",children:["Item of type ",(0,lU.jsx)("code",{children:u})," not valid for this list"]}),(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"Why is this happening?"}),(0,lU.jsxs)(lY.xv,{size:1,children:["The current schema does not declare items of type ",(0,lU.jsx)("code",{children:u})," as valid for this list. This could mean that the type has been removed as a valid item type, or that someone else has added it to their own local schema that is not yet deployed."]}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsxs)(lY.xv,{size:1,children:[(0,lU.jsx)(a0.sLo,{})," You can still move or delete this item, but it cannot be edited since the schema definition for its type is nowhere to be found."]})}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,lU.jsx)(lY.Zb,{padding:2,overflow:"auto",border:!0,children:(0,lU.jsx)(lY.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,lU.jsx)(lY.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,flex:1,onFocus:n,onClick:c,onKeyDown:d,__unstable_focusRing:!0,...r,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{marginRight:3,children:(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.Tzq,{})})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsxs)(lY.xv,{size:1,textOverflow:"ellipsis",children:["Item of type ",(0,lU.jsx)("code",{children:u})," not valid for this list"]})})]})})})}function kO(e){let{member:t}=e;return"INVALID_ITEM_TYPE"===t.error.type?(0,lU.jsx)(kA,{value:t.error.value}):(0,lU.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})}let kz=(0,lK.memo)(function(e){let{member:t,renderAnnotation:n,renderBlock:i,renderInput:r,renderInlineBlock:l,renderField:a,renderItem:o,renderPreview:s}=e;return"field"===t.kind?(0,lU.jsx)(kd,{member:t,renderAnnotation:n,renderBlock:i,renderInlineBlock:l,renderInput:r,renderField:a,renderItem:o,renderPreview:s},t.key):"error"===t.kind?(0,lU.jsx)(kw,{member:t},t.key):"fieldSet"===t.kind?(0,lU.jsx)(kk,{member:t,renderAnnotation:n,renderBlock:i,renderInlineBlock:l,renderInput:r,renderField:a,renderItem:o,renderPreview:s},t.key):(console.warn(Error("Unhandled member kind ".concat(t.kind))),null)});function kM(e){let{members:t,renderAnnotation:n,renderBlock:i,renderInput:r,renderInlineBlock:l,renderField:a,renderItem:o,renderPreview:s}=e,d=(0,lK.useMemo)(()=>t.map(e=>(0,lU.jsx)(kz,{member:e,renderAnnotation:n,renderBlock:i,renderField:a,renderInlineBlock:l,renderInput:r,renderItem:o,renderPreview:s},e.key)),[t,n,i,a,l,r,o,s]);return(0,lU.jsx)(lU.Fragment,{children:d})}let kI=e=>{let{children:t}=e;return t},kR=(0,lK.memo)(function(e){let t=(0,lK.useMemo)(()=>"absolutePath"in e?e.absolutePath:e.path.concat(e.relativePath),[e]),n=(0,lK.useCallback)(()=>(0,lU.jsx)(lU.Fragment,{children:"Missing destination render function"}),[]);return(0,lU.jsx)(kF,{...e,absolutePath:t,destinationRenderAnnotation:e.renderAnnotation||n,destinationRenderBlock:e.renderBlock||n,destinationRenderField:e.renderField,destinationRenderInlineBlock:e.renderInlineBlock||n,destinationRenderInput:e.renderInput,destinationRenderItem:e.renderItem,destinationRenderPreview:e.renderPreview})}),kF=(0,lK.memo)(function e(t){let{absolutePath:n,destinationRenderAnnotation:i,destinationRenderBlock:r,destinationRenderField:l,destinationRenderInlineBlock:a,destinationRenderInput:o,destinationRenderItem:s,destinationRenderPreview:d}=t,c=(0,lK.useCallback)(t=>{let c=(0,lB.Xy)(t.path,n)||(0,lB.Ny)(n,t.path);if(c)return o(t);if(!wT(t)&&!wE(t))throw Error("Expected either object input props or array input props for: ".concat(JSON.stringify(t.path)));return(0,lU.jsx)(e,{...t,absolutePath:n,destinationRenderAnnotation:i,destinationRenderBlock:r,destinationRenderInput:o,destinationRenderItem:s,destinationRenderField:l,destinationRenderInlineBlock:a,destinationRenderPreview:d})},[n,i,r,l,a,o,s,d]),u=(0,lK.useCallback)(e=>{let i=(0,lB.Ny)(n,e.path)&&(t.includeField||!(0,lB.Xy)(n,e.path));return i?l(e):kI(e)},[n,l,t.includeField]),p=(0,lK.useCallback)(e=>{let i=(0,lB.Ny)(n,e.path)&&(t.includeItem||!(0,lB.Xy)(n,e.path));return i?s(e):kI(e)},[n,s,t.includeItem]),h=(0,lK.useCallback)(e=>{let i=(0,lB.Ny)(n,e.path)&&(t.includeItem||!(0,lB.Xy)(n,e.path));return i?r(e):kI(e)},[n,r,t.includeItem]),f=(0,lK.useCallback)(e=>{let i=(0,lB.Ny)(n,e.path)&&(t.includeItem||!(0,lB.Xy)(n,e.path));return i?a(e):kI(e)},[n,a,t.includeItem]),m=(0,lK.useCallback)(e=>{let r=(0,lB.Ny)(n,e.path)&&(t.includeItem||!(0,lB.Xy)(n,e.path));return r?i(e):kI(e)},[n,i,t.includeItem]);if(wE(t)){let e=(0,lB.fi)(t.path,n),i=t.members.find(t=>"item"==t.kind&&(0,lV.Fd)(e[0])&&t.key===e[0]._key);if(!i){let e=(0,lB.fi)(t.path,n),i=e[0]._key;return(0,lU.jsxs)("div",{children:["No array item with _key ",(0,lU.jsxs)("code",{children:['"',i,'"']})," found at path ",JSON.stringify(t.path)]})}return"error"===i.kind?(0,lU.jsx)(kO,{member:i}):(0,lU.jsx)(kC,{member:i,renderAnnotation:m,renderBlock:h,renderInput:c,renderField:u,renderInlineBlock:f,renderItem:p,renderPreview:d})}if(wT(t)){let e=(0,lB.fi)(t.path,n),i=t.members.find(t=>"field"==t.kind&&e[0]===t.name);if(!i){let t=e[0];return(0,lU.jsxs)("div",{children:["Field ",JSON.stringify(t)," not found among members â please verify that it's both defined in the schema and that it has not been conditionally hidden."]})}return(0,lU.jsx)(kd,{member:i,renderAnnotation:m,renderBlock:h,renderInput:c,renderInlineBlock:f,renderField:u,renderItem:p,renderPreview:d})}throw Error("FormInput can only be used with arrays or objects")}),kD=(0,lK.createContext)(null);function kZ(e){let{scrollElement:t,containerElement:n}=e;return(0,lU.jsx)(kD.Provider,{value:{scrollElement:t,containerElement:n},children:e.children})}let kL=[0,0,1,0];function kq(e){let{children:t,header:n,id:i,legacy_referenceElement:r,onClose:l,type:a,width:o,autofocus:s}=e,[d,c]=(0,lK.useState)(null),u=(0,lK.useRef)(null),p=(0,lU.jsx)(jt,{margins:kL,children:(0,lU.jsx)(lY.xu,{ref:u,padding:4,children:t})});
1return"dialog"===a?(0,lU.jsx)(kZ,{scrollElement:d,containerElement:u,children:(0,lU.jsx)(lY.Vq,{header:n,id:i||"",onClickOutside:l,onClose:l,width:o,contentRef:c,__unstable_autoFocus:s,children:p})}):(0,lU.jsx)(uT,{header:n,onClose:l,referenceElement:r,width:o,containerRef:c,children:(0,lU.jsx)(kZ,{scrollElement:d,containerElement:u,children:p})})}let kN={portal:!0,tone:"default"},kV={position:"absolute",top:0,left:0,bottom:0,right:0,opacity:.6},kU={position:"relative"};function kB(e){var t,n,i,r,l,a;let{schemaType:o,parentSchemaType:s,path:d,readOnly:c,onRemove:u,value:p,open:h,onInsert:f,onFocus:m,onOpen:g,onClose:x,changed:v,focused:b,children:y,inputProps:{renderPreview:j}}=e,w=!c&&(null==(t=s.options)?void 0:t.sortable)!==!1,k=s.of,C=(0,lK.useRef)(null);yp(C,h),m$(b,(e,t)=>{var n;!e&&t&&C.current&&(null==(n=C.current)||n.focus())});let _=p._resolvingInitialValue,S=(0,lK.useCallback)(()=>{f({items:[{...p,_key:yf()}],position:"after"})},[f,p]),T=(0,lK.useCallback)((e,t)=>{f({items:[wl(t)],position:e})},[f]),E=gi(d,!0),P=(0,lK.useMemo)(()=>0===E.length?null:(0,lU.jsx)(yF,{presence:E,maxAvatars:1}),[E]),A=ga(d,!0),O=(0,lK.useMemo)(()=>0===A.length?null:(0,lU.jsx)(lY.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,lU.jsx)(js,{validation:A,__unstable_showSummary:!0})}),[A]),z=A.some(e=>"error"===e.level),M=A.some(e=>"warning"===e.level),I=(0,lK.useMemo)(()=>c?null:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg}),id:"".concat(e.inputId,"-menuButton"),menu:(0,lU.jsxs)(lY.v2,{children:[(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:u}),(0,lU.jsx)(lY.sN,{text:"Duplicate",icon:a0.TIy,onClick:S}),(0,lU.jsx)(wo,{types:k,onInsert:T})]}),popover:kN}),[S,T,u,k,e.inputId,c]),R=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:c,hasErrors:z,hasWarnings:M}),F=(0,lU.jsx)(j2,{menu:I,presence:P,validation:O,tone:R,focused:b,dragHandle:w,selected:h,children:(0,lU.jsxs)(lY.Zb,{as:"button",type:"button",tone:"inherit",radius:2,disabled:_,padding:1,onClick:g,ref:C,onFocus:m,__unstable_focusRing:!0,style:kU,children:[j({schemaType:e.schemaType,value:e.value,layout:"default",skipVisibilityCheck:!0}),_&&(0,lU.jsx)(lY.Zb,{style:kV,tone:"transparent",radius:2,as:lY.kC,justify:"center",children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"center",padding:3,children:[(0,lU.jsx)(lY.xu,{marginX:3,children:(0,lU.jsx)(lY.$j,{muted:!0})}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:"Resolving initial valueâ¦"})]})})]})}),D=fk(o);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(cD,{path:d,isChanged:v,hasFocus:!!b,children:(0,lU.jsx)(lY.xu,{paddingX:1,children:F})}),h&&(0,lU.jsx)(kq,{header:c?"View ".concat(D):"Edit ".concat(D),type:(null==(i=null==(n=null==s?void 0:s.options)?void 0:n.modal)?void 0:i.type)||"dialog",width:null!=(a=null==(l=null==(r=null==s?void 0:s.options)?void 0:r.modal)?void 0:l.width)?a:1,id:p._key,onClose:x,autofocus:b,legacy_referenceElement:C.current,children:y})]})}function kK(e){var t;return(null==(t=e.components)?void 0:t.item)?e.components.item:(0,lV.dD)(e)?wS:kB}let kH={portal:!0,tone:"default"};function kW(e){var t,n,i,r,l,a,o,s,d,c;let u=(0,lK.useRef)(null),{schemaType:p,path:h,open:f,inputId:m,children:g,inputProps:x}=e,{readOnly:v,focused:b,renderPreview:y,onChange:j}=e.inputProps,w=(0,lK.useCallback)(()=>x.onChange(mD()),[x]),k=e.value,{EditReferenceLink:C,getReferenceInfo:_,selectedState:S,isCurrentDocumentLiveEdit:T}=EI({path:h,schemaType:p,value:k});yp(u,f),m$(b,(e,t)=>{!e&&t&&u.current&&u.current.focus()});let E=e.validation.some(e=>"error"===e.level),P=e.validation.some(e=>"warning"===e.level),A=wu(null==k?void 0:k._ref,_),O=(null==(t=A.result)?void 0:t.type)||(null==(n=null==k?void 0:k._strengthenOnPublish)?void 0:n.type),z=O?p.to.find(e=>e.name===O):void 0,M="pressed"===S,I="selected"===S,R=null==k?void 0:k._ref,F=R&&(null==(l=null==(r=null==(i=A.result)?void 0:i.preview)?void 0:r.published)?void 0:l._id),D=(0,lK.useCallback)(()=>{j([!0===p.weak?mF(!0,["_weak"]):mD(["_weak"]),mD(["_strengthenOnPublish"])])},[j,p.weak]),Z=(0,lK.useCallback)(()=>{j(!0===p.weak?mF(!0,["_weak"]):mD(["_weak"]))},[j,p]),L=(0,lK.useCallback)(()=>
1{x.onPathFocus(["_ref"])},[x]),q=(null==k?void 0:k._weak)?"weak":"strong",N=!0===p.weak?"weak":"strong",V=R&&!A.isLoading&&(null==k?void 0:k._strengthenOnPublish),U=!A.isLoading&&(null==(a=A.result)?void 0:a.availability.available)&&R&&q!==N&&!V,B=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:v,hasErrors:E,hasWarnings:P}),K=!(null==k?void 0:k._ref)||"_ref"===x.focusPath[0],H=(null==(o=A.result)?void 0:o.preview.draft)||(null==(s=A.result)?void 0:s.preview.published),W=(0,lU.jsxs)(lU.Fragment,{children:[T&&F&&k._strengthenOnPublish&&(0,lU.jsx)(wi,{padding:1,title:p.weak?"Finalize reference":"Convert to strong reference",status:"info","data-testid":"alert-reference-published",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:[(0,lU.jsx)("strong",{children:null==(c=null==(d=A.result)?void 0:d.preview.published)?void 0:c.title})," is published and this reference should now be"," ",p.weak?(0,lU.jsx)(lU.Fragment,{children:"finalized"}):(0,lU.jsx)(lU.Fragment,{children:"converted to a strong reference"}),"."]}),(0,lU.jsx)(lY.zx,{onClick:D,text:(0,lU.jsx)(lU.Fragment,{children:"Convert to strong reference"}),tone:"positive"})]})}),U&&(0,lU.jsx)(wi,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,lU.jsx)("em",{children:q}),", but according to the current schema it should be"," ",(0,lU.jsxs)("em",{children:[N,"."]})]}),(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:p.weak?(0,lU.jsxs)(lU.Fragment,{children:["It will not be possible to delete the"," ",(null==H?void 0:H.title)?(0,lU.jsxs)(lU.Fragment,{children:['"',null==H?void 0:H.title,'"-document']}):(0,lU.jsx)(lU.Fragment,{children:"referenced document"})," ","without first removing this reference."]}):(0,lU.jsxs)(lU.Fragment,{children:["This makes it possible to delete the"," ",(null==H?void 0:H.title)?(0,lU.jsxs)(lU.Fragment,{children:['"',null==H?void 0:H.title,'"-document']}):(0,lU.jsx)(lU.Fragment,{children:"referenced document"}
1)," ","without first deleting this reference, leaving this field referencing a nonexisting document."]})}),(0,lU.jsx)(lY.zx,{onClick:Z,text:(0,lU.jsxs)(lU.Fragment,{children:["Convert to ",N," reference"]}),tone:"caution"})]})}),A.error&&(0,lU.jsx)(wi,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["Error: ",A.error.message]}),(0,lU.jsx)(lY.zx,{onClick:A.retry,text:(0,lU.jsx)(lU.Fragment,{children:"Retry"}),tone:"primary"})]})})]}),$=(0,lK.useMemo)(()=>(0,lK.forwardRef)(function(e,t){return(0,lU.jsx)(a1.nR,{...e,intent:"edit",params:{id:null==k?void 0:k._ref,type:null==z?void 0:z.name},target:"_blank",rel:"noopener noreferrer",ref:t})}),[null==z?void 0:z.name,null==k?void 0:k._ref]),X=(0,lK.useMemo)(()=>v?null:(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{paddingY:3,paddingX:2,mode:"bleed",icon:a0.zGg}),id:"".concat(m,"-menuButton"),menu:(0,lU.jsxs)(lY.v2,{children:[!v&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.sN,{text:"Clear",tone:"critical",icon:a0.XHJ,onClick:w}),(0,lU.jsx)(lY.sN,{text:"Replace",icon:a0.bnu,onClick:L})]}),!v&&(null==k?void 0:k._ref)&&(0,lU.jsx)(lY.R,{}),(null==k?void 0:k._ref)&&(0,lU.jsx)(lY.sN,{as:$,"data-as":"a",text:"Open in new tab",icon:a0.buG})]}),popover:kH})}),[w,L,m,$,v,null==k?void 0:k._ref]);return(0,lU.jsx)(jm,{__unstable_headerActions:e.actions,level:e.level,title:e.title,description:e.description,validation:e.validation,__unstable_presence:e.presence,children:K?(0,lU.jsx)(lY.xu,{paddingY:2,children:g}):(0,lU.jsx)(lY.Zb,{shadow:1,radius:1,padding:1,tone:B,children:(0,lU.jsxs)(lY.Kq,{space:1,children:[(0,lU.jsxs)(lY.kC,{gap:1,align:"center",children:[(0,lU.jsx)(wj,{flex:1,as:C,tone:"inherit",radius:2,documentId:null==k?void 0:k._ref,documentType:null==z?void 0:z.name,paddingX:2,paddingY:1,__unstable_focusRing:!0,selected:I,pressed:M,ref:u,"data-selected":!!I||void 0,"data-pressed":!!M||void 0,children:(0,lU.jsx)(wf,{value:k,referenceInfo:A,renderPreview:y,type:p})}),(0,lU.jsx)(lY.xu,{children:X})]}),W]})})})}function k$(e,t){return op()(e.options,t)}let kX=["array","file","image","reference","slug"],kG=["asset","crop","hotspot","_ref","_weak"],kY=["tags"],kJ=["slug"];function kQ(e,t){if(!e||t.has(e))return[];t.add(e);let n=e.type?kQ(e.type,t):[];return[e,...n]}function k0(e){let{onMouseEnter:t,onMouseLeave:n}=gs();return(0,lU.jsx)(cD,{path:e.path,hasFocus:!!e.inputProps.focused,isChanged:e.inputProps.changed,onMouseEnter:t,onMouseLeave:n,children:e.children})}function k1(e){let{onMouseEnter:t,onMouseLeave:n}=gs();return(0,lU.jsx)(jm,{__unstable_headerActions:e.actions,__unstable_presence:e.presence,"data-testid":"field-".concat(e.inputId),description:e.description,inputId:e.inputId,level:e.level,onMouseEnter:t,onMouseLeave:n,title:e.title,validation:e.validation,children:(0,lU.jsx)(cD,{path:e.path,hasFocus:!!e.inputProps.focused,isChanged:e.inputProps.changed,children:e.children})})}function k2(e){let{onMouseEnter:t,onMouseLeave:n}=gs();return(0,lU.jsx)(jA,{__unstable_headerActions:e.actions,"data-testid":"field-".concat(e.inputId),level:e.level,title:e.title,description:e.description,collapsed:e.collapsed,collapsible:e.collapsible,onCollapse:e.onCollapse,onExpand:e.onExpand,onMouseEnter:t,onMouseLeave:n,validation:e.validation,__unstable_presence:e.presence,children:e.children})}function k3(e){let{onMouseEnter:t,onMouseLeave:n}=gs(),i=e.inputProps.members.find(e=>"field"===e.kind&&"hotspot"===e.name),r=(null==i?void 0:i.open)?e.presence:e.presence.concat((null==i?void 0:i.field.presence)||[]);return(0,lU.jsx)(jA,{__unstable_headerActions:e.actions,level:e.level,title:e.title,description:e.description,collapsed:e.collapsed,collapsible:e.collapsible,onCollapse:e.onCollapse,onExpand:e.onExpand,onMouseEnter:t,onMouseLeave:n,validation:e.validation,__unstable_presence:r,children:e.children})}function k4(e){var t;if(null==(t=e.components)?void 0:t.field)return e.components.field;if((0,lV.EG)(e))return k0;let n=kQ(e,new Set);return n.some(e=>"image"===e.name||"file"===e.name)?k3:n.some(e=>(0,lV.dD)(e))?kW:"object"!==e.jsonType&&"array"!==e.jsonType?k1:k2}var k5=Object.freeze,k6=Object.defineProperty;let k8=aW.ZP.div(nw||(nw=k5(k6(z=["\n display: flex;\n pointer-events: all;\n"],"raw",{value:k5(z.slice())}))));function k9(e){let t=(0,sj._F)(),{block:n,onChange:i,renderBlockActions:r}=e,l=(0,lK.useMemo)(()=>t.schemaTypes.decorators.map(e=>e.value),[t]),a=(0,lK.useMemo)(()=>
1{if(r){let e={block:n,value:sj.q$.getValue(t),set:function(e){let{allowedDecorators:t,block:n,onChange:i}=e;return e=>{let r=[mF((0,sT.nX)(e,{allowedDecorators:t}),[{_key:n._key}])];return i(mN.from(r))}}({allowedDecorators:l,block:n,onChange:i}),unset:function(e){let{block:t,onChange:n}=e;return()=>{let e=[mD([{_key:t._key}])];return n(mN.from(e))}}({block:n,onChange:i}),insert:function(e){let t;let{allowedDecorators:n,block:i,onChange:r}=e;return e=>{t=(t=Array.isArray(e)?e:[e]).map(e=>(0,sT.nX)(e,{allowedDecorators:n}));let l=[mR(t,"after",[{_key:i._key}])];return r(mN.from(l))}}({allowedDecorators:l,block:n,onChange:i})};return r(e)}},[r,n,t,i,l]);return a?(0,lU.jsx)(k8,{contentEditable:!1,children:a}):null}var k7=Object.freeze,Ce=Object.defineProperty,Ct=(e,t)=>k7(Ce(e,"raw",{value:k7(t||e.slice())}));let Cn=aW.ZP.div(e=>{let{theme:t}=e,{radius:n,space:i,color:r}=t.sanity,l=(0,lY.m4)(r.spot.yellow,.2);return(0,aW.iv)(nk||(nk=Ct(["\n position: absolute;\n border-radius: ","px;\n top: -","px;\n bottom: -","px;\n left: ","px;\n right: 0;\n background-color: ",";\n "])),n[3],i[2],i[1]+i[1],i[4]+i[1],l)});var Ci=Object.freeze,Cr=Object.defineProperty,Cl=(e,t)=>Ci(Cr(e,"raw",{value:Ci(t||e.slice())}));let Ca=(0,aW.ZP)(cD)(()=>(0,aW.iv)(nC||(nC=Cl(["\n width: 1px;\n height: 100%;\n\n & > div {\n height: 100%;\n }\n "]))));function Co(e){return e.type?Co(e.type):"block"===e.name}function Cs(e){return"field"===e.kind&&"array"===e.field.schemaType.jsonType}let Cd=["@@_NONEXISTENT_PATH_@@"];function Cc(e){let t=(0,lK.useRef)(null),n=(null==e?void 0:e.validation)&&e.validation.length>0?e.validation:co,i=ga((null==e?void 0:e.path)||Cd),r=(0,lK.useMemo)(()=>(null==e?void 0:e.schemaType)&&Co(null==e?void 0:e.schemaType)?n:n.concat(i),[i,e,n]),[l,a,o]=(0,lK.useMemo)(()=>[r.filter(e=>"error"===e.level).length>0,r.filter(e=>"warning"===e.level).length>0,r.filter(e=>"info"===e.level).length>0],[r]),s=ge(t.current,r);return t.current=s,(0,lK.useMemo)(()=>({validation:s,hasError:l,hasWarning:a,hasInfo:o}),[s,l,a,o])}let Cu=(0,lK.createContext)([]);function Cp(e){return(0,lU.jsx)(Cu.Provider,{value:e.markers,children:e.children})}function Ch(e){let t=(0,lK.useContext)(Cu);if(!t)throw Error("Form context not provided");let n=(0,lK.useMemo)(()=>t.filter(t=>(0,lB.Xy)(t.path,e)),[t,e]);return n}let Cf=(0,lK.createContext)([]);function Cm(e){return(0,lU.jsx)(Cf.Provider,{value:e.memberItems,children:e.children})}function Cg(e){let t=(0,lK.useContext)(Cf);if(!t)throw Error("Form context not provided");return t.find(t=>t.key===e)}function Cx(e){}var Cv=Object.freeze,Cb=Object.defineProperty,Cy=(e,t)=>Cv(Cb(e,"raw",{value:Cv(t||e.slice())}));let Cj=(0,aW.ZP)(lY.Zb)(e=>{var t;let{color:n,radius:i,space:r}=e.theme.sanity,l=(0,aW.iv)(n_||(n_=Cy(["\n pointer-events: none;\n content: '';\n position: absolute;\n top: -","px;\n bottom: -","px;\n left: -","px;\n right: -","px;\n border-radius: ","px;\n mix-blend-mode: ",";\n "])),r[1],r[1],r[1],r[1],i[2],n.dark?"screen":"multiply");return(0,aW.iv)(nS||(nS=Cy(["\n box-shadow: 0 0 0 1px var(--card-border-color);\n border-radius: ","px;\n pointer-events: all;\n position: relative;\n\n &[data-focused] {\n box-shadow: 0 0 0 1px ",";\n }\n\n &:not([data-focused]):not([data-selected]) {\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n\n &[data-markers] {\n &:after {\n ","\n background-color: ",";\n }\n }\n\n &[data-warning] {\n &:after {\n ","\n background-color: ",";\n }\n\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n\n &[data-invalid] {\n &:after {\n ","\n background-color: ",";\n }\n\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n "])),i[1],null==(t=n.selectable)?void 0:t.primary.selected.border,n.input.default.hovered.border,l,n.dark?a8.VG.purple[950].hex:a8.VG.purple[50].hex,l,n.muted.caution.hovered.bg,n.muted.caution.hovered.border,l,n.input.invalid.enabled.bg,n.input.invalid.hovered.border)}),Cw=(0,aW.ZP)(lY.xu)(nT||(nT=Cy(["\n display: block;\n width: 100%;\n user-select: none;\n pointer-events: all;\n"]))),Ck=aW.ZP.div(e=>{let{theme:t,$hasChanges:n}=e,{space:i}=t.sanity;return(0,aW.iv)(nP||(nP=Cy(["\n position: absolute;\n width: ","px;\n right: 0;\n top: 0;\n bottom: 0;\n padding-left: ","px;\n user-select: none;\n\n ","\n\n [data-dragged] & {\n visibility: hidden;\n }\n "])),i[2],i[1],!n&&(0,aW.iv)(nE||(nE=Cy(["\n display: none;\n "]))))}),CC=(0,aW.ZP)(lY.kC)(nA||(nA=Cy(["\n position: relative;\n\n [data-dragged] > & {\n opacity: 0.5;\n }\n"]))),C_=(0,aW.ZP)(lY.xu)(nO||(nO=Cy(["\n width: 25px;\n position: relative;\n\n [data-dragged] & {\n visibility: hidden;\n }\n"]))),CS=(0,aW.ZP)(lY.kC)(nz||(nz=Cy(["\n position: absolute;\n right: 0;\n [data-dragged] & {\n visibility: hidden;\n }\n"]))),CT=(0,aW.ZP)(lY.xu)(nM||(nM=Cy(["\n max-width: 250px;\n"]))),CE={constrainSize:!0,placement:"bottom",portal:"default",tone:"default"};function CP(e){let{children:t,focused:n,isOpen:i,onOpen:r,onRemove:l,readOnly:a,value:o}=e,s=(0,lK.useId)(),d=(0,lK.useRef)(null),c=(0,lK.useRef)(!1),u=(0,lK.useMemo)(()=>(0,lV.Yk)(o)?(0,lK.forwardRef)(function(e,t){return(0,lU.jsx)(a1.nR,{...e,intent:"edit",params:{id:o._ref},ref:t})}):void 0,[o]);(0,lK.useEffect)(()=>
1{i&&(c.current=!1)},[i]),(0,lY.qh)((0,lK.useCallback)(e=>{n&&("Tab"!==e.key||!d.current||c.current||i||(e.preventDefault(),e.stopPropagation(),d.current.focus(),c.current=!0))},[n,i]));let p=(0,lK.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),l()},[l]);return(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{flex:1,children:t}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{"aria-label":"Open menu",fontSize:1,iconRight:a0.zGg,mode:"bleed",paddingX:2,tabIndex:n?0:1}),ref:d,id:s,menu:(0,lU.jsx)(lY.v2,{children:(0,lU.jsxs)(lU.Fragment,{children:["_ref"in o&&o._ref&&(0,lU.jsx)(lY.sN,{as:u,"data-as":"a",icon:a0.xPt,text:"Open reference"}),a&&(0,lU.jsx)(lY.sN,{icon:a0.hsE,onClick:r,text:"View"}),!a&&(0,lU.jsx)(lY.sN,{icon:a0.dY8,onClick:r,text:"Edit"}),!a&&(0,lU.jsx)(lY.sN,{icon:a0.XHJ,onClick:p,text:"Delete",tone:"critical"})]})}),popover:CE})})]})}let CA=e=>Array.isArray(e)?e.flatMap(CA):"number"==typeof e?[e]:"auto"===e?["auto"]:[],CO=e=>"dialog"===e||"popover"===e?e:void 0;function Cz(e){let{onClose:t,children:n,title:i,width:r=1,autoFocus:l}=e,a=(0,lK.useId)(),[o,s]=(0,lK.useState)(null),d=(0,lK.useRef)(null);return(0,lU.jsx)(lY.Vq,{header:i,id:a,onClickOutside:t,onClose:t,portal:"default",width:r,contentRef:s,__unstable_autoFocus:l,children:(0,lU.jsx)(jt,{margins:[0,0,1,0],children:(0,lU.jsx)(kZ,{scrollElement:o,containerElement:d,children:(0,lU.jsx)(lY.xu,{padding:4,ref:d,children:n})})})})}var CM=Object.freeze,CI=Object.defineProperty,CR=(e,t)=>CM(CI(e,"raw",{value:CM(t||e.slice())}));let CF=(0,aW.ZP)(lY.J2)(nI||(nI=CR(["\n &[data-popper-reference-hidden='true'] {\n visibility: hidden;\n pointer-events: none;\n }\n\n & > div {\n overflow: hidden;\n overflow: clip;\n }\n"]))),CD=(0,aW.ZP)(lY.xu)(nR||(nR=CR(["\n /* Prevent overflow caused by change indicator */\n overflow-x: hidden;\n overflow-y: auto;\n"]))),CZ=(0,aW.ZP)(lY.xu)(nF||(nF=CR(["\n box-shadow: 0 1px 0 var(--card-shadow-outline-color);\n position: relative;\n z-index: 10;\n min-height: auto;\n"]))),CL=["top","bottom"];function Cq(e){let{floatingBoundary:t,referenceBoundary:n,referenceElement:i,width:r=0}=e,[l,a]=(0,lK.useState)(!1);return(0,lK.useEffect)(()=>{a(!0)},[]),(0,lU.jsx)(CF,{content:(0,lU.jsx)(CN,{...e}),constrainSize:!0,"data-ui":"PopoverEditDialog",fallbackPlacements:CL,floatingBoundary:t,open:l,overflow:"auto",placement:"bottom",portal:"default",preventOverflow:!0,referenceBoundary:n,referenceElement:i,width:r})}function CN(e){let{onClose:t,referenceBoundary:n,referenceElement:i,title:r,autoFocus:l}=e;(0,lY.qh)((0,lK.useCallback)(e=>{"Escape"===e.key&&t()},[t])),(0,lY.O8)(t,i?[i]:[],n);let[a,o]=(0,lK.useState)(null),s=(0,lK.useRef)(null);return(0,lU.jsx)(kZ,{scrollElement:a,containerElement:s,children:(0,lU.jsxs)(lY.kC,{ref:s,direction:"column",height:"fill",children:[(0,lU.jsx)(CZ,{flex:"none",padding:1,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{flex:1,padding:2,children:(0,lU.jsx)(lY.xv,{weight:"semibold",children:r})}),(0,lU.jsx)(lY.zx,{autoFocus:!!l,icon:a0.Two,mode:"bleed",onClick:t,padding:2})]})}),(0,lU.jsx)(CD,{flex:1,children:(0,lU.jsx)(jt,{margins:[0,0,1,0],children:(0,lU.jsx)(lY.xu,{padding:3,ref:o,children:e.children})})})]})})}function CV(e){let{autoFocus:t,defaultType:n,floatingBoundary:i,onClose:r,referenceBoundary:l,referenceElement:a,schemaType:o}=e,s=(0,lK.useMemo)(()=>(function(e){var t;let n=null==(t=e.options)?void 0:t.modal;return"object"==typeof n&&null!==n?{type:CO(n.type),width:CA(n.width)}:void 0})(o),[o]),d=(null==s?void 0:s.type)||n,c=(0,lU.jsxs)(lU.Fragment,{children:["Edit ",o.title]}),u=(0,lK.useCallback)(()=>{r()},[r]),p=null==s?void 0:s.width;return"popover"===d?(0,lU.jsx)(Cq,{autoFocus:t,floatingBoundary:i,onClose:u,referenceBoundary:l,referenceElement:a,title:c,width:p,children:e.children}):(0,lU.jsx)(Cz,{onClose:u,title:c,width:p,autoFocus:t,children:e.children})}function CU(e){var t;let{floatingBoundary:n,focused:i,isFullscreen:r,onItemClose:l,onItemOpen:a,onPathFocus:o,path:s,readOnly:d,referenceBoundary:c,relativePath:u,renderAnnotation:p,renderBlock:h,renderBlockActions:f,renderCustomMarkers:m,renderField:g,renderInlineBlock:x,renderInput:v,renderItem:b,renderPreview:y,schemaType:j,selected:w,value:k}=e,{onChange:C}=m7(),{Markers:_}=mY().__internal.components,[S,T]=(0,lK.useState)(!1),E=Ch(s),P=(0,sj._F)(),A=Cg(gO(s)),O=(0,lK.useRef)(!1),z=(0,lK.useMemo)(()=>({anchor:{path:u,offset:0},focus:{path:u,offset:0}}),[u]),M=(0,lK.useCallback)(()=>T(!0),[]),I=(0,lK.useCallback)(()=>T(!1),[]),R=(0,lK.useCallback)(()=>{A&&(sj.q$.blur(P),a(A.node.path))},[P,A,a]),F=(0,lK.useCallback)(()=>
1{l(),sj.q$.select(P,z),sj.q$.focus(P)},[l,P,z]),D=(0,lK.useCallback)(()=>{if(!O.current)try{sj.q$.delete(P,z,{mode:"blocks"})}catch(e){console.error(e)}finally{O.current=!0}},[P,z]);(0,lK.useEffect)(()=>()=>{O.current&&sj.q$.focus(P)},[P]);let Z=(0,lK.useMemo)(()=>r&&!f?{paddingX:5}:r&&f?{paddingLeft:5,paddingRight:2}:f?{paddingLeft:3,paddingRight:2}:{paddingX:3},[r,f]),{validation:L,hasError:q,hasWarning:N,hasInfo:V}=Cc(null==A?void 0:A.node),U=P.schemaTypes.portableText,B=E.length>0,K=gi(s,!0),H=(0,lK.useMemo)(()=>K.filter(e=>(0,lB.Xy)(e.path,s)),[s,K]),W=q||N||V||B,$=(0,lK.useMemo)(()=>W&&(0,lU.jsx)(CT,{padding:2,children:(0,lU.jsx)(_,{markers:E,validation:L,renderCustomMarkers:m})})||null,[_,E,m,W,L]),X=!!(null==A?void 0:A.member.open),G=null==A?void 0:A.input,Y=(null==A?void 0:A.node.path)||co,J=null==(t=null==A?void 0:A.elementRef)?void 0:t.current,Q=(0,lK.useMemo)(()=>({__unstable_floatingBoundary:n,__unstable_referenceBoundary:c,__unstable_referenceElement:J||null,children:G,focused:i,markers:E,onClose:F,onOpen:R,onPathFocus:o,onRemove:D,open:X,parentSchemaType:U,path:Y,presence:H,readOnly:!!d,renderAnnotation:p,renderBlock:h,renderDefault:CB,renderField:g,renderInlineBlock:x,renderInput:v,renderItem:b,renderPreview:y,schemaType:j,selected:w,validation:L,value:k}),[n,J,G,i,E,F,R,o,D,X,U,Y,H,d,c,p,h,g,x,v,b,y,j,w,L,k]);return(0,lK.useMemo)(()=>(0,lU.jsx)(lY.xu,{ref:null==A?void 0:A.elementRef,contentEditable:!1,children:(0,lU.jsx)(lY.kC,{paddingBottom:1,marginY:3,style:Cx(),children:(0,lU.jsxs)(CC,{flex:1,children:[(0,lU.jsx)(lY.u,{placement:"top",portal:"editor",disabled:!W,content:$,children:(0,lU.jsx)(Cw,{...Z,children:h&&h(Q)})}),(0,lU.jsx)(C_,{marginRight:1,children:(0,lU.jsx)(CS,{children:f&&k&&i&&!d&&(0,lU.jsx)(k9,{block:k,onChange:C,renderBlockActions:f})})}),r&&A&&(0,lU.jsx)(Ck,{$hasChanges:A.member.item.changed,onMouseOut:I,onMouseOver:M,children:(0,lU.jsx)(Ca,{hasFocus:i,isChanged:A.member.item.changed,path:A.member.item.path,withHoverEffect:!1})}),S&&(0,lU.jsx)(Cn,{})]})})}),[Q,i,I,M,Z,r,A,C,d,h,f,S,$,W,k])}let CB=e=>{let{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,children:r,focused:l,markers:a,onClose:o,onOpen:s,onRemove:d,open:c,readOnly:u,renderPreview:p,schemaType:h,selected:f,value:m,validation:g}=e,x=(0,lV.Or)(m),v=g.filter(e=>"error"===e.level).length>0,b=g.filter(e=>"warning"===e.level).length>0,y=a.length>0,j=f||l?"primary":"default",w=(0,lK.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),s()},[s]);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(Cj,{"data-focused":l?"":void 0,"data-image-preview":x?"":void 0,"data-invalid":v?"":void 0,"data-markers":y?"":void 0,"data-read-only":u?"":void 0,"data-selected":f?"":void 0,"data-testid":"pte-block-object","data-warning":b?"":void 0,flex:1,onDoubleClick:w,padding:x?0:1,tone:j,children:p({actions:(0,lU.jsx)(CP,{isOpen:c,focused:l,onOpen:s,onRemove:d,readOnly:u,value:m}),layout:x?"blockImage":"block",schemaType:h,skipVisibilityCheck:!0,value:m})}),c&&(0,lU.jsx)(CV,{floatingBoundary:t,defaultType:"dialog",onClose:o,autoFocus:l,schemaType:h,referenceBoundary:n,referenceElement:i,children:r})]})},CK=[1,2,3,4,5,6,7,8,9],CH=["â","â","â "],CW=["number","lower-alpha","lower-roman"],C$={em:"em","strike-through":"s",underline:"u",strong:"strong",code:"code"},CX={h1:{paddingTop:5,paddingBottom:4},h2:{paddingTop:4,paddingBottom:4},h3:{paddingTop:4,paddingBottom:3},h4:{paddingTop:4,paddingBottom:3},h5:{paddingTop:4,paddingBottom:3},h6:{paddingTop:4,paddingBottom:2},normal:{paddingTop:2,paddingBottom:3},blockquote:{paddingTop:2,paddingBottom:3}};function CG(e){return"list-level-".concat(e)}var CY=Object.freeze,CJ=Object.defineProperty,CQ=(e,t)=>CY(CJ(e,"raw",{value:CY(t||e.slice())}));let C0=aW.ZP.div(function(e){var t;let{$level:n,theme:i}=e,{color:r,fonts:l,radius:a,space:o}=i.sanity,s=CW[(n-1)%CW.length],d=CH[(n-1)%CH.length];return(0,aW.iv)(nD||(nD=CQ(["\n --marker-bg-color: transparent;\n\n mix-blend-mode: ",";\n position: relative;\n\n & > [data-ui='TextBlock_inner'] {\n position: relative;\n flex: 1;\n }\n\n & >
1 div:before {\n content: '';\n position: absolute;\n top: -","px;\n bottom: -","px;\n left: -","px;\n right: -","px;\n border-radius: ","px;\n background-color: var(--marker-bg-color);\n // This is to make sure the marker is always behind the text\n z-index: -1;\n }\n\n &[data-markers] {\n --marker-bg-color: ",";\n }\n\n &[data-warning] {\n --card-border-color: ",";\n --marker-bg-color: ",";\n }\n\n &[data-error] {\n --card-border-color: ",";\n --marker-bg-color: ",";\n }\n\n & [data-list-prefix] {\n position: absolute;\n margin-left: -4.5rem;\n width: 3.75rem;\n text-align: right;\n box-sizing: border-box;\n }\n\n &[data-list-item='number'] [data-list-prefix] {\n font-variant-numeric: tabular-nums;\n\n & > span:before {\n content: counter(",") '.';\n content: counter(",", ",") '.';\n }\n }\n\n &[data-list-item='bullet'] [data-list-prefix] {\n & > span {\n position: relative;\n top: -0.1875em;\n\n &:before {\n content: '","';\n font-size: 0.46666em;\n }\n }\n }\n\n & [data-text] {\n overflow-wrap: anywhere;\n text-transform: none;\n white-space: pre-wrap;\n font-family: ",";\n flex: 1;\n\n *::selection {\n background-color: ",";\n }\n }\n "])),r.dark?"screen":"multiply",o[1],o[1],o[1],o[1],a[2],r.dark?a8.VG.purple[950].hex:a8.VG.purple[50].hex,r.muted.caution.enabled.border,r.muted.caution.hovered.bg,r.muted.critical.enabled.border,r.muted.critical.hovered.bg,CG(n),CG(n),s,d,l.text.family,null==(t=r.selectable)?void 0:t.primary.pressed.bg)}),C1=(0,aW.ZP)(lY.xu)(nZ||(nZ=CQ(["\n position: relative;\n display: flex;\n"]))),C2=aW.ZP.div(nL||(nL=CQ(["\n user-select: none;\n white-space: nowrap;\n"]))),C3=(0,aW.ZP)(lY.xu)(nq||(nq=CQ(["\n user-select: none;
1\n"]))),C4=(0,aW.ZP)(lY.xu)(nN||(nN=CQ(["\n line-height: 0;\n width: 25px;\n position: relative;\n"]))),C5=(0,aW.ZP)(lY.kC)(e=>{let{theme:t}=e,{fonts:n,space:i}=t.sanity,r=n.text.sizes[1],l=n.text.sizes[2],a=r.lineHeight-r.ascenderHeight-r.descenderHeight,o=l.lineHeight-l.ascenderHeight-l.descenderHeight,s=a+i[2]+i[2];return(0,aW.iv)(nV||(nV=CQ(["\n user-select: none;\n position: absolute;\n right: 0;\n top: ","px;\n "])),0-(s-o)/2)}),C6=(0,aW.ZP)(lY.xu)(nU||(nU=CQ(["\n max-width: 250px;\n"]))),C8=(0,aW.ZP)(lY.kC)(nB||(nB=CQ(["\n position: relative;\n padding-left: ","px;\n"])),e=>{let{$level:t}=e;return t?32*t:0}),C9=aW.ZP.div(e=>{let{theme:t,$hasChanges:n}=e,{space:i}=t.sanity;return(0,aW.iv)(nH||(nH=CQ(["\n position: absolute;\n width: ","px;\n right: 0;\n top: 0;\n bottom: 0;\n padding-left: ","px;\n user-select: none;\n\n ","\n "])),i[2],i[1],!n&&(0,aW.iv)(nK||(nK=CQ(["\n display: none;\n "]))))});var C7=Object.freeze,_e=Object.defineProperty,_t=(e,t)=>C7(_e(e,"raw",{value:C7(t||e.slice())}));let _n=aW.ZP.div(nW||(nW=_t(["\n display: block;\n"]))),_i=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.xv,{"data-testid":"text-style--normal",...n,children:(0,lU.jsx)(_n,{children:t})})},_r=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h1","data-testid":"text-style--h1",size:5,...n,children:(0,lU.jsx)(_n,{children:t})})},_l=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h2","data-testid":"text-style--h2",size:4,...n,children:(0,lU.jsx)(_n,{children:t})})},_a=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h3","data-testid":"text-style--h3",size:3,...n,children:(0,lU.jsx)(_n,{children:t})})},_o=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h4","data-testid":"text-style--h4",size:2,...n,children:(0,lU.jsx)(_n,{children:t})})},_s=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h5","data-testid":"text-style--h5",size:1,...n,children:(0,lU.jsx)(_n,{children:t})})},_d=e=>{let{children:t,...n}=e;return(0,lU.jsx)(lY.X6,{as:"h6","data-testid":"text-style--h6",size:0,...n,children:(0,lU.jsx)(_n,{children:t})})},_c=aW.ZP.blockquote(n$||(n$=_t(["\n position: relative;\n display: block;\n margin: 0;\n padding-left: ","px;\n\n &::before {\n content: '';\n position: absolute;\n left: 0;\n top: -4px;\n bottom: -4px;\n width: 3px;\n background: var(--card-border-color);\n }\n"])),e=>{let{theme:t}=e;return t.sanity.space[3]}),_u=e=>{let{children:t,...n}=e;return(0,lU.jsx)(_c,{"data-testid":"text-style--blockquote",...n,children:(0,lU.jsx)(lY.xv,{as:"p",children:t})})},_p={normal:_i,h1:_r,h2:_l,h3:_a,h4:_o,h5:_s,h6:_d,blockquote:_u};function _h(e){let{children:t,floatingBoundary:n,focused:i,isFullscreen:r,onItemClose:l,onItemOpen:a,onPathFocus:o,path:s,readOnly:d,referenceBoundary:c,renderBlock:u,renderAnnotation:p,renderBlockActions:h,renderCustomMarkers:f,renderField:m,renderInlineBlock:g,renderInput:x,renderItem:v,renderPreview:b,schemaType:y,selected:j,spellCheck:w,value:k}=e,{Markers:C}=mY().__internal.components,[_,S]=(0,lK.useState)(!1),T=Ch(s),E=Cg(gO(s)),P=(0,sj._F)(),{onChange:A}=m7(),O=gi(s,!0),z=(0,lK.useMemo)(()=>O.filter(e=>(0,lB.Xy)(e.path,s)||"children"===e.path.slice(-3)[1]&&e.path.length-s.length==2),[s,O]),M=(0,lK.useCallback)(()=>S(!0),[]),I=(0,lK.useCallback)(()=>S(!1),[]),{validation:R,hasError:F,hasWarning:D,hasInfo:Z}=Cc(null==E?void 0:E.node),L=!!f&&T.length>0,q=F||D||L||Z,N=(0,lK.useCallback)(()=>{E&&a(E.node.path)},[a,E]),V=(0,lK.useCallback)(()=>{sj.q$.delete(P,{focus:{path:s,offset:0},anchor:{path:s,offset:0}},{mode:"blocks"}),setTimeout(()=>sj.q$.focus(P))},[P,s]),U=(0,lK.useMemo)(()=>(0,lU.jsxs)(C8,{align:"flex-start",$level:null==k?void 0:k.level,children:[k.listItem&&(0,lU.jsx)(C2,{contentEditable:!1,children:(0,lU.jsx)(lY.xv,{"data-list-prefix":"",children:(0,lU.jsx)(_n,{})})}),(0,lU.jsx)("div",{"data-text":"",style:Cx(),children:t})]}),[k.listItem,k.level,t]),B=(0,lK.useMemo)(()=>r&&!h?{paddingX:5}:r&&h?{paddingLeft:5,paddingRight:2}:h?{paddingLeft:3,paddingRight:2}:{paddingX:3},[r,h]),K=(0,lK.useMemo)(()=>k.listItem?{paddingY:2}:CX[k.style||"normal"]||{paddingY:2},[k]),H=!!(null==E?void 0:E.member.open),W=P.schemaTypes.portableText,$=(0,lK.useMemo)(()=>{var e;return{__unstable_floatingBoundary:n,__unstable_referenceBoundary:c,__unstable_referenceElement:(null==(e=null==E?void 0:E.elementRef)?void 0:e.current)||null,children:U,focused:i,markers:T,onClose:l,onOpen:N,onPathF
1ocus:o,onRemove:V,open:H,parentSchemaType:W,path:(null==E?void 0:E.node.path)||co,presence:z,readOnly:!!d,renderAnnotation:p,renderBlock:u,renderDefault:_f,renderField:m,renderInput:x,renderInlineBlock:g,renderItem:v,renderPreview:b,schemaType:y,selected:j,validation:R,value:k}},[n,i,H,T,null==E?void 0:E.elementRef,null==E?void 0:E.node.path,l,N,o,V,W,d,c,p,u,m,g,x,v,b,y,j,U,z,R,k]),X=(0,lK.useMemo)(()=>q&&(0,lU.jsx)(C6,{padding:2,children:(0,lU.jsx)(C,{markers:T,renderCustomMarkers:f,validation:R})})||null,[C,T,f,q,R]);return(0,lK.useMemo)(()=>(0,lU.jsx)(lY.xu,{"data-testid":"text-block",...K,style:Cx(),ref:null==E?void 0:E.elementRef,children:(0,lU.jsx)(C1,{"data-testid":"text-block__wrapper",children:(0,lU.jsxs)(lY.kC,{flex:1,...B,children:[(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.u,{content:X,disabled:!q,placement:"top",portal:"editor",children:(0,lU.jsx)(C0,{$level:k.level||1,"data-error":F?"":void 0,"data-list-item":k.listItem,"data-markers":L?"":void 0,"data-read-only":d,"data-testid":"text-block__text","data-warning":D?"":void 0,spellCheck:w,children:u&&u($)})})}),(0,lU.jsxs)(C3,{contentEditable:!1,children:[(0,lU.jsx)(C4,{marginRight:1,children:(0,lU.jsx)(C5,{children:h&&i&&!d&&(0,lU.jsx)(k9,{onChange:A,block:k,renderBlockActions:h})})}),r&&E&&(0,lU.jsx)(C9,{$hasChanges:E.member.item.changed,onMouseEnter:M,onMouseLeave:I,children:(0,lU.jsx)(Ca,{hasFocus:i,isChanged:E.member.item.changed,path:E.member.item.path,withHoverEffect:!1})})]}),_&&(0,lU.jsx)(Cn,{})]})})}),[$,i,M,I,F,L,D,B,r,E,A,K,d,u,h,_,w,X,q,k])}let _f=e=>(0,lU.jsx)(lU.Fragment,{children:e.children});var _m=Object.freeze,_g=Object.defineProperty;let _x=(0,aW.ZP)(lY.J2)(nX||(nX=_m(_g(M=["\n &[data-popper-reference-hidden='true'] {\n display: none !important;\n }\n"],"raw",{value:_m(M.slice())})))),_v=["top","bottom"];function _b(e){let{floatingBoundary:t,onClosePopover:n,onEdit:i,onDelete:r,referenceBoundary:l,referenceElement:a,title:o,open:s}=e,{sanity:d}=(0,lY.Fg)(),c=(0,lK.useRef)(null),u=(0,lK.useRef)(null),p=d.color.dark?"light":"dark";(0,lY.qh)((0,lK.useCallback)(e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),n())},[n]));let h=(0,lK.useCallback)(e=>{var t;if(null==(t=u.current)||!t.disabled){e.preventDefault(),e.stopPropagation();try{r(e)}catch(e){console.error(e)}finally{u.current&&(u.current.disabled=!0)}}},[r]),f=(0,lK.useMemo)(()=>(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsxs)(lY.gF,{space:1,children:[(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{weight:"semibold",size:1,children:o})}),(0,lU.jsx)(lY.zx,{icon:a0.dY8,mode:"bleed",onClick:i,padding:2,ref:c,alt:"Edit object"}),(0,lU.jsx)(lY.zx,{ref:u,icon:a0.XHJ,mode:"bleed",padding:2,onClick:h,tone:"critical",alt:"Remove object"})]})}),[h,i,o]);return(0,lU.jsx)(_x,{constrainSize:!0,content:f,fallbackPlacements:_v,floatingBoundary:t,open:s,placement:"top",portal:!0,referenceBoundary:l,referenceElement:a,scheme:p})}var _y=Object.freeze,_j=Object.defineProperty,_w=(e,t)=>_y(_j(e,"raw",{value:_y(t||e.slice())}));let _k=(0,aW.ZP)(lY.Zb)(function(e){var t,n,i;let{theme:r}=e,{color:l,radius:a}=r.sanity;return(0,aW.iv)(nJ||(nJ=_w(["\n line-height: 0;\n border-radius: ","px;\n padding: 2px;\n box-shadow: inset 0 0 0 1px var(--card-border-color);\n height: calc(1em - 1px);\n margin-top: 0.0625em;\n cursor: default;\n\n &:not([hidden]) {\n display: inline-flex;\n align-items: center;\n vertical-align: top;\n }\n\n &[data-ready-only] {\n cursor: default;\n }\n\n &[data-focused] {\n box-shadow: inset 0 0 0 1px ",";\n color: ",";\n }\n\n &[data-selected] {\n background-color: ",";\n }\n\n &:not([data-focused]):not([data-selected]) {\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n\n &[data-markers] {\n --card-bg-color: ",";\n }\n\n &[data-warning] {\n --card-bg-color: ",";\n\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n\n &[data-invalid] {\n --card-bg-color: ",";\n --card-border-color: ",";\n\n @media (hover: hover) {\n &:hover {\n --card-border-color: ",";\n }\n }\n }\n "])),a[2],null==(t=l.selectable)?void 0:t.primary.selected.border,null==(n=l.selectable)?void 0:n.primary.pressed.fg,null==(i=l.selectable)?void 0:i.primary.pressed.bg,l.input.default.hovered.border,l.dark?a8.VG.purple[950].hex:a8.VG.purple[50].hex,l.muted.caution.hovered.bg,l.muted.caution.hovered.border,l.input.invalid.enabled.bg,l.input.invalid.enabled.border,l.input.invalid.hovered.border)}),_C=aW.ZP.span(nG||(nG=_w(["\n display: block;\n max-width: calc(5em + 80px);\n position: relative;\n"]))),__=(0,aW.ZP)(lY.xu)(nY||(nY=_w(["\n max-width: 250px;\n"]))),_S=e=>{var t;let{floatingBoundary:n,focused:i,onItemClose:r,onItemOpen:l,onPathFocus:a,path:o,readOnly:s,referenceBoundary:d,relativePath:c,renderAnnotation:u,renderBlock:p,renderCustomMarkers:h,renderField:f,renderItem:m,renderInlineBlock:g,renderInput:x,renderPreview:v,schemaType:b,selected:y,value:j}=e,{Markers:w}
1=mY().__internal.components,k=(0,sj._F)(),C=Ch(o),_=Cg(gO(o)),{validation:S,hasError:T,hasInfo:E,hasWarning:P}=Cc(null==_?void 0:_.node),A=k.schemaTypes.block,O=C.length>0,z=(0,lK.useMemo)(()=>({anchor:{path:c,offset:0},focus:{path:c,offset:0}}),[c]),M=(0,lK.useCallback)(()=>{sj.q$.delete(k,z,{mode:"children"}),sj.q$.focus(k)},[z,k]),I=(0,lK.useCallback)(()=>{_&&(sj.q$.blur(k),l(_.node.path))},[k,l,_]),R=(0,lK.useCallback)(()=>{r(),sj.q$.select(k,z),sj.q$.focus(k)},[r,k,z]),F=!!(null==_?void 0:_.member.open),D=null==_?void 0:_.input,Z=(null==_?void 0:_.node.path)||co,L=null==(t=null==_?void 0:_.elementRef)?void 0:t.current,q=gi(o,!0),N=(0,lK.useMemo)(()=>q.filter(e=>(0,lB.Xy)(e.path,o)),[o,q]),V=(0,lK.useMemo)(()=>({__unstable_floatingBoundary:n,__unstable_referenceBoundary:d,__unstable_referenceElement:L,children:D,focused:i,onClose:R,onOpen:I,onPathFocus:a,onRemove:M,open:F,markers:C,member:null==_?void 0:_.member,parentSchemaType:A,path:Z,presence:N,readOnly:!!s,renderAnnotation:u,renderBlock:p,renderDefault:_T,renderField:f,renderInlineBlock:g,renderInput:x,renderItem:m,renderPreview:v,schemaType:b,selected:y,value:j,validation:S}),[n,i,D,F,C,null==_?void 0:_.member,Z,R,I,a,M,A,s,d,L,u,p,f,g,x,m,v,N,b,y,S,j]),U=T||P||E||O,B=(0,lK.useMemo)(()=>U&&(0,lU.jsx)(__,{padding:2,children:(0,lU.jsx)(w,{markers:C,validation:S,renderCustomMarkers:h})})||null,[w,C,h,U,S]);return(0,lK.useMemo)(()=>(0,lU.jsx)("span",{ref:null==_?void 0:_.elementRef,contentEditable:!1,children:(0,lU.jsx)(lY.u,{placement:"bottom",portal:"editor",disabled:!U,content:B,children:g&&(0,lU.jsx)("span",{style:{position:"relative"},children:g(V)})})}),[V,null==_?void 0:_.elementRef,g,B,U])},_T=e=>{let{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,children:r,focused:l,markers:a,onClose:o,onOpen:s,onRemove:d,open:c,readOnly:u,renderPreview:p,schemaType:h,selected:f,validation:m,value:g}=e,x=a.length>0,[v,b]=(0,lK.useState)(!1),y=(null==h?void 0:h.title)||h.name,j=m.filter(e=>"error"===e.level).length>0,w=m.filter(e=>"warning"===e.level).length>0,k=(0,lK.useCallback)(()=>{b(!1),s()},[s]);(0,lK.useEffect)(()=>{c?b(!1):l?b(!0):b(!1)},[l,c]);let C=(0,lK.useMemo)(()=>j?"critical":w?"caution":f||l?"primary":void 0,[l,j,w,f]),_=(0,lK.useCallback)(()=>{b(!1)},[]);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(_k,{"data-focused":l||void 0,"data-invalid":j||void 0,"data-markers":x||void 0,"data-read-only":u||void 0,"data-selected":f||void 0,"data-warning":w||void 0,forwardedAs:"span",onClick:u?k:void 0,onDoubleClick:k,tone:C,children:(0,lU.jsx)(_C,{children:p({layout:"inline",schemaType:h,skipVisibilityCheck:!0,value:g,fallbackTitle:"Click to edit"})})}),i&&(0,lU.jsx)(_b,{floatingBoundary:t,onClosePopover:_,onDelete:d,onEdit:k,open:v,referenceBoundary:n,referenceElement:i,title:y}),c&&(0,lU.jsx)(CV,{defaultType:"popover",onClose:o,autoFocus:l,floatingBoundary:t,referenceBoundary:n,referenceElement:i,schemaType:h,children:r})]})};var _E=Object.freeze,_P=Object.defineProperty;let _A=(0,aW.ZP)(lY.J2)(nQ||(nQ=_E(_P(I=["\n &[data-popper-reference-hidden='true'] {\n display: none !important;\n }\n"],"raw",{value:_E(I.slice())})))),_O=["top","bottom"];function _z(e){let{floatingBoundary:t,onOpen:n,onRemove:i,referenceBoundary:r,referenceElement:l,title:a}=e,[o,s]=(0,lK.useState)(!1),[d,c]=(0,lK.useState)(null),[u,p]=(0,lK.useState)(null),h=(0,lK.useRef)(null),{sanity:f}=(0,lY.Fg)(),m=(0,lK.useRef)(null),g=f.color.dark?"light":"dark",x=(0,lK.useMemo)(()=>d?{getBoundingClientRect:()=>d}:null,[d]);(0,lY.qh)((0,lK.useCallback)(e=>{o&&"Escape"===e.key&&s(!1)},[o]));let v=(0,lK.useCallback)(()=>{let e=window.getSelection();if(!e)return;let{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:r}=e;(0,lK.startTransition)(()=>p({anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:r}))},[]);(0,lK.useEffect)(()=>(document.addEventListener("selectionchange",v,{passive:!0}),()=>{document.removeEventListener("selectionchange",v)}),[v]),(0,lK.useEffect)(()=>{var e;if(!u)return;let{anchorNode:t,focusNode:n}=u;if((null==l?void 0:l.contains(t))&&t===n){let t=null==(e=window.getSelection())?void 0:e.getRangeAt(0),n=null==t?void 0:t.getBoundingClientRect();h.current=t||null,n&&(0,lK.startTransition)(()=>c(n)),(0,lK.startTransition)(()=>s(!0))}else n&&((0,lK.startTransition)(()=>{s(!1),c(null)}),h.current=null)},[u,l]);let b=(0,lK.useCallback)(()=>{s(!1),n()},[n]),y=(0,lK.useCallback)(()=>{s(!1),i()},[i]);return((0,lK.useEffect)(()=>
1{if(!o)return;let e=()=>{h.current&&c(h.current.getBoundingClientRect())};return null==t||t.addEventListener("scroll",e,{passive:!0}),()=>{null==t||t.removeEventListener("scroll",e)}},[o,t]),o)?(0,lU.jsx)(_A,{floatingBoundary:t,constrainSize:!0,content:(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsxs)(lY.gF,{space:1,children:[(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{weight:"semibold",size:1,children:a})}),(0,lU.jsx)(lY.zx,{icon:a0.dY8,mode:"bleed",onClick:b,padding:2,alt:"Edit annotation",tabIndex:0}),(0,lU.jsx)(lY.zx,{icon:a0.XHJ,mode:"bleed",padding:2,onClick:y,tone:"critical",alt:"Remove annotation",tabIndex:0})]})}),fallbackPlacements:_O,open:!0,placement:"top",portal:!0,preventOverflow:!0,ref:m,referenceBoundary:r,referenceElement:x,scheme:g}):null}var _M=Object.freeze,_I=Object.defineProperty,_R=(e,t)=>_M(_I(e,"raw",{value:_M(t||e.slice())}));let _F=aW.ZP.span(e=>{var t,n,i,r;let{$toneKey:l="default",theme:a}=e;return(0,aW.iv)(n0||(n0=_R(["\n text-decoration: none;\n display: inline;\n background-color: ",";\n border-bottom: 1px dashed ",";\n color: ",";\n\n &[data-link] {\n border-bottom: 1px solid ",";\n }\n\n &[data-custom-markers] {\n background-color: ",";\n }\n\n &[data-warning] {\n background-color: ",";\n }\n\n &[data-error] {\n background-color: ",";\n }\n "])),null==(t=a.sanity.color.selectable)?void 0:t[l].enabled.bg,null==(n=a.sanity.color.selectable)?void 0:n[l].enabled.fg,null==(i=a.sanity.color.selectable)?void 0:i[l].enabled.fg,null==(r=a.sanity.color.selectable)?void 0:r[l].enabled.fg,a.sanity.color.dark?a8.VG.purple[950].hex:a8.VG.purple[50].hex,a.sanity.color.muted.caution.hovered.bg,a.sanity.color.muted.critical.hovered.bg)}),_D=(0,aW.ZP)(lY.xu).attrs({forwardedAs:"span"})(n1||(n1=_R(["\n max-width: 250px;\n"])));function _Z(e){var t;let{children:n,editorNodeFocused:i,floatingBoundary:r,focused:l,onItemClose:a,onItemOpen:o,onPathFocus:s,path:d,readOnly:c,referenceBoundary:u,renderAnnotation:p,renderBlock:h,renderCustomMarkers:f,renderField:m,renderInlineBlock:g,renderInput:x,renderItem:v,renderPreview:b,schemaType:y,selected:j,value:w}=e,{Markers:k=m5}=mY().__internal.components,C=(0,sj._F)(),_=(0,lK.useMemo)(()=>d.slice(0,d.length-2).concat(["markDefs",{_key:w._key}]),[d,w._key]),[S,T]=(0,lK.useState)(null),E=(0,lK.useMemo)(()=>d.slice(d.length-3,d.length),[d]),P=Cg(gO(_)),{validation:A}=Cc(null==P?void 0:P.node),O=Ch(d),z=(0,lK.useMemo)(()=>(0,lU.jsx)("span",{"data-annotation":"",children:n}),[n]),M=(0,lK.useCallback)(()=>{P&&(sj.q$.blur(C),s(P.node.focusPath),o(P.node.path))},[C,P,o,s]),I=(0,lK.useCallback)(()=>{a();let e=sj.q$.getSelection(C),t=(null==e?void 0:e.focus.path)&&(0,lB.Xy)(e.focus.path,E)&&e.focus.offset,n=(null==e?void 0:e.anchor.path)&&(0,lB.Xy)(e.anchor.path,E)&&e.anchor.offset;sj.q$.select(C,{anchor:{path:E,offset:n||0},focus:{path:E,offset:t||0}}),sj.q$.focus(C)},[C,E,a]),R=(0,lK.useCallback)(()=>{sj.q$.removeAnnotation(C,y),sj.q$.focus(C)},[C,y]),F=(0,lK.useMemo)(()=>A.length>0||O.length>0?(0,lU.jsx)(lY.u,{placement:"bottom",portal:"default",content:(0,lU.jsx)(_D,{padding:2,children:(0,lU.jsx)(k,{markers:O,renderCustomMarkers:f,validation:A})}),children:z}):void 0,[k,O,f,z,A]),D=gi(d,!0),Z=(0,lK.useMemo)(()=>D.filter(e=>(0,lB.Xy)(e.path,d)),[d,D]),L=!!(null==P?void 0:P.member.open),q=null==P?void 0:P.input,N=(null==P?void 0:P.node.path)||co,V=(0,lK.useMemo)(()=>({__unstable_floatingBoundary:r,__unstable_referenceBoundary:u,__unstable_referenceElement:S,__unstable_textElementFocus:i,children:q,focused:l,markers:O,onClose:I,onOpen:M,onPathFocus:s,onRemove:R,open:L,parentSchemaType:C.schemaTypes.block,path:N,presence:Z,readOnly:!!c,renderAnnotation:p,renderBlock:h,renderField:m,renderInlineBlock:g,renderInput:x,renderPreview:b,renderItem:v,renderDefault:_L,schemaType:y,selected:j,textElement:F||z,validation:A,value:w}),[C.schemaTypes.block,i,r,l,q,L,O,F,N,I,M,s,R,c,u,S,p,h,m,g,x,v,b,Z,y,j,z,A,w]),U=null==(t=y.components)?void 0:t.annotation,B=(0,lK.useCallback)(e=>{(null==P?void 0:P.elementRef)&&(P.elementRef.current=e),T(e)},[P]);return(0,lK.useMemo)(()=>(0,lU.jsx)("span",{ref:B,style:Cx(),children:U?(0,lU.jsx)(U,{...V}):(0,lU.jsx)(_L,{...V})}),[U,V,B])}let _L=e=>{let{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,
1children:r,focused:l,markers:a,onClose:o,onOpen:s,onRemove:d,open:c,readOnly:u,schemaType:p,textElement:h,validation:f}=e,m="link"===p.name,g=f.filter(e=>"error"===e.level).length>0,x=f.filter(e=>"warning"===e.level).length>0,v=a.length>0,b=(0,lK.useMemo)(()=>g?"critical":x?"caution":m?"primary":"default",[m,g,x]);return(0,lU.jsxs)(_F,{$toneKey:b,"data-link":m?"":void 0,"data-error":g?"":void 0,"data-warning":x?"":void 0,"data-markers":v||void 0,onClick:u?s:void 0,children:[h,(0,lU.jsx)(_z,{floatingBoundary:t,referenceBoundary:n,referenceElement:i,onOpen:s,onRemove:d,title:p.title||p.name}),c&&(0,lU.jsx)(CV,{defaultType:"popover",floatingBoundary:t,onClose:o,autoFocus:l,referenceBoundary:n,referenceElement:i,schemaType:p,children:r})]})};function _q(e){var t;return(null==(t=e.components)?void 0:t.block)?e.components.block:Co(e)?_f:CB}function _N(e){var t;return(null==(t=e.components)?void 0:t.inlineBlock)?e.components.inlineBlock:_T}function _V(e){var t;return(null==(t=e.components)?void 0:t.annotation)?e.components.annotation:_L}let _U=/^\d+$/;function _B(e){return e.split(/[[.\]]/g).filter(Boolean).map(e=>e.includes("==")?function(e){let[t,n]=e.split("==");return{[t]:n.replace(/^['"]/,"").replace(/['"]$/,"")}}(e):_U.test(e)?Number(e):e)}function _K(e){let{reference:t,children:n,observeAsset:i,waitPlaceholder:r}=e,l=null==t?void 0:t._ref,a=(0,lJ.m2)(()=>i(l),[l,i]);return(0,lU.jsx)(lU.Fragment,{children:l&&a?n(a):r})}function _H(e){return null===e?[]:[e]}function _W(e){return Promise.all(e.map(e=>{if("file"===e.kind&&e.webkitGetAsEntry){let t;try{t=e.webkitGetAsEntry()}catch(t){return _H(e.getAsFile())}return t?t.isDirectory?function e(t){if(t.isFile)return new Promise((e,n)=>t.file(e,n)).then(e=>[e]);if(t.isDirectory){let n=t.createReader();return new Promise((e,t)=>n.readEntries(e,t)).then(e=>e.filter(e=>!e.name.startsWith("."))).then(t=>Promise.all(t.map(e)).then(om()))}return Promise.resolve([])}(t):_H(e.getAsFile()):[]}if("file"===e.kind){let t=e.getAsFile();return Promise.resolve(t?[t]:[])}return"string"===e.kind?(console.warn('DataTransfer with kind="string" is currently not supported'),Promise.resolve([])):(console.warn("Unknown DataTransferItem.kind: %s",e.kind),Promise.resolve([]))}))}let _$={opacity:0,position:"absolute"};function _X(e){return lK.forwardRef(function(t,n){let{onFiles:i,onFilesOver:r,onFilesOut:l,disabled:a,...o}=t,[s,d]=lK.useState(!1),c=lK.useRef(null),u=(0,lY.ts)(n),p=lK.useRef([]),h=(0,lK.useCallback)(e=>{null==i||i(e)},[i]),f=(0,lK.useCallback)(e=>{e.target===u.current&&(e.ctrlKey||e.metaKey)&&"v"===e.key&&d(!0)},[u]),m=(0,lK.useCallback)(e=>{var t;((t=e.clipboardData).files&&t.files.length>0?Promise.resolve(Array.from(t.files||[])):_W(Array.from(t.items||[])).then(om())).then(e=>c.current?e.length>0?e:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg";return e.isContentEditable?new Promise(e=>setTimeout(e,10)).then(()=>Array.from(e.querySelectorAll("img"))).then(t=>(e.innerHTML="",t)).then(e=>Promise.all(e.map(e=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e.match(/^webkit-fake-url:\/\//)?Promise.reject(Error("Cannot read image contents from webkit fake url")):new Promise((i,r)=>{let l=new Image;l.crossOrigin="anonymous",l.referrerPolicy="strict-origin-when-cross-origin",l.onload=()=>{let e=document.createElement("canvas");e.width=l.width,e.height=l.height;let a=e.getContext("2d");null==a||a.drawImage(l,0,0,e.width,e.height);try{e.toBlob(i,t,n)}catch(e){r(e)}},l.src=e})})(e.src)))).then(e=>e.map(e=>new File([e],"pasted-image.jpg",{type:t}))):Promise.reject(Error('Expected element to be contentEditable="true". Instead found a non contenteditable '.concat(e.tagName)))}(c.current,"image/jpeg"):[]).then(e=>{var t;h(e),d(!1),null==(t=u.current)||t.focus()})},[h,u]),g=(0,lK.useCallback)(e=>{p.current=[],e.preventDefault(),e.stopPropagation();let t=e.nativeEvent.dataTransfer;i&&t&&(function(e){let t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t&&t.length>0?Promise.resolve(t):_W(n).then(om())})(t).then(e=>{e&&h(e)}),null==l||l()},[h,i,l]),x=(0,lK.useCallback)(e=>{i&&(e.preventDefault(),e.stopPropagation())},[i]),v=(0,lK.useCallback)(e=>{if(e.stopPropagation(),r&&u.current===e.currentTarget){p.current=[...new Set(p.current),e.currentTarget];let t=Array.from(e.dataTransfer.items).map(e=>({type:e.type,kind:e.kind}));r(t)}},[r,u]),b=(0,lK.useCallback)(e=>{e.stopPropagation();let t=p.current.indexOf(e.currentTarget);t>-1&&p.current.splice(t,1),0===p.current.length&&(null==l||l())},[l]),y=lK.useRef(!1);return lK.useEffect(()=>{var e;!y.current&&s&&c.current?(c.current.focus(),function(e){let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();null==n||n.removeAllRanges(),null==n||n.addRange(t)}
1(c.current)):y.current&&!s&&(null==(e=c.current)||e.focus()),y.current=s},[s]),(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(e,{...o,ref:u,onKeyDown:a?void 0:f,onDragOver:a?void 0:x,onDragEnter:a?void 0:v,onDragLeave:a?void 0:b,onDrop:a?void 0:g}),!a&&s&&(0,lU.jsx)("div",{contentEditable:!0,onPaste:m,ref:c,style:_$})]})})}function _G(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function _Y(e){let{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,l=0-i.offset,a=t?t.bg:"var(--card-bg-color)";return[l>0&&"inset 0 0 0 ".concat(l,"px var(--card-focus-ring-color)"),n&&_G(n),l<0&&"0 0 0 ".concat(0-l,"px ").concat(a),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}var _J=Object.freeze,_Q=Object.defineProperty,_0=(e,t)=>_J(_Q(e,"raw",{value:_J(t||e.slice())}));function _1(e){return(0,aW.ZP)(e)(e=>{let t={width:e.$border?1:0,color:"var(--card-border-color)"};return(0,aW.iv)(n2||(n2=_0(["\n --card-focus-box-shadow: ",";\n\n border-radius: ",";\n outline: none;\n box-shadow: var(--card-focus-box-shadow);\n\n &:focus {\n --card-focus-box-shadow: ",";\n }\n "])),_G(t),(0,lY.hO)(e.theme.sanity.radius[1]),_Y({base:e.theme.sanity.color.base,border:t,focusRing:e.theme.sanity.focusRing}))})}let _2=_X(_1(lY.Zb));var _3=Object.freeze,_4=Object.defineProperty,_5=(e,t)=>_3(_4(e,"raw",{value:_3(t||e.slice())}));let _6=(0,aW.ZP)(lY.Zb)(n3||(n3=_5(["\n min-height: 82px;\n box-sizing: border-box;\n"]))),_8=(0,aW.ZP)(lY.kC)(n4||(n4=_5(["\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"]))),_9=(0,aW.ZP)(lY.Kq)(n5||(n5=_5(["\n position: relative;\n width: 60%;\n"]))),_7=(0,aW.ZP)(lY.EK)(n6||(n6=_5(["\n position: relative;\n width: 100%;\n\n code {\n overflow: hidden;\n overflow: clip;\n text-overflow: ellipsis;\n position: relative;\n max-width: 200px;\n }\n"]))),Se=e=>new Date().getTime()-new Date(e).getTime();function St(e){let{uploadState:t,onCancel:n,onStale:i,height:r}=e,l=t.file.name;return(0,lK.useEffect)(()=>{Se(t.updatedAt)>12e4&&(null==i||i())},[t.updatedAt,i]),(0,lU.jsx)(_6,{tone:"primary",padding:4,border:!0,style:{height:"".concat(r,"px")},children:(0,lU.jsxs)(_8,{align:"center",justify:"space-between",height:"fill",direction:"row",gap:2,children:[(0,lU.jsxs)(_9,{children:[(0,lU.jsx)(lY.kC,{justify:"center",gap:[3,3,2,2],direction:["column","column","row"],children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsxs)(lY.gF,{space:2,children:["Uploading",(0,lU.jsx)(_7,{size:1,children:l||"..."})]})})}),(0,lU.jsx)(lY.Zb,{marginTop:3,radius:5,shadow:1,children:(0,lU.jsx)(pd,{value:t.progress})})]}),n?(0,lU.jsx)(lY.zx,{fontSize:2,text:"Cancel upload",mode:"ghost",tone:"critical",onClick:n}):null]})})}function Sn(e,t){var n;let i=e.split(","),r=null==(n=i[0].match(/:(.*?);/))?void 0:n[1],l=atob(i[1]),a=l.length,o=new Uint8Array(a);for(;a--;)o[a]=l.charCodeAt(a);return new File([o],t,{type:r})}function Si(e){var t,n;let{assetFromSource:i,onChange:r,type:l,resolveUploader:a,uploadWith:o,isImage:s}=e;if(!i)throw Error("No asset given");if(!Array.isArray(i)||0===i.length)throw Error("Returned value must be an array with at least one item (asset)");let d=i[0],c=d.assetDocumentProps,u=null==c?void 0:c.originalFilename,p=null==c?void 0:c.label,h=null==c?void 0:c.title,f=null==c?void 0:c.description,m=null==c?void 0:c.creditLine,g=null==c?void 0:c.source,x=s?[mD(["hotspot"]),mD(["crop"])]:[];switch(d.kind){case"assetDocumentId":r([mI({_type:l.name}),...x,mF({_type:"reference",_ref:d.value},["asset"])]);break;case"file":{let e=a(l,d.value);e&&o(e,d.value,{label:p,title:h,description:f,creditLine:m,source:g});break}case"base64":(t=d.value,new Promise((e,n)=>{let i=t.toString(),r=i.substring(11,i.indexOf(";base64"));if(!r&&!u){n(Error("Could not find mime type for image"));return}e(Sn(t,u||"".concat((0,sh.Z)(),".").concat(r)))})).then(e=>{let t=a(l,e);t&&o(t,e,{label:p,title:h,description:f,creditLine:m,source:g})});break;case"url":(n=d.value,new Promise((e,t)=>{let i=new XMLHttpRequest;i.onload=()=>{let n=new FileReader;n.onloadend=()=>{var i;let r=null==(i=n.result)?void 0:i.toString(),l=null==r?void 0:r.substring(11,r.indexOf(";base64"));if(!l&&!u){t(Error("Could not find mime type for image"));return}e(Sn(n.result,u||"".concat((0,sh.Z)(),".").concat(l)))},n.readAsDataURL(i.response)},i.onerror=e=>{t(e)},i.open("GET",n),i.responseType="blob",i.send()})).then(e=>{let t=a(l,e);t&&o(t,e,{label:p,title:h,description:f,creditLine:m,source:g})});break;default:throw Error("Invalid value returned from asset source plugin")}}var Sr=Object.freeze,Sl=Object.defineProperty;let Sa=(0,aW.ZP)(lY.sN)(n8||(n8=Sr(Sl(R=["\n position: relative;\n\n & input {\n overflow: hidden;\n overflow: clip;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n min-width: 0;\n display: block;\n appearance: none;\n padding: 0;\n margin: 0;\n border: 0;\n opacity: 0;\n }\n"],"raw",{value:Sr(R.slice())})))),So=lK.forwardRef(function(e,t){let{icon:n,id:i,accept:r,capture:l,fontSize:a,multiple:o,onSelect:s,padding:d=3,space:c=3,textAlign:u,text:p,disabled:h,...f}=e,m="".concat(i||"","-").concat((0,lK.useId)()),g=lK.useCallback(e=>{s&&e.target.files&&s(Array.from(e.target.files))},[s]),x=(0,lU.jsxs)(lY.kC,{align:"center",justify:"flex-start",padding:d,children:[n&&(0,lU.jsx)(lY.xu,{marginRight:p?c:void 0,children:(0,lU.jsxs)(lY.xv,{size:a,children:[(0,lK.isValidElement)(n)&&n,(0,a6.isValidElementType)(n)&&(0,lK.createElement)(n)]})}),p&&(0,lU.jsx)(lY.xv,{align:u,size:a,textOverflow:"ellipsis",children:p})]});return(0,lU.jsxs)(Sa,{...f,htmlFor:m,padding:0,fontSize:2,disabled:h,ref:t,children:[x,(0,lU.jsx)("input",{"data-testid":"file-menuitem-input",accept:r,capture:l,id:m,multiple:o,onChange:g,type:"file",value:"",disabled:h})]})});function Ss(e){let{onUpload:t,onReset:n,readOnly:i,accept:r,directUploads:l,browse:a,downloadUrl:o,c
1opyUrl:s}=e,{push:d}=(0,lY.pm)(),c=(0,lK.useCallback)(()=>{navigator.clipboard.writeText(s||""),d({closable:!0,status:"success",title:"The URL is copied to the clipboard"})},[d,s]);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Replace"})}),(0,lU.jsx)(So,{icon:a0.rG2,mode:"bleed",onSelect:t,accept:r,text:"Upload","data-testid":"file-input-upload-button",disabled:i||!l,fontSize:2}),a,(o||s)&&(0,lU.jsx)(lY.R,{}),o&&(0,lU.jsx)(lY.sN,{as:"a",icon:a0._8t,text:"Download",href:o}),s&&(0,lU.jsx)(lY.sN,{icon:a0.Kmg,text:"Copy URL",onClick:c}),(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.sN,{tone:"critical",icon:a0.X5P,text:"Clear field",onClick:n,disabled:i,"data-testid":"file-input-clear"})]})}var Sd=Object.freeze,Sc=Object.defineProperty;let Su=(0,aW.ZP)(lY.kC)(n9||(n9=Sd(Sc(F=["\n pointer-events: none;\n"],"raw",{value:Sd(F.slice())}))));function Sp(e){let{hoveringFiles:t,type:n,readOnly:i,acceptedFiles:r,rejectedFilesCount:l,directUploads:a}=e,o="file"===n,s=(0,lK.useMemo)(()=>i?(0,lU.jsx)(a0.CPA,{}):t&&l>0||!a?(0,lU.jsx)(a0.vaB,{}):o?(0,lU.jsx)(a0.bg6,{}):(0,lU.jsx)(a0.XBm,{}),[a,t,o,i,l]),d=(0,lK.useMemo)(()=>{let e="Drag or paste ".concat(n," here");return a?(i&&(e="Read only"),t&&a&&!i&&(r.length>0&&(e="Drop to upload ".concat(n)),l>0&&(e="Can't upload ".concat(l," file").concat(l>1?"s":""," here"))),e):"Can't upload files here"},[r.length,a,t,i,l,n]);return(0,lU.jsxs)(Su,{align:"center",gap:2,justify:"center",children:[(0,lU.jsx)(lY.xv,{muted:!0,children:s}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:d})]})}var Sh=Object.freeze,Sf=Object.defineProperty,Sm=(e,t)=>Sh(Sf(e,"raw",{value:Sh(t||e.slice())}));let Sg=(0,aW.ZP)(lY.zx).attrs({forwardedAs:"label"})(e=>{let{theme:t}=e,{focusRing:n}=t.sanity,i=t.sanity.color.base;return(0,aW.iv)(n7||(n7=Sm(["\n &:not([data-disabled='true']) {\n &:focus-within {\n box-shadow: ",";\n }\n }\n\n & input {\n overflow: hidden;\n overflow: clip;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n min-width: 0;\n display: block;\n appearance: none;\n padding: 0;\n margin: 0;\n border: 0;\n opacity: 0;\n }\n "])),_Y({base:i,border:{width:1,color:"var(--card-border-color)"},focusRing:n}))}),Sx=lK.forwardRef(function(e,t){let{icon:n,id:i,accept:r,capture:l,fontSize:a,multiple:o,onSelect:s,padding:d=3,space:c=3,textAlign:u,text:p,disabled:h,...f}=e,m="".concat(i||"","-").concat((0,lK.useId)()),g=(0,lY.Fg)(),x=lK.useCallback(e=>{s&&e.target.files&&s(Array.from(e.target.files))},[s]),v=(0,lU.jsxs)(lY.kC,{align:"center",justify:"center",padding:d,children:[n&&(0,lU.jsx)(lY.xu,{marginRight:p?c:void 0,children:(0,lU.jsxs)(lY.xv,{size:a,children:[(0,lK.isValidElement)(n)&&n,(0,a6.isValidElementType)(n)&&(0,lK.createElement)(n)]})}),p&&(0,lU.jsx)(lY.xv,{align:u,size:a,textOverflow:"ellipsis",weight:g.sanity.button.textWeight,children:p})]});return(0,lU.jsxs)(Sg,{...f,htmlFor:m,padding:0,fontSize:2,disabled:h,children:[v,(0,lU.jsx)("input",{"data-testid":"file-button-input",accept:r,capture:l,id:m,multiple:o,onChange:x,ref:t,type:"file",value:"",disabled:h})]})}),Sv=lK.memo(function(e){let{accept:t,acceptedFiles:n,browse:i,directUploads:r,hoveringFiles:l,onUpload:a,readOnly:o,rejectedFilesCount:s,type:d}=e,[c,u]=(0,lK.useState)(null),p=(0,lY.h4)(c),h=(null==p?void 0:p.border)&&p.border.width<440;return(0,lU.jsxs)(lY.kC,{align:h?void 0:"center",direction:h?"column":"row",gap:4,justify:"space-between",paddingY:h?1:void 0,ref:u,children:[(0,lU.jsx)(lY.kC,{flex:1,justify:"center",children:(0,lU.jsx)(Sp,{acceptedFiles:n,directUploads:r,hoveringFiles:l,readOnly:o,rejectedFilesCount:s,type:d})}),(0,lU.jsxs)(lY.kC,{align:"center",gap:2,justify:"center",wrap:"wrap",children:[(0,lU.jsx)(Sx,{accept:t,"data-testid":"file-input-upload-button",disabled:o||!r,icon:a0.rG2,mode:"ghost",onSelect:a,text:"Upload"}),i]})]})});var Sb=Object.freeze,Sy=Object.defineProperty;let Sj=(0,aW.ZP)(lY.zx)(ie||(ie=Sb(Sy(D=["\n width: 100%;\n"],"raw",{value:Sb(D.slice())}))));function Sw(e){let{onClearStale:t}=e;return(0,lU.jsxs)(lY.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,lU.jsxs)(lY.kC,{gap:4,marginBottom:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"Incomplete upload"}),(0,lU.jsx)(lY.xv,{size:1,children:"An upload has made no progress in the last 6m and likely got interrupted. You can safely clear the incomplete upload and try uploading again."})]})]}),(0,lU.jsx)(Sj,{icon:a0.X5P,text:"Clear upload",onClick:t,mode:"ghost"})]})}var Sk=Object.freeze,SC=Object.defineProperty,S_=(e,t)=>Sk(SC(e,"raw",{value:Sk(t||e.slice())}));let SS=(0,aW.ZP)(lY.Zb)(it||(it=S_(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),ST=(0,aW.ZP)(lY.kC)(ii||(ii=S_(["\n height: 100%;\n"])));function SE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===e)return"0 Bytes";let n=t<0?0:t,i=Math.floor(Math.log(e)/Math.log(1024));return"".concat(parseFloat((e/Math.pow(1024,i)).toFixed(n))," ").concat(["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i])}function SP(e){let{originalFilename:t,size:n,children:i,muted:r,disabled:l,onClick:a,isMenuOpen:o,onMenuOpen:s,setMenuButtonElement:d}=e,[c,u]=(0,lK.useState)(null),[p,h]=(0,lK.useState)(null),f=(0,lK.useCallback)(()=>s(!0),[s]);(0,lY.qh)((0,lK.useCallback)(e=>
1{o&&("Escape"===e.key||"Tab"===e.key)&&(s(!1),null==p||p.focus())},[o,s,p])),(0,lY.O8)((0,lK.useCallback)(e=>{(null==p?void 0:p.contains(e.target))||s(!1)},[p,s]),[c]);let m=(0,lK.useCallback)(e=>{d(e),h(e)},[d]);return(0,lK.useEffect)(()=>{o&&(null==c||c.focus())},[o,c]),(0,lU.jsxs)(lY.kC,{wrap:"nowrap",justify:"space-between",align:"center",children:[(0,lU.jsx)(lY.Zb,{as:r||l?void 0:"button",radius:2,padding:2,tone:"inherit",onClick:a,flex:1,children:(0,lU.jsxs)(lY.kC,{wrap:"nowrap",align:"center",children:[(0,lU.jsx)(lY.Zb,{padding:3,tone:"transparent",shadow:1,radius:1,children:(0,lU.jsx)(lY.xv,{muted:r,children:(0,lU.jsx)(a0.bg6,{})})}),(0,lU.jsxs)(lY.Kq,{flex:1,space:2,marginLeft:3,children:[(0,lU.jsx)(lY.xv,{size:2,textOverflow:"ellipsis",muted:r,"data-testid":"file-name",children:t}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,"data-testid":"file-size",children:SE(n)})]})]})}),(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.kC,{justify:"center",children:(0,lU.jsx)(lY.J2,{content:(0,lU.jsx)(lY.v2,{ref:u,children:i}),id:"file-actions-menu",portal:!0,open:o,constrainSize:!0,children:(0,lU.jsx)(lY.zx,{"aria-label":"Open file options menu","data-testid":"options-menu-button",icon:a0.zGg,mode:"bleed",onClick:f,ref:m})})})})]})}function SA(){return(0,lU.jsxs)(lY.kC,{align:"center",justify:"flex-start",padding:2,children:[(0,lU.jsx)(lY.Od,{padding:3,radius:1,animated:!0}),(0,lU.jsxs)(lY.Kq,{flex:1,space:2,marginLeft:3,children:[(0,lU.jsx)(lY.JQ,{style:{width:"100%"},radius:1,animated:!0}),(0,lU.jsx)(lY.JQ,{style:{width:"100%"},radius:1,animated:!0})]})]})}var SO=Object.freeze,Sz=Object.defineProperty;let SM=(0,aW.ZP)(lY.zx)(ir||(ir=SO(Sz(Z=["\n width: 100%;\n"],"raw",{value:SO(Z.slice())}))));function SI(e){let{onClearValue:t}=e;return(0,lU.jsxs)(lY.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,lU.jsxs)(lY.kC,{gap:4,marginBottom:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"Invalid file value"}),(0,lU.jsx)(lY.xv,{size:1,children:"The value of this field is not a valid file. Resetting this field will let you choose a new file."})]})]}),(0,lU.jsx)(SM,{icon:a0.X5P,text:"Reset value",onClick:t,mode:"ghost"})]})}var SR=Object.defineProperty,SF=(e,t,n)=>t in e?SR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,SD=(e,t,n)=>(SF(e,"symbol"!=typeof t?t+"":t,n),n);function SZ(e){let{children:t}=e;return t}let SL=["asset"];class Sq extends lK.PureComponent{constructor(e){var t;super(e),t=this,SD(this,"_assetFieldPath"),SD(this,"uploadSubscription",null),SD(this,"browseButtonElement",null),SD(this,"state",{isUploading:!1,selectedAssetSource:null,hoveringFiles:[],isStale:!1,isMenuOpen:!1}),SD(this,"toast",null),SD(this,"handleRemoveButtonClick",()=>{let{path:e,value:t}=this.props,n=e.slice(-1)[0],i=Object.keys(t||{}),r=i.filter(e=>!["_type","_key","_upload","asset"].includes(e)),l=0===r.length,a=["asset"].concat(i.filter(e=>["_upload"].includes(e))).map(e=>mD([e]));this.props.onChange(mN.from(l&&!("string"!=typeof n)?mD():a))}),SD(this,"handleCancelUpload",()=>{this.cancelUpload()}),SD(this,"handleClearUploadState",()=>{this.setState({isStale:!1}),this.clearUploadStatus()}),SD(this,"handleStaleUpload",()=>{this.setState({isStale:!0})}),SD(this,"handleClearField",()=>{this.props.onChange(mD(["asset"]))}),SD(this,"handleSelectFiles",e=>{let{directUploads:t,readOnly:n}=this.props,{hoveringFiles:i}=this.state;t&&!n?this.uploadFirstAccepted(e):i.length>0&&this.handleFilesOut()}),SD(this,"handleSelectFileFromAssetSource",e=>{this.setState({selectedAssetSource:e})}),SD(this,"handleAssetSourceClosed",()=>{var e;this.setState({selectedAssetSource:null}),null==(e=this.browseButtonElement)||e.focus()}),SD(this,"setBrowseButtonElement",e=>{this.browseButtonElement=e}),SD(this,"uploadWith",function(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{schemaType:r,onChange:l,client:a}=t.props,{source:o}=i,s={metadata:op()(r,"options.metadata"),storeOriginalFilename:op()(r,"options.storeOriginalFilename"),source:o};t.cancelUpload(),t.setState({isUploading:!0}),l(mN.from([mI({_type:r.name})])),t.uploadSubscription=e.upload(a,n,r,s).subscribe({next:e=>{e.patches&&l(mN.from(e.patches))},error:e=>{var n;console.error(e),null==(n=t.toast)||n.push({status:"error",description:"The upload could not be completed at this time.",title:"Upload failed"}),t.clearUploadStatus()},complete:()=>{t.setState({isUploading:!1})}})}),SD(this,"handleSelectAssetFromSource",e=>{let{onChange:t,schemaType:n,resolveUploader:i}=this.props;Si({assetFromSource:e,onChange:t,type:n,resolveUploader:i,uploadWith:this.uploadWith}),this.setState({selectedAssetSource:null})}),SD(this,"handleFileTargetFocus",e=>{var t;e.currentTarget===e.target&&e.currentTarget===(null==(t=this.props.elementProps.ref)?void 0:t.current)&&this.props.elementProps.onFocus(e)}),SD(this,"handleFilesOver",e=>{this.setState({hoveringFiles:e})}),SD(this,"handleFilesOut",()=>{this.setState({hoveringFiles:[]})}
1),SD(this,"handleUpload",e=>{let{file:t,uploader:n}=e;this.uploadWith(n,t)}),SD(this,"setToast",e=>{this.toast=e}),this._assetFieldPath=e.path.concat(SL)}clearUploadStatus(){var e;(null==(e=this.props.value)?void 0:e._upload)&&this.props.onChange(mN.from([mD(["_upload"])]))}cancelUpload(){this.uploadSubscription&&(this.uploadSubscription.unsubscribe(),this.clearUploadStatus())}uploadFirstAccepted(e){let{schemaType:t}=this.props,n=e.map(e=>{var n,i;return{file:e,uploader:null==(i=(n=this.props).resolveUploader)?void 0:i.call(n,t,e)}}).find(e=>e.uploader);n&&this.uploadWith(n.uploader,n.file),this.setState({isMenuOpen:!1})}renderUploadState(e){let{isUploading:t}=this.state;return(0,lU.jsx)(St,{uploadState:e,onCancel:t?this.handleCancelUpload:void 0,onStale:this.handleStaleUpload})}renderAssetSource(){let{selectedAssetSource:e}=this.state,{value:t,schemaType:n,observeAsset:i}=this.props;if(!e)return null;let r=op()(n,"options.accept",""),l=e.component;return t&&t.asset?(0,lU.jsx)(_K,{observeAsset:i,reference:t.asset,waitPlaceholder:(0,lU.jsx)(SA,{}),children:e=>(0,lU.jsx)(l,{selectedAssets:[e],selectionType:"single",assetType:"file",accept:r,dialogHeaderTitle:"Select file",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}):(0,lU.jsx)(l,{selectedAssets:[],selectionType:"single",assetType:"file",accept:r,dialogHeaderTitle:"Select file",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}renderAsset(){let{value:e,changed:t,readOnly:n,elementProps:i}=this.props,{hoveringFiles:r,isStale:l}=this.state,a=!!((null==e?void 0:e._upload)||(null==e?void 0:e.asset));return!e||void 0===e.asset||(null==e?void 0:e._upload)||(0,o2.OT)(e)?o=>(0,lU.jsxs)(lU.Fragment,{children:[l&&(0,lU.jsx)(lY.xu,{marginBottom:2,children:(0,lU.jsx)(Sw,{onClearStale:this.handleClearUploadState})}),(0,lU.jsx)(cD,{path:this._assetFieldPath,hasFocus:!!o.focused,isChanged:t,children:(null==e?void 0:e._upload)?this.renderUploadState(e._upload):(0,lU.jsx)(_2,{...i,onFocus:this.handleFileTargetFocus,tabIndex:0,disabled:!!n,onFiles:this.handleSelectFiles,onFilesOver:this.handleFilesOver,onFilesOut:this.handleFilesOut,tone:this.getFileTone(),$border:a||r.length>0,style:{padding:1},sizing:"border",radius:2,children:(0,lU.jsxs)("div",{style:{position:"relative"},children:[!(null==e?void 0:e.asset)&&this.renderUploadPlaceholder(),(null==e?void 0:e.asset)&&r.length>0?this.renderAssetMenu(this.getFileTone()):null,!(null==e?void 0:e._upload)&&(null==e?void 0:e.asset)&&this.renderPreview()]})})})]}):()=>(0,lU.jsx)(SI,{onClearValue:this.handleClearField})}renderPreview(){let{value:e,readOnly:t,assetSources:n,schemaType:i,directUploads:r,observeAsset:l}=this.props,{isMenuOpen:a}=this.state,o=null==e?void 0:e.asset;if(!o)return null;let s=op()(i,"options.accept",""),d=n&&(null==n?void 0:n.length)===0?null:(0,lU.jsx)(lY.sN,{icon:a0.W1M,text:"Browse",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(n[0])},disabled:t,"data-testid":"file-input-browse-button"});return n.length>1&&(d=n.map(e=>(0,lU.jsx)(lY.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e)},icon:e.icon||a0.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)},e.name))),(0,lU.jsx)(_K,{reference:o,observeAsset:l,waitPlaceholder:(0,lU.jsx)(SA,{}),children:n=>{let i,l,{originalFilename:o,extension:c,url:u,size:p}=n;return(0,o2.OT)(e)&&(l="".concat(u,"?dl"),i=u),(0,lU.jsx)(SP,{size:p,originalFilename:o||"download.".concat(c),muted:!t,onMenuOpen:e=>this.setState({isMenuOpen:e}),isMenuOpen:a,setMenuButtonElement:this.setBrowseButtonElement,children:(0,lU.jsx)(Ss,{onUpload:this.handleSelectFiles,browse:d,onReset:this.handleRemoveButtonClick,downloadUrl:l,copyUrl:i,readOnly:t,accept:s,directUploads:r})})}})}renderAssetMenu(e){let{schemaType:t,readOnly:n,directUploads:i,resolveUploader:r}=this.props,{hoveringFiles:l}=this.state,a=l.filter(e=>null==r?void 0:r(t,e)),o=l.length-a.length;return(0,lU.jsx)(SS,{tone:e,children:(0,lU.jsx)(ST,{align:"center",justify:"center",gap:2,flex:1,children:(0,lU.jsx)(Sp,{readOnly:n,hoveringFiles:l,acceptedFiles:a,rejectedFilesCount:o,directUploads:i,type:"file"})})})}renderBrowser(){let{assetSources:e,readOnly:t,directUploads:n,id:i}=this.props;return 0===e.length?null:e.length>1&&!t&&n?(0,lU.jsx)(lY.j2,{id:"".concat(i,"_assetFileButton"),ref:this.setBrowseButtonElement,button:(0,lU.jsx)(lY.zx,{mode:"ghost",text:"Select","data-testid":"file-input-multi-browse-button",icon:a0.W1M}),"data-testid":"input-select-button",menu:(0,lU.jsx)(lY.v2,{children:e.map(e=>(0,lU.jsx)(lY.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e)},icon:e.icon||a0.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)}
1,e.name))})}):(0,lU.jsx)(lY.zx,{fontSize:2,text:"Browse",icon:a0.W1M,mode:"ghost",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e[0])},"data-testid":"file-input-browse-button",disabled:t,ref:this.setBrowseButtonElement})}renderUploadPlaceholder(){let{readOnly:e,schemaType:t,directUploads:n,resolveUploader:i}=this.props,{hoveringFiles:r}=this.state,l=r.filter(e=>null==i?void 0:i(t,e)),a=r.length-l.length,o=op()(t,"options.accept","");return(0,lU.jsx)("div",{style:{padding:1},children:(0,lU.jsx)(lY.Zb,{tone:e?"transparent":"inherit",border:!0,padding:3,style:0===r.length?{borderStyle:"dashed"}:{borderStyle:"dashed",borderColor:"transparent"},children:(0,lU.jsx)(Sv,{browse:this.renderBrowser(),onUpload:this.handleSelectFiles,readOnly:e,hoveringFiles:r,acceptedFiles:l,rejectedFilesCount:a,type:"file",accept:o,directUploads:n})})})}getFileTone(){let{directUploads:e,schemaType:t,value:n,readOnly:i,resolveUploader:r}=this.props,{hoveringFiles:l}=this.state,a=l.filter(e=>null==r?void 0:r(t,e)),o=l.length-a.length;return l.length>0&&(o>0||!e)?"critical":(null==n?void 0:n._upload)||i||!(l.length>0)?(null==n?void 0:n._upload)&&(null==n?void 0:n.asset)&&i?"transparent":"default":"primary"}render(){let{members:e,renderAnnotation:t,renderBlock:n,renderInlineBlock:i,renderItem:r,renderInput:l,renderField:a,renderPreview:o}=this.props,{selectedAssetSource:s}=this.state;return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(pJ,{ref:this.setToast}),e.map(e=>"field"===e.kind&&("crop"===e.name||"hotspot"===e.name)?null:"field"===e.kind?(0,lU.jsx)(kd,{member:e,renderAnnotation:t,renderInlineBlock:i,renderBlock:n,renderInput:"asset"===e.name?this.renderAsset():l,renderField:"asset"===e.name?SZ:a,renderItem:r,renderPreview:o},e.key):"fieldSet"===e.kind?(0,lU.jsx)(kk,{member:e,renderAnnotation:t,renderBlock:n,renderField:a,renderInlineBlock:i,renderInput:l,renderItem:r,renderPreview:o},e.key):"error"===e.kind?(0,lU.jsx)(kw,{member:e},e.key):(0,lU.jsxs)(lU.Fragment,{children:["Unknown member kind: $",e.kind]})),s&&this.renderAssetSource()]})}}var SN=Object.freeze,SV=Object.defineProperty;let SU=(0,aW.ZP)(lY.xu)(il||(il=SN(SV(L=["\n position: relative;\n padding-bottom: calc("," * 100%);\n\n & > div {\n position: absolute;\n top: ","px;\n left: ","px;\n right: ","px;\n bottom: ","px;\n }\n"],"raw",{value:SN(L.slice())}))),e=>{let{ratio:t=1.5}=e;return 1/t},e=>{let{padding:t=0}=e;return t},e=>{let{padding:t=0}=e;return t},e=>{let{padding:t=0}=e;return t},e=>{let{padding:t=0}=e;return t});function SB(e){let{src:t,children:n}=e,[i,r]=(0,lK.useState)(!0),[l,a]=(0,lK.useState)(null),[o,s]=(0,lK.useState)(null);return(0,lK.useEffect)(()=>{a(null),s(null),r(!0);let e=new Image;e.onload=()=>{a(e),s(null),r(!1)},e.onerror=()=>{s(Error("Could not load image from ".concat(JSON.stringify(t)))),r(!1)},e.referrerPolicy="strict-origin-when-cross-origin",e.src=t},[t]),n({image:l,error:o,isLoading:i})}let SK=["","webkit","moz","ms","o"].map(e=>"".concat(e,"backingStoreRatio")),SH=-1;function SW(e,t){let n={x:t.center.x,y:t.center.y},i=t.width/2,r=t.height/2;if(i<=0||r<=0)return!1;let l={x:e.x-n.x,y:e.y-n.y};return Math.pow(l.x,2)/Math.pow(i,2)+Math.pow(l.y,2)/Math.pow(r,2)<=1}function S$(e,t){let{x:n,y:i}=e;return Math.pow(n-t.x,2)+Math.pow(i-t.y,2)<Math.pow(t.radius,2)}function SX(e,t){return e.x>=t.left&&e.x<=t.left+t.width&&e.y>=t.top&&e.y<=t.top+t.height}function SG(e,t){return{x:t.center.x-t.width/2*Math.cos(e),y:t.center.y-t.height/2*Math.sin(e)}}var SY=Object.defineProperty,SJ=(e,t,n)=>t in e?SY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,SQ=(e,t,n)=>(SJ(e,"symbol"!=typeof t?t+"":t,n),n);class S0{constructor(e,t){SQ(this,"x"),SQ(this,"y"),this.x=e,this.y=t}}class S1{constructor(e,t,n){SQ(this,"y"),SQ(this,"_left"),SQ(this,"_right"),this.y=e,this._left=t,this._right=n}get right(){return new S0(this._right,this.y)}get left(){return new S0(this._left,this.y)}get length(){return this._right-this._left}}class S2{constructor(e){SQ(this,"rect"),this.rect=e}get top(){return new S1(this.rect.top,this.rect.left,this.rect.right)}get bottom(){return new S1(this.rect.bottom,this.rect.left,this.rect.right)}}class S3{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;SQ(this,"left"),SQ(this,"top"),SQ(this,"width"),SQ(this,"height"),this.left=e,this.top=t,this.width=n,this.height=i}static fromEdges(e){let{left:t,right:n,top:i,bottom:r}=e;return new S3(t,i,1-t-n,1-i-r)}setTopLeft(e,t){return new S3(e,t,this.width||0,this.height||0)}setSize(e,t){return new S3(this.left||0,this.top||0,e,t)}setCenter(e,t){let n=this.width||0,i=this.height||0;return new S3(e-n/2,t-i/2,n||0,i||0)}get center(){return new S0(this.left+this.width/2,this.top+this.height/2)}get corners(){return new S2(this)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}multiply(e){return new S3((this.left||0)+this.width*e.left,(this.top||0)+this.height*e.top,this.width*e.width,this.height*e.height)}grow(e){return new S3(this.left-e,this.top-e,this.width+2*e,this.height+2*e)}shrink(e){return this.grow(-e)}cropRelative(e){let t=this.top+e.top*this.height,n=this.left+e.left*this.width,i=this.height*e.height,r=this.width*e.width;return new S3(n,t,r,i)}clamp(e){let{left:t,top:n,width:i,height:r}=this;return e.width<i&&(i=e.width,t=e.left),e.height<r&&(r=e.height,n=e.top),t+i>e.left+e.width&&(t=e.right-i),n+r>e.top+e.height&&(n=e.bottom-r),new S3(Math.max(t,e.left),Math.max(n,e.top),i,r)}}var S4=Object.defineProperty,S5=(e,t,n)=>t in e?S4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S6=(e,t,n)=>(S5(e,"symbol"!=typeof t?t+"":t,n),n);let S8=sU()("sanity-imagetool");function S9(e,t,n){return{x:e-n.left,y:t-n.top}}function S7(e){return"touches"in e?e.touches.length>0?{x:e.touches[0].clientX,y:e.touches[0].clientY}:{x:0,y:0}:{x:e.clientX,y:e.clientY}}var Te=Object.freeze,Tt=Object.defineProperty,Tn=(e,t)=>Te(Tt(e,"raw",{value:Te(t||e.slice())}));
1let Ti=class extends lK.PureComponent{constructor(){super(...arguments),S6(this,"domNode",null),S6(this,"currentPos",null),S6(this,"isDragging",!1),S6(this,"handleTouchMove",e=>{this.isDragging&&e.preventDefault()}),S6(this,"handleDragStart",e=>{let{onDragStart:t,readOnly:n}=this.props;if(n||!this.domNode)return;if(this.isDragging){S8("Start cancelled, already a drag in progress");return}this.isDragging=!0;let i=S7(e);S8("Drag started %o",i),t(S9(i.x,i.y,this.domNode.getBoundingClientRect())),this.currentPos=i}),S6(this,"handleDrag",e=>{var t;if(!this.isDragging||this.props.readOnly||!this.currentPos)return;let{onDrag:n}=this.props,i=S7(e),r=(t=this.currentPos,{x:i.x-t.x,y:i.y-t.y});n(r),S8("moving by %o",r),this.currentPos=i}),S6(this,"handleDragEnd",e=>{let{onDragEnd:t,readOnly:n}=this.props;if(!this.isDragging||n||!this.domNode)return;let i=S7(e);t(S9(i.x,i.y,this.domNode.getBoundingClientRect())),this.isDragging=!1,this.currentPos=null,S8("Done moving %o",i)}),S6(this,"handleDragCancel",()=>{if(!this.isDragging||this.props.readOnly||!this.currentPos||!this.domNode)return;let{onDragEnd:e}=this.props;this.isDragging=!1,e(S9(this.currentPos.x,this.currentPos.y,this.domNode.getBoundingClientRect())),this.currentPos=null}),S6(this,"setDomNode",e=>{this.domNode=e})}componentDidMount(){ck?(document.body.addEventListener("touchmove",this.handleTouchMove,{passive:!1}),document.body.addEventListener("touchend",this.handleDragEnd),document.body.addEventListener("touchcancel",this.handleDragCancel)):(document.body.addEventListener("mousemove",this.handleDrag),document.body.addEventListener("mouseup",this.handleDragEnd),document.body.addEventListener("mouseleave",this.handleDragCancel))}componentWillUnmount(){ck?(document.body.removeEventListener("touchmove",this.handleTouchMove),document.body.removeEventListener("touchend",this.handleDragEnd),document.body.removeEventListener("touchcancel",this.handleDragCancel)):(document.body.removeEventListener("mousemove",this.handleDrag),document.body.removeEventListener("mouseup",this.handleDragEnd),document.body.removeEventListener("mouseleave",this.handleDragCancel))}render(){let{readOnly:e,onDragStart:t,onDragEnd:n,onDrag:i,...r}=this.props;return(0,lU.jsx)("canvas",{ref:this.setDomNode,onTouchStart:e?void 0:this.handleDragStart,onMouseDown:e?void 0:this.handleDragStart,onTouchMove:e?void 0:this.handleDrag,...r})}},Tr=aW.ZP.div(ia||(ia=Tn(["\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;
1\n"]))),Tl=(0,aW.ZP)(Ti)(io||(io=Tn(["\n display: block;\n position: relative;\n max-width: calc(100% - 0.5em); /* to prevent overlap with change bar */\n max-height: calc(100% + 1em);\n user-select: none;\n"]))),Ta={x:.5,y:.5,height:1,width:1},To={top:0,left:0,right:0,bottom:0};var Ts=Object.defineProperty,Td=(e,t,n)=>t in e?Ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tc=(e,t,n)=>(Td(e,"symbol"!=typeof t?t+"":t,n),n);function Tu(e,t){let{top:n,right:i,bottom:r,left:l}=e.crop||To,a={hotspot:e.hotspot,crop:{top:n+(t.top||0)>0?n:0,right:i+(t.right||0)>0?i:0,bottom:r+(t.bottom||0)>0?r:0,left:l+(t.left||0)>0?l:0}},o={top:n+(t.top||0)>0&&t.top||0,right:i+(t.right||0)>0&&t.right||0,bottom:r+(t.bottom||0)>0&&t.bottom||0,left:l+(t.left||0)>0&&t.left||0};return{value:a,delta:o}}let Tp=oe()(()=>{let e=window.devicePixelRatio||1,t=document.createElement("canvas").getContext("2d"),n=t&&(-1===SH&&(SH=SK.find(e=>e in t)),SH&&t[SH])||1;return e/n}),Th=["left","right","top","topLeft","topRight","bottom","bottomLeft","bottomRight"];class Tf extends lK.PureComponent{constructor(){super(...arguments),Tc(this,"state",{cropping:!1,cropMoving:!1,moving:!1,resizing:!1,mousePosition:null}),Tc(this,"canvas"),Tc(this,"handleDragStart",e=>{let{x:t,y:n}=e,i={x:t*this.getScale(),y:n*this.getScale()},r=SW(i,this.getHotspotRect()),l=S$(i,this.getDragHandleCoords()),a=this.getActiveCropHandleFor(i),o=SX(i,this.getCropRect());a?this.setState({cropping:a}):l?this.setState({resizing:!0}):r?this.setState({moving:!0}):o&&this.setState({cropMoving:!0})}),Tc(this,"handleDrag",e=>{this.state.cropping?this.emitCrop(this.state.cropping,e):this.state.cropMoving?this.emitCropMove(e):this.state.moving?this.emitMove(e):this.state.resizing&&this.emitResize(e)}),Tc(this,"handleDragEnd",()=>{let{onChange:e,onChangeEnd:t}=this.props;this.setState({moving:!1,resizing:!1,cropping:!1,cropMoving:!1});let{hotspot:n,crop:i}=this.getClampedValue(),r=function(e){let t=e.top>e.bottom,n=e.left>e.right;return{top:t?e.bottom:e.top,bottom:t?e.top:e.bottom,left:n?e.right:e.left,right:n?e.left:e.right}}(i),l={crop:{top:r.top,bottom:1-r.bottom,left:r.left,right:1-r.right},hotspot:{x:n.center.x,y:n.center.y,height:Math.abs(n.height),width:Math.abs(n.width)}};e(l),t&&t(l)}),Tc(this,"handleMouseOut",()=>{this.setState({mousePosition:null})}),Tc(this,"handleMouseMove",e=>{let t=e.currentTarget.getBoundingClientRect();this.setState({mousePosition:{x:(e.clientX-t.left)*this.getScale(),y:(e.clientY-t.top)*this.getScale()}})}),Tc(this,"setCanvas",e=>{this.canvas=e})}getHotspotRect(){let{value:e,image:t}=this.props,n=e.hotspot||Ta,i=new S3().setSize(n.width,n.height).setCenter(n.x,n.y);return new S3().setSize(t.width,t.height).shrink(8*this.getScale()).multiply(i)}getCropRect(){let{value:e,image:t}=this.props;return new S3().setSize(t.width,t.height).shrink(8*this.getScale()).cropRelative(S3.fromEdges(e.crop||To).clamp(new S3(0,0,1,1)))}getCropHandles(){let e=this.getCropRect(),t=12*this.getScale(),n=t/2,i=new S3(0,0,t,t);return{left:i.setTopLeft(e.left-n,e.center.y-n),right:i.setTopLeft(e.right-n,e.center.y-n),top:i.setTopLeft(e.center.x-n,e.top-n),topLeft:i.setTopLeft(e.left-n,e.top-n),topRight:i.setTopLeft(e.right-n,e.top-n),bottom:i.setTopLeft(e.center.x-n,e.bottom-n),bottomLeft:i.setTopLeft(e.left-n,e.bottom-n),bottomRight:i.setTopLeft(e.right-n,e.bottom-n)}}getActiveCropHandleFor(e){let{x:t,y:n}=e,i=this.getCropHandles();for(let e of Th)if(SX({x:t,y:n},i[e]))return e;return!1}emitMove(e){let{image:t,value:n,onChange:i}=this.props,r=this.getScale(),l={x:e.x*r/t.width,y:e.y*r/t.height};i(function(e,t){let n=e&&e.hotspot||Ta;return{...e,hotspot:{...n,x:n.x+t.x,y:n.y+t.y}}}(n,l))}emitCropMove(e){let{image:t,onChange:n,value:i}=this.props,r=this.getScale(),l=e.x*r/t.width,a=-e.x*r/t.width,o=e.y*r/t.height,s=-e.y*r/t.height,d={left:l,right:a,top:o,bottom:s};!i||!i.crop||i.crop.top+d.top<0||i.crop.left+d.left<0||i.crop.right+d.right<0||i.crop.bottom+d.bottom<0||n(Tm(i,d))}emitCrop(e,t){let{image:n,onChange:i,value:r}=this.props,l=this.getScale(),a=0,o=0,s=0,d=0;"left"==e||"topLeft"===e||"bottomLeft"===e?a=t.x*l/n.width:("right"==e||"topRight"===e||"bottomRight"===e)&&(o=-t.x*l/n.width),"top"==e||"topLeft"===e||"topRight"===e?s=t.y*l/n.height:("bottom"==e||"bottomLeft"===e||"bottomRight"===e)&&(d=-t.y*l/n.height);let c={left:a,right:o,top:s,bottom:d},u=Tu(r,c).value,p=Tu(r,c).delta;i(Tm(u,p))}emitResize(e){let{image:t,onChange:n,value:i}=this.props,r=this.getScale(),l={x:e.x*r*2/t.width,y:e.y*r*2/t.height};n(function(e,t){let n=e&&e.hotspot||Ta;return{...e,hotspot:{...n,height:n.height+t.height,width:n.width+t.width}}}(i,{height:l.y,width:l.x}))}getClampedValue(){let e=this.props.value,t=S3.fromEdges(e.crop||To).clamp(new S3(0,0,1,1)),n=e.hotspot||Ta,i=new S3(0,0,1,1).setSize(n.width,n.height).setCenter(n.x,n.y).clamp(t);return{crop:t,hotspot:i}}paintHotspot(e,t){let{image:n,readOnly:i}=this.props,r=new S3().setSize(n.width,n.height),{hotspot:l,crop:a}=this.getClampedValue(),o=this.getScale(),s=8*o;function d(t,i,r,l,a,o,s,d){e.save(),e.drawImage(n,t,i,r,l,a,o,s,d),e.restore(
1)}e.save(),function(){let t=r.cropRelative(a),n=r.shrink(s).cropRelative(a);e.save(),d(t.left,t.top,t.width,t.height,n.left,n.top,n.width,n.height),e.globalAlpha=.5,e.fillStyle="black",e.fillRect(n.left,n.top,n.width,n.height),e.restore()}(),function(){e.save();let n=r.shrink(s).multiply(l),i=n.height/n.width;e.scale(1,i),e.beginPath(),e.globalAlpha=t,e.arc(n.center.x,n.center.y/i,Math.abs(n.width/2),0,2*Math.PI,!1),e.strokeStyle="white",e.lineWidth=1.5*o,e.stroke(),e.closePath(),e.restore()}(),e.clip(),function(){let e=r.multiply(l),t=r.shrink(s).multiply(l);d(e.left,e.top,e.width,e.height,t.left,t.top,t.width,t.height)}(),e.restore(),i||function(t){e.save();let n=10*o,i=r.shrink(s).multiply(l),a=SG(t,i);e.beginPath(),e.arc(a.x,a.y,n,0,2*Math.PI,!1),e.fillStyle="rgb(255,255,255)",e.fill(),e.closePath(),e.restore(),e.beginPath(),e.arc(a.x,a.y,n,0,2*Math.PI,!1),e.strokeStyle="rgb(0, 0, 0)",e.lineWidth=.5*o,e.stroke(),e.closePath()}(1.25*Math.PI)}getActualSize(){var e;let t=null==(e=this.canvas)?void 0:e.domNode;return t?{height:t.clientHeight,width:t.clientWidth}:{height:0,width:0}}getDragHandleCoords(){let e=this.getHotspotRect(),t=SG(1.25*Math.PI,e);return{x:t.x,y:t.y,radius:8*this.getScale()}}debug(e){e.save();let{image:t}=this.props,n=this.getHotspotRect(),i=this.getScale(),r=8*i;function l(e){o(e,r,e,t.height-r)}function a(e){o(r,e,t.width-r,e)}function o(t,n,i,r){e.beginPath(),e.moveTo(t,n),e.lineTo(i,r),e.stroke(),e.closePath()}e.setLineDash&&e.setLineDash([2*i,2*i]),e.lineWidth=.5*i,e.strokeStyle="rgba(200, 200, 200, 0.5)",l(n.center.x),a(n.center.y),e.strokeStyle="rgba(150, 150, 150, 0.5)",a(n.top),a(n.bottom),l(n.left),l(n.right),e.restore()}
1paintBackground(e){let{image:t}=this.props,n=new S3().setSize(t.width,t.height).shrink(8*this.getScale());e.save(),e.fillStyle="white",e.clearRect(0,0,t.width,t.height),e.globalAlpha=.3,e.drawImage(t,n.left,n.top,n.width,n.height),e.restore()}paint(e){let{readOnly:t}=this.props;e.save();let n=Tp();e.scale(n,n);let i=!t&&this.state.mousePosition?.8:.2;this.paintBackground(e),this.paintHotspot(e,i),this.debug(e),this.paintCropBorder(e),t||this.highlightCropHandles(e,i),e.restore()}paintMousePosition(e){if(!this.state.mousePosition)return;let{x:t,y:n}=this.state.mousePosition;e.beginPath(),e.arc(t,n,14*this.getScale(),0,2*Math.PI,!1),e.fillStyle="lightblue",e.fill(),e.restore()}paintCropBorder(e){let t=this.getCropRect();e.save(),e.beginPath(),e.fillStyle="rgba(66, 66, 66, 0.9)",e.lineWidth=1,e.rect(t.left,t.top,t.width,t.height),e.stroke(),e.closePath(),e.restore()}highlightCropHandles(e,t){e.save();let n=this.getCropHandles();Th.forEach(i=>{e.fillStyle=this.state.cropping===i?"rgba(202, 54, 53, ".concat(t,")"):"rgba(230, 230, 230, ".concat(t+.4,")");let{left:r,top:l,height:a,width:o}=n[i];e.fillRect(r,l,o,a),e.beginPath(),e.fillStyle="rgba(66, 66, 66, ".concat(t,")"),e.rect(r,l,o,a),e.closePath(),e.stroke()}),e.restore()}getScale(){let e=this.getActualSize();return this.props.image.width/e.width}getCursor(){let{mousePosition:e}=this.state,{readOnly:t}=this.props;if(!e||t)return"auto";let n=this.state.cropping||this.getActiveCropHandleFor(e);if(n)return function(e){switch(e){case"left":case"right":return"col-resize";case"top":case"bottom":return"row-resize";case"topRight":case"bottomLeft":return"nesw-resize";case"topLeft":case"bottomRight":return"nwse-resize";default:return null}}(n)||"auto";let i=S$(e,this.getDragHandleCoords());if(this.state.resizing||i)return"move";
1if(this.state.moving||this.state.cropMoving)return"url(".concat("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAABdSURBVEjH7ZA7DsAwCEMN6v2vTCdESpLKQRl5gxfzMQDNRQyWlEK83QAIRh3cH/QbIhQwMDl8gORl7A16WD/xxAdq6N6SgycKUblf41+wbFBT44RiCi11NU3TLHgBxRUUD4ITqnIAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTUtMDEtMjFUMDA6MTM6NDMrMDE6MDC74T7AAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDEyLTA0LTAyVDA0OjEzOjM3KzAyOjAwQJ35wQAAAABJRU5ErkJggg==","), move");let r=SW(e,this.getHotspotRect()),l=SX(e,this.getCropRect());return r||l?"url(".concat("data:image/png;base64,AAACAAEAICACAAcABQAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAAAEAAAAAAAAAAAAAAgAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAA/AAAAfwAAAP+AAAH/gAAB/8AAA//AAAd/wAAGf+AAAH9gAADbYAAA2yAAAZsAAAGbAAAAGAAAAAAAAA//////////////////////////////////////////////////////////////////////////////////////gH///4B///8Af//+AD///AA///wAH//4AB//8AAf//AAD//5AA///gAP//4AD//8AF///AB///5A////5///8=","), move"):"auto"}componentDidMount(){this.draw()}componentDidUpdate(){this.draw()}draw(){if(!this.canvas)return;let e=this.canvas.domNode,t=e.getContext("2d");if(!t)return;this.paint(t);let n=e.style.cursor,i=this.getCursor();n!==i&&(e.style.cursor=i)}render(){let{image:e,readOnly:t}=this.props,n=Tp();return(0,lU.jsx)(Tr,{children:(0,lU.jsx)(Tl,{readOnly:t,ref:this.setCanvas,onDrag:this.handleDrag,onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd,onMouseMove:this.handleMouseMove,onMouseOut:this.handleMouseOut,height:e.height*n,width:e.width*n})})}}function Tm(e,t){let n=e&&e.crop||To;return{...e,crop:{left:n.left+(t.left||0),right:n.right+(t.right||0),top:n.top+(t.top||0),bottom:n.bottom+(t.bottom||0)}}}function Tg(e){let{image:t,maxHeight:n,maxWidth:i,children:r}=e,[l]=(0,lK.useState)(()=>{let e=document.createElement("canvas");return e.style.display="none",e});(0,lK.useEffect)(()=>(document.body.appendChild(l),()=>{document.body.removeChild(l)}),[l]);let a=(0,lK.useCallback)((e,t,n)=>{let i=e.width/e.height,r=Math.min(e.width,n),a=Math.min(e.height,t),o=e.width>e.height,s=o?r:a*i,d=o?r/i:a;l.width=s,l.height=d;let c=l.getContext("2d");return c&&c.drawImage(e,0,0,e.width,e.height,0,0,s,d),l},[l]);return r(a(t,n,i))}function Tx(e){return(0,lU.jsx)(SB,{src:e.src,children:t=>{let{isLoading:n,image:i,error:r}=t;return n?(0,lU.jsx)("div",{children:"Loading..."}):r?(0,lU.jsx)("div",{children:r.message}):i?(0,lU.jsx)(Tg,{image:i,maxHeight:Tx.maxHeight,maxWidth:Tx.maxWidth,children:t=>(0,lU.jsx)(Tf,{image:t,...e})}):null}})}function Tv(e){if(!e)return null;if("aspectRatio"in e)return e.aspectRatio;if("height"in e||"width"in e){if("number"!=typeof e.height&&"number"!=typeof e.width)throw Error("Height and width must be numbers, got ".concat(JSON.stringify(e)));return e.width/e.height}return null}function Tb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=Math.pow(10,t);return Math.round(e*n)/n}function Ty(e){return 0===e?0:"".concat(e,"%")}function Tj(e){return Ty(Tb(100*e))}Tx.maxHeight=500,Tx.maxWidth=1e3;var Tw=Object.freeze,Tk=Object.defineProperty;let TC=aW.ZP.div(is||(is=Tw(Tk(q=["\n position: relative;\n width: 100%;\n"],"raw",{value:Tw(q.slice())})))),T_=sU()("sanity-imagetool"),TS=(0,lK.memo)(function(e){let{alignX:t="center",alignY:n="center",alt:i,aspectRatio:r="none",className:l="",crop:a=To,hotspot:o=Ta,onError:s,onLoad:d,src:c,srcAspectRatio:u,srcSet:p,style:h}=e,[f,m]=(0,lK.useState)(null),g=(0,lK.useRef)(null),x=(0,lK.useRef)(null),v=(0,lK.useCallback)(()=>{if(g.current){if("auto"===r){let e=g.current.parentNode;(0,lK.startTransition)(()=>m(e.offsetWidth/e.offsetHeight))}else m(null)}},[r]);(0,lK.useEffect)(()=>{let e=x.current,t=e&&e.src&&e.complete&&void 0!==e.naturalWidth;return t&&(T_("Image '%s' already loaded, refreshing (from cache) to trigger onLoad / onError",c),e.src=e.src),v(),window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v)}},[c,v]);let b=(0,lK.useMemo)(()=>"none"===r?a?function(e,t){let n=1/t,i=t*n,r=i-(e.left+e.right)*i,l=n-(e.top+e.bottom)*n;return r/l}(a,u):u:"auto"===r?f:r||null,[r,f,a,u]),y=(0,lK.useMemo)(()=>(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Tv(e.image)||1,n=e.hotspot||Ta,i=e.crop||To,r=Tv(e.container)||t*function(e){let t=1-e.top-e.bottom,n=1-e.left-e.right;return n/t}(i),l=e.align||{x:"center",y:"center"},a=function(e,t,n){let i,r,l;let a=t.crop,o=n.aspect,s=n.align,d=1-a.left-a.right,c=1-a.top-a.bottom,u={top:-a.top/c,left:-a.left/d,width:1/d,height:1/c},p=d/c*e,h={x:(t.hotspot.x-a.left)/d,y:(t.hotspot.y-a.top)/c,height:t.hotspot.height/c,width:t.hotspot.width/d},f=1/h.width,m=1/h.height*p/o,g=Math.min(f,m),x=p<=o;if((i=x?1:p/o)>g){let e;r="letterbox";let t=i-g;
1l={width:e=x?1-t:g,height:e/p*o,left:0,top:0};let n=h.x*l.width-h.width*l.width/2;switch(s.x){case"left":l.left=x?0:-n;break;case"right":l.left=x?1-l.width:n;break;case"center":l.left=x?(1-l.width)/2:-n;break;default:throw Error("Invalid x alignment: '".concat(s.x,"'. Must be either 'left', 'right' or 'center'"))}let a=h.y*l.height-h.height*l.height/2;switch(s.y){case"top":l.top=x?-a:0;break;case"bottom":l.top=a;break;case"center":l.top=x?-a:(1-l.height)/2;break;default:throw Error("Invalid y alignment: '".concat(s.y,"'. Must be either 'top', 'bottom' or 'center'"))}}else if(x){r="full_width";let e=-h.y/p*o+.5,t=i/p*o;e>0?e=0:-e>t-1&&(e=-(t-1)),l={width:i,height:t,left:0,top:e}}else{r="full_height";let e=.5-h.x*i;e>0?e=0:-e>i-1&&(e=-(i-1)),l={width:i,height:i/p*o,top:0,left:e}}return{method:r,crop:l,image:u}}(t,{hotspot:n,crop:i},{aspect:r,align:l}),o=Ty(Tb(100/r));return{debug:{result:a},container:{overflow:"hidden",position:"relative",width:"100%",height:o},padding:{marginTop:o},crop:{position:"absolute",overflow:"hidden",height:Tj(a.crop.height),width:Tj(a.crop.width),top:Tj(a.crop.top),left
1:Tj(a.crop.left)},image:{position:"absolute",height:Tj(a.image.height),width:Tj(a.image.width),top:Tj(a.image.top),left:Tj(a.image.left)}}})({container:{aspectRatio:b||u},image:{aspectRatio:u},hotspot:o,crop:a,align:{x:t,y:n}}),[t,n,a,o,u,b]);return(0,lU.jsx)(TC,{className:"".concat(l),style:h,ref:g,children:(0,lU.jsxs)("div",{style:y.container,children:[(0,lU.jsx)("div",{style:y.padding}),(0,lU.jsx)("div",{style:y.crop,children:(0,lU.jsx)("img",{ref:x,src:c,alt:i,srcSet:p,onLoad:d,onError:s,style:y.image})})]})})}),TT={isLoading:!0};var TE=Object.freeze,TP=Object.defineProperty;let TA=["hotspot"],TO=[["3:4",3/4],["Square",1],["16:9",16/9],["Panorama",4]],Tz={crop:To,hotspot:Ta},TM=aW.ZP.div(id||(id=TE(TP(N=["\n min-height: 6em;\n"],"raw",{value:TE(N.slice())}))));function TI(e){return(0,lU.jsx)(lY.kC,{align:"center",justify:"center",padding:4,style:{overflowWrap:"break-word"},children:e.children})}function TR(e){let{imageUrl:t,value:n,changed:i,level:r,path:l,focusPath:a=co,presence:o,onChange:s,schemaType:d,onPathFocus:c,readOnly:u,elementProps:p}=e,[h,f]=(0,lK.useState)(n||Tz),{image:m,isLoading:g,error:x}=function(e){let[t,n]=(0,lK.useState)(TT);return(0,lK.useEffect)(()=>{n(TT);let t=new l9.y(t=>{let n=document.createElement("img"),i=!1;return n.onload=()=>{i=!0,t.next(n),t.complete()},n.onerror=()=>{i=!0,t.error(Error("Could not load image from ".concat(e.startsWith("blob:")?"blob":e)))},n.src=e,()=>{n.onload=null,n.onerror=null,i||(n.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=")}}).subscribe({error:e=>{n({isLoading:!1,error:e})},next:e=>{n({image:e,isLoading:!1})}});return()=>{t.unsubscribe()}},[e]),t}(t),v=(0,lK.useCallback)(()=>{c(TA)},[c]);(0,lK.useEffect)(()=>{f(n||Tz)},[n]);let b="hotspot"===a[0];m$(b,e=>{var t;!e&&b&&(null==(t=p.ref.current)||t.focus())});let y=(0,lK.useCallback)(e=>{if(u)return;let t=d.fields.find(e=>"crop"===e.name&&"object"!==e.type.name),n=d.fields.find(e=>"object"!==e.type.name&&"hotspot"===e.name),i=t?{_type:t.type.name,...e.crop||To}:e.crop,r=n?{_type:n.type.name,...e.hotspot||Ta}:e.hotspot;s([mF(i,["crop"]),mF(r,["hotspot"])])},[s,u,d.fields]);return(0,lU.jsx)(jm,{title:"Hotspot & crop",level:r,description:"Adjust the rectangle to crop image. Adjust the circle to specify the area that should always be visible.",__unstable_presence:o,children:(0,lU.jsxs)("div",{children:[(0,lU.jsx)(lY.Zb,{__unstable_checkered:!0,__unstable_focusRing:!0,tabIndex:0,ref:p.ref,onFocus:v,children:(0,lU.jsx)(cD,{path:l.concat(TA),hasFocus:"hotspot"===a[0],isChanged:i,children:(0,lU.jsxs)(SU,{ratio:1.5,children:[(g||x)&&(0,lU.jsx)(TI,{children:x?(0,lU.jsx)(lY.Zb,{padding:4,radius:2,tone:"critical",border:!0,children:(0,lU.jsxs)(lY.xv,{children:["Error: ",x.message]})}):(0,lU.jsx)(lY.xv,{muted:!0,children:"Loading image⦠"})}),!g&&m&&(0,lU.jsx)(lY.xu,{margin:1,children:(0,lU.jsx)(Tx,{value:h,src:m.src,readOnly:!!u,onChangeEnd:y,onChange:f})})]})})}),(0,lU.jsx)(lY.xu,{marginTop:3,children:(0,lU.jsx)(lY.rj,{columns:TO.length,gap:1,children:TO.map(e=>{let[t,n]=e;return(0,lU.jsxs)("div",{children:[(0,lU.jsx)(lY.X6,{as:"h4",size:0,children:t}),(0,lU.jsx)(lY.xu,{marginTop:2,children:(0,lU.jsx)(SU,{ratio:n,children:(0,lU.jsx)(lY.Zb,{__unstable_checkered:!0,children:!g&&m?(0,lU.jsx)(TS,{aspectRatio:n,src:m.src,srcAspectRatio:m.width/m.height,hotspot:h.hotspot||Ta,crop:h.crop||To}):(0,lU.jsx)(TM,{})})})})]},n)})})})]})})}var TF=Object.freeze,TD=Object.defineProperty;let TZ=(0,aW.ZP)(lY.gF)(ic||(ic=TF(TD(V=["\n position: absolute;\n top: 0;\n right: 0;\n"],"raw",{value:TF(V.slice())}))));function TL(e){let{onEdit:t,children:n,showEdit:i,setHotspotButtonElement:r,setMenuButtonElement:l,onMenuOpen:a,isMenuOpen:o}=e,[s,d]=(0,lK.useState)(null),[c,u]=(0,lK.useState)(null),p=(0,lK.useCallback)(()=>a(!o),[a,o]);(0,lY.qh)((0,lK.useCallback)(e=>{o&&("Escape"===e.key||"Tab"===e.key)&&(a(!1),null==c||c.focus())},[o,a,c])),(0,lY.O8)((0,lK.useCallback)(e=>{(null==c?void 0:c.contains(e.target))||a(!1)},[c,a]),[s]);let h=(0,lK.useCallback)(e=>{l(e),u(e)},[l]);return(0,lK.useEffect)(()=>{o&&(null==s||s.focus())},[o,s]),(0,lU.jsxs)(TZ,{"data-buttons":!0,space:1,padding:2,children:[i&&(0,lU.jsx)(lY.zx,{"aria-label":"Open image edit dialog","data-testid":"options-menu-edit-details",icon:a0.Rf5,mode:"ghost",onClick:t,ref:r}),(0,lU.jsx)(lY.J2,{id:"image-actions-menu",content:(0,lU.jsx)(lY.v2,{ref:d,children:n}),portal:!0,open:o,constrainSize:!0,children:(0,lU.jsx)(lY.zx,{"aria-label":"Open image options menu","data-testid":"options-menu-button",icon:a0.zGg,mode:"ghost",onClick:p,ref:h})})]})}var Tq=Object.freeze,TN=Object.defineProperty,TV=(e,t)=>Tq(TN(e,"raw",{value:Tq(t||e.slice())}));let TU=(0,aW.ZP)(lY.Zb)(iu||(iu=TV(["\n position: relative;\n width: 100%;\n overflow: hidden;\n overflow: clip;\n min-height: 3.75rem;\n max-height: 20rem;\n\n & > div[data-container] {\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex !important;
1\n align-items: center;\n justify-content: center;\n }\n\n & img {\n max-width: 100%;\n max-height: 100%;\n }\n"]))),TB=(0,aW.ZP)(lY.$j)(ip||(ip=TV(["\n position: absolute;\n"]))),TK=(0,aW.ZP)(lY.kC)(e=>{let{tone:t,drag:n}=e,i=lY.Lg.color.light[t].card.enabled.fg,r=(0,lY.m4)(lY.Lg.color.light[t].card.enabled.bg,.8);return(0,aW.iv)(ih||(ih=TV(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n backdrop-filter: ",";\n color: ",";\n background-color: ",";\n "])),n?"blur(10px)":"",t?i:"",n?r:"transparent")}),TH=(0,aW.ZP)(lY.kC)(im||(im=TV(["\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n"]))),TW=e=>{let t=new URLSearchParams(e.split("?")[1]),n=t.get("rect");return n?[n.split(",")[2],n.split(",")[3]].map(Number):e.split("-")[1].split(".")[0].split("x").map(Number)};function T$(e){let{drag:t,readOnly:n,isRejected:i,src:r,...l}=e,[a,o]=(0,lK.useState)(!1),[s,d]=(0,lK.useState)(null),c=(0,lY.XL)(s),u=(null==c?void 0:c.width)||0,p=i||n?"critical":"primary",h=t?p:"default",f=30*document.documentElement.clientHeight/100,[m,g]=TW(r);(0,lK.useEffect)(()=>{o(!1)},[r]);let x=(0,lK.useCallback)(()=>{o(!0)},[]);return(0,lU.jsxs)(TU,{...l,ref:d,style:{height:(m>u?u/(m/g):g)<f?null:"".concat(30,"vh")},tone:"transparent",children:[(0,lU.jsxs)(lY.Zb,{"data-container":!0,tone:"inherit",children:[!a&&(0,lU.jsx)(TY,{cardTone:"transparent",drag:!0,content:(0,lU.jsx)(TB,{})}),(0,lU.jsx)("img",{src:r,"data-testid":"hotspot-image-input",alt:e.alt,onLoad:x,referrerPolicy:"strict-origin-when-cross-origin"})]}),t&&(0,lU.jsx)(TY,{cardTone:h,drag:t,content:(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{marginBottom:3,children:(0,lU.jsx)(lY.X6,{children:(0,lU.jsx)(TX,{isRejected:i,readOnly:n})})}),(0,lU.jsx)(TG,{isRejected:i,readOnly:n})]})})]})}function TX(e){let{isRejected:t,readOnly:n}=e;return t?(0,lU.jsx)(a0.vaB,{}):n?(0,lU.jsx)(a0.CPA,{}):(0,lU.jsx)(a0.XBm,{})}function TG(e){let{isRejected:t,readOnly:n}=e,i="Drop image to upload";return t&&(i="Cannot upload this file here"),n&&(i="This field is read only"),(0,lU.jsx)(lY.xv,{size:1,children:i})}function TY(e){let{cardTone:t,drag:n,content:i}=e;return(0,lU.jsx)(TK,{justify:"flex-end",padding:3,tone:t,drag:n,children:(0,lU.jsx)(TH,{direction:"column",align:"center",justify:"center",children:i})})}var TJ=Object.freeze,TQ=Object.defineProperty;let T0=(0,aW.ZP)(lY.zx)(ig||(ig=TJ(TQ(U=["\n width: 100%;\n"],"raw",{value:TJ(U.slice())}))));function T1(e){let{onClearValue:t}=e;return(0,lU.jsxs)(lY.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,lU.jsxs)(lY.kC,{gap:4,marginBottom:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"Invalid image value"}),(0,lU.jsx)(lY.xv,{size:1,children:"The value of this field is not a valid image. Resetting this field will let you choose a new image."})]})]}),(0,lU.jsx)(T0,{icon:a0.X5P,text:"Reset value",onClick:t,mode:"ghost"})]})}var T2=Object.defineProperty,T3=(e,t,n)=>t in e?T2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T4=(e,t,n)=>(T3(e,"symbol"!=typeof t?t+"":t,n),n);let T5=()=>"undefined"!=typeof window&&window.devicePixelRatio?Math.round(Math.max(1,window.devicePixelRatio)):1;function T6(e){let{children:t}=e;return t}let T8=["asset"],T9={portal:!0};class T7 extends lK.PureComponent{constructor(e){var t;super(e),t=this,T4(this,"_previewElement",null),T4(this,"_assetPath"),T4(this,"uploadSubscription",null),T4(this,"state",{isUploading:!1,selectedAssetSource:null,hoveringFiles:[],isStale:!1,hotspotButtonElement:null,menuButtonElement:null,isMenuOpen:!1}),T4(this,"toast",null),T4(this,"setPreviewElement",e=>{this._previewElement=e}),T4(this,"setHotspotButtonElement",e=>{this.setState({hotspotButtonElement:e})}),T4(this,"setMenuButtonElement",e=>{this.setState({menuButtonElement:e})}),T4(this,"getUploadOptions",e=>{let{schemaType:t,resolveUploader:n}=this.props,i=n&&n(t,e);return i?[{type:t,uploader:i}]:[]}),T4(this,"uploadWith",function(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{schemaType:r,onChange:l,client:a}=t.props,{label:o,title:s,description:d,creditLine:c,source:u}=i,p={metadata:op()(r,"options.metadata"),storeOriginalFilename:op()(r,"options.storeOriginalFilename"),label:o,title:s,description:d,creditLine:c,source:u};t.cancelUpload(),t.setState({isUploading:!0}),l(mI({_type:r.name})),t.uploadSubscription=e.upload(a,n,r,p).subscribe({next:e=>{e.patches&&l(e.patches)},error:e=>{var n;console.error(e),null==(n=t.toast)||n.push({status:"error",description:"The upload could not be completed at this time.",title:"Upload failed"}),t.clearUploadStatus()},complete:()=>{l([mD(["hotspot"]),mD(["crop"])]),t.setState({isUploading:!1})}})}),T4(this,"handleRemoveButtonClick",()=>{let{value:e}=this.props,t=Object.keys(e||{}),n=t.filter(e=>!["_type","_key","_upload","asset","crop","hotspot"].includes(e)),i=0===n.length,r=["asset"].concat(t.filter(e=>["crop","hotspot","_upload"].includes(e))).map(e=>mD([e]));this.props.onChange(i&&!this.valueIsArrayElement()?mD():r)}),T4(this,"handleFieldChange",e=>{let{onChange:t,schemaType:n}=this.props;if(!this.valueIsArrayElement()&&this.eventIsUnsettingLastFilledField(e)){t(mD());return}t(e.prepend(mI({_type:n.name})).patches)}),T4(this,"eventIsUnsettingLastFilledField",e=>{let t=e.patches[0];if(1!==e.patches.length||"unset"!==t.type)return!1;let n=Object.keys(this.props.value||{}),i=n.filter(e=>!["_type","_key","crop","hotspot"].includes(e)),r=1===e.patches[0].path.length&&1===i.length&&i[0]===e.patches[0].path[0];return r}),T4(this,"valueIsArrayElement",()=>{let{path:e}=this.props,t=e.slice(-1)[0];return"string"!=typeof t}),T4(this,"handleOpenDialog",()=>{let{onFieldOpen:e}=this.props;e("hotspot")}
1),T4(this,"handleCloseDialog",()=>{var e;let{onFieldClose:t}=this.props;t("hotspot"),null==(e=this.state.hotspotButtonElement)||e.focus()}),T4(this,"handleSelectAssetFromSource",e=>{let{onChange:t,schemaType:n,resolveUploader:i}=this.props;Si({assetFromSource:e,onChange:t,type:n,resolveUploader:i,uploadWith:this.uploadWith,isImage:!0}),this.setState({selectedAssetSource:null})}),T4(this,"handleFileTargetFocus",e=>{var t;e.currentTarget===e.target&&e.currentTarget===(null==(t=this.props.elementProps.ref)?void 0:t.current)&&this.props.elementProps.onFocus(e)}),T4(this,"handleFilesOver",e=>{this.setState({hoveringFiles:e.filter(e=>"string"!==e.kind)})}),T4(this,"handleFilesOut",()=>{this.setState({hoveringFiles:[]})}),T4(this,"handleCancelUpload",()=>{this.cancelUpload()}),T4(this,"handleClearUploadState",()=>{this.setState({isStale:!1}),this.clearUploadStatus()}),T4(this,"handleStaleUpload",()=>{this.setState({isStale:!0})}),T4(this,"handleClearField",()=>{this.props.onChange([mD(["asset"]),mD(["crop"]),mD(["hotspot"])])}),T4(this,"handleSelectFiles",e=>{let{directUploads:t,readOnly:n}=this.props,{hoveringFiles:i}=this.state;t&&!n?this.uploadFirstAccepted(e):i.length>0&&this.handleFilesOut()}),T4(this,"handleSelectImageFromAssetSource",e=>{this.setState({selectedAssetSource:e})}),T4(this,"handleAssetSourceClosed",()=>{var e;this.setState({selectedAssetSource:null}),null==(e=this.state.menuButtonElement)||e.focus()}),T4(this,"renderHotspotInput",e=>{let{value:t,changed:n,id:i,imageUrlBuilder:r}=this.props,l=this.isImageToolEnabled()&&t&&t.asset;return(0,lU.jsx)(lY.Vq,{__unstable_autoFocus:!1,header:"Edit hotspot and crop",id:"".concat(i,"_dialog"),onClickOutside:this.handleCloseDialog,onClose:this.handleCloseDialog,width:1,children:(0,lU.jsx)(jt,{children:(0,lU.jsx)(lY.xu,{padding:4,children:(0,lU.jsx)(lY.Kq,{space:5,children:l&&(null==t?void 0:t.asset)&&(0,lU.jsx)(TR,{...this.props,imageUrl:r.image(t.asset).url(),value:t,presence:e.presence,changed:n})})})})})}),T4(this,"renderPreview",()=>{let{value:e,schemaType:t,readOnly:n,directUploads:i,imageUrlBuilder:r,resolveUploader:l}=this.props;if(!e||!(0,o2.JZ)(e))return null;let{hoveringFiles:a}=this.state,o=a.filter(e=>l(t,e)),s=a.length-o.length,d=r.width(2e3).fit("max").image(e).dpr(T5()).auto("format").url();return(0,lU.jsx)(T$,{drag:!(null==e?void 0:e._upload)&&a.length>0,isRejected:s>0||!i,readOnly:n,src:d,alt:"Preview of uploaded image"})}),T4(this,"setToast",e=>{this.toast=e}),this._assetPath=e.path.concat(T8)}isImageToolEnabled(){return!0===op()(this.props.schemaType,"options.hotspot")}clearUploadStatus(){var e;(null==(e=this.props.value)?void 0:e._upload)&&this.props.onChange(mD(["_upload"]))}cancelUpload(){this.uploadSubscription&&(this.uploadSubscription.unsubscribe(),this.clearUploadStatus())}uploadFirstAccepted(e){let{schemaType:t,resolveUploader:n}=this.props,i=e.map(e=>({file:e,uploader:n(t,e)})).find(e=>e.uploader);i&&this.uploadWith(i.uploader,i.file),this.setState({isMenuOpen:!1})}renderAssetMenu(){let{value:e,assetSources:t,schemaType:n,readOnly:i,directUploads:r,imageUrlBuilder:l,observeAsset:a}=this.props,o=null==e?void 0:e.asset;if(!o)return null;let s=op()(n,"options.accept","image/*"),d=e&&o&&this.isImageToolEnabled(),c=t&&0===t.length?null:(0,lU.jsx)(lY.sN,{icon:a0.W1M,text:"Select",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(t[0])},disabled:i,"data-testid":"file-input-browse-button"});return t&&t.length>1&&(c=t.map(e=>(0,lU.jsx)(lY.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e)},icon:e.icon||a0.XBm,"data-testid":"file-input-browse-button-".concat(e.name),disabled:i},e.name))),(0,lU.jsx)(_K,{observeAsset:a,reference:o,children:t=>{let n,a,{_id:o,originalFilename:u,extension:p}=t;if((0,o2.JZ)(e)){let e=u||"download.".concat(p);a=l.image(o).forceDownload(e).url(),n=l.image(o).url()}return(0,lU.jsx)(TL,{isMenuOpen:this.state.isMenuOpen,onEdit:this.handleOpenDialog,onMenuOpen:e=>this.setState({isMenuOpen:e}),setHotspotButtonElement:this.setHotspotButtonElement,setMenuButtonElement:this.setMenuButtonElement,showEdit:d,children:(0,lU.jsx)(Ss,{onUpload:this.handleSelectFiles,browse:c,onReset:this.handleRemoveButtonClick,downloadUrl:a,copyUrl:n,readOnly:i,directUploads:r,accept:s})})}})}renderBrowser(){let{assetSources:e,readOnly:t,directUploads:n,id:i}=this.props;return e&&0===e.length?null:e&&e.length>1&&!t&&n?(0,lU.jsx)(lY.j2,{id:"".concat(i,"_assetImageButton"),ref:this.setMenuButtonElement,button:(0,lU.jsx)(lY.zx,{"data-testid":"file-input-multi-browse-button",icon:a0.W1M,iconRight:a0.v4q,mode:"ghost",text:"Select"}),menu:(0,lU.jsx)(lY.v2,{children:e.map(e=>(0,lU.jsx)(lY.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e)},icon:e.icon||a0.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)}
1,e.name))}),popover:T9}):(0,lU.jsx)(lY.zx,{fontSize:2,text:"Select",icon:a0.W1M,mode:"ghost",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e[0])},"data-testid":"file-input-browse-button",disabled:t})}renderUploadPlaceholder(){let{schemaType:e,readOnly:t,directUploads:n,resolveUploader:i}=this.props,{hoveringFiles:r}=this.state,l=r.filter(t=>i(e,t)),a=r.length-l.length,o=op()(e,"options.accept","image/*");return(0,lU.jsx)("div",{style:{padding:1},children:(0,lU.jsx)(lY.Zb,{tone:t?"transparent":"inherit",border:!0,padding:3,style:0===r.length?{borderStyle:"dashed"}:{borderStyle:"dashed",borderColor:"transparent"},children:(0,lU.jsx)(Sv,{browse:this.renderBrowser(),onUpload:this.handleSelectFiles,readOnly:t,hoveringFiles:r,acceptedFiles:l,rejectedFilesCount:a,type:"image",accept:o,directUploads:n})})})}renderUploadState(e){var t;let{isUploading:n}=this.state,i=null==(t=this._previewElement)?void 0:t.offsetHeight;return(0,lU.jsx)(St,{uploadState:e,onCancel:n?this.handleCancelUpload:void 0,onStale:this.handleStaleUpload,height:i})}renderAssetSource(){let{selectedAssetSource:e}=this.state,{value:t,schemaType:n,observeAsset:i}=this.props,r=op()(n,"options.accept","image/*");if(!e)return null;let l=e.component;return t&&t.asset?(0,lU.jsx)(_K,{observeAsset:i,reference:t.asset,children:e=>(0,lU.jsx)(l,{selectedAssets:[e],assetType:"image",accept:r,selectionType:"single",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}):(0,lU.jsx)(l,{selectedAssets:[],selectionType:"single",assetType:"image",accept:r,onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}getFileTone(){let{schemaType:e,value:t,readOnly:n,directUploads:i,resolveUploader:r}=this.props,{hoveringFiles:l}=this.state,a=l.filter(t=>r(e,t)),o=l.length-a.length;return l.length>0&&(o>0||!i)?"critical":(null==t?void 0:t._upload)||n||!(l.length>0)?n?"transparent":(null==t?void 0:t._upload)&&(null==t?void 0:t.asset)?"transparent":"default":"primary"}renderAsset(){let{value:e,readOnly:t,elementProps:n}=this.props,{hoveringFiles:i,isStale:r}=this.state,l=!!((null==e?void 0:e._upload)||(null==e?void 0:e.asset));return!e||void 0===e.asset||(null==e?void 0:e._upload)||(0,o2.JZ)(e)?a=>(0,lU.jsxs)(lU.Fragment,{children:[r&&(0,lU.jsx)(lY.xu,{marginBottom:2,children:(0,lU.jsx)(Sw,{onClearStale:this.handleClearUploadState})}),(0,lU.jsx)(cD,{path:a.path.concat(T8),hasFocus:!!a.focused,isChanged:a.changed,children:(null==e?void 0:e._upload)?this.renderUploadState(e._upload):(0,lU.jsxs)(_2,{...n,onFocus:this.handleFileTargetFocus,tabIndex:0,disabled:!!t,onFiles:this.handleSelectFiles,onFilesOver:this.handleFilesOver,onFilesOut:this.handleFilesOut,tone:this.getFileTone(),$border:l||i.length>0,style:{padding:1},sizing:"border",radius:2,children:[!(null==e?void 0:e.asset)&&this.renderUploadPlaceholder(),!(null==e?void 0:e._upload)&&(null==e?void 0:e.asset)&&(0,lU.jsxs)("div",{style:{position:"relative"},ref:this.setPreviewElement,children:[this.renderPreview(),this.renderAssetMenu()]})]})})]}):()=>(0,lU.jsx)(T1,{onClearValue:this.handleClearField})}render(){let{members:e,renderAnnotation:t,renderBlock:n,renderField:i,renderInlineBlock:r,renderInput:l,renderItem:a,renderPreview:o}=this.props,{selectedAssetSource:s}=this.state,d=e.find(e=>"field"===e.kind&&"hotspot"===e.name);return(0,lU.jsxs)(lY.Kq,{space:5,"data-testid":"image-input",children:[(0,lU.jsx)(pJ,{ref:this.setToast}),e.map(e=>"field"===e.kind&&("crop"===e.name||"hotspot"===e.name)?null:"field"===e.kind?(0,lU.jsx)(kd,{member:e,renderAnnotation:t,renderBlock:n,renderInlineBlock:r,renderInput:"asset"===e.name?this.renderAsset():l,renderField:"asset"===e.name?T6:i,renderItem:a,renderPreview:o},e.key):"fieldSet"===e.kind?(0,lU.jsx)(kk,{member:e,renderAnnotation:t,renderBlock:n,renderField:i,renderInlineBlock:r,renderInput:l,renderItem:a,renderPreview:o},e.key):"error"===e.kind?(0,lU.jsx)(kw,{member:e},e.key):(0,lU.jsxs)(lU.Fragment,{children:["Unknown member kind: $",e.kind]})),(null==d?void 0:d.open)&&(0,lU.jsx)(kR,{...this.props,absolutePath:d.field.path,renderInput:this.renderHotspotInput}),s&&this.renderAssetSource()]})}}let Ee=()=>{},Et={isLoading:!0,result:void 0,error:void 0,retry:Ee},En={isLoading:!1,result:void 0,error:void 0,retry:Ee};function Ei(e,t){let[n,i]=(0,lK.useState)(0),r=(0,lK.useCallback)(()=>{i(e=>e+1)},[]),l=(0,lK.useMemo)(()=>({_id:e._id,_type:e._type}),[e._id,e._type]),a=(0,lJ.m2)(()=>l._id?t(l).pipe((0,ad.U)(e=>({isLoading:!1,result:e,error:void 0,retry:r,retryAttempt:n})),(0,ag.O)(Et),(0,au.K)(e=>(console.error(e),(0,lQ.of)({isLoading:!1,result:void 0,error:e,retry:r,retryAttempt:n})))):(0,lQ.of)(En),[l,t,r,n],Et),o=mW(e._id,e._id);return o!==e._id?Et:a}var Er=Object.freeze,El=Object.defineProperty,Ea=(e,t)=>Er(El(e,"raw",{value:Er(t||e.slice())}));let Eo=(0,aW.ZP)(lY.kC)(ix||(ix=Ea(["\n /* this is a hack to avoid layout jumps while previews are loading\n or the message is not tall enough to fill the card\n there's probably better ways of solving this */\n min-height: 36px;\n"]))),Es=(0,aW.ZP)(lY.kC)(iv||(iv=Ea(["\n /* This limits the width of the tooltip content */\n max-width: 250px;\n"])));function Ed(e){return(0,lU.jsx)(Es,{padding:3,children:(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{as:"p",size:1,children:e.children})})})})}function Ec(e){var t,n,i;let{refType:r,showStudioUrlIcon:l,hasStudioUrl:a,showTypeLabel:o,availability:s,preview:d,id:c,dataset:u,projectId:p}=e,h=(null==s?void 0:s.reason)==="NOT_FOUND",f=(null==s?void 0:s.reason)==="PERMISSION_DENIED",m=null==(t=d.published)?void 0:t.media,g=(0,lK.useMemo)(()=>
1{if(m){let e=void 0!==(null==m?void 0:m.asset)&&(0,o2.JZ)(m),t=lK.isValidElement(m);return e||t?function(e){let{dimensions:n}=e;return t?m:(0,lU.jsx)("img",{src:o1()({dataset:u,projectId:p}).image(m).withOptions(n).url(),alt:"Image preview of referenced document",referrerPolicy:"strict-origin-when-cross-origin"})}:null}return(null==r?void 0:r.icon)?(0,lK.createElement)(r.icon):null},[m,u,p,null==r?void 0:r.icon]);return(0,lU.jsxs)(Eo,{align:"center",justify:"center",flex:1,"data-testid":"preview",children:[(null==s?void 0:s.available)?(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(uX,{title:null==(n=d.published)?void 0:n.title,subtitle:null==(i=d.published)?void 0:i.subtitle,media:g||!1})}):(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.kC,{align:"center",children:(0,lU.jsx)(lY.xu,{flex:1,paddingY:2,children:(0,lU.jsx)(lY.xv,{muted:!0,children:"Document unavailable"})})})}),(0,lU.jsx)(lY.xu,{paddingLeft:3,children:(0,lU.jsxs)(lY.gF,{space:4,children:[r&&o&&(0,lU.jsx)(lY.__,{size:1,muted:!0,children:r.title||r.type}),(f||h)&&(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:h?(0,lU.jsxs)(Ed,{children:["The referenced document no longer exist and might have been deleted.",(0,lU.jsx)("br",{}),"(id: ",(0,lU.jsx)("code",{children:c}),")"]}):(0,lU.jsx)(Ed,{children:"The referenced document could not be accessed due to insufficient permissions"}),children:(0,lU.jsx)(pG,{tone:"default",children:f?(0,lU.jsx)(a0.vaB,{}):(0,lU.jsx)(a0.BHU,{})})})}),!(h||f)&&l&&(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsx)(Es,{padding:2,children:a?(0,lU.jsx)(lY.xv,{size:1,children:"This document opens in a new tab"}):(0,lU.jsxs)(lY.xv,{size:1,children:["This document cannot be opened ",(0,lU.jsx)("br",{})," (unable to resolve URL to Studio)"]})}),children:(0,lU.jsx)(pG,{size:1,tone:"default",muted:!a,children:(0,lU.jsx)(a0.buG,{})})})})]})})]})}function Eu(){let e=Ni(fC);return e.config().projectId}function Ep(e){var t;let{isLoading:n,result:i,error:r}=Ei(e.document,e.getReferenceInfo),l=Eu();if(n)return(0,lU.jsxs)(lY.Kq,{space:2,padding:1,children:[(0,lU.jsx)(lY.Qr,{style:{maxWidth:320},radius:1,animated:!0}),(0,lU.jsx)(lY.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!0})]});if(r)return(0,lU.jsx)(lY.Kq,{space:2,padding:1,children:(0,lU.jsxs)(mH,{title:"Failed to load referenced document",children:["Error: ",r.message]})});if(!i)return null;if((null==(t=i.availability)?void 0:t.reason)==="PERMISSION_DENIED")return(0,lU.jsx)(lY.Kq,{space:2,padding:1,children:"Insufficient permissions to view this document"});let a=e.referenceType.to.find(e=>e.type===i.type);return a?i&&a&&(0,lU.jsx)(Ec,{id:i.id,availability:i.availability,preview:i.preview,refType:a,dataset:e.referenceType.dataset,projectId:l,showTypeLabel:e.referenceType.to.length>1}):(0,lU.jsxs)(lY.Kq,{space:2,padding:1,children:["Search returned a type that's not valid for this reference: \"$",i.type,'"']})}function Eh(e){var t,n;let{value:i,type:r,showStudioUrlIcon:l,hasStudioUrl:a,referenceInfo:o}=e,s=Eu();if(o.isLoading||o.error)return(0,lU.jsxs)(lY.Kq,{space:2,padding:1,children:[(0,lU.jsx)(lY.Qr,{style:{maxWidth:320},radius:1,animated:!o.error}),(0,lU.jsx)(lY.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!o.error})]});let d=r.to.length>1,c=null==(t=o.result)?void 0:t.type,u=r.to.find(e=>e.type===c);return(null==(n=o.result.availability)?void 0:n.available)&&!u?(0,lU.jsx)(lY.Kq,{space:2,padding:2,children:(0,lU.jsxs)(lY.xv,{as:"p",children:["The referenced document is of invalid type: (",c||"unknown",")",(0,lU.jsx)("pre",{children:JSON.stringify(i,null,2)})]})}):(0,lU.jsx)(Ec,{availability:o.result.availability,hasStudioUrl:a,showStudioUrlIcon:l,preview:o.result.preview,refType:u,projectId:s,dataset:r.dataset,id:i._ref,showTypeLabel:d})}var Ef=Object.freeze,Em=Object.defineProperty,Eg=(e,t)=>Ef(Em(e,"raw",{value:Ef(t||e.slice())}));let Ex=(0,aW.ZP)(lY.J2)(ib||(ib=Eg(["\n & > div {\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n"]))),Ev=(0,aW.ZP)(lY.xv)(iy||(iy=Eg(["\n word-break: break-word;\n"]))),Eb=(0,lK.forwardRef)(function(e,t){let n=e.options&&e.options.length>0,i=(0,lK.useCallback)((t,i)=>{let{content:r,hidden:l,inputElement:a,onMouseEnter:o,onMouseLeave:s}=t;return(0,lU.jsx)(Ex,{"data-testid":"autocomplete-popover",placement:"bottom-start",arrow:!1,constrainSize:!0,onMouseEnter:o,onMouseLeave:s,content:(0,lU.jsx)("div",{ref:i,children:n?r:(0,lU.jsx)(lY.xu,{padding:4,children:(0,lU.jsx)(lY.kC,{align:"center",height:"fill",justify:"center",children:(0,lU.jsxs)(Ev,{align:"center",muted:!0,children:["No results for ",(0,lU.jsxs)("strong",{children:["â",e.searchString,"â"]})]})})})}),open:!e.loading&&!l,ref:e.portalRef,portal:!0,referenceElement:e.referenceElement||a,matchReferenceWidth:!0})},[n,e.searchString,e.loading,e.portalRef,e.referenceElement]);return(0,lU.jsx)(lY.F2,{...e,ref:t,renderPopover:i})});var Ey=Object.freeze,Ej=Object.defineProperty;let Ew=(0,aW.ZP)(lY.zx)(ij||(ij=Ey(Ej(B=["\n width: 100%;\n"],"raw",{value:Ey(B.slice())}))));function Ek(e){let{value:t,onClearValue:n}=e,i=(0,lK.useMemo)(()=>!!(null==t?void 0:t._ref),[null==t?void 0:t._ref]);return(0,lU.jsxs)(lY.Zb,{tone:"caution",padding:4,border:!0,radius:2,"data-testid":"alert-cross-dataset-reference-feature-disabled",children:[(0,lU.jsxs)(lY.kC,{gap:4,marginBottom:i?4:void 0,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{as:"h2",size:1,weight:"semibold",children:"Unavailable feature: Cross dataset reference"}),i&&(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",size:1,children:["This feature has been disabled. Read how to enable it in"," ",(0,lU.jsx)("a",{href:"https://www.sanity.io/docs/cross-dataset-references",target:"_blank",rel:"noreferrer",children:"documentation"})]}),(0,lU.jsx)(lY.xv,{as:"p",size:1,children:"You can still clear this field's existing reference, but that cannot be revoked as long as the feature is disabled."})]}),!i&&(0,lU.jsxs)(lY.xv,{as:"p",size:1,children:["Read how to enable it in"," ",(0,lU.jsx)("a",{href:"https://www.sanity.io/docs/cross-dataset-references",target:"_blank",rel:"noreferrer",children:"documentation"})]})]})]}),n&&i&&(0,lU.jsx)(Ew,{icon:a0.X5P,text:"Reset value",onClick:n,mode:"ghost"})]})}let EC={isLoading:!0,enabled:!0,features:[]},E_={hits:[],isLoading:!1},ES=()=>!0,ET=["_ref"];function EE(e){var t,n,r;
1let{changed:l,focused:a,focusPath:o,getReferenceInfo:s,onChange:d,onPathFocus:c,onSearch:u,path:p,readOnly:h,schemaType:f,validation:m,value:g,elementProps:x}=e,v=Eu(),[b,y]=(0,lK.useState)(E_),j=(0,lK.useCallback)(e=>{if(!e){d(mD()),c([]);return}let t=b.hits.find(t=>t.id===e);if(!t)throw Error("Selected an item that wasnt part of the result set");d(mF({_type:f.name,_ref:ci(e),_projectId:v,_dataset:f.dataset,_weak:f.weak,_key:null==g?void 0:g._key})),c([])},[null==g?void 0:g._key,b.hits,f.name,f.dataset,f.weak,v,d,c]),w=(0,lK.useCallback)(()=>{d(mD())},[d]),k=(0,lK.useCallback)(e=>{27===e.keyCode&&(null==c||c([]))},[c]),C=(0,lK.useCallback)(e=>s(e,f),[s,f]),_=(0,lK.useMemo)(()=>({_id:null==g?void 0:g._ref}),[null==g?void 0:g._ref]),S=Ei(_,C),T=function(e){let t=Ni(fC);i||(i=(function(e){let{versionedClient:t}=e;return t.observable.request({uri:"/features",tag:"features"})})({versionedClient:t}).pipe((0,am.d)()));let n=(0,lJ.m2)(()=>i.pipe((0,ad.U)(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{isLoading:!1,enabled:!!(null==t?void 0:t.includes(e)),features:t}}),(0,ag.O)(EC),(0,au.K)(e=>(console.error(e),(0,lQ.of)({isLoading:!1,enabled:!0,features:[]})))),[e],EC);return n}("crossDatasetReferences"),E=(0,lK.useRef)(null),P=1===o.length&&"_ref"===o[0],A=x.ref;m$({hasFocusAt:P,ref:null==g?void 0:g._ref},(e,t)=>{var n;let i=(null==e?void 0:e.ref)!==t.ref,r=(null==e?void 0:e.hasFocusAt)!==t.hasFocusAt;(r||i)&&t.hasFocusAt&&(null==(n=A.current)||n.focus())});let O=(null==g?void 0:g._weak)?"weak":"strong",z=!0===f.weak?"weak":"strong",M=!!(null==g?void 0:g._ref),I=(0,lK.useCallback)(()=>{d(!0===f.weak?mF(!0,["_weak"]):mD(["_weak"]))},[d,f]),{push:R}=(0,lY.pm)(),F=(0,lK.useMemo)(()=>m.filter(e=>"error"===e.level),[m]),D=(0,lK.useCallback)(e=>{e.currentTarget===x.ref.current&&(null==c||c([lB.Zg]))},[x.ref,c]),Z=(0,lK.useCallback)(e=>{e.currentTarget===x.ref.current&&(null==c||c(ET))},[x.ref,c]),L=(0,lK.useCallback)(()=>{null==c||c(ET)},[c]),q=(0,lK.useId)(),N=(0,lJ.W2)(e=>e.pipe((0,af.h)(d9),(0,ac.x)(),(0,ap.w)(e=>(0,l0.z)((0,lQ.of)({isLoading:!0}),u(e).pipe((0,ad.U)(t=>({hits:t,searchString:e,isLoading:!1})),(0,au.K)(e=>(R({title:"Reference search failed",description:e.message,status:"error",id:"reference-search-fail-".concat(q)}),console.error(e),(0,lQ.of)({hits:[]})))))),(0,ah.R)((e,t)=>({...e,...t}),E_),(0,as.b)(y)),[q,u,R]),V=(0,lK.useCallback)(()=>{N("")},[N]),U=!S.isLoading&&M&&O!==z,B=(null==g?void 0:g._ref)&&(null==(n=f.studioUrl)?void 0:n.call(f,{id:null==g?void 0:g._ref,type:null==(t=null==S?void 0:S.result)?void 0:t.type}))||null,K=(0,lK.useCallback)(e=>(0,lU.jsx)(uM,{as:"button",type:"button",radius:2,children:(0,lU.jsx)(lY.xu,{paddingX:3,paddingY:1,children:(0,lU.jsx)(Ep,{referenceType:f,document:e.hit.published,getReferenceInfo:C})})}),[f,C]),H=null==(r=S.result)?void 0:r.preview.published,W=P||!(null==g?void 0:g._ref),$=(0,lK.useRef)(null),X=(0,lK.useRef)(null),G=(0,lK.useRef)(null);return mX([$,X,G],()=>{P&&c([])}),(0,lU.jsxs)(lU.Fragment,{children:[!T.isLoading&&!T.enabled&&(0,lU.jsx)(Ek,{value:g,onClearValue:w}),(T.isLoading||T.enabled)&&(0,lU.jsx)(lY.Kq,{space:1,children:W?(0,lU.jsx)(lY.Kq,{space:2,ref:$,children:(0,lU.jsx)(cD,{path:p,isChanged:l,hasFocus:!!a,children:(0,lU.jsx)("div",{ref:E,children:(0,lU.jsx)(Eb,{...x,"data-testid":"autocomplete",loading:b.isLoading,referenceElement:E.current,portalRef:X,id:q||"",options:b.hits.map(e=>({value:e.id,hit:e})),onFocus:Z,radius:1,placeholder:"Type to search",onKeyDown:k,readOnly:h,disabled:S.isLoading,onQueryChange:N,searchString:b.searchString,onChange:j,filterOption:ES,renderOption:K,openButton:{onClick:V}})})})}):(0,lU.jsx)(cD,{path:p,isChanged:l,hasFocus:!!a,children:(0,lU.jsxs)(lY.Zb,{padding:0,border:!0,flex:1,radius:1,tone:h?"transparent":S.error||F.length>0?"critical":"default",children:[(0,lU.jsxs)(lY.kC,{align:"center",padding:1,children:[B?(0,lU.jsx)(uM,{as:"a",target:"_blank",rel:"noopener noreferrer",href:B,"data-as":"a",flex:1,padding:1,paddingRight:3,radius:2,tone:"inherit",__unstable_focusRing:!0,tabIndex:0,onFocus:D,ref:x.ref,children:(0,lU.jsx)(Eh,{value:g,referenceInfo:S,showStudioUrlIcon:!0,hasStudioUrl:!!B,type:f})}):(0,lU.jsx)(uM,{flex:1,padding:1,paddingRight:3,radius:2,tone:"inherit",__unstable_focusRing:!0,tabIndex:0,onFocus:D,ref:x.ref,children:(0,lU.jsx)(Eh,{value:g,referenceInfo:S,showStudioUrlIcon:!0,type:f})}),(0,lU.jsx)(lY.gF,{paddingX:1,children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg,"data-testid":"menu-button"}),id:"".concat(q,"-menuButton"),menu:(0,lU.jsx)(lY.v2,{children:!h&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.sN,{text:"Clear",tone:"critical",icon:a0.X5P,"data-testid":"menu-item-clear",onClick:w}),(0,lU.jsx)(lY.sN,{text:"Replace",icon:a0.bnu,"data-testid":"menu-item-replace",onClick:L})]})}),placement:"right",popover:{portal:!0,tone:"default"}})})]}),U&&(0,lU.jsx)(wi,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,lU.jsx)("em",{children:O}),", but according to the current schema it should be ",(0,lU.jsxs)("em",{children:[z,"."]})]}),(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:f.weak?(0,lU.jsxs)(lU.Fragment,{children:['It will not be possible to delete the "',null==H?void 0:H.title,'"-document without first removing this reference.']}):(0,lU.jsxs)(lU.Fragment,{children:['This makes it possible to delete the "',null==H?void 0:H.title,'"-document without first deleting this reference, leav
1ing this field referencing a nonexisting document.']})}),(0,lU.jsx)(lY.zx,{onClick:I,text:(0,lU.jsxs)(lU.Fragment,{children:["Convert to ",z," reference"]}),tone:"caution"})]})}),S.error&&(0,lU.jsx)(wi,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["Error: ",S.error.message]}),(0,lU.jsx)(lY.zx,{onClick:S.retry,text:(0,lU.jsx)(lU.Fragment,{children:"Retry"}),tone:"primary"})]})})]})})})]})}let EP={available:!0,reason:"READABLE"},EA={available:!1,reason:"PERMISSION_DENIED"},EO={available:!1,reason:"NOT_FOUND"};async function Ez(e,t,n,i){if(!e)return{};if("function"==typeof e.filter){let r=n.slice(0,-1),l=(0,lB.U2)(t,r),a=await e.filter({document:t,parentPath:r,parent:l,getClient:i});return a}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}async function EM(e,t,n,i){if(!e)return{};if("function"==typeof e.filter){let r=n.slice(0,-1),l=lB.U2(t,r);return e.filter({document:t,parentPath:r,parent:l,getClient:i})}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}function EI(e){var t,n,i,r;let{path:l,schemaType:a}=e,o=Iw(),s=o.getClient(fC),d=Nu(),c=UY(),u=(0,lK.useMemo)(()=>s.withConfig({apiVersion:"2021-03-25"}),[s]),{EditReferenceLinkComponent:p,onEditReference:h,activePath:f,initialValueTemplateItems:m}=yc(),g=ke([]),x=function(e){let t=(0,lK.useRef)(e);return t.current=e,t}(g),v=null==(t=x.current)?void 0:t._type,b=(0,lK.useMemo)(()=>{var e;return null==(e=d.get(v))?void 0:e.liveEdit},[v,d]),y=(null==(n=a.options)?void 0:n.disableNew)===!0,j=o.getClient,w=(0,lK.useCallback)(e=>(0,at.D)(EM(a.options,x.current,l,j)).pipe((0,ay.z)(t=>{let{filter:n,params:i}=t;return mO(u,e,a,{...a.options,filter:n,params:i,tag:"search.reference"})}),(0,au.K)(e=>{var t;let n=e.details&&"queryParseError"===e.details.type;return(null==(t=a.options)?void 0:t.filter)&&n&&(e.message='Invalid reference filter, please check the custom "filter" option'),(0,l5._)(e)})),[x,l,u,a,j]),k=null==(r=null==(i=e.value)?void 0:i._strengthenOnPublish)?void 0:r.template,C=(0,lK.useMemo)(()=>(0,lK.forwardRef)(function(e,t){return p?(0,lU.jsx)(p,{...e,ref:t,parentRefPath:l,template:k}):null}),[p,l,k]),_=(0,lK.useCallback)(e=>{null==h||h({parentRefPath:l,id:e.id,type:e.type,template:e.template})},[h,l]),S=lB.Ny(l,(null==f?void 0:f.path)||[])?null==f?void 0:f.state:"none",T=(0,lK.useMemo)(()=>y?[]:(m||[]).filter(e=>a.to.some(t=>{var n;return t.name===(null==(n=e.template)?void 0:n.schemaType)})).map(e=>{var t;return(null==(t=e.template)?void 0:t.schemaType)?{id:e.id,title:e.title||"".concat(e.template.schemaType," from template ").concat(e.template.id),type:e.template.schemaType,icon:e.icon,template:{id:e.template.id,params:e.parameters},permission:{granted:e.granted,reason:e.reason}}:void 0}).filter(d9),[y,m,a.to]),E=(0,lK.useCallback)(e=>mA(c,e,a),[c,a]);return{selectedState:S,handleSearch:w,isCurrentDocumentLiveEdit:b,handleEditReference:_,EditReferenceLink:C,createOptions:T,getReferenceInfo:E}}function ER(e){let{getReferenceInfo:t,id:n,renderPreview:i}=e,{isLoading:r,result:l,error:a}=wu(n,t);if(r)return(0,lU.jsxs)(lY.Kq,{space:2,padding:1,children:[(0,lU.jsx)(lY.Qr,{style:{maxWidth:320},radius:1,animated:!0}),(0,lU.jsx)(lY.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!0})]});if(a)return(0,lU.jsx)(lY.Kq,{space:2,padding:1,children:(0,lU.jsx)(mH,{title:"Failed to load referenced document",children:(0,lU.jsxs)(lY.xv,{muted:!0,size:1,children:["Error: ",a.message]})})});if(!l)return null;if("PERMISSION_DENIED"===l.availability.reason)return(0,lU.jsx)(lY.Kq,{space:2,padding:1,children:"Insufficient permissions to view this document"});let o=e.type.to.find(e=>e.name===l.type);return o?l&&o&&(0,lU.jsx)(wh,{id:l.id,layout:"default",preview:l.preview,refType:o,renderPreview:i,showTypeLabel:e.type.to.length>1}):(0,lU.jsxs)(lY.Kq,{space:2,padding:1,children:["Search returned a type that's not valid for this reference: \"$",l.type,'"']})}let EF={display:"inline-flex"},ED={width:"100%"},EZ={portal:!0,tone:"default",constrainSize:!0,fallbackPlacements:["bottom","left","top"],placement:"right",preventOverflow:!0};function EL(e){let{createOptions:t,onCreate:n,id:i,...r}=e,l=t.some(e=>e.permission.granted);return l?t.length>1?(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{...r,disabled:e.readOnly,text:"Create newâ¦",mode:"ghost",icon:a0.dtP}),id:i,menu:(0,lU.jsx)(lY.v2,{ref:e.menuRef,children:t.map(e=>(0,lU.jsx)(lY.u,{disabled:e.permission.granted,content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(ub,{operationLabel:"create this type of document"})}),portal:!0,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.sN,{disabled:!e.permission.granted,icon:e.icon,text:e.title,onClick:()=>n(e)})})},e.id))}),popover:EZ}):(0,lU.jsx)(lY.zx,{...r,text:"Create new",mode:"ghost",disabled:!t[0].permission.granted||e.readOnly,onClick:()=>n(t[0]),icon:a0.dtP}):(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(ub,{operationLabel:"create a new reference"})}),children:(0,lU.jsx)("div",{style:EF,children:(0,lU.jsx)(lY.zx,{text:"Create new",mode:"ghost",disabled:!0,icon:a0.dtP,style:ED})})})}var Eq=Object.freeze,EN=Object.defineProperty,EV=(e,t)=>Eq(EN(e,"raw",{value:Eq(t||e.slice())}));let EU=(0,aW.ZP)(lY.J2)(iw||(iw=EV(["\n & > div {\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n"]))),EB=(0,aW.ZP)(lY.xv)(ik||(ik=EV(["\n word-break: break-word;\n"]))),EK=(0,lK.forwardRef)(function(e,t){let n=e.options&&e.options.length>0,i=(0,lK.useCallback)((t,i)=>{var r;let{content:l,hidden:a,inputElement:o,onMouseEnter:s,onMouseLeave:d}=t;return(0,lU.jsx)(EU,{placement:"bottom-start",arrow:!1,constrainSize:!0,onMouseEnter:s,onMouseLeave:d,c
1ontent:(0,lU.jsx)("div",{ref:i,children:n?l:(0,lU.jsx)(lY.xu,{padding:4,children:(0,lU.jsx)(lY.kC,{align:"center",height:"fill",justify:"center",children:(0,lU.jsxs)(EB,{align:"center",muted:!0,children:["No results for ",(0,lU.jsxs)("strong",{children:["â",e.searchString,"â"]}),(null==(r=e.searchString)?void 0:r.toLowerCase())==="capybara"?(0,lU.jsx)(lU.Fragment,{children:". What a shame. There should be more Capybaras."}):null]})})})}),open:!e.loading&&!a,ref:e.portalRef,portal:!0,referenceElement:e.referenceElement||o,matchReferenceWidth:!0})},[n,e.searchString,e.loading,e.portalRef,e.referenceElement]);return(0,lU.jsx)(lY.F2,{...e,ref:t,renderPopover:i})});var EH=Object.freeze,EW=Object.defineProperty,E$=(e,t)=>EH(EW(e,"raw",{value:EH(t||e.slice())}));let EX=(0,aW.iv)(iC||(iC=E$(["\n grid-template-columns: minmax(0px, 1fr);\n"]))),EG=(0,aW.iv)(i_||(i_=E$(["\n grid-template-columns: 1fr min-content;\n"]))),EY=(0,aW.ZP)(lY.rj)(e=>e.$narrow?EX:EG),EJ=(0,lK.forwardRef)(function(e,t){let[n,i]=(0,lK.useState)(null),r=(0,lK.useCallback)(e=>{"function"==typeof t?t(e):t&&(t.current=e),i(e)},[t]),l=(0,lY.XL)(n);return(0,lU.jsx)(EY,{ref:r,gap:1,$narrow:480>((null==l?void 0:l.width)||0),children:e.children})});var EQ=Object.freeze,E0=Object.defineProperty;let E1=(0,aW.ZP)(uM)(iS||(iS=EQ(E0(K=["\n /* this is a hack to avoid layout jumps while previews are loading\n there's probably better ways of solving this */\n min-height: 36px;\n"],"raw",{value:EQ(K.slice())})))),E2={hits:[],isLoading:!1},E3=()=>!0;function E4(e){return null!==e}function E5(e){var t,n,i,r,l,a;let{createOptions:o,onChange:s,onEditReference:d,onSearch:c,schemaType:u,readOnly:p,id:h,onPathFocus:f,value:m,renderPreview:g,path:x,elementProps:v,focusPath:b}=e,{getReferenceInfo:y}=EI({path:x,schemaType:u,value:m}),[j,w]=(0,lK.useState)(E2),k=(0,lK.useCallback)(e=>{let t=(0,sh.Z)(),n=[mI({}),mF(u.name,["_type"]),mF(t,["_ref"]),mF(!0,["_weak"]),mF({type:e.type,weak:u.weak,template:e.template},["_strengthenOnPublish"])].filter(d9);s(n),d({id:t,type:e.type,template:e.template}),f([])},[s,d,f,u]),C=(0,lK.useCallback)(e=>{if(!e){s(mD()),f([]);return}let t=j.hits.find(t=>t.id===e);if(!t)throw Error("Selected an item that wasnt part of the result set");let n=[mI({}),mF(u.name,["_type"]),mF(ci(e),["_ref"]),t.published&&!u.weak?mD(["_weak"]):mF(!0,["_weak"]),t.published?mD(["_strengthenOnPublish"]):mF({type:null==t?void 0:t.type,weak:u.weak},["_strengthenOnPublish"])].filter(d9);s(n),f([])},[s,f,u.name,u.weak,j.hits]),_=(0,lK.useCallback)(()=>{s(mD())},[s]),S=(0,lK.useCallback)(()=>{(null==m?void 0:m._ref)||_()},[_,null==m?void 0:m._ref]),T=(0,lK.useCallback)(e=>{"Escape"===e.key&&f([])},[f]),E=wu(null==m?void 0:m._ref,y),P=(0,lK.useRef)(null),{push:A}=(0,lY.pm)(),O=(0,lJ.W2)(e=>e.pipe((0,af.h)(E4),(0,ap.w)(e=>(0,l0.z)((0,lQ.of)({isLoading:!0}),c(e).pipe((0,ad.U)(t=>({hits:t,searchString:e,isLoading:!1})),(0,au.K)(e=>(A({title:"Reference search failed",description:e.message,status:"error",id:"reference-search-fail-".concat(h)}),console.error(e),(0,lQ.of)({hits:[]})))))),(0,ah.R)((e,t)=>({...e,...t}),E2),(0,as.b)(w)),[h,c,A]),z=(0,lK.useCallback)(()=>{O("")},[O]),M=(0,lK.useCallback)(e=>{"Escape"===e.key&&f([])},[f]),I=(0,lK.useCallback)(e=>{var t,n;let i=(null==(t=e.hit.draft)?void 0:t._id)||(null==(n=e.hit.published)?void 0:n._id)||e.value;return(0,lU.jsx)(E1,{forwardedAs:"button",type:"button",radius:2,tone:"inherit",children:(0,lU.jsx)(lY.xu,{paddingX:3,paddingY:1,children:(0,lU.jsx)(ER,{getReferenceInfo:y,id:i,renderPreview:g,type:u})})})},[u,y,g]),R=(0,lK.useCallback)(()=>{var e,t,n,i;return(null==(t=null==(e=E.result)?void 0:e.preview.draft)?void 0:t.title)||(null==(i=null==(n=E.result)?void 0:n.preview.published)?void 0:i.title)||""},[null==(n=null==(t=E.result)?void 0:t.preview.draft)?void 0:n.title,null==(r=null==(i=E.result)?void 0:i.preview.published)?void 0:r.title]),F=(0,lK.useCallback)(()=>f(["_ref"]),[f]),D=(0,lK.useCallback)(t=>{var n;(null==(n=P.current)?void 0:n.contains(t.relatedTarget))||e.elementProps.onBlur(t)},[e.elementProps]),Z=(null==(a=null==(l=null==E?void 0:E.result)?void 0:l.availability)?void 0:a.reason)==="NOT_FOUND"&&!(null==m?void 0:m._strengthenOnPublish)&&(null==m?void 0:m._weak);m$((null==b?void 0:b[0])==="_ref",(e,t)=>{var n;!e&&t&&(null==(n=v.ref.current)||n.focus())});let L=(0,lK.useMemo)(()=>j.hits.map(e=>({value:e.id,hit:e})),[j.hits]),q=1===b.length&&"_ref"===b[0],{menuRef:N,containerRef:V}=function(){let e=(0,lK.useContext)(ww);return e||{menuRef:{current:null},containerRef:{current:null}}}(),U=(0,lK.useRef)(null),B=(0,lK.useRef)(null),K=(0,lK.useRef)(null);return mX([V,U,B,K,N],()=>{q&&S()}),(0,lU.jsx)(lY.Kq,{space:1,"data-testid":"reference-input",ref:U,children:(0,lU.jsxs)(lY.Kq,{space:2,children:[Z?(0,lU.jsx)(mH,{"data-testid":"alert-nonexistent-document",title:"Nonexistent document reference",suffix:(0,lU.jsx)(lY.Kq,{padding:2,children:(0,lU.jsx)(lY.zx,{text:"Clear",onClick:_})}),children:(0,lU.jsxs)(lY.xv,{size:1,children:["This field is currently referencing a document that doesn't exist (ID:",(0,lU.jsx)("code",{children:m._ref}),"). You can either remove the reference or replace it with another document."]})}):null,(0,lU.jsxs)(EJ,{ref:P,children:[(0,lU.jsx)(EK,{...v,onFocus:
1F,onBlur:D,"data-testid":"autocomplete",loading:j.isLoading,referenceElement:P.current,options:L,radius:1,placeholder:"Type to search",onKeyDown:T,readOnly:E.isLoading||p,onQueryChange:O,searchString:j.searchString,onChange:C,filterOption:E3,renderOption:I,renderValue:R,openButton:{onClick:z},portalRef:B,value:null==m?void 0:m._ref}),o.length>0&&(0,lU.jsx)(EL,{id:"".concat(h,"-selectTypeMenuButton"),readOnly:p,createOptions:o,onCreate:k,onKeyDown:M,menuRef:K})]})]})})}async function E6(e,t,n,i){if(!e)return{};if("function"==typeof e.filter){let r=n.slice(0,-1),l=(0,lB.U2)(t,r),a=await e.filter({document:t,parentPath:r,parent:l,getClient:i});return a}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}function E8(e){var t,n,i,r;let l=Iw(),a=l.getClient(fC),o=Nu(),s=UY(),{path:d,schemaType:c}=e,{EditReferenceLinkComponent:u,onEditReference:p,activePath:h,initialValueTemplateItems:f}=yc(),m=ke([]),g=function(e){let t=(0,lK.useRef)(e);return t.current=e,t}(m),x=null==(t=g.current)?void 0:t._type,v=o.get(x),b=(0,lK.useMemo)(()=>null==v?void 0:v.liveEdit,[v]),y=(null==(n=c.options)?void 0:n.disableNew)===!0,j=l.getClient,w=(0,lK.useCallback)(e=>(0,at.D)(E6(c.options,g.current,d,j)).pipe((0,ay.z)(t=>{let{filter:n,params:i}=t;return mO(a,e,c,{...c.options,filter:n,params:i,tag:"search.reference"})}),(0,au.K)(e=>{var t;let n=e.details&&"queryParseError"===e.details.type;return(null==(t=c.options)?void 0:t.filter)&&n&&(e.message='Invalid reference filter, please check the custom "filter" option'),(0,l5._)(e)})),[g,d,a,c,j]),k=null==(r=null==(i=e.value)?void 0:i._strengthenOnPublish)?void 0:r.template,C=(0,lK.useMemo)(()=>(0,lK.forwardRef)(function(e,t){return u?(0,lU.jsx)(u,{...e,ref:t,parentRefPath:d,template:k}):null}),[u,d,k]),_=(0,lK.useCallback)(e=>{null==p||p({parentRefPath:d,id:e.id,type:e.type,template:e.template})},[p,d]),S=lB.Ny(d,(null==h?void 0:h.path)||[])?null==h?void 0:h.state:"none",T=(0,lK.useMemo)(()=>y?[]:(f||[]).filter(e=>c.to.some(t=>{var n;return t.name===(null==(n=e.template)?void 0:n.schemaType)})).map(e=>{var t,n,i;return(null==(t=e.template)?void 0:t.schemaType)?{id:e.id,title:e.title||"".concat(e.template.schemaType," from template ").concat(null==(n=e.template)?void 0:n.id),type:e.template.schemaType,icon:e.icon,template:{id:null==(i=e.template)?void 0:i.id,params:e.parameters},permission:{granted:e.granted,reason:e.reason}}:void 0}).filter(d9),[y,f,c.to]),E=(0,lK.useCallback)((e,t)=>mA(s,e,t),[s]);return(0,lU.jsx)(E5,{...e,onSearch:w,liveEdit:b,getReferenceInfo:E,selectedState:S,editReferenceLinkComponent:C,createOptions:T,onEditReference:_})}function E9(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("object"!=typeof e&&!Array.isArray(e))return e===t;if(e._key&&e._key===t._key)return!0;if(Array.isArray(e))return!e.length===t.length&&e.every((n,i)=>E9(e[i],t[i]));let n=Object.keys(e),i=Object.keys(e);return n.length===i.length&&n.every(n=>E9(e[n],t[n]))}function E7(e,t){return!!e&&e.some(e=>E9(e,t))}let Pe=[];function Pt(e){var t,n;let{renderPreview:i,schemaType:r,onChange:l,onPathFocus:a,value:o=[],readOnly:s,elementProps:d,path:c,changed:u}=e,p=(0,lK.useMemo)(()=>{var e;return((null==(e=r.options)?void 0:e.list)||Pe).map((e,t)=>(0,lV.fU)(e)?e:{...e,_key:"auto-generated-".concat(t)})},[null==(t=r.options)?void 0:t.list]),h=(0,lK.useCallback)((e,t)=>{if(!e&&(0,lV.fU)(t)){l(mD([{_key:t._key}]));return}let n=p.filter(n=>E9(t,n)?e:E7(o,n));l(n.length>0?mF(n):mD())},[l,p,o]),f=(0,lK.useCallback)(e=>{a([e])},[a]),m=(null==(n=r.options)?void 0:n.layout)==="grid";return(0,lU.jsx)(cD,{path:c,isChanged:u,hasFocus:!1,children:(0,lU.jsx)(lY.rj,{gap:2,columns:m?Math.min(p.length,4):1,tabIndex:0,...d,children:p.map((e,t)=>{let n=r.of.find(t=>t.name===(0,sy.wq)(e)),l=E7(o,e),a=!n;return(0,lU.jsxs)(lY.kC,{align:"center",as:"label",muted:a,children:[(0,lU.jsx)(lY.XZ,{disabled:a,checked:l,onChange:t=>h(t.currentTarget.checked,e),onFocus:()=>f(t),readOnly:s}),(0,lU.jsx)(lY.xu,{flex:1,marginLeft:2,children:n?i({layout:"default",schemaType:n,value:e}):(0,lU.jsx)(lY.Zb,{tone:"caution",radius:2,children:(0,lU.jsx)(kA,{value:e,onFocus:()=>f(t)})})})]},t)})})})}var Pn=Object.freeze,Pi=Object.defineProperty;let Pr=(0,aW.ZP)(lY.Zb)(iT||(iT=Pn(Pi(H=["\n max-width: ","px;\n"],"raw",{value:Pn(H.slice())}))),e=>{let{theme:t}=e;return t.sanity.container[1]});
1function Pl(e){let{value:t,onFocus:n,vertical:i,...r}=e,[l,a]=lK.useState(!1),[o,s]=lK.useState(null);(0,lY.O8)(()=>a(!1),[o]);let d=lK.useCallback(e=>{("Escape"===e.key||"Tab"===e.key)&&a(!1)},[]),c=(0,lK.useCallback)(()=>{a(e=>!e)},[]),u=(0,sy.wq)(t);return(0,lU.jsx)(lY.J2,{open:l,ref:s,onKeyDown:d,portal:!0,constrainSize:!0,tone:"default",content:(0,lU.jsx)(Pr,{margin:1,padding:3,onKeyDown:d,tabIndex:0,overflow:"auto",children:(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{weight:"semibold",children:"Why is this happening?"})}),(0,lU.jsxs)(lY.xv,{size:1,children:["The current schema does not declare items of type ",(0,lU.jsx)("code",{children:u})," as valid for this list. This could mean that the type has been removed as a valid item type, or that someone else has added it to their own local schema that is not yet deployed."]}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsxs)(lY.xv,{size:1,children:[(0,lU.jsx)(a0.sLo,{})," You can still move or delete this item, but it cannot be edited since the schema definition for its type is nowhere to be found."]})}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,lU.jsx)(lY.Zb,{padding:2,overflow:"auto",border:!0,children:(0,lU.jsx)(lY.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,lU.jsx)(lY.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,flex:1,onFocus:n,onClick:c,onKeyDown:d,__unstable_focusRing:!0,...r,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{marginRight:3,children:(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.Tzq,{})})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsxs)(lY.xv,{size:1,textOverflow:"ellipsis",children:["Item of type ",(0,lU.jsx)("code",{children:u})," not valid for this list"]})})]})})})}function Pa(e){var t,n;let{schemaType:i,onChange:r,value:l=[],readOnly:a,path:o,changed:s,onIndexFocus:d,elementProps:c}=e,u=(0,lK.useMemo)(()=>{var e;return((null==(e=i.options)?void 0:e.list)||[]).map(e=>e&&"object"==typeof e&&"title"in e&&"value"in e?{title:e.title||ol()(String(e.value)),value:e.value}:{title:ol()(String(e)),value:e})},[null==(t=i.options)?void 0:t.list]),p=(e,t)=>{let n=u.map(e=>e.value).filter(n=>n===t?e:l.includes(n));r(n.length>0?mF(n):mD())},h=(null==(n=i.options)?void 0:n.layout)==="grid";return(0,lU.jsx)(cD,{path:o,isChanged:s,hasFocus:!1,children:(0,lU.jsx)(lY.rj,{gap:2,columns:h?Math.min(u.length,4):1,...c,children:u.map((e,t)=>{let n=i.of.find(t=>t.name===(0,sy.wq)(e.value)),r=l.includes(e.value),o=!n;return(0,lU.jsxs)(lY.kC,{align:"center",as:"label",muted:o,children:[(0,lU.jsx)(lY.XZ,{disabled:o,checked:r,onChange:t=>p(t.currentTarget.checked,e.value),onFocus:()=>d(t),readOnly:a}),(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{children:e.title})}),!n&&(0,lU.jsx)(Pl,{value:e,onFocus:()=>d(t)})]},t)})})})}function Po(e){return(0,lV.M1)(e.schemaType)?(0,lU.jsx)(Pt,{...e}):(0,lU.jsx)(Pa,{...e})}var Ps=Object.freeze,Pd=Object.defineProperty,Pc=(e,t)=>Ps(Pd(e,"raw",{value:Ps(t||e.slice())}));let Pu=aW.ZP.div(iE||(iE=Pc(["\n position: relative;\n"]))),Pp=aW.ZP.div(iP||(iP=Pc(["\n z-index: 13;\n opacity: 0;\n transition: opacity 300ms linear;\n"]))),Ph=(0,aW.ZP)(lY.Zb)(iA||(iA=Pc(["\n border: 1px solid var(--card-border-color);\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 12;\n transition: opacity 150ms ease-in-out;\n opacity: 0;\n box-sizing: border-box;\n"]))),Pf=(0,aW.ZP)(lY.kC)(iO||(iO=Pc(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n\n :hover,\n :focus {\n & "," {\n opacity: 0.9;\n }\n\n & "," {\n opacity: 1;\n }\n }\n"])),Ph,Pp),Pm=()=>"undefined"!=typeof window&&"ontouchstart"in window||"undefined"!=typeof navigator&&navigator.maxTouchPoints>0;function Pg(e){let{children:t,message:n,onActivate:i,isOverlayActive:r}=e,[l,a]=(0,lK.useState)(!1),o=(0,lK.useCallback)(()=>{i&&i()},[i]),s=(0,lK.useCallback)(e=>{r&&"Space"===e.code&&i&&(e.preventDefault(),i())},[r,i]),d=(0,lK.useCallback)(()=>{a(!0)},[]),c=(0,lK.useCallback)(()=>{a(!1)},[]),u=(0,lK.useMemo)(()=>{let e=Pm(),t=e?"Tap":"Click";l&&!e&&(t+=" or press space");let i=n||"".concat(t," to activate");return(0,lU.jsx)(lY.xv,{weight:"semibold",children:i})},[l,n]);return(0,lU.jsxs)(Pu,{onBlur:c,onClick:o,onFocus:d,onKeyDown:s,children:[r&&(0,lU.jsxs)(Pf,{tabIndex:0,align:"center",justify:"center",children:[(0,lU.jsx)(Ph,{radius:1}),(0,lU.jsx)(Pp,{children:u})]}),t]})}var Px=Object.freeze,Pv=Object.defineProperty;let Pb=aW.ZP.span(iz||(iz=Px(Pv(W=["\n /* Make sure the annotation styling is visible */\n &[data-mark='code'] {\n mix-blend-mode: multiply;\n color: inherit;\n }\n"],"raw",{value:Px(W.slice())}))));function Py(e){let{value:t,focused:n,selected:i,children:r,schemaType:l}=e,a=C$[t],o=l.component,s=(0,lK.useCallback)(e=>(0,lU.jsx)(Pb,{as:a,"data-mark":t,children:e.children}),[a,t]);return(0,lK.useMemo)(()=>{let e={focused:n,renderDefault:s,schemaType:l,selected:i,title:l.title,value:t};return o?(0,lU.jsx)(o,{...e,children:r}):(0,lU.jsx)(s,{...e,children:r})},[o,s,r,n,l,i,t])}let Pj={portal:!0,constrainSize:!0};
1function Pw(e){let{disableRestoreFocusOnClose:t,menuButton:n,menuButtonProps:i,menuOptionsArray:r,onMenuClose:l}=e;return(0,lU.jsx)(lY.j2,{__unstable_disableRestoreFocusOnClose:t,id:"menu-button",onClose:l,popover:Pj,...i,button:n,menu:(0,lU.jsx)(lY.v2,{children:r.map((e,t)=>{let{collapsedProps:n={},expandedProps:i={},tooltipProps:r={},tooltipText:l,dividerBefore:a,fontSize:o,padding:s,text:d,icon:c,selected:u,...p}=e.props;return(0,lU.jsxs)(lK.Fragment,{children:[a&&0!==t&&(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.sN,{text:d,icon:c,pressed:u,...p})]},e.key)})})})}var Pk=Object.freeze,PC=Object.defineProperty;let P_=aW.ZP.div(iM||(iM=Pk(PC($=["\n border-right: 1px solid var(--card-border-color);\n height: auto;\n\n &[data-hidden] {\n opacity: 0;\n }\n"],"raw",{value:Pk($.slice())}))));function PS(e){let{hidden:t,...n}=e;return(0,lU.jsx)(P_,{"data-ui":"CollapseMenuDivider","data-hidden":t?"":void 0,...n})}var PT=Object.freeze,PE=Object.defineProperty,PP=(e,t)=>PT(PE(e,"raw",{value:PT(t||e.slice())}));let PA=(0,aW.iv)(iI||(iI=PP(["\n list-style: none;\n display: flex;\n white-space: nowrap;\n\n &[data-hidden='true'] {\n opacity: 0;\n visibility: hidden;\n }\n"]))),PO=(0,aW.ZP)(lY.kC)(iR||(iR=PP(["\n padding: ","px;\n margin: -","px;\n box-sizing: border-box;\n"])),3,3),Pz=(0,aW.ZP)(lY.kC)(iF||(iF=PP(["\n border-radius: inherit;\n position: relative;\n"]))),PM=(0,aW.ZP)(lY.kC)(iD||(iD=PP(["\n width: max-content;\n\n &[data-hidden='true'] {\n height: 0px;\n visibility: hidden;\n }\n"]))),PI=(0,aW.ZP)(function(e){let{callback:t,children:n,options:i,...r}=e,[l,a]=(0,lK.useState)(null);return(0,lK.useEffect)(()=>{if(!l)return;let e=new IntersectionObserver(t,i);return e.observe(l),()=>{e.unobserve(l),e.disconnect()}},[l,t,i]),(0,lU.jsx)(lY.kC,{ref:a,...r,children:n})})(iZ||(iZ=PP(["\n ","\n"])),PA),PR=(0,aW.ZP)(lY.kC)(iL||(iL=PP(["\n ","\n"])),PA);function PF(e){return!!e}let PD=(0,lK.forwardRef)(function(e,t){let{children:n,collapsed:i,collapseText:r=!0,disableRestoreFocusOnClose:l,gap:a,menuButtonProps:o,onMenuClose:s,...d}=e,[c,u]=(0,lK.useState)(null),[p,h]=(0,lK.useState)(null),f=(0,lY.XL)(c),[m,g]=(0,lK.useState)([]),x=(0,lK.useMemo)(()=>!!f&&!!c&&!!p&&f.width<p.scrollWidth,[p,c,f]),v=(0,lK.useMemo)(()=>(null==o?void 0:o.button)||(0,lU.jsx)(lY.zx,{icon:a0.zGg,mode:"bleed"}),[o]),b=(0,lK.useMemo)(()=>({root:c,threshold:1,rootMargin:"2px"}),[c]),y=(0,lK.useMemo)(()=>lK.Children.toArray(n).filter(PF),[n]),j=(0,lK.useMemo)(()=>y.filter(e=>{let{key:t}=e;return m.find(e=>e.key===t)}),[y,m]),w=(0,lK.useMemo)(()=>i||j.length>0,[i,j.length]),k=(0,lK.useCallback)(e=>j.some(t=>t.key===e),[j]),C=(0,lK.useCallback)((e,t)=>{let n=k(t.key);if(e.isIntersecting||n||g(e=>[t,...e]),e.isIntersecting&&n){let e=j.filter(e=>{let{key:n}=e;return n!==t.key});g(e)}},[k,j]),_=(0,lK.useMemo)(()=>y.map(e=>{let{collapsedProps:t,expandedProps:n}=e.props,i=x?t:n,l=x&&r?void 0:e.props.text;return(0,lK.cloneElement)(e,{...i,text:l})}),[y,r,x]);return i?(0,lU.jsx)(Pw,{disableRestoreFocusOnClose:l,menuButton:v,menuButtonProps:o,menuOptionsArray:y,onMenuClose:s}):(0,lU.jsxs)(PO,{align:"center","data-ui":"CollapseMenu",overflow:"hidden",sizing:"border",ref:t,...d,children:[(0,lU.jsxs)(Pz,{direction:"column",flex:1,justify:"center",ref:u,children:[(0,lU.jsx)(PM,{gap:a,children:_.map((e,t)=>{let{dividerBefore:n,tooltipText:i="",tooltipProps:r={}}=e.props,l=k(e.key);return(0,lU.jsxs)(lK.Fragment,{children:[n&&0!==t&&(0,lU.jsx)(PS,{hidden:l}),(0,lU.jsx)(PI,{options:b,callback:t=>C(t[0],e),"aria-hidden":l,"data-hidden":l,children:(0,lU.jsx)(lY.u,{portal:!0,disabled:!i,content:(0,lU.jsx)(lY.xu,{padding:2,sizing:"border",children:(0,lU.jsx)(lY.xv,{size:1,children:i})}),...r,children:(0,lU.jsx)(lY.kC,{children:(0,lK.cloneElement)(e,{disabled:e.props.disabled||l,"aria-hidden":l})})})})]},e.key)})}),(0,lU.jsx)(PM,{"data-hidden":!0,"aria-hidden":"true",gap:a,ref:h,children:y.map((e,t)=>{let{dividerBefore:n}=e.props;return(0,lU.jsxs)(lK.Fragment,{children:[n&&0!==t&&(0,lU.jsx)(PS,{}),(0,lU.jsx)(PR,{children:(0,lK.cloneElement)(e,{disabled:!0,"aria-hidden":!0})},e.key)]},e.key)})})]}),w&&(0,lU.jsx)(lY.kC,{marginLeft:a,children:(0,lU.jsx)(Pw,{disableRestoreFocusOnClose
1:l,menuButton:v,menuButtonProps:o,menuOptionsArray:j,onMenuClose:s})})]})}),PZ=(0,lK.forwardRef)(function(e,t){let{collapsedProps:n={},expandedProps:i={},tooltipProps:r={},tooltipText:l,dividerBefore:a,...o}=e;return(0,lU.jsx)(lY.zx,{"data-ui":"CollapseMenuButton",...o,ref:t})});var PL=Object.freeze,Pq=Object.defineProperty;let PN=aW.ZP.div(iq||(iq=PL(Pq(X=["\n width: 1em;\n height: 1em;\n border-radius: inherit;\n background-origin: content-box;\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n transform: scale(0.7);\n"],"raw",{value:PL(X.slice())}))));function PV(e){let{icon:t,active:n}=e,i=(0,lK.useMemo)(()=>({backgroundImage:"url(".concat(t,")"),filter:n?"invert(100%)":"invert(0%)"}),[n,t]);return(0,lU.jsx)(PN,{style:i})}function PU(e,t){let n=op()(e,"to[0].icon");return e.icon||e.type&&e.type.icon||n||t}let PB={link:a0.xPt},PK={strong:a0.mY4,em:a0.h32,"strike-through":a0.dwl,underline:a0.Adg,code:a0.dNJ},PH={number:a0.NvX,bullet:a0.AEM};function PW(){let e=(0,sj._F)(),t=(0,sj.L9)();return(0,lK.useMemo)(()=>sj.q$.focusBlock(e),[e,t])}let P$=(0,lK.memo)(PD),PX={constrainSize:!0,portal:!0},PG={padding:2,mode:"bleed"},PY=(0,lK.memo)(function(e){let{disabled:t,groups:n,isFullscreen:i,collapsed:r}=e,l=PW(),a=(0,sj._F)(),o=(null==l?void 0:l._type)!==a.schemaTypes.block.name,s=!o&&Array.isArray(l.children)&&1===l.children.length&&(null==l?void 0:l.children[0].text)==="",d=t||o,c=(0,lK.useMemo)(()=>n.reduce((e,t)=>e.concat(t.actions.map((e,t)=>0===t?{...e,firstInGroup:!0}:e)),[]),[n]),u=function(e){let{actions:t}=e,n=(0,sj._F)(),i=(0,sj.L9)();return d6((0,lK.useMemo)(()=>{let e=sj.q$.activeAnnotations(n).map(e=>e._type);return t.filter(t=>"annotation"===t.type?e.includes(t.key):"listStyle"===t.type?sj.q$.hasListStyle(n,t.key):sj.q$.isMarkActive(n,t.key)).map(e=>e.key)},[n,i]))}({actions:c}),p=(0,lK.useCallback)(()=>{sj.q$.focus(a)},[a]),h=(0,lK.useMemo)(()=>c.map(e=>{let t="annotation"===e.type&&s,n=u.includes(e.key);return(0,lK.createElement)(PZ,{disabled:d||t,...PG,dividerBefore:e.firstInGroup,icon:e.icon?"string"==typeof e.icon?(0,lU.jsx)(PV,{active:n,icon:e.icon}):e.icon:"annotation"===e.type?PB[e.key]||a0.Tzq:"listStyle"===e.type?PH[e.key]||a0.Tzq:PK[e.key]||a0.Tzq,key:e.key,onClick:()=>e.handle(n),selected:n,text:e.title||e.key,tooltipText:e.title||e.key,tooltipProps:{disabled:d||t,placement:i?"bottom":"top",portal:"default"}})}),[c,u,d,s,i]),f=(0,lK.useMemo)(()=>({button:(0,lU.jsx)(lY.zx,{icon:a0.zGg,mode:"bleed",padding:2,disabled:d}),popover:PX}),[d]);return(0,lU.jsx)(P$,{collapsed:r,disableRestoreFocusOnClose:!0,gap:1,menuButtonProps:f,onMenuClose:p,children:h})});var PJ=Object.freeze,PQ=Object.defineProperty,P0=(e,t)=>PJ(PQ(e,"raw",{value:PJ(t||e.slice())}));let P1=(0,lK.memo)(lY.j2),P2=(0,aW.ZP)(lY.sN)(iN||(iN=P0(["\n // Change the border color variable used by BlockQuote\n // to make the border visible when the MenuItem is selected\n &[data-selected] {\n [data-option='blockquote'] {\n --card-border-color: var(--card-muted-fg-color);\n }\n }\n"]))),P3=(0,aW.ZP)(lY.zx)(iV||(iV=P0(["\n width: 100%;\n"]))),P4={constrainSize:!0,placement:"bottom-start",portal:"default"},P5={h1:e=>(0,lU.jsx)(_r,{children:e}),h2:e=>(0,lU.jsx)(_l,{children:e}),h3:e=>(0,lU.jsx)(_a,{children:e}),h4:e=>(0,lU.jsx)(_o,{children:e}),h5:e=>(0,lU.jsx)(_s,{children:e}),h6:e=>(0,lU.jsx)(_d,{children:e}),normal:e=>(0,lU.jsx)(_i,{children:e}),blockquote:e=>(0,lU.jsx)(_u,{"data-option":"blockquote",children:e})},P6=Object.keys(P5),P8=e=>e.preventDefault(),P9={key:"style-none",style:"",title:"No style"},P7=(0,lK.memo)(function(e){let{disabled:t,items:n}=e,i=(0,sj._F)(),r=PW(),l=t||!!r&&i.schemaTypes.block.name!==r._type,a=function(e){let{items:t}=e,n=(0,sj._F)(),i=PW(),r=(0,sj.L9)();return d6((0,lK.useMemo)(()=>t.filter(e=>sj.q$.hasBlockStyle(n,e.style)).map(e=>e.style),[i,r]))}({items:n}),{activeItems:o,items:s}=(0,lK.useMemo)(()=>{let e=n.filter(e=>a.includes(e.style)),t=n;return 0===e.length&&t.length>1&&(t=t.concat([P9]),e.push(P9)),{activeItems:e,items:t}},[a,n]),d=(0,lK.useMemo)(()=>o.length>1?"Multiple":1===o.length?o[0].title:P9.title,[o]),c=(0,lK.useCallback)(e=>{if(r&&e.style!==r.style){let t=sj.q$.getSelection(i);sj.q$.toggleBlockStyle(i,e.style),sj.q$.select(i,null),t&&sj.q$.select(i,{...t})}setTimeout(()=>
1{sj.q$.focus(i)})},[i,r]),u=(0,lK.useCallback)((e,t)=>{let n=P6.includes(e),i=P5[e];return n?i(t):(0,lU.jsx)(lY.xv,{children:t})},[]),p=(0,lK.useMemo)(()=>(0,lU.jsx)(P3,{disabled:l,iconRight:a0.GVG,mode:"bleed",onClick:P8,padding:2,text:d}),[l,d]),h=(0,lK.useMemo)(()=>(0,lU.jsx)(lY.v2,{disabled:l,children:s.map(e=>(0,lU.jsx)(P2,{pressed:o.includes(e),onClick:l?void 0:()=>c(e),children:u(e.style,(null==e?void 0:e.title)||e.style)},e.key))}),[l,o,c,s,u]);return(0,lU.jsx)(P1,{popover:P4,id:"block-style-select",button:p,menu:h})}),Ae=(0,lK.memo)(PD),At={constrainSize:!0,portal:!0},An=(0,lK.memo)(function(e){let{disabled:t,items:n,isFullscreen:i,collapsed:r}=e,l=PW(),a=(0,sj._F)(),o=l&&l._type!==a.schemaTypes.block.name,s=(0,lK.useCallback)(()=>{sj.q$.focus(a)},[a]),d=(0,lK.useMemo)(()=>n.map(e=>{let n=e.type.title||dL()(e.type.name);return(0,lU.jsx)(PZ,{"aria-label":"Insert ".concat(n).concat(e.inline?" (inline)":" (block)"),padding:2,mode:"bleed",disabled:t||o&&!0===e.inline,icon:e.icon,onClick:e.handle,text:n,tooltipText:"Insert ".concat(n),tooltipProps:{disabled:t,placement:i?"bottom":"top",portal:"default"}},e.key)}),[n,t,o,i]),c=(0,lK.useMemo)(()=>({button:(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"bleed",padding:2,disabled:t}),popover:At}),[t]);return(0,lU.jsx)(Ae,{collapsed:r,collapseText:!1,disableRestoreFocusOnClose:!0,gap:1,menuButtonProps:c,onMenuClose:s,children:d})});var Ai=Object.freeze,Ar=Object.defineProperty,Al=(e,t)=>
1Ai(Ar(e,"raw",{value:Ai(t||e.slice())}));let Aa=(0,aW.ZP)(lY.kC)(iU||(iU=Al(["\n width: 100%;\n"]))),Ao=(0,aW.ZP)(lY.xu)(iB||(iB=Al(["\n width: 8em;\n"]))),As=(0,aW.ZP)(lY.kC)(iK||(iK=Al(["\n border-right: 1px solid var(--card-border-color);\n"]))),Ad=(0,aW.ZP)(lY.xu)(iW||(iW=Al(["\n ","\n"])),e=>{let{$withInsertMenu:t}=e;return t&&(0,aW.iv)(iH||(iH=Al(["\n max-width: max-content;\n border-right: 1px solid var(--card-border-color);\n "])))}),Ac=(0,aW.ZP)(lY.xu)(i$||(i$=Al(["\n border-left: 1px solid var(--card-border-color);\n"]))),Au="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),Ap=(0,lK.memo)(function(e){let{actionGroups:t,blockStyles:n,disabled:i,insertMenuItems:r,isFullscreen:l,onToggleFullscreen:a}=e,o=t.reduce((e,t)=>e+t.actions.length,0),s=r.length>0,[d,c]=(0,lK.useState)(null),u=(0,lY.XL)(d),p=!!u&&(null==u?void 0:u.width)<400,h=n.length>1;pV({rootElement:d});let f=(0,lK.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]);return(0,lU.jsxs)(Aa,{align:"center",ref:c,onMouseDown:f,children:[h&&(0,lU.jsx)(As,{flex:p?1:void 0,children:(0,lU.jsx)(Ao,{padding:l?2:1,children:(0,lU.jsx)(P7,{disabled:i,items:n})})}),(0,lU.jsxs)(lY.kC,{flex:1,children:[o>0&&(0,lU.jsx)(Ad,{flex:p?void 0:1,padding:l?2:1,$withInsertMenu:s,children:(0,lU.jsx)(PY,{disabled:i,collapsed:p,groups:t,isFullscreen:l})}),s&&(0,lU.jsx)(lY.xu,{flex:p?void 0:1,padding:l?2:1,children:(0,lU.jsx)(An,{disabled:i,collapsed:p,items:r,isFullscreen:l})})]}),(0,lU.jsx)(Ac,{padding:l?2:1,children:(0,lU.jsx)(lY.u,{content:(0,lU.jsxs)(lY.kC,{align:"center",padding:1,children:[(0,lU.jsx)(lY.xu,{flex:1,paddingX:1,children:(0,lU.jsx)(lY.xv,{size:1,children:"".concat(l?"Collapse":"Expand"," editor")})}),(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.p8,{keys:["".concat(Au?"Cmd":"Ctrl"),"Enter"]})})]}),placement:l?"bottom":"top",portal:"default",children:(0,lU.jsx)(lY.zx,{padding:2,icon:l?a0.W5x:a0.Qq,mode:"bleed",onClick:a})})})]})});function Ah(e){let{hotkeys:t,isFullscreen:n,readOnly:i,onMemberOpen:r,onToggleFullscreen:l}=e,a=(0,sj._F)(),o=(0,sj.L9)(),s=VE(),d=i||!o,{push:c}=(0,lY.pm)(),u=(0,lK.useCallback)(e=>{let t=!1,n=setTimeout(()=>{t=!0,c({id:"resolving-initial-value",status:"info",title:"Resolving initial valueâ¦"})},300);return s(e,{}).then(e=>(t&&c({id:"resolving-initial-value",status:"info",duration:500,title:"Initial value resolved"}),e)).catch(t=>{c({title:"Could not resolve initial value",id:"resolving-initial-value",description:"Unable to resolve initial value for type: ".concat(e.name,": ").concat(t.message,"."),status:"error"})}).finally(()=>clearTimeout(n))},[c,s]),p=(0,lK.useCallback)(async e=>{let t=await u(e),n=sj.q$.insertBlock(a,e,t);n&&r(n)},[a,r,u]),h=(0,lK.useCallback)(async e=>{let t=await u(e),n=sj.q$.insertChild(a,e,t);n&&r(n)},[a,r,u]),f=function(e){let{hotkeys:t,onMemberOpen:n,resolveInitialValue:i,disabled:r}=e,l=(0,sj._F)(),a=(0,lK.useCallback)(async e=>{let t=await i(e),r=sj.q$.addAnnotation(l,e,t);r&&r.markDefPath&&n(r.markDefPath)},[l,n,i]);return(0,lK.useMemo)(()=>l?[{name:"format",actions:function(e,t,n){let i=e.schemaTypes;return i.decorators.map(i=>{let r=Object.keys(n.marks||{}).find(e=>{var t;return(null==(t=n.marks)?void 0:t[e])===i.value}),l=[];return r&&(l=[r]),{type:"format",disabled:t,icon:null==i?void 0:i.icon,key:i.value,handle:()=>{sj.q$.toggleMark(e,i.value),sj.q$.focus(e)},hotkeys:l,title:i.title}})}(l,r,t)},{name:"list",actions:function(e,t){let n=e.schemaTypes;return n.lists.map(n=>({type:"listStyle",key:n.value,disabled:t,icon:null==n?void 0:n.icon,handle:()=>{sj.q$.toggleList(e,n.value)},title:n.title}))}(l,r)},{name:"annotation",actions:function(e,t,n){let i=e.schemaTypes,r
1=sj.q$.focusChild(e),l=r&&r.text;return i.annotations.map(i=>({type:"annotation",disabled:!l||t,icon:op()(i,"icon")||op()(i,"type.icon")||op()(i,"type.to.icon")||op()(i,"type.to[0].icon"),key:i.name,handle:t=>{t?(sj.q$.removeAnnotation(e,i),sj.q$.focus(e)):n(i)},title:i.title||sL()(i.name)}))}(l,r,a)}]:[],[r,l,a,t])}({hotkeys:t,onMemberOpen:r,resolveInitialValue:u,disabled:!0}),m=(0,lK.useMemo)(()=>a.schemaTypes.styles.map(e=>({key:"style-".concat(e.value),style:e.value,styleComponent:e&&e.component,title:e.title})),[a]),g=(0,lK.useMemo)(()=>(function(e,t,n,i){let r=e.blockObjects.map((e,t)=>({handle:()=>n(e),icon:PU(e,a0.sTT),inline:!1,key:"block-".concat(t),type:e})),l=e.inlineObjects.map((e,t)=>({handle:()=>i(e),icon:PU(e,a0.Kz2),inline:!0,key:"inline-".concat(t),type:e})),a=r.concat(l).filter(e=>{var t;return!(null==(t=e.type)?void 0:t.hidden)});return a})(a.schemaTypes,0,p,h),[d,a,p,h]);return(0,lU.jsx)(Ap,{actionGroups:f,blockStyles:m,disabled:d,insertMenuItems:g,isFullscreen:n,onToggleFullscreen:l})}var Af=Object.freeze,Am=Object.defineProperty,Ag=(e,t)=>Af(Am(e,"raw",{value:Af(t||e.slice())}));let Ax=(0,aW.ZP)(lY.Zb)(iX||(iX=Ag(["\n height: ",";\n\n &:not([hidden]) {\n display: flex;\n }\n\n flex-direction: column;\n"])),e=>{let{$fullscreen:t}=e;return t?"100%":"15em"}),Av=(0,aW.ZP)(lY.Zb)(iG||(iG=Ag(["\n z-index: 10;\n line-height: 0;\n"]))),Ab=(0,aW.ZP)(lY.Zb)(iY||(iY=Ag(["\n position: relative;\n overflow: hidden;\n overflow: clip;\n\n & > [data-portal] {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n\n & > * {\n pointer-events: initial;\n }\n }\n\n &::selection,\n *::selection {\n background-color: transparent;\n }\n"]))),Ay=(0,aW.ZP)(cq)(iJ||(iJ=Ag(["\n position: relative;\n overflow: auto;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n & > * {\n flex: 1;\n min-height: auto;\n }\n"]))),Aj=(0,aW.ZP)(lY.W2)(iQ||(iQ=Ag(["\n /* @todo: calculate from theme */\n /* max-width: 728px; */\n"]))),Aw=(0,aW.ZP)(lY.Zb)(i2||(i2=Ag(["\n height: 100%;\n width: 100%;\n counter-reset: ",";\n overflow: hidden;\n overflow: clip;\n\n & > div {\n height: 100%;\n }\n\n & .pt-editable {\n display: block;\n width: 100%;\n height: 100%;\n\n ","\n\n & > .pt-list-item-bullet + .pt-list-item-number,\n & > .pt-list-item-number + .pt-list-item-bullet {\n margin-top: ","px;\n counter-reset: ",";\n }\n\n & > :not(.pt-list-item) + .pt-list-item {\n margin-top: ","px;\n }\n\n /* Reset the list count if the element is not a numbered list item */\n & > :not(.pt-list-item-number) {\n counter-reset: ",";\n }\n\n ","\n\n & > .pt-list-item + :not(.pt-list-item) {\n margin-top: ","px;\n }\n\n & > :first-child {\n padding-top: ","px;\n }\n\n & > :last-child {\n padding-bottom: ","px;\n }\n\n /* & > .pt-block {\n & .pt-inline-object {\n }\n } */\n\n & .pt-drop-indicator {\n pointer-events: none;\n border: 1px solid var(--card-focus-ring-color) !important;\n height: 0px !important;\n border-radius: 1px;\n margin-top: -3px;\n left: calc(\n "," - 1px\n );\n right: calc(\n "," - 1px\n );\n width: calc(\n 100% -\n "," + 2px\n ) !important;\n }\n }\n"])),CK.map(e=>CG(e)).join(" "),CK.map(e=>(0,aW.iv)(i0||(i0=Ag(["\n & > .pt-list-item-number[class~='pt-list-item-level-","'] {\n counter-increment: ",";\n }\n "])),e,CG(e))),e=>{let{theme:t}=e;return t.sanity.space[3]},CK.map(e=>CG(e)).join(" "),e=>{let{theme:t}=e;return t.sanity.space[2]},CK.map(e=>CG(e)).join(" "),CK.slice(1).map(e=>(0,aW.iv)(i1||(i1=Ag(["\n & > .pt-list-item-level-"," + .pt-list-item-level-"," {\n counter-reset: ",";\n }\n "])),e,e-1,CG(e))),e=>{let{theme:t}=e;return t.sanity.space[3]},e=>{let{$isFullscreen:t,theme:n}=e;return n.sanity.space[t?5:3]},e=>{let{$isFullscreen:t,theme:n}=e;return n.sanity.space[t?9:5]},e=>{let{$isFullscreen:t,theme:n}=e;return t?(0,lY.hO)(n.sanity.space[5]):(0,lY.hO)(n.sanity.space[3])},e=>{let{$isFullscreen:t,theme:n}=e;return t?(0,lY.hO)(n.sanity.space[5]):(0,lY.hO)(n.sanity.space[3])},e=>{let{$isFullscreen:t,theme:n}=e;return t?(0,lY.hO)(2*n.sanity.space[5]):(0,lY.hO)(2*n.sanity.space[3])}),Ak=e=>{let{block:t,focused:n,children:i,selected:r,schemaType:l}=e,a=(0,lK.useMemo)(()=>(t.style&&_p[t.style]?_p[t.style]:_p[0])||_i,[t.style]),o=(0,lK.useCallback)(e=>(0,lU.jsx)(a,{children:(0,lU.jsx)(_n,{"data-testid":"text-style--".concat(t.style),children:e.children})}),[a,t.style]);return(0,lK.useMemo)(()=>{let e=l.component,{title:a,value:s}=l,d={block:t,focused:n,renderDefault:o,schemaType:l,selected:r,title:a,value:s};return e?(0,lU.jsx)(e,{...d,children:i}):(0,lU.jsx)(o,{...d,children:i})},[o,t,i,n,l,r])},AC=e=>(0,lU.jsx)(lU.Fragment,{children:e.children}),A_=e=>{let{block:t,children:n,schemaType:i,selected:r,focused:l,level:a,value:o}=e,{title:s,component:d}=i;return(0,lK.useMemo)(()=>{let e={block:t,focused:l,level:a,renderDefault:AC,schemaType:i,selected:r,title:s,value:o};return d?(0,lU.jsx)(d,{...e,children:n}):(0,lU.jsx)(AC,{...e,children:n})},[d,t,n,l,a,i,r,s,o])},AS=e=>(0,lU.jsx)(Py,{...e}),AT=e=>(0,lU.jsx)(Ak,{...e}),AE=e=>(0,lU.jsx)(A_,{...e});function AP(e){let{hasFocus:t,hotkeys:n,initialSelection:i,isActive:r,isFullscreen:l,onCopy:a,onItemOpen:o,onPaste:s,onToggleFullscreen:d,path:c,readOnly:u,renderAnnotation:p,renderBlock:h,renderChild:f,scrollElement:m,setPortalElement:g,setScrollElement:x}=e,{isTopLayer:v}=(0,lY.sJ)(),b=(0,lK.useRef)(null),y=(0,sj._F)(),{element:j}=(0,lY.sz)();(0,lY.qh)((0,lK.useCallback)(e=>{v&&l&&"Escape"===e.key&&d()},[d,l,v]));let w=(0,lK.useCallback)(()=>(0,lU.jsx)(lU.Fragment,{children:"Empty"}),[]),k=function(){let e=(0,sj._F)();return(0,lK.useMemo)(()=>{var t;
1let n=null==(t=e.schemaTypes.block.options)?void 0:t.spellCheck,i="undefined"!=typeof navigator&&/Chrome\/96/.test(navigator.userAgent);return(void 0!==n||!0!==i)&&n},[e])}(),C=(0,lK.useMemo)(()=>(e,t)=>{let n=sj.q$.getSelection(e);if(n){let e=t.startContainer.parentElement;if(!e)return;(0,sP.Z)(e,{scrollMode:"if-needed",boundary:m,block:"start",inline:"nearest"})}},[m]),_=(0,lK.useRef)(t);(0,lK.useEffect)(()=>{_.current=t},[t]),(0,lK.useEffect)(()=>{_.current&&sj.q$.focus(y)},[y,l]);let S=(0,lK.useMemo)(()=>(0,lU.jsx)(sj.iV,{hotkeys:n,onCopy:a,onPaste:s,ref:b,renderAnnotation:p,renderBlock:h,renderChild:f,renderDecorator:AS,renderListItem:AE,renderPlaceholder:w,renderStyle:AT,scrollSelectionIntoView:C,selection:i,spellCheck:k}),[n,i,a,s,p,h,f,w,C,k]),T=(0,lK.useCallback)(e=>{o(c.concat(e))},[o,c]);return(0,lU.jsxs)(Ax,{$fullscreen:l,"data-testid":"pt-editor",children:[r&&(0,lU.jsx)(Av,{"data-testid":"pt-editor__toolbar-card",shadow:1,children:(0,lU.jsx)(Ah,{hotkeys:n,isFullscreen:l,onMemberOpen:T,onToggleFullscreen:d,readOnly:u})}),(0,lU.jsxs)(Ab,{flex:1,tone:u?"transparent":"default",children:[(0,lU.jsx)(Ay,{ref:x,children:(0,lU.jsx)(Aj,{padding:l?2:0,sizing:"border",width:1,children:(0,lU.jsx)(Aw,{$isFullscreen:l,tone:u?"transparent":"default",children:(0,lU.jsx)(lY.NM,{element:l?m:j,children:S})})})}),(0,lU.jsx)("div",{"data-portal":"",ref:g})]})]})}var AA=Object.freeze,AO=Object.defineProperty,Az=(e,t)=>AA(AO(e,"raw",{value:AA(t||e.slice())}));let AM=aW.ZP.div(e=>{let{theme:t}=e,{focusRing:n,input:i}=t.sanity,r=t.sanity.color.base,l=t.sanity.color.input,a={color:l.default.enabled.border,width:i.border.width};return(0,aW.iv)(i3||(i3=Az(["\n --input-box-shadow: ",";\n\n position: relative;\n\n & [data-wrapper] {\n overflow: hidden;\n overflow: clip;\n position: relative;\n z-index: 1;\n padding: ","px;\n }\n\n & [data-border] {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n box-shadow: var(--input-box-shadow);\n z-index: 2;\n border-radius: 1px;\n pointer-events: none;\n }\n\n &:not([data-read-only])[data-focused] [data-border] {\n --input-box-shadow: ",";\n }\n "])),_G(a),i.border.width,_Y({base:r,border:a,focusRing:n}))}),AI=(0,aW.ZP)(lY.mh)(i4||(i4=Az(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n"])));function AR(e){let{changed:t,focused:n,focusPath:i=co,hasFocus:r,hotkeys:l,isActive:a,isFullscreen:o,onActivate:s,onCopy:d,onItemClose:c,onItemOpen:u,onItemRemove:p,onPaste:h,onPathFocus:f,onToggleFullscreen:m,path:g,readOnly:x,renderAnnotation:v,renderBlock:b,renderBlockActions:y,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,value:T}=e,E=(0,sj._F)(),P=(0,lY.sz)().element,[A,O]=(0,lK.useState)(null),[z,M]=(0,lK.useState)(null),I=(0,lK.useCallback)(()=>{m()},[m]),R=(0,lK.useMemo)(()=>({...l,custom:{"mod+enter":m,...(null==l?void 0:l.custom)||{}}}),[l,m]),F=function(e){let t=(0,sj._F)(),[n]=(0,lK.useState)(()=>e);return n!==e&&console.warn("Make sure that hotkeys are a stable object across renders, or there will be issues with key handling in the Portable Text Editor."),(0,lK.useMemo)(()=>{let e={marks:{}};return t.schemaTypes.decorators.forEach(t=>{switch(t.value){case"strong":e.marks["mod+b"]=t.value;break;case"em":e.marks["mod+i"]=t.value;break;case"underline":e.marks["mod+u"]=t.value;break;case"code":e.marks["mod+'"]=t.value}}),{marks:{...e.marks,...(n||{}).marks},custom:n.custom}},[t,n])}(R),D=T&&y?y:void 0,Z=T&&j?j:void 0,[L,q]=(0,lK.useState)(null),N=(0,lK.useCallback)(e=>{let{children:t,focused:n,path:i,selected:r,schemaType:l,value:a}=e;return(0,lU.jsx)(_h,{floatingBoundary:P,focused:n,isFullscreen:o,onItemClose:c,onItemOpen:u,onItemRemove:p,onPathFocus:f,path:g.concat(i),readOnly:x,referenceBoundary:z,renderAnnotation:v,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderBlockActions:D,renderCustomMarkers:Z,renderPreview:S,renderBlock:b,schemaType:l,selected:r,value:a,children:t})},[D,Z,z,o,c,u,p,f,P,g,x,v,b,w,k,C,_,S]),V=(0,lK.useCallback)(e=>{let{focused:t,path:n,selected:i,schemaType:r,value:l}=e;return(0,lU.jsx)(CU,{floatingBoundary:P,focused:t,isFullscreen:o,onItemClose:c,onItemOpen:u,onItemRemove:p,onPathF
1ocus:f,path:g.concat(n),readOnly:x,referenceBoundary:z,relativePath:n,renderAnnotation:v,renderBlock:b,renderBlockActions:D,renderCustomMarkers:Z,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:r,selected:i,value:l})},[P,z,o,c,u,p,f,g,x,v,b,D,Z,w,k,C,_,S]),U=(0,lK.useCallback)(e=>{let{value:t}=e,n=t._type===E.schemaTypes.block.name;return n?N(e):V(e)},[E.schemaTypes.block.name,V,N]),B=(0,lK.useCallback)(e=>{let{children:t,focused:n,path:i,selected:r,schemaType:l,value:a}=e,o=a._type===E.schemaTypes.span.name;return o?t:(0,lU.jsx)(_S,{floatingBoundary:P,focused:n,onItemClose:c,onItemOpen:u,onPathFocus:f,path:g.concat(i),readOnly:x,referenceBoundary:z,relativePath:i,renderAnnotation:v,renderBlock:b,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:l,selected:r,value:a})},[P,z,E.schemaTypes.span.name,c,u,f,g,x,v,b,j,w,k,C,_,S]),K=(0,lK.useCallback)(e=>{let{children:t,focused:i,path:r,selected:l,schemaType:a,value:o}=e;return(0,lU.jsx)(_Z,{editorNodeFocused:i,floatingBoundary:P,focused:!!n,onItemClose:c,onItemOpen:u,onPathFocus:f,path:g.concat(r),readOnly:x,referenceBoundary:z,renderAnnotation:v,renderBlock:b,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:a,selected:l,value:o,children:t})},[P,z,n,c,u,f,g,x,v,b,j,w,k,C,_,S]),H=(0,lK.useMemo)(()=>(0,lU.jsx)(AP,{hasFocus:r,hotkeys:F,isActive:a,isFullscreen:o,onItemOpen:u,onCopy:d,onPaste:h,onToggleFullscreen:I,path:g,readOnly:x,renderAnnotation:K,renderBlock:U,renderChild:B,setPortalElement:q,scrollElement:z,setScrollElement:M}),[z,F,I,r,K,U,B,a,o,d,u,h,g,x]),W=(0,lY.vI)(),$=(0,lK.useMemo)(()=>({collapsed:A,default:W.element,editor:L,expanded:W.element}),[W.element,L,A]);return!function(e){let{focusPath:t,boundaryElement:n,onItemClose:i}=e,r=function(){let e=(0,lK.useContext)(Cf);if(!e)throw Error("Form context not provided");return e}(),l=(0,sj._F)(),a=(0,sj.L9)();(0,lK.useEffect)(()=>{var e,i,o,s;if(0===t.length||(null==a?void 0:a.focus.path)&&(0,lB.Xy)(a.focus.path,t))return;let d=r.find(e=>e.member.open);if(d&&(null==(e=d.elementRef)?void 0:e.current)){n&&((0,sP.Z)(n,{scrollMode:"if-needed",block:"start",inline:"start"}),(0,sP.Z)(d.elementRef.current,{scrollMode:"if-needed",boundary:n,block:"start",inline:"start"}));let e=1===t.length,r="textBlock"===d.kind,a=r&&4===t.length&&"children"===t[1]&&"text"===t[3],c=r&&3===t.length&&"children"===t[1];if("textBlock"===d.kind){let n=c||a?t.slice(0,3):[t[0],"children",Array.isArray(null==(i=d.node.value)?void 0:i.children)&&(null==(o=d.node.value)?void 0:o.children[0]._key)&&{_key:null==(s=d.node.value)?void 0:s.children[0]._key}||0];(e||c||a)&&(sj.q$.select(l,{anchor:{path:n,offset:0},focus:{path:n,offset:0}}),sj.q$.focus(l))}}},[n,l,t,i,r,null==a?void 0:a.focus.path])}({focusPath:i,boundaryElement:z,onItemClose:c}),(0,lU.jsx)(lY.Xp,{__unstable_elements:$,children:(0,lU.jsx)(Pg,{onActivate:s,isOverlayActive:!a,children:(0,lU.jsx)(cD,{disabled:o,hasFocus:!!n,isChanged:t,path:g,children:(0,lU.jsxs)(AM,{"data-focused":r?"":void 0,"data-read-only":x?"":void 0,children:[(0,lU.jsx)(lY.xu,{"data-wrapper":"",ref:O,children:(0,lU.jsx)(lY.h_,{__unstable_name:o?"expanded":"collapsed",children:o?(0,lU.jsx)(AI,{children:H}):H})}),(0,lU.jsx)("div",{"data-border":""})]})})})})}function AF(e){let{onChange:t,onIgnore:n,resolution:i,readOnly:r}=e,l=(0,lK.useCallback)(()=>{i&&t({type:"mutation",patches:i.patches})},[t,i]);return i?(0,lU.jsx)(mH,{suffix:(0,lU.jsxs)(lY.Kq,{padding:2,children:[i.action&&(0,lU.jsxs)(lY.rj,{columns:[1,2],gap:1,children:[(0,lU.jsx)(lY.zx,{mode:"ghost",onClick:n,text:"Ignore"}),!r&&(0,lU.jsx)(lY.zx,{onClick:l,text:i.action,tone:"caution"})]}),(0,lU.jsx)(lY.xu,{padding:3,children:i.action&&(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"NOTE: Itâs generally safe to perform the action above, but if you are in doubt, get in touch with those responsible for configuring your studio."})})]}),title:(0,lU.jsx)(lU.Fragment,{children:"Invalid Portable Text Editor value"}),children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:i.description}),(0,lU.jsx)(lY.Zb,{border:!0,overflow:"auto",padding:2,tone:"inherit",children:(0,lU.jsx)(lY.EK,{language:"json",children:JSON.stringify(i.item,null,2)})})]})}):null}function AD(e,t){if(e===t)return!0;
1if(!Array.isArray(e)||!Array.isArray(t)||e.length<t.length)return!1;for(let n=0,i=t.length;n<i;n++)if(!function(e,t){let n=typeof e;return n===typeof t&&("object"===n?aQ()(e,t):e===t)}(t[n],e[n]))return!1;return!0}function AZ(e){var t;let{elementProps:n,focused:i,focusPath:r,hotkeys:l,markers:a=co,members:o,onChange:s,onCopy:d,onItemRemove:c,onInsert:u,onPaste:p,onPathFocus:h,path:f,readOnly:m,renderBlockActions:g,renderCustomMarkers:x,schemaType:v,value:b}=e,{onBlur:y}=n;(0,lK.useImperativeHandle)(n.ref,()=>({focus(){w.current&&sj.q$.focus(w.current)}}));let{subscribe:j}=function(e){let{path:t}=e,{patchChannel:n}=mY().__internal,i=(0,lK.useCallback)(e=>n.subscribe(n=>{let{snapshot:i,patches:r}=n,l=r.filter(e=>AD(e.path,t)).map(e=>({...e,path:e.path.slice(t.length)}));l.length&&e({shouldReset:r.some(e=>{var n;return(0===(n=e.path).length||AD(t,n)&&!AD(n,t))&&("set"===e.type||"unset"===e.type)}),snapshot:cc(i)?t.reduce((e,t)=>"object"==typeof t?sK()(e,t):op()(e,t),i):{},patches:l})}),[t,n]);return{subscribe:i}}({path:f}),w=(0,lK.useRef)(null),[k,C]=(0,lK.useState)(!1),[_,S]=(0,lK.useState)(null),[T,E]=(0,lK.useState)(!1),[P,A]=(0,lK.useState)(!1),O=(0,lY.pm)(),z=(0,lK.useRef)([]),M=(0,lK.useMemo)(()=>new l2.x,[]),I=(0,lK.useMemo)(()=>M.asObservable(),[M]),R=(0,lK.useRef)(null),F=(0,lK.useCallback)(()=>{w.current&&E(e=>!e)},[]);(0,lK.useEffect)(()=>{_&&b!==_.value&&S(null)},[_,b]),(0,lK.useEffect)(()=>j(e=>{let{patches:t,snapshot:n}=e;M.next({patches:t,snapshot:n})}),[M,j]);let D=(0,lK.useMemo)(()=>{var t;let n=[];for(let e of o)if("item"===e.kind){let i=!Co(e.item.schemaType);if(i)n.push({kind:"objectBlock",member:e,node:e.item});else{(e.item.validation.length>0||e.item.changed||(null==(t=e.item.presence)?void 0:t.length))&&n.push({kind:"textBlock",member:e,node:e.item});let i=e.item.members.find(e=>"field"===e.kind&&"children"===e.name);if(i&&"field"===i.kind&&ks(i))for(let e of i.field.members)"item"===e.kind&&"span"!==e.item.schemaType.name&&n.push({kind:"inlineObject",member:e,node:e.item});let r=e.item.members.filter(Cs).find(e=>"markDefs"===e.name);if(r)for(let e of r.field.members)"item"===e.kind&&"object"===e.item.schemaType.jsonType&&n.push({kind:"annotation",member:e,node:e.item})}}let i=n.map(t=>{let n;let i=gO(t.node.path),r=z.current.find(e=>e.key===i);return("textBlock"!==t.kind&&(n=(0,lU.jsx)(kR,{absolutePath:t.node.path,...e})),r)?((t.member.open||r.node.value!==t.node.value)&&(r.input=n),r.member=t.member,r.node=t.node,r):{kind:t.kind,key:i,member:t.member,node:t.node,elementRef:(0,lK.createRef)(),input:n}});return z.current=i,i},[o,e]),Z=i||1===(t=r).length||3===t.length&&"children"===t[1];(0,lK.useEffect)(()=>{Z&&A(!0)},[Z]);let L=(0,lK.useCallback)(e=>{switch(e.type){case"mutation":case"undo":case"redo":s(e.patches.map(e=>({...e,patchType:mM})));break;case"selection":(0,lK.startTransition)(()=>{e.selection&&h(e.selection.focus.path)});break;case"focus":A(!0);break;case"blur":y(e.event);break;case"invalidValue":S(e);break;case"error":O.push({status:e.level,description:e.description})}},[y,s,h,O]);(0,lK.useEffect)(()=>{C(!1)},[b]);let q=(0,lK.useCallback)(()=>{C(!0)},[]),N=(0,lK.useMemo)(()=>_&&_.resolution?(0,lU.jsx)(lY.xu,{marginBottom:2,children:(0,lU.jsx)(AF,{onChange:L,onIgnore:q,resolution:_.resolution,readOnly:m})}):null,[L,q,_,m]),V=(0,lK.useCallback)(()=>{!P&&(A(!0),w.current&&sj.q$.focus(w.current))},[P]);return(0,lU.jsxs)(lY.xu,{ref:R,children:[!k&&N,(!_||k)&&(0,lU.jsx)(Cp,{markers:a,children:(0,lU.jsx)(Cm,{memberItems:D,children:(0,lU.jsx)(sj.q$,{ref:w,patches$:I,onChange:L,maxBlocks:void 0,readOnly:m,schemaType:v,value:b,children:(0,lU.jsx)(AR,{...e,hasFocus:Z,hotkeys:l,isActive:P,isFullscreen:T,onActivate:V,onItemRemove:c,onCopy:d,onInsert:u,onPaste:p,onToggleFullscreen:F,renderBlockActions:g,renderCustomMarkers:x})})})})]})}function AL(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}var Aq=Object.freeze,AN=Object.defineProperty,AV=(e,t)=>Aq(AN(e,"raw",{value:Aq(t||e.slice())}));let AU=(0,aW.ZP)(lY.Zb)(e=>{let{theme:t}=e,{focusRing:n,input:i,radius:r}=t.sanity,l=t.sanity.color.input,a=(0,lY.hO)(t.sanity.space[1]);return{position:"relative",borderRadius:"".concat(r[1],"px"),color:l.default.enabled.fg,boxShadow:AL({color:l.default.enabled.border,width:i.border.width}),"& > .content":{position:"relative",lineHeight:0,margin:"-".concat(a," 0 0 -").concat(a)},"& > .content > div":{display:"inline-block",verticalAlign:"top",padding:"".concat(a," 0 0 ").concat(a)},"&:not([data-read-only])":{cursor:"text"},"@media(hover:hover)":{"&:not([data-disabled]):not([data-read-only]):hover":{borderColor:l.default.hovered.border}},"&:not([data-disabled]):not([data-read-only])[data-focused]":{boxShadow:function(e){let{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,l=0-i.offset,a=t?t.bg:"var(--card-bg-color)";return[l>0&&"inset 0 0 0 ".concat(l,"px var(--card-focus-ring-color)"),n&&AL(n),l<0&&"0 0 0 ".concat(0-l,"px ").concat(a),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(
1Boolean).join(",")}({border:{color:l.default.enabled.border,width:i.border.width},focusRing:n})},"*:disabled + &":{color:l.default.disabled.fg,backgroundColor:l.default.disabled.bg,boxShadow:AL({color:l.default.disabled.border,width:i.border.width})}}}),AB=aW.ZP.input(e=>{let{theme:t}=e,n=t.sanity.fonts.text,i=t.sanity.color.input,r=t.sanity.space[2],l=t.sanity.fonts.text.sizes[2];return{appearance:"none",background:"none",border:0,borderRadius:0,outline:"none",fontSize:(0,lY.hO)(l.fontSize),lineHeight:l.lineHeight/l.fontSize,fontFamily:n.family,fontWeight:n.weights.regular,margin:0,display:"block",minWidth:"1px",maxWidth:"100%",boxSizing:"border-box",paddingTop:(0,lY.hO)(r-l.ascenderHeight),paddingRight:(0,lY.hO)(r),paddingBottom:(0,lY.hO)(r-l.descenderHeight),paddingLeft:(0,lY.hO)(r),"&:not(:invalid):not(:disabled)":{color:i.default.enabled.fg},"&:not(:invalid):disabled":{color:i.default.disabled.fg}}}),AK=(0,aW.ZP)(lY.xu)(e=>{let{theme:t}=e,n=t.sanity.color.input;return(0,aW.iv)(i5||(i5=AV(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n pointer-events: none;\n --card-fg-color: ",";\n "])),n.default.enabled.placeholder)}),AH=(0,aW.ZP)(lY.xu)(i6||(i6=AV(['\n // This is needed to make textOverflow="ellipsis" work properly for the Text primitive\n max-width: 100%;\n']))),AW=(0,lK.forwardRef)((e,t)=>{let{disabled:n,onChange:i,onFocus:r,placeholder:l,readOnly:a,value:o=[],...s}=e,d=(0,lK.useMemo)(()=>l||("undefined"!=typeof window&&"ontouchstart"in window?"Enter tagâ¦":"Enter tag and press ENTERâ¦"),[l]),[c,u]=(0,lK.useState)(""),p=!n&&!a,[h,f]=(0,lK.useState)(!1),m=(0,lY.ts)(t),g=(0,lK.useRef)(null),x=(0,lK.useCallback)(e=>{let t=(0,lY.Re)(e.target)&&e.target.closest('[data-ui="Tag"]');if(t)return;let n=m.current;n&&setTimeout(()=>
1n.focus(),0)},[m]),v=(0,lK.useCallback)(()=>{f(!1)},[]),b=(0,lK.useCallback)(e=>{u(e.currentTarget.value)},[]),y=(0,lK.useCallback)(e=>{f(!0),r&&r(e)},[r]),j=(0,lK.useCallback)(e=>{if("Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),i&&c)){let e=o.concat([{value:c}]);u(""),i&&i(e)}},[c,i,o]),w=(0,lK.useCallback)(e=>{if(!i)return;let t=o.slice(0);t.splice(e,1),i(t)},[i,o]);return(0,lK.useEffect)(()=>{let e=m.current;e&&(e.style.width="0",e.style.width="".concat(e.scrollWidth,"px"))},[m,c]),(0,lU.jsxs)(AU,{"data-disabled":n?"":void 0,"data-focused":h?"":void 0,"data-read-only":a?"":void 0,"data-ui":"TagInput",onPointerDown:x,overflow:"auto",padding:1,ref:g,children:[p&&(0,lU.jsx)(AK,{hidden:!!(c||o.length),padding:3,children:(0,lU.jsx)(lY.xv,{textOverflow:"ellipsis",children:d})}),(0,lU.jsxs)("div",{className:"content",children:[o.map((e,t)=>(0,lU.jsx)(AH,{children:(0,lU.jsx)(A$,{enabled:p,index:t,muted:!p,onRemove:w,tag:e})},"tag-".concat(t))),(0,lU.jsx)("div",{children:(0,lU.jsx)(AB,{...s,disabled:!p,onBlur:v,onChange:b,onFocus:y,onKeyDown:j,ref:m,type:"text",value:c})},"tag-input")]})]})});function A$(e){let{enabled:t,index:n,muted:i,onRemove:r,tag:l}=e,a=(0,lK.useCallback)(()=>{r(n)},[n,r]);return(0,lU.jsx)(lY.Zb,{"data-ui":"Tag",padding:1,radius:2,tone:"transparent",children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.xu,{flex:1,padding:1,children:(0,lU.jsx)(lY.xv,{muted:i,textOverflow:"ellipsis",children:l.value})}),t&&(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.zx,{icon:a0.Two,mode:"bleed",onClick:a,padding:1})})]})})}function AX(e){let{onChange:t,readOnly:n,value:i=[],elementProps:r,path:l,changed:a}=e,o=(0,lK.useMemo)(()=>null==i?void 0:i.map(e=>({value:e})),[i]),s=(0,lK.useCallback)(e=>{t(0===e.length?mD():mF(e.map(e=>e.value)))},[t]);return(0,lU.jsx)(cD,{path:l,isChanged:a,hasFocus:!1,children:(0,lU.jsx)(AW,{onChange:s,readOnly:n,value:o,...r})})}AW.displayName="TagInput";let AG={portal:!0,tone:"default"};function AY(e){let{member:t,sortable:n,onRemove:i}=e,r=(0,lK.useId)();return(0,lU.jsx)(lY.xu,{paddingX:1,children:(0,lU.jsx)(j2,{dragHandle:n,tone:"caution",menu:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg}),id:"".concat(r,"-menuButton"),menu:(0,lU.jsx)(lY.v2,{children:(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:i})}),popover:AG}),children:"INVALID_ITEM_TYPE"===t.error.type?(0,lU.jsx)(Pl,{value:t.error.value}):(0,lU.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})})})}function AJ(e){let{hoveringFiles:t,types:n,resolveUploader:i}=e,r=t.filter(e=>n.some(t=>i(t,e))),l=t.length-r.length,a=n.length>1;return(0,lU.jsx)(lU.Fragment,{children:r.length>0?(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.rG2,{})}),(0,lU.jsxs)(lY.xv,{children:["Drop to upload"," ",a&&(0,lU.jsxs)(lU.Fragment,{children:[r.length," file",r.length>1?"s":""]})]})]}),l>0&&(0,lU.jsx)(lY.xu,{marginTop:4,children:(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:(0,lU.jsx)(a0.vaB,{})}),(0,lU.jsxs)(lY.xv,{muted:!0,size:1,children:[l," file",l>1?"s":""," can't be uploaded here"]})]})})]}):(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.vaB,{})}),(0,lU.jsxs)(lY.xv,{children:["Can't upload ",t.length>1?"any of these files":"this file"," here"]})]})})}var AQ=Object.freeze,A0=Object.defineProperty;let A1=(0,aW.ZP)(lY.mh)(i8||(i8=AQ(A0(G=["\n position: absolute;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n top: -2px;\n left: -2px;\n right: -2px;\n bottom: -2px;\n background-color: var(--card-bg-color);\n opacity: 0.8;\n"],"raw",{value:AQ(G.slice())}))));var A2=Object.freeze,A3=Object.defineProperty;let A4=aW.ZP.div(i9||(i9=A2(A3(Y=["\n position: relative;\n"],"raw",{value:A2(Y.slice())})))),A5=function(e){let t=_X(e);return lK.forwardRef(function(e,n){let{children:i,resolveUploader:r,onUpload:l,types:a,...o}=e,{push:s}=(0,lY.pm)(),d=lK.useCallback((e,t)=>{let{type:n,uploader:i}=t;
1null==l||l({file:e,schemaType:n,uploader:i})},[l]),c=lK.useCallback(e=>{if(!r)return;let t=e.map(e=>({file:e,uploaderCandidates:a.map(t=>({type:t,uploader:r(t,e)})).filter(e=>e.uploader)})),n=t.filter(e=>e.uploaderCandidates.length>0),i=t.filter(e=>0===e.uploaderCandidates.length);if(i.length>0){let e=i.length>1;s({closable:!0,status:"warning",title:"The following item".concat(e?"s":""," can't be uploaded because there's no known conversion from content type").concat(e?"s":""," to array item:"),description:i.map((e,t)=>(0,lU.jsxs)(lY.kC,{padding:2,children:[(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.xv,{weight:"semibold",children:e.file.name})}),(0,lU.jsx)(lY.xu,{paddingLeft:2,children:(0,lU.jsxs)(lY.xv,{size:1,children:["(",e.file.type,")"]})})]},t))})}n.forEach(e=>{d(e.file,aX()(e.uploaderCandidates,e=>e.uploader.priority)[0])})},[s,r,a,d]),[u,p]=lK.useState([]),h=lK.useCallback(()=>p([]),[]);return(0,lU.jsx)(A4,{children:(0,lU.jsxs)(t,{...o,ref:n,onFiles:c,onFilesOver:p,onFilesOut:h,children:[r&&u.length>0&&(0,lU.jsx)(A1,{zOffset:10,children:(0,lU.jsx)(AJ,{hoveringFiles:u,types:a,resolveUploader:r})}),i]})})})}(_1(lY.Zb)),A6={portal:!0,tone:"default"},A8=lK.forwardRef(function(e,t){let{sortable:n,value:i,insertableTypes:r,onInsert:l,onRemove:a,readOnly:o,inputId:s,validation:d,children:c,presence:u,schemaType:p}=e,h=d.filter(e=>"error"===e.level).length>0,f=d.filter(e=>"warning"===e.level).length>0,m=(0,lK.useCallback)((e,t)=>{l({position:e,items:[k_(t)]})},[l]),g=(0,lK.useCallback)(()=>{i&&l({position:"after",items:[i]})},[l,i]),x=(0,lK.useMemo)(()=>h?"critical":f?"caution":void 0,[h,f]),v=(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg}),id:"".concat(s,"-menuButton"),popover:A6,menu:(0,lU.jsxs)(lY.v2,{children:[(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:a}),(0,lU.jsx)(lY.sN,{text:"Duplicate",icon:a0.TIy,onClick:g}),(0,lU.jsx)(wo,{types:r,onInsert:m})]})});return(0,lU.jsx)(j2,{tone:x,menu:!o&&v,dragHandle:!o&&n,presence:0===u.length?null:(0,lU.jsx)(yF,{presence:u,maxAvatars:1}),validation:d.length>0?(0,lU.jsx)(lY.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,lU.jsx)(js,{validation:d})}):null,children:(0,lU.jsx)(lY.kC,{align:p?"flex-end":"center",ref:t,children:(0,lU.jsx)(lY.kC,{align:"flex-end",flex:1,children:(0,lU.jsx)(lY.xu,{flex:1,marginRight:2,children:c})})})})});function A9(e){let{schemaType:t,readOnly:n,children:i,onValueCreate:r,onItemAppend:l}=e,a=(0,lK.useId)(),o=lK.useCallback(e=>{l(r(e))},[r,l]),s=lK.useCallback(()=>{o(t.of[0])},[t,o]),d=(0,lK.useMemo)(()=>({constrainSize:!0,portal:!0}),[]);return n?(0,lU.jsx)(lY.u,{portal:!0,content:(0,lU.jsx)(lY.xu,{padding:2,sizing:"border",children:(0,lU.jsx)(lY.xv,{size:1,children:"This field is read-only"})}),children:(0,lU.jsx)(lY.rj,{children:(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",disabled:!0,text:1===t.of.length?"Add item":"Add item..."})})}):(0,lU.jsxs)(lY.rj,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[1===t.of.length?(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",onClick:s,text:"Add item"}):(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{icon:a0.dtP,mode:"ghost",text:"Add itemâ¦"}),id:a||"",menu:(0,lU.jsx)(lY.v2,{children:t.of.map((e,t)=>{var n,i;let r=(0,lV.dD)(e)&&1===(e.to||[]).length&&e.to[0].icon,l=e.icon||(null==(n=e.type)?void 0:n.icon)||r;return(0,lU.jsx)(lY.sN,{text:e.title||(null==(i=e.type)?void 0:i.name),onClick:()=>o(e),icon:l},t)})}),popover:d}),i]})}var A7=Object.defineProperty,Oe=(e,t,n)=>t in e?A7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ot=(e,t,n)=>(Oe(e,"symbol"!=typeof t?t+"":t,n),n);class On extends lK.PureComponent{constructor(e){super(e),Ot(this,"_element",null),Ot(this,"handleAppend",e=>{let{value:t=[],onIndexFocus:n,onItemAppend:i}=this.props;i(e),n(t.length)}),Ot(this,"handlePrepend",e=>{let{onIndexFocus:t,value:n=[],onItemPrepend:i}=this.props;i(e),t(n.length)}),Ot(this,"handleSortEnd",e=>{let{onIndexFocus:t,onMoveItem:n,value:i}=this.props;i&&n(e),t(e.toIndex)}),Ot(this,"handleItemMoveStart",()=>{this.setState({disableTransition:!1})}),Ot(this,"handleItemMoveEnd",()=>{this.setState({disableTransition:!0})}),Ot(this,"renderArrayItem",e=>{var t;let{schemaType:n}=this.props,i=(null==(t=n.options)?void 0:t.sortable)!==!1;return(0,lU.jsx)(A8,{...e,sortable:i,insertableTypes:n.of})}),this.state={disableTransition:!1}}focus(){this._element&&this._element.focus()}getSnapshotBeforeUpdate(e){var t;let{focusPath:n=[],value:i=[]}=e,{focusPath:r=[],value:l=[]}=this.props;if(n[0]===r[0]&&i.length!==l.length){let e=r[0],n=window.getSelection();if(!((null==n?void 0:n.focusNode)instanceof HTMLElement))return null;let i=null==(t=n.focusNode)?void 0:t.querySelector("input,textarea");return i instanceof HTMLInputElement?{prevFocusedIndex:e,restoreSelection:{text:n.toString(),start:i.selectionStart,end:i.selectionEnd,value:i.value}}:{}}return null}componentDidUpdate(e,t,n){var i;let{onIndexFocus:r}=this.props;if((null==n?void 0:n.restoreSelection)&&e.value){let t=e.value[n.prevFocusedIndex],l=function(e,t,n){let i=t-1,r=t,l=e.length;for(;i>-1||r<l;){let t=e[r];if(r<l&&n(t,r))return r;let a=e[i];if(i>-1&&n(a,i))return i;i--,r++}return -1}(this.props.value||[],n.prevFocusedIndex,e=>e===t);if(-1===l)return;let a=null==(i=this._element)?void 0:i.querySelector("[data-item-index='".concat(l,"'] input,textarea"));if(a instanceof HTMLInputElement){a.focus();try{a.setSelectionRange(n.restoreSelection.start,n.restoreSelection.end)}catch{}}r(l)}}render(){let{schemaType:e,members:t,readOnly:n,renderInput:i,onUpload:r,onItemRemove:l,resolveUploader:a,elementProps:o,arrayFunctions:s=A9,path:d,changed:c}=this.props,u=!n&&!1!==op()(e,"options.sortable"),p=t.map(e=>({id:"".concat(e.key,"-").concat("item"===e.kind?e.item.value:"error"),member:e}));return(0,lU.jsxs)(lY.Kq,{space:3,"data-testid":"array-primitives-input",children:[(0,lU.jsx)(A5,{types:e.of,resolveUploader:a,onUpload:r,...o,tabIndex:0,children:(0,lU.jsx)(lY.Kq,{space:1,children:0===p.length?(0,lU.jsx)(lY.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:e.placeholder||(0,lU.jsx)(lU.Fragment,{children:"No items"})})}):(0,lU.jsx)(lY.Zb,{padding:1,border:!0,children:(0,lU.jsx)(jY,{onItemMove:this.handleSortEnd,onItemMoveStart:this.handleItemMoveStart,onItemMoveEnd:this.handleItemMoveEnd,items:p.map(e=>e.id),sortable:u,gap:1,children:p.map((e,t)=>{let{member:n,id:r}=e;return(0,lU.jsxs)(jJ,{id:r,sortable:u,disableTransition:this.state.disableTransition,children:["item"===n.kind&&(0,lU.jsx)(cD,{path:n.item.path,isChanged:c,hasFocus:!1,children:(0,lU.jsx)(kS,{member:n,renderItem:this.renderArrayItem,renderInput:i})}),"error"===n.kind&&(0,lU.jsx)(AY,{sortable:u,member:n,onRemove:()=>l(t)})]},n.key)})})})})}),(0,lU.jsx)(s,{onChange:this.props.onChange,onItemAppend:this.handleAppend,onItemPrepend:this.handlePrepend,onValueCreate:k_,readOnly:this.props.readOnly,schemaType:this.props.schemaType,value:this.props.value})]})}}var Oi=Object.freeze,Or=Object.defineProperty,Ol=(e,t)=>
1Oi(Or(e,"raw",{value:Oi(t||e.slice())}));let Oa=(0,aW.ZP)(lY.kC)(i7||(i7=Ol(["\n min-height: 35px;\n"]))),Oo=(0,aW.ZP)(lY.kC)(re||(re=Ol(["\n position: absolute;\n top: 0;\n right: 0;\n height: 35px;\n"]))),Os=(0,aW.ZP)(lY.Zb)(rt||(rt=Ol(["\n position: absolute;\n top: 0;\n left: 0;\n"]))),Od=(0,aW.ZP)(lY.Zb)(rn||(rn=Ol(["\n transition: border-color 250ms;\n box-sizing: border-box;\n position: relative;\n\n @media (hover: hover) {\n "," {\n opacity: 0;\n }\n\n &:hover,\n &:focus-within {\n "," {\n opacity: 1;\n }\n }\n }\n\n ."," & {\n box-shadow: 0 0 0 0, 0 8px 17px 2px var(--card-shadow-umbra-color),\n 0 3px 14px 2px var(--card-shadow-penumbra-color),\n 0 5px 5px -3px var(--card-shadow-ambient-color);\n }\n\n &[aria-selected='true'] {\n box-shadow: 0 0 0 2px var(--card-focus-ring-color);\n }\n"])),Os,Os,jB);function Oc(e){let{validation:t,selected:n,tone:i,presence:r,children:l,dragHandle:a,menu:o,footer:s,...d}=e;return(0,lU.jsxs)(Od,{forwardedAs:lY.kC,direction:"column",border:!0,selected:n,"aria-selected":n,radius:2,tone:i,...d,children:[l,a&&(0,lU.jsx)(Os,{margin:1,radius:2,display:"flex",tone:"inherit","data-ui":"DragHandleCard",children:(0,lU.jsx)(jL,{grid:!0,padding:2,mode:"ghost"})}),r&&(0,lU.jsx)(Oo,{align:"center",marginX:1,children:r}),(0,lU.jsxs)(Oa,{align:"center",paddingX:1,sizing:"border",justify:"space-between",children:[(0,lU.jsx)(lY.kC,{children:t}),(0,lU.jsx)(lY.xu,{children:s}),o]})]})}var Ou=Object.freeze,Op=Object.defineProperty;let Oh=(0,aW.ZP)(lY.Zb)(ri||(ri=Ou(Op(J=["\n border-top-right-radius: inherit;\n border-top-left-radius: inherit;\n height: 100%;\n position: relative;\n\n @media (hover: hover) {\n &:hover {\n filter: brightness(95%);\n }\n }\n\n &:focus:focus-visible {\n box-shadow: 0 0 0 2px var(--card-focus-ring-color);\n }\n"],"raw",{value:Ou(J.slice())})))),Of={portal:!0,tone:"default"},Om={position:"absolute",top:0,left:0,bottom:0,right:0};function Og(e){var t,n,i,r,l,a;let{schemaType:o,parentSchemaType:s,path:d,readOnly:c,onRemove:u,value:p,open:h,onInsert:f,onFocus:m,onOpen:g,onClose:x,changed:v,focused:b,children:y,inputProps:{renderPreview:j}}=e,w=!c&&(null==(t=s.options)?void 0:t.sortable)!==!1,k=s.of,C=(0,lK.useRef)(null);yp(C,h),m$(b,(e,t)=>{var n;!e&&t&&C.current&&(null==(n=C.current)||n.focus())});let _=p._resolvingInitialValue,S=(0,lK.useCallback)(()=>{f({items:[{...p,_key:yf()}],position:"after"})},[f,p]),T=(0,lK.useCallback)((e,t)=>{f({items:[wl(t)],position:e})},[f]),E=gi(d,!0),P=(0,lK.useMemo)(()=>0===E.length?null:(0,lU.jsx)(yF,{presence:E,maxAvatars:1}),[E]),A=ga(d,!0),O=(0,lK.useMemo)(()=>0===A.length?null:(0,lU.jsx)(lY.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,lU.jsx)(js,{validation:A,__unstable_showSummary:!0})}),[A]),z=A.some(e=>"error"===e.level),M=A.some(e=>"warning"===e.level),I=(0,lK.useMemo)(()=>c?null:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg}),id:"".concat(e.inputId,"-menuButton"),menu:(0,lU.jsxs)(lY.v2,{children:[(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:u}),(0,lU.jsx)(lY.sN,{text:"Duplicate",icon:a0.TIy,onClick:S}),(0,lU.jsx)(wo,{types:k,onInsert:T})]}),popover:Of}),[S,T,u,k,e.inputId,c]),R=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:c,hasErrors:z,hasWarnings:M}),F=(0,lU.jsx)(Oc,{menu:I,presence:P,validation:O,tone:R,radius:2,border:!0,focused:b,dragHandle:w,selected:h,children:(0,lU.jsxs)(Oh,{tone:"inherit",overflow:"auto",forwardedAs:"button","data-ui":"PreviewCard","data-as":"button",type:"button",flex:1,tabIndex:0,disabled:_,onClick:g,ref:C,onFocus:m,__unstable_focusRing:!0,children:[j({schemaType:o,value:p,layout:"media",withBorder:!1,withShadow:!1}),_&&(0,lU.jsx)(lY.Zb,{as:lY.kC,style:Om,children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"center",gap:1,padding:1,children:[(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsx)(lY.$j,{muted:!0})}),(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"Resolving initial valueâ¦"})]})})]})}),D=fk(o);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(cD,{path:d,isChanged:v,hasFocus:!!b,children:F}
1),h&&(0,lU.jsx)(kq,{header:c?"View ".concat(D):"Edit ".concat(D),type:(null==(i=null==(n=null==s?void 0:s.options)?void 0:n.modal)?void 0:i.type)||"dialog",width:null!=(a=null==(l=null==(r=null==s?void 0:s.options)?void 0:r.modal)?void 0:l.width)?a:1,id:p._key,onClose:x,autofocus:b,legacy_referenceElement:C.current,children:y})]})}var Ox=Object.freeze,Ov=Object.defineProperty;let Ob=(0,aW.ZP)(lY.Zb)(rr||(rr=Ox(Ov(Q=["\n max-width: ","px;\n"],"raw",{value:Ox(Q.slice())}))),e=>{let{theme:t}=e;return t.sanity.container[1]});function Oy(e){let{value:t,onFocus:n,vertical:i,...r}=e,[l,a]=lK.useState(!1),[o,s]=lK.useState(null);(0,lY.O8)(()=>a(!1),[o]);let d=lK.useCallback(e=>{("Escape"===e.key||"Tab"===e.key)&&a(!1)},[]),c=(0,lK.useCallback)(()=>{a(e=>!e)},[]),u=(0,sy.wq)(t);return(0,lU.jsx)(lY.J2,{open:l,ref:s,onKeyDown:d,portal:!0,constrainSize:!0,tone:"default",content:(0,lU.jsx)(Ob,{margin:1,padding:3,onKeyDown:d,tabIndex:0,overflow:"auto",children:(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{weight:"semibold",children:"Why is this happening?"})}),(0,lU.jsxs)(lY.xv,{size:1,children:["The current schema does not declare items of type ",(0,lU.jsx)("code",{children:u})," as valid for this list. This could mean that the type has been removed as a valid item type, or that someone else has added it to their own local schema that is not yet deployed."]}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsxs)(lY.xv,{size:1,children:[(0,lU.jsx)(a0.sLo,{})," You can still move or delete this item, but it cannot be edited since the schema definition for its type is nowhere to be found."]})}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,lU.jsx)(lY.Zb,{padding:2,overflow:"auto",border:!0,children:(0,lU.jsx)(lY.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,lU.jsx)(lY.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,style:{height:"100%"},onFocus:n,onClick:c,onKeyDown:d,__unstable_focusRing:!0,...r,children:(0,lU.jsxs)(lY.Kq,{space:4,marginTop:2,children:[(0,lU.jsx)(lY.xu,{margin:1,children:(0,lU.jsx)(lY.xv,{align:"center",size:4,children:(0,lU.jsx)(a0.Tzq,{})})}),(0,lU.jsxs)(lY.xv,{align:"center",size:1,children:["Items of type ",(0,lU.jsx)("code",{children:u})," is not valid for this list"]})]})})})}let Oj={portal:!0,tone:"default"};function Ow(e){let{member:t,sortable:n}=e,i=(0,lK.useId)(),{onChange:r}=m7(),l=(0,lK.useCallback)(()=>{r(mN.from([mD([{_key:t.key}])]))},[r,t.key]);return(0,lU.jsx)(Oc,{dragHandle:n,tone:"caution",style:{height:"100%"},menu:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:"bleed",icon:a0.zGg}),id:"".concat(i,"-menuButton"),menu:(0,lU.jsx)(lY.v2,{children:(0,lU.jsx)(lY.sN,{text:"Remove",tone:"critical",icon:a0.XHJ,onClick:l})}),popover:Oj}),children:"INVALID_ITEM_TYPE"===t.error.type?(0,lU.jsx)(Oy,{value:t.error.value,vertical:!0}):(0,lU.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})})}let Ok=[];function OC(e){var t;let{arrayFunctions:n=mQ,elementProps:i,members:r,onChange:l,onInsert:a,onItemMove:o,onUpload:s,readOnly:d,renderAnnotation:c,renderBlock:u,renderField:p,renderInlineBlock:h,renderInput:f,renderPreview:m,resolveUploader:g,schemaType:x,value:v=Ok}=e,b=(0,lK.useCallback)(e=>{a({items:[e],position:"before",referenceItem:0})},[a]),y=(0,lK.useCallback)(e=>{a({items:[e],position:"after",referenceItem:-1})},[a]),j=(null==(t=x.options)?void 0:t.sortable)!==!1,w=(0,lK.useCallback)(e=>(0,lU.jsx)(Og,{...e}),[]),k=(0,lK.useMemo)(()=>r.map(e=>e.key),[r]);return(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(A5,{types:x.of,resolveUploader:g,onUpload:s,...i,tabIndex:0,children:(0,lU.jsxs)(lY.Kq,{"data-ui":"ArrayInput__content",space:3,children:[(null==r?void 0:r.length)===0&&(0,lU.jsx)(lY.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:x.placeholder||(0,lU.jsx)(lU.Fragment,{children:"No items"})})}),(null==r?void 0:r.length)>0&&(0,lU.jsx)(lY.Zb,{border:!0,radius:1,children:(0,lU.jsx)(jY,{columns:[2,3,4],gap:3,padding:1,margin:1,items:k,onItemMove:o,sortable:j,children:r.map(e=>(0,lU.jsxs)(jJ,{sortable:j,id:e.key,flex:1,children:["item"===e.kind&&(0,lU.jsx)(kC,{member:e,renderAnnotation:c,renderBlock:u,renderInlineBlock:h,renderItem:w,renderField:p,renderInput:f,renderPreview:m}),"error"===e.kind&&(0,lU.jsx)(Ow,{sortable:j,member:e})]},e.key))})})]})}),(0,lU.jsx)(n,{onChange:l,onItemAppend:y,onItemPrepend:b,onValueCreate:wl,readOnly:d,schemaType:x,value:v})]})}let O_=[];function OS(e){var t;let{arrayFunctions:n=mQ,elementProps:i,members:r,onChange:l,onInsert:a,onItemMove:o,onUpload:s,focusPath:d,readOnly:c,renderAnnotation:u,renderBlock:p,renderField:h,renderInlineBlock:f,renderInput:m,renderItem:g,renderPreview:x,resolveUploader:v,schemaType:b,value:y=O_}=e,[j,w]=(0,lK.useState)(null),{space:k}=(0,lY.Fg)().sanity,C=(0,lK.useCallback)(e=>{a({items:[e],position:"before",referenceItem:0})},[a]),_=(0,lK.useCallback)(e=>{a({items:[e],position:"after",referenceItem:-1})},[a]),S=function(e,t){let n=(0,lK.useRef)(e),i=n.current,r=t(i,e);return(0,lK.useEffect)(()=>{r||(n.current=e)}),r?i:e}((0,lK.useMemo)(()=>r.map(e=>e.key),[r]),aQ()),{scrollElement:T,containerElement:E}=function(){let e=(0,lK.useContext)(kD);if(!e)throw Error("VirtualizerScrollInstance: missing context value");return e}(),P=(0,lK.useRef)(null),A=(0,lK.useMemo)(()=>(0,lV.Fd)(d[0])?d[0]._key:d[0],[d]),O=(0,lK.useCallback)(e=>{let t={...e};if(null!==j&&(t.startIndex=Math.min(e.startIndex,j),t.endIndex=Math.max(e.endIndex,j)),A){let e=S.findIndex(e=>e===A);-1!==e&&(t.startIndex=Math.min(t.startIndex,e),t.endIndex=Math.max(t.endIndex,e))}return(0,aY.MK)(t)},[j,A,S]),z=(0,lK.useCallback)((e,t)=>{if(!e.scrollElement)return;let n=e.scrollElement,i=()=>{var e,i,r,l;let a=null!=(i=null==(e=E.current)?void 0:e.getBoundingClientRect().top)?i:0,o=null!=(l=null==(r=P.current)?void 0:r.getBoundingClientRect().top)?l:0;t(n.scrollTop-Math.floor(o-a))};return i(),e.scrollElement.addEventListener("scroll",i,{capture:!1,passive:!0}),()=>{n.removeEventListener("scroll",i)}},[E]),M=(0,lK.useCallback)(()=>53,[]),I=(0,aG.MG)({count:r.length,estimateSize:M,getScrollElement:(0,lK.useCallback)(()=>T,[T]),observeElementOffset:z,rangeExtractor:O,getItemKey:(0,lK.useCallback)(e=>
1S[e],[S]),scrollToFn:(e,t,n)=>{e!==n.scrollOffset&&(0,aY.sA)(e,t,n)}}),R=I.getVirtualItems(),F=(0,lK.useCallback)(e=>{var t,n;let{active:i}=e;w(null==(n=null==(t=i.data.current)?void 0:t.sortable)?void 0:n.index)},[]),D=(0,lK.useCallback)(()=>{w(null)},[]),Z=(null==(t=b.options)?void 0:t.sortable)!==!1;return(0,lU.jsxs)(lY.Kq,{space:3,ref:P,children:[(0,lU.jsx)(A5,{types:b.of,resolveUploader:v,onUpload:s,...i,tabIndex:0,children:(0,lU.jsx)(lY.Kq,{"data-ui":"ArrayInput__content",space:3,children:0===r.length?(0,lU.jsx)(lY.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:b.placeholder||(0,lU.jsx)(lU.Fragment,{children:"No items"})})}):(0,lU.jsx)(lY.Zb,{border:!0,radius:1,style:{height:"".concat(I.getTotalSize()+R.length*k[1]+k[1],"px"),width:"100%",position:"relative"},children:(0,lU.jsx)(jY,{axis:"y",gap:1,paddingY:1,items:S,onItemMove:o,onItemMoveStart:F,onItemMoveEnd:D,sortable:Z,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(R[0].start,"px)")},children:R.map(t=>{let n=r[t.index];return(0,lU.jsxs)(jJ,{ref:I.measureElement,sortable:Z,"data-index":t.index,id:n.key,children:["item"===n.kind&&(0,lU.jsx)(kC,{member:n,renderAnnotation:u,renderBlock:p,renderField:h,renderInlineBlock:f,renderInput:m,renderItem:g,renderPreview:x}),"error"===n.kind&&(0,lU.jsx)(AY,{sortable:Z,member:n,onRemove:()=>e.onItemRemove(n.key)})]},t.key)})})})})}),(0,lU.jsx)(n,{onChange:l,onItemAppend:_,onItemPrepend:C,onValueCreate:wl,readOnly:c,schemaType:b,value:y})]})}function OT(e){var t;let n=(null==(t=e.schemaType.options)?void 0:t.layout)==="grid";return n?(0,lU.jsx)(OC,{...e}):(0,lU.jsx)(OS,{...e})}let OE=["string","number","boolean"];function OP(e){return(0,lV.n4)(e)?e:{title:sL()("".concat(e)),value:e}}let OA={title:"",value:void 0};function OO(e){var t,n;let{value:i,readOnly:r,validationError:l,schemaType:a,onChange:o,path:s,changed:d,focused:c,elementProps:u}=e,p=(0,lK.useMemo)(()=>{var e;return((null==(e=a.options)?void 0:e.list)||[]).map(OP)},[null==(t=a.options)?void 0:t.list]),h=p.find(e=>e.value===i),f=a.options&&"radio"===a.options.layout,m=(0,lK.useCallback)(e=>{let t=Number(e);return p[t]},[p]),g=(0,lK.useCallback)(e=>String(p.indexOf(e)),[p]),x=(0,lK.useId)(),v=lK.useCallback(e=>{o(mN.from(void 0===(null==e?void 0:e.value)?mD():mF(e.value)))},[o]),b=(0,lK.useCallback)(e=>{let t=m(e.currentTarget.value);if(!t){v(OA);return}v(t)},[v,m]),y=f?(0,lU.jsx)(Oz,{...u,value:h,inputId:x,items:p,direction:(null==(n=a.options)?void 0:n.direction)||"vertical",customValidity:l,onChange:v,readOnly:r}):(0,lU.jsx)(lY.Ph,{...u,customValidity:l,value:g(h),readOnly:r,onChange:b,children:[OA,...p].map((e,t)=>(0,lU.jsx)("option",{value:t-1,children:e.title},"".concat(t-1)))});return(0,lU.jsx)(cD,{path:s,isChanged:d,hasFocus:!!c,children:y})}let Oz=(0,lK.forwardRef)(function(e,t){let{items:n,value:i,onChange:r,onFocus:l,readOnly:a,customValidity:o,direction:s,inputId:d}=e,c="horizontal"===s?lY.gF:lY.Kq;return(0,lU.jsx)(lY.Zb,{border:!0,padding:3,radius:1,children:(0,lU.jsx)(c,{space:3,role:"group",children:n.map((e,n)=>(0,lU.jsx)(OM,{customValidity:o,inputId:d,item:e,onChange:r,onFocus:l,readOnly:a,ref:0===n?t:null,value:i},n))})})}),OM=(0,lK.forwardRef)(function(e,t){let{customValidity:n,inputId:i,item:r,onChange:l,onFocus:a,readOnly:o,value:s}=e,d=(0,lK.useCallback)(()=>{l(r)},[r,l]);return(0,lU.jsxs)(lY.kC,{as:"label",align:"center",children:[(0,lU.jsx)(lY.Y8,{ref:t,checked:s===r,onChange:d,onFocus:a,readOnly:o,customValidity:n,name:i}),(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:r.title})})]})});function OI(e){let{validationError:t,elementProps:n}=e;return(0,lU.jsx)(lY.oi,{...n,customValidity:t,"data-testid":"string-input"})}let OR=(e,t)=>{if("function"==typeof e)throw Error('Schema type "'.concat((null==t?void 0:t.name)||"<not-found>","\"'s `validation` was not run though `inferFromSchema`"));return e?Array.isArray(e)?e:[e]:[]};function OF(e,t){for(let n of OR(null==e?void 0:e.validation,e))for(let e of n._rules)if(e.flag===t)return e;return null}function OD(e){let{schemaType:t,validationError:n,elementProps:i}=e,r=OF(t,"min"),l=OF(t,"integer"),a=OF(t,"precision"),o="number"==typeof(null==r?void 0:r.constraint)&&(null==r?void 0:r.constraint)>=0,s=l||(null==a?void 0:a.constraint)===0;return(0,lU.jsx)(lY.oi,{...i,type:"number",step:"any",inputMode:o?s?"numeric":"decimal":"text",customValidity:n,placeholder:t.placeholder,pattern:o?"[d]*":void 0,max:Number.MAX_SAFE_INTEGER,min:Number.MIN_SAFE_INTEGER,"data-testid":"number-input"})}var OZ=Object.freeze,OL=Object.defineProperty,Oq=(e,t)=>
1OZ(OL(e,"raw",{value:OZ(t||e.slice())}));let ON=(0,aW.ZP)(lY.xu)(rl||(rl=Oq(["\n align-self: center;\n"]))),OV=(0,aW.ZP)(lY.xu)(ra||(ra=Oq(["\n line-height: 0;\n"])));function OU(e){let{fieldNames:t,onChange:n,readOnly:i,value:r}=e,l=t.length,a=(0,lK.useCallback)(e=>{n(mD([e]))},[n]);return(0,lU.jsxs)(mH,{status:"warning",title:(0,lU.jsxs)(lU.Fragment,{children:[1===l&&(0,lU.jsx)(lU.Fragment,{children:"Unknown field found"}),l>1&&(0,lU.jsx)(lU.Fragment,{children:"Unknown fields found"})]}),children:[(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:1===l?(0,lU.jsx)(lU.Fragment,{children:"Encountered a field that is not defined in the schema."}):(0,lU.jsxs)(lU.Fragment,{children:["Encountered ",l," fields that are not defined in the schema."]})}),(0,lU.jsxs)(we,{marginTop:4,open:be,title:(0,lU.jsx)(lU.Fragment,{children:"Developer info"}),children:[(0,lU.jsx)(lY.xu,{marginBottom:3,children:(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:1===l?(0,lU.jsx)(lU.Fragment,{children:"This field is not defined in the schema, which could mean that the field definition has been removed or that someone else has added it to their own local project and have not deployed their changes yet."}):(0,lU.jsx)(lU.Fragment,{children:"These fields are not defined in the documentâs schema, which could mean that the field definitions have been removed or that someone else has added them to their own local project and have not deployed their changes yet."})})}),(0,lU.jsx)(lY.Kq,{as:"ul",space:3,children:t.map(e=>(0,lU.jsx)(OB,{fieldName:e,onUnsetClick:a,readOnly:i,value:null==r?void 0:r[e]},e))})]})]})}function OB(e){let{fieldName:t,onUnsetClick:n,readOnly:i,value:r}=e,l=(0,lK.useCallback)(()=>{n(t)},[t,n]);return(0,lU.jsx)(lY.Zb,{as:"li",padding:3,radius:2,shadow:1,tone:"caution",children:(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsxs)(lY.Zb,{border:!0,radius:1,children:[(0,lU.jsx)(lY.Zb,{borderBottom:!0,padding:3,children:(0,lU.jsx)(lY.EK,{weight:"medium",children:t})}),(0,lU.jsx)(lY.xu,{overflow:"auto",padding:3,children:(0,lU.jsx)(lY.EK,{language:"json",children:JSON.stringify(r,null,2)})})]}),i&&(0,lU.jsxs)(lY.xv,{as:"p",muted:!0,size:1,children:["This field is ",(0,lU.jsx)("strong",{children:"read only"})," according to the documentâs schema and cannot be unset. If you want to be able to unset this in Studio, make sure you remove the"," ",(0,lU.jsx)("code",{children:"readOnly"})," field from the enclosing type in the schema."]}),!i&&(0,lU.jsx)(lY.zx,{icon:a0.XHJ,onClick:l,tone:"critical",text:(0,lU.jsx)(lU.Fragment,{children:"Remove field"})})]})})}var OK=Object.freeze,OH=Object.defineProperty;let OW=(0,aW.ZP)(lY.Zb)(ro||(ro=OK(OH(ee=["\n margin-bottom: ","px;\n padding-bottom: ","px;\n"],"raw",{value:OK(ee.slice())}))),e=>{let{$level:t,theme:n}=e;return 0===t?0:-1*n.sanity.space[5]},e=>{let{$level:t,theme:n}=e;return n.sanity.space[4]}),O$=(0,lK.forwardRef)(function(e,t){let{onClick:n}=e,i=lK.useCallback(()=>{null==n||n(e.name)},[e.name,n]);return(0,lU.jsx)(lY.OK,{"data-testid":"group-tab-".concat(name),size:1,id:"".concat(e.name,"-tab"),label:e.title,ref:t,...e,onClick:i})}),OX=e=>{let{name:t,title:n,...i}=e,{selected:r}=e;return(0,lU.jsx)("option",{title:n,value:t,id:"".concat(t,"-tab"),"aria-controls":i["aria-controls"],"data-testid":"group-select-".concat(t),"aria-selected":r?"true":"false",children:n||t})};var OG=Object.freeze,OY=Object.defineProperty;let OJ=(0,aW.ZP)(lY.iX)(rs||(rs=OG(OY(et=["\n /* Hide on small screens */\n &[data-eq-max~='0'] [data-ui='TabList'] {\n display: none;\n }\n\n /* Hide on medium to large screens */\n [data-ui='Select'] {\n display: none;\n }\n\n /* Show on small screens */\n &[data-eq-max~='0'] [data-ui='Select'] {\n display: block;\n }\n"],"raw",{value:OG(et.slice())})))),OQ=e=>{let{inputId:t,groups:n,onClick:i,shouldAutoFocus:r=!0,disabled:l}=e;return(0,lU.jsx)(lY.td,{space:2,"data-testid":"field-group-tabs",children:n.map(e=>(0,lU.jsx)(O$,{"aria-controls":"".concat(t,"-field-group-fields"),autoFocus:r&&e.selected,disabled:l||e.disabled,icon:null==e?void 0:e.icon,name:e.name,onClick:i,selected:!!e.selected,title:e.title||e.name},"".concat(t,"-").concat(e.name,"-tab")))})},O0=e=>{var t;let{disabled:n,groups:i,inputId:r,onSelect:l,shouldAutoFocus:a=!0}=e,o=(0,lK.useCallback)(e=>{l(e.currentTarget.value)},[l]);return(0,lU.jsx)(lY.Ph,{"aria-label":"Field groups",autoFocus:a,"data-testid":"field-group-select",disabled:n,fontSize:2,muted:!0,onChange:o,value:null==(t=i.find(e=>e.selected))?void 0:t.name,children:i.map(e=>(0,lU.jsx)(OX,{"aria-controls":"".concat(r,"-field-group-fields"),disabled:e.disabled,name:e.name,selected:!!e.selected,title:e.title||e.name},"".concat(r,"-").concat(e.name,"-tab")))})},O1=lK.memo(function(e){let{disabled:t=!1,onClick:n,...i}=e,r=(0,lK.useCallback)(e=>{null==n||n(e)},[n]);return(0,lU.jsxs)(OJ,{"data-testid":"field-group-root",children:[(0,lU.jsx)(OQ,{...i,disabled:t,onClick:r}),(0,lU.jsx)(O0,{...i,disabled:t,onSelect:r})]})}),O2=(0,lK.memo)(function(e){let{schemaType:t,groups:n,members:i,onChange:r,renderAnnotation:l,renderBlock:a,renderInlineBlock:o,renderInput:s,renderField:d,renderItem:c,renderPreview:u,level:p,value:h,id:f,onFieldGroupSelect:m}=e,{columns:g}=t.options||{},x=(0,lK.useMemo)(()=>
1{if(!t.fields)return null;let e=t.fields.map(e=>e.name),n=Object.keys(h||{}).filter(t=>!t.startsWith("_")&&!e.includes(t));return 0===n.length?null:(0,lU.jsx)(OU,{fieldNames:n,value:h,onChange:r})},[r,t.fields,h]),v=(0,lK.useCallback)(()=>(0,lU.jsx)(kM,{members:i,renderAnnotation:l,renderBlock:a,renderField:d,renderInlineBlock:o,renderInput:s,renderItem:c,renderPreview:u}),[i,l,a,d,o,s,c,u]);return 0===i.length?null:(0,lU.jsxs)(lY.Kq,{space:5,children:[n.length>0?(0,lU.jsx)(OW,{$level:p,"data-testid":"field-groups",children:(0,lU.jsx)(O1,{groups:n,inputId:f,onClick:m,shouldAutoFocus:!1})}):null,g?(0,lU.jsx)(lY.rj,{columns:g,gap:4,marginTop:1,children:v()}):v(),x]})});function O3(e){let{date:t,focused:n,isCurrentMonth:i,isToday:r,onSelect:l,selected:a}=e,o=(0,lK.useCallback)(()=>{l(t)},[t,l]);return(0,lU.jsx)("div",{"aria-selected":a,"data-ui":"CalendarDay",children:(0,lU.jsx)(lY.Zb,{"aria-label":t.toDateString(),"aria-pressed":a,as:"button",__unstable_focusRing:!0,"data-weekday":!0,"data-focused":n?"true":"",role:"button",tabIndex:-1,onClick:o,padding:3,radius:2,selected:a,tone:r||a?"primary":"default",children:(0,lU.jsx)(lY.xv,{muted:!a&&!i,style:{textAlign:"center"},weight:i?"medium":"regular",children:t.getDate()})})})}let O4=["January","February","March","April","May","June","July","August","September","October","November","December"],O5=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],O6=sW()(0,24),O8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],O9=[1,2,3,4,5,6],O7=e=>{let t=(0,oy.Z)(e);return(0,oj.Z)({start:t,end:(0,ow.Z)(t)})},ze=e=>e.map(e=>[e,...O9.map(t=>(0,ok.Z)(e,t))]),zt=e=>ze(O7(e)).map(e=>({number:(0,oC.Z)(e[0]),days:e}));function zn(e){return(0,lU.jsx)(lY.xu,{"aria-hidden":e.hidden||!1,"data-ui":"CalendarMonth",children:(0,lU.jsxs)(lY.rj,{gap:1,style:{gridTemplateColumns:"repeat(7, minmax(44px, 46px))"},children:[O5.map(e=>(0,lU.jsx)(lY.xu,{paddingY:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"medium",style:{textAlign:"center"},children:e})},e)),zt(e.date).map((t,n)=>t.days.map((t,i)=>{let r=e.focused&&(0,o_.Z)(t,e.focused),l=e.selected&&(0,o_.Z)(t,e.selected),a=(0,o_.Z)(t,new Date),o=e.focused&&(0,oS.Z)(t,e.focused);return(0,lU.jsx)(O3,{date:t,focused:r,isCurrentMonth:o,isToday:a,onSelect:e.onSelect,selected:l},"".concat(n,"-").concat(i))}))]})})}let zi={dayPresets:!1,timePresets:!1},zr=lK.forwardRef(function(e,t){let{onChange:n,onBlur:i,onKeyPress:r,value:l,...a}=e,[o,s]=lK.useState(),d=lK.useCallback(e=>{s(e.currentTarget.value)},[]),c=lK.useCallback(e=>{let t=e.currentTarget.value;t!=="".concat(l)&&n&&n(e),s(void 0)},[n,l]),u=lK.useCallback(e=>{c(e),i&&i(e)},[c,i]),p=lK.useCallback(e=>{"Enter"===e.key&&c(e),r&&r(e)},[c,r]);return(0,lU.jsx)(lY.oi,{...a,"data-testid":"date-input",ref:t,value:void 0===o?l:o,onChange:d,onBlur:u,onKeyPress:p})}),zl=e=>{let{onChange:t,...n}=e,i=lK.useCallback(e=>{let n=parseInt(e.currentTarget.value,10);isNaN(n)||t(n)},[t]);return(0,lU.jsx)(zr,{...n,onChange:i,inputMode:"numeric"})},za=(0,lU.jsx)("span",{"data-preserve-focus":!0,style:{overflow:"hidden",position:"absolute",outline:"none"},tabIndex:-1}),zo=(0,lK.forwardRef)(function(e,t){let{selectTime:n,onFocusedDateChange:i,selectedDate:r=new Date,focusedDate:l=r,timeStep:a=1,onSelect:o,...s}=e,d=(0,lK.useCallback)(e=>i(e),[i]),c=(0,lK.useCallback)(e=>d((0,oT.Z)((0,oE.Z)(l,e),1)),[l,d]),u=(0,lK.useCallback)(e=>c(Number(e.currentTarget.value)),[c]),p=(0,lK.useCallback)(e=>d((0,oP.Z)(l,e)),[l,d]),h=(0,lK.useCallback)(e=>d((0,oA.Z)(l,e)),[l,d]),f=(0,lK.useCallback)(e=>{o((0,oO.Z)((0,oz.Z)(e,r.getHours()),r.getMinutes()))},[o,r]),m=(0,lK.useCallback)(e=>{let t=Number(e.currentTarget.value);o((0,oO.Z)(r,t))},[o,r]),g=(0,lK.useCallback)(e=>{let t=Number(e.currentTarget.value);o((0,oz.Z)(r,t))},[o,r]);(0,lK.useCallback)((e,t)=>{o((0,oz.Z)((0,oO.Z)(r,t),e))},[o,r]);let x=(0,lY.ts)(t),v=(0,lK.useCallback)(()=>{var e,t;null==(t=null==(e=x.current)?void 0:e.querySelector('[data-focused="true"]'))||t.focus()},[x]),b=(0,lK.useCallback)(e=>{var t,n;if(O8.includes(e.key)){if(e.preventDefault(),e.target.hasAttribute("data-calendar-grid")){v();return}"ArrowUp"===e.key&&i((0,ok.Z)(l,-7)),"ArrowDown"===e.key&&i((0,ok.Z)(l,7)),"ArrowLeft"===e.key&&i((0,ok.Z)(l,-1)),"ArrowRight"===e.key&&i((0,ok.Z)(l,1)),null==(n=null==(t=x.current)?void 0:t.querySelector("[data-preserve-focus]"))||n.focus()}},[x,v,i,l]);(0,lK.useEffect)(()=>{v()},[v]),(0,lK.useEffect)(()=>{var e;
1let t=null==(e=document.activeElement)?void 0:e.matches("[data-calendar-grid], [data-calendar-grid] [data-preserve-focus]");t&&v()},[x,v,l]),(0,lK.useCallback)(()=>f((0,ok.Z)(new Date,-1)),[f]),(0,lK.useCallback)(()=>f(new Date),[f]),(0,lK.useCallback)(()=>f((0,ok.Z)(new Date,1)),[f]);let y=(0,lK.useCallback)(()=>o(new Date),[o]);return(0,lU.jsxs)(lY.xu,{"data-ui":"Calendar",...s,ref:x,children:[(0,lU.jsxs)(lY.xu,{padding:2,children:[zi.dayPresets,(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(zs,{moveFocusedDate:p,onChange:u,value:null==l?void 0:l.getMonth()})}),(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(zd,{moveFocusedDate:p,onChange:h,value:l.getFullYear()})})]}),(0,lU.jsxs)(lY.xu,{"data-calendar-grid":!0,onKeyDown:b,marginTop:2,overflow:"hidden",tabIndex:0,children:[(0,lU.jsx)(zn,{date:l,focused:l,onSelect:f,selected:r}),za]})]}),n&&(0,lU.jsxs)(lY.xu,{padding:2,style:{borderTop:"1px solid var(--card-border-color)"},children:[(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsxs)(lY.kC,{align:"center",flex:1,children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.Ph,{"aria-label":"Select hour",value:null==r?void 0:r.getHours(),onChange:g,children:O6.map(e=>(0,lU.jsx)("option",{value:e,children:"".concat(e).padStart(2,"0")},e))})}),(0,lU.jsx)(lY.xu,{paddingX:1,children:(0,lU.jsx)(lY.xv,{children:":"})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.Ph,{"aria-label":"Select minutes",value:null==r?void 0:r.getMinutes(),onChange:m,children:sW()(0,60,a).map(e=>(0,lU.jsx)("option",{value:e,children:"".concat(e).padStart(2,"0")},e))})})]}),(0,lU.jsx)(lY.xu,{marginLeft:2,children:(0,lU.jsx)(lY.zx,{text:"Set to current time",mode:"bleed",onClick:y})})]}),zi.timePresets]})]})});function zs(e){let{moveFocusedDate:t,onChange:n,value:i}=e,r=(0,lK.useCallback)(()=>t(-1),[t]),l=(0,lK.useCallback)(()=>t(1),[t]);return(0,lU.jsxs)(lY.kC,{flex:1,children:[(0,lU.jsx)(lY.zx,{"aria-label":"Go to previous month",onClick:r,mode:"bleed",icon:a0.wyc,paddingX:2,radius:0}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.Ph,{radius:0,value:i,onChange:n,children:O4.map((e,t)=>(0,lU.jsx)("option",{value:t,children:e},t))})}),(0,lU.jsx)(lY.zx,{"aria-label":"Go to next month",mode:"bleed",icon:a0.XCv,onClick:l,paddingX:2,radius:0})]})}function zd(e){let{moveFocusedDate:t,onChange:n,value:i}=e,r=(0,lK.useCallback)(()=>t(-12),[t]),l=(0,lK.useCallback)(()=>t(12),[t]);return(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.zx,{"aria-label":"Previous year",onClick:r,mode:"bleed",icon:a0.wyc,paddingX:2,radius:0}),(0,lU.jsx)(zl,{value:i,onChange:n,radius:0,style:{width:65}}),(0,lU.jsx)(lY.zx,{"aria-label":"Next year",onClick:l,mode:"bleed",icon:a0.XCv,paddingX:2,radius:0})]})}let zc=lK.forwardRef(function(e,t){let{value:n=new Date,onChange:i,...r}=e,[l,a]=lK.useState(),o=lK.useCallback(e=>{i(e),a(void 0)},[i]);return(0,lU.jsx)(zo,{...r,ref:t,selectedDate:n,onSelect:o,focusedDate:l||n,onFocusedDateChange:a})}),zu=(0,lK.forwardRef)(function(e,t){let{value:n,inputValue:i,onInputChange:r,onChange:l,selectTime:a,timeStep:o,...s}=e,[d,c]=(0,lK.useState)(null),u=(0,lY.ts)(t),p=(0,lK.useRef)(null),[h,f]=(0,lK.useState)(!1);(0,lY.O8)(()=>f(!1),[d]);let m=(0,lK.useCallback)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[u]),g=(0,lK.useCallback)(e=>{"Escape"===e.key&&f(!1)},[]),x=(0,lK.useCallback)(()=>f(!0),[]),v=(0,lU.jsx)(lY.xu,{padding:1,children:(0,lU.jsx)(lY.zx,{ref:p,icon:a0.Que,mode:"bleed",padding:2,onClick:x,style:{display:"block"},"data-testid":"select-date-button"})});return(0,lU.jsx)(zr,{ref:u,...s,value:i,onChange:r,suffix:h?(0,lU.jsx)(lY.li,{zOffset:1e3,children:(0,lU.jsx)(lY.J2,{constrainSize:!0,"data-testid":"date-input-dialog",portal:!0,content:(0,lU.jsx)(lY.xu,{overflow:"auto",children:(0,lU.jsx)(a2.ZP,{onDeactivation:m,children:(0,lU.jsx)(zc,{selectTime:a,timeStep:o,onKeyUp:g,value:n,onChange:l})})}),open:!0,placement:"bottom",ref:c,radius:2,children:v})}):v})}),zp=new Date,zh=lK.forwardRef(function(e,t){let{id:n,deserialize:i,formatInputValue:r,onChange:l,parseInputValue:a,placeholder:o,readOnly:s,selectTime:d,serialize:c,timeStep:u,value:p,...h}=e,[f,m]=lK.useState(null);(0,lK.useEffect)(()=>{m(null)},[p]);let g=lK.useCallback(e=>{let t=e.currentTarget.value,n=""===t?null:a(t);null===n?(l(null),void 0===p&&f&&m(null)):n.isValid?l(c(n.date)):m(t)},[a,l,p,f,c]),x=lK.useCallback(e=>{l(e?c(e):null)},[c,l]),v=(0,lY.ts)(t),b=f?a(f):p?i(p):null,y=f||((null==b?void 0:b.isValid)?r(b.date):p);return s?(0,lU.jsx)(lY.oi,{value:y,readOnly:!0}):(0,lU.jsx)(zu,{...h,id:n,selectTime:d,timeStep:u,placeholder:o||"e.g. ".concat(r(zp)),ref:v,value:null==b?void 0:b.date,inputValue:y||"",readOnly:!!s,onInputChange:g,onChange:x,customValidity:null==b?void 0:b.error})});function zf(e){return e.toISOString()}function zm(e){let t=new Date(e);return t instanceof Date&&!isNaN(t.valueOf())?{isValid:!0,date:t}:{isValid:!1,error:'Invalid date value: "'.concat(e,'"')}}let zg="YYYY-MM-DD",zx=e=>(0,sb.Q)(e,zg),zv=e=>(0,sb.W)(e,zg);var zb=Object.freeze,zy=Object.defineProperty;let zj=(0,aW.ZP)(lY.Kx)(rd||(rd=zb(zy(en=["\n &[data-as='textarea'] {\n resize: vertical;\n }\n"],"raw",{value:zb(en.slice())})))),zw=(e,t)=>{var n;let i=null==(n=t.options)?void 0:n.maxLength;return e?sX()(e,{truncate:"number"==typeof i?i:200,symbols:!0}):""};
1async function zk(e,t,n){var i;if(!e)return e;let r=(null==(i=t.options)?void 0:i.slugify)||zw;return r(e,t,n)}async function zC(e,t,n){return"function"==typeof e?e(t,n):lB.U2(t,e)}let z_={document:O2,object:O2,array:function(e){let t=(0,lK.useMemo)(()=>{var t;return Array.isArray(null==(t=e.schemaType.options)?void 0:t.list)},[e.schemaType]);return t?(0,lU.jsx)(Po,{...e}):(0,lV.d7)(e.schemaType)?(0,lU.jsx)(On,{...e}):(0,lU.jsx)(OT,{...e})},boolean:function(e){var t;let{id:n,value:i,schemaType:r,readOnly:l,elementProps:a,validation:o}=e,s=(null==(t=r.options)?void 0:t.layout)||"switch",d="boolean"!=typeof i,c=i||!1,u="checkbox"===s?lY.XZ:lY.rs;return(0,lU.jsx)(lY.Zb,{border:!0,"data-testid":"boolean-input",radius:1,tone:l?"transparent":void 0,children:(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(OV,{padding:3,children:(0,lU.jsx)(u,{label:r.title,...a,checked:c,disabled:l,indeterminate:d,style:{margin:-4}})}),(0,lU.jsx)(lY.xu,{flex:1,paddingY:3,children:(0,lU.jsx)(jp,{description:r.description,inputId:n,validation:o,title:r.title})}),(0,lU.jsx)(ON,{paddingX:3,paddingY:1,children:(0,lU.jsx)(jI,{maxAvatars:1,position:"top"})})]})})},number:OD,text:function(e){let{schemaType:t,validationError:n,value:i,elementProps:r}=e;return(0,lU.jsx)(zj,{customValidity:n,value:i||"",placeholder:t.placeholder,rows:"number"==typeof t.rows?t.rows:10,...r})},email:function(e){let{validationError:t,elementProps:n}=e;return(0,lU.jsx)(lY.oi,{...n,type:"email",inputMode:"email",customValidity:t})},datetime:function(e){let{onChange:t,schemaType:n,value:i,elementProps:r}=e,{dateFormat:l,timeFormat:a,timeStep:o}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dateFormat:e.dateFormat||"YYYY-MM-DD",timeFormat:e.timeFormat||"HH:mm",timeStep:"timeStep"in e&&Number(e.timeStep)||1,calendarTodayLabel:e.calendarTodayLabel||"Today"}}(n.options),s=(0,lK.useCallback)(e=>{let n=e;null!==n&&o>1&&(n=function(e,t){if(!t||1===t)return e;let n=(0,oM.Z)(e),i=(0,oI.Z)(n),r=i%t;return 0!==r?zf((0,oO.Z)(n,i-r)):zf(n)}(n,o)),t(null===n?mD():mF(n))},[t,o]),d=lK.useCallback(e=>(0,sb.W)(e,"".concat(l," ").concat(a)),[l,a]),c=lK.useCallback(e=>(0,sb.Q)(e,"".concat(l," ").concat(a)),[l,a]);return(0,lU.jsx)(zh,{...r,onChange:s,deserialize:zm,formatInputValue:d,parseInputValue:c,placeholder:n.placeholder,selectTime:!0,serialize:zf,timeStep:o,value:i})},date:function(e){let{readOnly:t,onChange:n,schemaType:i,elementProps:r,value:l}=e,{dateFormat:a}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dateFormat:e.dateFormat||zg,calendarTodayLabel:e.calendarTodayLabel||"Today"}}(i.options),o=(0,lK.useCallback)(e=>{n(null===e?mD():mF(e))},[n]),s=(0,lK.useCallback)(e=>(0,sb.W)(e,a),[a]),d=(0,lK.useCallback)(e=>(0,sb.Q)(e,a),[a]);return(0,lU.jsx)(zh,{...r,deserialize:zx,formatInputValue:s,onChange:o,parseInputValue:d,placeholder:i.placeholder,readOnly:t,selectTime:!1,serialize:zv,value:l})},url:function(e){var t,n;let{schemaType:i,validationError:r,elementProps:l}=e,a=OF(i,"uri"),o=(null==(n=null==(t=null==a?void 0:a.constraint)?void 0:t.options)?void 0:n.allowRelative)?"text":"url";return(0,lU.jsx)(lY.oi,{type:o,inputMode:"url",customValidity:r,...l})},image:function(e){var t;let n=null==(t=e.schemaType.options)?void 0:t.sources,{image:i}=mY().__internal,r=UY(),l=Ni(fC),a=mY(),o=a.__internal.image.directUploads,s=(0,lK.useCallback)((e,t)=>o?wX(e,t):null,[o]),d=lK.useMemo(()=>n||i.assetSources,[i,n]),c=lK.useMemo(()=>o1()(l),[l]),u=(0,lK.useCallback)(e=>wI(r,e),[r]);return(0,lU.jsx)(T7,{...e,client:l,assetSources:d,directUploads:i.directUploads,imageUrlBuilder:c,observeAsset:u,resolveUploader:s})},file:function(e){var t;let n=null==(t=e.schemaType.options)?void 0:t.sources,i=UY(),{file:r}=mY().__internal,l=Ni(fC),a=(0,lK.useCallback)((e,t)=>r.directUploads?wX(e,t):null,[r.directUploads]),o=(0,lK.useMemo)(()=>n||r.assetSources,[r,n]),s=(0,lK.useCallback)(e=>wI(i,e),[i]);return(0,lU.jsx)(Sq,{...e,client:l,assetSources:o,directUploads:r.directUploads,observeAsset:s,resolveUploader:a})},string:OI,slug:function(e){var t;let{getDocument:n}=mY().__internal,{path:i,value:r,schemaType:l,validation:a,onChange:o,readOnly:s,elementProps:d}=e,c=null==(t=l.options)?void 0:t.source,u=(0,lK.useMemo)(()=>a.filter(e=>"error"===e.level),[a]),p=function(){let{getClient:e}=Iw(),t=Nu(),n=Nj(),i=Nc(),r=Na();return(0,lK.useMemo)(()=>
1({projectId:i,dataset:r,getClient:e,schema:t,currentUser:n}),[e,t,n,i,r])}(),h=(0,lK.useCallback)(e=>{if(!e){o(mN.from(mD([])));return}o(mN.from([mI({_type:l.name}),mF(e,["current"])]))},[o,l.name]),[f,m]=function(e,t){let[n,i]=lK.useState(null),r=lK.useRef(0),l=lK.useCallback(t=>{let n=++r.current;i({status:"pending"}),Promise.resolve().then(()=>e(t)).then(e=>{n===r.current&&i({status:"complete",result:e})},e=>{n===r.current&&i({status:"error",error:e})})},[e,...t]);return[n,l]}(()=>{if(!c)return Promise.reject(Error('Source is missing. Check source on type "'.concat(l.name,'" in schema')));let e=n()||{_type:l.name},t=function(e,t,n){let i=e.slice(0,-1),r=lB.U2(t,i);return{parentPath:i,parent:r,...n}}(i,e,p);return zC(c,e,t).then(e=>zk(e||"",l,t)).then(e=>h(e))},[c,n,l,i,p,h]),g=(null==f?void 0:f.status)==="pending",x=lK.useCallback(e=>h(e.currentTarget.value),[h]);return(0,lU.jsx)(lY.Kq,{space:3,children:(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsxs)(lY.xu,{flex:1,children:[(0,lU.jsx)(lY.oi,{customValidity:u.length>0?u[0].message:"",disabled:g,onChange:x,value:(null==r?void 0:r.current)||"",readOnly:s,...d}),(null==f?void 0:f.status)==="error"&&(0,lU.jsx)(lY.Zb,{padding:2,tone:"critical",children:f.error.message})]}),c&&(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.zx,{mode:"ghost",type:"button",disabled:s||g,onClick:m,text:(null==f?void 0:f.status)==="pending"?"Generatingâ¦":"Generate"})})]})})},crossDatasetReference:function(e){let{path:t,schemaType:n}=e,i=Iw(),r=i.getClient(fC),l=UY(),a=i.getClient,o=(0,lK.useMemo)(()=>r.withConfig({dataset:n.dataset,apiVersion:"2022-03-07",ignoreBrowserTokenWarning:!0}).clone(),[r,n.dataset]),s=ke([]),d=function(e){let t=(0,lK.useRef)(e);return t.current=e,t}(s),c=(0,lK.useCallback)(e=>(0,at.D)(Ez(n.options,d.current,t,a)).pipe((0,ay.z)(t=>{let{filter:i,params:r}=t;return function(e,t,n,i){let r=mS(n.to.map(e=>({name:e.type,__experimental_search:e.__experimental_search})),e,i);return r(t,{includeDrafts:!1}).pipe((0,ad.U)(e=>e.map(e=>e.hit)),(0,ad.U)(cr),(0,ad.U)(e=>e.map(e=>({id:e.id,type:e.type,published:e.published}))))}(o,e,n,{...n.options,filter:i,params:r,tag:"search.cross-dataset-reference"})}),(0,au.K)(e=>{var t;let i=e.details&&"queryParseError"===e.details.type;return(null==(t=n.options)?void 0:t.filter)&&i&&(e.message='Invalid reference filter, please check the custom "filter" option'),(0,l5._)(e)})),[o,d,t,n,a]),u=(0,lK.useMemo)(()=>(function(e){let{client:t,documentPreviewStore:n}=e,{dataset:i,projectId:r}=t.config(),l=i&&r?{dataset:i,projectId:r}:void 0;return function(e,i){return(e._type?(0,lQ.of)(e):n.observeDocumentTypeFromId(e._id,l).pipe((0,ad.U)(t=>({_id:e._id,_type:t})))).pipe((0,ap.w)(r=>{if(!r._type)return(function(e,t){let n={uri:e.getDataUrl("doc",t),json:!0,query:{excludeContent:"true"},tag:"".concat("cross-dataset-refs",".availability")};return e.observable.request(n).pipe((0,ad.U)(e=>{let n=o9()(e.omitted||[],e=>e.id),i=n[t];return i?"existence"===i.reason?EO:"permission"===i.reason?EA:null:EP}))})(t,e._id).pipe((0,ad.U)(t=>({id:e._id,type:void 0,availability:t,preview:{published:void 0}})));let a=i.to.find(e=>e.type===r._type),o=[...fW(null==a?void 0:a.preview)||[],["_updatedAt"],["_createdAt"]],s=n.observePaths(e,o,l).pipe((0,ad.U)(e=>e?ml(e,a):e));return(0,ae.a)([s]).pipe((0,ad.U)(t=>{let[n]=t;return{type:r._type,id:e._id,availability:EP,preview:{published:cc(n)?n:void 0}}}))}))}})({client:o,documentPreviewStore:l}),[o,l]);return(0,lU.jsx)(EE,{...e,getReferenceInfo:u,onSearch:c})}};function zS(e){var t,n,i,r;if(null==(t=e.components)?void 0:t.input)return e.components.input;let l=fM("array",e)?1===(n=e).of.length&&fM("string",n.of[0])&&(null==(i=n.options)?void 0:i.layout)==="tags"?AX:(null==(r=n.options)?void 0:r.list)?Po:n.of.every(e=>OE.includes(e.jsonType))?On:n.of.some(e=>fM("block",e))?AZ:OT:fM("reference",e)?E8:fM("string",e)?k$(e,"list")?OO:OI:fM("number",e)?k$(e,"list")?OO:OD:void 0;if(l)return l;let a=kQ(e,new Set),o=a.reduce((e,t)=>(e[t.name]=t,e),{}),s=Object.values(o).find(e=>z_[e.name]);if(s)return z_[s.name];throw Error("Could not find input component for schema type `".concat(e.name,"`"))}function zT(e){var t;return(null==(t=e.components)?void 0:t.preview)?e.components.preview:fF}
1function zE(e){let{componentResolver:t,componentProps:n}=e;if(!n.schemaType)throw Error("the `schemaType` property must be defined");let i=t(n.schemaType),r=(0,lK.useCallback)(e=>{var n;if(!(null==(n=e.schemaType)?void 0:n.type))throw Error("Attempted to render form component of non-existent parent type");let{components:i,...r}=e.schemaType,l=t(r);return(0,lK.createElement)(l,e)},[t]);return(0,lK.createElement)(i,{...n,renderDefault:r})}function zP(e){return zE({componentProps:e,componentResolver:zS})}function zA(e){return zE({componentProps:e,componentResolver:k4})}function zO(e){return zE({componentProps:e,componentResolver:kK})}function zz(e){return zE({componentProps:e,componentResolver:zT})}function zM(e){return zE({componentProps:e,componentResolver:_q})}function zI(e){return zE({componentProps:e,componentResolver:_N})}function zR(e){return zE({componentProps:e,componentResolver:_V})}function zF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.input}function zD(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.field}function zZ(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.preview}function zL(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.item}function zq(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.block}function zN(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.inlineBlock}function zV(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.annotation}function zU(){return fz({defaultComponent:zz,pick:zZ})}function zB(e){let t=zU();return(0,lU.jsx)(fH,{...e,component:t})}let zK=e=>{let{asset:t,assetType:n,referringDocuments:i}=e,r=i.length,l=t.originalFilename?(0,lU.jsx)("strong",{children:t.originalFilename}):"this ".concat(n);return r>0?(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.Zb,{borderBottom:!0,marginTop:2,paddingBottom:2,marginBottom:1,children:(0,lU.jsxs)(lY.xv,{as:"h2",size:[1,1,2,2],weight:"regular",textOverflow:"ellipsis",children:[r," ",1===r?"document is":"documents are"," using ",l]})}),i.map(e=>(0,lU.jsx)(zH,{document:e},e._id))]}):(0,lU.jsxs)(lY.xv,{size:[1,1,2,2],as:"h2",weight:"regular",children:["No documents are using ",l]})},zH=e=>{let{document:t}=e,n=Nu(),i=(0,lK.useCallback)(e=>(0,lU.jsx)(a1.nR,{...e,params:{id:t._id,type:t._type},intent:"edit"}),[t]);return(0,lU.jsx)(lY.Zb,{as:i,paddingY:2,paddingX:1,radius:2,"data-as":"a",tabIndex:0,children:(0,lU.jsx)(lY.kC,{align:"center",gap:2,children:(0,lU.jsx)(zB,{layout:"default",value:{_type:"reference",_ref:t._id},schemaType:n.get(t._type)})})},t._id)},zW={maxWidth:"100%",height:"120px",objectFit:"contain",objectPosition:"center"},z$={gridColumn:"span 1",overflow:"hidden",display:"flex",alignSelf:"center",justifyContent:"center"},zX={height:"100%"},zG=e=>{let{asset:t,assetType:n,hasResults:i=!1}=e,r="image"===n,l=t.originalFilename?(0,lU.jsxs)(lU.Fragment,{children:["The ",n," ",(0,lU.jsx)("strong",{children:t.originalFilename})]}):"this ".concat(n);return i?(0,lU.jsx)(lY.Zb,{tone:"caution",padding:[3,3,4],border:!0,radius:2,marginBottom:3,children:(0,lU.jsxs)(lY.rj,{columns:3,gap:[2,3,4],children:[(0,lU.jsxs)(lY.kC,{gap:[3,4],align:"center",style:{gridColumn:r?"span 2":"span 3"},children:[(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.foC,{})}),(0,lU.jsxs)(lY.xv,{size:1,children:[l," cannot be deleted because it's being used. In order to delete the ",n," you need the remove all uses of it."]})]}),r&&(0,lU.jsx)(lY.Zb,{__unstable_checkered:!0,border:!0,radius:1,style:z$,children:(0,lU.jsx)(lY.kC,{align:"center",justify:"center",style:zX,children:(0,lU.jsx)("img",{src:"".concat(t.url,"?w=200"),style:zW,alt:"Preview of image",referrerPolicy:"strict-origin-when-cross-origin"})})})]})}):(0,lU.jsx)(lY.Zb,{paddingX:[2,3,4],paddingY:[3,3,3,4],children:(0,lU.jsxs)(lY.rj,{columns:3,gap:3,children:[(0,lU.jsx)(lY.kC,{style:{gridColumn:r?"span 2":"span 3"},align:"center",children:(0,lU.jsxs)(lY.xv,{children:["You are about to delete the ",n,t.originalFilename&&(0,lU.jsxs)(lU.Fragment,{children:[" ",(0,lU.jsx)("strong",{children:t.originalFilename})]})," ","and its metadata.",(0,lU.jsx)("br",{}),(0,lU.jsx)("br",{}),"Are you sure?"]})}),r&&(0,lU.jsx)(lY.Zb,{__unstable_checkered:!0,border:!0,radius:1,style:z$,children:(0,lU.jsx)(lY.kC,{align:"center",justify:"center",style:zX,children:(0,lU.jsx)("img",{src:"".concat(t.url,"?w=200"),style:zW,alt:"Preview of image",referrerPolicy:"str
1ict-origin-when-cross-origin"})})})]})})},zY="confirmDelete",zJ="listUsage";function zQ(e){let{asset:t,assetType:n="image",mode:i=zJ,isDeleting:r=!1,onClose:l,onDelete:a}=e,{isLoading:o,referringDocuments:s}=function(e){let t=UJ();return(0,lJ.m2)(()=>t.listenQuery("*[references($docId)] [0...101]",{docId:e},{tag:"use-referring-documents"}).pipe((0,ad.U)(e=>({referringDocuments:e,isLoading:!1})),(0,ag.O)(fA)),[t,e],fA)}(t._id),d=i===zJ?"Documents using ".concat(n):"Delete ".concat(n),[c,u]=(0,lK.useState)(!1),[p,h]=(0,lK.useState)(!0),[f,m]=(0,lK.useState)([]),g=f.length>0,x=i===zJ||g,v=i===zY&&!g,b=i===zY?(0,lU.jsxs)(lY.rj,{padding:2,gap:2,columns:2,children:[(0,lU.jsx)(lY.zx,{mode:"bleed",text:"Cancel",onClick:l}),(0,lU.jsx)(lY.zx,{text:"Delete",tone:"critical",icon:a0.XHJ,onClick:a,loading:r,disabled:!c})]}):void 0;return(0,lK.useEffect)(()=>{let e=s.reduce((e,t)=>t._id.startsWith("drafts.")?e.concat(t._id.slice(7)):e,[]),t=s.filter(t=>!e.includes(t._id));m(t),u(0===t.length&&!o),h(o)},[o,s]),(0,lU.jsxs)(lY.Vq,{__unstable_autoFocus:!p,footer:b,header:d,id:"asset-dialog",onClickOutside:l,onClose:l,width:1,children:[p&&(0,lU.jsx)(lY.xu,{padding:4,children:(0,lU.jsx)(fP,{text:"Loading..."})}),!p&&(0,lU.jsxs)(lY.Kq,{paddingX:v?0:[2,3,4],paddingY:v?0:[3,3,3,4],space:1,children:[i===zY&&(0,lU.jsx)(zG,{asset:t,assetType:n,hasResults:g}),x&&(0,lU.jsx)(zK,{asset:t,referringDocuments:f,assetType:n})]})]})}function z0(e){let{isSelected:t,border:n=!0,onAction:i}=e;return(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{padding:2,mode:n?"ghost":t?"default":"bleed",icon:a0.zGg,tone:n?"default":t?"primary":"default"}),id:"asset-menu",portal:!0,menu:(0,lU.jsxs)(lY.v2,{children:[(0,lU.jsx)(lY.sN,{text:"Show uses",icon:a0.xPt,onClick:()=>{i({type:"showUsage"})}}),(0,lU.jsx)(lY.sN,{text:"Delete",icon:a0.XHJ,tone:"critical",onClick:()=>{i({type:"delete"})}})]}),placement:"right"})}var z1=Object.freeze,z2=Object.defineProperty,z3=(e,t)=>z1(z2(e,"raw",{value:z1(t||e.slice())}));let z4="undefined"!=typeof window&&window.devicePixelRatio?Math.round(window.devicePixelRatio):1,z5=aW.ZP.img(rc||(rc=z3(["\n position: absolute;\n z-index: 1;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: block;\n object-fit: contain;\n"]))),z6=(0,aW.ZP)(lY.Zb)(ru||(ru=z3(["\n position: relative;\n z-index: 1;\n padding-bottom: 100%;\n"]))),z8=aW.ZP.div(rp||(rp=z3(["\n position: relative;\n display: inherit;\n"]))),z9=aW.ZP.div(rh||(rh=z3(["\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n top: 3px;\n right: 3px;\n\n & button[data-selected] {\n display: block;\n }\n\n @media (hover: hover) {\n // If hover is supported, hide the buttons until the user hovers or focuses the asset\n // Use opacity to enable the buttons to still be focusable\n & button {\n opacity: 0;\n }\n\n ",":hover & {\n button {\n opacity: 1;\n }\n }\n\n ",":focus-within & {\n button {\n opacity: 1;\n }\n }\n }\n"])),z8,z8),z7=lK.memo(function(e){let t=Ni(fC),n=(0,lY.pm)(),i=(0,lK.useRef)(),{asset:r,onClick:l,onKeyPress:a,onDeleteFinished:o,isSelected:s}=e,[d,c]=(0,lK.useState)(!1),[u,p]=(0,lK.useState)(!1),[h,f]=(0,lK.useState)(!1);(0,lK.useEffect)(()=>()=>{i.current&&i.current.unsubscribe()},[]);let m=(0,lK.useCallback)(()=>{p(!0)},[p]),g=(0,lK.useCallback)(()=>{c(!1),p(!1)},[c,p]),x=(0,lK.useCallback)(()=>{c(!0)},[c]),v=(0,lK.useCallback)(e=>{n.push({closable:!0,status:"error",title:"Image could not be deleted",description:e.message})},[n]),b=(0,lK.useCallback)(()=>{n.push({status:"success",title:"Image was deleted"})},[n]),y=(0,lK.useCallback)(()=>{f(!0),i.current=t.observable.delete(r._id).subscribe({next:()=>{f(!1),o(r._id),p(!1),b()},error:e=>{f(!1),v(e),console.error("Could not delete asset",e)}})},[r._id,v,b,o,t.observable]),j=(0,lK.useCallback)(e=>{"delete"===e.type&&m(),"showUsage"===e.type&&x()},[m,x]),{originalFilename:w,_id:k,url:C}=r,_=200*Math.max(1,z4),S=C.includes(".gif")?"".concat(C,"?h=").concat(_,"&fit=max&fm=jpg"):"".concat(C,"?h=").concat(_,"&fit=max");return(0,lU.jsxs)(z8,{children:[(0,lU.jsx)(lY.zx,{tone:"primary",selected:s,tabIndex:0,"data-id":k,mode:"ghost",onKeyPress:a,padding:0,style:{padding:2},children:(0,lU.jsxs)(z6,{__unstable_checkered:!0,children:[(0,lU.jsx)(z5,{alt:w,src:S,onClick:l,"data-id":k}),h&&(0,lU.jsx)(fE,{})]})}),(0,lU.jsx)(z9,{children:(0,lU.jsx)(z0,{isSelected:s,onAction:j})}),(d||u)&&(0,lU.jsx)(zQ,{asset:r,mode:u?"confirmDelete":"listUsage",onClose:g,onDelete:y,isDeleting:h})]})}),Me=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],Mt=["B","kiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],Mn=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],Mi=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],Mr=(e,t,n
1)=>{let i=e;return"string"==typeof t||Array.isArray(t)?i=e.toLocaleString(t,n):(!0===t||void 0!==n)&&(i=e.toLocaleString(void 0,n)),i},Ml={"image/bmp":{title:"Bitmap Image"},"image/jpeg":{title:"JPEG Image"},"image/gif":{title:"GIF Image"},"image/vnd.microsoft.icon":{title:"Icon"},"image/png":{title:"PNG Image"},"image/svg+xml":{title:"SVG Image"},"image/webp":{title:"WebP Image"},"image/tiff":{title:"TIFF Image"},"image/heic":{title:"HEIC Image"},"audio/midi":{title:"MIDI Audio"},"audio/midi-x":{title:"MIDI Audio"},"audio/mpeg":{title:"MP3 Audio"},"audio/ogg":{title:"OGG Audio"},"audio/wav":{title:"WAV Audio"},"audio/webm":{title:"WebM Audio"},"audio/aac":{title:"AAC Audio"},"video/x-msvideo":{title:"AVI Video"},"video/mp4":{title:"MP4 Video"},"video/mpeg":{title:"MPEG Video"},"video/ogg":{title:"OGG Video"},"video/webm":{title:"WebM Video"},"video/quicktime":{title:"QuickTime Video"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{title:"Excel Spreadsheet"},"application/vnd.ms-excel":{title:"Excel Spreadsheet"},"text/plain":{title:"Text"},"text/javascript":{title:"JavaScript"},"text/markdown":{title:"Markdown"},"text/csv":{title:"CSV"},"text/css":{title:"CSS"},"application/pdf":{title:"PDF Document"},"application/xml":{title:"XML Document"},"text/xml":{title:"XML Document"},"application/zip":{title:"ZIP Archive"},"application/vnd.rar":{title:"RAR Archive"},"application/x-7z-compressed":{title:"7-zip Archive"},"application/octet-stream":{title:"Binary"}};var Ma=Object.freeze,Mo=Object.defineProperty,Ms=(e,t)=>Ma(Mo(e,"raw",{value:Ma(t||e.slice())}));let Md=aW.ZP.span(rf||(rf=Ms(["\n background-color: transparent;\n flex-shrink: 0;\n"]))),Mc=(0,aW.ZP)(lY.kC)(rm||(rm=Ms([""]))),Mu=(0,aW.ZP)(lY.xv)(rg||(rg=Ms([""]))),Mp=(0,aW.ZP)(lY.Zb)(rv||(rv=Ms(["\n &:hover-within "," {\n --card-muted-fg-color: var(--card-muted-fg-color);\n --card-fg-color: var(--card-fg-color);\n }\n\n ","\n"])),Mu,e=>e.isSelected&&(0,aW.iv)(rx||(rx=Ms(["\n --card-muted-fg-color: var(--card-bg-color);\n --card-fg-color: var(--card-bg-color);\n "])))),Mh=(0,aW.ZP)(lY.zx)(rj||(rj=Ms(["\n box-shadow: none;\n min-width: 0;\n cursor: pointer;\n position: initial;\n\n &:before,\n &:after {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n }\n\n &:before {\n z-index: 0;\n pointer-events: none;\n border-radius: 0.1875rem;\n }\n\n ","\n\n ","\n"])),e=>e.isSelected&&(0,aW.iv)(rb||(rb=Ms(["\n --card-muted-fg-color: var(--card-bg-color);\n --card-fg-color: var(--card-bg-color);\n\n &:before {\n background-color: var(--card-focus-ring-color);\n }\n\n "," {\n --card-muted-fg-color: var(--card-bg-color);\n }\n\n "," {\n --card-muted-fg-color: var(--card-bg-color);\n --card-fg-color: var(--card-bg-color);\n }\n "])),Md,Mc),e=>!e.isSelected&&(0,aW.iv)(ry||(ry=Ms(["\n &:hover:before {\n background-color: var(--card-bg-color);\n }\n\n &:focus:before {\n background-color: var(--card-code-bg-color);\n }\n\n &:focus-within:before {\n background-color: var(--card-bg-color);\n }\n "])))),Mf=(0,aW.ZP)(lY.xv)(rw||(rw=Ms(["\n overflow-wrap: anywhere;\n"]))),Mm={position:"relative"},Mg={flexShrink:0},Mx={minWidth:0},Mv={zIndex:3,marginTop:"-0.5rem",marginBottom:"-0.5rem"},Mb=e=>{let t=Ni(fC),n=(0,lY.pm)(),i=(0,lK.useRef)(),[r,l]=(0,lK.useState)(!1),[a,o]=(0,lK.useState)(!1),[s,d]=(0,lK.useState)(!1),[c,u]=(0,lK.useState)(!1),{asset:p,onClick:h,onKeyPress:f,onDeleteFinished:m,isSelected:g,isMobile:x}=e,{originalFilename:v,_id:b,mimeType:y,size:j,_createdAt:w}=p,k=Ng(w,{agoSuffix:!0}),C=(null==Ml?void 0:Ml[y])?Ml[y].title:function(e){let t=e.replace("x-","").split("/")[1];return t.charAt(0).toUpperCase()+t.slice(1)}(y),_=function(e){let t,{bits:n=!1,binary:i=!1,signed:r=!1,minimumFractionDigits:l,maximumFractionDigits:a,locale:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=e;if(!Number.isFinite(s))throw TypeError("Expected a finite number, got ".concat(typeof s,": ").concat(s));let d=n?i?Mi:Mn:i?Mt:Me;if(r&&0===s)return" 0 ".concat(d[0]);let c=s<0,u=c?"-":r?"+":"";if(c&&(s=-s),void 0!==l&&(t={minimumFractionDigits:l}),void 0!==a&&(t={maximumFractionDigits:a,...t}),s<1){let e=Mr(s,o,t);return"".concat(u+e," ").concat(d[0])}let p=Math.min(Math.floor(i?Math.log(s)/Math.log(1024):Math.log10(s)/3),d.length-1);s/=(i?1024:1e3)**p,t||(s=s.toPrecision(3));
1let h=Mr(Number(s),o,t),f=d[p];return"".concat(u+h," ").concat(f)}(j),S=(v||"").length>37,T=()=>{o(!0)},E=e=>{n.push({closable:!0,status:"error",title:"File could not be deleted",description:e.message})},P=()=>{n.push({status:"success",title:"File was deleted"})},A=()=>{d(!0),i.current=t.observable.delete(p._id).subscribe({next:()=>{d(!1),null==m||m(p._id),o(!1),P()},error:e=>{d(!1),E(e),console.error("Could not delete asset",e)}})},O=()=>{l(!1),o(!1)},z=()=>{l(!0)};return x?(0,lU.jsxs)(lY.Zb,{paddingBottom:2,style:Mm,children:[(0,lU.jsxs)(lY.rj,{columns:4,gap:1,style:{position:"relative",gridTemplateColumns:"1fr 30px",opacity:s?.5:1},children:[(0,lU.jsx)(Mh,{asset:p,mode:"bleed",padding:0,"data-id":b,onClick:h,paddingY:1,children:(0,lU.jsxs)(lY.kC,{gap:2,flex:2,align:"center",children:[(0,lU.jsx)(lY.Zb,{as:Md,padding:2,tone:"transparent",radius:2,children:(0,lU.jsx)(lY.xv,{muted:!0,size:2,style:Mg,children:(0,lU.jsx)(a0.$lS,{})})}),(0,lU.jsx)(lY.xv,{size:1,align:"left",textOverflow:"ellipsis",style:Mx,children:v})]})}),(0,lU.jsx)(lY.kC,{justify:"flex-end",align:"center",paddingRight:1,style:Mv,children:(0,lU.jsx)(lY.zx,{mode:"bleed",fontSize:1,padding:2,onClick:()=>{u(!c)},icon:c?a0.g8U:a0.v4q})})]}),c&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsxs)(lY.rj,{marginTop:3,columns:3,gap:1,children:[(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Size"}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:_})]}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Type"}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:C})]}),(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Date added"}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:k})]})]}),(0,lU.jsxs)(lY.Kq,{space:2,marginTop:3,children:[(0,lU.jsx)(lY.zx,{fontSize:1,tone:"default",mode:"ghost",text:"Show uses",onClick:z,icon:a0.xPt}),(0,lU.jsx)(lY.zx,{fontSize:1,tone:"critical",mode:"ghost",text:"Delete",icon:a0.XHJ,disabled:g,title:g?"Cannot delete current file":"Delete file",onClick:T})]})]}),(r||a)&&(0,lU.jsx)(zQ,{assetType:"file",asset:p,mode:a?"confirmDelete":"listUsage",onClose:O,onDelete:A,isDeleting:s})]}):(0,lU.jsxs)(Mp,{asset:p,paddingBottom:1,style:Mm,radius:0,overflow:"hidden",isSelected:g,"aria-selected":"true",children:[(0,lU.jsxs)(lY.rj,{columns:4,gap:1,"data-id":b,paddingY:1,style:{position:"relative",gridTemplateColumns:"3fr 1fr 1fr 2fr 30px",opacity:s?.5:1},children:[(0,lU.jsx)(Mh,{asset:p,mode:"bleed","data-id":b,onClick:h,padding:0,onKeyPress:f,title:"Select the file ".concat(v),isSelected:g,children:(0,lU.jsxs)(Mc,{gap:2,flex:2,paddingRight:1,align:"center",onClick:h,onKeyPress:f,"data-id":b,title:"Select the file ".concat(v),children:[(0,lU.jsx)(lY.Zb,{as:Md,padding:2,tone:"transparent",radius:2,style:Mg,children:(0,lU.jsx)(lY.xv,{muted:!0,size:2,children:(0,lU.jsx)(a0.$lS,{})})}),S&&(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:v})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:(0,lU.jsx)(lY.xv,{size:1,align:"left",textOverflow:"ellipsis",style:Mx,children:v})}),!S&&(0,lU.jsx)(lY.xv,{size:1,align:"left",textOverflow:"ellipsis",style:Mx,children:v})]})}),(0,lU.jsx)(Mc,{align:"center",children:(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:_})}),(0,lU.jsx)(Mc,{align:"center",children:(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(Mf,{size:1,muted:!0,textOverflow:"ellipsis",children:C})})}),(0,lU.jsx)(Mc,{align:"center",children:(0,lU.jsx)(lY.xv,{as:"time",size:1,muted:!0,dateTime:w,children:k})}),(0,lU.jsx)(Mc,{justify:"flex-end",align:"center",paddingX:1,paddingY:1,style:Mv,children:(0,lU.jsx)(z0,{border:!1,isSelected:!1,onAction:e=>{"delete"===e.type&&T(),"showUsage"===e.type&&z()}})})]}),(r||a)&&(0,lU.jsx)(zQ,{assetType:"file",asset:p,mode:a?"confirmDelete":"listUsage",onClose:O,onDelete:A,isDeleting:s})]})},My={paddingLeft:"2.2rem"},Mj={gridTemplateColumns:"3fr 1fr 1fr 2fr 30px"};function Mw(e){let t=(0,lY.d2)(),n=t<2,{assets:i,onClick:r,onKeyPress:l,onDeleteFinished:a,selectedAssets:o,isLoading:s}=e;return(0,lU.jsxs)(lY.xu,{padding:4,children:[(0,lU.jsx)(lY.Zb,{borderBottom:!0,paddingBottom:2,marginBottom:1,children:n?(0,lU.jsx)(lY.rj,{style:Mj,children:(0,lU.jsx)(lY.xu,{flex:2,paddingLeft:5,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Filename"})})}):(0,lU.jsxs)(lY.rj,{gap:1,style:Mj,children:[(0,lU.jsx)(lY.xu,{flex:2,style:My,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Filename"})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Size"})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Type"})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Date added"})})]})}),(0,lU.jsxs)(lY.Kq,{children:[s&&0===i.length&&(0,lU.jsx)(lY.xu,{paddingTop:4,paddingBottom:2,children:(0,lU.jsx)(lY.kC,{justify:"center",children:(0,lU.jsx)(lY.$j,{muted:!0}
1)})}),i.map(e=>(0,lU.jsx)(Mb,{asset:e,isMobile:n,isSelected:o.some(t=>t._id===e._id),onClick:r,onKeyPress:l,onDeleteFinished:a},e._id))]})]})}var Mk=Object.freeze,MC=Object.defineProperty,M_=(e,t)=>Mk(MC(e,"raw",{value:Mk(t||e.slice())}));let MS="sanity.imageAsset",MT=e=>{let t=["image/*","audio/*","video/*"],n=e.split(",").map(e=>e.trim()),i=n.reduce((e,n)=>t.includes(n)?{...e,wildcards:"mimeType match '".concat(n,"' || ").concat(e.wildcards)}:0===n.indexOf(".")?{...e,extensions:"'".concat(n.replace(".",""),"', ").concat(e.extensions)}:{...e,mimes:"'".concat(n,"', ").concat(e.mimes)},{mimes:"",extensions:"",wildcards:""});return"&&\n (\n ".concat(i.wildcards," \n extension in [").concat(i.extensions,"] ||\n mimeType in [").concat(i.mimes,"]\n )")},ME=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:MS,i=arguments.length>3?arguments[3]:void 0,r=i.length>0,l=r?MT(i):"";return'\n *[_type == "'.concat(n,'" ').concat(l,"] | order(_updatedAt desc) [").concat(e,"...").concat(t,"] {\n _id,\n _updatedAt,\n _createdAt,\n url,\n originalFilename,\n mimeType,\n extension,\n size,\n metadata {dimensions}\n }\n")},MP=(0,aW.ZP)(lY.rj)(rk||(rk=M_(["\n grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));\n"]))),MA=(0,aW.ZP)(lY.Zb)(rC||(rC=M_(["\n border-top: 1px solid var(--card-border-color);\n position: sticky;\n bottom: 0;\n z-index: 200;\n"]))),MO=lK.memo(lK.forwardRef(function(e,t){let n=Ni(fC),i=(0,lK.useMemo)(()=>n.withConfig({apiVersion:"2023-02-14"}),[n]),r=(0,lK.useRef)("default-asset-source-".concat(ob()())),l=(0,lK.useRef)(0),a=(0,lK.useRef)(),[o,s]=(0,lK.useState)([]),[d,c]=(0,lK.useState)(!1),[u,p]=(0,lK.useState)(!1),[h,f]=(0,lK.useState)(!0),{selectedAssets:m,assetType:g="image",dialogHeaderTitle:x="Select image",onClose:v,onSelect:b,accept:y}=e,j=y?y.split(",").map(e=>e.trim()).join(", "):"",w=!h&&y&&y.length>0,k=y&&"image/*"===y&&"image"===g,C=(0,lK.useCallback)(e=>{let t=200*e,n=t+200,r="image"===g,l=r?MS:"sanity.fileAsset";f(!0),void 0!==y&&(a.current=i.observable.fetch(ME(t,n,l,y),{},{tag:r?"asset.image-list":"asset.file-list"}).subscribe(e=>{c(e.length<200),s(t=>t.concat(e)),f(!1)}))},[g,y,i]),_=(0,lK.useCallback)(e=>{s(t=>t.filter(t=>t._id!==e))},[s]),S=(0,lK.useCallback)(e=>{let t=o.find(t=>t._id===e);if(t){let t=[{kind:"assetDocumentId",value:e}];b(t)}},[o,b]),T=(0,lK.useCallback)(e=>{e.preventDefault(),S(e.currentTarget.getAttribute("data-id"))},[S]),E=(0,lK.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),S(e.currentTarget.getAttribute("data-id")))},[S]),P=(0,lK.useCallback)(()=>{v&&v()},[v]),A=(0,lK.useCallback)(e=>{e.preventDefault(),C(++l.current)},[C]);(0,lK.useEffect)(()=>(C(l.current),()=>{a.current&&a.current.unsubscribe()}),[C]),(0,lK.useEffect)(()=>{h||l.current&&0!==l.current||p(!0)},[h]);let O=(0,lK.useMemo)(()=>(0,lU.jsxs)(lY.xu,{padding:4,children:[(0,lU.jsx)(MP,{gap:2,children:o.map(e=>(0,lU.jsx)(z7,{asset:e,isSelected:m.some(t=>t._id===e._id),onClick:T,onKeyPress:E,onDeleteFinished:_},e._id))}),h&&0===o.length&&(0,lU.jsx)(lY.kC,{justify:"center",children:(0,lU.jsx)(lY.$j,{muted:!0})}),!h&&0===o.length&&(0,lU.jsx)(lY.xv,{align:"center",muted:!0,children:"No images"})]}),[o,_,T,E,h,m]),z=(0,lK.useMemo)(()=>(0,lU.jsx)(Mw,{isLoading:h,assets:o,selectedAssets:m,onClick:T,onKeyPress:E,onDeleteFinished:_}),[h,o,m,T,E,_]);return(0,lU.jsxs)(lY.Vq,{__unstable_autoFocus:u,header:x,id:r.current,onClickOutside:P,onClose:P,ref:t,width:2,children:[w&&!k&&(0,lU.jsx)(lY.Zb,{tone:"primary",marginTop:4,marginX:4,padding:[3,3,4],border:!0,radius:2,children:(0,lU.jsxs)(lY.kC,{gap:[3,4],align:"center",children:[(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.hQ6,{})}),(0,lU.jsxs)(lY.xv,{size:1,children:["Only showing assets of accepted types: ",(0,lU.jsx)("b",{children:j})]})]})}),"image"===g&&O,"file"===g&&z,o.length>0&&!d&&(0,lU.jsx)(MA,{tone:"default",padding:4,children:(0,lU.jsx)(lY.kC,{direction:"column",children:(0,lU.jsx)(lY.zx,{type:"button",icon:a0._8t,loading:h,onClick:A,text:"Load more",tone:"primary"})})})]})})),Mz={name:"sanity-default",title:"Uploaded files",component:MO,icon:a0.TAM},MM={name:"sanity-default",title:"Uploaded images",component:MO,icon:a0.XBm}
1,MI=[{fieldPath:"_updatedAt",icon:a0.Que,operators:[{name:"dateTimeLast",type:"item"},{type:"divider"},{name:"dateTimeRange",type:"item"},{name:"dateTimeAfter",type:"item"},{name:"dateTimeBefore",type:"item"},{type:"divider"},{name:"dateTimeEqual",type:"item"},{name:"dateTimeNotEqual",type:"item"}],title:"Updated at",name:"updatedAt",type:"pinned"},{fieldPath:"_createdAt",icon:a0.Que,operators:[{name:"dateTimeLast",type:"item"},{type:"divider"},{name:"dateTimeRange",type:"item"},{name:"dateTimeAfter",type:"item"},{name:"dateTimeBefore",type:"item"},{type:"divider"},{name:"dateTimeEqual",type:"item"},{name:"dateTimeNotEqual",type:"item"}],title:"Created at",name:"createdAt",type:"pinned"},{icon:a0.xPt,operators:[{name:"referencesDocument",type:"item"},{name:"referencesAssetImage",type:"item"},{name:"referencesAssetFile",type:"item"}],title:"Contains document, image or file",name:"references",type:"pinned"},{fieldType:"array",icon:a0.AEM,name:"array",operators:[{name:"defined",type:"item"},{name:"notDefined",type:"item"},{type:"divider"},{name:"arrayCountEqual",type:"item"},{name:"arrayCountNotEqual",type:"item"},{type:"divider"},{name:"arrayCountGt",type:"item"},{name:"arrayCountGte",type:"item"},{name:"arrayCountLt",type:"item"},{name:"arrayCountLte",type:"item"},{type:"divider"},{name:"arrayCountRange",type:"item"}],type:"field"},{fieldType:"array",icon:a0.AEM,name:"arrayList",operators:[{name:"arrayListIncludes",type:"item"},{name:"arrayListNotIncludes",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"},{type:"divider"},{name:"arrayCountEqual",type:"item"},{name:"arrayCountNotEqual",type:"item"},{type:"divider"},{name:"arrayCountGt",type:"item"},{name:"arrayCountGte",type:"item"},{name:"arrayCountLt",type:"item"},{name:"arrayCountLte",type:"item"},{type:"divider"},{name:"arrayCountRange",type:"item"}],type:"field"},{fieldType:"array",icon:a0.AEM,name:"arrayReferences",operators:[{name:"arrayReferenceIncludes",type:"item"},{name:"arrayReferenceNotIncludes",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"},{type:"divider"},{name:"arrayCountEqual",type:"item"},{name:"arrayCountNotEqual",type:"item"},{type:"divider"},{name:"arrayCountGt",type:"item"},{name:"arrayCountGte",type:"item"},{name:"arrayCountLt",type:"item"},{name:"arrayCountLte",type:"item"},{type:"divider"},{name:"arrayCountRange",type:"item"}],type:"field"},{fieldType:"boolean",icon:a0.nSX,name:"boolean",operators:[{name:"booleanEqual",type:"item"},{type:"divider"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"date",icon:a0.Que,name:"date",operators:[{name:"dateLast",type:"item"},{type:"divider"},{name:"dateRange",type:"item"},{name:"dateAfter",type:"item"},{name:"dateBefore",type:"item"},{type:"divider"},{name:"dateEqual",type:"item"},{name:"dateNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"datetime",icon:a0.Que,name:"datetime",operators:[{name:"dateTimeLast",type:"item"},{type:"divider"},{name:"dateTimeRange",type:"item"},{name:"dateTimeAfter",type:"item"},{name:"dateTimeBefore",type:"item"},{type:"divider"},{name:"dateTimeEqual",type:"item"},{name:"dateTimeNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"email",icon:a0.Rhe,name:"email",operators:[{name:"stringMatches",type:"item"},{name:"stringNotMatches",type:"item"},{type:"divider"},{name:"stringEqual",type:"item"},{name:"stringNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"file",icon:a0.$lS,name:"file",operators:[{name:"assetFileEqual",type:"item"},{name:"assetFileNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"image",icon:a0.XBm,name:"image",operators:[{name:"assetImageEqual",type:"item"},{name:"assetImageNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"number",icon:a0.yEv,name:"number",operators:[{name:"numberEqual",type:"item"},{name:"numberNotEqual",type:"item"},{type:"divider"},{name:"numberGt",type:"item"},{name:"numberGte",type:"item"},{name:"numberLt",type:"item"},{name:"numberLte",type:"item"},{type:"divider"},{name:"numberRange",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"array",icon:a0.aI,name:"portableText",operators:[{name:"portableTextMatches",type:"item"},{name:"portableTextNotMatches",type:"item"},{type:"divider"},{name:"portableTextEqual",type:"item"},{name:"portableTextNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"reference",icon:a0.xPt,name:"reference",operators:[{name:"referenceEqual",type:"item"},{name:"referenceNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"slug",icon:a0.Rhe,name:"slug",operators:[{name:"slugMatches",type:"item"},{name:"slugNotMatches",type:"item"},{type:"divider"},{name:"slugEqual",type:"item"},{name:"slugNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"string",icon:a0.Rhe,name:"string",operators:[{name:"stringMatches",type:"item"},{name:"stringNotMatches",type:"item"},{type:"divider"},{name:"stringEqual",type:"item"},{name:"stringNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"string",icon:a0.GVG,name:"stringList",operators:[{name:"stringListEqual",type:"item"},{name:"stringListNotEqual",type:"item"},{type:"divider"},{name:"stringMatches",type:"item"},{name:"stringNotMatches",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"text",icon:a0.Rhe,name:"text",operators:[{name:"stringMatches",type:"item"},{name:"stringNotMatches",type:"item"},{type:"divider"},{name:"stringEqual",type:"item"},{name:"stringNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"url",icon:a0.Rhe,name:"url",operators:[{name:"stringMatches",type:"item"},{name:"stringNotMatches",type:"item"},{type:"divider"},{name:"stringEqual",type:"item"},{name:"stringNotEqual",type:"item"},{type:"divider"},{name:"defined",type:"item"},{name:"notDefined",type:"item"}],type:"field"}];function MR(e){let{documentId:t,schemaType:n}=e,i=UY(),{draft:r,published:l,isLoading:a}=(0,lJ.m2)(()=>fX(i,n,t,""),[t,i,n]),o=(0,lK.useMemo)(()=>({_id:t,_type:n.name}),[t,n.name]),s=fY({draft:r,published:l,value:o});return a?(0,lU.jsx)(lY.Od,{animated:!0,marginLeft:1,radius:2,style:{width:"10ch",height:"1em"}}):(0,lU.jsx)(lU.Fragment,{children:s.title||t.slice(0,8)})}let MF="yyyy-MM-dd";function MD(e){let{value:t}=e,n=(null==t?void 0:t.date)?new Date(t.date):null;return n&&(0,oR.Z)(n)?(0,lU.jsx)(lU.Fragment,{children:(0,oh.Z)(n,MF)}):null}function MZ(e){let{value:t}=e,n=(null==t?void 0:t.date)?new Date(t.date):null;return n&&(0,oR.Z)(n)?(0,lU.jsx)(lU.Fragment,{children:(0,oh.Z)(n,MF)}):null}function ML(e){let{value:t}=e,n=(null==t?void 0:t.dateMin)?new Date(t.dateMin):null,i=(null==t?void 0:t.dateMax)?new Date(t.dateMax):null;return i&&n&&(0,oR.Z)(i)&&(0,oR.Z)(n)?(0,lU.jsxs)(lU.Fragment,{children:[(0,oh.Z)(n,MF)," â ",(0,oh.Z)(i,MF)]}):null}function Mq(e){let{value:t}=e;return(0,lU.jsx)(lU.Fragment,{children:t})}function MN(e){let{value:t}=e;
1return(0,lU.jsxs)(lU.Fragment,{children:[t," ",(0,oQ.Z)("item",t)]})}function MV(e){let{value:t}=e,n=Nu(),i=t._ref,r=n.get(t._type);return r?(0,lU.jsx)(MR,{documentId:i,schemaType:r}):null}function MU(e){let{value:t}=e;return(0,lU.jsx)(lU.Fragment,{children:t})}let MB=(0,lK.createContext)(void 0);function MK(){let e=(0,lK.useContext)(MB);if(void 0===e)throw Error("useSearchState must be used within an SearchProvider");return e}function MH(e){let{value:t,onChange:n}=e,[i,r]=(0,lK.useState)(null!=t?t:""),{state:{fullscreen:l}}=MK(),a=(0,lK.useCallback)(e=>{r(e.currentTarget.value);let t=parseFloat(e.currentTarget.value);n(Number.isFinite(t)?t:null)},[n]);return(0,lU.jsx)(lY.oi,{fontSize:l?2:1,onChange:a,placeholder:"Value",radius:2,step:"any",type:"number",value:i})}function MW(e){var t,n;let{onChange:i,value:r}=e,[l,a]=(0,lK.useState)(null!=(t=null==r?void 0:r.max)?t:""),[o,s]=(0,lK.useState)(null!=(n=null==r?void 0:r.min)?n:""),{state:{fullscreen:d}}=MK(),c=(0,lK.useCallback)(e=>{var t;a(e.currentTarget.value);let n=parseFloat(e.currentTarget.value);i({max:Number.isFinite(n)?n:null,min:null!=(t=null==r?void 0:r.min)?t:null})},[null==r?void 0:r.min,i]),u=(0,lK.useCallback)(e=>{var t;s(e.currentTarget.value);let n=parseFloat(e.currentTarget.value);i({max:null!=(t=null==r?void 0:r.max)?t:null,min:Number.isFinite(n)?n:null})},[null==r?void 0:r.max,i]);return(0,lU.jsxs)(lY.kC,{gap:2,children:[(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.oi,{fontSize:d?2:1,onChange:u,placeholder:"Min value",radius:2,step:"any",type:"number",value:o})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.oi,{fontSize:d?2:1,onChange:c,placeholder:"Max value",radius:2,step:"any",type:"number",value:l})})]})}function M$(e,t){let n=t.split("."),i=n[0];if(i&&(0,lV.m$)(e)){let t=e.fields.find(e=>e.name===i);if(t){let e=n.slice(1).join(".");return e?M$(t.type,e):t}}}var MX=Object.freeze,MG=Object.defineProperty,MY=(e,t)=>MX(MG(e,"raw",{value:MX(t||e.slice())}));let MJ=(0,aW.ZP)(lY.xu)(r_||(r_=MY(["\n @supports (-webkit-overflow-scrolling: touch) {\n * [data-ui='Box'] {\n background-attachment: scroll;\n }\n }\n"]))),MQ=(0,aW.ZP)(lY.__)(rS||(rS=MY(["\n max-width: 150px;\n"])));function M0(e){let{documentId:t,presence:n,schemaType:i}=e,r=UY(),{draft:l,published:a,isLoading:o}=(0,lJ.m2)(()=>fX(r,i,t,""),[t,r,i]),s=(0,lK.useMemo)(()=>({_id:t,_type:i.name}),[t,i.name]),d=(0,lK.useMemo)(()=>o?null:(0,lU.jsxs)(lY.gF,{space:3,children:[n&&n.length>0&&(0,lU.jsx)(yw,{presence:n}),(0,lU.jsx)(MQ,{size:0,muted:!0,textOverflow:"ellipsis",children:i.title})]}),[o,n,i.title]);return(0,lU.jsx)(MJ,{children:(0,lU.jsx)(fF,{...fY({draft:l,published:a,value:s}),isPlaceholder:null==o||o,layout:"default",icon:i.icon,status:d})})}function M1(e){let{compact:t,disableIntentLink:n,documentId:i,documentType:r,onClick:l,...a}=e,o=Nu(),s=o.get(r),d=UN(i),c=(0,lK.useMemo)(()=>({id:i,type:null==s?void 0:s.name}),[i,null==s?void 0:s.name]),{onClick:u,href:p}=(0,a1.PM)({intent:"edit",params:c}),h=(0,lK.useCallback)(e=>{n||u(e),null==l||l()},[n,l,u]);return s?(0,lU.jsx)(lY.xu,{...a,children:(0,lU.jsx)(uM,{as:"a","data-as":"a",flex:1,href:n?void 0:p,onClick:h,padding:t?1:2,radius:2,tabIndex:-1,children:(0,lU.jsx)(M0,{documentId:i,presence:d,schemaType:s})})}):null}let M2="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),M3=M2?"Cmd":"Ctrl",M4=lY.Lg.space[1];function M5(e){let{allowEmptyQueries:t,terms:n}=e,i=!!t||n.query.length>0,r=!!n.filter,l=n.types.length>0;return i||r||l}function M6(e){return mm(e).filter(e=>!1!==e.__experimental_omnisearch_visibility)}function M8(e,t){var n,i;return(null!=(n=e.title)?n:e.name).localeCompare(null!=(i=t.title)?i:t.name)}let M9={error:null,hits:[],loading:!1,terms:{query:"",types:[]}};function M7(e){return null!==e}function Ie(e){var t;return{...e,terms:{...e.terms,filter:null==(t=e.terms.filter)?void 0:t.trim(),query:e.terms.query.trim()}}}function It(e){let{allowEmptyQueries:t,initialState:n,onComplete:i,onError:r,onStart:l,schema:a}=e,[o,s]=(0,lK.useState)(n),d=Ni(fC),c=(0,lK.useMemo)(()=>mS(M6(a),d,{tag:"search.global",unique:!0}),[d,a]),u=(0,lJ.W2)(e=>e.pipe((0,af.h)(M7),(0,ad.U)(Ie),(0,ac.x)(aU()),(0,aE.D)(e=>(0,l6.H)((null==e?void 0:e.debounceTime)||300)),(0,as.b)(l),(0,ap.w)(e=>(0,l0.z)((0,lQ.of)({...M9,loading:!0,options:e.options,terms:e.terms}),(0,ai.s)(()=>M5({allowEmptyQueries:t,terms:e.terms}),c(e.terms,e.options).pipe((0,ad.U)(e=>({hits:e})),(0,as.b)(e=>{let{hits:t}=e;return null==i?void 0:i(t)}),(0,au.K)(t=>(null==r||r(t),(0,lQ.of)({...M9,error:t,loading:!1,options:e.options,terms:e.terms})))),(0,lQ.of)(l7.E).pipe((0,as.b)(()=>null==i?void 0:i([])))),(0,lQ.of)({loading:!1}))),(0,ah.R)((e,t)=>({...e,...t}),M9),(0,as.b)(s)),[t,c]),p=(0,lK.useCallback)(e=>u(e),[u]);return{handleSearch:p,searchState:o}}function In(e){let t,{availableCharacters:n=40,types:i}=e,r=i.reduce((t=n,function(e,i,r){let l=Ii(i);return t-=l.length,0===r?e.push(i):n>l.length&&t>l.length&&e.push(i),e}),[]),l=i.length-r.length;return i.length?["".concat(r.map(Ii).join(", ")),...l?["+".concat(l," more")]:[]].join(" "):"All types"}function Ii(e){var t;return null!=(t=e.title)?t:e.name}var Ir=Object.freeze,Il=Object.defineProperty;let Ia=()=>!0,Io=(0,aW.ZP)(lY.xv)(rT||(rT=Ir(Il(ei=["\n word-break: break-word;\n"],"raw",{value:Ir(ei.slice())})))),Is=(0,lK.forwardRef)(function(e,t){let{onSelect:n,types:i=[],value:r}=e,l=(0,lK.useRef)(null),a=Nu(),{state:{fullscreen:o}}=MK(),s=(0,lK.useId)(),[d,c]=(0,lK.useState)([]),{handleSearch:u,searchState:p}=It({allowEmptyQueries:!0,initialState:{hits:[],loading:!1,error:null,terms:{query:"",types:i}},onComplete:e=>{c(e.map(e=>({hit:e,value:e.hit._id})))},schema:a}),h=(0,lK.useCallback)(()=>{u({debounceTime:0,options:{limit:100},terms:{query:"",types:i}})},[u,i]),f=(0,lK.useCallback)(e=>{e?u({options:{limit:100},terms:{query:e||"",types:i}}):u({debounceTime:0,options:{limit:0},terms:{query:"",types:i}})},[u,i]),m=(0,lK.useCallback)(e=>{var t;let i=null==(t=d.find(t=>t.value===e))?void 0:t.hit.hit;i&&(null==n||n({_ref:ci(i._id),_type:i._type}))},[d,n]),g=(0,lK.useMemo)(()=>{let e=In({types:i});return i.length>0?"Search for ".concat(e):"Search all documents"},[i]),x=(0,lK.useCallback)(e=>{let t=e.hit.hit._type;return(0,lU.jsx)(M1,{compact:!0,disableIntentLink:!0,documentId:e.value,documentType:t})},[]),v=(0,lK.useCallback)((e,t)=>{let{content:n,hidden:i,onMouseEnter:r,onMouseLeave:a}=e,o=d&&d.length>0;return(0,lU.jsx)(lY.J2,{arrow:!1,constrainSize:!0,content:(0,lU.jsx)("div",{ref:t,children:o?n:p.terms.query&&(0,lU.jsx)(lY.xu,{padding:4,children:(0,lU.jsx)(lY.kC,{align:"center",height:"fill",justify:"center",children:(0,lU.jsxs)(Io,{align:"center",muted:!0,children:["No results for ",(0,lU.jsxs)("strong",{children:["â",p.terms.query,"â"]}
1)]})})})}),matchReferenceWidth:!0,onMouseEnter:r,onMouseLeave:a,open:!p.loading&&!i,overflow:"auto",placement:"bottom-start",radius:2,referenceElement:l.current})},[d,p.loading,p.terms.query]);return(0,lU.jsx)("div",{ref:l,children:(0,lU.jsx)(lY.F2,{"aria-label":g,filterOption:Ia,fontSize:o?2:1,id:s,loading:p.loading,openButton:{onClick:h},options:d,onQueryChange:f,onSelect:m,placeholder:g,radius:2,ref:t,renderOption:x,renderPopover:v,value:null==r?void 0:r._ref})})});function Id(e){let{fieldDefinition:t,onChange:n,value:i}=e,{onClose:r,state:{documentTypesNarrowed:l,fullscreen:a}}=MK(),o=Nu(),s=(0,lK.useCallback)(e=>n(e),[n]),d=(0,lK.useMemo)(()=>t?t.documentTypes.filter(e=>l.includes(e)).flatMap(e=>{let n=o.get(e);if(n){let e=M$(n,t.fieldPath);if((0,lV.jB)(null==e?void 0:e.type))return null==e?void 0:e.type.of.filter(lV.dD).flatMap(e=>e.to);if((0,lV.dD)(null==e?void 0:e.type))return null==e?void 0:e.type.to}return[]}).reduce((e,t)=>(0>e.findIndex(e=>e.name===(null==t?void 0:t.name))&&e.push(t),e),[]):[],[l,t,o]),c=(0,lK.useCallback)(()=>s(null),[s]),u=(0,lK.useCallback)(()=>{null==r||r()},[r]);return(0,lU.jsx)(lY.xu,{style:{width:"min(calc(100vw - 40px), 420px)"},children:(null==i?void 0:i._ref)&&(null==i?void 0:i._type)?(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.Zb,{padding:1,radius:1,shadow:1,children:(0,lU.jsx)(M1,{compact:!0,documentId:i._ref,documentType:i._type,onClick:u})}),(0,lU.jsx)(lY.zx,{fontSize:a?2:1,mode:"ghost",onClick:c,text:"Clear",tone:"critical"})]}):(0,lU.jsx)(Is,{onSelect:s,types:d,value:i})})}function Ic(e){let{onClick:t,selected:n,title:i,value:r}=e,l=(0,lK.useCallback)(()=>t(r),[t,r]);return(0,lU.jsx)(lY.sN,{onClick:l,padding:3,pressed:n,tone:"default",children:(0,lU.jsx)(lY.kC,{align:"center",justify:"space-between",gap:3,children:(0,lU.jsxs)(lY.Kq,{paddingRight:2,space:2,children:[(0,lU.jsx)(lY.xv,{size:1,weight:"regular",children:i}),r&&(0,lU.jsx)(lY.EK,{muted:!0,size:0,children:r})]})})})}function Iu(e){let{fieldDefinition:t,onChange:n,value:i}=e,r=(0,lK.useId)(),{state:{documentTypesNarrowed:l}}=MK(),a=Nu(),o=(0,lK.useMemo)(()=>{if(!t)return[];let e=t.documentTypes.filter(e=>l.includes(e)).map(e=>{let n=a.get(e);if(n){let e=M$(n,t.fieldPath);return null==e?void 0:e.type.options}return null}).filter(d9),n=e.map(e=>e.list).flatMap(e=>null==e?void 0:e.map(e=>(0,lV.n4)(e)?e:{title:sL()("".concat(e)),value:e})).filter(d9);return n.reduce((e,t)=>{let n=e.findIndex(e=>e.value===(null==t?void 0:t.value));if(n>-1){let i=e[n];e[n]={...e[n],title:sa()([...i.title,t.title]).sort()}}else e.push({...t,title:[t.title]});return e},[])},[l,t,a]),s=(0,lK.useCallback)(e=>{n(e)},[n]);return(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{mode:"ghost",padding:3,children:(0,lU.jsxs)(lY.kC,{align:"center",gap:2,justify:"space-between",children:[(0,lU.jsx)(lY.xv,{size:1,weight:"regular",children:i||"Select..."}),(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.GVG,{})})})]})}),id:r||"",menu:(0,lU.jsx)(lY.v2,{children:o.map((e,t)=>(0,lU.jsx)(Ic,{onClick:s,selected:e.value===i,title:e.title.join(", "),value:e.value||""},t))}),popover:{constrainSize:!0,placement:"bottom-start",portal:!1,radius:2}})}let Ip=()=>(0,lU.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,lU.jsx)("path",{d:"M7.04 19V17.512H17.36V19H7.04ZM7.04 15.328V13.624L12.08 11.872L15.32 10.816V10.72L12.08 9.664L7.04 7.912V6.208L17.36 9.88V11.656L7.04 15.328Z",fill:"currentColor"})}),Ih=()=>(0,lU.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,lU.jsx)("path",{d:"M7.568 18.848V16.952L14.792 12.08V11.984L7.568 7.112V5.216L16.52 11.288V12.776L7.568 18.848Z",fill:"currentColor"})}),If=()=>(0,lU.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,lU.jsx)("path",{d:"M7.04 19V17.512H17.36V19H7.04ZM17.36 15.328L7.04 11.656V9.88L17.36 6.208V7.912L12.32 9.664L9.08 10.72V10.816L12.32 11.872L17.36 13.624V15.328Z",fill:"currentColor"})}),Im=()=>(0,lU.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,lU.jsx)("path",{d:"M16.952 19.632L8 13.56V12.072L16.952 6V7.896L9.728 12.768V12.864L16.952 17.736V19.632Z",fill:"currentColor"})});function Ig(e){return JSON.stringify(e)}let Ix=(0,lK.createContext)(null);function Iv(e){let{children:t,workspace:n}=e;return(0,lU.jsx)(Ix.Provider,{value:n,children:t})}function Ib(){let e=(0,lK.useContext)(Ix);if(!e)throw Error("Workspace: missing context value");return e}let Iy=(0,lK.createContext)(null);function Ij(e){let{children:t,...n}=e,i=(0,lK.useContext)(Iy),{unstable_sources:r}=Ib();if("source"in n){let{source:e}=n;return(0,lU.jsx)(Iy.Provider,{value:e,children:t})}if("name"in n){let{name:e}=n,l=r.find(t=>t.name===e);if(!l)throw Error("Could not find source with name `".concat(e,"` in current workspace"));return i===l?(0,lU.jsx)(lU.Fragment,{children:t}):(0,lU.jsx)(Iy.Provider,{value:l,children:t})}throw Error("Invalid props passed into SourceProvider. A `name` or a `source` object is required.")}function Iw(){let e=(0,lK.useContext)(Iy);if(!e)throw Error("Could not find `source` context");return e}function Ik(e){return(0,lU.jsx)(lY.xu,{...e,children:(0,lU.jsxs)(lY.kC,{align:"flex-start",ga
1p:3,children:[(0,lU.jsx)(pG,{tone:"caution",children:(0,lU.jsx)(a0.foC,{})}),(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(pG,{size:1,tone:"caution",weight:"semibold",children:"No valid asset sources found."}),(0,lU.jsx)(pG,{size:1,tone:"caution",children:"Currently, only the default asset source is supported."}),(0,lU.jsx)(pG,{size:1,tone:"caution",children:"Please ensure it's enabled in your studio configuration file."})]})]})})}function IC(e){let{reference:t}=e,n=UY(),i=(0,lK.useCallback)(e=>wI(n,e),[n]);return(0,lU.jsx)(_K,{observeAsset:i,reference:t,waitPlaceholder:(0,lU.jsx)(IS,{}),children:e=>(0,lU.jsx)(I_,{asset:e})})}function I_(e){let{asset:t}=e;return(0,lU.jsx)(lY.Zb,{padding:2,shadow:1,children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"space-between",wrap:"nowrap",children:[(0,lU.jsx)(lY.Zb,{padding:3,radius:1,shadow:1,tone:"transparent",children:(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.bg6,{})})}),(0,lU.jsxs)(lY.Kq,{flex:1,space:2,marginLeft:3,children:[(0,lU.jsx)(lY.xv,{size:2,textOverflow:"ellipsis",muted:!0,children:(null==t?void 0:t.originalFilename)||t._id}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:SE(t.size)})]})]})})}function IS(){return(0,lU.jsx)(lY.Zb,{padding:2,shadow:1,children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"flex-start",children:[(0,lU.jsx)(lY.Zb,{padding:3,radius:1,shadow:1,tone:"transparent",children:(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.bg6,{})})}),(0,lU.jsxs)(lY.Kq,{flex:1,space:2,marginLeft:3,children:[(0,lU.jsx)(lY.JQ,{animated:!0,style:{width:"100%"},radius:1}),(0,lU.jsx)(lY.JQ,{animated:!0,style:{width:"100%"},radius:1})]})]})})}var IT=Object.freeze,IE=Object.defineProperty,IP=(e,t)=>IT(IE(e,"raw",{value:IT(t||e.slice())}));let IA=(0,aW.ZP)(lY.Zb)(rE||(rE=IP(["\n position: relative;\n padding-bottom: 100%;\n"]))),IO=aW.ZP.img(rP||(rP=IP(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: block;\n object-fit: contain;\n"]))),Iz=(0,aW.ZP)(lY.kC)(rA||(rA=IP(["\n height: 100%;\n position: absolute;\n width: 100%;\n"])));function IM(e){let{reference:t}=e,n=UY(),i=(0,lK.useCallback)(e=>wI(n,e),[n]);return(0,lU.jsx)(_K,{observeAsset:i,reference:t,children:e=>(0,lU.jsx)(II,{asset:e})})}function II(e){let{asset:t}=e,[n,i]=(0,lK.useState)(!1),r="".concat(t.url,"?h=800&fit=max"),l=(0,lK.useCallback)(()=>i(!0),[]);return(0,lU.jsxs)(IA,{__unstable_checkered:!0,border:!0,children:[!n&&(0,lU.jsx)(Iz,{align:"center",justify:"center",children:(0,lU.jsx)(lY.$j,{})}),(0,lU.jsx)(IO,{onLoad:l,src:r})]})}function IR(e){let{reference:t}=e;return t?t._type.startsWith("sanity.fileAsset")?(0,lU.jsx)(IC,{reference:t}):t._type.startsWith("sanity.imageAsset")?(0,lU.jsx)(IM,{reference:t}):null:null}var IF=Object.freeze,ID=Object.defineProperty;let IZ={file:"sanity.fileAsset",image:"sanity.imageAsset"},IL=(0,aW.ZP)(lY.xu)(rO||(rO=IF(ID(er=["\n width: min(calc(100vw - 40px), 320px);\n"],"raw",{value:IF(er.slice())}))));function Iq(e){return function(t){let{onChange:n,value:i}=t,[r,l]=(0,lK.useState)(null),[a,o]=(0,lK.useState)(null),{state:{fullscreen:s}}=MK(),{file:d,image:c}=Iw().form,u=(0,lK.useMemo)(()=>{switch(e){case"file":return d.assetSources.filter(e=>e.name===Mz.name);case"image":return c.assetSources.filter(e=>e.name===MM.name);default:throw Error("Unknown asset source found")}},[d.assetSources,c.assetSources]),p=(0,lK.useId)(),h=Ni(fC),f=(0,lK.useCallback)(()=>{o(null),n(null)},[n]),m=(0,lK.useCallback)(()=>{l(null)},[]),g=(0,lK.useCallback)(e=>{let t=e[0];o(t),m()},[m]),x=(0,lK.useCallback)(e=>l(e),[]);(0,lK.useEffect)(()=>{(null==a?void 0:a.kind)==="assetDocumentId"&&"string"==typeof(null==a?void 0:a.value)&&e&&n({_ref:a.value,_type:IZ[e]})},[h,n,a]);let v=null==r?void 0:r.component,b=s?2:1,y=i?"Change ".concat(e):"Select ".concat(e),j=op()(e,"options.accept","image"===e?"image/*":"");return(0,lU.jsx)(IL,{children:(0,lU.jsxs)(lY.Kq,{space:3,children:[r&&v&&(0,lU.jsx)(lY.h_,{children:(0,lU.jsx)(v,{assetType:e,dialogHeaderTitle:"Select ".concat(e),onClose:m,onSelect:g,selectedAssets:[],selectionType:"single",accept:j})}),i&&(0,lU.jsx)(IR,{reference:i}),(0,lU.jsxs)(lY.kC,{gap:2,children:[0===u.length&&(0,lU.jsx)(Ik,{padding:2}),u.length>0&&(0,lU.jsx)(lU.Fragment,{children:u.length>1?(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{fontSize:b,icon:i?a0.UEU:a0.W1M,iconRight:a0.v4q,mode:"ghost",style:{flex:i?1:0},text:y}),id:p,menu:(0,lU.jsx)(lY.v2,{children:u.map(e=>(0,lU.jsx)(lY.sN,{fontSize:b,icon:e.icon||a0.XBm,onClick:()=>x(e),text:e.title},e.name))}),popover:{constrainSize:!0,portal:!1,radius:2}}):(0,lU.jsx)(lY.zx,{fontSize:b,icon:i?a0.UEU:a0.W1M,mode:"ghost",onClick:()=>x(u[0]),style:{flex:i?1:0},text:y})}),i&&(0,lU.jsx)(lY.zx,{fontSize:s?2:1,mode:"ghost",onClick:f,style:{flex:1},text:"Clear",tone:"critical"})]})]})})}}let IN={assetFileEqual:{buttonLabel:"is",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref == ").concat(Ig(n._ref)):null},initialValue:null,inputComponent:Iq("file"),label:"is",type:"assetFileEqual"},assetFileNotEqual:{buttonLabel:"is not",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref != ").concat(Ig(n._ref)):null},initialValue:null,inputComponent:Iq("file"),label:"is not",type:"assetFileNotEqual"},assetImageEqual:{buttonLabel:"is",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref == ").concat(Ig(n._ref)):null},initialValue:null,inputComponent:Iq("image"),label:"is",type:"assetImageEqual"},assetImageNotEqual:{buttonLabel:"is not",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref != ").concat(Ig(n._ref)):null},initialValue:null,inputComponent:Iq("image"),label:"is not",type:"assetImageNotEqual"}};var IV=Object.freeze,IU=Object.defineProperty;let IB="Include time",IK=(0,aW.ZP)(lY.xv)(rz||(rz=IV(IU(el=["\n cursor: default;\n"],"raw",{value:IV(el.slice())}))));function IH(e){let{onChange:t,value:n}=e;return(0,lU.jsxs)(lY.kC,{align:"center",gap:2,justify:"flex-end",marginTop:1,children:[(0,lU.jsx)(lY.Kq,{children:(0,lU.jsx)(IK,{muted:!0,onClick:t,size:1,weight:"medium",children:IB})}),(0,lU.jsx)(lY.rs,{checked:n,label:IB,onChange:t})]})}let IW=(0,lK.createContext)(void 0);function I$(){let e=(0,lK.useContext)(IW);if(void 0===e)throw Error("useCalendar must be used within an CalendarContext.Provider");return e}let IX=["January","February","March","April","May","June","July","August","September","October","November","December"],IG=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];sW()(0,24);let IY=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],IJ=[1,2,3,4,5,6];function IQ(e){let{focusedDate:t}=I$(),{fontSize:n,moveFocusedDate:i,onNowClick:r}=e,l=(0,lK.useCallback)(()=>i(-1),[i]),a=(0,lK.useCallback)(()=>i(1),[i]);return(0,lU.jsxs)(lY.kC,{align:"center",flex:1,justify:"space-between",children:[(0,lU.jsxs)(lY.gF,{paddingLeft:2,space:1,children:[(0,lU.jsx)(lY.xv,{weight:"medium",children:IX[t.getMonth()]}),(0,lU.jsx)(lY.xv,{weight:"medium",children:t.getFullYear()})]}),(0,lU.jsxs)(lY.xu,{children:[(0,lU.jsx)(lY.zx,{fontSize:n,text:"Today",mode:"bleed",onClick:r}),(0,lU.jsx)(lY.zx,{"aria-label":"Go to previous month",onClick:l,mode:"bleed",icon:a0.wyc}),(0,lU.jsx)(lY.zx,{"aria-label":"Go to next month",mode:"bleed",icon:a0.XCv,onClick:a})]})]})}var I0=Object.freeze,I1=Object.defineProperty,I2=(e,t)=>
1I0(I1(e,"raw",{value:I0(t||e.slice())}));let I3=aW.ZP.svg(e=>{let{theme:t}=e;return(0,aW.iv)(rM||(rM=I2(["\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n\n circle {\n stroke: ",";\n stroke-width: 3;\n fill: none;\n }\n "])),t.sanity.color.card.enabled.border)}),I4=(0,aW.ZP)(lY.Zb)(rI||(rI=I2(["\n position: relative;\n\n &[data-focused='true'] {\n z-index: 1;\n }\n\n &[data-start-date='true'] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n\n &[data-end-date='true'] {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n\n &[data-within-range='true'] {\n border-radius: 0;\n }\n"])));function I5(e){let{date:t,onSelect:n}=e,i=(0,lK.useCallback)(()=>{n(t)},[t,n]),{date:r,endDate:l,focusedDate:a,fontSize:o,selectRange:s}=I$(),d=r&&(0,o_.Z)(t,r),c=s&&r&&(0,o_.Z)(t,r),u=s&&l&&(0,o_.Z)(t,l),p=(0,oS.Z)(t,a),h=a&&(0,o_.Z)(t,a),f=(0,o_.Z)(t,new Date),m=r&&l&&!c&&!u&&(0,oF.Z)(t,r)&&(0,oD.Z)(t,l);return(0,lU.jsxs)(I4,{__unstable_focusRing:!0,"aria-label":t.toDateString(),"aria-pressed":d,"data-end-date":!!u||void 0,"data-focused":h?"true":"","data-ui":"CalendarDay","aria-selected":d,"data-start-date":!!c||void 0,"data-within-range":!!m||void 0,forwardedAs:"button",onClick:i,padding:3,radius:2,role:"button",selected:d||c||u,tabIndex:-1,tone:m?"primary":"default",children:[f&&(0,lU.jsx)(I3,{height:"100%",preserveAspectRatio:"xMidYMid meet",vectorEffect:"non-scaling-stroke",viewBox:"0 0 100 100",width:"100%",children:(0,lU.jsx)("circle",{cx:"50",cy:"50",r:"40%"})}),(0,lU.jsx)(lY.xv,{align:"center",muted:!d&&!p,size:o,weight:f?"medium":"regular",children:t.getDate()})]})}let I6=e=>{let t=(0,oy.Z)(e);return(0,oj.Z)({start:t,end:(0,ow.Z)(t)})},I8=e=>e.map(e=>[e,...IJ.map(t=>(0,ok.Z)(e,t))]),I9=e=>I8(I6(e)).map(e=>({number:(0,oC.Z)(e[0]),days:e}));var I7=Object.freeze,Re=Object.defineProperty;let Rt=(0,aW.ZP)(lY.rj)(rR||(rR=I7(Re(ea=["\n grid-template-columns: repeat(7, minmax(44px, auto));\n"],"raw",{value:I7(ea.slice())}))));function Rn(e){let{hidden:t,onSelect:n}=e,{focusedDate:i,fontSize:r}=I$();return(0,lU.jsx)(lY.xu,{"aria-hidden":t||!1,"data-ui":"CalendarMonth",children:(0,lU.jsxs)(Rt,{children:[IG.map(e=>(0,lU.jsx)(lY.xu,{paddingBottom:3,paddingTop:2,children:(0,lU.jsx)(lY.xv,{align:"center",size:r,weight:"medium",children:e})},e)),I9(i).map((e,t)=>e.days.map((e,i)=>(0,lU.jsx)(I5,{date:e,onSelect:n},"".concat(t,"-").concat(i))))]})})}let Ri=(0,lU.jsx)("span",{"data-preserve-focus":!0,style:{overflow:"hidden",position:"absolute",outline:"none"},tabIndex:-1});function Rr(e){let{date:t,endDate:n,fontSize:i,onSelect:r,selectRange:l,selectTime:a}=e,[o,s]=(0,lK.useState)(null),[d,c]=(0,lK.useState)(!1),[u,p]=(0,lK.useState)(t||new Date),h=(0,lK.useRef)(t||null),f=(0,lK.useRef)(n||null),m=(0,lK.useCallback)(()=>{var e;null==(e=null==o?void 0:o.querySelector('[data-focused="true"]'))||e.focus()},[o]),g=(0,lK.useCallback)(e=>{let i=(0,oZ.Z)(e,{hours:e.getHours(),minutes:e.getMinutes(),seconds:0,milliseconds:0}),a=t&&(0,oD.Z)(i,t),o=n&&(0,oF.Z)(i,n);if(l){if(a||o){r({date:i,endDate:null});return}d?r({date:t||null,endDate:i}):r({date:i,endDate:t?null:n||null})}else r({date:i})},[t,n,r,d,l]),x=(0,lK.useCallback)(()=>{let e=new Date;l?p(e):r({date:e})},[r,l,p]),v=(0,lK.useCallback)(e=>{var t;if(IY.includes(e.key)){if(e.preventDefault(),e.target.hasAttribute("data-calendar-grid")){m();return}"ArrowUp"===e.key&&p((0,ok.Z)(u,-7)),"ArrowDown"===e.key&&p((0,ok.Z)(u,7)),"ArrowLeft"===e.key&&p((0,ok.Z)(u,-1)),"ArrowRight"===e.key&&p((0,ok.Z)(u,1)),null==(t=null==o?void 0:o.querySelector("[data-preserve-focus]"))||t.focus()}},[o,m,u,p]),b=(0,lK.useCallback)(e=>p((0,oP.Z)(u,e)),[u,p]);return(0,lK.useEffect)(()=>{m()},[m]),(0,lK.useEffect)(()=>{var e;
1let t=null==(e=document.activeElement)?void 0:e.matches("[data-calendar-grid], [data-calendar-grid] [data-preserve-focus]");t&&m()},[m,u]),(0,lK.useEffect)(()=>{var e,i;let l=(null==t?void 0:t.getTime())!==(null==(e=h.current)?void 0:e.getTime()),a=(null==n?void 0:n.getTime())!==(null==(i=f.current)?void 0:i.getTime()),o=t&&n&&(0,oF.Z)(t,n);l&&!a&&(o&&(c(!0),r({date:t,endDate:null})),c(!!t),t&&p(t)),!l&&a&&(o&&(c(!0),r({date:n,endDate:null})),c(!!t&&!n),n&&p(n)),l&&a&&(c(!0),t&&p(t)),h.current=t||null,f.current=n||null},[t,n,r]),(0,lU.jsx)(IW.Provider,{value:{date:t,endDate:n,focusedDate:u,fontSize:i,selectRange:l,selectTime:a},children:(0,lU.jsxs)(lY.xu,{"data-ui":"Calendar",ref:s,children:[(0,lU.jsx)(lY.kC,{children:(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(IQ,{fontSize:i,moveFocusedDate:b,onNowClick:x})})}),(0,lU.jsxs)(lY.xu,{"data-calendar-grid":!0,onKeyDown:v,marginTop:2,overflow:"hidden",tabIndex:0,children:[(0,lU.jsx)(Rn,{onSelect:g}),Ri]})]})})}function Rl(e){let{date:t,endDate:n,onChange:i,selectRange:r,selectTime:l}=e,{state:{fullscreen:a}}=MK(),o=(0,lK.useCallback)(e=>{i(e)},[i]);return(0,lU.jsx)(Rr,{date:t,endDate:n,fontSize:a?2:1,onSelect:o,selectRange:r,selectTime:l})}var Ra=Object.freeze,Ro=Object.defineProperty,Rs=(e,t)=>Ra(Ro(e,"raw",{value:Ra(t||e.slice())}));let Rd=(0,aW.ZP)(lY.xu)(e=>{let{background:t,smallClearButton:n}=e;return(0,aW.iv)(rF||(rF=Rs(["\n width: 100%;\n\n input + span {\n background: ",";\n }\n\n [data-qa='clear-button'] {\n background: none;\n box-shadow: none;\n display: flex; /* TODO: hack, currently used to vertically center <TextInput>'s clearButton */\n transform: ",";\n &:hover {\n opacity: 0.5;\n }\n }\n "])),e=>{let{theme:n}=e;return t?n.sanity.color.card.disabled.bg2:"transparent"},n?"scale(0.8)":"scale(1)")}),Rc=(0,lK.forwardRef)(function(e,t){let{background:n,smallClearButton:i,...r}=e;return(0,lU.jsx)(Rd,{background:n,smallClearButton:i,children:(0,lU.jsx)(lY.oi,{...r,ref:t})})});function Ru(e){let t,{date:n,dateOnly:i,roundDay:r}=e;switch(r){case"end":t=(0,oL.Z)(n);break;case"start":t=(0,oq.Z)(n);break;default:t=n}return i?t.toISOString().split("T")[0]:t.toISOString()}var Rp=Object.freeze,Rh=Object.defineProperty,Rf=(e,t)=>Rp(Rh(e,"raw",{value:Rp(t||e.slice())}));
1let Rm={date:{exampleDate:"Jan 1, 2000",pattern:"MMM d, yyyy"},datetime:{exampleDate:"Jan 1, 2000 12:00 AM",pattern:"MMM d, yyyy p"}},Rg=aW.ZP.span(e=>{let{theme:t}=e;return(0,aW.iv)(rD||(rD=Rf(["\n font-weight: ",";\n "])),t.sanity.fonts.text.weights.medium)}),Rx=(0,aW.ZP)(lY.xv)(rZ||(rZ=Rf(["\n color: ",";\n"])),a8.VG.red[500].hex);function Rv(e){let{isDateTime:t,onChange:n,placeholderDate:i,isDateTimeFormat:r,value:l,...a}=e,o=(0,lK.useMemo)(()=>r?Rm.datetime.pattern:Rm.date.pattern,[r]),[s,d]=(0,lK.useState)(void 0),[c,u]=(0,lK.useState)(()=>{if(!l)return"";let e=new Date(l);return(0,oh.Z)(e,o)}),p=(0,lK.useMemo)(()=>{let e=i||new Date;return(0,oh.Z)(e,o)},[o,i]),h=(0,lK.useCallback)(e=>{let{dateString:i,triggerOnChange:r}=e;if(!i)return;let l=(0,oN.Z)(i,o,new Date),a=(0,oR.Z)(l);a&&(r&&n(Ru({date:l,dateOnly:!t})),u((0,oh.Z)(l,o))),d(a?void 0:"Invalid ".concat(t?"datetime":"date"))},[o,t,n]),f=(0,lK.useCallback)(()=>{h({dateString:c,triggerOnChange:!0})},[c,h]),m=(0,lK.useCallback)(e=>{u(e.currentTarget.value)},[]),g=(0,lK.useCallback)(()=>{n(null),d(void 0),u("")},[n]),x=(0,lK.useCallback)(e=>{"Enter"===e.key&&h({dateString:c,triggerOnChange:!0})},[c,h]);return(0,lK.useEffect)(()=>{let e=l&&new Date(l);e&&h({dateString:(0,oh.Z)(e,o),triggerOnChange:!1})},[o,h,r,l]),(0,lU.jsx)(lY.u,{content:(0,lU.jsxs)(lY.kC,{gap:2,children:[(0,lU.jsx)(Rx,{size:1,children:(0,lU.jsx)(a0.uIy,{})}),(0,lU.jsxs)(lY.xv,{muted:!0,size:1,children:["Must be in the format"," ",(0,lU.jsx)(Rg,{children:r?Rm.datetime.exampleDate:Rm.date.exampleDate})]})]}),disabled:!s,padding:3,placement:"top",portal:!0,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(Rc,{...a,clearButton:!!c,customValidity:s,onBlur:f,onChange:m,onClear:g,onKeyDown:x,placeholder:p,value:c})})})}function Rb(e){let{isDateTime:t,onChange:n,value:i}=e,{state:{fullscreen:r}}=MK(),l=(0,lK.useCallback)(e=>{let{date:r}=e;if(r){let e=Ru({date:r,dateOnly:!t});n({includeTime:null==i?void 0:i.includeTime,date:e})}else n(null)},[t,n,null==i?void 0:i.includeTime]),a=(0,lK.useCallback)(()=>{let e=!(null==i?void 0:i.includeTime),r=(null==i?void 0:i.date)?new Date(i.date):null,l=null;r&&(l=Ru({date:r,dateOnly:!t})),n({includeTime:e,date:l})},[t,n,i]),o=(0,lK.useCallback)(e=>{n({includeTime:null==i?void 0:i.includeTime,date:e||null})},[n,null==i?void 0:i.includeTime]);return(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(Rv,{"aria-label":"Date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:o,radius:2,value:null==i?void 0:i.date}),(0,lU.jsx)(Rl,{date:(null==i?void 0:i.date)?new Date(i.date):void 0,onChange:l,selectTime:t}),t&&(0,lU.jsx)(IH,{onChange:a,value:!!(null==i?void 0:i.includeTime)})]})}function Ry(e){return(0,lU.jsx)(Rb,{...e,isDateTime:!1})}function Rj(e){let{direction:t,isDateTime:n,onChange:i,value:r}=e,{state:{fullscreen:l}}=MK(),a=(0,lK.useMemo)(()=>{switch(t){case"after":return"end";case"before":return"start";default:return}},[t]),o=(0,lK.useCallback)(e=>{let{date:t}=e,l=null;t&&(l=Ru({date:t,dateOnly:!n,roundDay:(null==r?void 0:r.includeTime)?void 0:a})),i({includeTime:null==r?void 0:r.includeTime,date:l})},[n,i,a,null==r?void 0:r.includeTime]),s=(0,lK.useCallback)(()=>{let e=!(null==r?void 0:r.includeTime),t=(null==r?void 0:r.date)?new Date(r.date):null,l=null;t&&(l=Ru({date:t,dateOnly:!n,roundDay:e?"start":a})),i({includeTime:e,date:l})},[n,i,a,r]),d=(0,lK.useCallback)(e=>{i({includeTime:null==r?void 0:r.includeTime,date:e||null})},[i,null==r?void 0:r.includeTime]);return(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(Rv,{"aria-label":"Date",fontSize:l?2:1,isDateTime:n,isDateTimeFormat:n&&(null==r?void 0:r.includeTime),onChange:d,radius:2,value:null==r?void 0:r.date}),(0,lU.jsx)(Rl,{date:(null==r?void 0:r.date)?new Date(r.date):void 0,onChange:o,selectTime:n}),n&&(0,lU.jsx)(IH,{onChange:s,value:!!(null==r?void 0:r.includeTime)})]})}function Rw(e){let{onChange:t,value:n}=e,[i,r]=(0,lK.useState)((null==n?void 0:n.unitValue)||""),l=(0,lK.useRef)("days"),a=(0,lK.useRef)((null==n?void 0:n.unitValue)||null),{state:{fullscreen:o}}=MK(),s=(0,lK.useCallback)(()=>{t({unit:null==l?void 0:l.current,unitValue:null==a?void 0:a.current})},[t]),d=(0,lK.useCallback)(e=>{l.current=e.currentTarget.value,s()},[s]),c=(0,lK.useCallback)(e=>{r(e.currentTarget.value);let t=parseFloat(e.currentTarget.value);a.current=Number.isFinite(t)?t:null,s()},[s]);return(0,lU.jsxs)(lY.kC,{gap:2,children:[(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.oi,{"aria-label":"Unit value",fontSize:o?2:1,onChange:c,pattern:"\\d*",radius:2,step:"1",type:"number",value:i})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsxs)(lY.Ph,{"aria-label":"Select unit",fontSize:o?2:1,onChange:d,radius:2,value:null==n?void 0:n.unit,children:[(0,lU.jsx)("option",{value:"days",children:"Days"}),(0,lU.jsx)("option",{value:"months",children:"Months"}),(0,lU.jsx)("option",{value:"years",children:"Years"})]})})]})}function Rk(e){let{isDateTime:t,onChange:n,value:i}=e,{state:{fullscreen:r}}=MK(),l=(0,lK.useMemo)(()=>(0,ok.Z)(new Date,-7),[]),a=(0,lK.useMemo)(()=>new Date,[]),o=(0,lK.useCallback)(e=>{let{date:r,endDate:l}=e;n(RC({date:r,endDate:l,includeTime:null==i?void 0:i.includeTime,isDateTime:t}))},[t,n,null==i?void 0:i.includeTime]),s=(0,lK.useCallback)(()=>{let e=!(null==i?void 0:i.includeTime);n(RC({date:(null==i?void 0:i.dateMin)?new Date(i.dateMin):null,endD
1ate:(null==i?void 0:i.dateMax)?new Date(i.dateMax):null,includeTime:e,isDateTime:t}))},[t,n,i]),d=(0,lK.useCallback)(e=>{n({includeTime:null==i?void 0:i.includeTime,dateMax:e||null,dateMin:(null==i?void 0:i.dateMin)||null})},[n,i]),c=(0,lK.useCallback)(e=>{n({includeTime:null==i?void 0:i.includeTime,dateMax:(null==i?void 0:i.dateMax)||null,dateMin:e||null})},[n,i]);return(0,lU.jsx)("div",{children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.kC,{direction:"column",gap:3,children:[(0,lU.jsx)(Rv,{"aria-label":"Start date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:c,placeholderDate:l,radius:2,value:null==i?void 0:i.dateMin}),(0,lU.jsx)(Rv,{"aria-label":"End date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:d,placeholderDate:a,radius:2,value:null==i?void 0:i.dateMax})]}),(0,lU.jsx)(Rl,{date:(null==i?void 0:i.dateMin)?new Date(i.dateMin):void 0,endDate:(null==i?void 0:i.dateMax)?new Date(i.dateMax):void 0,onChange:o,selectRange:!0,selectTime:t}),t&&(0,lU.jsx)(IH,{onChange:s,value:!!(null==i?void 0:i.includeTime)})]})})}function RC(e){let{date:t,endDate:n,includeTime:i,isDateTime:r}=e;return i?{includeTime:i,dateMax:n?Ru({date:n,dateOnly:!r,roundDay:"start"}):null,dateMin:t?Ru({date:t,dateOnly:!r,roundDay:"start"}):null}:{includeTime:i,dateMax:n?Ru({date:n,dateOnly:!r,roundDay:"end"}):null,dateMin:t?Ru({date:t,dateOnly:!r,roundDay:"start"}):null}}function R_(e){return(0,lU.jsx)(Rb,{...e,isDateTime:!0})}let RS={dateAfter:{buttonLabel:"after",buttonValueComponent:MZ,initialValue:null,label:"is after"},dateBefore:{buttonLabel:"before",buttonValueComponent:MZ,initialValue:null,label:"is before"},dateEqual:{buttonLabel:"is",buttonValueComponent:MD,initialValue:{date:null,includeTime:!1},label:"is"},dateLast:{buttonLabel:"last",buttonValueComponent:function(e){var t;let{value:n}=e;return(0,lU.jsxs)(lU.Fragment,{children:[Math.floor(null!=(t=null==n?void 0:n.unitValue)?t:0)," ",n.unit]})},label:"is in the last"},dateNotEqual:{buttonLabel:"is not",buttonValueComponent:MD,initialValue:{date:null,includeTime:!1},label:"is not"},dateRange:{buttonLabel:"is between",initialValue:null,label:"is between"}},RT={dateAfter:{...RS.dateAfter,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," > ").concat(Ig(null==n?void 0:n.date)):null},inputComponent:function(e){return(0,lU.jsx)(Rj,{...e,direction:"after",isDateTime:!1})},type:"dateAfter"},dateBefore:{...RS.dateBefore,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," < ").concat(Ig(null==n?void 0:n.date)):null},inputComponent:function(e){return(0,lU.jsx)(Rj,{...e,direction:"before",isDateTime:!1})},type:"dateBefore"},dateEqual:{...RS.dateEqual,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," == ").concat(Ig(n.date)):null},inputComponent:Ry,type:"dateEqual"},dateLast:{...RS.dateLast,groqFilter:e=>{let{fieldPath:t,value:n}=e,i="number"==typeof(null==n?void 0:n.unitValue)?Math.floor(n.unitValue):void 0,r=Number.isFinite(i)?(0,oV.Z)(new Date,{days:(null==n?void 0:n.unit)==="days"?i:0,months:(null==n?void 0:n.unit)==="months"?i:0,years:(null==n?void 0:n.unit)==="years"?i:0}).toISOString().split("T")[0]:null;return r&&t?"".concat(t," > ").concat(Ig(r)):null},inputComponent:Rw,initialValue:{unit:"days",unitValue:7},type:"dateLast"},dateNotEqual:{...RS.dateNotEqual,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," != ").concat(Ig(n.date)):null},inputComponent:Ry,type:"dateNotEqual"},dateRange:{...RS.dateRange,buttonValueComponent:ML,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.dateMax)&&(null==n?void 0:n.dateMin)&&t?"".concat(t," >= ").concat(Ig(n.dateMin)," && ").concat(t," <= ").concat(Ig(n.dateMax)):null},initialValue:{includeTime:!1,dateMax:(0,oU.Z)().toISOString(),dateMin:null},inputComponent:function(e){return(0,lU.jsx)(Rk,{...e,isDateTime:!1})},type:"dateRange"},dateTimeAfter:{...RS.dateAfter,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"dateTime(".concat(t,") > dateTime(").concat(Ig(n.date),")"):null},inputComponent:function(e){return(0,lU.jsx)(Rj,{...e,direction:"after",isDateTime:!0})},type:"dateTimeAfter"},dateTimeBefore:{...RS.dateBefore,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"dateTime(".concat(t,") < dateTime(").concat(Ig(n.date),")"):null},inputComponent:function(e){return(0,lU.jsx)(Rj,{...e,direction:"before",isDateTime:!0})},type:"dateTimeBefore"},dateTimeEqual:{...RS.dateEqual,groqFilter:e=>{let{fieldPath:t,value:n}=e,i=(null==n?void 0:n.date)&&new Date(n.date);if(!i||!(0,oR.Z)(i)||!t)return null;let r=((null==n?void 0:n.includeTime)?(0,oB.Z)(i):(0,oq.Z)(i)).toISOString(),l=((null==n?void 0:n.includeTime)?(0,oK.Z)(i):(0,oL.Z)(i)).toISOString();return"dateTime(".concat(t,") > dateTime(").concat(Ig(r),") && dateTime(").concat(t,") < dateTime(").concat(Ig(l),")")},inputComponent:R_,type:"dateTimeEqual"},dateTimeLast:{...RS.dateLast,groqFilter:e=>{let{fieldPath:t,value:n}=e,i="number"==typeof(null==n?void 0:n.unitValue)?Math.floor(n.unitValue):void 0,r=Number.isFinite(i)?(0,oV.Z)(new Date,{days:(null==n?void 0:n.unit)==="days"?i:0,months:(null==n?void 0:n.unit)==="months"?i:0,years:(null==n?void 0:n.unit)==="years"?i:0}).toISOString():null;return r&&t?"dateTime(".concat(t,") > dateTime(").concat(Ig(r),")"):null},initialValue:{unit:"days",unitValue:7},inputComponent:Rw,type:"dateTimeLast"},dateTimeNotEqual:{...RS.dateNotEqual,groqFilter:e=>{let{fieldPath:t,value:n}=e,i=(null==n?void 0:n.date)&&new Date(n.date);if(!i||!(0,oR.Z)(i)||!t)return null;let r=((null==n?void 0:n.includeTime)?(0,oB.Z)(i):(0,oq.Z)(i)).toISOString(),l=((null==n?void 0:n.includeTime)?(0,oK.Z)(i):(0,oL.Z)(i)).toISOString();return"dateTime(".concat(t,") < dateTime(").concat(Ig(r),") || dateTime(").concat(t,") > dateTime(").concat(Ig(l),")")},inputComponent:R_,type:"dateTimeNotEqual"},dateTimeRange:{...RS.dateRange,buttonValueComponent:ML,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.dateMax)&&(null==n?void 0:n.dateMin)&&t?"dateTime(".concat(t,") >= dateTime(").concat(Ig(n.dateMin),") && dateTime(").concat(t,") <= dateTime(").concat(Ig(n.dateMax),")"):null},initialValue:{includeTime:!1,dateMax:(0,oU.Z)().toISOString(),dateMin:null},inputComponent:function(e){return(0,lU.jsx)(Rk,{...e,isDateTime:!0})},type:"dateTimeRange"}};function RE(e){let{onChange:t,value:n}=e,{state:{fullscreen:i}}=MK(),r=(0,lK.useCallback)(e=>t(e.currentTarget.value||null),[t]);return(0,lU.jsx)(lY.oi,{fontSize:i?2:1,onChange:r,placeholder:"Value",radius:2,value:n||""})}let RP={referenceEqual:{buttonLabel:"is",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,"._ref == ").concat(Ig(n._ref)):null}
1,initialValue:null,inputComponent:Id,label:"is",type:"referenceEqual"},referenceNotEqual:{buttonLabel:"is not",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,"._ref != ").concat(Ig(n._ref)):null},initialValue:null,inputComponent:Id,label:"is not",type:"referenceNotEqual"},referencesAssetFile:{buttonLabel:"â",buttonValueComponent:MV,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(Ig(t._ref),")"):null},initialValue:null,inputComponent:Iq("file"),label:"file",type:"referencesAssetFile"},referencesAssetImage:{buttonLabel:"â",buttonValueComponent:MV,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(Ig(t._ref),")"):null},initialValue:null,inputComponent:Iq("image"),label:"image",type:"referencesAssetImage"},referencesDocument:{buttonLabel:"â",buttonValueComponent:MV,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(Ig(t._ref),")"):null},initialValue:null,inputComponent:Id,label:"document",type:"referencesDocument"}},RA={arrayCountEqual:{buttonLabel:"has",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") == ").concat(Ig(n)):null},initialValue:null,inputComponent:MH,label:"quantity is",type:"arrayCountEqual"},arrayCountGt:{buttonLabel:"has >",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") > ").concat(Ig(n)):null},icon:Ih,initialValue:null,inputComponent:MH,label:"quantity greater than",type:"arrayCountGt"},arrayCountGte:{buttonLabel:"has â¥",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") >= ").concat(Ig(n)):null},icon:Ip,initialValue:null,inputComponent:MH,label:"quantity greater than or equal to",type:"arrayCountGte"},arrayCountLt:{buttonLabel:"has <",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") < ").concat(Ig(n)):null},icon:Im,initialValue:null,inputComponent:MH,label:"quantity less than",type:"arrayCountLt"},arrayCountLte:{buttonLabel:"has â¤",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") <= ").concat(Ig(n)):null},icon:If,initialValue:null,inputComponent:MH,label:"quantity less than or equal to",type:"arrayCountLte"},arrayCountNotEqual:{buttonLabel:"does not have",buttonValueComponent:MN,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") != ").concat(Ig(n)):null},initialValue:null,inputComponent:MH,label:"quantity is not",type:"arrayCountNotEqual"},arrayCountRange:{buttonLabel:"has between",buttonValueComponent:function(e){let{value:t}=e;return(0,lU.jsxs)(lU.Fragment,{children:[t.min," â ",t.max," items"]})},groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(null==n?void 0:n.max)&&Number.isFinite(null==n?void 0:n.min)&&t?"count(".concat(t,") > ").concat(Ig(null==n?void 0:n.min)," && count(").concat(t,") < ").concat(Ig(null==n?void 0:n.max)):""},initialValue:null,inputComponent:MW,label:"quantity is between",type:"arrayCountRange"},arrayListIncludes:{buttonLabel:"includes",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(Ig(n)," in ").concat(t):null},initialValue:null,inputComponent:Iu,label:"includes",type:"arrayListIncludes"},arrayListNotIncludes:{buttonLabel:"does not include",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(Ig(n)," in ").concat(t,")"):null},initialValue:null,inputComponent:Iu,label:"does not include",type:"arrayListNotIncludes"},arrayReferenceIncludes:{buttonLabel:"includes",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(Ig(n._ref)," in ").concat(t,"[]._ref"):null},initialValue:null,inputComponent:Id,label:"includes",type:"arrayReferenceIncludes"},arrayReferenceNotIncludes:{buttonLabel:"does not include",buttonValueComponent:MV,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"!(".concat(Ig(n._ref)," in ").concat(t,"[]._ref)"):null}
1,initialValue:null,inputComponent:Id,label:"does not include",type:"arrayReferenceNotIncludes"},...IN,booleanEqual:{buttonLabel:"is",buttonValueComponent:function(e){let{value:t}=e;return(0,lU.jsx)(lU.Fragment,{children:t?"True":"False"})},groqFilter:e=>{let{fieldPath:t,value:n}=e;return void 0!==n&&t?"".concat(t," == ").concat(Ig(n)):null},initialValue:!0,inputComponent:function(e){let{onChange:t,value:n}=e,{state:{fullscreen:i}}=MK(),r=(0,lK.useCallback)(e=>{t("true"===e.currentTarget.value)},[t]);return(0,lU.jsxs)(lY.Ph,{fontSize:i?2:1,onChange:r,radius:2,value:String(null==n||n),children:[(0,lU.jsx)("option",{value:"true",children:"True"}),(0,lU.jsx)("option",{value:"false",children:"False"})]})},label:"is",type:"booleanEqual"},...RT,defined:{buttonLabel:"not empty",groqFilter:e=>{let{fieldPath:t}=e;return t?"defined(".concat(t,")"):null},label:"not empty",type:"defined"},notDefined:{buttonLabel:"empty",groqFilter:e=>{let{fieldPath:t}=e;return t?"!defined(".concat(t,")"):null},label:"empty",type:"notDefined"},numberEqual:{buttonLabel:"is",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," == ").concat(Ig(n)):null},initialValue:null,inputComponent:MH,label:"is",type:"numberEqual"},numberGt:{buttonLabel:">",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," > ").concat(Ig(n)):null},icon:Ih,initialValue:null,inputComponent:MH,label:"greater than",type:"numberGt"},numberGte:{buttonLabel:"â¥",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," >= ").concat(Ig(n)):null},icon:Ip,initialValue:null,inputComponent:MH,label:"greater than or equal to",type:"numberGte"},numberLt:{buttonLabel:"<",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," < ").concat(Ig(n)):null},icon:Im,initialValue:null,inputComponent:MH,label:"less than",type:"numberLt"},numberLte:{buttonLabel:"â¤",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," <= ").concat(Ig(n)):null},icon:If,initialValue:null,inputComponent:MH,label:"less than or equal to",type:"numberLte"},numberNotEqual:{buttonLabel:"is not",buttonValueComponent:Mq,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," != ").concat(Ig(n)):null},initialValue:null,inputComponent:MH,label:"is not",type:"numberNotEqual"},numberRange:{buttonLabel:"is between",buttonValueComponent:function(e){let{value:t}=e;return(0,lU.jsxs)(lU.Fragment,{children:[t.min," â ",t.max]})},groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(null==n?void 0:n.max)&&Number.isFinite(null==n?void 0:n.min)&&t?"".concat(t," > ").concat(Ig(null==n?void 0:n.min)," && ").concat(t," < ").concat(Ig(null==n?void 0:n.max)):""},initialValue:null,inputComponent:MW,label:"is between",type:"numberRange"},portableTextEqual:{buttonLabel:"is",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") == ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is",type:"portableTextEqual"},portableTextMatches:{buttonLabel:"contains",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") match ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"contains",type:"portableTextMatches"},portableTextNotEqual:{buttonLabel:"is not",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") != ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is not",type:"portableTextNotEqual"},portableTextNotMatches:{buttonLabel:"does not contain",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(pt::text(".concat(t,") match ").concat(Ig(n),")"):null},initialValue:null,inputComponent:RE,label:"does not contain",type:"portableTextNotMatches"},...RP,slugEqual:{buttonLabel:"is",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current == ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is",type:"slugEqual"},slugMatches:{buttonLabel:"contains",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current match ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"contains",type:"slugMatches"},slugNotEqual:{buttonLabel:"is not",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current != ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is not",type:"slugNotEqual"},slugNotMatches:{buttonLabel:"does not contain",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(t,".current match ").concat(Ig(n),")"):null},initialValue:null,inputComponent:RE,label:"does not contain",type:"slugNotMatches"},stringEqual:{buttonLabel:"is",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," == ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is",type:"stringEqual"},stringListEqual:{buttonLabel:"is",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," == ").concat(Ig(n)):null},initialValue:null,inputComponent:Iu,label:"is",type:"stringListEqual"},stringListNotEqual:{buttonLabel:"is not",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," != ").concat(Ig(n)):null},initialValue:null,inputComponent:Iu,label:"is not",type:"stringListNotEqual"},stringMatches:{buttonLabel:"contains",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," match ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"contains",type:"stringMatches"},stringNotEqual:{buttonLabel:"is not",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," != ").concat(Ig(n)):null},initialValue:null,inputComponent:RE,label:"is not",type:"stringNotEqual"},stringNotMatches:{buttonLabel:"does not contain",buttonValueComponent:MU,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(t," match ").concat(Ig(n),")"):null},initialValue:null,inputComponent:RE,label:"does not contain",type:"stringNotMatches"}},RO=Object.values(RA);function Rz(e){let t=typeof e;if("object"===t){if(null===e)return"null";if(Array.isArray(e))return"array";if(e instanceof Object&&"Object"!==e.constructor.name)return e.constructor.name}return t}let RM=[],RI=[],RR=[],RF=(e,t,n)=>{let{schema:i}=t,r=null==i?void 0:i.types;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `schema.types` to be an array or a function, but received ".concat(Rz(r)))},RD=async(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.productionUrl;return r?await r(e,n):e},RZ=(e,t,n)=>{let{tools:i}=t;if(!i)return e;if("function"==typeof i)return i(e,n);if(Array.isArray(i))return[...e,...i];throw Error("Expected `tools` to be an array or a function, but received ".concat(Rz(i)))},RL=(e,t,n)=>{let{schema:i}=t,r=null==i?void 0:i.templates;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `schema.templates` to be an array or a function, but received ".concat(Rz(r)))},Rq=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.badges;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `document.badges` to be an array or a function, but received ".concat(Rz(r)))},RN=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.actions;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `document.actions` to be an array or a function, but received ".concat(Rz(r)))},RV=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.newDocumentOptions;if(!r)return e;if("function"!=typeof r)throw Error("Expected `document.resolveNewDocumentOptions` to be a function, but received ".concat(Rz(r)));return r(e,n)},RU=(e,t,n)=>{var i;let{form:r}=t,l=null==(i=null==r?void 0:r.file)?void 0:i.assetSources;if(!l)return e;if("function"==typeof l)return l(e,n);if(Array.isArray(l))return[...e,...l];throw Error("Expected `form.file.assetSources` to be an array or a function, but received ".concat(Rz(l)))},RB=(e,t,n)=>{var i;let{form:r}=t,l=null==(i=null==r?void 0:r.image)?void 0:i.assetSources;if(!l)return e;if("function"==typeof l)return l(e,n);if(Array.isArray(l))return[...e,...l];throw Error("Expected `form.image.assetSources` to be an array or a function, but received ".concat(Rz(l)))},RK=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.unstable_languageFilter;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `document.unstable_languageFilter` to be an array or a function, but received ".concat(Rz(r)))},RH=(e,t,n)=>{let{document:i}=t,r=null==i?void 0:i.inspectors;if(!r)return e;if("function"==typeof r)return r(e,n);if(Array.isArray(r))return[...e,...r];throw Error("Expected `document.inspectors` to be an array or a function, but received ".concat(Rz(r)))};
1var RW=Object.defineProperty,R$=(e,t,n)=>t in e?RW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RX=(e,t,n)=>(R$(e,"symbol"!=typeof t?t+"":t,n),n);class RG extends Error{constructor(e){let{propertyName:t,path:n,cause:i}=e,r=cc(i)&&"string"==typeof(null==i?void 0:i.message)?": ".concat(i.message):"";super("An error occurred while resolving `".concat(t,"` from ").concat(n.join(" > ")).concat(r)),RX(this,"propertyName"),RX(this,"path"),RX(this,"cause"),this.propertyName=t,this.cause=i,this.path=n}}let RY=(e,t)=>{let{plugins:n=[],...i}=e,r={config:i,path:[...t,i.name]},l=n.flatMap(e=>RY(e,[...t,i.name])),a=[...l,r];return a};function RJ(e){let{config:t,context:n,initialValue:i,propertyName:r,...l}=e,a=RY(t,[]);if("reducer"in l)return a.reduce((e,t)=>{let{config:i,path:a}=t;try{return l.reducer(e,i,n)}catch(e){throw new RG({propertyName:r,path:a,cause:e})}},i);let o=l.asyncReducer;return(async()=>{let e=i;for(let{config:t,path:i}of a)try{e=await o(e,t,n)}catch(e){throw new RG({propertyName:r,path:i,cause:e})}return e})()}var RQ=Object.defineProperty,R0=(e,t,n)=>t in e?RQ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R1=(e,t,n)=>(R0(e,"symbol"!=typeof t?t+"":t,n),n);class R2 extends Error{constructor(e){let{causes:t,name:n,type:i}=e,r=t.filter(Boolean).map(e=>cc(e)&&"string"==typeof(null==e?void 0:e.message)?e.message:String(e));super("Could not resolve ".concat(i).concat(n?" `".concat(n,"`"):"",":\n").concat(r.map(e=>" - ".concat(e)).join("\n"),"\n\n")),R1(this,"name"),R1(this,"type"),R1(this,"causes"),this.name=n,this.causes=t,this.type=i}}class R3 extends Error{constructor(e){super("SchemaError"),this.schema=e}}var R4=Object.freeze,R5=Object.defineProperty;function R6(e){let t=e.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0);return Math.abs(16807*t%2147483647)/2147483647}let R8=aW.ZP.text(rL||(rL=R4(R5(eo=["\n font-family: ",";\n font-weight: ",";\n font-size: 16px;\n transform: translateY(1px);\n"],"raw",{value:R4(eo.slice())}))),e=>{let{theme:t}=e;return t.sanity.fonts.heading.family},e=>{let{theme:t}=e;return t.sanity.fonts.heading.weights.bold}),R9=e=>"error"===e.severity;function R7(e){let{projectId:t,dataset:n,schema:i,currentUser:r,getClient:l}=e;return(0,lK.useMemo)(()=>({projectId:t,dataset:n,schema:i,currentUser:r,getClient:l}),[t,n,i,r,l])}function Fe(e){let{projectId:t,dataset:n,schema:i,currentUser:r,getClient:l}=e;return{projectId:t,dataset:n,schema:i,currentUser:r,getClient:l}}function Ft(e){let{title:t}=e;return(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsx)(lY.xv,{weight:"bold",children:t})})}let Fn=(0,lK.createContext)(null),Fi=(0,lK.createContext)(null);function Fr(){let e=(0,lY.ue)();return e?"dark":"light"}function Fl(e){let{children:t,scheme:n}=e,i=Fr(),r="system"===n?i:n;return(0,lU.jsx)(lY.f6,{scheme:r,theme:lY.Lg,children:t})}let Fa="sanityStudio:ui:colorScheme";function Fo(e){let{children:t,onSchemeChange:n,scheme:i}=e;return i?(0,lU.jsx)(Fc,{scheme:i,onSchemeChange:n,children:t}):(0,lU.jsx)(Fs,{onSchemeChange:n,children:t})}function Fs(e){let{children:t,onSchemeChange:n}=e,i=(0,lK.useMemo)(()=>{let e;let t=new Set;return{subscribe:n=>(e||(e=Fd(localStorage.getItem(Fa))||"system"),t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,setSnapshot:n=>{for(let i of(e=Fd(n),t))i()},getServerSnapshot:()=>"system"}},[]),r=(0,lK.useSyncExternalStore)(i.subscribe,i.getSnapshot,i.getServerSnapshot);return(0,lK.useEffect)(()=>{"function"==typeof n&&n(r),localStorage.setItem(Fa,r)},[n,r]),(0,lU.jsx)(Fi.Provider,{value:i.setSnapshot,children:(0,lU.jsx)(Fn.Provider,{value:r,children:(0,lU.jsx)(Fl,{scheme:r,children:t})})})}function Fd(e){switch(e){case"dark":case"light":return e;default:return"system"}}function Fc(e){let{children:t,onSchemeChange:n,scheme:i}=e;return(0,lU.jsx)(Fi.Provider,{value:"function"==typeof n&&n,children:(0,lU.jsx)(Fn.Provider,{value:i,children:(0,lU.jsx)(Fl,{scheme:i,children:t})})})}function Fu(){let e=(0,lK.useContext)(Fi);if(null===e)throw Error("Could not find `ColorSchemeSetValueContext` context");return e}function Fp(){let e=(0,lK.useContext)(Fn);if(null===e)throw Error("Could not find `ColorSchemeValueContext` context");return e}function Fh(){let e=Fp(),t=Fr();return"system"===e?t:e}function Ff(){let e=Fh(),t=Fu();return(0,lK.useMemo)(()=>({scheme:e,setScheme:t}),[e,t])}function Fm(e){let t=Fp();return(0,lK.useMemo)(()=>[{title:"System",name:"system",label:"Use system appearance",selected:"system"===t,onSelect:()=>e("system"),icon:a0.ugZ},{title:"Dark",name:"dark",label:"Use dark appearance",selected:"dark"===t,onSelect:()=>e("dark"),icon:a0.kLh},{title:"Light",name:"light",label:"Use light appearance",selected:"light"===t,onSelect:()=>e("light"),icon:a0.NWY}],[t,e])}let Fg=(0,lK.createContext)(null);
1function Fx(e){let{config:t,children:n,basePath:i}=e,{workspaces:r}=(0,lK.useMemo)(()=>(function(e,t){if(!Array.isArray(e)&&"missingConfigFile"in e)throw new R2({name:"",type:"configuration file",causes:["No `sanity.config.ts` file found","No `sanity.config.js` file found"]});let n=function(e){let t=e||"";if("string"!=typeof t||t.length>0&&!t.startsWith("/"))throw new R2({name:"",type:"options",causes:["basePath must be a string, and must start with a slash"]});return"/"===t?"":t}(null==t?void 0:t.basePath),i=Array.isArray(e)?e:[e];try{!function(e){let{workspaces:t}=e;if(0===t.length)throw new FC("At least one workspace is required.");(function(e){let t=1===e.length,n=new Map;e.forEach((e,i)=>{let{name:r,title:l}=e,a=Fb(l,i);if(!r&&!t)throw new FC("All workspaces must have a `name`, unless only a single workspace is defined. "+"Workspace ".concat(a," did not define a `name`."),{workspace:e,index:i});let o=t&&void 0===r?"default":r;if("string"!=typeof o)throw new FC("Workspace at index ".concat(i," defined an invalid `name` - must be a string."),{workspace:e,index:i});let s=o.toLowerCase(),d=n.get(s);if(d){let t=Fb(d.workspace.title,d.index);throw new FC("`name`s must be unique. Workspace ".concat(t," and ")+"workspace ".concat(a," both have the `name` `").concat(o,"`"),{workspace:e,index:i})}if(n.set(s,{index:i,workspace:e}),!/^[a-z0-9][a-z0-9_-]*$/i.test(o))throw new FC("All workspace `name`s must consist of only a-z, 0-9, underscore and dashes, and cannot begin with an underscore or dash. "+"Workspace ".concat(a," has the invalid name `").concat(o,"`"),{workspace:e,index:i})})})(t),function(e){e.length>1&&e.every(F_),e.every(FS);let[t,...n]=e,i=(t.basePath||"/").substring(1).split("/").filter(Boolean).length;n.forEach((e,n)=>{let r=(e.basePath||"/").substring(1).split("/").length;if(i!==r)throw new FC("All workspace `basePath`s must have the same amount of segments. Workspace `".concat(Fv(t,n),"` had ").concat(i," segment").concat(1===i?"":"s"," `").concat(t.basePath,"` but workspace `").concat(Fv(e,n),"` had ").concat(r," segment").concat(1===r?"":"s"," `").concat(e.basePath,"`"),{workspace:e,index:n})});let r=new Map;e.forEach((e,t)=>{let n=(e.basePath||"").toLowerCase(),i=r.get(n);if(i)throw new FC("`basePath`s must be unique. Workspaces `".concat(i,"` and ")+"`".concat(Fv(e,t),"` both have the `basePath` `").concat(n,"`"),{workspace:e,index:t});r.set(n,Fv(e,t))})}(t)}({workspaces:i})}catch(e){throw new R2({name:"",type:"workspace",causes:[e.message]})}let r=i.map(e=>{let{unstable_sources:t=[],...i}=e,r=[i,...t],l=r.map(e=>{let t;let{projectId:n,dataset:i}=e;try{t=RJ({propertyName:"schema.types",config:e,context:{projectId:n,dataset:i},initialValue:[],reducer:RF})}catch(t){throw new R2({name:e.name,type:"source",causes:[t]})}let r=function(e){let t=(0,os.Fv)(e.types).getTypes(),n=(0,os._T)(t),i=n.some(e=>e.problems.some(fj)),r=oo.V.compile({name:e.name,types:i?[]:[...e.types,...fw].filter(Boolean)});return r._validation=n,function(e){let t=e.getTypeNames();return t.forEach(t=>{let n=e.get(t);n&&function e(t,n){if(!n.has(t)){if(n.add(t),t.validation=fx(t),"fields"in t)for(let i of t.fields)e(i.type,n);if("of"in t)for(let i of t.of)e(i,n);if(t.annotations)for(let i of t.annotations)e(i,n)}}(n,new Set)}),e}(r)}({name:e.name,types:t}),l=r._validation,a=null==l?void 0:l.filter(e=>e.problems.some(R9));if(l&&(null==a?void 0:a.length))throw new R3(r);let o=function(e){var t;if(cc(t=e.auth)&&"state"in t&&cc(t.state)&&"subscribe"in t.state&&"function"==typeof t.state.subscribe)return e.auth;let n=e.unstable_clientFactory||a9.eI,{projectId:i,dataset:r,apiHost:l}=e;return hv({apiHost:l,...e.auth,clientFactory:n,dataset:r,projectId:i})}(e),s=o.state.pipe((0,ad.U)(t=>{let{client:n,authenticated:i,currentUser:l}=t;return function(e){var t,n,i,r;let l,a,o,{config:s,client:d,currentUser:c,schema:u,authenticated:p,auth:h}=e,{dataset:f,projectId:m}=s,g=function(e,t){let n=e.withConfig({apiVersion:"2022-06-30"}),{dataset:i,url:r,requestTagPrefix:l="sanity.studio"}=n.config(),a="".concat(r.replace(/\/+$/,""),"/socket/").concat(i).replace(/^http/,"ws"),o="".concat(a,"?tag=").concat(l),s=t.token?{token$:t.token}:{};return(0,oa.W0)(o,s)}(d,h),x=[],v={},b=e=>{if(!e||!e.apiVersion)throw Error("Missing required `apiVersion` option");return v[e.apiVersion]||(v[e.apiVersion]=d.withConfig(e)),v[e.apiVersion]},y={client:d,getClient:b,currentUser:c,dataset:f,projectId:m,schema:u};y.client=[...Object.keys(d),...Object.keys(d.__proto__)].reduce((e,t)=>
1{let n=Object.hasOwnProperty.call(d,t)?d[t]:d.__proto__[t];return Object.defineProperty(e,t,{get:()=>(console.warn('`configContext.client` is deprecated and will be removed in the next release! Use `context.getClient({apiVersion: "2021-06-07"})` instead'),n)})},{});try{l=RJ({config:s,context:y,propertyName:"schema.templates",reducer:RL,initialValue:u.getTypeNames().filter(e=>!/^sanity\./.test(e)).map(e=>u.get(e)).filter(d9).filter(e=>{var t;return(null==(t=e.type)?void 0:t.name)==="document"}).map(e=>{let t={id:e.name,schemaType:e.name,title:e.title||e.name,icon:e.icon,value:e.initialValue||{_type:e.name}};return t})})}catch(e){throw new R2({name:s.name,type:"source",causes:[e]})}try{a=RJ({config:s,context:y,initialValue:[],propertyName:"tools",reducer:RZ})}catch(e){throw new R2({name:s.name,type:"source",causes:[e]})}if(a.some(e=>{let{name:t}=e;return"tool"===t}))throw Error('A tool cannot have the name "tool". Please enter a different name.');let j=l.filter(e=>{var t;return!(null==(t=e.parameters)?void 0:t.length)}).map(e=>({templateId:e.id,description:e.description,icon:e.icon,title:e.title})),w=l.reduce((e,t)=>(e.set(t.id,t),e),new Map),k=e=>{let{schemaType:t}=e,n=RJ({config:s,context:{...y,creationContext:e},initialValue:j,propertyName:"document.resolveNewDocumentOptions",reducer:RV}),i=[];if(i.length)throw new R2({name:s.name,type:"source",causes:i});return n.map((e,t)=>{let n=w.get(e.templateId);if(!n)throw Error("Could not find template with ID `".concat(e.templateId,"`"));let i=u.get(n.schemaType);if(!i)throw Error("Could not find matching schema type `".concat(n.schemaType,"` for template `").concat(n.id,"`"));let r=e.title||n.title,l=(null==i?void 0:i.title)===r?void 0:null==i?void 0:i.title;return{id:"".concat(e.templateId,"-").concat(t),templateId:e.templateId,type:"initialValueTemplateItem",title:r,subtitle:e.subtitle||l,description:e.description||n.description,icon:e.icon||n.icon||(null==i?void 0:i.icon),initialDocumentId:e.initialDocumentId,parameters:e.parameters,schemaType:n.schemaType}}).filter(n=>{var i;return!t||"document"===e.type||t===(null==(i=w.get(n.templateId))?void 0:i.schemaType)})};try{o=k({type:"global"})}catch(e){x.push(e)}if(x.length)throw new R2({name:s.name,type:"source",causes:x});let C={type:"source",name:s.name,title:s.title||ol()(s.name),schema:u,getClient:b,dataset:f,projectId:m,tools:a,currentUser:c,authenticated:p,templates:l,auth:h,document:{actions:e=>RJ({config:s,context:{...y,...e},initialValue:RI,propertyName:"document.actions",reducer:RN}),badges:e=>RJ({config:s,context:{...y,...e},initialValue:RM,propertyName:"document.badges",reducer:Rq}),unstable_fieldActions:e=>RJ({config:s,context:{...y,...e},initialValue:hz,propertyName:"document.unstable_fieldActions",reducer:hO}),inspectors:e=>RJ({config:s,context:{...y,...e},initialValue:co,propertyName:"document.inspectors",reducer:RH}),resolveProductionUrl:e=>RJ({config:s,context:{...y,...e},initialValue:void 0,propertyName:"resolveProductionUrl",asyncReducer:RD}),resolveNewDocumentOptions:k,unstable_languageFilter:e=>RJ({config:s,context:{...y,...e},initialValue:RR,propertyName:"document.unstable_languageFilter",reducer:RK})},form:{file:{assetSources:RJ({config:s,context:y,initialValue:[Mz],propertyName:"formBuilder.file.assetSources",reducer:RU}),directUploads:(null==(n=null==(t=s.form)?void 0:t.file)?void 0:n.directUploads)===void 0||s.form.file.directUploads},image:{assetSources:RJ({config:s,context:y,initialValue:[MM],propertyName:"formBuilder.image.assetSources",reducer:RB}),directUploads:(null==(r=null==(i=s.form)?void 0:i.image)?void 0:r.directUploads)===void 0||s.form.image.directUploads}},search:{filters:MI,operators:RO},__internal:{bifur:g,staticInitialValueTemplateItems:o,options:s}};return C}({config:e,client:n,currentUser:l,schema:r,authenticated:i,auth:o})}),(0,am.d)(1));return{name:e.name,projectId:e.projectId,dataset:e.dataset,title:e.title||ol()(e.name),auth:o,schema:r,source:s}}),a=i.title||ol()(i.name),o={type:"workspace-summary",auth:l[0].auth,basePath:function(e,t){let n=[e,t||""].map(e=>
1e.replace(/^\/+/g,"").replace(/\/+$/g,"")).filter(Boolean).join("/");return"/".concat(n)}(n,i.basePath),dataset:i.dataset,schema:l[0].schema,icon:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return(0,a6.isValidElementType)(e)?(0,lK.createElement)(e):(0,lK.isValidElement)(e)?e:function(e,t){let n=R6("".concat(e," ").concat(t)),i=a8.mE.filter(e=>"gray"!==e),r=i[Math.floor(n*i.length)],l=["300","400","500","600","700"],a=R6(n.toString()),o=l[Math.floor(a*l.length)],s=a8.VG[r][o].hex,d=e.split(/\s/g).map(e=>e.replace(/\\W/g,"")).filter(Boolean).slice(0,2).map(e=>e.charAt(0).toUpperCase()),c=(0,dh._j)(s,.4),u=(0,dh.$n)(s,.4),p=(0,dh.WC)(s,"readable",c)?(0,dh.WC)(s,"readable",u)?(0,dh.XV)(s):u:c;return(0,lU.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:[(0,lU.jsx)("rect",{width:32,height:32,rx:2,fill:s}),(0,lU.jsx)(R8,{x:"50%",y:"50%",textAnchor:"middle",alignmentBaseline:"middle",dominantBaseline:"middle",fill:p,children:d})]})}(t,n)}(i.icon,a,"".concat(i.projectId," ").concat(i.dataset)),name:i.name||"default",projectId:i.projectId,theme:i.theme||lY.Lg,title:a,subtitle:i.subtitle,__internal:{sources:l}};return o});return{type:"prepared-config",workspaces:r}})(t,{basePath:i}),[t,i]);return(0,lU.jsx)(Fg.Provider,{value:r,children:n})}function Fv(e,t){let{name:n,title:i}=e;return"string"==typeof n&&n.trim().length>0?n:Fb(i,t)}function Fb(e,t){let n="string"==typeof e&&e.trim().length>0?' (titled "'.concat(e,'")'):"";return"at index ".concat(t).concat(n)}function Fy(){let e=(0,lK.useContext)(Fg);if(!e)throw Error("Could not find `workspaces` context");return e}var Fj=Object.defineProperty,Fw=(e,t,n)=>t in e?Fj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fk=(e,t,n)=>(Fw(e,"symbol"!=typeof t?t+"":t,n),n);class FC extends Error{constructor(e,t){super(e),Fk(this,"index"),Fk(this,"identifier"),this.index=null==t?void 0:t.index,this.identifier=(null==t?void 0:t.workspace)&&Fv(t.workspace,t.index)}}function F_(e,t){let{name:n,basePath:i}=e;if(i&&"string"==typeof i)return!0;if(void 0===i)throw new FC("If more than one workspace is defined, every workspace must have a `basePath` defined. "+"Workspace `".concat(n,"` is missing a `basePath`"),{workspace:e,index:t});throw new FC("If more than one workspace is defined, every workspace must have a `basePath` defined. "+"Workspace `".concat(n,"` has an invalid `basePath` (must be a non-empty string)"),{workspace:e,index:t})}function FS(e,t){let{name:n,basePath:i}=e;if(i&&"/"!==i&&!/^\/[a-z0-9/_-]*[a-z0-9_-]+$/i.test(i))throw new FC("All workspace `basePath`s must start with a leading `/`, consist of only URL safe characters, and cannot end with a trailing `/`. "+"Workspace `".concat(n,"`'s basePath is `").concat(i,"`"),{workspace:e,index:t})}function FT(){return(0,lU.jsx)(lY.Zb,{height:"fill",children:(0,lU.jsx)(lY.kC,{align:"center",height:"fill",justify:"center",padding:4,sizing:"border",children:(0,lU.jsx)(lY.W2,{width:0,children:(0,lU.jsx)(lY.Zb,{padding:4,radius:2,shadow:1,tone:"caution",children:(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsxs)(lY.Kq,{flex:1,marginLeft:3,space:3,children:[(0,lU.jsx)(lY.xv,{as:"h1",size:1,weight:"bold",children:"No configured tools"}),(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:"Please configure a tool in your Studio configuration."}),(0,lU.jsx)(lY.xv,{as:"p",muted:!0,size:1,children:(0,lU.jsx)("a",{href:"https://www.sanity.io/docs/studio-tools",rel:"noreferrer",target:"_blank",children:"Learn how to add a tool â"})})]})]})})})})})}function FE(e){let{toolName:t}=e;return(0,lU.jsx)(lY.Zb,{height:"fill",children:(0,lU.jsx)(lY.kC,{align:"center",height:"fill",justify:"center",padding:4,sizing:"border",children:(0,lU.jsx)(lY.W2,{width:0,children:(0,lU.jsx)(lY.Zb,{padding:4,radius:2,shadow:1,tone:"caution",children:(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsx)(lY.Kq,{flex:1,marginLeft:3,space:3,children:(0,lU.jsxs)(lY.xv,{as:"h1",size:1,weight:"bold",children:["Tool not found: ",(0,lU.jsx)("code",{children:t})]})})]})})})})})}function FP(){return(0,lU.jsxs)(lY.kC,{as:lY.Zb,justify:"center",align:"center",height:"fill",direction:"column",gap:4,children:[(0,lU.jsx)(lY.xv,{muted:!0,children:"Loadingâ¦"}),(0,lU.jsx)(lY.$j,{muted:!0}
1)]})}var FA=Object.freeze,FO=Object.defineProperty,Fz=(e,t)=>FA(FO(e,"raw",{value:FA(t||e.slice())}));let FM={error:"critical",warning:"caution"},FI=aW.ZP.code(rq||(rq=Fz(["\n && {\n background: none;\n color: inherit;\n }\n"]))),FR=(0,aW.ZP)(lY.xv)(rN||(rN=Fz(["\n white-space: pre-line;\n"])));function FF(e){let{problemGroups:t}=e,n=(0,lK.useMemo)(()=>{let e=[];for(let n of t)for(let t of n.problems)e.push({group:n,problem:t});return e},[t]);return(0,lU.jsx)(lY.Kq,{as:"ul",space:4,children:n.map((e,t)=>{let{group:n,problem:i}=e,r="error"===i.severity,l="warning"===i.severity,a=function(e){let t=e.path[0];return"type"===t.kind?{name:t.name,type:t.type}:null}(n);return(0,lU.jsxs)(lY.Zb,{border:!0,padding:4,radius:2,tone:FM[i.severity],children:[(0,lU.jsxs)(lY.kC,{children:[(0,lU.jsx)(lY.xu,{marginRight:3,children:(0,lU.jsxs)(lY.xv,{muted:!0,size:1,children:[r&&(0,lU.jsx)(a0.uIy,{}),l&&(0,lU.jsx)(a0.foC,{})]})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(lY.xv,{size:1,weight:"semibold",children:a?(0,lU.jsxs)(lU.Fragment,{children:[sL()(a.type),' type "',a.name,'"']}):null})})]}),(0,lU.jsx)(lY.xu,{marginTop:4,children:(0,lU.jsx)(lY.Zb,{border:!0,overflow:"auto",padding:2,tone:"inherit",children:(0,lU.jsx)(lY.Oo,{separator:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"â"}),children:n.path.map((e,t)=>"type"===e.kind?(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(FI,{children:"".concat(function(e){if(null==e?void 0:e.startsWith("<unnamed_type_@_index")){let t=e.slice(1,-1).split("_");return"[".concat(t[4],"]")}return e}(e.name),":").concat(e.type)})},t):"property"===e.kind?(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(FI,{children:e.name})},t):null)})})}),(0,lU.jsx)(lY.xu,{as:"ul",marginTop:4,children:(0,lU.jsx)(lY.xu,{as:"li",children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(FR,{muted:!0,size:1,children:i.message}),i.helpId&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:(0,lU.jsx)("a",{href:(0,dM.h)(i.helpId),target:"_blank",rel:"noopener noreferrer",children:"View documentation â"})})]})})})]},t)})})}function FD(e){var t;let{schema:n}=e,i=(null==(t=n._validation)?void 0:t.filter(e=>e.problems.some(e=>"error"===e.severity)))||[];return(0,lK.useEffect)(()=>(function(e){let t=e._validation,n=null==t?void 0:t.filter(e=>e.problems.some(e=>"warning"===e.severity));(null==n?void 0:n.length)!==0&&(console.groupCollapsed("â ï¸ Schema has ".concat(null==n?void 0:n.length," warnings")),null==n||n.forEach(e=>{let t=e.path.map(e=>"type"===e.kind?"".concat(e.name||"<unnamed>","(").concat(e.type,")"):"property"===e.kind?e.name:null).filter(Boolean).join(" > ");console.group("%cAt ".concat(t),"color: #FF7636"),e.problems.forEach(e=>{console.log(e.message)}),console.groupEnd()}),console.groupEnd())})(n),[n]),(0,lU.jsx)(lY.Zb,{height:"fill",overflow:"auto",paddingY:[4,5,6,7],paddingX:4,sizing:"border",children:(0,lU.jsx)(lY.W2,{width:1,children:(0,lU.jsxs)(lY.Kq,{space:5,children:[(0,lU.jsx)(lY.X6,{as:"h1",children:"Schema errors"}),(0,lU.jsx)(FF,{problemGroups:i})]})})})}function FZ(e){return(0,lU.jsx)(lY.Zb,{height:"fill",sizing:"border",tone:"caution",display:"flex",children:(0,lU.jsx)(lY.kC,{direction:"row",justify:"center",flex:1,align:"center",children:(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(lY.X6,{as:"h1",children:"Workspace not found"}),(0,lU.jsx)(lY.gF,{children:(0,lU.jsx)(lY.zx,{text:"Go to default workspace",onClick:e.onNavigateToDefaultWorkspace,mode:"ghost"})})]})})})}let FL=(0,lK.createContext)(null),Fq=(0,lK.createContext)(null);function FN(e){let{children:t,history:n}=e;return(0,lU.jsx)(Fq.Provider,{value:n,children:t})}let FV=(0,lK.memo)(function(e){let{children:t,history:n,activeWorkspace:i,setActiveWorkspace:r}=e,l=(0,lK.useMemo)(()=>({activeWorkspace:i,setActiveWorkspace:r}),[i,r]);return(0,lU.jsx)(FL.Provider,{value:l,children:(0,lU.jsx)(FN,{history:n,children:t})})}),FU=()=>"undefined"==typeof document?(0,dA.PP)():(0,dA.lX)();function FB(e){let{children:t,LoadingComponent:n,NotFoundComponent:i,unstable_history:r}=e,l=Fy(),a=(0,lK.useMemo)(()=>r||FU(),[r]),o=(0,lK.useCallback)(e=>{let t=l.find(t=>t.name===e);t&&a.push(t.basePath)},[a,l]),s=(0,lK.useCallback)(()=>{o(l[0].name)},[o,l]),d=function(e,t){let n=(0,lK.useMemo)(()=>t.map(e=>{let t=e.basePath||"/";return{workspace:e,name:e.name,basePath:t,basePathRegex:RegExp("^".concat(dz()(t),"(\\/|$)"),"i")}}),[t]),i=(0,lK.useMemo)(()=>(function(e){let t=e.map(e=>e.basePath.substring(1).split("/")),n=t.reduce((e,t)=>
1{for(let n=0;n<e.length;n++){let i=e[n],r=t[n].toLowerCase();if(i!==r)return e.slice(0,n)}return e});return RegExp("^".concat(function e(t){let[n,...i]=t;return n?"(\\/".concat(dz()(n)).concat(e(i),"(\\/|$))?"):""}(n),"$"),"i")})(n),[n]),[r]=(0,lK.useState)(()=>e.location.pathname),l=(0,lK.useMemo)(()=>({subscribe:t=>e.listen(t),getSnapshot:()=>e.location.pathname,getServerSnapshot:()=>r,selector:e=>(function(e){let{pathname:t,workspaces:n,basePathRegex:i}=e,[r]=n;for(let{workspace:e,basePath:i,basePathRegex:r}of n)if(r.test(t)||"/"===i)return{type:"match",workspace:e};return"/"===t||i.test(t)?{type:"redirect",pathname:r.basePath}:{type:"not-found"}})({basePathRegex:i,pathname:e,workspaces:n}),isEqual:(e,t)=>{if(e.type!==t.type)return!1;switch(e.type){case"match":return e.workspace===t.workspace;case"redirect":return e.pathname===t.pathname;case"not-found":return!0;default:throw Error("Unknown type: ".concat(e.type))}}}),[i,e,r,n]);return(0,dr.useSyncExternalStoreWithSelector)(l.subscribe,l.getSnapshot,l.getServerSnapshot,l.selector,l.isEqual)}(a,l);switch((0,lK.useEffect)(()=>{"redirect"===d.type&&a.replace(d.pathname)},[a,d]),d.type){case"match":return(0,lU.jsx)(FV,{activeWorkspace:d.workspace,history:a,setActiveWorkspace:o,children:t});case"redirect":return(0,lU.jsx)(n,{});case"not-found":return(0,lU.jsx)(i,{onNavigateToDefaultWorkspace:s});default:throw Error("Unknown type: ".concat(d.type))}}function FK(){let e=(0,lK.useContext)(FL);if(!e)throw Error("Could not find `ActiveWorkspaceMatcher` context");return e}var FH=Object.freeze,FW=Object.defineProperty;let F$={"logged-in":"","logged-out":"Signed out","no-access":""},FX=(0,aW.ZP)(lY.Zb)(rV||(rV=FH(FW(es=["\n width: 35px;\n height: 35px;\n\n svg {\n width: 100%;\n height: 100%;\n }\n"],"raw",{value:FH(es.slice())})))),FG=e=>(0,a6.isValidElementType)(e)?(0,lK.createElement)(e):(0,lK.isValidElement)(e)?e:void 0;function FY(e){let{state:t,subtitle:n,selected:i,title:r,icon:l,iconRight:a}=e,o=(0,lK.useMemo)(()=>FG(l),[l]),s=(0,lK.useMemo)(()=>FG(a),[a]);return(0,lU.jsxs)(lY.kC,{align:"center",flex:"none",gap:3,children:[(0,lU.jsx)(FX,{radius:2,tone:"transparent",children:o}),(0,lU.jsxs)(lY.Kq,{flex:1,space:2,children:[(0,lU.jsx)(lY.xv,{textOverflow:"ellipsis",weight:"medium",children:r}),n&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:n})]}),t&&F$[t]&&(0,lU.jsx)(lY.xu,{paddingLeft:1,children:(0,lU.jsx)(lY.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:F$[t]})}),(i||s)&&(0,lU.jsxs)(lY.kC,{align:"center",gap:4,paddingLeft:3,paddingRight:2,children:[i&&(0,lU.jsx)(lY.xv,{children:(0,lU.jsx)(a0.KML,{})}),s&&(0,lU.jsx)(lY.xv,{muted:!0,children:s})]})]})}let FJ=d8(e=>(0,ae.a)(e.map(e=>e.auth.state.pipe((0,ad.U)(t=>[e.name,t])))).pipe((0,ad.U)(e=>Object.fromEntries(e))));var FQ=Object.freeze,F0=Object.defineProperty;let F1=[{url:"https://slack.sanity.io/",title:"Community"},{url:"https://www.sanity.io/docs",title:"Docs"},{url:"https://www.sanity.io/legal/privacy",title:"Privacy"},{url:"https://www.sanity.io",title:"sanity.io"}],F2=(0,aW.ZP)(lY.xv)(rU||(rU=FQ(F0(ed=["\n a {\n color: inherit;\n }\n"],"raw",{value:FQ(ed.slice())}))));function F3(e){let{children:t,footer:n,header:i}=e;return(0,lU.jsxs)(lY.Kq,{space:6,children:[(0,lU.jsx)(lY.Zb,{border:!0,radius:3,overflow:"auto",children:(0,lU.jsxs)(lY.Kq,{children:["object"==typeof i&&(0,lU.jsx)(lY.xu,{children:i}),"string"==typeof i&&(0,lU.jsx)(lY.xu,{paddingY:4,children:(0,lU.jsx)(lY.X6,{align:"center",size:1,children:i})}),(0,lU.jsx)(lY.xu,{paddingX:1,children:(0,lU.jsx)(lY.Zb,{borderTop:!!i,borderBottom:!!n,children:t})}),n&&(0,lU.jsx)(lY.xu,{children:n})]})}),(0,lU.jsxs)(lY.kC,{direction:"column",gap:4,justify:"center",align:"center",paddingBottom:4,children:[(0,lU.jsx)(lY.xv,{size:3,children:(0,lU.jsx)(dI.hn,{})}),(0,lU.jsx)(lY.kC,{align:"center",gap:2,children:F1.map((e,t)=>(0,lU.jsxs)(lK.Fragment,{children:[(0,lU.jsx)(F2,{muted:!0,size:1,children:(0,lU.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.title})}),t<F1.length-1&&(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:"â¢"})]},e.title))})]})]})}
1function F4(){var e;let t=Fy(),{activeWorkspace:n,setActiveWorkspace:i}=FK(),[r]=FJ(t),[l,a]=(0,lK.useState)((null==n?void 0:n.name)||null),o=1===t.length?t[0]:t.find(e=>e.name===l),s=null==(e=null==o?void 0:o.auth)?void 0:e.LoginComponent,d=(0,lK.useCallback)(()=>a(null),[]);return r?s&&o?(0,lU.jsxs)(lY.Kq,{space:2,children:[t.length>1&&(0,lU.jsx)(lY.kC,{children:(0,lU.jsx)(lY.zx,{fontSize:1,icon:a0.Y4O,mode:"bleed",onClick:d,padding:2,text:"Choose another workspace"})}),(0,lU.jsx)(F3,{header:(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsx)(FY,{icon:o.icon,title:o.title,subtitle:null==o?void 0:o.subtitle})}),children:(0,lU.jsx)(lY.Kq,{padding:2,paddingBottom:3,paddingTop:4,children:(0,lK.createElement)(s,{...sm()(o,["type","__internal"]),key:l})})})]}):(0,lU.jsx)(F3,{header:"Choose your workspace",footer:(0,lU.jsx)(lY.Kq,{padding:1,children:(0,lU.jsx)(lY.zx,{as:"a",href:"https://beta.sanity.io/docs/platform/studio/config/workspaces",icon:a0.dtP,justify:"flex-start",mode:"bleed",rel:"noopener noreferrer",target:"__blank",text:"Add workspace"})}),children:(0,lU.jsx)(lY.Kq,{space:1,paddingX:1,paddingY:2,children:t.map(e=>{let t=r[e.name],l=t.authenticated?"logged-in":e.auth.LoginComponent?"logged-out":"no-access";return(0,lU.jsx)(lY.Zb,{as:"button",radius:2,padding:2,onClick:()=>{"logged-in"===l&&e.name!==n.name&&i(e.name),"logged-out"===l&&a(e.name)},children:(0,lU.jsx)(FY,{icon:null==e?void 0:e.icon,iconRight:a0.XCv,state:l,subtitle:null==e?void 0:e.subtitle,title:(null==e?void 0:e.title)||e.name})},e.name)})})}):(0,lU.jsx)(FP,{})}var F5=Object.freeze,F6=Object.defineProperty;let F8=(0,aW.ZP)(lY.v2)(rB||(rB=F5(F6(ec=["\n max-width: 350px;\n min-width: 250px;\n"],"raw",{value:F5(ec.slice())}))));function F9(e){let{scheme:t}=Ff(),n=Fy(),{activeWorkspace:i,setActiveWorkspace:r}=FK(),[l]=FJ(n),{navigateUrl:a}=(0,a1.tv)(),o=(0,lK.useMemo)(()=>({constrainSize:!0,scheme:t,portal:!0}),[t]);return(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{icon:a0.GVG,mode:"bleed",...e,disabled:!l}),id:"workspace-menu",menu:(0,lU.jsxs)(F8,{children:[(0,lU.jsx)(lY.xu,{paddingX:3,paddingY:3,children:(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Workspaces"})}),l&&n.map(e=>{let t=l[e.name],n=t.authenticated?"logged-in":e.auth.LoginComponent?"logged-out":"no-access";return(0,lU.jsx)(lY.sN,{onClick:()=>{"logged-in"===n&&e.name!==i.name&&r(e.name),"logged-out"===n&&a({path:e.basePath})},padding:2,pressed:e.name===i.name,children:(0,lU.jsx)(FY,{icon:null==e?void 0:e.icon,selected:e.name===i.name,state:n,subtitle:null==e?void 0:e.subtitle,title:(null==e?void 0:e.title)||e.name})},e.name)})]}),popover:o})}function F7(){return(0,lU.jsx)(lY.Zb,{height:"fill",overflow:"auto",children:(0,lU.jsx)(lY.kC,{height:"fill",direction:"column",align:"center",justify:"center",paddingTop:4,children:(0,lU.jsx)(lY.W2,{width:0,children:(0,lU.jsx)(F4,{})})})})}function De(){return(0,lU.jsx)(lU.Fragment,{children:"TODO: implement config errors screen"})}function Dt(){let[e,t]=(0,lK.useState)(null),[n,i]=(0,lK.useState)(null);if(n)throw n;let{activeWorkspace:r}=FK(),l=(0,lK.useCallback)(()=>{var e,t;null==(t=(e=r.auth).logout)||t.call(e)},[r]);(0,lK.useEffect)(()=>{let e=r.auth.state.subscribe({next:e=>{let{currentUser:n}=e;t(n)},error:i});return()=>{e.unsubscribe()}},[r]);let a=hb(null==e?void 0:e.provider);return(0,lU.jsx)(lY.Zb,{height:"fill",children:(0,lU.jsx)(lY.Vq,{id:"not-authorized-dialog",header:"Not authorized",width:1,footer:(0,lU.jsx)(lY.Kq,{paddingX:3,paddingY:2,children:(0,lU.jsx)(lY.zx,{text:"Sign out",onClick:l})}),children:(0,lU.jsxs)(lY.Kq,{paddingX:4,paddingY:5,space:4,children:[(0,lU.jsx)(lY.xv,{children:"You are not authorized to access this studio. Maybe you could ask someone to invite you to collaborate on this project?"}),(0,lU.jsxs)(lY.xv,{children:["If you think this is an error, verify that you are signed in with the correct account. You are currently signed in as"," ",(0,lU.jsxs)("strong",{children:[null==e?void 0:e.name," (",null==e?void 0:e.email,")"]}),a?" through ".concat(a):"","."]})]})})})}var Dn=Object.freeze,Di=Object.defineProperty;let Dr=aW.ZP.label(rK||(rK=Dn(Di(eu=["\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n overflow: clip;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n"],"raw",{value:Dn(eu.slice())}))));function Dl(e){let{projectId:t}=e,n=window.location.origin,i=(0,lK.useMemo)(()=>{let e=new URL("https://sanity.io/manage/project/".concat(t,"/api"));return e.searchParams.set("cors","add"),e.searchParams.set("origin",n),e.searchParams.set("credentials",""),e.toString()},[n,t]);return(0,lK.useEffect)(()=>{let e=()=>{window.location.reload()};return window.addEventListener("focus",e),()=>{window.removeEventListener("focus",e)}},[]),(0,lU.jsx)(lY.Zb,{height:"fill",children:(0,lU.jsx)(lY.Vq,{id:"cors-error-dialog",header:"Before you continue...",width:1,children:(0,lU.jsxs)(lY.Kq,{paddingX:4,paddingY:5,space:4,children:[(0,lU.jsxs)(lY.xv,{children:["To access your content, you need to ",(0,lU.jsx)("b",{children:"add the following URL as a CORS origin"})," to your Sanity project."]}),(0,lU.jsx)(Dr,{"aria-hidden":"true",children:"CORS URL to be added"}),(0,lU.jsx)(lY.oi,{value:n,readOnly:!0}),(0,lU.jsx)(lY.zx,{as:"a",href:i,target:"_blank",rel:"noopener noreferrer",tone
1:"primary",children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"center",gap:3,children:[(0,lU.jsx)(lY.xv,{weight:"medium",children:"Continue"}),(0,lU.jsx)(lY.xv,{weight:"medium",children:(0,lU.jsx)(a0.buG,{})})]})})]})})})}function Da(e){let{children:t,heading:n="An error occured"}=e,[{error:i},r]=(0,lK.useState)({error:null}),l=cc(i)&&"string"==typeof i.message&&i.message,a=cc(i)&&"string"==typeof i.stack&&i.stack,o=(0,lK.useCallback)(()=>r({error:null}),[r]);return((0,dx.H)(o),i instanceof p9)?(0,lU.jsx)(Dl,{projectId:null==i?void 0:i.projectId}):i instanceof R3?(0,lU.jsx)(FD,{schema:i.schema}):i?(0,lU.jsx)(lY.Zb,{height:"fill",overflow:"auto",paddingY:[4,5,6,7],paddingX:4,sizing:"border",tone:"critical",children:(0,lU.jsx)(lY.W2,{width:3,children:(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(lY.X6,{children:n}),(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.zx,{onClick:o,text:"Retry",tone:"default"})}),(0,lU.jsx)(lY.Zb,{border:!0,radius:2,overflow:"auto",padding:4,tone:"inherit",children:(0,lU.jsxs)(lY.Kq,{space:4,children:[l&&(0,lU.jsx)(lY.EK,{size:1,children:(0,lU.jsxs)("strong",{children:["Error: ",l]})}),a&&(0,lU.jsx)(lY.EK,{size:1,children:a})]})})]})})}):(0,lU.jsx)(lY.SV,{onCatch:r,children:t})}var Do=Object.freeze,Ds=Object.defineProperty;let Dd=(0,aW.ZP)(lY.Zb)(rH||(rH=Do(Ds(ep=["\n height: 100%;\n left: 0;\n overflow: hidden;\n overflow: clip;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: 200;\n"],"raw",{value:Do(ep.slice())})))),Dc=(0,lK.createContext)({onSearchFullscreenOpenChange:()=>"",searchFullscreenOpen:!1,searchFullscreenPortalEl:null});function Du(){let{name:e,title:t,tools:n}=Ib(),i=(0,a1.z)((0,lK.useCallback)(e=>"string"==typeof e.tool?e.tool:void 0,[])),r=(0,lK.useMemo)(()=>n.find(e=>e.name===i),[i,n]),[l,a]=(0,lK.useState)(!1),[o,s]=(0,lK.useState)(null),d=(0,lK.useMemo)(()=>{let n=t||ol()(e);return i?"".concat(n," â ").concat(ol()(i)):n},[i,e,t]);(0,lK.useEffect)(()=>{document.title=d},[d]);let c=(0,lK.useCallback)(e=>{a(e)},[]),u=(0,lK.useMemo)(()=>({searchFullscreenOpen:l,searchFullscreenPortalEl:o,onSearchFullscreenOpenChange:c}),[l,o,c]),p=fz({defaultComponent:qN,pick:qW});return(0,lU.jsxs)(lY.kC,{"data-ui":"ToolScreen",direction:"column",height:"fill","data-testid":"studio-layout",children:[(0,lU.jsx)(Dc.Provider,{value:u,children:(0,lU.jsx)(p,{})}),0===n.length&&(0,lU.jsx)(FT,{}),n.length>0&&!r&&i&&(0,lU.jsx)(FE,{toolName:i}),l&&(0,lU.jsx)(Dd,{ref:s,overflow:"auto"}),(0,lU.jsx)(Da,{heading:"The ".concat(null==r?void 0:r.name," tool crashed"),children:(0,lU.jsx)(lY.Zb,{flex:1,hidden:l,children:r&&i&&(0,lU.jsx)(a1.NZ,{scope:i,children:(0,lU.jsx)(lK.Suspense,{fallback:(0,lU.jsx)(Dp,{}),children:(0,lK.createElement)(r.component,{tool:r})})})})},null==r?void 0:r.name)]})}function Dp(){return(0,lU.jsxs)(lY.kC,{justify:"center",align:"center",height:"fill",direction:"column",gap:4,children:[(0,lU.jsx)(lY.xv,{muted:!0,children:"Loadingâ¦"}),(0,lU.jsx)(lY.$j,{muted:!0})]})}var Dh=Object.freeze,Df=Object.defineProperty;let Dm=aW.ZP.div(rW||(rW=Dh(Df(eh=["\n position: absolute;\n width: 18px;\n height: 18px;\n background: var(--card-bg-color);\n bottom: -4px;\n right: -4px;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--card-bg-color);\n box-sizing: content-box;\n\n svg {\n box-sizing: content-box;\n border: 1px solid var(--card-hairline-soft-color);\n border-radius: 50%;\n padding: 2px;\n width: 12px;\n height: 12px;\n }\n\n &[data-logo='github'] {\n svg {\n path {\n fill: var(--card-fg-color);\n }\n }\n }\n\n &[data-logo='saml'] {\n svg {\n path {\n fill: var(--card-fg-color);\n }\n }\n }\n"],"raw",{value:Dh(eh.slice())})))),Dg=(0,lU.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,lU.jsxs)("g",{clipPath:"url(#clip0)",children:[(0,lU.jsx)("path",{d:"M12 6.13764C12 5.72977 11.9663 5.31971 11.8943 4.91846H6.12036V7.22895H9.42684C9.28963 7.97412 8.84876 8.63332 8.20322 9.05221V10.5514H10.1759C11.3342 9.50637 12 7.9631 12 6.13764Z",fill:"#4285F4"}),(0,lU.jsx)("path",{d:"M6.12019 12.0002C7.77118 12.0002 9.16349 11.4688 10.1779 10.5517L8.20529 9.05253C7.65646 9.41851 6.94793 9.62574 6.12244 9.62574C4.52544 9.62574 3.17136 8.56971 2.68552 7.1499H0.649902V8.69537C1.68908 10.7215 3.80567 12.0002 6.12019 12.0002V12.0002Z",fill:"#34A853"}),(0,lU.jsx)("path",{d:"M2.68332 7.14986C2.4269 6.40469 2.4269 5.59778 2.68332 4.8526V3.30713H0.649951C-0.218278 5.00252 -0.218278 6.99995 0.649951 8.69533L2.68332 7.14986V7.14986Z",fill:"#FBBC04"}),(0,lU.jsx)("path",{d:"M6.12019 2.37483C6.99291 2.3616 7.8364 2.68348 8.46845 3.27433L10.2161 1.56131C9.1095 0.542752 7.64071 -0.017233 6.12019 0.000404333C3.80566 0.000404333 1.68908 1.27911 0.649902 3.3074L2.68326 4.85288C3.16686 3.43087 4.52319 2.37483 6.12019 2.37483V2.37483Z",fill:"#EA4335"})]}),(0,lU.jsx)("defs",{children:(0,lU.jsx)("clipPath",{id:"clip0",children:(0,lU.jsx)("rect",{width:"12",height:"12",fill:"white"})})})]}),Dx=(0,lU.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,lU.jsx)("g",{clipPath:"url(#clip0)",children:(0,lU.jsx)("path",{d:"M11.195 3.13503C10.6711 2.22838 9.91808 1.47537 9.01144 0.951471C8.09222 0.414976 7.08837 0.146729 5.99987 0.146729C4.91137 0.146729 3.90752 0.414976 2.98831 0.951471C2.08163 1.47534
11.32862 2.22836 0.804744 3.13503C0.268248 4.05497 0 5.05883 0 6.14659C0 7.45399 0.381531 8.62978 1.14459 9.67394C1.90765 10.7181 2.89327 11.4408 4.10143 11.8419C4.24208 11.868 4.34624 11.8497 4.41392 11.7872C4.44666 11.7577 4.47263 11.7215 4.49006 11.681C4.50749 11.6405 4.51595 11.5967 4.51488 11.5527C4.51488 11.537 4.51361 11.3963 4.51105 11.1307C4.5085 10.8651 4.50722 10.6334 4.50722 10.4355L4.32745 10.4666C4.18407 10.4895 4.03885 10.4986 3.89375 10.494C3.71159 10.4908 3.53001 10.4725 3.35087 10.4393C3.16049 10.4045 2.98119 10.3246 2.82796 10.2064C2.66705 10.0846 2.54715 9.91661 2.48428 9.72484L2.40602 9.54506C2.34022 9.40286 2.25754 9.2691 2.15976 9.14666C2.04775 9.00072 1.93447 8.90176 1.81991 8.84977L1.76518 8.81064C1.72769 8.78356 1.6936 8.75205 1.66367 8.71679C1.63479 8.6841 1.61108 8.64719 1.59334 8.60734C1.57766 8.57085 1.5907 8.54085 1.63247 8.51731C1.67461 8.49405 1.75123 8.48256 1.86068 8.48256L2.01692 8.50582C2.12108 8.52662 2.24996 8.5891 2.40356 8.69326C2.5585 8.79876 2.68797 8.93748 2.78254 9.09932C2.90239 9.31294 3.04695 9.47575 3.21624 9.58775C3.38552 9.69976 3.55609 9.75576 3.72793 9.75576C3.87725 9.7578 4.02641 9.74479 4.17312 9.7169C4.29459 9.69195 4.41264 9.65254 4.52473 9.59952C4.57162 9.25037 4.69931 8.98212 4.90782 8.79477C4.63684 8.76849 4.36827 8.72157 4.10444 8.6544C3.84797 8.58382 3.60133 8.48141 3.37029 8.34958C3.12825 8.218 2.91442 8.04015 2.74095 7.82613C2.57421 7.6178 2.4374 7.34417 2.3305 7.00524C2.2236 6.6663 2.1707 6.27584 2.1718 5.83383C2.1718 5.20357 2.37757 4.66708 2.7891 4.22435C2.59629 3.75006 2.61453 3.21885 2.84383 2.63073C2.99487 2.58385 3.21879 2.61897 3.51559 2.73608C3.81239 2.85319 4.02983 2.95352 4.16792 3.03707C4.30601 3.12025 4.41665 3.19058 4.49983 3.24804C5.48153 2.9773 6.51821 2.9773 7.49991 3.24804L7.79679 3.0606C8.0249 2.92356 8.26549 2.80849 8.51535 2.71693C8.79135 2.61276 9.00231 2.58412 9.14825 2.63101C9.38248 3.21949 9.40327 3.7507 9.21064 4.22462C9.62199 4.66735 9.82776 5.20385 9.82795 5.83411C9.82795 6.27684 9.77459 6.66904 9.66787 7.01071C9.56116 7.35238 9.42325 7.62601 9.25415 7.8316C9.07785 8.04326 8.86311 8.21966 8.62124 8.35149C8.39008 8.48329 8.14337 8.5857 7.88682 8.65632C7.62412 8.72277 7.35674 8.76915 7.087 8.79505C7.35698 9.02927 7.49206 9.3994 7.49225 9.90543V11.5527C7.49115 11.5964 7.49929 11.6398 7.51612 11.6802C7.53295 11.7206 7.5581 11.7569 7.58993 11.7869C7.65505 11.8493 7.75794 11.8675 7.89858 11.8416C9.10693 11.4403 10.0926 10.7177 10.8557 9.67367C11.6188 8.62968 12.0003 7.4539 12.0003 6.14632C11.9997 5.05873 11.7313 4.05497 11.195 3.13503V3.13503Z",fill:"black"})}),(0,lU.jsx)("defs",{children:(0,lU.jsx)("clipPath",{id:"clip0",children:(0,lU.jsx)("rect",{width:"12",height:"12",fill:"white"})})})]}),Dv=(0,lU.jsxs)("svg",{width:"17",height:"9",viewBox:"0 0 17 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,lU.jsx)("path",{d:"M0.0691681 5.98162C0.115833 7.24157 1.07247 8.00221 2.59841 8.00221C4.17102 8.00221 5.12299 7.19957 5.12299 5.86962C5.12299 4.83832 4.55367 4.25501 3.25172 3.96569L2.56108 3.80703C1.8331 3.64837 1.53445 3.38704 1.53445 2.91106C1.53445 2.40708 1.94977 2.09442 2.61708 2.09442C3.27505 2.09442 3.6997 2.43508 3.75103 2.99039H5.00166C4.95966 1.78643 4.01236 0.997795 2.60308 0.997795C1.14713 0.997795 0.218496 1.79577 0.218496 3.05105C0.218496 4.04968 0.815808 4.69366 2.03376 4.96898L2.73374 5.13231C3.51304 5.30497 3.8117 5.54763 3.8117 6.00495C3.8117 6.55093 3.34972 6.90092 2.62174 6.90092C1.85644 6.90092 1.38045 6.56493 1.31979 5.98162H0.0691681Z"}),(0,lU.jsx)("path",{d:"M5.97695 5.98162C6.02362 7.24157 6.98025 8.00221 8.5062 8.00221C10.0788 8.00221 11.0308 7.19957 11.0308 5.86962C11.0308 4.83832 10.4615 4.25501 9.15951 3.96569L8.46886 3.80703C7.74089 3.64837 7.44223 3.38704 7.44223 2.91106C7.44223 2.40708 7.85755 2.09442 8.52486 2.09442C9.18284 2.09442 9.60749 2.43508 9.65882 2.99039H10.9094C10.8674 1.78643 9.92015 0.997795 8.51086 0.997795C7.05492 0.997795 6.12628 1.79577 6.12628 3.05105C6.12628 4.04968 6.72359 4.69366 7.94155 4.96898L8.64153 5.13231C9.42083 5.30497 9.71949 5.54763 9.71949 6.00495C9.71949 6.55093 9.2575 6.90092 8.52953 6.90092C7.76422 6.90092 7.28824 6.56493 7.22758 5.98162H5.97695Z"}),(0,lU.jsx)("path",{d:"M16.9852 5.01565V3.98435C16.9852 2.11309 16.0099 0.997795 14.3953 0.997795C12.7807 0.997795 11.8054 2.11309 11.8054 3.98435V5.01565C11.8054 6.88692 12.7807 8.00221 14.3953 8.00221C16.0099 8.00221 16.9852 6.88692 16.9852 5.01565ZM14.3953 6.82625C13.5833 6.82625 13.154 6.21494 13.154 5.00165V3.99835C13.154 2.78506 13.5833 2.17375 14.3953 2.17375C15.2073 2.17375 15.6366 2.78506 15.6366 3.99835V5.00165C15.6366 6.21494 15.2073 6.82625 14.3953 6.82625Z"})]}),Db=e=>{let{provider:t}=e,n=null==t?void 0:t.startsWith("saml-");return(0,lU.jsxs)(Dm,{"data-logo":n?"saml":t,children:["google"===t&&Dg,"github"===t&&Dx,"sanity"===t&&(0,lU.jsx)(dI.xN,{}),n&&Dv]})};var Dy=Object.freeze,Dj=Object.defineProperty,Dw=(e,t)=>Dy(Dj(e,"raw",{value:Dy(t||e.slice())}));let Dk=(0,aW.ZP)(lY.v2)(r$||(r$=Dw(["\n min-width: 200px;\n max-width: 300px;\n"]))),DC=(0,aW.ZP)(lY.xu)(rX||(rX=Dw(["\n position: relative;\n min-width: ","px;\n min-height: ","px;\n"])),e=>{let{theme:t}=e;return t.sanity.avatar.sizes[1].size},e=>{let{theme:t}=e;return t.sanity.avatar.sizes[1].size});function D_(e){let{setScheme:t}=e,n=Fm(t);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Appearance"})}),n.map(e=>{let{icon:t,label:n,name:i,onSelect:r,selected:l,title:a}=e;return(0,lU.jsx)(lY.sN,{"aria-label":n,icon:t,onClick:r,pressed:l,text:a,iconRight:l&&(0,lU.jsx)(a0.KML,{})},i)})]})}function DS(){let{currentUser:e,projectId:t,auth:n}=Ib(),i=Fh(),r=Fu(),l=!!(e&&cS(e,"administrator")),a=hb(null==e?void 0:e.provider),o=(0,lK.useMemo)(()=>({placement:"bottom-end",portal:!0,preventOverflow:!0,scheme:i,constrainSize:!0}),[i]);return(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{mode:"bleed",padding:0,paddingX:1,children:(0,lU.jsxs)(lY.kC,{align:"center",gap:1,children:[(0,lU.jsx)(U4,{user:"me",size:1}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:(0,lU.jsx)(a0.v4q,{})})]})}),id:"user-menu",menu:(0,lU.jsxs)(Dk,{children:[(0,lU.jsx)(lY.Zb,{padding:2,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.u,{disabled:!a,portal:!0,content:a&&(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsxs)(lY.xv,{size:1,children:["Signed in with ",a]})}),children:(0,lU.jsxs)(DC,{marginRight:3,children:[(0,lU.jsx)(U4,{size:1,user:"me"}),(null==e?void 0:e.provider)&&(0,lU.jsx)(Db,{provider:e.provider})]})}),(0,lU.jsxs)(lY.Kq,{space:2,flex:1,children:[(0,lU.jsx)(lY.xv,{size:2,weight:"medium",textOverflow:"ellipsis",children:null==e?void 0:e.name}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:null==e?void 0:e.email})]})]})}),r&&(0,lU.jsx)(D_,{setScheme:r}),(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.sN,{as:"a","aria-label":"Manage project",href:"https://sanity.io/manage/project/".concat(t),target:"_blank",text:"Manage project",icon:a0.IEm}),l&&(0,lU.jsx)(lY.sN,{as:"a","aria-label":"Invite members",href:"https://sanity.io/manage/project/".concat(t,"/members"),target:"_blank",text:"Invite members",icon:a0.oyc}),n.logout&&(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.sN,{iconRight:a0.Ow9,text:"Sign out",disabled:!n.logout,...n.logout&&{onClick:n.logout}})]})]}),popover:o})}var DT=Object.freeze,DE=Object.defineProperty;let DP=(0,aW.ZP)(lY.xu)(rG||(rG=DT(DE(ef=["\n max-width: 300px;\n"],"raw",{value:DT(ef.slice())}))));function DA(e){let{option:t,currentUser:n,onClick:i,preview:r}=e,l=(0,lK.useMemo)(()=>({template:t.templateId,type:t.schemaType}),[t.schemaType,t.templateId]),{onClick:a,href:o}=(0,a1.PM)({intent:"create",params:l}),s=(0,lK.useCallback)(e=>{a(e),i(t)},[a,i,t]);return(0,lU.jsx)(lY.u,{disabled:t.hasPermission,portal:!0,content:(0,lU.jsx)(DP,{padding:2,children:(0,lU.jsx)(ub,{currentUser:n,operationLabel:"create this document"})}),children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.Zb,{as:t.hasPermission?"a":"button",disabled:!t.hasPermission,href:o,marginBottom:1,onClick:s,padding:"inline"===r?3:4,radius:2,children:(0,lU.jsx)(lY.xv,{size:"inline"===r?1:void 0,children:t.title})})})},t.id)}var DO=Object.freeze,Dz=Object.defineProperty,DM=(e,t)=>DO(Dz(e,"raw",{value:DO(t||e.slice())}));let DI=(0,aW.ZP)(lY.kC)(rY||(rY=DM(["\n min-height: 100px;\n"]))),DR=aW.ZP.strong(rJ||(rJ=DM(["\n word-break: break-all;\n"])));function DF(e){let{currentUser:t,loading:n,onDocumentClick:i,options:r,preview:l,searchQuery:a,textInputElement:o}=e,s=r.length>0&&!n,d=(0,lK.useCallback)(()=>{i()},[i]),c=(0,lK.useCallback)(e=>{var t;return(null==(t=r[e])?void 0:t.hasPermission)===!1},[r]),u=(0,lK.useCallback)(e=>(0,lU.jsx)(DA,{currentUser:t,onClick:d,option:e,preview:l},e.id),[t,d,l]);return n?(0,lU.jsx)(DI,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,lU.jsxs)(lY.gF,{space:2,children:[(0,lU.jsx)(lY.$j,{muted:!0,size:1}),(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"Loadingâ¦"})]})}):!s&&a?(0,lU.jsx)(DI,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,lU.jsxs)(lY.xv,{align:"center",muted:!0,size:1,children:["No results found for ",(0,lU.jsxs)(DR,{children:["â",a,"â"]}
1)]})}):s?(0,lU.jsx)(uc,{activeItemDataAttr:"data-hovered",ariaLabel:"New document",autoFocus:ck?void 0:"input",getItemDisabled:c,inputElement:o,itemHeight:33,items:r,overscan:5,padding:"inline"===l?1:2,paddingBottom:0,renderItem:u}):(0,lU.jsx)(DI,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:"No documents found"})})}var DD=Object.freeze,DZ=Object.defineProperty,DL=(e,t)=>DD(DZ(e,"raw",{value:DD(t||e.slice())}));let Dq=(0,aW.ZP)(lY.J2)(()=>(0,aW.iv)(rQ||(rQ=DL(["\n [data-ui='Popover__wrapper'] {\n width: 320px;\n display: flex;\n flex-direction: column;\n border-radius: ","px;\n position: relative;\n overflow: hidden;\n overflow: clip;\n }\n "])),e=>{let{theme:t}=e;return t.sanity.radius[3]})),DN=(0,aW.ZP)(lY.Vq)(()=>(0,aW.iv)(r0||(r0=DL(["\n [data-ui='DialogCard'] {\n justify-content: flex-start;\n }\n "])))),DV=(0,aW.ZP)(lY.xu)(r1||(r1=DL(["\n max-width: 300px;\n"]))),DU=(0,aW.ZP)(lY.kC)(r2||(r2=DL([""]))),DB=(0,aW.ZP)(lY.Zb)(r3||(r3=DL(["\n min-height: max-content;\n"]))),DK=(0,aW.ZP)(lY.Zb)(r4||(r4=DL(["\n min-height: max-content;\n"]))),DH=(0,aW.ZP)(lY.kC)(e=>{let{$maxDisplayedItems:t,$itemHeight:n}=e;return(0,aW.iv)(r5||(r5=DL(["\n --item-height: ","px;\n --max-items: ",";\n --list-padding: 0.5rem;\n\n position: relative;\n max-height: calc(var(--item-height) * var(--max-items) + var(--list-padding));\n min-height: calc((var(--item-height) * 1));\n "])),n,t)});function DW(e){let{canCreateDocument:t,modal:n="popover",loading:i,options:r}=e,[l,a]=(0,lK.useState)(!1),[o,s]=(0,lK.useState)(""),[d,c]=(0,lK.useState)(null),[u,p]=(0,lK.useState)(null),[h,f]=(0,lK.useState)(null),[m,g]=(0,lK.useState)(null),{scheme:x}=Ff(),v=Nj(),b=r.length>0,y=!t||!b,j="Search",w="Create new document",k=(0,lK.useMemo)(()=>(function(e,t){let n=e.map(e=>({...e,title:(null==e?void 0:e.title)||e.id})),i=n.sort((e,t)=>e.title.localeCompare(t.title));return i.filter(e=>(function(e,t){let n=t.title.toLowerCase(),i=e.trim().toLowerCase(),r=i.split(/[\s\-_]+/);return r.every(e=>n.includes(e))})(t,e)).sort((e,n)=>(function(e,t,n){let i=t.title.toLowerCase(),r=n.title.toLowerCase(),l=e.trim().toLowerCase();return i.startsWith(l)&&!r.startsWith(l)?-1:r.startsWith(l)&&!i.startsWith(l)?1:i.includes(l)&&!r.includes(l)?-1:r.includes(l)&&!i.includes(l)?1:0})(t,e,n))})(r,o),[r,o]),C=(0,lK.useCallback)(e=>{s(e.currentTarget.value)},[]),_=(0,lK.useCallback)(()=>a(e=>!e),[]),S=(0,lK.useCallback)(()=>{a(!1),s(""),null==h||h.focus()},[h]),T=(0,lK.useCallback)(e=>{"ArrowDown"!==e.key||l||a(!0)},[l]),E=(0,lK.useCallback)(e=>{("Escape"===e.key||"Tab"===e.key)&&l&&S()},[S,l]);(0,lY.O8)(()=>{l&&S()},[h,u,d]);let P=(0,lK.useMemo)(()=>({currentUser:v,loading:i,onDocumentClick:_,options:k,searchQuery:o,preview:"popover"===n?"inline":"default",textInputElement:m}),[v,k,_,i,n,m,o]),A=(0,lK.useMemo)(()=>({border:!1,defaultValue:o,disabled:i,icon:a0.W1M,onChange:C,placeholder:j,ref:g}),[C,i,j,o]),O=(0,lK.useMemo)(()=>({"aria-label":w,disabled:y||i,icon:a0.j29,mode:"bleed",onClick:_,ref:f,selected:l}),[y,_,i,l,w]),z=(0,lK.useMemo)(()=>b?t?(0,lU.jsx)(lY.xv,{size:1,children:"New document..."}):(0,lU.jsx)(ub,{currentUser:v,operationLabel:"create any document"}):(0,lU.jsx)(lY.xv,{size:1,children:"No document types"}),[t,v,b]),M=(0,lK.useMemo)(()=>({content:(0,lU.jsx)(DV,{padding:2,children:z}),disabled:i||l,placement:"bottom",portal:!0,scheme:x}),[i,l,x,z]);return"dialog"===n?(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.u,{...M,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.zx,{...O})})}),l&&(0,lU.jsx)(DN,{header:w,id:"create-new-document-dialog",onClickOutside:S,onClose:S,ref:p,scheme:x,width:1,children:(0,lU.jsxs)(DU,{direction:"column",flex:1,height:"fill",children:[(0,lU.jsx)(DK,{padding:2,borderBottom:!0,children:(0,lU.jsx)(lY.oi,{...A})}),(0,lU.jsx)(lY.kC,{direction:"column",overflow:"hidden",children:(0,lU.jsx)(DF,{...P})})]})})]}):(0,lU.jsx)(Dq,{constrainSize:!0,onKeyDown:E,open:l,portal:!0,radius:3,ref:c,scheme:x,content:(0,lU.jsxs)(DU,{direction:"column",flex:1,forwardedAs:a2.ZP,height:"fill",returnFocus:!0,children:[(0,lU.jsx)(DB,{sizing:"border",children:(0,lU.jsxs)(lY.Kq,{children:[(0,lU.jsx)(lY.xu,{paddingX:3,paddingY:3,children:(0,lU.jsx)(lY.xu,{paddingY:1,children:(0,lU.jsx)(lY.__,{size:1,muted:!0,children:w})})}),(0,lU.jsx)(lY.Zb,{borderTop:!0,borderBottom:!0,padding:1,children:(0,lU.jsx)(lY.oi,{...A,fontSize:1,radius:1})})]})}),(0,lU.jsx)(DH,{$itemHeight:33,$maxDisplayedItems:10,direction:"column",overflow:"hidden",children:(0,lU.jsx)(DF,{...P})})]}),children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.u,{...M,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.zx,{...O,"aria-expanded":l,"aria-haspopup":"true",onKeyDown:T})})})})})}var D$=Object.freeze,DX=Object.defineProperty;let DG=(0,aW.ZP)(lY.Zb)(r6||(r6=D$(DX(em=["\n background: transparent;\n margin: calc((-35px + 11px) / 2);\n"],"raw",{value:D$(em.slice())})))),DY=(0,lK.memo)(function(e){let{presence:t,focused:n,onFocus:i}=e,[r,l]=(0,lK.useState)(null),a=sx()(t.locations||[],["lastActiveAt"],["desc"]).find(e=>e.documentId),o=!!(null==a?void 0:a.documentId);(0,lK.useEffect)(()=>{n&&r&&(r.focus(),r.setAttribute("data-selected","")),n||null==r||r.removeAttribute("data-selected")},[r,n]);let s=(0,lK.useCallback)(()=>{i(t.user.id)},[i,t.user.id]),d=(0,lK.useMemo)(()=>(0,lK.forwardRef)(function(e,t){return(null==a?void 0:a.path)?(0,lU.jsx)(a1.nR,{...e,intent:"edit",params:{id:null==a?void 0:a.documentId,path:lB.BB(null==a?void 0:a.path)},ref:t}):null}),[a]);return(0,lU.jsx)(lY.sN,{as:a?d:"div","data-as":a?"a":"div",onFocus:s,paddingY:o?4:3,paddingLeft:4,paddingRight:3,ref:l,children:(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(DG,{children:(0,lU.jsx)(U4,{size:1,user:t.user,status:o?"editing":"inactive"},t.user.id)}),(0,lU.jsxs)(lY.Kq,{space:2,marginLeft:4,children:[(0,lU.jsx)(lY.xv,{textOverflow:"ellipsis",children:t.user.displayName}),!o&&(0,lU.jsx)(lY.xv,{size:0,muted:!0,textOverflow:"ellipsis",children:"Not in a document"})]})]})})});var DJ=Object.freeze,DQ=Object.defineProperty,D0=(e,t)=>DJ(DQ(e,"raw",{value:DJ(t||e.slice())}));let D1=(0,aW.ZP)(lY.Zb)(r8||(r8=D0(["\n background: transparent;\n"]))),D2=(0,aW.ZP)(lY.v2)(r9||(r9=D0(["\n max-width: 350px;\n min-width: 250px;\n"]))),D3=(0,aW.ZP)(lY.Kq)(r7||(r7=D0(["\n position: sticky;\n bottom: 0;\n"])));
1function D4(e){let{collapse:t}=e,n=function(){let[e,t]=(0,lK.useState)([]),n=UQ();return(0,lK.useEffect)(()=>{let e=n.globalPresence$.subscribe(t);return()=>{e.unsubscribe()}},[n]),e}(),{projectId:i}=Ib(),{scheme:r}=Ff(),l=n.length>0,[a,o]=(0,lK.useState)(),s=(0,lK.useCallback)(e=>{o(e)},[]),d=(0,lK.useCallback)(()=>{o("")},[]),c=(0,lK.useMemo)(()=>t?(0,lU.jsx)(pK,{icon:a0.oyc,mode:"bleed",tone:l?"positive":void 0}):(0,lU.jsx)(lY.zx,{mode:"bleed",padding:1,children:(0,lU.jsx)(D1,{children:(0,lU.jsx)(lY.Jh,{maxLength:4,children:n.map(e=>(0,lU.jsx)(U4,{user:e.user},e.user.id))})})}),[t,l,n]),u=(0,lK.useMemo)(()=>({constrainSize:!0,portal:!0,scheme:r}),[r]);return(0,lU.jsx)(lY.j2,{button:c,id:"global-presence-menu",onClose:d,menu:(0,lU.jsxs)(D2,{padding:1,children:[l&&(0,lU.jsx)(lY.Kq,{children:n.map(e=>(0,lU.jsx)(DY,{focused:a===e.user.id,onFocus:s,presence:e},e.user.id))}),!l&&(0,lU.jsx)(lY.xu,{paddingX:3,paddingY:4,children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{weight:"semibold",size:2,children:"No one else is here"}),(0,lU.jsx)(lY.xv,{size:1,muted:!0,children:"Invite people to the project to see their online status."})]})}),(0,lU.jsxs)(D3,{space:1,children:[(0,lU.jsx)(lY.R,{}),(0,lU.jsx)(lY.sN,{as:"a",href:"https://sanity.io/manage/project/".concat(i),iconRight:a0.IEm,onFocus:d,paddingY:4,rel:"noopener noreferrer",target:"_blank",text:"Manage members"})]})]}),popover:u})}var D5=Object.freeze,D6=Object.defineProperty,D8=(e,t)=>D5(D6(e,"raw",{value:D5(t||e.slice())}));let D9={duration:.2},D7={open:{opacity:1},closed:{opacity:0}},Ze={open:{x:"0%"},closed:{x:"-100%"}},Zt=(0,aW.ZP)(lY.mh)(le||(le=D8(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),Zn=(0,aW.ZP)((0,dF.E)(lY.Zb))(lt||(lt=D8(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: var(--card-shadow-penumbra-color);\n"]))),Zi=(0,aW.ZP)((0,dF.E)(lY.Zb))(ln||(ln=D8(["\n position: relative;\n pointer-events: all;\n flex-direction: column;\n height: 100%;\n min-width: 200px;\n max-width: 280px;\n overflow: auto;\n"])));function Zr(e){let{setScheme:t}=e,n=Fm(t);return(0,lU.jsx)(lU.Fragment,{children:(0,lU.jsxs)(lY.Zb,{borderTop:!0,flex:"none",padding:3,overflow:"auto",children:[(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.__,{size:1,muted:!0,children:"Appearance"})}),(0,lU.jsx)(lY.Kq,{as:"ul",marginTop:1,space:1,children:n.map(e=>{let{icon:t,label:n,name:i,onSelect:r,selected:l,title:a}=e;return(0,lU.jsx)(lY.Kq,{as:"li",children:(0,lU.jsx)(lY.zx,{"aria-label":n,icon:t,iconRight:l&&(0,lU.jsx)(a0.KML,{}),justify:"flex-start",mode:"bleed",onClick:r,selected:l,text:a})},i)})})]})})}let Zl=(0,lK.memo)(function(e){let{activeToolName:t,isOpen:n,onClose:i,tools:r}=e,l=Fu(),{auth:a,currentUser:o,projectId:s}=Ib(),d=Fy(),c=qG(),u=!!(o&&cS(o,"administrator")),p=(0,lK.useCallback)(e=>{"Escape"===e.key&&i()},[i]);return(0,lU.jsx)(dD.M,{children:n&&(0,lU.jsx)(a2.ZP,{autoFocus:!0,returnFocus:!0,children:(0,lU.jsxs)(Zt,{onKeyDown:p,children:[(0,lU.jsx)(Zn,{animate:"open","data-open":n,exit:"closed",initial:"closed",onClick:i,transition:D9,variants:D7}),(0,lU.jsxs)(Zi,{animate:"open","data-open":n,display:"flex",exit:"closed",height:"fill",initial:"closed",shadow:1,transition:D9,variants:Ze,children:[(0,lU.jsx)(lY.Zb,{borderBottom:!0,children:(0,lU.jsxs)(lY.Kq,{space:3,padding:3,children:[(0,lU.jsxs)(lY.kC,{align:"center",children:[(0,lU.jsx)(lY.kC,{flex:1,align:"center",paddingRight:2,children:(0,lU.jsxs)(lY.kC,{flex:1,align:"center",children:[(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(U4,{size:1,user:"me"})}),(0,lU.jsx)(lY.xu,{flex:1,marginLeft:2,title:(null==o?void 0:o.name)||(null==o?void 0:o.email),children:(0,lU.jsx)(lY.xv,{textOverflow:"ellipsis",children:(null==o?void 0:o.name)||(null==o?void 0:o.email)})})]})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(lY.zx,{icon:a0.Two,mode:"bleed",onClick:i,title:"Close menu"})})]}),d.length>1&&(0,lU.jsx)(F9,{text:"Select workspace",justify:"flex-start"})]})}),(0,lU.jsxs)(lY.kC,{direction:"column",flex:1,justify:"space-between",overflow:"auto",children:[(0,lU.jsx)(lY.Zb,{flex:"none",padding:3,children:(0,lU.jsx)(c,{activeToolName:t,closeSidebar:i,context:"sidebar",isSidebarOpen:n,tools:r})}),(0,lU.jsxs)(lY.kC,{direction:"column",children:[l&&(0,lU.jsx)(Zr,{setScheme:l}),(0,lU.jsx)(lY.Zb,{borderTop:!0,flex:"none",padding:3,children:(0,lU.jsxs)(lY.Kq,{as:"ul",space:1,children:[(0,lU.jsx)(lY.Kq,{as:"li",children:(0,lU.jsx)(lY.zx,{"aria-label":"Manage project",as:"a",href:"https://sanity.io/manage/project/".concat(s),icon:a0.IEm,justify:"flex-start",mode:"bleed",target:"_blank",text:"Manage project"})}),u&&(0,lU.jsx)(lY.Kq,{as:"li",children:(0,lU.jsx)(lY.zx,{"aria-label":"Invite members",as:"a",href:"https://sanity.io/manage/project/".concat(s,"/members"),icon:a0.oyc,justify:"flex-start",mode:"bleed",target:"_blank",text:"Invite members"})})]})})]})]}),a.logout&&(0,lU.jsx)(lY.Zb,{flex:"none",padding:3,borderTop:!0,children:(0,lU.jsx)(lY.Kq,{children:(0,lU.jsx)(lY.zx,{iconRight:a0.Ow9,justify:"flex-start",mode:"bleed",onClick:a.logout,text:"Sign out"})})})]})]})})})});function Za(){var e;let t=Nu(),n=(null==(e=t._validation)?void 0:e.filter(e=>e.problems.some(e=>
1"warning"===e.severity)))||[],{scheme:i}=Ff(),r=(0,lK.useId)(),[l,a]=(0,lK.useState)(!1),[o,s]=(0,lK.useState)(null),d=(0,lK.useCallback)(()=>a(!0),[]),c=(0,lK.useCallback)(()=>{a(!1),o&&o.focus()},[o]);return 0===n.length?null:(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(pK,{icon:a0.foC,label:"Found configuration issues",mode:"bleed",onClick:d,ref:s,selected:l,tone:"caution",tooltip:{scheme:i}}),l&&(0,lU.jsx)(lY.Vq,{header:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.xv,{weight:"semibold",children:"Configuration issues"}),(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"Configuration checks are only performed during development and will not be visible in production builds"})]}),width:2,onClickOutside:c,onClose:c,scheme:i,id:r,children:(0,lU.jsxs)(lY.Kq,{space:4,padding:4,children:[(0,lU.jsxs)(lY.X6,{as:"h2",size:1,children:["Found ",n.length," schema warnings"]}),(0,lU.jsx)(FF,{problemGroups:n})]})})]})}function Zo(e){let{title:t,children:n,href:i,onClick:r}=e;return(0,lU.jsx)(lY.zx,{"aria-label":t,as:"a","data-testid":"logo",href:i,mode:"bleed",onClick:r,padding:0,children:n})}let Zs=(0,df.ZP)("mod+".concat("k")),Zd=(0,df.ZP)("escape");function Zc(e){let{children:t,hasValidTerms:n,onClose:i,onOpen:r,open:l}=e,a=(0,lK.useRef)(!1),{dispatch:o,searchCommandList:s,setOnClose:d,state:{result:c}}=MK(),u=(0,lK.useCallback)(()=>{var e;o({index:null!=(e=null==s?void 0:s.getTopIndex())?e:-1,type:"LAST_ACTIVE_INDEX_SET"}),i()},[o,i,s]);return(!function(e){let{open:t,onClose:n,onOpen:i}=e,{isTopLayer:r}=(0,lY.sJ)(),l=(0,lK.useCallback)(()=>{null==n||n()},[n]),a=(0,lK.useCallback)(e=>{Zs(e)&&(e.preventDefault(),t?l():null==i||i()),Zd(e)&&t&&r&&l()},[l,r,t,i]);(0,lY.qh)(a)}({onClose:u,onOpen:r,open:l}),(0,lK.useEffect)(()=>{d(u)},[u,d]),(0,lK.useEffect)(()=>{(!n||c.loaded)&&a.current&&o({index:0,type:"LAST_ACTIVE_INDEX_SET"})},[o,n,c.loaded]),(0,lK.useEffect)(()=>{n||!a.current||l||o({type:"ORDERING_RESET"})},[o,n,l]),(0,lK.useEffect)(()=>{(null==a?void 0:a.current)||(a.current=!0)},[]),l)?(0,lU.jsx)("div",{children:t}):null}function Zu(e,t){return t?e[t]:void 0}function Zp(e,t){var n;return{fieldId:t,filterName:e.name,operatorType:(null==(n=null==e?void 0:e.operators.find(e=>"item"===e.type))?void 0:n.name)||""}}function Zh(e){let{fieldDefinitions:t,filterDefinitions:n,filters:i,operatorDefinitions:r}=e;return i.filter(e=>Zx({filter:e,filterDefinitions:n,fieldDefinitions:t,operatorDefinitions:r})).map(e=>{var i;return null==(i=Zu(r,e.operatorType))?void 0:i.groqFilter({fieldPath:function(e){let{filter:t,fieldDefinitions:n,filterDefinitions:i}=e,r=Zf(n,t),l=i[t.filterName];if(l)switch(l.type){case"field":return null==r?void 0:r.fieldPath;case"pinned":return null==l?void 0:l.fieldPath;default:return}}({filter:e,fieldDefinitions:t,filterDefinitions:n}),value:null==e?void 0:e.value})}).filter(e=>!dg()(e)).filter(d9).join(" && ")}function Zf(e,t){return(null==t?void 0:t.fieldId)?e[t.fieldId]:void 0}function Zm(e){return[e.filterName,...e.fieldId?[e.fieldId]:[]].join("-")}function Zg(e){let{fieldDefinitions:t,filters:n,types:i}=e,r=i.map(e=>e.name),l=Object.values(t).filter(e=>n.map(e=>null==e?void 0:e.fieldId).includes(e.id)).filter(e=>e.documentTypes.length>0).map(e=>e.documentTypes),a=o6()(...l),o=[];return r.length>0&&o.push(r),a.length>0&&o.push(a),o6()(...o).sort()}function Zx(e){let{filter:t,filterDefinitions:n,fieldDefinitions:i,operatorDefinitions:r}=e,l=n[t.filterName],a=Zu(r,t.operatorType),o=Zf(i,t);if(!l||!a||t.fieldId&&!o)return!1;if("field"===l.type){if(!(null==o?void 0:o.fieldPath)||!t.fieldId)return!1;let e=a.groqFilter({fieldPath:o.fieldPath,value:t.value});if(!e)return!1}if("pinned"===l.type){let e=a.groqFilter({fieldPath:l.fieldPath,value:t.value});if(!e)return!1}return!0}var Zv=Object.freeze,Zb=Object.defineProperty;let Zy=(0,df.ZP)("escape"),Zj=aW.ZP.div(li||(li=Zv(Zb(eg=["\n background: transparent;\n height: 100%;\n left: 0;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: -1;\n"],"raw",{value:Zv(eg.slice())}))));function Zw(e){let{anchorElement:t,children:n,onClose:i}=e,{isTopLayer:r}=(0,lY.sJ)(),l=(0,lK.useCallback)(e=>{Zy(e)&&r&&i()},[r,i]);(0,lY.qh)(l);let a=function(e){let[t,n]=(0,lK.useState)(e&&Zk(e)),i=(0,lK.useCallback)(()=>{e&&n(Zk(e))},[e]);return(0,lK.useEffect)(()=>{e&&n(Zk(e))},[e]),(0,lK.useEffect)(()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]),t}(t||null);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(Zj,{onClick:i}),(0,lU.jsx)(a2.ZP,{autoFocus:!1,returnFocus:!0,children:(0,lU.jsx)(lY.Zb,{display:"flex",overflow:"hidden",radius:2,style:{maxHeight:"min(calc(100vh - ".concat(a,"px - ").concat(5,"px - ").concat(M4,"px), ").concat(500,"px"),zIndex:1},children:(0,lU.jsx)(lY.kC,{children:n})})})]})}function Zk(e){let t=e.getBoundingClientRect(),n=t.y+t.height+5;return n}var ZC=Object.freeze,Z_=Object.defineProperty,ZS=(e,t)=>ZC(Z_(e,"raw",{value:ZC(t||e.slice())}));let ZT=(0,aW.ZP)(lY.xu)(lr||(lr=ZS(["\n border-bottom: 1px solid ",";\n flex-shrink: 0;\n"])),e=>{let{theme:t}=e;return t.sanity.color.base.border}),ZE=(0,aW.ZP)(lY.kC)(ll||(ll=ZS(["\n box-sizing: border-box;\n"]))),ZP=(0,lK.forwardRef)(function(e,t){let{ariaInputLabel:n,onChange:i,onClear:r,typeFilter:l}=e,{state:{fullscreen:a}}=MK();return(0,lU.jsx)(ZT,{children:(0,lU.jsx)(ZE,{align:"center",flex:1,padding:1,children:(0,lU.jsx)(Rc,{"aria-label":n,autoComplete:"off",border:!1,clearButton:!!l,fontSize:a?2:1,icon:a0.W1M,muted:!0,onChange:i,onClear:r,placeholder:"Filter",ref:t,smallClearButton:!0,spellCheck:!1,radius:2,value:l})})})});function ZA(e){let{fieldDefinitions:t,filterDefinitions:n,filters:i,id:r,headerTitle:l,tone:a}=e,o=i.map(e=>({fieldDefinition:Zf(t,e),filterDefinition:n[e.filterName],filter:e,group:r,tone:a||"default",type:"filter"}));return o.length>0?[...l?[{title:l||"",tone:a||"default",type:"header"}]:[],...o]:[]}function ZO(e,t){return e.title.toLowerCase().includes(t.toLowerCase())}function Zz(e){return"pinned"===e.type&&void 0!==(null==e?void 0:e.group)}function ZM(e){return"pinned"===e.type&&void 0===(null==e?void 0:e.group)}function ZI(e){let{filter:t,maxLength:n}=e,{state:{definitions:i}}=MK(),r=(0,lK.useMemo)(()=>{let e=i.filters[t.filterName];switch(null==e?void 0:e.type){case"field":{let e=Zf(i.fields,t);if(null==e?void 0:e.titlePath)return e.titlePath[e.titlePath.length-1];return null}case"pinned":return e.title;default:return null}},[i,t]);return r?n&&r.length>n?(0,lU.jsxs)("span",{children:[r.slice(0,n),"â¦"]}):(0,lU.jsx)("span",{children:r}):null}function ZR(e){var t;let{filter:n}=e,{state:{definitions:i}}=MK(),r=null==(t=i.filters[n.filterName])?void 0:t.icon;return r?(0,lK.createElement)(r):(0,lU.jsx)(a0.Tzq,{})}function ZF(e){var t;let{filter:n,small:i=!0}=e,{state:{definitions:r}}=MK(),l=Zf(r.fields,n);return(0,lU.jsxs)(lY.Kq,{space:i?2:3,children:[(null==l?void 0:l.titlePath)&&(null==(t=l.titlePath)?void 0:t.length)>1&&(0,lU.jsx)(lY.xu,{marginLeft:4,children:(0,lU.jsx)(lY.xv,{muted:!0,size:i?0:1,children:l.titlePath.slice(0,-1).map((e,t)=>(0,lU.jsxs)(lK.Fragment,{children:[(0,lU.jsx)("span",{children:e}),t!==l.titlePath.length-2&&(0,lU.jsx)("span",{style:{opacity:.75,paddingLeft:"0.25em",paddingRight:"0.25em"},children:(0,lU.jsx)(a0.XCv,{})})]},t))})}
1),(0,lU.jsxs)(lY.kC,{align:"flex-start",gap:3,children:[(0,lU.jsx)(lY.xu,{style:{flexShrink:0},children:(0,lU.jsx)(lY.xv,{size:i?1:2,children:(0,lU.jsx)(ZR,{filter:n})})}),(0,lU.jsx)(lY.xv,{size:i?1:2,weight:"medium",children:(0,lU.jsx)(ZI,{filter:n})})]})]})}function ZD(e){var t,n;return(0,lK.isValidElement)(e)?(t=(0,dR.Dq)(e),(null==(n=new DOMParser().parseFromString(t,"text/html"))?void 0:n.body.textContent)||""):"string"==typeof e?e:""}function ZZ(e){let{children:t,fieldDefinition:n,filterDefinition:i,visible:r}=e,{state:{documentTypesNarrowed:l}}=MK(),a=Nu(),o=(0,lK.useMemo)(()=>(null==n?void 0:n.documentTypes)?n.documentTypes.map(e=>{let t=a.get(e);return(null==t?void 0:t.title)||ol()(null==t?void 0:t.name)}).filter(d9).sort():[],[null==n?void 0:n.documentTypes,a]),s=(0,lK.useMemo)(()=>{if(null==n?void 0:n.documentTypes){let e=n.documentTypes.map(e=>{let t=a.get(e);if(t){let e=M$(t,n.fieldPath);return(null==e?void 0:e.type.description)&&ZD(null==e?void 0:e.type.description)}return null}).filter(d9).sort(),t=sa()(e);if(1===t.length)return t[0]}},[null==n?void 0:n.documentTypes,null==n?void 0:n.fieldPath,a]);return(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.Zb,{tone:"default",radius:2,style:{maxWidth:"250px"},children:(0,lU.jsxs)(lY.Kq,{padding:3,space:4,children:[n&&(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsx)(lY.__,{muted:!0,size:0,children:"Field name"}),(0,lU.jsx)(lY.gF,{children:(0,lU.jsx)(lY.Zb,{tone:"caution",padding:1,radius:2,children:(0,lU.jsx)(lY.EK,{size:0,children:null==n?void 0:n.name})})})]}),s&&(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsx)(lY.__,{muted:!0,size:0,children:"Field description"}),(0,lU.jsx)(lY.xv,{muted:!0,size:0,children:ZL(s)})]}),(null==i?void 0:i.description)&&(0,lU.jsx)(lY.xv,{muted:!0,size:0,children:ZL(i.description)}),!l.length&&o.length>0&&(0,lU.jsxs)(lY.Kq,{space:2,children:[(0,lU.jsxs)(lY.kC,{align:"center",gap:1,children:[(0,lU.jsx)(lY.__,{muted:!0,size:0,children:"Used in document types"}),(0,lU.jsx)(lY.Zb,{padding:1,radius:2,tone:"transparent",children:(0,lU.jsx)(lY.xv,{size:0,muted:!0,children:o.length})})]}),(0,lU.jsxs)(lY.xv,{size:0,weight:"regular",muted:!0,children:[o.slice(0,10).join(", "),(null==o?void 0:o.length)>10?" +".concat(o.length-10," more"):""]})]})]})}),disabled:!r,fallbackPlacements:["left"],placement:"right",portal:!0,children:t})}function ZL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:256;return e.length>t?"".concat(e.slice(0,t-1),"â¦"):e}let Zq=lK.memo(function(e){let{item:t,onClose:n,...i}=e,[r,l]=(0,lK.useState)(!1),{dispatch:a,state:{filters:o}}=MK(),s=(0,lK.useCallback)(()=>{a({filter:t.filter,type:"TERMS_FILTERS_ADD"}),null==n||n()},[a,t.filter,n]),d=!!o.find(e=>Zm(e)===Zm(t.filter)),c=(0,lK.useRef)(),u=(0,lK.useCallback)(()=>{c.current=setTimeout(()=>l(!0),500)},[]),p=(0,lK.useCallback)(()=>{l(!1),clearTimeout(c.current)},[]);(0,lK.useEffect)(()=>()=>clearTimeout(c.current),[]);let h=!!(t.fieldDefinition||t.filterDefinition.description);return(0,lU.jsx)(lY.xu,{...i,children:(0,lU.jsx)(lY.zx,{disabled:d,fontSize:1,justify:"flex-start",mode:"bleed",onClick:d?void 0:s,onMouseEnter:u,onMouseLeave:p,padding:0,style:{position:"relative",whiteSpace:"normal",width:"100%"},tabIndex:-1,tone:null==t?void 0:t.tone,children:(0,lU.jsx)(ZZ,{fieldDefinition:t.fieldDefinition,filterDefinition:t.filterDefinition,visible:h&&r,children:(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsx)(ZF,{filter:t.filter})})})})})}),ZN=lK.memo(function(e){let{item:t}=e;return(0,lU.jsx)(lY.xu,{paddingTop:1,children:(0,lU.jsx)(lY.Zb,{borderBottom:!0,padding:3,tone:null==t?void 0:t.tone,children:(0,lU.jsx)(lY.__,{muted:!0,size:0,textOverflow:"ellipsis",children:t.title})})})});function ZV(e){let{onClose:t}=e,[n,i]=(0,lK.useState)(null),[r,l]=(0,lK.useState)(""),a=(0,lK.useCallback)(e=>l(e.currentTarget.value),[l]),o=(0,lK.useCallback)(()=>l(""),[]),s=Nu(),{state:{documentTypesNarrowed:d,definitions:c,filters:u,terms:{types:p}}}=MK(),h=(0,lK.useMemo)(()=>(function(e){let{documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,schema:r,titleFilter:l,types:a}=e,o=Object.values(n).filter(e=>(function(e,t){let n=e.titlePath.join("/");return n.toLowerCase().includes(t.toLowerCase())})(e,l)).map(e=>{let t=i[e.filterName];return t?Zp(t,e.id):null}).filter(d9),s=function(e){let{fieldDefinitions:t,filterDefinitions:n,titleFilter:i}=e,r=Object.values(n).filter(ZM).filter(e=>ZO(e,i)).map(e=>Zp(e)),l=Object.values(n).filter(Zz).filter(e=>ZO(e,i)).reduce((e,t)=>
1(e[t.group]=e[t.group]||[],e[t.group].push(Zp(t)),e),{});return[...ZA({fieldDefinitions:t,filterDefinitions:n,filters:r,id:"pinned-ungrouped",tone:"primary"}),...Object.entries(l).flatMap(e=>{let[i,r]=e;return ZA({fieldDefinitions:t,filterDefinitions:n,filters:r,headerTitle:i,id:i,tone:"primary"})})]}({fieldDefinitions:n,filterDefinitions:i,titleFilter:l});return 0===t.length?[...s,...ZA({fieldDefinitions:n,filterDefinitions:i,filters:o,headerTitle:"All fields",id:"field"})]:[...s,...function(e){let{documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,filters:r,schema:l,types:a}=e,o=r.filter(e=>{let i=Zf(n,e);return 0===s3()(t,(null==i?void 0:i.documentTypes)||[]).length}),s=t.length>1&&a.length>1?ZA({fieldDefinitions:n,filterDefinitions:i,filters:o,headerTitle:"Shared fields",id:"shared",tone:"primary"}):[],d=t.map(e=>{let t=l.get(e);return{title:(null==t?void 0:t.title)||ol()(null==t?void 0:t.name)||"(Unknown type)",documentType:e}}).sort((e,t)=>e.title.localeCompare(t.title)).map(e=>{let{documentType:t,title:l}=e,a=r.filter(e=>{var i;let r=Zf(n,e);return i=[t],null==r?void 0:r.documentTypes.some(e=>i.includes(e))});return ZA({fieldDefinitions:n,filterDefinitions:i,filters:a,id:l,headerTitle:l})}).flat();return[...s,...d]}({documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,filters:o,schema:r,types:a})]})({documentTypesNarrowed:d,fieldDefinitions:c.fields,filterDefinitions:c.filters,schema:s,titleFilter:r,types:p}),[d,c.fields,c.filters,s,r,p]),f=(0,lK.useCallback)(e=>"filter"===e.type?(0,lU.jsx)(Zq,{item:e,onClose:t,paddingBottom:1}):"header"===e.type?(0,lU.jsx)(ZN,{item:e}):null,[t]),m=(0,lK.useCallback)(e=>{let t=h[e];return"filter"!==t.type||!!u.find(e=>Zm(e)===Zm(t.filter))},[h,u]),g=(0,lK.useCallback)(e=>{let t=h[e];switch(t.type){case"filter":return[...t.group?[t.group]:[],Zm(t.filter)].join("-");case"header":return"".concat(t.type,"-").concat(t.title);default:return e}},[h]);return(0,lU.jsxs)(lY.kC,{direction:"column",style:{width:"300px"},children:[(0,lU.jsx)(ZP,{ariaInputLabel:"Filter by title",onChange:a,onClear:o,ref:i,typeFilter:r}),(0,lU.jsxs)(lY.kC,{children:[h.length>0&&(0,lU.jsx)(uc,{activeItemDataAttr:"data-hovered",ariaLabel:"Filters",autoFocus:"input",getItemDisabled:m,getItemKey:g,inputElement:n,itemHeight:45,items:h,overscan:20,padding:1,paddingBottom:0,renderItem:f}),0==h.length&&(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsxs)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:["No matches for '",r,"'"]})})]})]})}function ZU(){let[e,t]=(0,lK.useState)(!1),[n,i]=(0,lK.useState)(null),{state:{fullscreen:r}}=MK(),l=(0,lK.useCallback)(()=>t(!1),[]),a=(0,lK.useCallback)(()=>t(!0),[]);return(0,lU.jsx)(lY.J2,{__unstable_margins:[5,0,0,0],content:(0,lU.jsx)(Zw,{anchorElement:n,onClose:l,children:(0,lU.jsx)(ZV,{onClose:l})}),open:e,placement:"bottom-start",radius:2,portal:!0,children:(0,lU.jsx)(lY.zx,{fontSize:1,icon:a0.dtP,mode:"bleed",onClick:a,padding:r?3:2,ref:i,selected:e,space:2,text:"Add filter"})})}let ZB=lK.memo(function(e){var t,n;let{selected:i,type:r,...l}=e,{dispatch:a}=MK(),o=(0,lK.useCallback)(()=>{a({type:"TERMS_TYPE_ADD",schemaType:r})},[a,r]),s=(0,lK.useCallback)(()=>{a({type:"TERMS_TYPE_REMOVE",schemaType:r})},[a,r]),d=(0,lK.useCallback)(()=>{i?s():o()},[o,s,i]);return(0,lU.jsx)(lY.xu,{...l,children:(0,lU.jsx)(lY.zx,{fontSize:1,iconRight:i&&a0.KML,justify:"flex-start",mode:"bleed",onClick:d,style:{width:"100%"},tabIndex:-1,text:null!=(n=r.title)?n:r.name,tone:i?"primary":"default"},null!=(t=r.title)?t:r.name)})});var ZK=Object.freeze,ZH=Object.defineProperty;let ZW=(0,aW.ZP)(lY.xu)(la||(la=ZK(ZH(ex=["\n border-top: 1px solid ",";\n flex-shrink: 0;\n"],"raw",{value:ZK(ex.slice())}))),e=>{let{theme:t}=e;return t.sanity.color.base.border});function Z$(){let[e,t]=(0,lK.useState)(null),[n,i]=(0,lK.useState)(""),r=(0,lK.useRef)(null),l=Nu(),{dispatch:a,state:{terms:{types:o}}}=MK(),[s,d]=(0,lK.useState)(o),c=(0,lK.useMemo)(()=>{let[e,t]=se()(M6(l).filter(e=>{var t;return!n||(null!=(t=e.title)?t:e.name).toLowerCase().includes(null==n?void 0:n.toLowerCase())}).sort(M8),e=>s.includes(e)),i=e.length>0,r=e.length>0,a=[];return i&&a.push({title:"Selected",type:"header"}
1),e.forEach(e=>a.push({item:e,selected:o.includes(e),type:"item"})),i&&r&&a.push({type:"divider"}),t.forEach(e=>a.push({item:e,selected:o.includes(e),type:"item"})),a},[l,o,s,n]),u=(0,lK.useCallback)(e=>i(e.currentTarget.value),[i]),p=(0,lK.useCallback)(()=>i(""),[]),h=(0,lK.useCallback)(()=>{var e,t;d([]),a({type:"TERMS_TYPES_CLEAR"}),null==(e=null==r?void 0:r.current)||e.focusInputElement(),null==(t=null==r?void 0:r.current)||t.scrollToIndex(0)},[a]),f=(0,lK.useCallback)(e=>{let t=c[e];switch(t.type){case"divider":return"".concat(t.type,"-").concat(e);case"header":return"".concat(t.type,"-").concat(t.title);case"item":return"".concat(t.type,"-").concat(t.item.name);default:return e}},[c]),m=(0,lK.useCallback)(e=>"divider"===e.type?(0,lU.jsx)(lY.xu,{paddingY:1,children:(0,lU.jsx)(lY.R,{})}):"header"===e.type?(0,lU.jsx)(lY.xu,{margin:1,paddingBottom:2,paddingTop:3,children:(0,lU.jsx)(lY.__,{muted:!0,size:0,children:e.title})}):"item"===e.type?(0,lU.jsx)(ZB,{paddingBottom:1,selected:e.selected,type:e.item}):null,[]),g=(0,lK.useCallback)(e=>{let t=c[e];return"item"!==t.type},[c]),x=(0,lK.useCallback)(e=>{let t=c[e];return"item"===t.type&&t.selected},[c]);return(0,lU.jsxs)(lY.kC,{direction:"column",style:{width:"250px"},children:[(0,lU.jsx)(ZP,{ariaInputLabel:"Filter by document type",onChange:u,onClear:p,ref:t,typeFilter:n}),(0,lU.jsxs)(lY.kC,{children:[c.length>0&&(0,lU.jsx)(uc,{activeItemDataAttr:"data-hovered",ariaLabel:"Document types",ariaMultiselectable:!0,autoFocus:"input",getItemDisabled:g,getItemSelected:x,getItemKey:f,inputElement:e,itemHeight:37,items:c,overscan:20,padding:1,paddingBottom:0,ref:r,renderItem:m}),!c.length&&(0,lU.jsx)(lY.xu,{padding:3,children:(0,lU.jsxs)(lY.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:["No matches for '",n,"'"]})})]}),!n&&o.length>0&&(0,lU.jsx)(ZX,{onClick:h,selectedTypes:o})]})}function ZX(e){let{onClick:t,selectedTypes:n}=e;return(0,lU.jsx)(ZW,{padding:1,children:(0,lU.jsx)(lY.Kq,{children:(0,lU.jsx)(lY.zx,{"aria-label":"Clear checked filters","data-name":"type-filter-button",disabled:0===n.length,fontSize:1,mode:"bleed",onClick:t,padding:3,text:"Clear",tone:"primary"})})})}var ZG=Object.freeze,ZY=Object.defineProperty,ZJ=(e,t)=>ZG(ZY(e,"raw",{value:ZG(t||e.slice())}));let ZQ=(0,aW.ZP)(lY.zx)(e=>{let{theme:t}=e,{regular:n}=t.sanity.fonts.text.weights;return(0,aW.iv)(lo||(lo=ZJ(["\n [data-ui='Text'] {\n font-weight: ",";\n }\n "])),n)});function Z0(){let[e,t]=(0,lK.useState)(!1),[n,i]=(0,lK.useState)(null),[r,l]=(0,lK.useState)(null),{state:{fullscreen:a,terms:{types:o}}}=MK(),s=(0,lK.useCallback)(()=>t(!1),[]),d=(0,lK.useCallback)(()=>t(!0),[]);(0,lY.O8)(s,[n,r]);let c=(0,lK.useMemo)(()=>In({types:o}),[o]);return(0,lU.jsx)(lY.J2,{__unstable_margins:[5,0,0,0],content:(0,lU.jsx)(Zw,{anchorElement:n,onClose:s,children:(0,lU.jsx)(Z$,{})}),open:e,placement:"bottom-start",portal:!0,radius:2,ref:l,children:(0,lU.jsx)(ZQ,{fontSize:1,iconRight:a0.GVG,mode:"ghost",onClick:d,padding:a?3:2,ref:i,selected:e,style:{maxWidth:"100%"},text:c,tone:"default"})})}var Z1=Object.freeze,Z2=Object.defineProperty;let Z3=(0,aW.ZP)(lY.xu)(ls||(ls=Z1(Z2(ev=["\n flex-shrink: ",";\n"],"raw",{value:Z1(ev.slice())}))),e=>{let{$flexShrink:t=0}=e;return t});function Z4(e){let{filter:t,fontSize:n=1,showContent:i=!0}=e,{state:{definitions:r,fullscreen:l}}=MK(),a=Zu(r.operators,t.operatorType),o=null==a?void 0:a.buttonValueComponent;return(0,lU.jsxs)(lY.kC,{align:"center",gap:1,children:[(0,lU.jsx)(Z3,{$flexShrink:l?1:0,children:(0,lU.jsx)(pG,{tone:"default",size:n,textOverflow:"ellipsis",weight:"semibold",children:(0,lU.jsx)(ZI,{filter:t,maxLength:l?25:40})})}),i&&(null==a?void 0:a.buttonLabel)&&(0,lU.jsx)(Z3,{$flexShrink:0,children:(0,lU.jsx)(pG,{tone:"default",size:n,textOverflow:"ellipsis",weight:"regular",children:a.buttonLabel})}),i&&o&&(0,lU.jsx)(Z3,{$flexShrink:1,children:(0,lU.jsx)(pG,{tone:"default",size:n,textOverflow:"ellipsis",weight:"semibold",children:(0,lU.jsx)(o,{value:null==t?void 0:t.value})})})]})}function Z5(e){return(0,lU.jsx)(lY.xu,{...e,children:(0,lU.jsxs)(lY.kC,{align:"flex-start",ga
1p:3,children:[(0,lU.jsx)(pG,{tone:"critical",children:(0,lU.jsx)(a0.uIy,{})}),(0,lU.jsxs)(lY.Kq,{space:4,children:[(0,lU.jsx)(pG,{size:1,tone:"critical",weight:"semibold",children:"An error occurred whilst displaying this filter."}),(0,lU.jsx)(pG,{size:1,tone:"critical",children:"This may indicate invalid options defined in your schema."})]})]})})}function Z6(e){let{onClick:t,operator:n,selected:i}=e,r=(0,lK.useCallback)(()=>t(n.type),[t,n.type]);return(0,lU.jsx)(lY.sN,{onClick:r,padding:3,pressed:i,tone:"default",children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"space-between",gap:3,children:[(0,lU.jsx)(lY.xu,{paddingRight:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"regular",children:n.label})}),(null==n?void 0:n.icon)&&(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:(0,lK.createElement)(n.icon)})]})})}function Z8(e){var t;let{filter:n,operator:i}=e,r=(0,lK.useId)(),{dispatch:l,state:a}=MK(),o=null==(t=a.definitions.filters[n.filterName])?void 0:t.operators,s=(0,lK.useCallback)(e=>{l({filterKey:Zm(n),operatorType:e,type:"TERMS_FILTERS_SET_OPERATOR"})},[l,n]);return i&&o&&!(o.length<=1)?(0,lU.jsx)(lY.gF,{children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{mode:"ghost",padding:3,children:(0,lU.jsxs)(lY.kC,{align:"center",gap:2,justify:"space-between",children:[(0,lU.jsx)(lY.xv,{size:a.fullscreen?2:1,weight:"regular",children:i.label}),(0,lU.jsx)(lY.xu,{marginLeft:1,children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.GVG,{})})})]})}),id:r||"",menu:(0,lU.jsx)(lY.v2,{children:o.map((e,t)=>{if("item"===e.type){let n=Zu(a.definitions.operators,e.name);return n?(0,lU.jsx)(Z6,{onClick:s,operator:n,selected:i.type===e.name},t):null}return"divider"===e.type?(0,lU.jsx)(lY.R,{},t):null})}),placement:"bottom-start",popover:{constrainSize:!0,portal:!1,radius:2}})}):null}function Z9(e){let{filter:t}=e,[n,i]=(0,lK.useState)(null),{dispatch:r,state:{definitions:l,fullscreen:a}}=MK(),o=l.filters[t.filterName],s=Zu(l.operators,t.operatorType),d=Zf(l.fields,t),c=Zm(t),u=(0,lK.useCallback)(()=>
1{r({filterKey:Zm(t),type:"TERMS_FILTERS_REMOVE"})},[r,t]),p=(0,lK.useCallback)(e=>{r({filterKey:c,type:"TERMS_FILTERS_SET_VALUE",value:e})},[r,c]),h=(0,lK.useCallback)(e=>{i(e)},[]),f=null==s?void 0:s.inputComponent;return n?(0,lU.jsx)(Z5,{padding:4}):(0,lU.jsx)(lY.SV,{onCatch:h,children:(0,lU.jsx)(a2.ZP,{autoFocus:!ck,returnFocus:!0,children:(0,lU.jsxs)(lY.kC,{direction:"column-reverse",children:[f&&(0,lU.jsx)(lY.Zb,{borderTop:!0,padding:3,children:(0,lU.jsx)(f,{fieldDefinition:d,onChange:p,value:t.value},t.operatorType)}),(0,lU.jsx)(lY.Zb,{padding:3,children:(0,lU.jsxs)(lY.Kq,{space:3,children:[(0,lU.jsxs)(lY.kC,{align:"flex-start",gap:3,justify:"space-between",children:[(0,lU.jsx)(lY.xu,{paddingBottom:1,paddingLeft:1,paddingRight:2,paddingTop:a?2:1,children:(0,lU.jsx)(ZF,{filter:t,small:!a})}),a&&(0,lU.jsx)(lY.zx,{fontSize:2,icon:a0.XHJ,mode:"bleed",onClick:u,padding:2,tone:"critical"})]}),(null==o?void 0:o.description)&&(0,lU.jsx)(lY.Zb,{border:!0,padding:3,radius:2,tone:"transparent",children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:o.description})}),(0,lU.jsx)(Z8,{filter:t,operator:s})]})})]})})})}var Z7=Object.freeze,Le=Object.defineProperty;let Lt=(0,aW.ZP)(lY.kC)(ld||(ld=Z7(Le(eb=["\n max-width: 480px;\n min-width: 150px;\n overflow: hidden;\n overflow: clip;\n width: 100%;\n"],"raw",{value:Z7(eb.slice())}))));function Ln(e){let{filter:t}=e;return(0,lU.jsxs)(Lt,{direction:"column",children:[(0,lU.jsx)(Z9,{filter:t}),!1]})}var Li=Object.freeze,Lr=Object.defineProperty,Ll=(e,t)=>Li(Lr(e,"raw",{value:Li(t||e.slice())}));let La=(0,aW.ZP)(lY.zx)(lc||(lc=Ll(["\n border-radius: ",";\n"])),e=>{let{theme:t}=e;return"0 ".concat((0,lY.hO)(t.sanity.radius[2])," ").concat((0,lY.hO)(t.sanity.radius[2])," 0")}),Lo=(0,aW.ZP)(lY.Zb)(lu||(lu=Ll(["\n position: absolute;\n right: 0;\n"]))),Ls=aW.ZP.div(lp||(lp=Ll(["\n align-items: center;\n display: inline-flex;\n max-width: 100%;\n position: relative;\n"]))),Ld=(0,aW.ZP)(lY.zx)(lh||(lh=Ll(["\n border: none;\n width: 100%;\n"])));function Lc(e){let{filter:t,initialOpen:n}=e,[i,r]=(0,lK.useState)(n),{dispatch:l,state:{definitions:a,fullscreen:o}}=MK(),s=(0,lK.useCallback)(()=>r(!1),[]),d=(0,lK.useCallback)(()=>r(!0),[]),c=(0,lK.useCallback)(()=>
1l({filterKey:Zm(t),type:"TERMS_FILTERS_REMOVE"}),[l,t]),u=(0,lK.useCallback)(e=>{["Backspace","Delete"].includes(e.key)&&c()},[c]),p=Zx({fieldDefinitions:a.fields,filter:t,filterDefinitions:a.filters,operatorDefinitions:a.operators});return(0,lU.jsx)(lY.J2,{__unstable_margins:[5,0,0,0],content:(0,lU.jsx)(Zw,{onClose:s,children:(0,lU.jsx)(Ln,{filter:t})}),constrainSize:!0,open:i,overflow:"auto",placement:"bottom-start",portal:!0,radius:2,children:(0,lU.jsxs)(Ls,{children:[(0,lU.jsx)(lY.Zb,{__unstable_focusRing:!0,display:"flex",radius:2,tone:p?"primary":"transparent",children:(0,lU.jsx)(Ld,{mode:"bleed",onClick:d,onKeyDown:u,paddingLeft:o?3:2,paddingRight:o?3:5,paddingY:o?3:2,children:(0,lU.jsx)(Z4,{filter:t,showContent:p})})}),!o&&(0,lU.jsx)(Lo,{__unstable_focusRing:!0,display:"flex",radius:2,tone:p?"primary":"transparent",children:(0,lU.jsx)(La,{"aria-label":"Delete filter",fontSize:1,icon:a0.Two,mode:"bleed",onClick:c,onKeyDown:u,padding:2,radius:2})})]})})}function Lu(){let{dispatch:e,state:{filters:t,fullscreen:n,lastAddedFilter:i,terms:{types:r}}}=MK(),l=(0,lK.useRef)(!1),a=(0,lK.useCallback)(()=>{e({type:"TERMS_FILTERS_CLEAR"}),e({type:"TERMS_TYPES_CLEAR"})},[e]),o=t.length>0||r.length>0;(0,lK.useEffect)(()=>{l.current=!0},[]);let s=i&&Zm(i),d=()=>(0,lU.jsx)(lY.zx,{fontSize:1,mode:"bleed",onClick:a,padding:n?3:2,text:"Clear filters",tone:"critical"});return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsxs)(lY.kC,{align:"flex-start",gap:3,justify:"space-between",padding:2,children:[(0,lU.jsxs)(lY.kC,{flex:1,gap:2,wrap:"wrap",children:[(0,lU.jsx)(Z0,{}),null==t?void 0:t.map(e=>{let t=Zm(e);return(0,lU.jsx)(Lc,{filter:e,initialOpen:l.current&&s===t},t)}),!n&&(0,lU.jsx)(ZU,{})]}),o&&!n&&(0,lU.jsx)(d,{})]}),n&&(0,lU.jsxs)(lY.kC,{justify:"space-between",paddingBottom:2,paddingX:2,children:[(0,lU.jsx)(ZU,{}),o&&(0,lU.jsx)(d,{})]}),!1]})}function Lp(){return(0,lU.jsx)(lY.kC,{align:"center",direction:"column",gap:4,paddingX:4,paddingY:5,children:(0,lU.jsxs)(lY.gF,{space:3,children:[(0,lU.jsx)(lY.xv,{muted:!0,children:"Use"}),(0,lU.jsx)(lY.xv,{muted:!0,children:(0,lU.jsx)(a0.d$S,{})}),(0,lU.jsx)(lY.xv,{muted:!0,children:"to refine your search"})]})})}function Lh(e){let{availableCharacters:t,types:n}=e,i=(0,lK.useMemo)(()=>In({availableCharacters:t,types:n}),[t,n]);return(0,lU.jsx)(lY.Zb,{border:!0,padding:2,radius:2,children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:i})})}var Lf=Object.freeze,Lm=Object.defineProperty;let Lg=(0,aW.ZP)(lY.Zb)(lf||(lf=Lf(Lm(ey=["\n cursor: default;\n"],"raw",{value:Lf(ey.slice())}))));function Lx(e){let{filter:t}=e;return(0,lU.jsx)(Lg,{border:!0,padding:2,radius:2,tone:"primary",children:(0,lU.jsx)(Z4,{filter:t})})}var Lv=Object.freeze,Lb=Object.defineProperty,Ly=(e,t)=>Lv(Lb(e,"raw",{value:Lv(t||e.slice())}));let Lj=(0,aW.ZP)(lY.zx)(lm||(lm=Ly(["\n border-radius: ",";\n cursor: default;\n width: 100%;\n"])),e=>{let{theme:t}=e;return(0,lY.hO)(t.sanity.radius[2])}),Lw=(0,aW.ZP)(lY.xu)(lg||(lg=Ly(["\n flex-shrink: 3;\n"]))),Lk=(0,aW.ZP)(lY.xu)(lx||(lx=Ly(["\n flex-shrink: 2;\n"]))),LC=aW.ZP.div(lv||(lv=Ly(["\n opacity: 0.8;\n visibility: hidden;\n\n @media (hover: hover) {\n ",":hover & {\n visibility: visible;\n }\n &:hover {\n opacity: 0.4;\n }\n }\n"])),Lj);function L_(e){var t;let{index:n,maxVisibleTypePillChars:i=40,value:r,...l}=e,{dispatch:a,recentSearchesStore:o}=MK(),s=i-r.query.length,d=(0,lK.useCallback)(()=>{if(a({type:"TERMS_SET",filters:null==r?void 0:r.filters,terms:r}),o){let e=null==o?void 0:o.addSearch(r,null==r?void 0:r.filters);a({recentSearches:e,type:"RECENT_SEARCHES_SET"})}},[a,o,r]),c=(0,lK.useCallback)(e=>{if(e.stopPropagation(),o){let e=null==o?void 0:o.removeSearchAtIndex(n);a({recentSearches:e,type:"RECENT_SEARCHES_SET"})}},[a,n,o]);return(0,lU.jsx)(lY.xu,{...l,children:(0,lU.jsx)(Lj,{mode:"bleed",onClick:d,paddingLeft:3,paddingRight:1,paddingY:1,tabIndex:-1,children:(0,lU.jsxs)(lY.kC,{align:"stretch",children:[(0,lU.jsxs)(lY.gF,{paddingY:2,children:[(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:(0,lU.jsx)(a0.T39,{})}),(0,lU.jsx)(lY.xv,{children:"â"})]}),(0,lU.jsxs)(lY.kC,{align:"stretch",flex:1,gap:2,justify:"flex-start",marginLeft:3,wrap:"wrap",children:[r.query&&(0,lU.jsx)(Lk,{paddingY:2,children:(0,lU.jsx)(lY.xv,{muted:!0,textOverflow:"ellipsis",children:r.query})}),r.types.length>0&&(0,lU.jsx)(Lw,{children:(0,lU.jsx)(Lh,{availableCharacters:s,types:r.types})}),null==(t=null==r?void 0:r.filters)?void 0:t.map((e,t)=>(0,lU.jsx)(Lx,{filter:e},t))]}),(0,lU.jsx)(lY.kC,{align:"center",children:(0,lU.jsx)(LC,{onClick:c,children:(0,lU.jsx)(lY.kC,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.Two,{})})})})})]})})})}var LS=Object.freeze,LT=Object.defineProperty;let LE=(0,aW.ZP)(lY.Zb)(lb||(lb=LS(LT(ej=["\n overflow-x: hidden;\n overflow-y: auto;\n position: relative;\n"],"raw",{value:LS(ej.slice())}))));function LP(e){let{inputElement:t}=e,{dispatch:n,recentSearchesStore:i,state:{filtersVisible:r,fullscreen:l,recentSearches:a}}=MK(),o=(0,lK.useRef)(null),s=(0,lK.useCallback)(()=>{var e;if(i){let e=i.removeSearch();n({recentSearches:e,type:"RECENT_SEARCHES_SET"})}null==(e=null==o?void 0:o.current)||e.focusInputElement()},[n,i]),d=(0,lY.d2)(),c=(0,lK.useMemo)(()=>d<2?20:40,[d]),u=(0,lK.useCallback)((e,t)=>{let{virtualIndex:n}=t;return(0,lU.jsx)(L_,{index:n,maxVisibleTypePillChars:c,paddingBottom:1,value:e})},[c]),p=!!a.length;return(0,lU.jsx)(LE,{borderTop:p||!p&&!r&&l,flex:1,children:a.length?(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.xu,{paddingBottom:2,paddingTop:4,paddingX:3,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:"Recent searches"})}),(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(uc,{activeItemDataAttr:"data-hovered",ariaLabel:"Recent searches",inputElement:t,initialIndex:0,itemHeight:36,items:a,paddingX:2,paddingY:1,renderItem:u})}),(0,lU.jsx)(lY.xu,{paddingBottom:2,paddingTop:1,paddingX:2,children:(0,lU.jsx)(lY.zx,{fontSize:1,justify:"flex-start",mode:"bleed",onClick:s,padding:2,tone:"default",children:(0,lU.jsx)(lY.xv,{muted:!0,size:1,children:"Clear recent searches"})})})]}):!r&&l&&(0,lU.jsx)(Lp,{})})}var LA=Object.freeze,LO=Object.defineProperty,Lz=(e,t)=>
1LA(LO(e,"raw",{value:LA(t||e.slice())}));let LM=(0,aW.F4)(ly||(ly=Lz(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"]))),LI=(0,aW.ZP)(a0.L4p)(lj||(lj=Lz(["\n animation: "," 500ms linear infinite;\n"])),LM),LR=(0,aW.ZP)(lY.xu)(lw||(lw=Lz(["\n position: relative;\n"]))),LF=aW.ZP.div(lk||(lk=Lz(["\n background: ",";\n border-radius: 100%;\n height: 6px;\n position: absolute;\n right: 2px;\n top: 2px;\n width: 6px;\n"])),e=>{var t;let{theme:n}=e;return null==(t=n.sanity.color.selectable)?void 0:t.primary.enabled.fg}),LD=(0,lK.forwardRef)(function(e,t){let{ariaInputLabel:n,onClose:i}=e,r=(0,lK.useRef)(!1),{dispatch:l,state:{filters:a,filtersVisible:o,fullscreen:s,result:{loading:d},terms:{types:c,query:u}}}=MK(),p=(0,lK.useCallback)(()=>l({type:"FILTERS_VISIBLE_SET",visible:!o}),[l,o]),h=(0,lK.useCallback)(e=>l({type:"TERMS_QUERY_SET",query:e.currentTarget.value}),[l]),f=(0,lK.useCallback)(()=>{l({type:"TERMS_QUERY_SET",query:""})},[l]);(0,lK.useEffect)(()=>{s||l({type:"FILTERS_VISIBLE_SET",visible:!0})},[l,s]),(0,lK.useEffect)(()=>{r.current=!0},[]);let m=a.length>0||c.length>0;return(0,lU.jsx)(lY.Zb,{flex:"none",children:(0,lU.jsxs)(lY.kC,{align:"center",flex:1,gap:s?2:1,padding:s?2:1,children:[s&&(0,lU.jsx)(lY.Zb,{children:(0,lU.jsx)(lY.zx,{"aria-label":"Close search",icon:a0.Y4O,mode:"bleed",onClick:i})}),(0,lU.jsx)(lY.xu,{flex:1,children:(0,lU.jsx)(Rc,{"aria-label":n,autoComplete:"off",background:s,border:!1,clearButton:!!u,fontSize:2,icon:d?LI:a0.W1M,onChange:h,onClear:f,placeholder:"Search",radius:s?2:1,ref:t,smallClearButton:s,spellCheck:!1,value:u})}),s&&(0,lU.jsxs)(LR,{children:[(0,lU.jsx)(lY.zx,{"aria-expanded":o,"aria-label":"Toggle filters",height:"fill",icon:a0.d$S,mode:"bleed",onClick:p,padding:3,selected:o,tone:"default"}),m&&(0,lU.jsx)(LF,{})]})]})})});function LZ(){return(0,lU.jsx)(lY.W2,{width:0,children:(0,lU.jsxs)(lY.Kq,{"aria-live":"assertive",space:4,paddingX:4,paddingY:5,children:[(0,lU.jsx)(lY.xv,{align:"center",muted:!0,weight:"semibold",children:"No results found"}),(0,lU.jsx)(lY.xv,{align:"center",muted:!0,size:1,children:"Try another keyword or adju
1st your filters"})]})})}function LL(){return(0,lU.jsxs)(lY.kC,{align:"center","aria-live":"assertive",direction:"column",flex:1,gap:3,marginY:2,padding:4,children:[(0,lU.jsx)(lY.xu,{marginBottom:1,children:(0,lU.jsx)(pG,{tone:"critical",children:(0,lU.jsx)(a0.foC,{})})}),(0,lU.jsx)(pG,{size:2,tone:"critical",weight:"semibold",children:"Something went wrong while searching"}),(0,lU.jsx)(pG,{size:1,tone:"critical",children:"Please try again or check your connection"})]})}let Lq={createdAsc:{ignoreScore:!0,sort:{direction:"asc",field:"_createdAt"},title:"Created: Oldest first"},createdDesc:{ignoreScore:!0,sort:{direction:"desc",field:"_createdAt"},title:"Created: Newest first"},relevance:{customMeasurementLabel:"relevance",sort:{direction:"desc",field:"_updatedAt"},title:"Best match"},updatedAsc:{ignoreScore:!0,sort:{direction:"asc",field:"_updatedAt"},title:"Updated: Oldest first"},updatedDesc:{ignoreScore:!0,sort:{direction:"desc",field:"_updatedAt"},title:"Updated: Newest first"}};var LN=Object.freeze,LV=Object.defineProperty;let LU=[Lq.relevance,{type:"divider"},Lq.createdAsc,Lq.createdDesc,{type:"divider"},Lq.updatedAsc,Lq.updatedDesc],LB=(0,aW.ZP)(lY.kC)(lC||(lC=LN(LV(ew=["\n box-sizing: border-box;\n"],"raw",{value:LN(ew.slice())}))));function LK(e){return"divider"===e.type}function LH(e){let{ordering:t}=e,{dispatch:n,state:{ordering:i}}=MK(),r=(0,lK.useCallback)(()=>{n({ordering:t,type:"ORDERING_SET"})},[n,t]),l=(0,lK.useMemo)(()=>aU()(i,t),[i,t]);return(0,lU.jsx)(lY.sN,{onClick:r,padding:3,pressed:l,tone:"default",children:(0,lU.jsx)(lY.kC,{align:"center",justify:"space-between",paddingRight:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"medium",children:t.title})})})}function LW(){let{state:{ordering:e}}=MK(),t=(0,lK.useId)(),n=LU.find(t=>aU()(e,t)&&!LK(t));return n?(0,lU.jsx)(lY.Zb,{borderBottom:!0,children:(0,lU.jsx)(LB,{align:"center",flex:1,padding:2,children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{mode:"bleed",padding:2,children:(0,lU.jsxs)(lY.kC,{align:"center",gap:1,justify:"space-between",children:[(0,lU.jsx)(lY.xu,{marginRight:1,children:(0,lU.jsx)(lY.xv,{size:1,children:(0,lU.jsx)(a0.fzI,{})})}),(0,lU.jsx)(lY.gF,{space:2,children:(0,lU.jsx)(lY.xv,{size:1,weight:"medium",children:n.title})})]})}),id:t||"",menu:(0,lU.jsx)(lY.v2,{children:LU.map((e,t)=>LK(e)?(0,lU.jsx)(lY.R,{},t):(0,lU.jsx)(LH,{ordering:e},t))}),placement:"bottom-start",popover:{portal:!0,radius:2}})})}):null}var L$=Object.freeze,LX=Object.defineProperty;let LG=(0,aW.ZP)(lY.Zb)(l_||(l_=L$(LX(ek=["\n cursor: help;\n left: 0;\n position: absolute;\n top: 0;\n"],"raw",{value:L$(ek.slice())}))));function LY(e){let{data:t}=e,{score:n}=t,i="default";n<=.1?i="critical":n>=.5&&(i="primary");let r=t.stories.filter(e=>e.score>0);return(0,lU.jsx)(lU.Fragment,{children:(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.Kq,{space:2,children:r.length?(0,lU.jsx)(lU.Fragment,{children:r.map(e=>(0,lU.jsxs)(lY.gF,{space:3,children:[(0,lU.jsx)(lY.EK,{size:0,weight:"semibold",children:e.path}),(0,lU.jsx)(lY.EK,{size:0,children:e.why})]},e.path))}):(0,lU.jsx)(lY.EK,{size:0,children:"No matches"})})}),placement:"bottom-start",portal:!0,children:(0,lU.jsx)(LG,{padding:1,shadow:1,tone:i,children:(0,lU.jsxs)(lY.EK,{size:0,children:["score: ",n]})})})})}var LJ=Object.freeze,LQ=Object.defineProperty;let L0=(0,aW.ZP)(lY.kC)(lS||(lS=LJ(LQ(eC=["\n opacity: ",";\n overflow-x: hidden;\n overflow-y: auto;\n position: relative;\n transition: 300ms opacity;\n width: 100%;\n"],"raw",{value:LJ(eC.slice())}))),e=>{let{$loading:t}=e;return t?.5:1});function L1(e){let{inputElement:t}=e,{dispatch:n,onClose:i,recentSearchesStore:r,setSearchCommandList:l,state:{debug:a,filters:o,fullscreen:s,lastActiveIndex:d,result:c,terms:u}}=MK(),p=!!c.hits.length,h=!c.hits.length&&c.loaded,f=c.error,m=(0,lK.useCallback)(()=>{if(r){let e=r.addSearch(u,o);n({recentSearches:e,type:"RECENT_SEARCHES_SET"})}null==i||i()},[n,o,i,r,u]),g=(0,lK.useCallback)(e=>(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(M1,{documentId:ci(e.hit._id)||"",documentType:e.hit._type,onClick:m,paddingBottom:2}),a&&(0,lU.jsx)(LY,{data:e})]}),[a,m]);return(0,lU.jsx)(lY.kC,{children:(0,lU.jsx)(lY.Zb,{borderTop:s||!!(f||p||h),flex:1,children:(0,lU.jsxs)(lY.kC,{direction:"column",height:"fill",children:[p&&(0,lU.jsx)(LW,{}),(0,lU.jsx)(L0,{$loading:c.loading,"aria-busy":c.loading,flex:1,children:f?(0,lU.jsx)(LL,{}):(0,lU.jsxs)(lU.Fragment,{children:[p&&(0,lU.jsx)(uc,{activeItemDataAttr:"data-hovered",ariaLabel:"Search results",fixedHeight:!0,initialIndex:d,inputElement:t,itemHeight:59,items:c.hits,overscan:4,padding:2,paddingBottom:0,ref:l,renderItem:g}),h&&(0,lU.jsx)(LZ,{})]})})]})})})}var L2=Object.freeze,L3=Object.defineProperty,L4=(e,t)=>
1L2(L3(e,"raw",{value:L2(t||e.slice())}));let L5=(0,aW.ZP)(lY.Zb)(lT||(lT=L4(["\n flex-direction: column;\n overflow: hidden;\n overflow: clip;\n pointer-events: all;\n position: relative;\n"]))),L6=(0,aW.ZP)(lY.xu)(lE||(lE=L4(["\n height: 100%;\n left: 0;\n overflow: hidden;\n overflow: clip;\n pointer-events: none;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: 1;\n"])));function L8(e){let{onClose:t,onOpen:n,open:i}=e,[r,l]=(0,lK.useState)(null),{scheme:a}=Ff(),{state:{filtersVisible:o,terms:s}}=MK(),d=M5({terms:s});return(0,lU.jsx)(Zc,{hasValidTerms:d,onClose:t,onOpen:n,open:i,children:(0,lU.jsx)(lY.h_,{children:(0,lU.jsx)(a2.ZP,{autoFocus:!ck,returnFocus:!0,children:(0,lU.jsx)(L6,{children:(0,lU.jsxs)(L5,{display:"flex",height:"fill",scheme:a,tone:"default",children:[(0,lU.jsx)(LD,{ariaInputLabel:d?"Search results":"Recent searches",onClose:t,ref:l}),o&&(0,lU.jsx)(lY.Zb,{borderTop:!0,flex:"none",children:(0,lU.jsx)(Lu,{})}),d?(0,lU.jsx)(L1,{inputElement:r}):(0,lU.jsx)(LP,{inputElement:r})]})})})})})}var L9=Object.freeze,L7=Object.defineProperty,qe=(e,t)=>L9(L7(e,"raw",{value:L9(t||e.slice())}));let qt=(0,aW.ZP)(lY.kC)(lP||(lP=qe(["\n position: absolute;\n right: 0;\n top: 0;\n\n & > :first-child {\n margin-right: 1px;\n }\n"]))),qn=(0,aW.ZP)(lY.kC)(lA||(lA=qe(["\n min-width: 253px;\n max-width: 350px;\n position: relative;\n"]))),qi=(0,aW.ZP)(lY.oi)(lO||(lO=qe(["\n padding-right: 60px;\n"]))),qr=(0,lK.forwardRef)(function(e,t){let{onOpen:n}=e,{dispatch:i,state:{terms:r}}=MK(),l=(0,lK.useCallback)(e=>{i({type:"TERMS_QUERY_SET",query:e.currentTarget.value}),n()},[i,n]),a=(0,lK.useCallback)(e=>{"Enter"===e.key&&n()},[n]);return(0,lU.jsxs)(qn,{align:"center",children:[(0,lU.jsx)(qi,{"aria-autocomplete":"list","aria-expanded":"false",autoComplete:"off",icon:a0.W1M,"data-testid":"studio-search",onChange:l,onClick:n,onKeyDown:a,placeholder:"Search",radius:2,ref:t,role:"combobox",value:r.query}),(0,lU.jsxs)(qt,{align:"center",height:"fill",marginRight:2,children:[(0,lU.jsx)(lY.WB,{children:M3}),(0,lU.jsx)(lY.WB,{children:"K"})]})]})});var ql=Object.freeze,qa=Object.defineProperty,qo=(e,t)=>ql(qa(e,"raw",{value:ql(t||e.slice())}));let qs=aW.ZP.div(lz||(lz=qo(["\n background-color: ",";\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n"])),e=>{let{theme:t}=e;return t.sanity.color.base.shadow.ambient}),qd=(0,aW.ZP)(lY.Zb)(lR||(lR=qo(["\n ","\n display: flex !important;\n flex-direction: column;\n max-height: ",";\n position: absolute;\n top: ","px;\n width: min(calc(100vw - ","px), ","px);\n"])),e=>{let{$position:t}=e;return t.x?(0,aW.iv)(lM||(lM=qo(["\n left: ","px;\n "])),t.x):(0,aW.iv)(lI||(lI=qo(["\n left: 50%;\n transform: translateX(-50%);\n "])))},e=>{let{$position:t}=e;return"min(calc(100vh - ".concat(t.y,"px - ").concat(M4,"px), ").concat(735,"px)")},e=>{let{$position:t}=e;return t.y},2*M4,800);function qc(e){let{disableFocusLock:t,onClose:n,onOpen:i,open:r,position:l}=e,[a,o]=(0,lK.useState)(null),[s,d]=(0,lK.useState)(null),{isTopLayer:c,zIndex:u}=(0,lY.sJ)(),{scheme:p}=Ff(),{onClose:h,state:{filtersVisible:f,terms:m}}=MK(),g=M5({terms:m}),x=(0,lK.useCallback)(()=>{c&&h&&r&&h()},[c,h,r]);return(0,lY.O8)(x,[a]),(0,lU.jsx)(Zc,{hasValidTerms:g,onClose:n,onOpen:i,open:r,children:(0,lU.jsx)(lY.h_,{children:(0,lU.jsxs)(a2.ZP,{autoFocus:!ck,disabled:t,returnFocus:!0,children:[(0,lU.jsx)(qs,{style:{zIndex:u}}),(0,lU.jsxs)(qd,{$position:l,overflow:"hidden",radius:2,ref:o,scheme:p,shadow:2,style:{zIndex:u},children:[(0,lU.jsx)(LD,{ariaInputLabel:g?"Search results":"Recent searches",onClose:n,ref:d}),f&&(0,lU.jsx)(lY.Zb,{borderTop:!0,flex:"none",children:(0,lU.jsx)(Lu,{})}),g?(0,lU.jsx)(L1,{inputElement:s}):(0,lU.jsx)(LP,{inputElement:s})]})]})})})}function qu(){let[e,t]=(0,lK.useState)(null),[n,i]=(0,lK.useState)(!1),r=(0,lK.useCallback)(()=>i(!1),[]),l=(0,lK.useCallback)(()=>i(!0),[]),a=function(e){let[t,n]=(0,lK.useState)(null),i=(0,lK.useCallback)(()=>{e&&n(qp(e))},[e]);return(0,lK.useEffect)(()=>{e&&n(qp(e))},[e]),(0,lK.useEffect)(()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]),t}(e);return(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(qr,{onOpen:l,ref:t}),a&&(0,lU.jsx)(qc,{onClose:r,onOpen:l,open:n,position:a})]})}function qp(e){let t=e.getBoundingClientRect();return{x:window.innerWidth-t.x>800?t.x-M4:null,y:t.y-M4}}function qh(e,t){let n=qm?window.localStorage.getItem(e):void 0;return n?JSON.parse(n):{version:t,recentSearches:[]}}function qf(e){let{lsKey:t,schema:n,fieldDefinitions:i,filterDefinitions:r,operatorDefinitions:l,version:a}=e,o=function(e){let{lsKey:t,storedSearch:n}=e;if(2!==n.version){let e={version:2,recentSearches:[]};return window.localStorage.setItem(t,JSON.stringify(e)),e}return n}({lsKey:t,storedSearch:qh(t,a)});return(function(e){let{fieldDefinitions:t,filterDefinitions:n,lsKey:i,operatorDefinitions:r,storedSearch:l,studioSchema:a,version:o}=e,s=M6(a).map(e=>e.name),d=l.recentSearches.filter(e=>e.terms.typeNames.every(e=>s.includes(e))&&e.filters.every(e=>Zx({fieldDefinitions:t,filter:e,filterDefinitions:n,operatorDefinitions:r}))),c={version:2,recentSearches:d};return c.recentSearches.length<l.recentSearches.length&&window.localStorage.setItem(i,JSON.stringify(c)),qh(i,o)})({studioSchema:n,storedSearch:o,lsKey:t,filterDefinitions:r,fieldDefinitions:i,operatorDefinitions:l,version:a}).recentSearches.filter(e=>!!e.terms).map((e,t)=>({__recent:{index:t,timestamp:new Date(e.created).getTime()},filters:e.filters,query:e.terms.query,types:e.terms.typeNames.map(e=>n.get(e)).filter(e=>!!(e&&"object"===e.jsonType))}))}let qm=(()=>{let e="__tmp__can_use";try{if("undefined"==typeof localStorage)return!1;return localStorage.setItem(e,"---"),localStorage.removeItem(e),!0}catch(e){return!1}})();function qg(e){return{...e,id:[e.type,e.fieldPath,e.filterName,e.documentTypes.join(",")].join("-")}}function qx(e){return"array"===e.type}function qv(e){return"document"===e.type}function qb(e){return"object"===e.type}
1function qy(e,t){let n=e.titlePath.slice(0,-1).join("/"),i=t.titlePath.slice(0,-1).join("/");return e.title.localeCompare(t.title)||n.localeCompare(i)||e.fieldPath.localeCompare(t.fieldPath)}function qj(e){return void 0!==e.__recent}let qw="core:studio:navbar:search:";sU()(qw);let qk=function(e){let t="".concat(qw).concat(e);return sU()&&sU().enabled(t)?sU()(t):sU()(qw)}("reducer");function qC(e,t){let n="\uD83D\uDD0D";switch(t.type.startsWith("SEARCH_REQUEST")&&(n="\uD83D\uDEA8"),t.type.startsWith("RECENT_SEARCHES")&&(n="\uD83D\uDCBE"),qk(n,t),t.type){case"FILTERS_VISIBLE_SET":return{...e,filtersVisible:t.visible};case"LAST_ACTIVE_INDEX_SET":return{...e,lastActiveIndex:t.index};case"ORDERING_RESET":return{...e,ordering:Lq.relevance,terms:q_(e.terms)};case"ORDERING_SET":return{...e,ordering:t.ordering,terms:q_(e.terms)};case"PAGE_INCREMENT":return{...e,pageIndex:e.pageIndex+1,terms:q_(e.terms)};case"RECENT_SEARCHES_SET":return{...e,recentSearches:t.recentSearches};case"SEARCH_CLEAR":return{...e,pageIndex:0,result:{...e.result,hasMore:null,hits:[]}};case"SEARCH_REQUEST_COMPLETE":return{...e,result:{...e.result,error:null,hasMore:t.hits.length>0,hits:e.pageIndex>0?[...e.result.hits,...t.hits]:t.hits,loaded:!0,loading:!1}};case"SEARCH_REQUEST_ERROR":return{...e,result:{...e.result,error:t.error,loaded:!1,loading:!1}};case"SEARCH_REQUEST_START":return{...e,result:{...e.result,loaded:!1,loading:!0}};case"TERMS_FILTERS_ADD":{var i;let n={...t.filter,value:null==(i=Zu(e.definitions.operators,t.filter.operatorType))?void 0:i.initialValue},r=[...e.filters,n];return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:r,types:e.terms.types}),filters:r,lastAddedFilter:n,terms:{...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:r,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_CLEAR":{let t=[];return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:t,types:e.terms.types}),filters:t,terms:{...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:t,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_REMOVE":{let n=e.filters.findIndex(e=>Zm(e)===t.filterKey),i=[...e.filters.slice(0,n),...e.filters.slice(n+1)];return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:i,types:e.terms.types}),filters:i,terms:{...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:i,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_SET_OPERATOR":{let n=e.filters.find(e=>Zm(e)===t.filterKey),i=Zu(e.definitions.operators,null==n?void 0:n.operatorType),r=Zu(e.definitions.operators,t.operatorType),l=null==r?void 0:r.initialValue,a=(null==i?void 0:i.inputComponent)!=(null==r?void 0:r.inputComponent),o=e.filters.map(e=>Zm(e)===t.filterKey?{...e,operatorType:t.operatorType,...a?{value:l}:{}}:e);return{...e,filters:o,terms:{...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:o,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_SET_VALUE":{let n=e.filters.map(e=>Zm(e)===t.filterKey?{...e,value:t.value}:e);return{...e,filters:n,terms:{...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:n,operatorDefinitions:e.definitions.operators})}}}case"TERMS_QUERY_SET":return{...e,pageIndex:0,result:{...e.result,loaded:!1},terms:q_({...e.terms,query:t.query})};case"TERMS_SET":{let n=t.filters||[],i=[...e.terms.types||[],...t.terms.types].sort(M8);return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:n,types:i}),filters:n,lastAddedFilter:null,pageIndex:0,result:{...e.result,loaded:!1},terms:{...t.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:n,operatorDefinitions:e.definitions.operators})}}}case"TERMS_TYPE_ADD":{let n=[...e.terms.types||[],t.schemaType].sort(M8),i=Zg({fieldDefinitions:e.definitions.fields,filters:[],types:n}),r=e.filters.filter(t=>{let n=Zf(e.definitions.fields,t);return!n||0===n.documentTypes.length||i.every(e=>n.documentTypes.findIndex(t=>t===e)>-1)});return{...e,documentTypesNarrowed:i,filters:r,pageIndex:0,result:{...e.result,loaded:!1},terms:q_({...e.terms,filter:Zh({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,operatorDefinitions:e.definitions.operators,filters:r}),types:n})}}case"TERMS_TYPE_REMOVE":{let n=(e.terms.types||[]).filter(e=>e!==t.schemaType);return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:e.filters,types:n}),pageIndex:0,result:{...e.result,loaded:!1},terms:q_({...e.terms,types:n})}}case"TERMS_TYPES_CLEAR":return{...e,documentTypesNarrowed:Zg({fieldDefinitions:e.definitions.fields,filters:e.filters,types:[]}),pageIndex:0,result:{...e.result,loaded:!1},terms:q_({...e.terms,types:[]})};default:return e}}function q_(e){if(qj(e)){let{__recent:t,...n}=e;return n}return e}function qS(e){let{children:t,fullscreen:n}=e,i=(0,lK.useRef)(null),[r,l]=(0,lK.useState)(null),a=Ni(fC),o=Nu(),s=Nj(),{search:{operators:d,filters:c}}=Iw(),{dataset:u,projectId:p}=a.config(),{fieldDefinitions:h,filterDefinitions:f,operatorDefinitions:m}=(0,lK.useMemo)(()=>({fieldDefinitions:(function(e,t){var n;let i=M6(e).map(e=>e.name),{documentTypes:r,objectTypes:l}=((null==(n=e._original)?void 0:n.types)||[]).filter(e=>!qv(e)||i.includes(e.name)).filter(e=>"slug"!==e.name).filter(e=>!e.name.startsWith("sanity.")).reduce((e,t)=>
1(qv(t)&&(e.documentTypes[t.name]=t),qb(t)&&(e.objectTypes[t.name]=t),e),{documentTypes:{},objectTypes:{}})||{documentTypes:{},objectTypes:{}},a=t.reduce((e,t)=>("field"===t.type&&e.push(t.fieldType),e),[]);return function(e,t,n){let i=Object.values(t).reduce((i,r)=>{let l=r.fields.reduce((i,l)=>(!function i(r){var l;let{acc:a,defType:o,depth:s=0,documentType:d,prevFieldPath:c,prevTitlePath:u}=r,p=o.name.startsWith("_"),h=(null==o?void 0:o.title)?ZD(o.title):ol()(o.name),f=c?"".concat(c,".").concat(o.name):o.name,m=u?[...u,h]:[h];if(!(s<=3))return;let g=n[o.type],x=t[o.type],v=qb(o)?o:null,b=x||g||v;if(b){null==(l=null==b?void 0:b.fields)||l.forEach(e=>i({acc:a,defType:e,depth:s+1,documentType:d,prevFieldPath:f,prevTitlePath:m}));return}e.includes(o.type)&&a.push({documentTypes:d&&!p?[d]:[],fieldPath:f,filterName:function(e){var t,n;if("string"===e.type&&null!=(t=e.options)&&t.list&&e.options.list.length>0)return"stringList";if(qx(e)){if(e.of.some(e=>"reference"===e.type))return"arrayReferences";if(e.of.find(e=>"block"===e.type))return"portableText";if(qx(e)&&e.of.every(e=>["boolean","number","string"].includes(e.type))&&null!=(n=e.options)&&n.list&&e.options.list.length>0)return"arrayList"}return e.type}(o),id:"",name:o.name,titlePath:m,title:h,type:o.type})}({acc:i,defType:l,documentType:r.name}),i),[]);return i.push(...l),i},[]).reduce((e,t)=>{let n=e.findIndex(e=>e.fieldPath===t.fieldPath&&e.title===t.title&&e.type===t.type);return n>-1?e[n]={...e[n],documentTypes:[...e[n].documentTypes,...t.documentTypes]}:e.push(t),e},[]).map(qg).sort(qy);return i}(a,r,l)})(o,c).reduce((e,t)=>(e[t.id]=t,e),{}),filterDefinitions:c.reduce((e,t)=>(e[t.name]=t,e),{}),operatorDefinitions:d.reduce((e,t)=>(e[t.type]=t,e),{})}),[c,d,o]),g=(0,lK.useMemo)(()=>(function(e){let{dataset:t,fieldDefinitions:n,filterDefinitions:i,operatorDefinitions:r,projectId:l,schema:a,user:o,version:s=2}=e;if(!t||!l||!qm||!o)return;let d="".concat("search::recent","__").concat(l,":").concat(t,":").concat(o.id);return{addSearch:(e,t)=>{let l=(t||[]).map(e=>({fieldId:e.fieldId,filterName:e.filterName,operatorType:e.operatorType,value:e.value})),o=l.filter(e=>Zx({fieldDefinitions:n,filter:e,filterDefinitions:i,operatorDefinitions:r})),c={created:new Date().toISOString(),filters:o,terms:{query:e.query.trim(),typeNames:e.types.map(e=>e.name)}},u=JSON.stringify(sm()(c,"created")),p={version:s,recentSearches:[c,...qh(d,s).recentSearches.filter(e=>JSON.stringify(sm()(e,"created"))!==u)].slice(0,5)};return window.localStorage.setItem(d,JSON.stringify(p)),qf({fieldDefinitions:n,filterDefinitions:i,lsKey:d,operatorDefinitions:r,schema:a,version:s})},getRecentSearches:()=>qf({fieldDefinitions:n,filterDefinitions:i,lsKey:d,operatorDefinitions:r,schema:a,version:s}),removeSearch:()=>{let e=qh(d,s),t={...e,recentSearches:[]};return window.localStorage.setItem(d,JSON.stringify(t)),qf({fieldDefinitions:n,filterDefinitions:i,lsKey:d,operatorDefinitions:r,schema:a,version:s})},removeSearchAtIndex:e=>{let t=qh(d,s);if(e<0||e>t.recentSearches.length)return qf({fieldDefinitions:n,filterDefinitions:i,lsKey:d,operatorDefinitions:r,schema:a,version:s});let l={...t,recentSearches:[...t.recentSearches.slice(0,e),...t.recentSearches.slice(e+1)]};return window.localStorage.setItem(d,JSON.stringify(l)),qf({fieldDefinitions:n,filterDefinitions:i,lsKey:d,operatorDefinitions:r,schema:a,version:s})}}})({dataset:u,fieldDefinitions:h,filterDefinitions:f,operatorDefinitions:m,projectId:p,schema:o,user:s,version:2}),[s,u,h,f,m,p,o]),x=(0,lK.useMemo)(()=>null==g?void 0:g.getRecentSearches(),[g]),v=(0,lK.useMemo)(()=>(function(e){let{currentUser:t,fullscreen:n,recentSearches:i=[],definitions:r}=e;return{currentUser:t,debug:"undefined"!=typeof window&&window.location.hash.slice(1).split(";").includes("_debug_search_score"),documentTypesNarrowed:[],filters:[],filtersVisible:!0,fullscreen:n,lastActiveIndex:-1,ordering:Lq.relevance,pageIndex:0,recentSearches:i,result:{error:null,hasMore:null,hits:[],loaded:!1,loading:!1},terms:{query:"",types:[]},definitions:r}})({currentUser:s,fullscreen:n,recentSearches:x,definitions:{fields:h,operators:m,filters:f}}),[s,h,f,n,m,x]),[b,y]=(0,lK.useReducer)(qC,v),{documentTypesNarrowed:j,filters:w,ordering:k,pageIndex:C,result:_,terms:S}=b,T=(0,lK.useRef)(!1),E=(0,lK.useRef)(v.ordering),P=(0,lK.useRef)(v.pageIndex),A=(0,lK.useRef)(v.terms),{handleSearch:O,searchState:z}=It({initialState:{..._,terms:S},onComplete:e=>y({hits:e,type:"SEARCH_REQUEST_COMPLETE"}),onError:e=>y({error:e,type:"SEARCH_REQUEST_ERROR"}),onStart:()=>y({type:"SEARCH_REQUEST_START"}),schema:o}),M=M5({terms:S}),I=j.map(e=>o.get(e)),R=w.filter(e=>Zx({fieldDefinitions:h,filter:e,filterDefinitions:f,operatorDefinitions:m})),F=(0,lK.useCallback)(e=>{i.current=e},[]);return(0,lK.useEffect)(()=>{let e=!aU()(k,E.current),t=C!==P.current,n=!aU()(S,A.current);if(e||t||n){let e=(null==k?void 0:k.customMeasurementLabel)||"".concat(k.sort.field," ").concat(k.sort.direction);O({options:{comments:[...qj(S)?["findability-recent-search:".concat(S.__recent.index)]:[],"findability-selected-types:".concat(S.types.length),"findability-sort:".concat(e),"findability-source: global","findability-filter-count:".concat(R.length)],limit:1e3,offset:1e3*C,skipSortByScore:k.ignoreScore,sort:[k.sort]},terms:{...S,...I?{types:I}:{}}}),P.current=C}E.current=k,A.current=S},[R.length,w,I,O,M,k,C,z.terms,S]),(0,lK.useEffect)(()=>{!M&&(null==T?void 0:T.current)&&_.hits.length>0&&y({type:"SEARCH_CLEAR"}),T.current=!0},[y,M,_.hits,S.query,S.types]),(0,lU.jsx)(MB.Provider,{value:{dispatch:y,onClose:null==i?void 0:i.current,recentSearchesStore:g,searchCommandList:r,setSearchCommandList:l,setOnClose:F,state:{...b,fullscreen:n}},children:t})}let qT="3.15.1";function qE(e){var t;let{error:n,isLoading:i,value:r}=e,l=null==(t=null==r?void 0:r.resources)?void 0:t.sectionArray,a=null==r?void 0:r.latestVersion;return i?(0,lU.jsx)(lY.kC,{align:"center",justify:"center",padding:3,children:(0,lU.jsx)(lY.$j,{})}):(0,lU.jsxs)(lU.Fragment,{children:[(void 0===r||n)&&(0,lU.jsx)("div",{children:qP}),!n&&(null==l?void 0:l.map(e=>e?(0,lU.jsx)(qA,{subSection:e},e._key):null)),(0,lU.jsxs)(lY.xu,{padding:3,children:[(0,lU.jsxs)(lY.xv,{size:1,muted:!0,weight:"medium",textOverflow:"ellipsis",children:["Sanity Studio version ",qT]}),!n&&a&&(0,lU.jsx)(lY.xu,{paddingTop:2,children:(0,lU.jsxs)(lY.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:["Latest version is ",a]})})]})]})}let qP=(0,lU.jsxs)(lU.Fragment,{children:[(0,lU.jsx)(lY.sN,{as:"a",text:"Join our community",size:0,href:"https://www.sanity.io/exchange/community",target:"_blank",muted:!1}),(0,lU.jsx)(lY.sN,{as:"a",text:"Help and support",size:0,href:"https://www.sanity.io/contact/support",target:"_blank",muted:!1}),(0,lU.jsx)(lY.sN,{as:"a",text:"Contact sales",size:0,href:"https://www.sanity.io/contact/sales?ref=studio",target:"_blank",muted:!1}),(0,lU.jsx)(lY.R,{})]});function qA(e){var t;let{subSection:n}=e;return(0,lU.jsxs)(lU.Fragment,{children:[n.sectionTitle&&(0,lU.jsx)(lY.Zb,{padding:2,paddingTop:3,marginLeft:1,children:(0,lU.jsx)(lY.__,{muted:!0,size:1,children:n.sectionTitle})}),null==(t=null==n?void 0:n.items)?void 0:t.map(e=>{if(!e||!e.title)return null;switch(e._type){case"externalLink":if(!e.url)return null;return(0,lU.jsx)(lY.sN,{as:"a",tone:"default",text:e.title,size:0,href:e.url,target:"_blank"},e._key);case"internalAction":if(!e.type)return null;return"show-welcome-modal"===e.type&&(0,lU.jsx)(lY.sN,{text:e.title,size:0},e._key);default:return null}}),(0,lU.jsx)(lY.R,{})]})}var qO=Object.freeze,qz=Object.defineProperty;let qM=(0,aW.ZP)(lY.v2)(lF||(lF=qO(qz(e_=["\n max-width: 300px;\n min-width: 200px;\n"],"raw",{value:qO(e_.slice())}))));function qI(){let{scheme:e}=Ff(),{value:t,error:n,isLoading:i}=function(){let e=Ni({apiVersion:"1"}),t=(0,lK.useMemo)(()=>(function(e){let t=e.withConfig({apiVersion:"1"}).observable.request({url:"/help",query:{m:["sanity@".concat(qT)]},tag:"module.version-check",json:!0}).pipe((0,ad.U)(e=>({...e})));return t})(e),[e]);return c_(t)}();return(0,lU.jsx)(lY.kC,{children:(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:"Help and resources "})}),scheme:e,placement:"bottom",portal:!0,children:(0,lU.jsx)("div",{children:(0,lU.jsx)(lY.j2,{button:(0,lU.jsx)(lY.zx,{"aria-label":"Help and resources",icon:a0.BHU,mode:"bleed",fontSize:2}),id:"menu-button-resources",menu:(0,lU.jsx)(qM,{children:(0,lU.jsx)(qE,{error:n,isLoading:i,value:t})}),popover:{constrainSize:!0,placement:"bottom",portal:!0,scheme:e}})})})})}var qR=Object.freeze,qF=Object.defineProperty,qD=(e,t)=>qR(qF(e,"raw",{value:qR(t||e.slice())}));let qZ=(0,aW.ZP)(lY.mh)(lD||(lD=qD(["\n min-height: auto;\n position: relative;\n\n &[data-search-open='true'] {\n top: 0;\n position: sticky;\n }\n"]))),qL=(0,aW.ZP)(lY.Zb)(lZ||(lZ=qD(["\n line-height: 0;\n"]))),qq=(0,aW.ZP)(lY.kC)(lL||(lL=qD(["\n width: max-content;\n"])));function qN(){let{name:e,tools:t,...n}=Ib(),i=(0,lY.Ur)().theme,r=Fy(),l=(0,a1.z)(),{scheme:a}=Ff(),{href:o,onClick:s}=(0,a1.rJ)({state:{}}),d=(0,lY.d2)(),c="string"==typeof l.tool?l.tool:void 0,u=function(){let{__internal:{staticInitialValueTemplateItems:e}}=Iw(),[t,n]=VR({templateItems:e}),i=(null==t?void 0:t.some(t=>e.some(e=>e.id===t.id)))||!1,r=(0,lK.useMemo)(()=>e.map(e=>{var n;return{...e,title:(null==e?void 0:e.title)||e.id,hasPermission:(null==(n=null==t?void 0:t.find(t=>
1t.id===e.id))?void 0:n.granted)||!1}}),[t,e]);return{canCreateDocument:i,loading:n,options:r}}(),{onSearchFullscreenOpenChange:p,searchFullscreenOpen:h,searchFullscreenPortalEl:f}=(0,lK.useContext)(Dc),m=fz({defaultComponent:Ft,pick:qX}),g=qG(),[x,v]=(0,lK.useState)(!1),b=(0,lK.useRef)(l),y=(0,lK.useRef)(e);(0,lK.useEffect)(()=>{(b.current.tool!==l.tool||e!==y.current)&&v(!1),b.current=l,y.current=e},[e,l]);let[j,w]=(0,lK.useState)(null),[k,C]=(0,lK.useState)(null),_=(0,lK.useMemo)(()=>({brandingCenter:d<=1,resources:d>1,collapsedPresenceMenu:d<=1,loginStatus:d>1,searchFullscreen:d<=1,configIssues:d>1&&be,workspaces:d>=3&&r.length>1,tools:d>=3}),[d,r.length]),S="string"==typeof e&&"root"!==e?ol()(e):null,T=n.title||S||"Studio";(0,lK.useEffect)(()=>{p(h)},[h,p]),(0,lK.useEffect)(()=>{p&&!_.searchFullscreen&&p(!1)},[p,_.searchFullscreen]);let E=(0,lK.useCallback)(()=>{p(!0)},[p]),P=(0,lK.useCallback)(()=>{p(!1),null==k||k.focus()},[p,k]),A=(0,lK.useCallback)(()=>{v(!1),null==j||j.focus()},[j]),O=(0,lK.useCallback)(()=>{v(!0)},[]);return(0,lU.jsxs)(qZ,{zOffset:100,"data-search-open":h,children:[(0,lU.jsx)(qL,{"data-testid":"navbar","data-ui":"Navbar",padding:2,scheme:"dark",shadow:i.__legacy||"dark"===a?1:void 0,sizing:"border",children:(0,lU.jsxs)(lY.kC,{align:"center",justify:"space-between",children:[(0,lU.jsxs)(qq,{align:"center",flex:_.brandingCenter?void 0:1,children:[!_.tools&&(0,lU.jsx)(lY.xu,{marginRight:1,children:(0,lU.jsx)(lY.zx,{mode:"bleed",icon:a0.Oqj,onClick:O,ref:w})}),!_.brandingCenter&&(0,lU.jsx)(lY.xu,{marginRight:1,children:(0,lU.jsx)(Zo,{href:o,onClick:s,title:T,children:(0,lU.jsx)(m,{title:T})})}),_.workspaces&&(0,lU.jsx)(lY.xu,{marginRight:2,children:(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:"Select workspace"})}),placement:"bottom",portal:!0,scheme:a,children:(0,lU.jsx)(lY.xu,{children:(0,lU.jsx)(F9,{})})})}),(0,lU.jsx)(lY.xu,{marginRight:_.brandingCenter?void 0:2,children:(0,lU.jsx)(DW,{...u,modal:_.brandingCenter?"dialog":"popover"})}),(0,lU.jsx)(lY.li,{children:(0,lU.jsx)(qS,{fullscreen:_.searchFullscreen,children:(0,lU.jsxs)(lY.NM,{element:document.body,children:[(0,lU.jsx)(lY.Xp,{element:f,children:_.searchFullscreen&&(0,lU.jsx)(L8,{onClose:P,onOpen:E,open:h})}),!_.searchFullscreen&&(0,lU.jsx)(qu,{})]})})}),_.tools&&(0,lU.jsx)(lY.Zb,{flex:1,marginX:2,overflow:"visible",paddingRight:1,children:(0,lU.jsx)(g,{activeToolName:c,closeSidebar:A,context:"topbar",isSidebarOpen:!1,tools:t})})]}),_.brandingCenter&&(0,lU.jsx)(lY.xu,{marginX:1,children:(0,lU.jsx)(Zo,{href:o,onClick:s,title:T,children:(0,lU.jsx)(m,{title:T})})}),(0,lU.jsxs)(lY.kC,{gap:2,children:[(_.configIssues||_.resources)&&(0,lU.jsx)(lY.Zb,{borderRight:!0,children:(0,lU.jsxs)(lY.kC,{gap:1,paddingX:2,children:[_.configIssues&&(0,lU.jsx)(Za,{}),_.resources&&(0,lU.jsx)(qI,{})]})}),(0,lU.jsxs)(lY.kC,{align:"center",gap:1,children:[(0,lU.jsx)(D4,{collapse:_.collapsedPresenceMenu}),_.tools&&(0,lU.jsx)(DS,{}),_.searchFullscreen&&(0,lU.jsx)(lY.zx,{"aria-label":"Open search",icon:a0.W1M,mode:"bleed",onClick:E,ref:C})]})]})]})}),!_.tools&&(0,lU.jsx)(Zl,{activeToolName:c,isOpen:x,onClose:A,tools:t})]})}let qV=(0,lK.forwardRef)(function(e,t){let{name:n,...i}=e,r=(0,a1.z)((0,lK.useCallback)(e=>({...e,tool:n,[n]:void 0}),[n]));return(0,lU.jsx)(a1.Px,{state:r,...i,ref:t})});function qU(e){let{activeToolName:t,tools:n}=e,{scheme:i}=Ff(),[r,l]=(0,lK.useState)(null);pV({rootElement:r,navigation:["arrows"]});let a=(0,lK.useMemo)(()=>({popover:{constrainSize:!0,portal:!0,scheme:i}}),[i]),o=(0,lK.useMemo)(()=>n.map((e,n)=>{let r=(null==e?void 0:e.title)||ol()(e.name)||void 0,l=(0,lK.forwardRef)(function(t,n){return(0,lU.jsx)(qV,{...t,ref:n,name:e.name})});return(0,lU.jsx)(PZ,{as:l,"data-as":"a",collapsedProps:{tooltipText:e.title},icon:e.icon||a0.Tzq,mode:"bleed",selected:t===e.name,text:r,tooltipProps:{scheme:i}},"".concat(e.name,"-").concat(n))}),[t,i,n]);return(0,lU.jsx)(PD,{"data-testid":"tool-collapse-menu",gap:1,menuButtonProps:a,ref:l,children:o})}function qB(e){let{activeToolName:t,isVisible:n,tools:i}=e;return(0,lK.useMemo)(()=>(0,lU.jsx)(lY.Kq,{as:"ul",space:1,children:i.map(e=>{let i=(null==e?void 0:e.title)||ol()(e.name)||void 0,r=(0,lK.forwardRef)(function(t,n){return(0,lU.jsx)(qV,{...t,ref:n,name:e.name})});return(0,lU.jsx)(lY.Kq,{as:"li",children:(0,lU.jsx)(lY.zx,{as:r,icon:e.icon||a0.BWR,justify:"flex-start",mode:"bleed",selected:t===e.name,tabIndex:n?0:-1,text:i})},e.name)})}),[t,n,i])}
1function qK(e){let{context:t,isSidebarOpen:n,...i}=e;return"sidebar"===t?(0,lU.jsx)(qB,{isVisible:n,...i}):(0,lU.jsx)(qU,{...i})}function qH(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.toolMenu}function qW(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.navbar}function q$(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.layout}function qX(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.logo}function qG(){return fz({defaultComponent:qK,pick:qH})}let qY=cs.__sanityErrorChannel;function qJ(){let{push:e}=(0,lY.pm)();return(0,lK.useEffect)(()=>{if(qY)return qY.subscribe(t=>{var n;!(!t.error||(n=t.error)instanceof R3||n instanceof p9||n instanceof R2)&&(console.error(t.error),e({id:t.error.message,closable:!0,description:t.error.message,duration:5e3,title:"Uncaught error",status:"error"}))})},[e]),null}function qQ(e){let{children:t,AuthenticateComponent:n=F7,LoadingComponent:i=FP,NotAuthenticatedComponent:r=Dt}=e,[l,a]=(0,lK.useState)(null);if(l)throw l;let[o,s]=(0,lK.useState)("loading"),{activeWorkspace:d}=FK();return((0,lK.useEffect)(()=>{var e,t;null==(t=(e=d.auth).handleCallbackUrl)||t.call(e).catch(a)},[d.auth]),(0,lK.useEffect)(()=>{let e=d.auth.state.subscribe({next:e=>{var t;let{authenticated:n,currentUser:i}=e;if((null==(t=null==i?void 0:i.roles)?void 0:t.length)===0){s("unauthorized");return}s(n?"logged-in":"logged-out")},error:a});return()=>{e.unsubscribe()}},[d]),"loading"===o)?(0,lU.jsx)(i,{}):"unauthorized"===o?(0,lU.jsx)(r,{}):"logged-out"===o?(0,lU.jsx)(n,{}):(0,lU.jsx)(lU.Fragment,{children:t})}function q0(e){let{children:t}=e,n=FK().activeWorkspace.theme;if(n.__legacy){let e=n.__dark?"dark":"light";return(0,lU.jsx)(Fi.Provider,{value:!1,children:(0,lU.jsx)(Fn.Provider,{value:e,children:(0,lU.jsx)(lY.f6,{scheme:e,theme:n,tone:"transparent",children:(0,lU.jsx)(lY.li,{children:t})})})})}return(0,lU.jsx)(lY.f6,{theme:n,tone:"transparent",children:(0,lU.jsx)(lY.li,{children:t})})}let q1={toast:[100,11e3]};var q2=Object.freeze,q3=Object.defineProperty,q4=(e,t)=>q2(q3(e,"raw",{value:q2(t||e.slice())}));function q5(e){let t={}.toolSwitcher||{},n=t.order||[],i=t.hidden||[];if(!n.length&&!i.length)return e;let r=e.reduce((e,t)=>{let i=t.title||"<unknown>";if(!t.name)return console.warn('Tool "'.concat(i,'" does not have the required "name" property')),e;if(e[t.name]){let n=e[t.name].tool.title;return console.warn('Tools with duplicate name "'.concat(t.name,'" found ("').concat(i,'" and "').concat(n,'")')),e}let r=n.indexOf(t.name);return e[t.name]={tool:t,index:-1===r?1/0:r},e},{}),l=e.filter(e=>-1===i.indexOf(e.name));return l.sort((e,t)=>{let n=r[e.name],i=r[t.name],l=n?n.index:1/0,a=i?i.index:1/0;return l===a?0:l-a}),l}function q6(e){let{children:t,LoadingComponent:n,workspace:i}=e,{basePath:r,tools:l}=i,a=function(){let e=(0,lK.useContext)(Fq);if(!e)throw Error("Could not find `RouterHistoryProvider` context");return e}(),o=(0,lK.useMemo)(()=>(function(e){let{basePath:t="/",tools:n}=e,i=a1.BC.create("/:tool",e=>{let t=n.find(t=>t.name===e.tool);return t?a1.BC.scope(t.name,"/",t.router):a1.BC.create("/")});return a1.BC.create(t,[a1.BC.intents("/intent"),i])})({basePath:r,tools:l}),[r,l]),[s,d]=function(e,t,n){var i;let r=(0,lK.useMemo)(()=>{let n=t.getBasePath(),i=RegExp("^".concat(dz()(n),"(\\/|$)"),"i"),r=e=>"/"===n||i.test(e);return{subscribe:t=>e.listen(t),getSnapshot:()=>e.location.pathname,getServerSnapshot:()=>null,selector:e=>"string"==typeof e&&r(e)?{type:"state",state:t.decode(e)||{},isNotFound:t.isNotFound(e)}:null}},[e,t]),l=(0,dr.useSyncExternalStoreWithSelector)(r.subscribe,r.getSnapshot,r.getServerSnapshot,r.selector,aU()),a=(0,lK.useRef)(l);(0,lK.useEffect)(()=>{var i;if((null==l?void 0:l.type)==="state"&&!(null==(i=l.state)?void 0:i.intent)){let i=function(e,t){let n=function(e,t){let n=q5(e),i=n[0];return t&&!t.tool&&i?Object.assign({},t,{tool:i.name}):t}(e,t&&q5(e).find(e=>e.name===t.space)?{...t,tool:t.space,space:void 0}:t);return n}(n,l.state);i&&i!==l.state&&e.replace(t.encode(i))}},[null==l?void 0:l.state,null==l?void 0:l.type,e,t,n]),(0,lK.useEffect)(()=>{let i=q8(l,t,n,a);i?e.replace(i):a.current=l},[l,e,t,n]);let o=(0,lK.useMemo)(()=>i=>{let{path:l,replace:o}=i,s=r.selector(l),d=q8(s,t,n,a),c="string"==typeof d?d:l;o?e.replace(c):e.push(c)},[e,t,r,n]);return[null!=(i=null==l?void 0:l.state)?i:null,o]}(a,o,l);return s?(0,lU.jsx)(a1.pG,{onNavigate:d,router:o,state:s,children:t}):(0,lU.jsx)(n,{})}function q8(e,t,n,i){var r,l;if((null==e?void 0:e.type)==="state"&&(null==(r=e.state)?void 0:r.intent)){let r=function(e,t,n){let{intent:i,params:r,payload:l}=n;if("string"!=typeof i)throw Error("intent must be a string");if(!cc(r))throw Error("intent params must be a string");let a=q5(e),o=(null==t?void 0:t.tool)?a.find(e=>e.name===t.tool):null,s=(o?[o,...a]:a).find(e=>e&&"function"==typeof e.canHandleIntent&&e.canHandleIntent(i,r,t&&t[e.name]));if(null==s?void 0:s.getIntentState){let e=s.getIntentState(i,r,t&&t[s.name],l);return{type:"state",isNotFound:!1,state:{...t,tool:s.name,[s.name]:e}}}return{type:"intent",isNotFound:!0,intent:{name:i,params:r}}}(n,(null==(l=i.current)?void 0:l.type)==="state"?i.current.state:{},e.state);if((null==r?void 0:r.type)==="state")return t.encode(r.state)}return null}function q9(e){let{children:t,LoadingComponent:n}=e,[i,r]=(0,lK.useState)(null);if(i)throw i;let{activeWorkspace:l}=FK(),[a,o]=(0,lK.useState)(null);return((0,lK.useEffect)(()=>{let e=(0,ae.a)(l.__internal.sources.map(e=>{let{source:t}=e;return t.pipe((0,au.K)(e=>{if(e instanceof R2)return(0,lQ.of)(e);throw e}))})).pipe((0,ad.U)(e=>{let t=e.filter(e=>e instanceof R2);if(t.length)throw new R2({name:l.name,causes:t,type:"workspace"});return e}),(0,ad.U)(e=>{let[t,...n]=e;return{...l,...t,unstable_sources:[t,...n],type:"workspace"}})).subscribe({next:o,error:r});return()=>e.unsubscribe()},[l]),a)?(0,lU.jsx)(Iv,{workspace:a,children:(0,lU.jsx)(Ij,{source:a.unstable_sources[0],children:(0,lU.jsx)(q6,{LoadingComponent:n,workspace:a,children:t})})}):(0,lU.jsx)(n,{})}function q7(e){let{ConfigErrorsComponent:t,...n}=e,[{error:i},r]=(0,lK.useState)({error:null});if(i)throw i;return(0,lU.jsx)(lY.SV,{onCatch:r,children:(0,lU.jsx)(q9,{...n})})}function Ne(e){let{children:t,config:n,basePath:i,onSchemeChange:r,scheme:l,unstable_history:a,unstable_noAuthBoundary:o}=e,s=(0,lU.jsx)(q7,{LoadingComponent:FP,ConfigErrorsComponent:De,children:(0,lU.jsx)(p3,{children:t})});return(0,lU.jsx)(Fo,{onSchemeChange:r,scheme:l,children:(0,lU.jsxs)(lY.VW,{paddingY:7,zOffset:q1.toast,children:[(0,lU.jsx)(qJ,{}
1),(0,lU.jsx)(Da,{children:(0,lU.jsx)(Fx,{config:n,basePath:i,children:(0,lU.jsx)(FB,{unstable_history:a,NotFoundComponent:FZ,LoadingComponent:FP,children:(0,lU.jsx)(q0,{children:(0,lU.jsx)(gE,{children:o?s:(0,lU.jsx)(qQ,{LoadingComponent:FP,AuthenticateComponent:F7,NotAuthenticatedComponent:Dt,children:s})})})})})})]})})}function Nt(){let e=fz({defaultComponent:Du,pick:q$});return(0,lU.jsx)(e,{})}function Nn(e){let{basePath:t,config:n,onSchemeChange:i,scheme:r,unstable_globalStyles:l,unstable_history:a,unstable_noAuthBoundary:o}=e;return(0,lU.jsxs)(Ne,{basePath:t,config:n,onSchemeChange:i,scheme:r,unstable_history:a,unstable_noAuthBoundary:o,children:[l&&(0,lU.jsx)(hT,{}),(0,lU.jsx)(Nt,{})]})}function Ni(e){let t=Iw();return e?t.getClient(e):(console.warn('Calling `useClient()` without specifying an API version is deprecated and will stop working in the next dev-preview release - please migrate to use `useClient({apiVersion: "2021-06-07"})`.'),t.getClient({apiVersion:"2021-06-07"}))}(0,aW.ZP)(lY.kC)(lq||(lq=q4([""]))),(0,aW.ZP)(lY.xu).attrs({padding:4})(lN||(lN=q4([""]))),db().registerLanguage(dj()),db().registerLanguage(dk()),db().registerLanguage(d_()),db().registerLanguage(dT()),db().registerLanguage(dP());let Nr="connecting";function Nl(e,t){let n=UJ();return(0,lJ.m2)(()=>n.pair.documentEvents(e,t).pipe((0,ad.U)(e=>e.type),(0,ad.U)(e=>"reconnect"!==e),(0,ap.w)(e=>e?(0,lQ.of)("connected"):(0,l6.H)(200).pipe((0,aP.h)("reconnecting"))),(0,ag.O)(Nr),(0,ac.x)()),[n.pair,e,t],Nr)}function Na(){return Iw().dataset}function No(e,t){let n=UJ();return(0,lJ.m2)(()=>n.pair.editOperations(e,t),[t,n.pair,e])}function Ns(e,t){let n=UJ();return(0,lJ.m2)(()=>n.pair.operationEvents(e,t),[n.pair,e,t])}function Nd(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",i=UJ();return(0,lJ.m2)(()=>{let r=i.pair.editState(e,t).pipe((0,a_.B)());return"low"===n?(0,l3.T)(r.pipe((0,ab.q)(1)),r.pipe((0,aA.T)(1),(0,aE.D)(()=>(0,l6.H)(1e3)))):i.pair.editState(e,t)},[i.pair,e,t,n])}function Nc(){return Iw().projectId}function Nu(){return Iw().schema}let Np={isSyncing:!0},Nh={isSyncing:!1};function Nf(e,t){let n=UJ();return(0,lJ.m2)(()=>n.pair.consistencyStatus(e,t).pipe((0,ad.U)(e=>e?Nh:Np)),[n.pair,t,e],Nh)}function Nm(){return Iw().templates}function Ng(e){let{minimal:t,agoSuffix:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e instanceof Date?e:new Date(e);if(!n.getTime())return{timestamp:"",refreshInterval:null};let i=Date.now(),r=(0,oH.Z)(i,n),l=(0,oW.Z)(i,n);if(r||l)return t.minimal&&0===l?{timestamp:(0,oh.Z)(n,"MMM d"),refreshInterval:null}:t.minimal?{timestamp:(0,oh.Z)(n,"MMM d, yyyy"),refreshInterval:null}:{timestamp:(0,oh.Z)(n,"MMM d, yyyy, hh:mm a"),refreshInterval:null};let a=(0,o$.Z)(i,n),o=(0,oQ.Z)("week",a);if(a)return t.minimal?{timestamp:t.agoSuffix?"".concat(a,"w ago"):"".concat(a,"w"),refreshInterval:36e5}:{timestamp:t.agoSuffix?"".concat(a," ").concat(o," ago"):"".concat(a," ").concat(o),refreshInterval:36e5};let s=(0,oX.Z)(i,n),d=(0,oQ.Z)("days",s);if(s){if(t.minimal){let e=t.agoSuffix?"".concat(s,"d ago"):"".concat(s,"d");return{timestamp:1===s?"yesterday":e,refreshInterval:36e5}}let e=t.agoSuffix?"".concat(s," ").concat(d," ago"):"".concat(s," ").concat(d);return{timestamp:1===s?"yesterday":e,refreshInterval:36e5}}let c=(0,oG.Z)(i,n),u=(0,oQ.Z)("hour",c);if(c)return t.minimal?{timestamp:t.agoSuffix?"".concat(c,"h ago"):"".concat(c,"h"),refreshInterval:6e4}:{timestamp:t.agoSuffix?"".concat(c," ").concat(u," ago"):"".concat(c," ").concat(u),refreshInterval:6e4};let p=(0,oY.Z)(i,n),h=(0,oQ.Z)("minute",p);if(p)return t.minimal?{timestamp:t.agoSuffix?"".concat(p,"m ago"):"".concat(p,"m"),refreshInterval:2e4}:{timestamp:t.agoSuffix?"".concat(p," ").concat(h," ago"):"".concat(p," ").concat(h),refreshInterval:2e4};let f=(0,oJ.Z)(i,n),m=(0,oQ.Z)("second",f);return f>10?t.minimal?{timestamp:t.agoSuffix?"".concat(f,"s ago"):"".concat(f,"s"),refreshInterval:5e3}:{timestamp:t.agoSuffix?"".concat(f," ").concat(m," ago"):"".concat(f," ").concat(m),refreshInterval:5e3}:{timestamp:"just now",refreshInterval:5e3}}(e,{minimal:t,agoSuffix:n}),[,r]=(0,lK.useReducer)(e=>e+1,0);return(0,lK.useEffect)(()=>{let e;return null!==i.refreshInterval&&function t(n){e=window.setTimeout(()=>{r(),e=window.setTimeout(()=>t(n),n)},n)}(i.refreshInterval),()=>{null!==e&&clearTimeout(e)}},[r,i.refreshInterval]),i.timestamp}let Nx={validation:[],isValidating:!1};function Nv(e,t){let n=UJ();return(0,lJ.m2)(()=>n.pair.validation(e,t),[n.pair,e,t],Nx)}let Nb=d8(e=>{let[t,n]=e;return(0,at.D)(t.getUser(n).catch(e=>(console.error(e),null)))});function Ny(e){let t=U$();return Nb((0,lK.useMemo)(()=>[t,e],[e,t]))}function Nj(){let{currentUser:e}=Iw();return e}let Nw=e=>{let t=e.LOCAL,n=e.document.HEAD;return t?{...t,_type:(n||t)._type,_rev:(n||t)._rev,_updatedAt:new Date().toISOString()}:t},Nk=e=>({type:"snapshot",document:e}),NC=e=>e.document,N_=e=>{let t=new l2.x,n=new ar.X(!0),i=new l2.x,r=new l2.x,l=new l2.x,a=new l2.x,o=e=>{let t=new sR.W6(e);return t.onMutation=e=>{let{mutation:n,remote:r}=e;i.next({type:"mutation",document:Nw(t),mutations:n.mutations,origin:r?"remote":"local"})},t.onRemoteMutation=e=>{l.next({type:"remoteMutation",head:t.document.HEAD,transactionId:e.transactionId,timestamp:e.timestamp,author:e.identity,effects:e.effects})},t.onRebase=(e,t,n)=>{r.next({type:"rebase",document:e,remoteMutations:t,localMutations:n})},t.onConsistencyChanged=e=>{n.next(e)},t.commitHandler=e=>a.next(e),t},s=e.pipe((0,ah.R)((e,t)=>"snapshot"===t.type?(e&&e.commit(),o(t.document||null)):null===e?(console.warn('Ignoring event of type "%s" since buffered document has not yet been set up with snapshot',t.type),null):e,null),(0,af.h)(e=>null!==e),(0,ac.x)(),(0,aO._)(1),(0,az.x)()),d=e.pipe((0,af.h)(e=>"mutation"===e.type),(0,aM.M)(s),(0,ad.U)(e=>{let[t,n]=e;return n.arrive(new sR.mm(t)),Nw(n)})),c=t.pipe((0,aM.M)(s),(0,as.b)(e=>{let[t,n]=e;"mutation"===t.type&&n.add(new sR.mm({mutations:t.mutations})),"commit"===t.type&&n.commit()}),(0,ax.j)(l7.E),(0,a_.B)()),u=e=>t.next(e),p=e=>u({type:"mutation",mutations:e}),h=(0,l3.T)(s.pipe((0,ad.U)(e=>e.LOCAL)),i.pipe((0,ad.U)(NC)),r.pipe((0,ad.U)(NC)),d).pipe((0,ad.U)(Nk),(0,aO._)(1),(0,az.x)()),f=(0,l3.T)(s.pipe((0,ad.U)(e=>e.document.HEAD),(0,ad.U)(Nk)),l).pipe((0,aO._)(1),(0,az.x)());return{updates$:(0,l3.T)(h,c,i,r),consistency$:n.pipe((0,ac.x)(),(0,aO._)(1),(0,az.x)()),remoteSnapshot$:f,commitRequest$:a,addMutation:e=>p([e]),addMutations:p,commit:()=>{s.pipe((0,ab.q)(1),(0,as.b)(e=>e.commit())).subscribe()}}},NS=e=>t=>{let{_id:n,_rev:i,_updatedAt:r,...l}=t;return{_id:e,...l}},NT=(e,t)=>{let n=N_(t),i=NS(e),r={delete:{id:e}};return{events:n.updates$,consistency$:n.consistency$,remoteSnapshot$:n.remoteSnapshot$,commitRequest$:n.commitRequest$,patch:t=>t.map(t=>({patch:{...t,id:e}})),create:e=>({create:i(e)}),createIfNotExists:e=>({createIfNotExists:i(e)}),createOrReplace:e=>({createOrReplace:i(e)}),delete:()=>r,mutate:e=>n.addMutations(e),commit:()=>n.commit()}},NE={type:"pending",phase:"begin"},NP={type:"pending",phase:"end"};function NA(e,t){return{type:"snapshot",documentId:e,document:t}}let NO=e=>t=>"reconnect"!==t.type&&"pending"!==t.type&&t.documentId===e;function Nz(e){return t=>({...t,version:e})}function NM(e,t){let{publishedId:n,draftId:i}=t,r=(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{publishedId:i,draftId:r}=t;return(0,l4.P)(()=>e.observable.listen("*[_id == $publishedId || _id == $draftId]",{publishedId:i,draftId:r},{includeResult:!1,events:["welcome","mutation","reconnect"],effectFormat:"mendoza",tag:n.tag||"document.pair-listener"})).pipe((0,aS.b)(t=>"welcome"===t.type?e.observable.getDocuments([r,i],{tag:"document.snapshots"}).pipe((0,ad.U)(e=>{let[t,n]=e;return{draft:t,published:n}})).pipe((0,aS.b)(e=>[NA(r,e.draft),NA(i,e.published)])):(0,lQ.of)(t)),(0,ah.R)((e,t)=>{if("mutation"!==t.type)return{next:[t],buffer:[]};let n=e.buffer.length>0,i=t.transactionTotalEvents>1;if(!i&&!n)return{next:[t],buffer:[]};if(!i)return{next:[],buffer:e.buffer.concat(t)};let r=e.buffer.concat(t);return!function(e){let t=sS()(e.filter(e=>"mutation"===e.type),e=>e.transactionId);return Object.values(t).every(e=>e.length===e[0].transactionTotalEvents)}(r)?{next:1===r.length?[NE]:[],buffer:r}:{next:r.concat(NP),buffer:[]}},{next:[],buffer:[]}),(0,ay.z)(e=>e.next))})(e,t).pipe((0,a_.B)()),l=r.pipe((0,af.h)(e=>"reconnect"===e.type)),a=NT(i,r.pipe((0,af.h)(NO(i)))),o=NT(n,r.pipe((0,af.h)(NO(n)))),s=r.pipe((0,af.h)(e=>"pending"===e.type)),d=(0,l3.T)(a.commitRequest$,o.commitRequest$).pipe((0,ay.z)(t=>(0,at.D)(function(e,t){let{resultRev:n,...i}=t;return e.dataRequest("mutate",i,{visibility:"async",returnDocuments:!1,tag:"document.commit",skipCrossDatasetReferenceValidation:!0}
1)}(e,t.mutation.params)).pipe((0,as.b)({error:e=>{let n="statusCode"in e&&"number"==typeof e.statusCode&&e.statusCode>=400&&e.statusCode<=500;n?t.cancel(e):t.failure(e)},next:()=>t.success()}))),(0,ax.j)(l7.E),(0,a_.B)());return{transactionsPendingEvents$:s,draft:{...a,events:(0,l3.T)(d,l,a.events).pipe((0,ad.U)(Nz("draft"))),consistency$:a.consistency$,remoteSnapshot$:a.remoteSnapshot$.pipe((0,ad.U)(Nz("draft")))},published:{...o,events:(0,l3.T)(d,l,o.events).pipe((0,ad.U)(Nz("published"))),consistency$:o.consistency$,remoteSnapshot$:o.remoteSnapshot$.pipe((0,ad.U)(Nz("published")))}}}function NI(e,t){let n=Object.create(null);return function(){let i=t(...arguments);return i in n||(n[i]=e(...arguments)),n[i]}}let NR=(e,t)=>{var n;return(null==(n=e.get(t))?void 0:n.liveEdit)===!0};function NF(e,t,n){var i,r;let l=e.config();return"".concat(null!=(i=l.dataset)?i:"","-").concat(null!=(r=l.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}let ND=NI((e,t,n)=>new l9.y(n=>{n.next(NM(e,t))}).pipe((0,aO._)(1),(0,az.x)()),NF);function NZ(e){return"snapshot"===e.type}function NL(e){return{snapshots$:e.events.pipe((0,af.h)(NZ),(0,ad.U)(e=>e.document),(0,aO._)(1),(0,az.x)()),patch:e.patch,create:e.create,createIfNotExists:e.createIfNotExists,createOrReplace:e.createOrReplace,delete:e.delete,mutate:e.mutate,commit:e.commit}}let Nq=NI((e,t,n)=>ND(e,t,n).pipe((0,ad.U)(e=>{let{published:t,draft:n,transactionsPendingEvents$:i}=e;return{transactionsPendingEvents$:i,published:NL(t),draft:NL(n)}}),(0,aO._)(1),(0,az.x)()),(e,t,n)=>{var i,r;let l=e.config();return"".concat(null!=(i=l.dataset)?i:"","-").concat(null!=(r=l.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}),NN={enabled:!0},NV={enabled:!1},NU=NI((e,t,n)=>{let i=NR(e.schema,n);return Nq(e.client,t,n).pipe((0,ap.w)(e=>(0,ae.a)([e.draft.snapshots$,e.published.snapshots$,e.transactionsPendingEvents$.pipe((0,ad.U)(e=>"begin"===e.phase?NN:NV),(0,ag.O)(NV))])),(0,ad.U)(e=>{let[r,l,a]=e;return{id:t.publishedId,type:n,draft:r,published:l,liveEdit:i,ready:!0,transactionSyncLock:a}}),(0,ag.O)({id:t.publishedId,type:n,draft:null,published:null,liveEdit:i,ready:!1,transactionSyncLock:null}),(0,aO._)(1),(0,az.x)())},(e,t,n)=>NF(e.client,t,n)),NB=NI((e,t,n)=>Nq(e.client,t,n).pipe((0,ap.w)(i=>(0,ae.a)([i.draft.snapshots$,i.published.snapshots$]).pipe((0,ad.U)(r=>{let[l,a]=r;return{...e,idPair:t,typeName:n,snapshots:{draft:l,published:a},draft:i.draft,published:i.published}}))),(0,aO._)(1),(0,az.x)()),(e,t,n)=>{var i,r;let l=e.client.config();return"".concat(null!=(i=l.dataset)?i:"","-").concat(null!=(r=l.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}),NK={disabled:e=>{let{snapshots:t}=e;return!t.draft&&!t.published&&"NOTHING_TO_DELETE"},execute:e=>{let{client:t,schema:n,idPair:i,typeName:r}=e,l=t.observable.transaction().delete(i.publishedId);return NR(n,r)?l.commit({tag:"document.delete"}):l.delete(i.draftId).commit({tag:"document.delete",skipCrossDatasetReferenceValidation:!0})}},NH={disabled:e=>{let{schema:t,typeName:n,snapshots:i}=e;return NR(t,n)?"LIVE_EDIT_ENABLED":!i.draft&&(i.published?"ALREADY_PUBLISHED":"NO_CHANGES")},execute:e=>{let{client:t,idPair:n,snapshots:i}=e;if(!i.draft)throw Error('cannot execute "publish" when draft is missing');let r=function e(t){return(0,lV.Yk)(t)?t._strengthenOnPublish?sm()(t,["_strengthenOnPublish"].concat(t._strengthenOnPublish.weak?[]:["_weak"])):t:"object"==typeof t&&t?Array.isArray(t)?t.map(e):Object.fromEntries(Object.entries(t).map(t=>{let[n,i]=t;return[n,e(i)]})):t}(sm()(i.draft,"_updatedAt")),l=t.observable.transaction();if(!i.draft)throw Error('cannot execute "publish" when draft is missing');return i.published?(l.patch(n.publishedId,{unset:["_revision_lock_pseudo_field_"],ifRevisionID:i.published._rev}),l.createOrReplace({...r,_id:n.publishedId,_type:i.draft._type})):l.create({...r,_id:n.publishedId,_type:i.draft._type}),l.delete(n.draftId),l.commit({tag:"document.publish",visibility:"async"})}},NW={disabled:()=>!1,execute:function(e){let{schema:t,snapshots:n,idPair:i,draft:r,published:l,typeName:a}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=arguments.length>2?arguments[2]:void 0;NR(t,a)?l.mutate([l.createIfNotExists({_type:a,...s}),...l.patch(o)]):r.mutate([r.createIfNotExists({...s,...n.published,_id:i.draftId,_type:a}),...r.patch(o)])}},N$={disabled:()=>!1,execute:e=>{let{draft:t,published:n}=e;return t.commit(),n.commit(),l7.E}},NX={disabled:e=>{let{snapshots:t}=e;return t.draft?!t.published&&"NOT_PUBLISHED":"NO_CHANGES"},execute:e=>{let{client:t,idPair:n}=e;return t.observable.transaction().delete(n.draftId).commit({tag:"document.discard-changes"})}},NG={disabled:e=>{let{schema:t,snapshots:n,typeName:i}=e;return NR(t,i)?"LIVE_EDIT_ENABLED":!n.published&&"NOT_PUBLISHED"},execute:e=>{let{client:t,idPair:n,snapshots:i}=e,r=t.observable.transaction().delete(n.publishedId);return i.published&&(r=r.createIfNotExists({...sm()(i.published,"_updatedAt"),_id:n.draftId,_type:i.published._type})),r.commit({tag:"document.unpublish",visibility:"async",skipCrossDatasetReferenceValidation:!0}
1)}},NY=["_createdAt","_updatedAt"],NJ={disabled:e=>{let{snapshots:t}=e;return!t.published&&!t.draft&&"NOTHING_TO_DUPLICATE"},execute:(e,t)=>{let{schema:n,client:i,snapshots:r,typeName:l}=e,a=r.draft||r.published;if(!a)throw Error("cannot execute on empty document");return i.observable.create({...sm()(a,NY),_id:NR(n,l)?t:cn(t),_type:a._type},{tag:"document.duplicate"})}},NQ={disabled:()=>!1,execute:(e,t)=>{let{historyStore:n,schema:i,idPair:r,typeName:l}=e,a=NR(i,l)?r.publishedId:r.draftId;return n.restore(r.publishedId,a,t)}},N0=NI((e,t,n)=>ND(e,t,n).pipe((0,ap.w)(e=>{let{draft:t,published:n}=e;return(0,ae.a)([t.consistency$,n.consistency$])}),(0,ad.U)(e=>{let[t,n]=e;return t&&n}),(0,ac.x)(),(0,aO._)(1),(0,az.x)()),(e,t,n)=>{var i,r;let l=e.config();return"".concat(null!=(i=l.dataset)?i:"","-").concat(null!=(r=l.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}),N1={del:NK,delete:NK,publish:NH,patch:NW,commit:N$,discardChanges:NX,unpublish:NG,duplicate:NJ,restore:NQ},N2=(e,t,n)=>{let i=N1[e];return(0,l4.P)(()=>{var e;return(0,l3.T)((0,lQ.of)(null),void 0===(e=i.execute(t,...n))?(0,lQ.of)(null):e)}).pipe((0,aI.Z)())},N3=new l2.x;function N4(e,t,n,i){N3.next({operationName:e,idPair:t,typeName:n,extraArgs:i})}let N5=["publish","unpublish","discardChanges","delete"],N6=NI(e=>{let t=N3.pipe((0,aR.v)(e=>e.idPair.publishedId),(0,ay.z)(t=>t.pipe((0,ap.w)(t=>NB(e,t.idPair,t.typeName).pipe((0,ab.q)(1),(0,ap.w)(n=>{let i=N5.includes(t.operationName);i&&(n.published.commit(),n.draft.commit());let r=N0(e.client,t.idPair,t.typeName).pipe((0,af.h)(Boolean)),l=i?r.pipe((0,ab.q)(1)):(0,lQ.of)(!0);return l.pipe((0,ap.w)(()=>N2(t.operationName,n,t.extraArgs)))}),(0,ad.U)(()=>({type:"success",args:t})),(0,au.K)(e=>(0,lQ.of)({type:"error",args:t,error:e})))))),(0,a_.B)()),n=t.pipe((0,af.h)(e=>"success"===e.type&&"patch"===e.args.operationName),(0,aF.p)(1e3,al.z,{leading:!0,trailing:!0}),(0,as.b)(e=>{N4("commit",e.args.idPair,e.args.typeName,[])}));return(0,l3.T)(t,n.pipe((0,ax.j)(l7.E)))},e=>{var t,n;let i=e.client.config();return"".concat(null!=(t=i.dataset)?t:"","-").concat(null!=(n=i.projectId)?n:"")}),N8=NI((e,t,n)=>ND(e,t,n).pipe((0,ap.w)(e=>{let{published:t,draft:n}=e;return(0,l3.T)(t.remoteSnapshot$,n.remoteSnapshot$)})),NF),N9={isValidating:!0,validation:[]},N7=[],Ve=(e,t)=>e(t).pipe((0,ad.U)(e=>{let{published:t}=e;return t.available})),Vt=NI((e,t,n)=>{let{draftId:i,publishedId:r}=t,l=NU(e,{draftId:i,publishedId:r},n).pipe((0,ad.U)(e=>{let{draft:t,published:n}=e;return t||n}),(0,aF.p)(200,al.z,{trailing:!0}),(0,ac.x)((e,t)=>(null==e?void 0:e._rev)===(null==t?void 0:t._rev)||aQ()(sm()(e,"_rev","_updatedAt"),sm()(t,"_rev","_updatedAt"))),(0,a_.B)()),a=l.pipe((0,ad.U)(e=>(0,s9.u4)(e,(e,t)=>((0,lV.Yk)(t)&&e.add(t._ref),e),new Set)),(0,ay.z)(e=>(0,at.D)(e))),o=a.pipe((0,aR.v)(e=>e,void 0,()=>(0,l6.H)(18e5)),(0,ay.z)(t=>t.pipe((0,aD.E)(),(0,ay.z)(t=>Ve(e.observeDocumentPairAvailability,t).pipe((0,ad.U)(e=>[t,e]))))),(0,ah.R)((e,t)=>{let[n,i]=t;return!!e[n]===i?e:i?{...e,[n]:i}:sm()(e,n)},{}),(0,ac.x)(aQ()),(0,am.d)({refCount:!0,bufferSize:1})),s=e=>{let{id:t}=e;return(0,aa.n)(o.pipe((0,aT.P)(),(0,ad.U)(e=>e[t])))},d=o.pipe((0,aA.T)(1),(0,aF.p)(1e3,al.z,{leading:!0,trailing:!0}));return(0,ae.a)([l,(0,l0.z)((0,lQ.of)(null),d)]).pipe((0,ad.U)(e=>{let[t]=e;return t}),(0,s7.q)(t=>(0,l4.P)(()=>(null==t?void 0:t._type)?(0,l0.z)((0,lQ.of)({isValidating:!0,revision:t._rev}),(function(e,t,n,i){let r=n.get(t._type);if(!r)return console.warn('Schema type for object type "%s" not found, skipping validation',t._type),(0,lQ.of)(fy);let l={getClient:e,schema:n,parent:void 0,value:t,path:[],document:t,type:r,getDocumentExists:null==i?void 0:i.getDocumentExists};return(function e(t){let{value:n,type:i,path:r=[],parent:l,...a}=t,o=fx(i),s=o.map(e=>(0,l4.P)(()=>e.validate(n,{...a,parent:l,path:r,type:i}))),d=[],c=o.some(e=>e.isRequired()),u=(null==i?void 0:i.jsonType)==="object"&&(!!n||null==n&&c);if(u){let t=i.fields.reduce((e,t)=>(e[t.name]=t.type,e),{});d=(d=d.concat(o.map(e=>e._fieldRules).filter(fb).flatMap(e=>Object.entries(e)).flatMap(e=>{let[i,l]=e,o=t[i];return fx({...o,validation:l}).map(e=>{let t=fv(n)?n[i]:void 0;return(0,l4.P)(()=>e.validate(t,{...a,parent:n,path:r.concat(i),type:o}))})}))).concat(i.fields.map(t=>e({...a,parent:n,value:fv(n)?n[t.name]:void 0,path:r.concat(t.name),type:t.type})))}let p=(null==i?void 0:i.jsonType)==="array"&&Array.isArray(n);
1return p&&(d=d.concat(n.map((t,l)=>e({...a,parent:n,value:t,path:r.concat((0,lV.fU)(t)?{_key:t._key}:l),type:function(e,t){if(1===t.length)return t[0];let n=(0,lV.ay)(e)&&e._type,i=null==e||!n&&hV(e).toLowerCase();return i&&"object"!==i?t.find(e=>e.jsonType===i):t.find(e=>{var t;return(null==(t=e.type)?void 0:t.name)===n})||t.find(e=>e.name===n)||t.find(e=>"object"===e.name&&"object"===i)}(t,i.of)})))),(0,l4.P)(()=>(0,l3.T)([...s,...d])).pipe((0,ay.z)(e=>{var t;return(0,l0.z)(new l9.y(e=>{let n=fs(()=>{e.complete()},t?{timeout:t}:void 0);return()=>fd(n)}),e)},40),(0,aj.J)(),(0,aw.q)(),(0,ad.U)(om()),(0,ad.U)(e=>o.some(e=>e._fieldRules)?ox()(e,e=>JSON.stringify(e)):e))})(l).pipe((0,au.K)(e=>(console.error(e),(0,lQ.of)([{type:"validation",level:"error",path:[],item:new hF(null==e?void 0:e.message)}]))))})(e.getClient,t,e.schema,{getDocumentExists:s}).pipe((0,ad.U)(e=>({validation:e,isValidating:!1})))):(0,lQ.of)({validation:N7,isValidating:!1}))),(0,ah.R)((e,t)=>({...e,...t}),N9),(0,aO._)(1),(0,az.x)())},(e,t,n)=>{var i,r;let l=e.client.config();return"".concat(null!=(i=l.dataset)?i:"","-").concat(null!=(r=l.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}),Vn=NI((e,t,n)=>ND(e,t,n).pipe((0,ap.w)(e=>{let{draft:t,published:n}=e;return(0,l3.T)(t.events,n.events)})),NF);function Vi(e){return{disabled:"NOT_READY",execute:()=>{throw Error("Called ".concat(e," before it was ready."))}}}let Vr={commit:Vi("commit"),delete:Vi("delete"),del:Vi("del"),publish:Vi("publish"),patch:Vi("patch"),discardChanges:Vi("discardChanges"),unpublish:Vi("unpublish"),duplicate:Vi("duplicate"),restore:Vi("restore")},Vl=(e,t,n)=>function(){for(var i=arguments.length,r=Array(i),l=0;l<i;l++)r[l]=arguments[l];return N4(e,t,n,r)};function Va(e,t,n){let i=t.disabled(n);return{disabled:i,execute:Vl(e,n.idPair,n.typeName)}}function Vo(e){return{commit:Va("commit",N$,e),delete:Va("delete",NK,e),del:Va("delete",NK,e),publish:Va("publish",NH,e),patch:Va("patch",NW,e),discardChanges:Va("discardChanges",NX,e),unpublish:Va("unpublish",NG,e),duplicate:Va("duplicate",NJ,e),restore:Va("restore",NQ,e)}}let Vs=NI((e,t,n)=>{let i=N6(e),r=NB(e,t,n),l=r.pipe((0,ad.U)(Vo));return(0,l0.z)((0,lQ.of)(Vr),(0,l3.T)(i.pipe((0,ay.z)(()=>l7.E)),l)).pipe((0,am.d)({refCount:!0,bufferSize:1}))},(e,t,n)=>NF(e.client,t,n)),Vd=(e,t,n,i)=>(0,l4.P)(()=>e.observable.fetch(t,n,{tag:i.tag,filterResponse:!0})),Vc=(e,t,n,i)=>(0,l4.P)(()=>e.listen(t,n,{events:["welcome","mutation","reconnect"],includeResult:!1,visibility:"query",tag:i.tag}));function Vu(e){return"welcome"===e.type}let Vp=["_key","_ref","_weak","_type"];function Vh(e){return e&&e.length>0?'"'.concat(e,'"'):e}function Vf(e,t){let n=e=>'Template "'.concat(t.id,'" initial value: ').concat(e);if(!sD()(e))throw Error(n("resolved to a non-object"));if(e._type&&t.schemaType!==e._type)throw Error(n('includes "_type"-property ('.concat(e._type,") that does not match template (").concat(t.schemaType,")")));try{return function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Array.isArray(t))return t.map((t,i)=>{if(Array.isArray(t))throw Error('multidimensional arrays are not supported (at path "'.concat((0,lB.BB)(n),'")'));return e(t,n.concat(i),!0)});if(!sD()(t))return t;let r=i&&!t._key?{_key:(0,sy.E2)()}:{};return n.length>0&&!t._type&&t._ref&&(r._type="reference"),t._ref&&function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e._type&&e.type)throw Error('Reference is missing "_type", but has a "type" property at path "'.concat((0,lB.BB)(t),'"'));let n=Object.keys(e).filter(e=>!Vp.includes(e));if(n.length>0){let e=n.length>1?"properties":"property";throw Error("Disallowed ".concat(e," found in reference: ").concat(n.map(Vh).join(", "),' at path "').concat((0,lB.BB)(t),'"'))}}(t,n),Object.keys(t).reduce((i,r)=>(i[r]=e(t[r],n.concat([r])),i),r)}(e)}catch(e){throw e.message=n(e.message),e}}function Vm(e,t){let n={...e,...t};return Object.keys(n).forEach(i=>{let r=t[i],l=e[i];sD()(r)&&sD()(l)&&(n[i]=Vm(l,r))}),n}async function Vg(e,t,n){return"function"==typeof e?e(t,n):e}async function Vx(e,t){var n,i;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(sD()(t)&&"function"==typeof t.serialize)return Vx(e,t.serialize(),r,l);let{id:a,schemaType:o,value:s}=t;
1if(!s)throw Error('Template "'.concat(a,'" has invalid "value" property'));let d=await Vg(s,r,l);if(n=d,!sD()(n))throw Error('Template "'.concat(a,'" has invalid "value" property - must be a plain object or a resolver function returning a plain object'));i=d,sD()(i)&&!Object.keys(d).length&&(d={_type:o}),d=Vf(d,t);let c=e.get(o);if(!c)throw Error('Could not find schema type with name "'.concat(o,'".'));let u=Vm(await Vb(c,r,Vv,l)||{},d);return Vf(u,t)}let Vv=10;function Vb(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Vv,i=arguments.length>3?arguments[3]:void 0;return n<=0?Promise.resolve(void 0):(0,lV.m$)(e)?Vj(e,t,n,i):(0,lV.jB)(e)?Vy(e,t,n,i):Vg(e.initialValue,t,i)}async function Vy(e,t,n,i){let r=await Vg(e.initialValue,void 0,i);if(Array.isArray(r))return Promise.all(r.map(async r=>{let l=function(e,t){let n=(0,sy.wq)(t);return"object"===n&&1===e.of.length?e.of[0]:e.of.find(e=>e.name===n)}(e,r);return(0,lV.m$)(l)?{...r,...await Vb(l,t,n-1,i),_key:(0,sy.E2)()}:r}))}async function Vj(e,t,n,i){let r={...await Vg(e.initialValue,t,i)||{}},l={};await Promise.all(e.fields.map(async e=>{let r=await Vb(e.type,t,n-1,i);null!=r&&(l[e.name]=r)}));let a=Vm(l,r);if(!(0,sy.Ru)(a))return"object"!==e.name&&(a._type=e.name),a}let Vw={type:"loading"};function Vk(e){if(ce(e))throw Error("editOpsOf does not expect a draft id.");return{publishedId:e,draftId:cn(e)}}let VC={isLoaded:!1,documentType:void 0};function V_(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=UJ(),i=ci(e),r=!!(t&&"*"!==t),l=(0,lK.useMemo)(()=>({documentType:t,isLoaded:!0}),[t]),[a,o]=(0,lK.useState)(r?l:VC);return(0,lK.useEffect)(()=>o(VC),[i,t]),(0,lK.useEffect)(()=>{if(r)return;let e=n.resolveTypeForDocument(i,t).subscribe(e=>o({documentType:e,isLoaded:!0}));return()=>e.unsubscribe()},[n,i,t,r]),r?l:a}function VS(e){let{documentId:t,documentType:n,templateName:i,templateParams:r}=e,l=d6(r),a=UJ(),o=VT(),s=(0,lK.useMemo)(()=>({_id:t,_type:n}),[t,n]),[d,c]=(0,lK.useState)({loading:!1,error:null,value:s});return(0,lK.useEffect)(()=>{if(!i){c({loading:!0,error:null,value:s});return}let e=a.initialValue({documentId:t,documentType:n,templateName:i,templateParams:l},o),r=e.subscribe(e=>{"loading"===e.type&&c({loading:!0,error:null,value:s}),"success"===e.type&&c({loading:!1,error:null,value:e.value?{...s,...e.value}:s}),"error"===e.type&&c({loading:!1,error:e.error,value:s})});return c({loading:!0,error:null,value:s}),()=>r.unsubscribe()},[s,t,a,n,i,l,o]),d}function VT(){let e=Iw(),t=Nu(),n=Nj(),i=Nc(),r=Na(),l=e.getClient;return(0,lK.useMemo)(()=>({projectId:i,dataset:r,getClient:l,schema:t,currentUser:n}),[l,t,n,i,r])}function VE(){let e=VT();return(0,lK.useCallback)((t,n)=>Vb(t,n,Vv,e),[e])}let VP=d8(function(e){let{client:t,grantsStore:n,schema:i,id:r,permission:l,type:a}=e;if("*"===a)return(0,lQ.of)({granted:!1,reason:"Type specified was `*`"});let o=!!function(e,t){let n=e.get(t);if(!n)throw Error("No such schema type: ".concat(t));return n}(i,a).liveEdit;return Nq(t,{draftId:cn(r),publishedId:ci(r)},a).pipe((0,ap.w)(e=>(0,ae.a)([e.draft.snapshots$,e.published.snapshots$]).pipe((0,ad.U)(e=>{let[t,n]=e;return{draft:t,published:n}}))),(0,ap.w)(e=>{let{draft:t,published:i}=e,r=(function(e){let{grantsStore:t,permission:n,draft:i,published:r,liveEdit:l}=e,a=i||r,o=a===i?"draft":"published",{checkDocumentPermission:s}=t;switch(n){case"delete":if(l)return[["delete published document (live-edit)",s("update",r)]];return[["delete draft document",s("update",i)],["delete published document",s("update",r)]];case"discardDraft":if(l)return[];return[["delete draft document",s("update",i)]];case"publish":if(l)return[];return[["update published document at its current state",s("update",r)],["delete draft document",s("update",i)],["create published document from draft",s("create",i&&{...i,_id:ci(i._id)})]];case"unpublish":if(l)return[];return[["update draft document at its current state",s("create",i)],["delete published document",s("update",r)],["create draft document from published version",s("create",r&&{...r,_id:cn(r._id)})]];case"update":if(l)return[["update published document (live-edit)",s("update",r)]];return[["update ".concat(o," document"),s("update",a)]];case"duplicate":if(l)return[["create new published document from existing document (live-edit)",s("create",{...r,_id:"dummy-id"})]];return[["create new draft document from existing ".concat(o," document"),s("create",{...a,_id:cn("dummy-id")})]];default:throw Error("Could not match permission: ".concat(n))}})({grantsStore:n,permission:l,draft:t,published:i,liveEdit:o}).map(e=>{let[t,n]=e;return n.pipe((0,ad.U)(e=>{let{granted:n,reason:i}=e;return{granted:n,reason:n?"":"not allowed to ".concat(t,": ").concat(i),label:t,permission:l}}))});return r.length?(0,ae.a)(r).pipe((0,ad.U)(e=>{let t=e.every(e=>e.granted),n=t?"":"Unable to ".concat(l,":\n ").concat(e.filter(e=>!e.granted).map(e=>e.reason).join("\n "));return{granted:t,reason:n}})):(0,lQ.of)({granted:!0,reason:""})}))});function VA(e){let{id:t,type:n,permission:i,client:r,schema:l,grantsStore:a}=e,o=Ni(fC),s=Nu(),d=UX(),c=(0,lK.useMemo)(()=>r||o,[o,r]),u=(0,lK.useMemo)(()=>l||s,[s,l]),p=(0,lK.useMemo)(()=>a||d,[d,a]);return VP((0,lK.useMemo)(()=>({client:c,schema:u,grantsStore:p,id:t,permission:i,type:n}
1),[c,p,t,i,u,n]))}function VO(e){let{grantsStore:t,document:n,permission:i}=e,{checkDocumentPermission:r}=t;return r(i,n)}let Vz=d8(VO);function VM(e){let{document:t,permission:n,...i}=e,r=UX();return Vz({grantsStore:i.grantsStore||r,document:t,permission:n})}let VI=d8(function(e){let{grantsStore:t,templateItems:n,templates:i,schema:r,context:l}=e;return(null==n?void 0:n.length)?(0,ae.a)(n.map(function e(t){return"object"==typeof t&&null!==t&&"serialize"in t?e(t.serialize()):t}).map(async e=>{let t=i.find(t=>t.id===e.templateId);if(!t)throw Error('template not found: "'.concat(e.templateId,'"'));let n=await Vx(r,t,e.parameters,l);return{template:t,item:e,resolvedInitialValue:n}}).map(e=>(0,at.D)(e).pipe((0,ap.w)(e=>{let{item:n,resolvedInitialValue:i,template:l}=e,a=r.get(l.schemaType);if(!a)throw Error('schema type not found: "'.concat(l.schemaType,'"'));let o=null==a?void 0:a.liveEdit,{initialDocumentId:s="dummy-id"}=n;return VO({grantsStore:t,permission:"create",document:{_id:o?ci(s):cn(s),...i}}).pipe((0,ad.U)(e=>{let{granted:t,reason:r}=e,o=n.title||l.title,s={...n,granted:t,reason:r,resolvedInitialValue:i,template:l,title:o,subtitle:a.title===o?void 0:a.title,description:n.description||l.description,icon:n.icon||l.icon};return s}))})))):(0,lQ.of)([])});function VR(e){let{templateItems:t,...n}=e,i=Nu(),r=Nm(),l=UX(),a=VT();return VI({templateItems:t,grantsStore:n.grantsStore||l,schema:n.schema||i,templates:n.templates||r,context:a})}let VF="_debug_",VD="undefined"==typeof window?(0,lQ.of)({}):(0,l1.R)(window,"hashchange"),VZ=(0,l0.z)((0,lQ.of)(0),VD).pipe((0,ad.U)(()=>"undefined"==typeof document?"#":document.location.hash),(0,ac.x)(),(0,ad.U)(e=>e.substring(1).split(";").filter(e=>e.toLowerCase().startsWith(VF)).map(e=>e.substring(VF.length)))),VL=VZ.pipe((0,ad.U)(e=>e.find(e=>e.startsWith("roles="))),(0,ad.U)(e=>(null==e?void 0:e.split("roles=")[1].split(",").map(e=>e.trim()))||[])),Vq=[{filter:'_id in path("**")',permissions:["read","create","history","update"]}],VN=[{filter:'_id in path("**")',permissions:["read","history"]}],VV={administrator:[{filter:'_id in path("**")',permissions:["read","create","history","update"]}],editor:Vq,developer:[{filter:'_id in path("**")',permissions:["read","create","history","update"]}],contributor:[{filter:'_id in path("**")',permissions:["read"]},{filter:'_id in path("drafts.**")',permissions:["create","history","update"]}],viewer:VN,restricted:[{filter:'_id in path("drafts.**") && _type in ["stringsTest", "book", "author", "referenceTest"]',permissions:["read","create","history","update"]},{filter:'_id in path("**")',permissions:["read"]}],requiresApproval:[{filter:"!locked",permissions:["read","create","update"]}],read:VN,write:Vq},VU=VL.pipe((0,ad.U)(e=>e.length?e.filter(e=>!!e&&e in VV).flatMap(e=>VV[e]||[]):null));async function VB(e,t,n){let i=await e.request({uri:"/projects/".concat(t,"/datasets/").concat(n,"/acl"),tag:"acl.get",withCredentials:!0});return i}let VK=new Map;async function VH(e,t,n){VK.has(t)||VK.set(t,(0,de.Q)("*[".concat(t,"]")));let i=VK.get(t),r=function(e){let t={};return null!==e&&(t.identity=e.id),t}(e),{identity:l}=r,a={...r},o=await (await (0,de.k)(i,{dataset:[n],identity:l,params:a})).get();return(null==o?void 0:o.length)===1}async function VW(e,t,n,i){if(!i)return{granted:!0,reason:"Null document, nothing to check"};if(!t.length)return{granted:!1,reason:"No document grants"};let r=[];for(let n of t)await VH(e,n.filter,i)&&r.push(n);let l=r.some(e=>e.permissions.some(e=>e===n));return{granted:l,reason:l?"Matching grant":"No matching grants found"}}async function V$(e,t){let n=await fetch(e,t?{headers:{Authorization:"Bearer ".concat(t)}}:{credentials:"include"});return function(e){let t;let n=e.body;if(!n)throw Error("Failed to read body from response");let i=!1;return new ReadableStream({start(e){t=n.getReader();let r=new TextDecoder,l="";t.read().then(function n(a){if(a.done){if(i)return;if(0===(l=l.trim()).length){e.close();return}e.enqueue(JSON.parse(l)),e.close();return}l+=r.decode(a.value,{stream:!0});let o=l.split("\n");for(let n=0;n<o.length-1;++n){let r=o[n].trim();if(0!==r.length)try{e.enqueue(JSON.parse(r))}catch(n){e.error(n),i=!0,t.cancel();return}}return l=o[o.length-1],t.read().then(n).catch(t=>e.error(t))}).catch(t=>e.error(t))}
1,cancel(){i=!0,t.cancel()}})}(n)}var VX=Object.defineProperty,VG=(e,t,n)=>t in e?VX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,VY=(e,t,n)=>(VG(e,"symbol"!=typeof t?t+"":t,n),n);function VJ(e){return{id:e,hasAttrs:!1,attrs:null,rev:null,events:[],aligned:!1}}function VQ(e,t){if(e.hasAttrs=!0,t){if(e.attrs={...t},"string"!=typeof e.attrs._rev)throw Error("snapshot has no _rev");e.rev=e.attrs._rev,delete e.attrs._rev}else e.attrs=null,e.rev=null;e.events=[]}class V0{constructor(e){VY(this,"timeline"),VY(this,"earliestTransactionId",null),VY(this,"_states"),this.timeline=e,this._states={draft:VJ(e.draftId),published:VJ(e.publishedId)}}appendRemoteSnapshotEvent(e){let t=this._states[e.version];if("snapshot"===e.type){this._maybeInvalidateHistory(),VQ(t,e.document);return}"remoteMutation"===e.type&&(t.aligned?(this._apply(t,e),this.timeline.addRemoteMutation(e)):t.hasAttrs?t.events.push(e):VQ(t,e.head))}prependHistoryEvent(e){if(!this.acceptsHistory)throw Error("cannot prepend history at this point");for(let t of Object.values(this._states))if(!t.aligned){let n=function(e,t){let n=t.events.findIndex(t=>e.id===t.transactionId);return n>=0?n+1:t.rev?t.rev===e.id?0:-1:0}(e,t);n>=0&&this._alignAtIndex(t,n)}this.timeline.addTranslogEntry(e),this.earliestTransactionId=e.id}didReachEarliestEntry(){for(let e of Object.values(this._states))if(!e.aligned){if(null!==e.attrs)throw Error("unable to find translog entry to align to");this._alignAtIndex(e,0)}this.timeline.didReachEarliestEntry()}get isAligned(){return Object.values(this._states).every(e=>e.aligned)}get acceptsHistory(){return this._isComplete}get currentDocument(){return{draft:this._states.draft.attrs,published:this._states.published.attrs}}_alignAtIndex(e,t){for(let n of e.events.slice(0,t))this._apply(e,n);for(let n of e.events.slice(t))this._apply(e,n),this.timeline.addRemoteMutation(n);e.events=[],e.aligned=!0}get _isComplete(){return Object.values(this._states).every(e=>e.hasAttrs)}_apply(e,t){e.attrs=(0,dn.a)(e.attrs,t.effects.apply),e.rev=t.transactionId}_maybeInvalidateHistory(){if(this._isComplete){for(let e of Object.values(this._states))e.aligned=!1;this.earliestTransactionId=null,this.timeline.reset()}}}var V1=Object.defineProperty,V2=(e,t,n)=>t in e?V1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V3=(e,t,n)=>(V2(e,"symbol"!=typeof t?t+"":t,n),n);class V4{constructor(e,t,n,i){V3(this,"timeline"),V3(this,"start"),V3(this,"end"),V3(this,"doc"),V3(this,"_startDocument"),V3(this,"_endDocument"),V3(this,"_diff"),this.timeline=e,this.start=n,this.end=i,this.doc=t}same(e,t){return this.start===e&&this.end===t}endAttributes(){return V5(this.endDocument())}endDocument(){return this._endDocument||(this._endDocument=this.timeline.replayBackwardsUntil(this.end.end,this.doc)),this._endDocument}startAttributes(){return V5(this.startDocument())}startDocument(){if(!this.start)throw Error("start required");return this._startDocument||(this._startDocument=this.timeline.replayBackwardsBetween(this.start.end,this.end.end-1,this.endDocument())),this._startDocument}diff(){if(!this._diff){if(!this.start)throw Error("start required");this._diff=this.timeline.calculateDiff(this.startDocument(),this.endDocument(),this.start.index+1,this.end.index)}return this._diff}}function V5(e){return e.draft||e.published}var V6=Object.defineProperty,V8=(e,t,n)=>t in e?V6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V9=(e,t,n)=>(V8(e,"symbol"!=typeof t?t+"":t,n),n);
1class V7{constructor(e){V9(this,"timeline"),V9(this,"client"),V9(this,"handler"),V9(this,"version",0),V9(this,"selectionState","inactive"),V9(this,"_aligner"),V9(this,"_fetchMore",!1),V9(this,"_fetchAtLeast",0),V9(this,"_isRunning",!1),V9(this,"_isSuspended",!1),V9(this,"_didErr",!1),V9(this,"_since",null),V9(this,"_sinceTime",null),V9(this,"_rev",null),V9(this,"_revTime",null),V9(this,"_reconstruction"),this.timeline=e.timeline,this.client=e.client,this.handler=e.handler,this._aligner=new V0(this.timeline),this.markChange()}clearRange(){this.setRange(null,null)}setRange(e,t){t!==this._rev&&this.setRevTime(t),e!==this._since&&this.setSinceTime(e);let n=10;if("loading"!==this._sinceTime&&"loading"!==this._revTime&&this._aligner.isAligned){if("invalid"===this._sinceTime||"invalid"===this._revTime)this.selectionState="invalid";else if(this._sinceTime){this.selectionState="range";let e=this._revTime||this.timeline.lastChunk();this._sinceTime.index>e.index?(this._revTime="invalid",this.selectionState="invalid"):this.setReconstruction(this._sinceTime,e)}else this._revTime?(this.selectionState="rev",this.setReconstruction(null,this._revTime)):(this.selectionState="inactive",n=0)}else this.selectionState="loading";this._fetchAtLeast=n,this.start()}setLoadMore(e){this._fetchMore=e,this.start()}get sinceTime(){return this._sinceTime&&"object"==typeof this._sinceTime?this._sinceTime:null}get revTime(){return this._revTime&&"object"==typeof this._revTime?this._revTime:null}get realRevChunk(){return this.revTime||this.timeline.lastChunk()}onOlderRevision(){return!!this._rev&&("range"===this.selectionState||"rev"===this.selectionState)}findRangeForNewRev(e){let t=this.timeline.isLatestChunk(e)?null:this.timeline.createTimeId(e);if(!this._since)return[null,t];let n=this.sinceTime;return n&&n.index<e.index?[this._since,t]:["@lastPublished",t]}findRangeForNewSince(e){let t=this.revTime;return t&&e.index<t.index?[this.timeline.createTimeId(e),this._rev]:[this.timeline.createTimeId(e),null]}setRevTime(e){this._rev=e,this._revTime=e?this.timeline.parseTimeId(e):null,"@lastPublished"===this._since&&(this._since=null,this._sinceTime=null)}setSinceTime(e){"@lastPublished"===e?"string"==typeof this._revTime?this._sinceTime=this._revTime:this._sinceTime=this.timeline.findLastPublishedBefore(this._revTime):this._sinceTime=e?this.timeline.parseTimeId(e):null,this._since=e}sinceAttributes(){return this._sinceTime&&this._reconstruction?this._reconstruction.startAttributes():null}displayed(){return this._revTime&&this._reconstruction?this._reconstruction.endAttributes():null}setReconstruction(e,t){this._reconstruction&&this._reconstruction.same(e,t)||(this._reconstruction=new V4(this.timeline,this._aligner.currentDocument,e,t))}currentDiff(){return this._reconstruction?this._reconstruction.diff():null}currentObjectDiff(){let e=this.currentDiff();if(e){if("null"===e.type)return null;if("object"!==e.type)throw Error("ObjectDiff expected, got ".concat(e.type))}return e}handleRemoteMutation(e){this._aligner.appendRemoteSnapshotEvent(e),this.markChange(),this._aligner.acceptsHistory&&this.start()}start(){this._didErr||this._isRunning||(this._isRunning=!0,this.tick().then(()=>{this._isRunning=!1}))}resume(){this._isSuspended=!1}suspend(){this._isSuspended=!0}async tick(){var e;let t=this._aligner.acceptsHistory&&!this.timeline.reachedEarliestEntry&&("loading"===this.selectionState||this._fetchMore||this.timeline.chunkCount<=this._fetchAtLeast)&&!this._isSuspended;if(t){try{await this.fetchMoreTransactions()}catch(t){this._didErr=!0,null==(e=this.handler)||e.call(this,t,this);return}await this.tick()}}async fetchMoreTransactions(){let e=this.timeline.publishedId,t=this.timeline.draftId,n=this.client.config(),i="tag=sanity.studio.desk.history&effectFormat=mendoza&excludeContent=true&excludeMutations=true&includeIdentifiedDocumentsOnly=true&reverse=true&limit=".concat(50),r=this._aligner.earliestTransactionId;r&&(i+="&toTransaction=".concat(r));let l=this.client.getUrl("/data/history/".concat(n.dataset,"/transactions/").concat(e,",").concat(t,"?").concat(i)),a=await V$(l,n.token),o=a.getReader(),s=0;for(;;){let e=await o.read();if(e.done)break;if("error"in e.value)throw Error(e.value.error.description||e.value.error.type);if(s++,e.value.id!==r){if(this._aligner.earliestTransactionId!==r||!this._aligner.acceptsHistory)return;this._aligner.prependHistoryEvent(e.value),r=this._aligner.earliestTransactionId}}this._aligner.earliestTransactionId===r&&this._aligner.acceptsHistory&&(s<50&&this._aligner.didReachEarliestEntry(),this.markChange())}markChange(){var e;this.timeline.updateChunks(),this.setRevTime(this._rev),this.setSinceTime(this._rev),this.version++,null==(e=this.handler)||e.call(this,null,this)}}function Ue(e){return e.draft||e.published}var Ut=Object.defineProperty,Un=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ui=(e,t,n)=>(Un(e,"symbol"!=typeof t?t+"":t,n),n);
1class Ur{constructor(e,t,n,i){Ui(this,"type","array"),Ui(this,"value"),Ui(this,"length"),Ui(this,"annotation"),Ui(this,"extractor"),Ui(this,"content"),Ui(this,"elements",[]),this.content=e,this.value=t,this.annotation=n,this.extractor=i,this.length=e.elements.length}at(e){if(e>=this.length)throw Error("out of bounds");let t=this.elements[e];return t||(this.elements[e]=Uo(this.content.elements[e],this.value[e],this.extractor))}annotationAt(e){let t=this.content.metas[e];return this.extractor.fromMeta(t)}}class Ul{constructor(e,t,n,i){Ui(this,"type","object"),Ui(this,"value"),Ui(this,"keys"),Ui(this,"annotation"),Ui(this,"extractor"),Ui(this,"content"),Ui(this,"fields",{}),this.content=e,this.value=t,this.annotation=n,this.extractor=i,this.keys=Object.keys(e.fields)}get(e){let t=this.fields[e];if(t)return t;let n=this.content.fields[e];if(n)return this.fields[e]=Uo(n,this.value[e],this.extractor)}}class Ua{constructor(e,t,n,i){Ui(this,"type","string"),Ui(this,"value"),Ui(this,"annotation"),Ui(this,"extractor"),Ui(this,"content"),this.content=e,this.value=t,this.annotation=n,this.extractor=i}sliceAnnotation(e,t){let n=[],i=0;for(let r of this.content.parts){let l=r.value.length,a=Math.max(0,e-i);if(a<l){let e=Math.min(l,t-i);if(e<=0)break;!function(e,t){if(n.length>0){var i;let r=n[n.length-1];if((i=r.annotation)&&t?i.author===t.author&&i.chunk===t.chunk:!i&&!t){r.text+=e;return}}n.push({text:e,annotation:t})}(r.value.slice(a,e),this.extractor.fromValue(r))}i+=l}return n}}function Uo(e,t,n){let i=n.fromValue(e);if(e.content)switch(e.content.type){case"array":return new Ur(e.content,t,i,n);case"object":return new Ul(e.content,t,i,n);case"string":return new Ua(e.content,t,i,n)}return(0,di.r)(t,i)}function Us(e,t,n){return n?Uc(e,n.transactionIndex+1,n.chunk.index):t?Uc(e,t.start,t.index):null}function Ud(e,t){return t?Uc(e,t.transactionIndex,t.chunk.index):null}function Uc(e,t,n){let i=e.transactionByIndex(t);if(!i)return null;let r=e.chunkByTransactionIndex(t,n);return r?{chunk:r,timestamp:i.timestamp,author:i.author}:null}var Uu=Object.defineProperty,Up=(e,t,n)=>t in e?Uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uh=(e,t,n)=>(Up(e,"symbol"!=typeof t?t+"":t,n),n);class Uf{constructor(){Uh(this,"_postive",[]),Uh(this,"_negative",[])}addToEnd(e){e.index=this._postive.length,this._postive.push(e)}addToBeginning(e){if(0==this.length){this.addToEnd(e);return}e.index=-(this._negative.length+1),this._negative.push(e)}mergeAtEnd(e,t){if(0===this.length){this.addToEnd(e);return}let n=this.lastIdx,i=t(this.get(n),e);Array.isArray(i)?(this.set(n,i[0]),this.addToEnd(i[1])):this.set(n,i)}mergeAtBeginning(e,t){if(0===this.length){this.addToEnd(e);return}let n=this.firstIdx,i=t(e,this.get(n));Array.isArray(i)?(this.set(n,i[1]),this.addToBeginning(i[0])):this.set(n,i)}removeFromEnd(){0===this._postive.length?this._negative.shift():this._postive.pop()}has(e){return e>=0?e<this._postive.length:-(e+1)<this._negative.length}get(e){return e>=0?this._postive[e]:this._negative[-(e+1)]}set(e,t){e>=0?(t.index=e,this._postive[e]=t):(t.index=e,this._negative[-(e+1)]=t)}get lastIdx(){return this._postive.length-1}get last(){return this.get(this.lastIdx)}get firstIdx(){return-this._negative.length}get first(){return this.get(this.firstIdx)}get length(){return this._postive.length+this._negative.length}}function Um(e,t){var n,i;if(e.end!==t.start)throw Error("chunks are not next to each other");let r=Uv(e.draftState,t.draftState),l=Uv(e.publishedState,t.publishedState);if("delete"===e.type&&"editDraft"===t.type)return[e,{...t,type:"create",draftState:r,publishedState:l}];if("delete"===t.type){if("missing"===r&&"present"===l)return[e,{...t,type:"discardDraft",draftState:r,publishedState:l}];if("present"===r&&"missing"===l)return[e,{...t,type:"unpublish",draftState:r,publishedState:l}]}if(("create"===(n=e.type)||"editDraft"===n)&&"editDraft"===t.type&&(i=e.endTimestamp,Date.parse(t.startTimestamp)-Date.parse(i)<3e5)){let n=new Set;for(let t of e.authors)n.add(t);for(let e of t.authors)n.add(e);return{index:0,id:t.id,type:e.type,start:e.start,end:t.end,startTimestamp:e.startTimestamp,endTimestamp:t.endTimestamp,authors:n,draftState:r,publishedState:l}}return[e,{...t,draftState:r,publishedState:l}]}function Ug(e){let t=!!e,n=e&&Ub(null==e?void 0:e.apply);return n?"deleted":t?"upsert":"unedited"}function Ux(e){let t=!!e.draftEffect,n=!!e.publishedEffect,i=e.draftEffect&&Ub(e.draftEffect.apply),r=e.publishedEffect&&Ub(e.publishedEffect.apply),l=function(e){let t=Ug(e.draftEffect),n=Ug(e.publishedEffect);if("unedited"===n){if("deleted"===t)return"delete";if("upsert"===t)return"editDraft"}if("deleted"===n)return"delete";if("upsert"===n){if("unedited"===t)return"editLive";if("deleted"===t)return"publish"}return"editLive"}(e);return{index:0,id:e.id,type:l,start:e.index,end:e.index+1,startTimestamp:e.timestamp,endTimestamp:e.timestamp,authors:new Set([e.author]),draftState:t?i?"missing":"present":"unknown",publishedState:n?r?"missing":"present":"unknown"}}function Uv(e,t){return"unknown"===t?e:t}function Ub(e){return 0===e[0]&&null===e[1]}var Uy=Object.defineProperty,Uj=(e,t,n)=>t in e?Uy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uw=(e,t,n)=>(Uj(e,"symbol"!=typeof t?t+"":t,n),n);class Uk{constructor(e){Uw(this,"reachedEarliestEntry",!1),Uw(this,"publishedId"),Uw(this,"draftId"),Uw(this,"_transactions",new Uf),Uw(this,"_chunks",new Uf),Uw(this,"_possiblePendingTransactions",new Map),Uw(this,"_recreateTransactionsFrom"),Uw(this,"_trace"),this.publishedId=e.publishedId,this.draftId="drafts.".concat(e.publishedId),e.enableTrace&&(this._trace=[],this._trace.push({type:"initial",publishedId:e.publishedId}),window.__sanityTimelineTrace=this._trace)}get chunkCount(){return this._chunks.length}mapChunks(e){let t=[],n=this._chunks.firstIdx,i=this._chunks.lastIdx;for(let r=i;r>=n;r--)t.push(e(this._chunks.get(r),r));return t}reset(){this._transactions=new Uf,this._chunks=new Uf,this._possiblePendingTransactions=new Map,this._recreateTransactionsFrom=void 0,this.reachedEarliestEntry=!1}addRemoteMutation(e){this._trace&&this._trace.push({type:"addRemoteMutation",event:e});let t=this._possiblePendingTransactions.get(e.transactionId),n=t?t.transaction:{index:0,id:e.transactionId,timestamp:e.timestamp.toISOString(),author:e.author};"draft"===e.version?n.draftEffect=e.effects:n.publishedEffect=e.effects,t?(this._possiblePendingTransactions.delete(e.transactionId),this._invalidateTransactionFrom(t.i
1dx)):(this._transactions.addToEnd(n),this._possiblePendingTransactions.set(e.transactionId,{transaction:n,idx:this._transactions.lastIdx}))}addTranslogEntry(e){this._trace&&this._trace.push({type:"addTranslogEntry",event:e}),this._transactions.addToBeginning({index:0,id:e.id,author:e.author,timestamp:e.timestamp,draftEffect:e.effects[this.draftId],publishedEffect:e.effects[this.publishedId]})}didReachEarliestEntry(){this._trace&&this._trace.push({type:"didReachEarliestEntry"}),this.reachedEarliestEntry=!0}updateChunks(){this._trace&&this._trace.push({type:"updateChunks"}),this._removeInvalidatedChunks(),this._addChunksFromTransactions(),this._createInitialChunk()}_removeInvalidatedChunks(){if(this._recreateTransactionsFrom){for(;this._chunks.length>0;){let e=this._chunks.last;if(this._recreateTransactionsFrom<e.end)this._chunks.removeFromEnd();else break}this._recreateTransactionsFrom=void 0}}_addChunksFromTransactions(){let e=this._transactions.firstIdx,t=this._transactions.lastIdx,n=this._chunks.length>0?this._chunks.last.end:e;for(let e=n;e<=t;e++){let t=this._transactions.get(e);this._chunks.mergeAtEnd(Ux(t),Um)}if(0==this._chunks.length)return;let i=this._chunks.first.start;for(let t=i-1;t>=e;t--){let e=this._transactions.get(t);this._chunks.mergeAtBeginning(Ux(e),Um)}}_invalidateTransactionFrom(e){(void 0===this._recreateTransactionsFrom||e<this._recreateTransactionsFrom)&&(this._recreateTransactionsFrom=e)}_createInitialChunk(){var e;if(this.reachedEarliestEntry){if((null==(e=this._chunks.first)?void 0:e.type)==="initial")return;let t=this._transactions.first;if(!t)return;let n=Ux(t);n.type="initial",n.id="@initial",n.end=n.start,this._chunks.addToBeginning(n)}}parseTimeId(e){if(0===this._chunks.length)return this.reachedEarliestEntry?"invalid":"loading";let t=e.split("/",3),n=t.shift(),i=t.shift(),r=Number(n);for(let e=this._chunks.lastIdx;e>=this._chunks.firstIdx;e--){let t=this._chunks.get(e);if(t.id===i)return t;if(Date.parse(t.endTimestamp)+36e5<r)return"invalid"}return this.reachedEarliestEntry?"invalid":"loading"}findLastPublishedBefore(e){for(let t=e?e.index-1:this._chunks.lastIdx;t>=this._chunks.firstIdx;t--){let e=this._chunks.get(t);if("publish"===e.type||"initial"===e.type)return e}return this.reachedEarliestEntry?this._chunks.first:"loading"}isLatestChunk(e){return e===this._chunks.last}createTimeId(e){return"".concat(e.endTimestamp.valueOf(),"/").concat(e.id)}lastChunk(){return this._chunks.last}transactionByIndex(e){return this._transactions.has(e)?this._transactions.get(e):null}chunkByTransactionIndex(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t;for(;;){let t=this._chunks.get(n);if(!t)throw Error("transaction does not belong in any chunk");if(e>=t.end)n++;else{if(!(e<t.start))return t;n--}}}replayBackwardsBetween(e,t,n){let i=n.draft,r=n.published;for(let n=t;n>=e;n--){let e=this._transactions.get(n);e.draftEffect&&(i=(0,dn.a)(i,e.draftEffect.revert)),e.publishedEffect&&(r=(0,dn.a)(r,e.publishedEffect.revert))}return{draft:i,published:r}}replayBackwardsUntil(e,t){return this.replayBackwardsBetween(e,this._transactions.lastIdx,t)}calculateDiff(e,t,n,i){var r,l;let a=dn.v.wrap(e.draft,null),o=dn.v.wrap(e.published,null),s=(r=a,l=o,"null"===dn.v.getType(r)?l:r),d=Ue(e),c=null;for(let e=n;e<=i;e++){let t=this._chunks.get(e);c||(c=t);for(let e=t.start;e<t.end;e++){let n=this._transactions.get(e),i={chunk:t,transactionIndex:e},r=a,l=o;n.draftEffect&&(a=dn.v.applyPatch(a,n.draftEffect.apply,i)),n.publishedEffect&&(o=dn.v.applyPatch(o,n.publishedEffect.apply,i));let s="null"!==dn.v.getType(r),d="null"!==dn.v.getType(a),c="null"!==dn.v.getType(o);c&&!d&&(o=dn.v.rebaseValue(r,o)),d&&!s&&(a=dn.v.rebaseValue(l,a))}}let u="null"===dn.v.getType(a)?o:a,p=Ue(t);return function(e,t,n,i,r,l){let a=Uo(n,i,{fromValue:n=>Us(e,t,n.endMeta),fromMeta:n=>Us(e,t,n)}),o=Uo(r,l,{fromValue:t=>Ud(e,t.startMeta),fromMeta:t=>Ud(e,t)});return(0,di.t)(a,o)}(this,c,s,d,u,p)}}let UC=Object.create(null),U_=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=Array.isArray(t)?t:[t],{time:r,revision:l}=n;if(r&&l)throw Error("getHistory can't handle both time and revision parameters");let a=e.config().dataset,o="/data/history/".concat(a,"/documents/").concat(i.join(","));if(l)o="".concat(o,"?revision=").concat(l);else{let e=r||new Date().toISOString();o="".concat(o,"?time=").concat(e)}return e.request({url:o})},US=(e,t,n)=>{let i=ci(t),r=cn(t),l="".concat(i,"@").concat(n),a=UC[l];if(a)return a;let o=e.config().dataset,s="/data/history/".concat(o,"/documents/").concat(i,",").concat(r,"?revision=").concat(n),d=e.request({url:s}).then(e=>{let t=e.documents||[],n=t.find(e=>e._id===i),l=t.find(e=>e._id===r);return l||n});return UC[l]=d,d},UT=e=>{let{client:t,documentId:n,documentType:i}=e,r=new Uk({enableTrace:be,publishedId:n});return new V7({client:t,documentId:n,documentType:i,timeline:r})},UE=async(e,t)=>{let n=Array.isArray(t)?t:[t],i=e.config().dataset,r="/data/history/".concat(i,"/transactions/").concat(n.join(",")),l=await e.request({url:r,query:{excludeContent:"true",includeIdentifiedDocumentsOnly:"true"}}
1),a=l.toString("utf8").split("\n").filter(Boolean).map(e=>JSON.parse(e));return a},UP=e=>(0,s9.u4)(e,(e,t)=>(0,lV.Yk)(t)&&!e.includes(t._ref)?[...e,t._ref]:e,[]),UA=(e,t)=>(function e(t,n){return Array.isArray(t)?n(t.map(t=>e(t,n)).filter(e=>void 0!==e)):cc(t)?n(Object.keys(t).reduce((i,r)=>{let l=e(t[r],n);return void 0!==l&&(i[r]=l),i},{})):n(t)})(e,e=>(0,lV.Yk)(e)?t(e):e),UO=(e,t)=>UA(e,e=>{let n=t[e._ref];return n?e:void 0}),Uz={chunks:[],diff:null,hasMoreChunks:!1,isLoading:!1,onOlderRevision:!1,realRevChunk:null,revTime:null,selectionState:"inactive",sinceAttributes:null,sinceTime:null,timelineDisplayed:null,timelineReady:!1};function UM(e){let{documentId:t,documentType:n,onError:i,rev:r,since:l}=e,a=UG(),o=(0,lK.useRef)(null),s=(0,lK.useRef)(Uz),d=Ni(fC),c=(0,lK.useMemo)(()=>a.getTimelineController({client:d,documentId:t,documentType:n}),[d,t,n,a]),u=(0,lK.useMemo)(()=>new ar.X(c),[c]);(0,lK.useEffect)(()=>(c.setRange(l||null,r||null),u.next(c),c.handler=(e,t)=>{e?u.error(e):setTimeout(()=>{t.setRange(l||null,r||null),u.next(t)},0)},c.resume(),()=>c.suspend()),[r,l,c,u]),(0,lK.useEffect)(()=>(o.current||(o.current=N8(d,{draftId:"drafts.".concat(t),publishedId:t},n).subscribe(e=>{c.handleRemoteMutation(e)})),()=>{o.current&&(o.current.unsubscribe(),o.current=null)}),[d,c,t,n]);let p=(0,lK.useMemo)(()=>({findRangeForRev:e=>c.findRangeForNewRev(e),findRangeForSince:e=>c.findRangeForNewSince(e),loadMore:()=>{c.setLoadMore(!0),s.current.isLoading=!0},getSnapshot:()=>s.current,subscribe:e=>{let t=u.pipe((0,as.b)(e=>e.setLoadMore(!1)),(0,ad.U)(e=>({chunks:e.timeline.mapChunks(e=>e),diff:e.sinceTime?e.currentObjectDiff():null,isLoading:!1,hasMoreChunks:!e.timeline.reachedEarliestEntry,onOlderRevision:e.onOlderRevision(),realRevChunk:e.realRevChunk,revTime:e.revTime,selectionState:e.selectionState,sinceAttributes:e.sinceAttributes(),sinceTime:e.sinceTime,timelineDisplayed:e.displayed(),timelineReady:!["invalid","loading"].includes(e.selectionState)})),(0,ac.x)(lW()),(0,au.K)(e=>(null==i||i(e),(0,lQ.of)(Uz))),(0,as.b)(e=>{s.current=e}),(0,as.b)(e)).subscribe();return()=>t.unsubscribe()}}),[c,i,u]);return p}function UI(e,t){return(0,dr.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,null,t)}let UR=[["nested","first"],["nested","second"],["nestedArray",{_key:"565c867c8dac"},"arrayNo1",{_key:"a645548a8f01"},"arrayNo1",{_key:"1685e372c40f"},"fieldNo0"],["nestedArray",{_key:"565c867c8dac"},"fieldNo0"],["nestedArray",{_key:"565c867c8dac"},"arrayNo19",{_key:"a02e7a93e2a2"},"fieldNo0"],["nestedArray",{_key:"565c867c8dac"},"arrayNo19",{_key:"a02e7a93e2a2"},"fieldNo19"],["address","country"],["address","street"],["customInputWithDefaultPresence","row3","cell3"]],UF=(0,l4.P)(()=>(0,l6.H)(0,1e4)).pipe((0,ax.j)(["pqSMwf6hH","pnLYqNfv5","priDVVmy8","p0NFOU0j8","pTDl2jw8d","pHMeQnTse","pDQYzJbyS","pZyoPHKUs","p4Tyi2Be5","pb9vii060","pE8yhOisw","p7Fd2C6Cj","p3exSgYCx","pbIQRYViC","p8GJaTEhN","p27ewL8aM","pYg97z75S","pdLr4quHv","pkJXiDgg6","pkl4UAKcA","pNoExists"]),(0,ad.U)((e,t)=>({type:"state",userId:e,sessionId:e+t,timestamp:new Date().toISOString(),locations:[{type:"document",documentId:"presence-debug",lastActiveAt:new Date().toISOString(),path:ds()(UR)}]})),(0,am.d)()),UD=e=>{if("rollCall"===e.type)return{type:"rollCall",userId:e.i,sessionId:e.session};if("state"===e.type){let{sessionId:t,locations:n}=e.m;return{type:"state",userId:e.i,sessionId:t,timestamp:new Date().toISOString(),locations:n}}if("disconnect"===e.type)return{type:"disconnect",userId:e.i,sessionId:e.m.session,timestamp:new Date().toISOString()};throw Error("Got unknown presence event: ".concat(JSON.stringify(e)))},UZ=(e,t)=>{let n=e.request("presence").pipe((0,ad.U)(UD));return[n.pipe((0,a_.B)()),n=>"rollCall"===n.type?e.request("presence_rollcall",{session:t}):"state"===n.type?e.request("presence_announce",{data:{locations:n.locations,sessionId:t}}):"disconnect"===n.type?e.request("presence_disconnect",{session:t}):l7.E]},UL="presence_session_id",Uq=function(){try{return window.sessionStorage.getItem(UL)}catch(e){}return null}()||function(e){try{window.sessionStorage.setItem(UL,e)}catch(e){}return e}((0,dl.x0)(16));function UN(e){let t=UQ(),[n,i]=(0,lK.useState)([]);return(0,lK.useEffect)(()=>{let n=t.documentPresence(e).subscribe(i);return()=>{n.unsubscribe()}},[e,t]),n}let UV=(e,t)=>{try{return JSON.parse(e)}catch(e){return console.warn("Failed to parse settings: ".concat(e.message)),t}},UU={get:(e,t)=>{let n=localStorage.getItem(e);return(0,lQ.of)(null===n?t:UV(n,t))},set:(e,t)=>(null==t?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t)),(0,lQ.of)(t))},UB=Object.create(null),UK={get:(e,t)=>(0,lQ.of)(e in UB?UB[e]:t),set:(e,t)=>(null==t?delete UB[e]:UB[e]=t,(0,lQ.of)(t))},UH=null,UW=[{id:"<system>",displayName:"Sanity",imageUrl:"https://public.sanity.io/logos/favicon-192.png"}];function U$(){let{getClient:e,currentUser:t}=Iw(),n=p4(),i=e(fC);return(0,lK.useMemo)(()=>{let e=n.get({namespace:"userStore",dependencies:[i,t]})||function(e){let{client:t,currentUser:n}=e,i=t.withConfig({apiVersion:"2021-06-07"}),r=new(dc())(async e=>{let t=await i.request({uri:"/users/".concat(e.join(",")),withCredentials:!0,tag:"users.get"}),n=Array.isArray(t)?t:[t],r=n.reduce((e,t)=>
1((null==t?void 0:t.id)&&(e[t.id]=t),e),{});return e.map(e=>r[e]||null)},{batchScheduleFn:e=>dp()(e)}),l=n&&{id:n.id,displayName:n.name,imageUrl:n.profileImage};return r.prime("me",l),(null==l?void 0:l.id)&&r.prime(l.id,l),UW.forEach(e=>r.prime(e.id,e)),{getUser:async e=>{try{return await r.load(e)}catch(e){if(403===e.statusCode)return Promise.resolve(null);throw e}},getUsers:async e=>{let t=await r.loadMany(e);return t.filter(e=>cc(e)&&"string"==typeof e.id)}}}({client:i,currentUser:t});return n.set({namespace:"userStore",dependencies:[i,t],value:e}),e},[i,t,n])}function UX(){let{getClient:e}=Iw(),t=e(fC),n=Nj(),i=p4();return(0,lK.useMemo)(()=>{let e=i.get({namespace:"grantsStore",dependencies:[t,n]})||function(e){let{client:t,currentUser:n}=e,i=t.withConfig({apiVersion:"2021-06-07"}),r=(0,l4.P)(()=>(0,lQ.of)(i.config())).pipe((0,ap.w)(e=>{let{projectId:t,dataset:n}=e;if(!t||!n)throw Error("Missing projectId or dataset");return VB(i,t,n)})),l=VU.pipe((0,ap.w)(e=>e?(0,lQ.of)(e):r),(0,aO._)(1),(0,dt.f)(1e3));return{checkDocumentPermission:(e,t)=>l.pipe((0,ap.w)(i=>VW(n,i,e,t)),(0,ac.x)(aQ()))}}({client:t,currentUser:n});return i.set({namespace:"grantsStore",dependencies:[t,n],value:e}),e},[t,n,i])}function UG(){let e=Ni(fC),t=p4();return(0,lK.useMemo)(()=>{let n=t.get({namespace:"historyStore",dependencies:[e]})||function(e){let{client:t}=e;return{getDocumentAtRevision:(e,n)=>US(t,e,n),getHistory:(e,n)=>U_(t,e,n),getTransactions:e=>UE(t,e),restore:(e,n,i)=>(0,at.D)(US(t,e,i)).pipe((0,ay.z)(n=>{if(!n)throw Error("Unable to find document with ID ".concat(e," at revision ").concat(i));let r=UP(n).map(e=>'"'.concat(e,'": defined(*[_id=="').concat(e,'"]._id)')).join(",");return t.observable.fetch("{".concat(r,"}")).pipe((0,ad.U)(e=>UO(n,e)))}),(0,ad.U)(e=>{let{_updatedAt:t,...i}=e;return{...i,_id:n}}),(0,ay.z)(e=>t.observable.createOrReplace(e,{visibility:"async"}))),getTimelineController:UT}}({client:e});return t.set({namespace:"historyStore",dependencies:[e],value:n}),n},[e,t])}function UY(){let e=Ni(fC),t=p4();return(0,lK.useMemo)(()=>{let n=t.get({namespace:"documentPreviewStore",dependencies:[e]})||function(e){let{client:t}=e,n=t.withConfig({apiVersion:"1"}),{observeFields:i}=function(e){let t;let{observePaths:n,versionedClient:i}=e,r=()=>{if(!t){let e=(0,at.D)(i.listen('*[!(_id in path("_.**"))]',{},{events:["welcome","mutation"],includeResult:!1,visibility:"query",tag:"preview.global"})).pipe((0,a_.B)()),n=e.pipe((0,af.h)(e=>"welcome"===e.type),(0,am.d)({refCount:!0,bufferSize:1}));n.subscribe();let r=e.pipe((0,af.h)(e=>"mutation"===e.type));t={welcome$:n,mutations$:r}}return t};function l(e){return function(t){let n=s8()(t.reduce((e,t,n)=>{let[i,r]=t,l=aX()(r.join(","),s5()).join(".");e[l]||(e[l]={fields:r,ids:[],map:[]});let a=e[l].ids.length;return e[l].ids[a]=i,e[l].map[a]=n,e},{}));return e.observable.fetch("[".concat(n.map(mu).join(","),"][0...").concat(n.length,"]"),{},{tag:"preview.document-paths"}).pipe((0,ad.U)(e=>e.reduce((e,t,i)=>{let r=n[i].map;return r.forEach((r,l)=>{let a=n[i].ids[l],o=t.find(e=>e._id===a);e[r]=o||null}),e},[])))}}let a=ma(l(i),100),o=ma(l(i),1e3),s={},d=oe()(function(e){let t=i.withConfig(e),n=l(t);return ma(n,10)},e=>e.dataset+e.projectId),c=(0,l1.R)(document,"visibilitychange").pipe((0,ag.O)(0),(0,ad.U)(()=>"visible"===document.visibilityState),(0,ap.w)(e=>e?(0,l6.H)(0,1e4):l7.E),(0,a_.B)());return{observeFields:function(e,t,n){let i=n?"".concat(n.projectId,":").concat(n.dataset,":").concat(e):"$current$-".concat(e);i in s||(s[i]=[]);let l=s[i],u=s3()(t,om()(l.map(e=>e.fields)));u.length>0&&l.push(function(e,t,n){let i=null,l=(0,l3.T)((0,l4.P)(()=>null===i?l7.E:(0,lQ.of)(i)),n?c.pipe((0,ag.O)(0)).pipe((0,ap.w)(()=>{let i=d(n);return i(e,t)})):(function(e){let t=r();return(0,l3.T)(t.welcome$,t.mutations$.pipe((0,af.h)(t=>t.documentId===e)))})(e).pipe((0,ap.w)(n=>"welcome"===n.type||"query"===n.visibility?a(e,t).pipe((0,ay.z)(n=>(0,l0.z)((0,lQ.of)(n),void 0===n?o(e,t):[]))):o(e,t)))).pipe((0,as.b)(e=>i=e),(0,am.d)({refCount:!0,bufferSize:1}));return{id:e,fields:t,changes$:l}}(e,t,n));let p=l.filter(e=>e.fields.some(e=>t.includes(e))).map(e=>e.changes$);return(0,ae.a)(p).pipe((0,ad.U)(e=>e.filter(Boolean)),(0,af.h)(e=>(function(e){let t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mp;for(let r=0;r<e.length;r++){if(0===r){t=i(e[r]);continue}if(t!==(n=i(e[r])))return!1;t=n}return!0})(e,e=>e._rev)),(0,ad.U)(e=>0===e.length?null:[...fQ,...t].reduce((t,n)=>{let i;let r=(e.some(e=>n in e&&(i=e[n],!0)),i);return void 0!==r&&(t[n]=r),t},{})),(0,ac.x)((e,n)=>e===n||!!e&&!!n&&"object"==typeof e&&"object"==typeof n&&t.every(t=>e[t]===n[t])))}}}({observePaths:(e,t,n)=>r(e,t,n),versionedClient:n}),{observePaths:r}=function(e){let{observeFields:t}=e;return{observePaths:(e,n,i)=>(function e(t,n,i,r){if(!t||"object"!=typeof t)return(0,lQ.of)(t);let l=(0,lV.Yk)(t)?t._ref:"_id"in t?t._id:void 0,a=l?{...t,_id:l}:{...t};"reference"===a._type&&(delete a._type,delete a._ref,delete a._weak,delete a._dataset,delete a._projectId,delete a._strengthenOnPublish);let o=n.filter(e=>!(e[0]in a));if(l&&o.length>0){let a=sa()(o.map(e=>e[0])),s=(0,lV.Yz)(t)?{projectId:t._projectId,dataset:t._dataset}:r;return i(l,a,s).pipe((0,ap.w)(r=>null===r?(0,lQ.of)(null):e({...a.reduce((e,t)=>
1(e[t]=void 0,e),{}),...(0,lV.Yk)(t)?{...t,...s}:t,...r},n,i,s)))}let s={};n.forEach(e=>{let[t,...n]=e;s[t]||(s[t]=[]),s[t].push(n)});let d=Object.keys(s).reduce((n,l)=>{let a=s[l].filter(e=>e.length>0);return 0===a.length?n[l]=cc(t)?t[l]:void 0:n[l]=e(t[l],a,i,r),n},a);return(0,lQ.of)(d).pipe(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new l9.y(e=>t.subscribe(e)).pipe((0,ap.w)(t=>{let n=f4(t).map(e=>{let n=t[e];return(0,an.b)(n)?(0,at.D)(n).pipe((0,ad.U)(t=>[e,t])):(0,lQ.of)([e,n])});return e.wait?(0,ae.a)(n).pipe((0,ad.U)(e=>e.reduce((e,t)=>{let[n,i]=t;return{...e,[n]:i}},{}))):(0,at.D)(n).pipe((0,aj.J)(),(0,ah.R)((e,t)=>{let[n,i]=t;return{...e,[n]:i}},{}))}))}({wait:!0}))})(e,n.map(e=>"string"==typeof e?e.split("."):e),t,i)}}({observeFields:i});function l(e,t){return r({_type:"reference",_ref:e},["_type"],t).pipe((0,ad.U)(e=>cc(e)&&"string"==typeof e._type?e._type:void 0),(0,ac.x)())}let a=function(e){let{observeDocumentTypeFromId:t,observePaths:n}=e;return function e(i,r,l,a){if((0,lV.mz)(r)){if(!(0,lV.Yz)(i))return(0,lQ.of)({snapshot:void 0});let n={projectId:i._projectId,dataset:i._dataset};return t(i._ref,n).pipe((0,ap.w)(t=>{if(t){let l=r.to.find(e=>e.type===t);return e(i,l,{},n)}return(0,lQ.of)({snapshot:void 0})}))}if((0,lV.dD)(r))return sD()(i)?t(i._ref).pipe((0,ap.w)(t=>{if(t){let n=r.to.find(e=>e.name===t);return e(i,n)}return(0,lQ.of)({snapshot:void 0})})):(0,lQ.of)({snapshot:void 0});let o=fW(r.preview);return o?n(i,o,a).pipe((0,ad.U)(e=>({type:r,snapshot:e&&ml(e,r,l)}))):(0,lQ.of)({type:r,snapshot:i&&sD()(i)?mi(r,i,l).returnValue:null})}}({observeDocumentTypeFromId:l,observePaths:r}),{observeDocumentPairAvailability:o}=ms(n,r),{observePathsDocumentPair:s}=function(e,t){let{observeDocumentPairAvailability:n}=ms(e,t),i=[["_updatedAt"],["_createdAt"],["_type"]];return{observePathsDocumentPair:function(e,r){let{draftId:l,publishedId:a}=ct(e);return n(l).pipe((0,ap.w)(e=>{if(!e.draft.available&&!e.published.available)return(0,lQ.of)({id:a,type:null,draft:{availability:e.draft,snapshot:void 0},published:{availability:e.published,snapshot:void 0}});let n=[...r,...i];return(0,ae.a)([t({_type:"reference",_ref:l},n),t({_type:"reference",_ref:a},n)]).pipe((0,ad.U)(t=>{let[n,i]=t,r=cc(n)&&"_type"in n&&n._type||cc(i)&&"_type"in i&&i._type||null;return{id:a,type:"string"==typeof r?r:null,draft:{availability:e.draft,snapshot:n},published:{availability:e.published,snapshot:i}}}))}))}}}(n,r);return{observePaths:r,observeForPreview:a,observeDocumentTypeFromId:l,unstable_observeDocumentPairAvailability:o,unstable_observePathsDocumentPair:s}}({client:e});return t.set({namespace:"documentPreviewStore",dependencies:[e],value:n}),n},[e,t])}function UJ(){let e=Iw().getClient,t=Nu(),n=Nm(),i=p4(),r=UG(),l=UY();return(0,lK.useMemo)(()=>{let a=i.get({namespace:"documentStore",dependencies:[e,l,r,t]})||function(e){let{getClient:t,documentPreviewStore:n,historyStore:i,initialValueTemplates:r,schema:l}=e,a=n.unstable_observeDocumentPairAvailability,o=t(fC),s={client:o,getClient:t,observeDocumentPairAvailability:a,historyStore:i,schema:l};return{checkoutPair:e=>NM(o,e),initialValue:(e,t)=>(function(e,t,n,i,r){let l=n.observePaths({_type:"reference",_ref:cn(i.documentId)},["_type"]),a=n.observePaths({_type:"reference",_ref:ci(i.documentId)},["_type"]),o=(0,l3.T)(l.pipe((0,ad.U)(e=>({draft:e}))),a.pipe((0,ad.U)(e=>({published:e})))).pipe((0,ah.R)((e,t)=>({...e,...t}),{}),(0,af.h)(e=>"draft"in e&&"published"in e),(0,ad.U)(e=>e.draft||e.published),(0,ac.x)((e,t)=>!!e!=!!t),(0,aZ.b)(25));return o.pipe((0,ap.w)(n=>{if(n)return(0,lQ.of)({type:"success",value:null});if(!i.templateName)return(0,lQ.of)({isResolving:!1,initialValue:void 0});let l=t.find(e=>e.id===i.templateName);if(!l)return console.warn('Template "%s" not defined, using empty initial value',i.templateName),(0,lQ.of)({isResolving:!1,initialValue:void 0});let a=(0,at.D)(Vx(e,l,i.templateParams,r)).pipe((0,ad.U)(e=>({isResolving:!1,initialValue:e}))).pipe((0,au.K)(e=>(console.group("Failed to resolve initial value"),console.error(e),console.error("Template ID: %s",i.templateName),console.error("Parameters: %o",i.templateParams),console.groupEnd(),(0,lQ.of)({type:"error",error:e}))));return(0,l3.T)((0,lQ.of)({isResolving:!0}),a).pipe((0,ap.w)(e=>{let{isResolving:t,initialValue:n,resolveError:i}=e;return i?(0,lQ.of)({type:"error",message:"Failed to resolve initial value"}):t?(0,lQ.of)(Vw):(0,lQ.of)({type:"success",value:n})}
1))}),(0,ag.O)(Vw),(0,ac.x)())})(l,r,n,e,t),listenQuery:(e,t,n)=>(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r="string"==typeof t?t:t.fetch,l="string"==typeof t?t:t.listen,a=Vc(e,l,n,i).pipe((0,ay.z)((e,t)=>0!==t||Vu(e)?(0,lQ.of)(e):(0,l5._)(()=>Error("reconnect"===e.type?"Could not establish EventSource connection":'Received unexpected type of first event "'.concat(e.type,'"')))),(0,a_.B)()),[o,s]=(0,ao.u)(a,Vu),d=()=>Vd(e,r,n,i);return(0,l3.T)(o.pipe((0,ab.q)(1)),s.pipe((0,af.h)(e=>!i.transitions||"mutation"!==e.type||i.transitions.includes(e.transition)),(0,aF.p)(i.throttleTime||1e3,al.z,{leading:!0,trailing:!0}))).pipe((0,s7.q)(e=>"mutation"===e.type&&"query"!==e.visibility?(0,l6.H)(1200).pipe((0,ay.z)(d)):d()))})(o,e,t,n),resolveTypeForDocument:(e,t)=>(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"*";if(n&&"*"!==n)return(0,lQ.of)(n);let i=ci(t),r=cn(i);return e.observable.fetch("*[_id in [$documentId, $draftId]]._type",{documentId:i,draftId:r}).pipe((0,ad.U)(e=>e[0]))})(o,e,t),pair:{consistencyStatus:(e,t)=>N0(s.client,Vk(e),t),documentEvents:(e,t)=>Vn(s.client,Vk(e),t),editOperations:(e,t)=>Vs(s,Vk(e),t),editState:(e,t)=>NU(s,Vk(e),t),operationEvents:(e,t)=>N6({client:o,historyStore:i,schema:l}).pipe((0,af.h)(n=>n.args.idPair.publishedId===e&&n.args.typeName===t),(0,ad.U)(e=>{let{operationName:t,idPair:n}=e.args;return"success"===e.type?{type:"success",op:t,id:n.publishedId}:{type:"error",op:t,id:n.publishedId,error:e.error}})),validation:(e,t)=>Vt(s,Vk(e),t)}}}({getClient:e,documentPreviewStore:l,historyStore:r,initialValueTemplates:n,schema:t});return i.set({namespace:"documentStore",dependencies:[e,l,r,t],value:a}),a},[e,l,r,i,t,n])}function UQ(){let{__internal:{bifur:e}}=Iw(),t=p4(),n=U$(),i=function(){let{bifur:e}=Iw().__internal,t=p4();return(0,lK.useMemo)(()=>{let n=t.get({namespace:"connectionStatusStore",dependencies:[e]})||function(e){var t;let{bifur:n}=e,i=(0,l3.T)(n.heartbeats,hj.pipe((0,ax.j)((0,l5._)(Error("The browser went offline"))))).pipe((0,ad.U)(e=>({type:"connected",lastHeartbeat:e})),(t=(e,t,n)=>{let i=Math.min(24e4,hw(t)),r=new Date(new Date().getTime()+i),l=(0,l6.H)(r),a=!navigator.onLine,o=hS({error:e,retryAt:r,isOffline:a,attemptNo:t}),s=l8.C.pipe((0,av.R)(a?hy:(0,l3.T)(l,hy,h_)));return(0,l0.z)((0,lQ.of)(o),s.pipe((0,ab.q)(1)),n)},e=>{let n=[],i=(0,au.K)((e,r)=>(n.push(e),t(e,n.length,r).pipe(i)));return e.pipe((0,as.b)(()=>{n=[]}),i)}),(0,ag.O)(hk));return{connectionStatus$:i}}({bifur:e});return t.set({namespace:"connectionStatusStore",dependencies:[e],value:n}),n},[e,t])}();return(0,lK.useMemo)(()=>{let r=t.get({namespace:"presenceStore",dependencies:[e,i,n]})||function(e){let{bifur:t,connectionStatusStore:n,userStore:i}=e,[r,l]=UZ(t,Uq),a=new ar.X([]),o=a.pipe((0,ac.x)()),s=e=>l({type:"state",locations:e}),d=()=>l({type:"rollCall"}),c=r.pipe((0,af.h)(e=>"rollCall"===e.type),(0,af.h)(e=>e.sessionId!==Uq)),u=(0,l6.H)(0,3e4),p=(0,l4.P)(()=>(0,l3.T)(o,c)).pipe((0,ap.w)(()=>u),(0,aM.M)(a),(0,ad.U)(e=>{let[,t]=e;return t}),(0,aL.e)(200),(0,ap.w)(e=>s(e)),(0,ax.j)(l7.E),(0,a_.B)()),h=(0,l4.P)(()=>d()).pipe((0,ax.j)(l7.E)),f=n.connectionStatus$.pipe((0,ad.U)(e=>e.type),(0,af.h)(e=>"connected"===e||"error"===e),(0,ac.x)()),m=VZ.pipe((0,ad.U)(e=>e.find(e=>e.startsWith("presence="))),(0,ad.U)(e=>(null==e?void 0:e.split("presence=")[1].split(",").map(e=>e.trim()))||[])),g=m.pipe((0,af.h)(e=>e.includes("fake_others")),(0,as.b)(()=>{console.log('Faking other users present in the studio. They will hang out in the document with _type: "presence" and _id: "presence-debug"')}),(0,aq.c)(UF)),x=m.pipe((0,ad.U)(e=>e.includes("show_own"))),v=(0,l3.T)(h,r).pipe((0,af.h)(e=>"state"===e.type||"disconnect"===e.type)),b=e=>({lastActiveAt:e.timestamp,locations:e.locations,sessionId:e.sessionId,userId:e.userId}),y=(0,l3.T)(v,g).pipe((0,ah.R)((e,t)=>"disconnect"===t.type?sm()(e,t.sessionId):{...e,[t.sessionId]:b(t)},{})),j=f.pipe((0,ap.w)(e=>"connected"===e?(0,l3.T)(y,p):l8.C),(0,ad.U)(e=>Object.values(e)),(0,ap.w)(e=>{let t=sa()(e.map(e=>
1e.userId));return(0,at.D)(i.getUsers(t)).pipe((0,ad.U)(t=>e.map(e=>({user:t.find(t=>t.id===e.userId),session:e})).filter(w)))}),(0,av.R)((0,l1.R)(window,"beforeunload").pipe((0,ap.w)(()=>l({type:"disconnect"})))),(0,am.d)({refCount:!0,bufferSize:1}));function w(e){return!!(e.user&&e.session)}let k=j.pipe((0,ad.U)(e=>{let t=sS()(e.map(e=>e.session),e=>e.userId);return Object.keys(t).map(n=>{var i;return{user:null==(i=e.find(e=>e.user.id===n))?void 0:i.user,sessions:t[n]}})}),(0,aM.M)(x),(0,ad.U)(e=>{let[t,n]=e;return t.filter(e=>{if(n)return!0;let t=e.sessions.some(e=>e.sessionId===Uq);return!t})}),(0,ad.U)(e=>e.map(e=>{var t;return{user:e.user,status:"online",lastActiveAt:null==(t=e.sessions.sort()[0])?void 0:t.lastActiveAt,locations:om()((e.sessions||[]).map(e=>e.locations||[])).map(e=>({type:e.type,documentId:e.documentId,path:e.path,lastActiveAt:e.lastActiveAt})).reduce((e,t)=>e.concat(t),[])}})));return{setLocation:e=>{a.next(e)},reportLocations:s,debugPresenceParam$:m,globalPresence$:k,documentPresence:e=>j.pipe((0,aM.M)(x),(0,ap.w)(t=>{let[n,i]=t;return(0,at.D)(n).pipe((0,af.h)(e=>i||e.session.sessionId!==Uq),(0,aN.V)(t=>(t.session.locations||[]).filter(t=>t.documentId===e).map(e=>({user:t.user,lastActiveAt:t.session.lastActiveAt,path:e.path||[],sessionId:t.session.sessionId}))),(0,aw.q)())}))}}({bifur:e,connectionStatusStore:i,userStore:n});return t.set({namespace:"presenceStore",dependencies:[e,i,n],value:r}),r},[e,i,t,n])}function U0(){let e=p4(),t=Ib();return(0,lK.useMemo)(()=>{let n=e.get({dependencies:[t],namespace:"settingsStore"})||function(){let e=!function(){if(null!==UH)return UH;let e="__test__";try{localStorage.setItem(e,e),localStorage.removeItem(e),UH=!0}catch(e){UH=!1}return UH}()?UK:UU,t=new l2.x,n=(e,t)=>"".concat(e,"::").concat(t),i=t.pipe((0,ap.w)(t=>e.set(t.key,t.value).pipe((0,ad.U)(e=>({key:t.key,value:e}))))),r=(t,n)=>(0,l3.T)(e.get(t,n),i.pipe((0,af.h)(e=>e.key===t),(0,ad.U)(e=>e.value))),l=(e,n)=>{t.next({key:e,value:n})},a=e=>({forKey:t=>{let i=n(e,t);return{listen:e=>r(i,e),set:e=>l(i,e),del:()=>l(i,void 0)}},listen:(t,i)=>r(n(e,t),i),set:(t,i)=>l(n(e,t),i),del:t=>l(n(e,t),void 0),forNamespace:t=>a(n(e,t))});return{forNamespace:a}}();return e.set({dependencies:[t],namespace:"settingsStore",value:n}),n},[e,t])}let U1=/[^\p{Alpha}\p{White_Space}]/gu,U2=/\p{White_Space}+/u,U3={small:0,medium:1,large:2};function U4(e){let{user:t,...n}=e;return cc(t)?n.withTooltip?(0,lU.jsx)(U5,{...n,user:t}):(0,lU.jsx)(U6,{...n,user:t}):(0,lU.jsx)(U8,{...e,user:t})}function U5(e){let{user:{displayName:t}}=e;return(0,lU.jsx)(lY.u,{content:(0,lU.jsx)(lY.xu,{padding:2,children:(0,lU.jsx)(lY.xv,{size:1,children:t})}),placement:"top",portal:!0,children:(0,lU.jsx)("div",{style:{display:"inline-block"},children:(0,lU.jsx)(U6,{...e})})})}let U6=(0,lK.forwardRef)(function(e,t){let{user:n,animateArrowFrom:i,position:r,size:l,status:a,tone:o}=e,[s,d]=(0,lK.useState)(null),c=function(e){let t=gw();return(0,lJ.m2)(e?t.listen(e):(0,l7.c)(),[e],t.get(null))}(n.id),u=s?void 0:null==n?void 0:n.imageUrl;return(0,lU.jsx)(lY.qE,{animateArrowFrom:i,arrowPosition:r,color:c.name,"data-legacy-tone":o,initials:(null==n?void 0:n.displayName)&&function(e){let t=e.replace(U1,"").split(U2);return 1===t.length?"".concat(t[0].charAt(0)).toUpperCase():"".concat(t[0].charAt(0)).concat(t[t.length-1].charAt(0))}(n.displayName),src:u,onImageLoadError:d,ref:t,size:"string"==typeof l?U3[l]:l,status:a,title:null==n?void 0:n.displayName})});function U8(e){let{user:t,...n}=e,[i]=Ny(t);return i?(0,lU.jsx)(U4,{...n,user:i}):null}let U9={name:"all-fields",title:"All fields",hidden:!1};function U7(e,t){return[...t.map((e,n)=>({type:"expandPath",path:t.slice(0,n+1)})),...Be(e,t)]}function Be(e,t){return 0===t.length?[]:(0,lV.m$)(e.schemaType)?function e(t,n){var i,r;if(0===n.length)return[];let[l,...a]=n,o=t._allMembers.find(e=>"fieldSet"===e.kind&&e.fieldSet.members.some(e=>"field"===e.kind&&e.name===l)),s=o?o.fieldSet.members:t._allMembers,d=s.find(e=>null!==e&&"field"===e.kind&&e.name===l),c=t.schemaType.fields.find(e=>e.name===l),u=null==(i=t.groups.find(e=>e.selected))?void 0:i.name,p=null==(r=(t.schemaType.groups||[]).find(e=>e.default))?void 0:r.name,h=u&&(u===U9.name||c&&sY()(c.group).includes(u)),f=[];return h||f.push({type:"setSelectedGroup",path:t.path,groupName:p||U9.name}
1),o&&f.push({type:"expandFieldSet",path:o.fieldSet.path}),d&&(ks(d)?f.push(...Bt(d.field,a)):ko(d)&&f.push(...e(d.field,a))),f}(e,t):(0,lV.M1)(e.schemaType)?Bt(e,t):[]}function Bt(e,t){if(0===t.length)return[];let[n,...i]=t;if(!(0,lV.Fd)(n))throw Error("Expected path segment to be an object with a _key property");let r=e.members.find(e=>e.key===n._key);return r?Be(r.item,i):[]}function Bn(e,t){let{currentUser:n,document:i,parent:r,value:l}=t;return"boolean"==typeof e||void 0===e?!!e:!0===e({document:i,parent:r,value:l,currentUser:n})}function Bi(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if((null==e?void 0:e.collapsible)===!1||(null==e?void 0:e.collapsable)===!1)return{collapsible:!1,collapsed:!1};let n="boolean"==typeof(null==e?void 0:e.collapsed)?e.collapsed:t>=3||void 0,i=(null==e?void 0:e.collapsible)===!0||(null==e?void 0:e.collapsable)===!0||!0===n||void 0;return{collapsible:i,collapsed:n}}function Br(e,t,n){return n.name===U9.name||void 0!==t&&(0===e.length&&n.name===U9.name||sY()(t).includes(n.name))}function Bl(e){return void 0===e||cc(e)}function Ba(e,t){return!(Array.isArray(e)&&void 0===t||Array.isArray(t)&&void 0===e)&&(!!e&&!t||!aU()(e,t))}function Bo(e){var t,n,i,r,l,a,o,s,d,c,u,p,h,f,m,g,x,v,b,y;let{parent:j,field:w,index:k}=e,C=(0,lB.s6)([...j.path,w.name]),_=(b=w.type,y=j.level+1,(0,lV.jB)(b)?function(e,t){var n;let{options:i}=e,r=(null==(n=(null==i?void 0:i.list)||[])?void 0:n.length)>0,l=kY.includes((null==i?void 0:i.layout)||"");return r&&!l?t:0}(b,y):function(e,t){var n,i,r;let{type:l,options:a}=e,o=function e(t,n){return(null==t?void 0:t.name)&&n.includes(null==t?void 0:t.name)?t:t?e(t.type,n):void 0}(l,kX),s=(null==e?void 0:e.jsonType)==="object"?e.fields:void 0,d=(null==o?void 0:o.name)||"";if(kJ.includes(d))return 0;let c=kX.includes(d),u=(null!=(n=null==s?void 0:s.filter(e=>!kG.includes(e.name)).length)?n:0)>0,p=(null!=(r=null==(i=null==a?void 0:a.list)?void 0:i.length)?r:0)>0;return u||p||!c?t:0}(b,y)),S=j.value,T=j.comparisonValue;if(!Bl(S))throw Error("Unexpected non-object value");let E=w.group?sY()(w.group):[],P=Br(j.groups,w.group,j.selectedGroup);if((0,lV.m$)(w.type)){let e=null==S?void 0:S[w.name],o=cc(T)?null==T?void 0:T[w.name]:void 0;if(!Bl(e))return{kind:"error",key:w.name,fieldName:w.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:w.type,resolvedValueType:(0,sy.wq)(e),value:e}};let s={value:e,parent:j.value,document:j.document,currentUser:j.currentUser},d=Bn(w.type.hidden,s);if(d)return{kind:"hidden",key:"field-".concat(w.name),name:w.name,index:k};let c=j.readOnly||Bn(w.type.readOnly,s),u=null==(n=null==(t=j.fieldGroupState)?void 0:t.children)?void 0:n[w.name],p=null==(r=null==(i=j.collapsedPaths)?void 0:i.children)?void 0:r[w.name],h=null==(a=null==(l=j.collapsedFieldSets)?void 0:l.children)?void 0:a[w.name],f=Bs({schemaType:w.type,currentUser:j.currentUser,parent:j.value,document:j.document,value:e,changed:Ba(e,o),comparisonValue:o,presence:j.presence,validation:j.validation,fieldGroupState:u,path:C,level:_,focusPath:j.focusPath,openPath:j.openPath,collapsedPaths:p,collapsedFieldSets:h,readOnly:c,changesOpen:j.changesOpen});if(null===f)return null;let m=Bi(w.type.options,_),g=p?p.value:m.collapsed;return{kind:"field",key:"field-".concat(w.name),name:w.name,index:k,inSelectedGroup:P,groups:E,open:(0,lB.Ny)(C,j.openPath),field:f,collapsed:g,collapsible:m.collapsible}}if((0,lV.jB)(w.type)){let e=null==S?void 0:S[w.name],t=cc(T)?null==T?void 0:T[w.name]:void 0;if((0,lV.M1)(w.type)){let n=void 0!==e;if(n&&!(void 0===e||Array.isArray(e))){let t=(0,sy.wq)(e);return{kind:"error",key:w.name,fieldName:w.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:w.type,resolvedValueType:t,value:e}}}if(n&&!(0===e.length||e.every(e=>cc(e))))return{kind:"error",key:w.name,fieldName:w.name,error:{type:"MIXED_ARRAY",schemaType:w.type,value:e}};if(n&&!(null==e?void 0:e.every(e=>cc(e)&&"_key"in e)))return{kind:"error",key:w.name,fieldName:w.name,error:{type:"MISSING_KEYS",value:e,schemaType:w.type}};let i=n?function(e){let t=new Set;return e.reduce((e,n,i)=>(t.has(n._key)&&e.push([i,n._key]),t.add(n._key),e),[])}(e):[];if(i.length>0)return{kind:"error",key:w.name,fieldName:w.name,error:{type:"DUPLICATE_KEYS",duplicates:i,schemaType:w.type}};let r=null==(s=null==(o=j.fieldGroupState)?void 0:o.children)?void 0:s[w.name],l=null==(c=null==(d=j.collapsedPaths)?void 0:d.children)?void 0:c[w.name],a=null==(p=null==(u=j.collapsedFieldSets)?void 0:u.children)?void 0:p[w.name],h=j.readOnly||Bn(w.type.readOnly,{value:e,parent:j.value,document:j.document,currentUser:j.currentUser}),f=function(e){if(20===e.level)return null;let t={value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser},n=Bn(e.schemaType.hidden,t);if(n)return null;
1let i=e.readOnly||Bn(e.schemaType.readOnly,t),r=Array.isArray(e.value)?e.value:[],l=e.presence.filter(t=>(0,lB.Xy)(t.path,e.path)),a=l.length?l:co,o=e.validation.filter(t=>(0,lB.Xy)(t.path,e.path)).map(e=>({level:e.level,message:e.item.message,path:e.path})),s=r.flatMap((t,n)=>(function(e){var t,n,i,r,l,a,o;let{arrayItem:s,parent:d,index:c}=e,u=function(e,t){let n=(0,sy.wq)(t);return"object"===n&&1===e.of.length?e.of[0]:e.of.find(e=>e.name===n)}(d.schemaType,s),p=s._key;if(!u){let e=(0,sy.wq)(s);return{kind:"error",key:p,index:c,error:{type:"INVALID_ITEM_TYPE",resolvedValueType:e,value:s,validTypes:d.schemaType.of}}}let h=(0,lB.s6)([...d.path,{_key:p}]),f=d.level+1,m={value:d.value,parent:e.parent,document:d.document,currentUser:d.currentUser},g=d.readOnly||Bn(d.schemaType.readOnly,m),x=null==(n=null==(t=d.fieldGroupState)?void 0:t.children)?void 0:n[p],v=null==(r=null==(i=d.collapsedPaths)?void 0:i.children)?void 0:r[p],b=null==(a=null==(l=d.collapsedFieldSets)?void 0:l.children)?void 0:a[p],y=Array.isArray(d.comparisonValue)&&d.comparisonValue.find(e=>e._key===s._key)||void 0,j=Bs({schemaType:u,level:f,document:d.document,value:s,comparisonValue:y,changed:Ba(s,y),path:h,focusPath:d.focusPath,openPath:d.openPath,currentUser:d.currentUser,collapsedPaths:v,collapsedFieldSets:b,presence:d.presence,validation:d.val
1idation,fieldGroupState:x,readOnly:g},!1),w=Bi(u.options,f),k=null!=(o=null==v?void 0:v.value)?o:w.collapsed;return{kind:"item",key:p,index:c,open:(0,lB.Ny)(h,d.openPath),collapsed:k,collapsible:!0,parentSchemaType:d.schemaType,item:j}})({arrayItem:t,parent:e,index:n}));return{changed:e.changed||s.some(e=>"item"===e.kind&&e.item.changed),value:e.value,readOnly:i,schemaType:e.schemaType,focused:(0,lB.Xy)(e.path,e.focusPath),focusPath:(0,lB.vC)(e.path,e.focusPath),path:e.path,id:(0,lB.BB)(e.path),level:e.level,validation:o,presence:a,members:s}}({schemaType:w.type,parent:j.value,currentUser:j.currentUser,document:j.document,value:e,changed:Ba(e,t),comparisonValue:t,fieldGroupState:r,focusPath:j.focusPath,openPath:j.openPath,presence:j.presence,validation:j.validation,collapsedPaths:l,collapsedFieldSets:a,level:_,path:C,readOnly:h});return null===f?null:{kind:"field",key:"field-".concat(w.name),name:w.name,index:k,open:(0,lB.Ny)(C,j.openPath),inSelectedGroup:P,groups:E,collapsible:!1,collapsed:!1,field:f}}{if(!(void 0===e||Array.isArray(e))){let t=(0,sy.wq)(e);return{kind:"error",key:w.name,fieldName:w.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:w.type,resolvedValueType:t,value:e}}}let n=null==(f=null==(h=j.fieldGroupState)?void 0:h.children)?void 0:f[w.name],i=null==(g=null==(m=j.collapsedPaths)?void 0:m.children)?void 0:g[w.name],r=null==(v=null==(x=j.collapsedFieldSets)?void 0:x.children)?void 0:v[w.name],l=j.readOnly||Bn(w.type.readOnly,{value:e,parent:j.value,document:j.document,currentUser:j.currentUser}),a=function(e){if(20===e.level)return null;let t={comparisonValue:e.comparisonValue,value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser},n=Bn(e.schemaType.hidden,t);if(n)return null;let i=e.readOnly||Bn(e.schemaType.readOnly,t),r=Array.isArray(e.value)?e.value:[],l=e.presence.filter(t=>(0,lB.Xy)(t.path,e.path)),a=l.length?l:co,o=e.validation.filter(t=>(0,lB.Xy)(t.path,e.path)).map(e=>({level:e.level,message:e.item.message,path:e.path})),s=r.flatMap((t,n)=>(function(e){var t,n;let{arrayItem:i,parent:r,index:l}=e,a=function(e,t){let n=(0,sy.wq)(t);return null==e?void 0:e.of.find(e=>e.name===n||e.jsonType===n)}(r.schemaType,i),o=(0,lB.s6)([...r.path,l]),s=null==(t=r.value)?void 0:t[l],d=null==(n=r.comparisonValue)?void 0:n[l],c=r.level+1,u="".concat((null==a?void 0:a.name)||"invalid-type","-").concat(String(l));if(!a)return{kind:"error",key:u,index:l,error:{type:"INVALID_ITEM_TYPE",validTypes:r.schemaType.of,resolvedValueType:(0,sy.wq)(a),value:s}};let p=r.readOnly||Bn(a.readOnly,{value:s,parent:r.value,document:r.document,currentUser:r.currentUser}),h=Bd({...r,path:o,schemaType:a,level:c,value:s,comparisonValue:d,readOnly:p});return{kind:"item",key:u,index:l,parentSchemaType:r.schemaType,open:(0,lB.Xy)(o,r.openPath),item:h}})({arrayItem:t,parent:e,index:n}));return{changed:e.changed||s.some(e=>"item"===e.kind&&e.item.changed),value:e.value,readOnly:i,schemaType:e.schemaType,focused:(0,lB.Xy)(e.path,e.focusPath),focusPath:(0,lB.vC)(e.path,e.focusPath),path:e.path,id:(0,lB.BB)(e.path),level:e.level,validation:o,presence:a,members:s}}({changed:Ba(e,t),comparisonValue:t,schemaType:w.type,parent:j.value,currentUser:j.currentUser,document:j.document,value:e,fieldGroupState:n,focusPath:j.focusPath,openPath:j.openPath,presence:j.presence,validation:j.validation,collapsedPaths:i,collapsedFieldSets:r,level:_,path:C,readOnly:l});return null===a?null:{kind:"field",key:"field-".concat(w.name),name:w.name,index:k,inSelectedGroup:P,groups:E,open:(0,lB.Ny)(C,j.openPath),collapsible:!1,collapsed:!1,field:a}}}{let e=null==S?void 0:S[w.name],t=cc(T)?null==T?void 0:T[w.name]:void 0,n={value:e,parent:j.value,document:j.document,currentUser:j.currentUser},i=Bn(w.type.hidden,n);if(i)return null;let r=j.readOnly||Bn(w.type.readOnly,n),l=Bd({...j,comparisonValue:t,value:e,schemaType:w.type,path:C,readOnly:r});return{kind:"field",key:"field-".concat(w.name),name:w.name,index:k,open:(0,lB.Ny)(C,j.openPath),inSelectedGroup:P,groups:E,collapsible:!1,collapsed:!1,field:l}}}function Bs(e){var t;let n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(20===e.level)return null;let i={value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser}
1,r=e.readOnly||Bn(e.schemaType.readOnly,i),l=e.schemaType.groups||[],a=null==(t=l.find(e=>e.default)||U9)?void 0:t.name,o=[U9,...l].flatMap(t=>{var n;let r=Bn(t.hidden,i),l=t.name===((null==(n=e.fieldGroupState)?void 0:n.value)||a),o=e.changesOpen?t.name===U9.name:l,s=!!e.changesOpen&&!o;return r?[]:[{disabled:s,icon:null==t?void 0:t.icon,name:t.name,selected:o,title:t.title}]}),s=o.find(e=>e.selected),d=e.schemaType.fieldsets?e.schemaType.fieldsets:e.schemaType.fields.map(e=>({single:!0,field:e})),c=d.flatMap((t,n)=>{var i,l,a,d;if(t.single){let i=t.field,l=Bo({field:i,parent:{...e,readOnly:r,groups:o,selectedGroup:s},index:n});return l?[l]:[]}let c=t.fields.map(e=>e.name),u=Bn(t.hidden,{currentUser:e.currentUser,document:e.document,parent:e.value,value:sQ()(e.value,c)}),p=Bn(t.readOnly,{currentUser:e.currentUser,document:e.document,parent:e.value,value:sQ()(e.value,c)}),h=t.fields.flatMap(t=>{if(u)return[{kind:"hidden",key:"field-".concat(t.name),name:t.name,index:n}];let i=Bo({field:t,parent:{...e,readOnly:r||p,groups:o,selectedGroup:s},index:n});return i?[i]:[]}),f=Bi(t.options,e.level),m=null!=(a=null==(l=((null==(i=e.collapsedFieldSets)?void 0:i.children)||{})[t.name])?void 0:l.value)?a:f.collapsed;return[{kind:"fieldSet",key:"fieldset-".concat(t.name),_inSelectedGroup:Br(o,t.group,s),groups:t.group?sY()(t.group):[],fieldSet:{path:(0,lB.s6)(e.path.concat(t.name)),name:t.name,title:t.title,description:t.description,hidden:!1,level:e.level+1,members:h.filter(e=>"hidden"!==e.kind),collapsible:null==f?void 0:f.collapsible,collapsed:m,columns:null==(d=null==t?void 0:t.options)?void 0:d.columns}}]}),u=l.length>0,p=e.presence.filter(t=>(0,lB.Xy)(t.path,e.path)),h=p.length?p:co,f=e.validation.filter(t=>(0,lB.Xy)(t.path,e.path)).map(e=>({level:e.level,message:e.item.message,path:e.path})),m=c.filter(e=>"hidden"!==e.kind);if(0===m.length&&n)return null;let g=u?o.flatMap(e=>{if(e.name===U9.name)return e;let t=m.some(t=>"error"!==t.kind&&("field"===t.kind?t.groups.includes(e.name):t.groups.includes(e.name)||t.fieldSet.members.some(t=>"error"!==t.kind&&t.groups.includes(e.name))));return t?e:[]}):[],x=m.flatMap(e=>{if("error"===e.kind)return[e];if("field"===e.kind)return e.inSelectedGroup?[e]:[];let t=e.fieldSet.members.filter(e=>"field"!==e.kind||e.inSelectedGroup);return t.length>0?[{...e,fieldSet:{...e.fieldSet,members:t}}]:[]});return{value:e.value,changed:Ba(e.value,e.comparisonValue),schemaType:e.schemaType,readOnly:r,path:e.path,id:(0,lB.BB)(e.path),level:e.level,focused:(0,lB.Xy)(e.path,e.focusPath),focusPath:(0,lB.vC)(e.path,e.focusPath),presence:h,validation:f,_allMembers:c,members:x,groups:g}}function Bd(e){let t=e.presence.filter(t=>(0,lB.Xy)(t.path,e.path)),n=t.length?t:co,i=e.validation.filter(t=>(0,lB.Xy)(t.path,e.path)).map(e=>({level:e.level,message:e.item.message,path:e.path}));return{schemaType:e.schemaType,changed:Ba(e.value,e.comparisonValue),value:e.value,level:e.level,id:(0,lB.BB)(e.path),readOnly:e.readOnly,focused:(0,lB.Xy)(e.path,e.focusPath),path:e.path,presence:n,validation:i}}function Bc(e,t){let{comparisonValue:n,value:i,fieldGroupState:r,collapsedFieldSets:l,collapsedPaths:a,focusPath:o,openPath:s,presence:d,validation:c,readOnly:u,changesOpen:p}=t,h=Nj(),f=(0,lK.useRef)(null);return(0,lK.useLayoutEffect)(()=>{f.current=null},[e]),(0,lK.useMemo)(()=>{let t=Bs({schemaType:e,document:i,fieldGroupState:r,collapsedFieldSets:l,collapsedPaths:a,value:i,comparisonValue:n,focusPath:o,openPath:s,readOnly:u,path:(0,lB.s6)([]),level:0,currentUser:h,presence:d,validation:c,changesOpen:p}),m=ge(f.current,t);return f.current=m,m},[e,i,r,l,a,n,o,s,u,h,d,c,p])}function Bu(e){return e.map(Bf)}function Bp(e,t){return om()(t.map(t=>om()(Object.keys(t).filter(Bh(["id","ifRevisionID","query"])).map(n=>{if("unset"===n)return t.unset.map(t=>({type:"unset",path:_B(t),origin:e}));if("insert"===n){let n="before"in t.insert?"before":"after";return{type:"insert",position:n,path:_B(t.insert[n]),items:t.insert.items,origin:e}}return Object.keys(t[n]).map(i=>"set"===n?{type:"set",path:_B(i),value:t[n][i],origin:e}:"inc"===n||"dec"===n?{type:n,path:_B(i),value:t[n][i],origin:e}:"setIfMissing"===n?{type:"setIfMissing",path:_B(i),value:t[n][i],origin:e}:"diffMatchPatch"===n?{type:n,path:_B(i),value:t[n][i],origin:e}:(console.warn(Error("Unsupported patch type: ".concat(n))),null)).filter(
1Boolean)}))))}let Bh=e=>t=>!e.includes(t);function Bf(e){if(e.patchType!==mM&&e.type)throw Error('Patch is missing "patchType" - import and use "'.concat(e.type,'()" from "sanity/form"'));if(e.patchType!==mM)throw Error('Patch is missing "patchType" - import and use the patch method helpers from "sanity/form"');let t=(0,sR.kC)(e.path||[]);if("insert"===e.type){let{position:n,items:i}=e;return{insert:{[n]:t,items:i}}}if("unset"===e.type)return{unset:[t]};if(!e.type)throw Error("Missing patch type in patch ".concat(JSON.stringify(e)));return t?{[e.type]:{[t]:e.value}}:{[e.type]:e.value}}(0,lK.memo)(function(e){let{transform:t}=e,n=m7(),i=(0,lK.useCallback)(e=>{let i=e.patches,r=t(i);n.onChange(mN.from(r))},[n,t]),r=(0,lK.useMemo)(()=>({...n,onChange:i}),[n,i]);return(0,lU.jsx)(m8.Provider,{value:r,children:e.children})}),lY.Lg.fonts.code.family,lY.Lg.fonts.text.family,a8.Sn.hex,a8.ix.hex,a8.iN[500].hex,a8.ix.hex,a8.Sn.hex,a8.MA[500].hex,a8.MA[500].hex,a8.MA[500].hex,a8.Q6[500].hex,a8.iN[500].hex,a8.ek[500].hex,a8.er[500].hex,a8.iN[500].hex,a8.iN[500].hex,a8.ek[500].hex,a8.er[500].hex,a8.Q6[500].hex,a8.Sn.hex,a8.ix.hex,lY.Lg}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.