1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[911],{32932:function(e,t,n){n.d(t,{$rW:function(){return lj},AY8:function(){return mo.AY},Ahg:function(){return rC},BoV:function(){return bd},C8M:function(){return AV},CbY:function(){return _m},CnE:function(){return Fp},Cnp:function(){return th},Cw0:function(){return zh},Dab:function(){return YU},Dqo:function(){return oV},Dr7:function(){return qh},Dtv:function(){return Lq},E6V:function(){return QZ},EyJ:function(){return Jy},F2f:function(){return vV},FMn:function(){return Vu},GWp:function(){return VV},H7Z:function(){return Nx},HD0:function(){return Rd},H__:function(){return gV},Hdz:function(){return Bq},IIC:function(){return Hg},INm:function(){return uN},I_y:function(){return nN},LOQ:function(){return KZ},LPT:function(){return Xp},LZ8:function(){return Ad},L_b:function(){return ff},Lky:function(){return SO},MBS:function(){return BF},MUX:function(){return yd},NEx:function(){return $Z},NuZ:function(){return Ed},P08:function(){return JU},Q3k:function(){return cz},QMc:function(){return xg},RgL:function(){return Id},Sis:function(){return KV},UMU:function(){return Xq},Uy$:function(){return Od},WVR:function(){return bD},YG6:function(){return Wp},YkG:function(){return mo.Yk},YtX:function(){return kV},Z2j:function(){return mo.Z2},Z7x:function(){return Zg},ZDM:function(){return Oh},_2T:function(){return lf},_ZM:function(){return TV},_eo:function(){return Am},a3k:function(){return fN},ap5:function(){return xV},cFj:function(){return kO},cWh:function(){return _O},clL:function(){return UV},d9t:function(){return JZ},duV:function(){return Uu},e8h:function(){return Mu},eLL:function(){return hf},ek8:function(){return jd},euX:function(){return gb},feb:function(){return mo.fe},fm0:function(){return km},hHf:function(){return Vq},iav:function(){return eN},jbM:function(){return Cu},jr5:function(){return nh},kJL:function(){return Md},kNp:function(){return ab},kqP:function(){return fm},kwM:function(){return Gy},l$t:function(){return ou},m85:function(){return WZ},mEJ:function(){return Cb},mPO:function(){return Ld},nqf:function(){return dz},nuD:function(){return oN},oUE:function(){return Ju},ogX:function(){return Qh},p9V:function(){return YZ},pt$:function(){return IV},qGk:function(){return og},quP:function(){return pb},quX:function(){return mo.qu},qyu:function(){return Sd},r8Q:function(){return gy},rq_:function(){return mV},t2O:function(){return Zq},t8m:function(){return Tm},tdq:function(){return fk},ukE:function(){return _p},vSY:function(){return $q},va7:function(){return Ig},vpR:function(){return tN},vsM:function(){return Td},xJ:function(){return xN},xMr:function(){return Yp},z12:function(){return mo.z1},z1O:function(){return XZ},zEW:function(){return sN},zNf:function(){return Im}});var i,r,o,s,a,l,c,d,u,p,h,f,m,g,x,v,y,b,j,w,k,C,_,S,T,I,P,E,A,F,M,O,R,z,D,B,L,Z,N,q,U,V,K,H,$,W,G,X,Y,J,Q,ee,te,ne,ie,re,oe,se,ae,le,ce,de,ue,pe,he,fe,me,ge,xe,ve,ye,be,je,we,ke,Ce,_e,Se,Te,Ie,Pe,Ee,Ae,Fe,Me,Oe,Re,ze,De,Be,Le,Ze,Ne,qe,Ue,Ve,Ke,He,$e,We,Ge,Xe,Ye,Je,Qe,et,tt,nt,it,rt,ot,st,at,lt,ct,dt,ut,pt,ht,ft,mt,gt,xt,vt,yt,bt,jt,wt,kt,Ct,_t,St,Tt,It,Pt,Et,At,Ft,Mt,Ot,Rt,zt,Dt,Bt,Lt,Zt,Nt,qt,Ut,Vt,Kt,Ht,$t,Wt,Gt,Xt,Yt,Jt,Qt,en,tn,nn,rn,on,sn,an,ln,cn,dn,un,pn,hn,fn,mn,gn,xn,vn,yn,bn,jn,wn,kn,Cn,_n,Sn,Tn,In,Pn,En,An,Fn,Mn,On,Rn,zn,Dn,Bn,Ln,Zn,Nn,qn,Un,Vn,Kn,Hn,$n,Wn,Gn,Xn,Yn,Jn,Qn,ei,ti,ni,ii,ri,oi,si,ai,li,ci,di,ui,pi,hi,fi,mi,gi,xi,vi,yi,bi,ji,wi,ki,Ci,_i,Si,Ti,Ii,Pi,Ei,Ai,Fi,Mi,Oi,Ri,zi,Di,Bi,Li,Zi,Ni,qi,Ui,Vi,Ki,Hi,$i,Wi,Gi,Xi,Yi,Ji,Qi,er,tr,nr,ir,rr,or,sr,ar,lr,cr,dr,ur,pr,hr,fr,mr,gr,xr,vr,yr,br,jr,wr,kr,Cr,_r,Sr,Tr,Ir,Pr,Er,Ar,Fr,Mr,Or,Rr,zr,Dr,Br,Lr,Zr,Nr,qr,Ur,Vr,Kr,Hr,$r,Wr,Gr,Xr,Yr,Jr,Qr,eo,to,no,io,ro,oo,so,ao,lo,co,uo,po,ho,fo,mo=n(42930),go=n(85893),xo=n(66996),vo=n(67294),yo=n(69590),bo=n.n(yo),jo=n(23279),wo=n.n(jo),ko=n(47252),Co=n(11636),_o=n(28440),So=n(32817),To=n(69243),Io=n(22401),Po=n(82649),Eo=n(23071),Ao=n(19917),Fo=n(83610),Mo=n(6222),Oo=n(9653),Ro=n(1545),zo=n(19293),Do=n(40317),Bo=n(40052),Lo=n(9141),Zo=n(82976),No=n(86515),qo=n(37991),Uo=n(36861),Vo=n(30743),Ko=n(42006),Ho=n(29127),$o=n(53741),Wo=n(79878),Go=n(34978),Xo=n(56542),Yo=n(94975),Jo=n(68515),Qo=n(98430),es=n(48902),ts=n(83505),ns=n(74727),is=n(5014),rs=n(46297),os=n(77270),ss=n(44367),as=n(65583),ls=n(51313),cs=n(91458),ds=n(92574),us=n(93833),ps=n(47753),hs=n(40148),fs=n(30218),ms=n(63428),gs=n(71932),xs=n(56890),vs=n(9132),ys=n(25631),bs=n(42965),js=n(48848),ws=n(58550),ks=n(58796),Cs=n(30062),_s=n(18446),Ss=n.n(_s),Ts=n(58354),Is=n(23493),Ps=n.n(Is),Es=n(14141),As=n(89734),Fs=n.n(As),Ms=n(1014),Os=n(60754),Rs=n(38993),zs=n.n(Rs),Ds=n(40168),Bs=n(933),Ls=n(54522),Zs=n(94184),Ns=n.n(Zs),qs=n(98235),Us=n(59864),Vs=n(55379),Ks=n(53584),Hs=n(88306),$s=n.n(Hs),Ws=n(21827),Gs=n(47037),Xs=n.n(Gs),Ys=n(18029),Js=n.n(Ys),Qs=n(35706),ea=n(42076),ta=n(30222),na=n(49150),ia=n(73955),ra=n.n(ia),oa=n(43703),sa=n(86298),aa=n(8230),la=n(77349),ca=n(13956),da=n(3151),ua=n(49160),pa=n(34176),ha=n(16218),fa=n(11640),ma=n(44749),ga=n(4543),xa=n(37042),va=n(23855),ya=n(39159),ba=n(61436),ja=n(42298),wa=n(42699),ka=n(313),Ca=n(92311),_a=n(83894),Sa=n(69119),Ta=n(70197),Ia=n(46038),Pa=n(28366),Ea=n(18717),Aa=n(55250),Fa=n(57278),Ma=n(31397),Oa=n(69295),Ra=n(67803),za=n(76972),Da=n(69690),Ba=n(11699),La=n(3982),Za=n(6803),Na=n.n(Za),qa=n(81548),Ua=n(39693),Va=n.n(Ua),Ka=n(25325),Ha=n.n(Ka),$a=n(24350),Wa=n.n($a),Ga=n(43174),Xa=n.n(Ga),Ya=n(7334),Ja=n.n(Ya),Qa=n(93386),el=n.n(Qa),tl=n(44908),nl=n.n(tl),il=n(58748),rl=n.n(il),ol=n(85564),sl=n.n(ol),al=n(59242),ll=n.n(al),cl=n(92742),dl=n.n(cl),ul=n(25934),pl=n(57557),hl=n.n(pl),fl=n(75472),ml=n.n(fl),gl=n(52027),xl=n(98434),vl=n(57122),yl=n(60814),bl=n(4527),jl=n(83508),wl=n(18156),kl=n(41609),Cl=n.n(kl),_l=n(9095),Sl=n(18612),Tl=n.n(Sl),Il=n(6979),Pl=n.n(Il),El=n(36155),Al=n.n(El),Fl=n(45950),Ml=n.n(Fl),Ol=n(96412),Rl=n.n(Ol),zl=n(4979),Dl=n.n(zl),Bl=n(55648),Ll=n(31103),Zl=n(3522),Nl=n.n(Zl),ql=(n(20745),n(76566)),Ul=n.n(ql),Vl=n(29043),Kl=n(45578),Hl=n.n(Kl),$l=n(7739),Wl=n.n($l),Gl=n(76590),Xl=n(17423),Yl=n(45587),Jl=n(60887),Ql=n(24285),ec=n(32339),tc=n(2141),nc=n(27361),ic=n.n(nc),rc=n(99119),oc=n(68630),sc=n.n(oc),ac=n(48403),lc=n.n(ac),cc=n(26642),dc=n.n(cc),uc=n(90634),pc=n.n(uc),hc=n(13311),fc=n.n(hc),mc=n(96026
1),gc=n.n(mc),xc=n(989),vc=n.n(xc),yc=n(84596),bc=n.n(yc),jc=n(78718),wc=n.n(jc),kc=n(63706),Cc=n.n(kc),_c=n(91966),Sc=n.n(_c),Tc=n(6557),Ic=n.n(Tc),Pc=n(52628),Ec=n.n(Pc),Ac=n(28092),Fc=n(85092),Mc=n(34167),Oc=n(80979),Rc=n(65104),zc=n(25874),Dc=n(75175),Bc=n(53416),Lc=n(95534),Zc=n.n(Lc),Nc=n(45933),qc=n.n(Nc),Uc=n(54087),Vc=n.n(Uc),Kc=n(11700),Hc=n.n(Kc),$c=n(38063),Wc=n(21137),Gc=n(97762),Xc=n(35516),Yc=n(51526),Jc=n(13218),Qc=n.n(Jc),ed=n(30998),td=n.n(ed),nd=n(66678),id=n.n(nd);function rd(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function od(e){return function(e){return"function"===typeof e}(e)?e():e}const sd=()=>{};let ad=!1;const ld=e=>{ad||console.warn(new Error('No context provided for reporter. Make sure that the component calling "useReporter('.concat(e,', ...)", is wrapped in a <Tracker> element'))),ad=!0};const cd={add:ld,update:ld,remove:ld,subscribe:()=>(ad||console.warn(new Error('No context provided for reporter. Make sure that the component calling "useReportedValues()", is wrapped inside a <Tracker> element')),ad=!0,()=>{}),read:function(){return ad||console.warn(new Error('No context provided for reporter. Make sure that the component calling "useReportedValues()", is wrapped inside a <Tracker> element')),ad=!0,[]}};let dd=0;const ud=()=>++dd;function pd(){const e=vo.createContext(cd);const t=function(e){return function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.is;const{add:r,update:o,remove:s}=vo.useContext(e),a=vo.useRef();vo.useLayoutEffect((()=>{if(null===t)return sd;const e=od(n);return r(t,e),a.current=e,()=>{s(t)}}),[r,t,s,n]),vo.useLayoutEffect((()=>{const e=od(n);"undefined"===typeof a.current||i(a.current,e)||null===t||o(t,e),a.current=e}))}}(e);return{Tracker:function(t){const n=vo.useMemo((()=>function(){const e=new Map,{publish:t,subscribe:n}=(0,ko.Z)(),i=wo()(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,go.jsx)(e.Provider,{value:n,children:t.children})},useReportedValues:function(){const t=vo.useContext(e),[n,i]=vo.useState(t.read());return vo.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(vo.useRef(ud()).current),e,n)}}}const hd=12,fd=pd(),md=fd.Tracker,gd=fd.useReportedValues,xd=fd.useReporter,vd=(0,vo.createContext)({isReviewChangesOpen:!1,onOpenReviewChanges:()=>{},onSetFocus:()=>{}}),yd=e=>{const t=vo.useRef(null),{onSetFocus:n}=vo.useContext(vd),[i,r]=vo.useState(!1),o=vo.useCallback((()=>{r(!0)}),[]),s=vo.useCallback((()=>{r(!1)}),[]);xd("change-".concat(xo.BB(e.path)),(()=>({element:t.current,path:e.path,isChanged:!0,hasFocus:!1,hasHover:i,hasRevertHover:e.hasHover})),bo());const a=(0,vo.useCallback)((t=>{!function(e,t,n){e.stopPropagation(),t(n)}(t,n,e.path)}),[n,e.path]);return(0,go.jsx)("div",{ref:t,onClick:a,onMouseLeave:s,onMouseEnter:o,children:e.children})};function bd(e){const t=(0,vo.useRef)(e);return Ss()(t.current,e)||(t.current=e),t.current}function jd(e,t){const n=[t,!0],i={type:"tuple",tuple:n};return function(t){const r=bd(t),o=(0,_o.m2)((()=>(0,So.of)(r).pipe((0,Go.w)((t=>(0,To.z)((0,So.of)({type:"loading"}),e(t).pipe((0,Ho.U)((e=>({type:"value",value:e}))))))),(0,Xo.R)(((e,t)=>{let[n]=e;return"loading"===t.type?[n,!0]:[t.value,!1]}),n),(0,$o.x)(((e,t)=>{let[n,i]=e,[r,o]=t;return n===r&&i===o})),(0,Ho.U)((e=>({type:"tuple",tuple:e}))),(0,Wo.K)((e=>(0,So.of)({type:"error",error:e}))))),[r],i);if("error"===o.type)throw o.error;return o.tuple}}function wd(e){return null!==e&&void 0!==e}const kd="".concat("drafts",".");function Cd(e){return e.startsWith(kd)}function _d(e){return{draftId:Sd(e),publishedId:Td(e)}}function Sd(e){return Cd(e)?e:kd+e}function Td(e){return Cd(e)?e.slice(kd.length):e}function Id(e){const t=e.reduce(((e,t)=>{const n=Td(t._id);let i=e.get(n);
1return 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 Pd(e){return Id(e).map((e=>e.draft||e.published)).filter(wd)}const Ed=Object.freeze({}),Ad=Object.freeze([]);const Fd=function(){if("undefined"!==typeof globalThis)return globalThis;if("undefined"!==typeof window)return window;if("undefined"!==typeof self)return self;if("undefined"!==typeof n.g)return n.g;throw new Error("@sanity/ui: could not locate global scope")}();function Md(e){return Array.isArray(e)}function Od(e){return Boolean(e)&&"object"===typeof e&&!Array.isArray(e)}function Rd(e){return"string"===typeof e}const zd="object"===typeof document&&"object"===typeof window&&window.ResizeObserver?window.ResizeObserver:Ts.do,Dd=(()=>{const e=(0,ko.Z)(),t=new zd((t=>e.publish(t)));return{observe:(n,i,r)=>{const o=e.subscribe((e=>{const t=e.find((e=>e.target===n));t&&i(t)}));return t.observe(n,r),()=>{o(),t.unobserve(n)}}}})(),Bd=["sanity.imageAsset","sanity.fileAsset"];function Ld(e){return"document"===e.type&&!function(e){return"document"===e.type&&Bd.includes(e.name)}(e)}const Zd=["match","in","asc","desc","true","false","null"],Nd=/^[a-zA-Z_][a-zA-Z0-9_]*$/,qd=e=>!Nd.test(e)||Zd.includes(e),Ud=e=>'["'.concat(e,'"]'),Vd=e=>{let t="";for(let i=0;i<e.length;i++){const r=e[i];if(n=r,Array.isArray(n)&&0===n.length){t+="[]";continue}if("number"===typeof r){t+="[".concat(r,"]");continue}const o=0===i;t=qd(r)?o?"@".concat(Ud(r)):"".concat(t).concat(Ud(r)):o?r:"".concat(t,".").concat(r)}var n;return t},Kd="undefined"!==typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0);const Hd={isLoading:!0,value:void 0,error:null};function $d(e,t){const n="undefined"===typeof t?Hd:{isLoading:!1,value:t,error:null};return(0,_o.m2)((()=>e.pipe((e=>e.pipe((0,Ho.U)((e=>({isLoading:!1,value:e,error:null}))),(0,Wo.K)((e=>(0,So.of)({isLoading:!1,value:void 0,error:e}))))))),[e],n)}function Wd(e,t){return e.roles.some((e=>e.name===t))}const Gd=Es.ZP.div((e=>{let{changed:t,disabled:n,isReviewChangeOpen:a}=e;return n?(0,Es.iv)(i||(i=rd(["\n "," {\n display: none;\n }\n "])),Yd):(0,Es.iv)(r||(r=rd(["\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,Es.iv)(o||(o=rd(["\n "," {\n opacity: 0;\n pointer-events: none;\n }\n "])),Yd),a&&(0,Es.iv)(s||(s=rd(["\n "," {\n opacity: 0;\n }\n "])),Qd))})),Xd=Es.ZP.div(a||(a=rd(["\n flex-grow: 1;\n min-width: 0;\n"]))),Yd=Es.ZP.div(l||(l=rd(["\n position: relative;\n opacity: 1;\n transition: opacity 100ms;\n z-index: ",";\n"])),(e=>{let{$zIndex:t}=e;return t})),Jd=Es.ZP.div((e=>{let{theme:t}=e;const n=t.sanity.color.spot.yellow,i=t.sanity.media[0];return(0,Es.iv)(c||(c=rd(["\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)})),Qd=Es.ZP.button((e=>{let{theme:t,$withHoverEffect:n}=e;const i=t.sanity.color.spot.yellow;return(0,Es.iv)(d||(d=rd(["\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,Es.iv)(u||(u=rd(["\n @media (hover: hover) {\n &:hover {\n opacity: 0.2;\n }\n }\n "]))))}));function eu(e){const{children:t,disabled:n,hasFocus:i,isChanged:r,withHoverEffect:o=!0}=e,[s,a]=(0,vo.useState)(!1),{onOpenReviewChanges:l,isReviewChangesOpen:c}=vo.useContext(vd),{zIndex:d}=(0,Co.sJ)(),u=(0,vo.useCallback)((()=>a(!0)),[]),p=(0,vo.useCallback)((()=>a(!1)),[]),h=(0,vo.useMemo)((()=>n||!r?null:(0,go.jsxs)(Yd,{"data-testid":"change-bar",$zIndex:d,children:[(0,go.jsx)(Jd,{"data-testid":"change-bar__marker"}),(0,go.jsx)(Qd,{"aria-label":"Review changes","data-testid":"change-bar__button",onClick:c?void 0:l,onMouseEnter:u,onMouseLeave:p,tabIndex:-1,type:"button",$withHoverEffect:o})]})),[n,r,d,c,l,u,p,o]);return(0,go.jsxs)(Gd,{changed:r,"data-testid":"change-bar-wrapper",disabled:n,focus:i,hover:s,isReviewChangeOpen:c,children:[(0,go.jsx)(Xd,{"data-testid":"change-bar__field-wrapper",children:t}),h]})}const tu=(0,vo.memo)((function(e){const{children:t,disabled:n,hasFocus:i,isChanged:r,onMouseEnter:o,onMouseLeave:s,path:a=Ad,withHoverEffect:l,...c}=e,d=(0,Co.sJ)(),[u,p]=(0,vo.useState)(!1),h=(0,vo.useCallback)((e=>{null==o||o(e),p(!0)}),[o]),f=(0,vo.useCallback)((e=>{null==s||s(e),p(!1)}),[s]),m=(0,vo.useRef)(null);return xd(n?null:"field-".concat(xo.BB(a)),(()=>({element:m.current,path:a,isChanged:r,hasFocus:i,hasHover:u,zIndex:d.zIndex})),bo()),(0,go.jsx)("div",{...c,ref:m,onMouseEnter:h,onMouseLeave:f,children:(0,go.jsx)(eu,{hasFocus:i,isChanged:r,disabled:n,withHoverEffect:l,children:t})})}));function nu(e){const{children:t,hasFocus:n,isChanged:i,path:r,withHoverEffect:o,...s}=e;return(0,go.jsx)(tu,{...s,path:r,hasFocus:n,isChanged:i,withHoverEffect:o,children:t})}vo.createContext({path:[],fullPath:[],focusPath:[],isChanged:!1});const iu=vo.createContext(null);const ru=()=>{},ou=vo.forwardRef((function(e,t){const{as:n="div",onScroll:i,...r}=e,o=(0,Co.ts)(t),s=(0,vo.useContext)(iu),a=(0,vo.useMemo)((()=>(0,ko.Z)()),[]);return(0,vo.useEffect)((()=>i?a.subscribe(i):ru),[a,i]),(0,vo.useEffect)((()=>s?a.subscribe(s.publish):ru),[s,a]),(0,vo.useEffect)((()=>{const e=e=>{a.publish(e)},t=o.current;if(t)return t.addEventListener("scroll",e,{passive:!0,capture:!0}),()=>{t.removeEventListener("scroll",e)}}),[a,o]),(0,go.jsx)(iu.Provider,{value:a,children:vo.createElement(n,{ref:o,"data-testid":"scroll-container",...r})})}));function su(e){let{onScroll:t,children:n}=e;return function(e){const t=vo.useContext(iu);vo.useEffect((()=>null==t?void 0:t.subscribe(e)),[e,t])}(t),(0,go.jsx)(go.Fragment,{children:n})}function au(e,t,n){const i=t.slice(t.indexOf("-")+1)||"[]",r=xo.mL(i),o="".concat(e,"-").concat(xo.BB(r));if(n.has(o))return n.get(o);let s;for(const[a,l]of n){if(!("path"in l)||!a.startsWith(e))continue;const t=xo.eh(r,l.path),n=l.path[l.path.length-1],i=t===l.path.length-1&&(0,mo.fU)(n);if(0!==t&&((t===l.path.length||i)&&(s=l,t===r.length)))break}return s}function lu(e){const t=getComputedStyle(e).overflow;return t.includes("auto")||t.includes("scroll")}function cu(e){let t=e.element;for(;(n=t).scrollHeight===n.offsetHeight&&n.scrollWidth===n.offsetWidth||!lu(n);)if(t=t.parentElement,!t)return;var n;
1t.scroll({top:t.scrollTop+e.rect.top-e.bounds.top-15,left:0,behavior:"smooth"})}const du=(e,t)=>{const n={top:0,left:0,height:t.offsetHeight,width:t.offsetWidth},i={top:0,left:0,height:e.offsetHeight,width:e.offsetWidth};let r=!1,o=e;for(;o&&o!==t&&t.contains(o);)r&&(n.top+=o.offsetTop,n.left+=o.offsetLeft),lu(o)&&(n.top=o.offsetTop,n.height=o.offsetHeight,n.left=o.offsetLeft,n.width=o.offsetWidth,r=!0),i.top+=o.offsetTop-o.scrollTop,i.left+=o.offsetLeft-o.scrollLeft,o=o.offsetParent;return{rect:i,bounds:n}};function uu(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 pu(e,t){return"M".concat(e," ").concat(t)}function hu(e,t){return"L".concat(e," ").concat(t)}function fu(e,t,n,i){return"Q".concat(e," ").concat(t," ").concat(n," ").concat(i)}function mu(e,t){const 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}}Es.ZP.rect(p||(p=rd(["\n stroke: #ccc;\n fill: none;\n pointer-events: none;\n stroke-linecap: round;\n"])));const gu=Es.ZP.path((e=>{let{theme:t}=e;const n=t.sanity.color.spot.yellow;return(0,Es.iv)(h||(h=rd(["\n fill: none;\n pointer-events: none;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke: ",";\n "])),n)})),xu=Es.ZP.path((e=>{let{theme:t}=e;const n=t.sanity.color.spot.yellow;return(0,Es.iv)(f||(f=rd(["\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)})),vu=(0,Es.ZP)((function(e){const{bounds:t,...n}=e,i=Math.max(t.left,e.left),r=Math.max(e.top,t.top),o=Math.max(0,e.height-(r-e.top)),s=Math.max(0,e.width-(i-e.left));return(0,go.jsx)("rect",{...n,x:i,y:r,height:o,width:s})}))((e=>{let{theme:t}=e;const n=t.sanity.color.spot.yellow;return(0,Es.iv)(m||(m=rd(["\n stroke: none;\n pointer-events: none;\n fill: ",";\n "])),n)})),yu=(0,vo.memo)((function(e){let{from:t,to:n}=e;const i=function(e){const t={top:e.from.bounds.top+hd,bottom:e.from.bounds.top+e.from.bounds.height-hd,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=mu(e.from.rect,t);n.left=e.from.rect.left+e.from.rect.width+1;const i={top:e.to.bounds.top+hd,bottom:e.to.bounds.top+e.to.bounds.height-hd,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=mu(e.to.rect,i),o=Math.max(r.startY,n.startY);return n.top=Math.min(o,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(o,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;const r=function(e){const{from:t,to:n}=e,{left:i,top:r}=t,{left:o,top:s}=n,a=[],l=Math.min(4,Math.abs(r-s)/2);return t.isAbove?a.push(pu(i+8,r-hd+2),hu(i+8,r-4),fu(i+8,r,i+8+4,r)):t.isBelow?a.push(pu(i+8,r+hd-2),hu(i+8,r+4),fu(i+8,r,i+8+4,r)):a.push(pu(i,r)),n.isAbove?r<n.bounds.top?a.push(hu(n.bounds.left-8-l,r),fu(n.bounds.left-8,r,n.bounds.left-8,r+l),hu(n.bounds.left-8,s-l),fu(n.bounds.left-8,s,n.bounds.left-8+l,s),hu(n.bounds.left+8-4,s),fu(n.bounds.left+8,s,n.bounds.left+8,s-4),hu(n.bounds.left+8,s-hd+2)):a.push(hu(n.bounds.left+8-4,r),fu(n.bounds.left+8,r,n.bounds.left+8,r-4),hu(n.bounds.left+8,s-hd+2)):n.isBelow?r>n.bounds.top+n.bounds.height?a.push(hu(n.bounds.left-8-l,r),fu(n.bounds.left-8,r,n.bounds.left-8,r-l),hu(n.bounds.left-8,s+l),fu(n.bounds.left-8,s,n.bounds.left-8+l,s),hu(n.bounds.left+8-4,s),fu(n.bounds.left+8,s,n.bounds.left+8,s+4),hu(n.bounds.left+8,s+hd-2)):a.push(hu(n.bounds.left+8-4,r),fu(n.bounds.left+8,r,n.bounds.left+8,r+4),hu(n.bounds.left+8,s+hd-2)):r<s?a.push(hu(n.bounds.left+8-l,r),fu(n.bounds.left+8,r,n.bounds.left+8,r+l),hu(n.bounds.left+8,s-l),fu(n.bounds.left+8,s,n.bounds.left+8+l,s),hu(o,s)):a.push(hu(n.bounds.left+8-l,r),fu(n.bounds.left+8,r,n.bounds.left+8,r-l),hu(n.bounds.left+8,s+l),fu(n.bounds.left+8,s,n.bounds.left+8+l,s),hu(o,s)),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e.join(t)}(a)}(i);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(xu,{d:r,strokeWidth:16}),(0,go.jsx)(gu,{d:r,strokeWidth:2}
1),(0,go.jsx)(vu,{top:n.rect.top,left:n.rect.left,height:n.rect.height,width:2,bounds:n.bounds}),i.from.isAbove&&(0,go.jsx)(gu,{d:uu(i.from.left+8,i.from.bounds.top-hd+2,-1),strokeWidth:2}),i.from.isBelow&&(0,go.jsx)(gu,{d:uu(i.from.left+8,i.from.bounds.top+i.from.bounds.height+hd-2,1),strokeWidth:2}),i.to.isAbove&&(0,go.jsx)(gu,{d:uu(i.to.bounds.left+8,i.to.bounds.top-hd+2,-1),strokeWidth:2}),i.to.isBelow&&(0,go.jsx)(gu,{d:uu(i.to.bounds.left+8,i.to.bounds.top+i.to.bounds.height+hd-2,1),strokeWidth:2}),false]})}));const bu=Es.ZP.svg(g||(g=rd(["\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"])));function ju(e,t,n,i){const r=[],o=[];for(const l of e){if("changePanel"===l[0]||!l[1].isChanged)continue;const[e,n]=l;e!==t?n.hasHover?r.push(l):n.hasFocus&&o.push(l):r.push(l)}const s=r.length>0,a=(s?r:o).map((e=>{let[t]=e;const i=au("field",t,n),r=au("change",t,n);return i&&r?{field:{id:t,...i},change:{id:t,...r}}:null})).filter(wd).map((e=>{let{field:t,change:n}=e;return{hasHover:t.hasHover||n.hasHover,hasFocus:t.hasFocus,hasRevertHover:n.hasRevertHover,field:{...t,...du(t.element,i)},change:{...n,...du(n.element,i)}}}));return{connectors:a,isHoverConnector:s}}function wu(e){const{rootElement:t,onSetFocus:n}=e,[i,r]=vo.useState(null),o=gd(),s=(0,vo.useMemo)((()=>new Map(o)),[o]),[{connectors:a},l]=(0,vo.useState)((()=>ju(o,i,s,t))),c=(0,vo.useMemo)((()=>Fs()(a,(e=>0-e.field.path.length)).slice(0,1)),[a]),d=(0,vo.useCallback)((()=>{l(ju(o,i,s,t))}),[s,o,i,t]);var u,p;return u=t,p=d,(0,vo.useEffect)((()=>Dd.observe(u,p)),[u,p]),(0,go.jsx)(su,{onScroll:d,children:(0,go.jsx)(bu,{style:{zIndex:c[0]&&c[0].field.zIndex},children:c.map((e=>{let{field:t,change:i}=e;return i?(0,go.jsx)(ku,{field:t,change:i,onSetFocus:n,setHovered:r},t.id):null}))})})}function ku(e){const{change:t,field:n,onSetFocus:i,setHovered:r}=e,o=(0,vo.useCallback)((()=>{cu(n),cu(t),i(n.path)}),[n,t,i]),s=(0,vo.useCallback)((()=>r(n.id)),[n,r]),a=(0,vo.useCallback)((()=>r(null)),[r]),l=(0,vo.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]),c=(0,vo.useMemo)((()=>({rect:t.rect,bounds:t.bounds})),[t.bounds,t.rect]);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)("g",{onClick:o,onMouseEnter:s,onMouseLeave:a,children:(0,go.jsx)(yu,{from:l,to:c})}),false]})}const Cu=function(e){let{children:t,className:n,isReviewChangesOpen:i,onOpenReviewChanges:r,onSetFocus:o,...s}=e;const[a,l]=vo.useState(),c=(0,vo.useMemo)((()=>({isReviewChangesOpen:i,onOpenReviewChanges:r,onSetFocus:o})),[i,r,o]);return(0,go.jsx)(vd.Provider,{value:c,children:(0,go.jsx)(md,{children:(0,go.jsxs)(ou,{...s,ref:l,className:n,children:[t,a&&(0,go.jsx)(wu,{rootElement:a,onSetFocus:o})]})})})};function _u(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function Su(e){const{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,o=0-i.offset,s=t?t.bg:"var(--card-bg-color)";return[o>0&&"inset 0 0 0 ".concat(o,"px var(--card-focus-ring-color)"),n&&_u(n),o<0&&"0 0 0 ".concat(0-o,"px ").concat(s),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}const Tu="data-active",Iu="a,button",Pu=Es.ZP.div((e=>{let{theme:t,offset:n}=e;return(0,Es.iv)(x||(x=rd(["\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,Co.hO)(t.sanity.radius[1]),-n,-n,-n,Au,Su({base:t.sanity.color.base,focusRing:t.sanity.focusRing}))})),Eu=Es.ZP.div(v||(v=rd(["\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"]))),Au=(0,Es.ZP)(Co.xu)(y||(y=rd(["\n height: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: auto;\n overscroll-behavior: contain;\n width: 100%;\n"]))),Fu=(0,Es.ZP)(Co.xu).attrs((e=>{let{$height:t}=e;return{style:{height:"".concat(t,"px")}}}))(b||(b=rd(["\n position: relative;\n width: 100%;\n"]))),Mu=(0,vo.forwardRef)((function(e,t){let{activeItemDataAttr:n=Tu,ariaLabel:i,ariaMultiselectable:r=!1,autoFocus:o,canReceiveFocus:s,fixedHeight:a,focusRingOffset:l=0,getItemDisabled:c,getItemKey:d,getItemSelected:u,initialIndex:p,initialScrollAlign:h="start",inputElement:f,itemHeight:m,items:g,onEndReached:x,onEndReachedIndexOffset:v=0,onlyShowSelectionWhenActive:y,overscan:b,renderItem:j,wrapAround:w=!0,...k}=e;const C=(0,vo.useRef)(!1),_=(0,vo.useRef)((0,vo.useId)()),S=(0,vo.useRef)(null!=p?p:0),[T,I]=(0,vo.useState)(null),[P,E]=(0,vo.useState)(!1),[A,F]=(0,vo.useState)(null),[M,O]=(0,vo.useState)(null),R=(0,vo.useCallback)((e=>{if(!x)return;const[t]=[...e.getVirtualItems()].reverse();if(!t)return;t.index>
1=g.length-v-1&&C.current&&x()}),[x,g.length,v]),z=(0,Ms.MG)({count:g.length,getItemKey:d,getScrollElement:()=>M,estimateSize:()=>m,onChange:R,overscan:b}),D=(0,vo.useMemo)((()=>{let e=-1;return g.reduce(((t,n,i)=>{var r,o;const s=null!=(r=null==c?void 0:c(i))&&r,a=null!=(o=null==u?void 0:u(i))&&o;return s||(e+=1),t[i]={activeIndex:s?null:e,disabled:s,selected:a},t}),[])}),[c,u,g]),B=(0,vo.useMemo)((()=>D.filter((e=>!e.disabled)).length),[D]),L=(0,vo.useCallback)((e=>null==A?void 0:A.setAttribute("data-enabled",(!e).toString())),[A]),Z=(0,vo.useCallback)((e=>"".concat(_.current,"-item-").concat(e)),[]),N=(0,vo.useCallback)((()=>"".concat(_.current,"-children")),[]),q=(0,vo.useCallback)((()=>{const e=[f,M].some((e=>document.activeElement===e));if(y&&!e&&!P)return;const t=Array.from((null==T?void 0:T.children)||[]);null==t||t.forEach((e=>{var t,i,r;const o=Number(null==(t=e.dataset)?void 0:t.index),s=null==(i=D[o])?void 0:i.activeIndex;null==(r=e.querySelector(Iu))||r.toggleAttribute(n,s===S.current)}))}),[n,null==T?void 0:T.children,P,f,D,y,M]),U=(0,vo.useCallback)((()=>{const e=Array.from((null==T?void 0:T.children)||[]);null==e||e.forEach((e=>{var t;null==(t=e.querySelector(Iu))||t.toggleAttribute(n,!1)}))}),[n,null==T?void 0:T.children]),V=(0,vo.useMemo)((()=>Ps()(q,200)),[q]),K=(0,vo.useCallback)((()=>{const e=null==S?void 0:S.current;g.length>0?(null==f||f.setAttribute("aria-activedescendant",Z(e)),null==M||M.setAttribute("aria-activedescendant",Z(e))):(null==f||f.removeAttribute("aria-activedescendant"),null==M||M.removeAttribute("aria-activedescendant"))}),[Z,f,g.length,M]),H=(0,vo.useCallback)((()=>{var e,t;const n=null==T?void 0:T.parentElement;if(T&&n){const i=n.getBoundingClientRect().top-T.getBoundingClientRect().top;return null!=(t=null==(e=z.getVirtualItemForOffset(i))?void 0:e.index)?t:-1}return-1}),[T,z]),$=(0,vo.useCallback)((e=>{let{index:t,scrollAlign:n,scrollIntoView:i=!0}=e;if(S.current=t,K(),q(),i){const e=D.findIndex((e=>e.activeIndex===t));e>-1&&z.scrollToIndex(e,n?{align:n}:{})}}),[K,D,q,z]),W=(0,vo.useCallback)((e=>{let t=-1;const n=B-1;if("next"===e){const e=w?0:n;t=S.current<B-1?S.current+1:e}if("previous"===e){const e=w?n:0;t=S.current>0?S.current-1:e}$({index:t,scrollIntoView:!0}),L(!1)}),[B,L,$,w]),G=(0,vo.useCallback)((e=>{switch(e){case"input":null==f||f.focus();break;case"list":null==M||M.focus()}}),[f,M]),X=(0,vo.useCallback)((()=>{null==f||f.focus()}),[f]),Y=(0,vo.useCallback)((()=>{null==M||M.focus()}),[M]),J=(0,vo.useCallback)((e=>()=>{$({index:e,scrollIntoView:!1})}),[$]),Q=(0,vo.useCallback)((()=>{q()}),[q]),ee=(0,vo.useCallback)((e=>t=>{const n=Array.from((null==T?void 0:T.children)||[]);if(n.length&&("ArrowDown"===t.key&&(t.preventDefault(),G(e),W("next")),"ArrowUp"===t.key&&(t.preventDefault(),G(e),W("previous")),"Enter"===t.key)){t.preventDefault(),G(e);const i=n.find((e=>Number(e.dataset.index)===D.findIndex((e=>e.activeIndex===S.current))));if(i){const e=null==i?void 0:i.querySelector(Iu);null==e||e.click()}}}),[null==T?void 0:T.children,G,D,W]),te=(0,vo.useCallback)((e=>ee("input")(e)),[ee]),ne=(0,vo.useCallback)((e=>ee("list")(e)),[ee]),ie=(0,vo.useCallback)((()=>{y&&(q(),E(!0))}),[y,q]),re=(0,vo.useCallback)((()=>{y&&(U(),E(!1))}),[U,y]);(0,vo.useImperativeHandle)(t,(()=>({focusInputElement(){X()},focusListElement(){Y()},getTopIndex:()=>H(),scrollToIndex(e){$({index:e}),L(!0)}})),[L,X,Y,H,$]),(0,vo.useEffect)((()=>{"undefined"===typeof p||C.current||$({index:p,scrollAlign:h,scrollIntoView:!0}),C.current=!0}),[p,h,y,$]),(0,vo.useEffect)((()=>{function e(){L(!0)}return null==M||M.addEventListener("mousemove",e),null==M||M.addEventListener("wheel",e),()=>{null==M||M.removeEventListener("mousemove",e),null==M||M.removeEventListener("wheel",e)}}),[L,M]),(0,vo.useEffect)((()=>(null==f||f.addEventListener("focus",Q),null==f||f.addEventListener("keydown",te),null==M||M.addEventListener("focus",Q),null==M||M.addEventListener("keydown",ne),()=>{null==f||f.removeEventListener("focus",Q),null==f||f.removeEventListener("keydown",te),null==M||M.removeEventListener("focus",Q),null==M||M.removeEventListener("keydown",ne)})),[s,Q,ee,te,ne,U,f,q,M]),(0,vo.useEffect)((()=>{K()}),[K,g]),(0,vo.useEffect)((()=>{const e=new MutationObserver(V);return T&&e.observe(T,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[T,V]),(0,vo.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")}
1),[N,f]),(0,vo.useEffect)((()=>{o&&G(o)}),[o,s,Y,X,G]);const oe=s?0:-1;return(0,go.jsxs)(Au,{id:N(),onMouseEnter:ie,onMouseLeave:re,ref:O,sizing:"border",tabIndex:oe,...k,children:[s&&(0,go.jsx)(Pu,{offset:l}),(0,go.jsx)(Eu,{"aria-hidden":"true","data-enabled":!0,ref:F}),z&&(0,go.jsx)(Fu,{$height:z.getTotalSize(),"aria-label":i,"aria-multiselectable":r,flex:1,ref:I,role:"listbox",children:z.getVirtualItems().map((e=>{const t=e.index,{activeIndex:n,disabled:i,selected:o}=D[t],s=j(g[t],{activeIndex:n,disabled:i,selected:o,virtualIndex:t}),l=(0,vo.cloneElement)(s,{tabIndex:-1}),c="number"!==typeof n||i?{}:{"aria-posinset":n+1,...r?{"aria-selected":o.toString()}:{},"aria-setsize":B,id:Z(n),role:"option",onMouseEnter:J(n)};return(0,go.jsx)("div",{"data-index":t,ref:a?void 0:z.measureElement,style:{flex:1,...a?{height:"".concat(e.size,"px")}:{},left:0,position:"absolute",top:0,transform:"translateY(".concat(e.start,"px)"),width:"100%"},tabIndex:-1,...c,children:l},e.key)}))})]})}));const Ou=new WeakMap;let Ru=0;function zu(e){const t=Ou.get(e);if(t)return t;const n="".concat(e.name||e.displayName||"<anonymous>","-").concat(Ru++);return Ou.set(e,n),n}function Du(e,t){(0,vo.useEffect)(e,function(e){const t=(0,vo.useRef)(void 0);return zs()(e,t.current)||(t.current=e),[t.current]}(t))}const Bu=(0,vo.memo)((function(e){const{hook:t,args:n,id:i,onNext:r,onReset:o,onRequestUpdate:s}=e,a=t({...n,onComplete:()=>{o(i)}});return Du((()=>(r(i,a),s(),()=>{r(i,null),s()})),a),null}),((e,t)=>e.args===t.args)),Lu=e=>clearTimeout(e),Zu="undefined"===typeof requestIdleCallback?e=>{const t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,Date.now()-t)})}),1)}:requestIdleCallback,Nu=Lu,qu={trailing:!0};function Uu(e){const{hooks:t,args:n,children:i,onReset:r}=e,o=(0,vo.useRef)({}),[s,a]=(0,vo.useState)(0),[l,c]=(0,vo.useState)({}),d=(0,vo.useRef)(null),u=(0,vo.useCallback)((()=>{d.current&&Nu(d.current),d.current=Zu((()=>{d.current=null,a((e=>e+1))}))}),[]),p=(h=u,f=60,m=qu,(0,vo.useMemo)((()=>Ps()(h,f,m)),[h,m,f]));var h,f,m;const g=(0,vo.useCallback)(((e,t)=>{if(null===t)delete o.current[e];else{const n=o.current[e];o.current[e]={...n,value:t}}}),[]),x=(0,vo.useCallback)((e=>{c((t=>({...t,[e]:(t[e]||0)+1}))),r&&r()}),[r]),v=(0,vo.useMemo)((()=>t.map((e=>zu(e)))),[t]),y=(0,vo.useMemo)((()=>v.map((e=>{var t;return null==(t=o.current[e])?void 0:t.value})).filter(wd)),[v,s]);return(0,go.jsxs)(go.Fragment,{children:[t.map((e=>{const t=zu(e),i=l[t]||0;return(0,go.jsx)(Bu,{hook:e,id:t,args:n,onNext:g,onRequestUpdate:p,onReset:x},"".concat(t,"-").concat(i))})),i({states:y})]})}function Vu(e){const{currentUser:t,title:n="Insufficient permissions",operationLabel:i="access this feature"}=e,r=(null==t?void 0:t.roles)||[],o=1!==r.length;return(0,go.jsxs)(Co.xu,{padding:2,children:[(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.vaB,{})}),(0,go.jsx)(Co.xv,{weight:"semibold",children:n})]}),(0,go.jsx)(Co.gF,{marginTop:4,children:(0,go.jsx)(Co.xv,{size:1,children:0===r.length?(0,go.jsxs)(go.Fragment,{children:["You have no role that grants you permission to ",i]}):(0,go.jsxs)(go.Fragment,{children:["Your role",o&&"s"," ",(s=r.map((e=>(0,go.jsx)("code",{children:e.title},e.name))),a=(0,go.jsx)(go.Fragment,{children:", "}),s.reduce(((e,t)=>null===e?[t]:[...e,a,t]),null))," ","do",o||"es"," not have permissions to ",i]})})})]});var s,a}const Ku=(0,Es.ZP)(Co.W2)((e=>{const{theme:t}=e,{container:n,media:i}=t.sanity;return(0,Co.Lt)(i,e.$width,(e=>({width:"auto"===e?"none":(0,Co.hO)(n[e]),maxWidth:"100%"})))})),Hu=vo.forwardRef((function(e,t){const{width:n,...i}=e,r=(0,Co.Q5)(n);return(0,go.jsx)(Ku,{...i,"data-ui":"PopoverContainer",$width:r,ref:t})})),$u=(0,Es.ZP)(Co.J2)((()=>(0,Es.iv)(j||(j=rd(["\n // Make the popover scrollable if it overflows the viewport\n [data-ui='Popover__wrapper'] {\n overflow: auto;\n }\n "]))))),Wu=(0,Es.ZP)(Co.mh)((e=>{const t=e.theme.sanity.radius[3];return(0,Es.iv)(w||(w=rd(["\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 Gu(e){const{children:t,header:n,onClose:i,referenceElement:r,containerRef:o,width:s}=e,a=(0,vo.useCallback)((()=>{i(),null==r||r.focus()}),[i,r]),l=(0,go.jsx)(Hu,{width:s,ref:o,children:(0,go.jsx)(Ls.ZP,{autoFocus:!0,children:(0,go.jsxs)(Co.Kq,{children:[(0,go.jsx)(Wu,{children:(0,go.jsx)(Co.xu,{padding:2,paddingLeft:3,children:(0,go.jsxs)(Co.kC,{align:"center",gap:2,children:[(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.xv,{textOverflow:"ellipsis",weight:"semibold",children:n})}),(0,go.jsx)(Co.zx,{icon:Ds.Two,mode:"bleed",onClick:a})]})})}),t]})})});return(0,go.jsx)($u,{portal:!0,constrainSize:!0,content:l,open:!0,referenceElement:r})}const Xu=(0,Es.ZP)(Co.Zb)((()=>(0,Es.iv)(k||(k=rd(["\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 "]))))),Yu=(0,vo.createContext)({selected:!1});const Ju=(0,vo.forwardRef)((function(e,t){const{children:n,selected:i,as:r,...o}=e;return(0,go.jsx)(Xu,{"data-ui":"PreviewCard",...o,forwardedAs:r,ref:t,selected:i,children:(0,go.jsx)(Yu.Provider,{value:{selected:i},children:n})})})),Qu={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}}
1,ep={block:31,blockImage:45,default:33,detail:45,inline:15,media:45},tp=Es.ZP.span((e=>{const{$dimensions:t,$layout:n,$radius:i,$responsive:r}=e,o=t.width||0,s=t.width||0,a=ep[n];return(0,Es.iv)(C||(C=rd(["\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\u2019t use the ":after" pseudo-element:\n The thing is we only want the shadow when then <MediaWrapper> contains\n something else than <svg> \u2013 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,Co.hO)(o),r?"100%":(0,Co.hO)(s),r?void 0:(0,Co.hO)(o),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[i])}),a)}));function np(e){const{border:t=!0,dimensions:n,layout:i,media:r,radius:o=1,responsive:s=!1,styles:a}=e;return(0,go.jsxs)(tp,{$dimensions:n,$layout:i,$radius:o,$responsive:s,className:null==a?void 0:a.media,"data-testid":"Media",children:[ip({dimensions:n,layout:i,media:r}),t&&(0,go.jsx)("span",{})]})}function ip(e){const{dimensions:t,layout:n,media:i,styles:r}=e;return(0,Us.isValidElementType)(i)?(0,vo.createElement)(i,{dimensions:t,layout:n}):"string"===typeof i?(0,go.jsx)(Co.xv,{as:"span",className:null==r?void 0:r.mediaString,children:i}):(0,vo.isValidElement)(i)?i:null}function rp(e,t,n){return"string"===typeof e?e:(0,Us.isValidElementType)(e)?(0,vo.createElement)(e,{layout:t}):e||n}tp.displayName="MediaWrapper";const op={...Qu.default,aspect:1,fit:"crop",dpr:(0,qs.x)()},sp=(0,Es.ZP)(Co.kC)(_||(_=rd(["\n height: ",";\n"])),(0,Co.hO)(Qu.default.height)),ap=(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1})(S||(S=rd(["\n max-width: ",";\n width: 80%;\n"])),(0,Co.hO)(160)),lp=(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1,size:1})(T||(T=rd(["\n max-width: ",";\n width: 60%;\n"])),(0,Co.hO)(120));function cp(e){const{title:t,subtitle:n,media:i,status:r,isPlaceholder:o,children:s,styles:a}=e,l=Ns()(null==a?void 0:a.root,Boolean(n)&&(null==a?void 0:a.hasSubtitle)),c=r&&(0,go.jsx)(Co.xu,{className:null==a?void 0:a.status,"data-testid":"default-preview__status",paddingLeft:3,paddingRight:1,children:rp(r,"default")});return o?(0,go.jsxs)(sp,{align:"center",className:null==a?void 0:a.placeholder,"data-testid":"default-preview",children:[!1!==i&&(0,go.jsx)(Co.Od,{animated:!0,marginRight:2,radius:2,style:Qu.default}),(0,go.jsxs)(Co.Kq,{"data-testid":"default-preview__heading",flex:1,paddingLeft:!1===i?1:2,paddingRight:r?0:1,space:2,children:[(0,go.jsx)(ap,{}),(0,go.jsx)(lp,{})]}),c]}):(0,go.jsxs)(sp,{align:"center",className:l,"data-testid":"default-preview",children:[!1!==i&&void 0!==i&&(0,go.jsx)(np,{dimensions:op,layout:"default",media:i,styles:a}),(0,go.jsxs)(Co.Kq,{className:null==a?void 0:a.heading,"data-testid":"default-preview__header",flex:1,paddingLeft:i?2:1,paddingRight:r?0:1,space:2,children:[(0,go.jsxs)(Co.xv,{className:null==a?void 0:a.title,style:{color:"inherit"},textOverflow:"ellipsis",children:[t&&rp(t,"default"),!t&&(0,go.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})]}),n&&(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",className:null==a?void 0:a.subtitle,children:rp(n,"default")}),s&&(0,go.jsx)("div",{className:null==a?void 0:a.children,children:s})]}),c]})}const dp=(0,Es.ZP)(Co.kC).attrs({align:"center"})(I||(I=rd(["\n height: ",";
1\n"])),(0,Co.hO)(Qu.detail.height)),up=(0,Es.ZP)(Co.xu)(P||(P=rd(["\n white-space: nowrap;\n"]))),pp=(0,Es.ZP)(Co.Od).attrs({animated:!0,radius:2})(E||(E=rd(["\n width: ",";\n height: ",";\n"])),(0,Co.hO)(Qu.detail.width),(0,Co.hO)(Qu.detail.height)),hp=(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1})(A||(A=rd(["\n max-width: ","; /* 80% of 200px */\n width: 80%;\n"])),(0,Co.hO)(160)),fp=(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1,size:1})(F||(F=rd(["\n max-width: ","; /* 60% of 200px */\n width: 60%;\n"])),(0,Co.hO)(120)),mp=(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1,size:1})(M||(M=rd(["\n max-width: ","; /* 90% of 200px */\n width: 90%;\n"])),(0,Co.hO)(180)),gp=(0,Es.ZP)(Co.xv)((e=>{let{theme:t}=e;const{fonts:n}=t.sanity,i=2*n.text.sizes[1].lineHeight;return(0,Es.iv)(O||(O=rd(["\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,Co.hO)(i),2)})),xp={...Qu.detail,fit:"crop",aspect:1,dpr:(0,qs.x)()};const vp=43,yp=Es.ZP.svg(R||(R=rd(["\n width: ","px;\n height: ","px;\n transform: rotate(-90deg);\n"])),vp,vp),bp=Es.ZP.circle((e=>{let{theme:t}=e;const{color:n}=t.sanity;return(0,Es.iv)(z||(z=rd(["\n fill: none;\n stroke: ",";\n stroke-width: ","px;\n "])),Vs.VG.gray[n.dark?900:100].hex,3)})),jp=Es.ZP.circle((e=>{let{theme:t}=e;const{color:n}=t.sanity;return(0,Es.iv)(D||(D=rd(["\n fill: none;\n stroke: ",";\n stroke-width: ","px;\n transition: stroke-dashoffset 75ms;\n "])),Vs.VG.blue[n.dark?400:500].hex,3)}));function wp(e){const{value:t}=e,n=Math.min(Math.max(t,0),100),i=2*Math.PI*20,r=(100-n)/100*i,o="".concat(21.5," ").concat(21.5," ").concat(vp," ").concat(vp);return(0,go.jsxs)(yp,{viewBox:o,children:[(0,go.jsx)(bp,{cx:vp,cy:vp,r:20}),(0,go.jsx)(jp,{cx:vp,cy:vp,r:20,style:{strokeDasharray:i,strokeDashoffset:"".concat(r,"px")}})]})}const kp=(0,Es.ZP)(Co.Zb)(B||(B=rd(["\n overflow: hidden;\n overflow: clip;\n"]))),Cp=(0,Es.ZP)(Co.Zb)((e=>{let{theme:t}=e;const{color:n}=t.sanity;return(0,Es.iv)(L||(L=rd(["\n height: ","rem;\n background: ",";\n transition: transform 75ms;\n "])),.5,Vs.VG.blue[n.dark?400:500].hex)}));function _p(e){const{value:t}=e;return(0,go.jsx)(kp,{radius:5,children:(0,go.jsx)(Cp,{radius:5,style:{transform:"translate3d(".concat(t-100,"%, 0, 0)")}})})}const Sp=(0,Es.ZP)(Co.xu)(Z||(Z=rd(["\n position: relative;\n"]))),Tp=(0,Es.ZP)(Co.kC).attrs({align:"center",justify:"center"})(N||(N=rd(["\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n"]))),Ip=(0,Es.ZP)(Co.Od).attrs({animated:!0,radius:2})(q||(q=rd(["\n width: 100%;\n height: 100%;\n"]))),Pp=(0,Es.ZP)(Co.kC).attrs({align:"center",justify:"center"})(U||(U=rd(["\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"]))),Ep=(0,Es.ZP)(Co.Kq).attrs({padding:2,space:2})(V||(V=rd(["\n max-width: ",";\n"])),(0,Co.hO)(200)),Ap={...Qu.media,aspect:1,fit:"crop",dpr:(0,qs.x)()};function Fp(e){const{media:t,mediaDimensions:n=Ap,children:i,isPlaceholder:r,progress:o=-1,subtitle:s,title:a,withBorder:l=!0,withRadius:c=!0}=e,d=n.aspect||1,u=(0,vo.useMemo)((()=>({paddingBottom:"".concat(100/d,"%")})),[d]),p=(0,vo.useMemo)((()=>a&&s?(0,go.jsxs)(Ep,{children:[a&&(0,go.jsx)(Co.xv,{align:"center",size:1,weight:"semibold",children:rp(a,"media")}),s&&(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:rp(s,"media")})]}):null),[s,a]);return(0,go.jsxs)(Sp,{"data-testid":"media-preview",overflow:"hidden",flex:1,children:[(0,go.jsx)("div",{style:u}),(0,go.jsx)(Co.u,{content:p,disabled:!p,placement:"top",portal:!0,children:(0,go.jsxs)(Tp,{children:[r?(0,go.jsx)(Ip,{}):(0,go.jsx)(np,{border:l,dimensions:n,layout:"media",media:t,radius:c?1:0,responsive:!0}),"number"===typeof o&&o>-1&&(0,go.jsx)(Pp,{children:(0,go.jsx)(wp,{value:o})})]})}),i]})}const Mp=(0,Es.ZP)(Co.kC).attrs({align:"center"})(K||(K=rd(["\n box-shadow: 0 0 0 1px var(--card-border-color);\n height: ",";\n white-space: nowrap;\n position: relative;\n z-index: 1;
1\n"])),(0,Co.hO)(Qu.block.height)),Op=(0,Es.ZP)(Co.Zb)(H||(H=rd(["\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})),Rp=(0,Es.ZP)(Co.xu).attrs({overflow:"hidden"})($||($=rd(["\n border-radius: ","px;\n"])),(e=>{let{theme:t}=e;return t.sanity.radius[1]})),zp={...Qu.blockImage,fit:"fillmax",dpr:(0,qs.x)()},Dp=e=>{const{height:t,width:n}=e;return t&&n?t/n*100:1};const Bp={...Qu.block,aspect:1,fit:"crop",dpr:(0,qs.x)()},Lp=(0,Es.ZP)(Co.kC).attrs({align:"center"})(W||(W=rd(["\n min-height: ",";\n"])),(0,Co.hO)(Qu.block.height));const Zp=Es.ZP.span(G||(G=rd(["\n display: inline-flex;\n align-items: center;\n vertical-align: top;\n height: calc(1em - 1px);\n max-width: 100%;\n"]))),Np=Es.ZP.span(X||(X=rd(["\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,Co.hO)(t.sanity.radius[1])}),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[1])})),qp=(0,Es.ZP)(Co.xv).attrs({forwardedAs:"span"})((e=>{let{theme:t}=e;const n=t.sanity.fonts.text,i=n.sizes[1];return(0,Es.iv)(Y||(Y=rd(["\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)})),Up={...Qu.inline,fit:"crop",aspect:1,dpr:(0,qs.x)()};(0,qs.x)(),(0,Es.ZP)(Co.xu)(J||(J=rd(["\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,Es.ZP)(Co.kC).attrs({align:"center"})(Q||(Q=rd(["\n height: ",";\n"])),(0,Co.hO)(Qu.default.height)),(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1})(ee||(ee=rd(["\n max-width: ",";\n width: 80%;\n"])),(0,Co.hO)(160)),(0,Es.ZP)(Co.Qr).attrs({animated:!0,radius:1,size:1})(te||(te=rd(["\n max-width: ",";\n width: 60%;\n"])),(0,Co.hO)(120));const Vp=["aria-hidden","disabled","href"];function Kp(e){const{direction:t="horizontal",initialFocus:n,loop:i=!0,navigation:r=["arrows"],pause:o=!1,rootElement:s}=e,[a,l]=(0,vo.useState)(-1),[c,d]=(0,vo.useState)([]),u=c.length,p=u-1,h="horizontal"===t?"ArrowRight":"ArrowDown",f="horizontal"===t?"ArrowLeft":"ArrowUp",m=(0,vo.useCallback)((()=>{if(s){const e=[...s.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled")&&"true"!==e.getAttribute("aria-hidden")));d(e)}}),[s]),g=(0,vo.useCallback)((e=>{l(e)}),[]),x=(0,vo.useCallback)((e=>{if(o)return;const t=()=>{e.preventDefault(),l((e=>{const t=(e+p)%u;return i||t!==p?t:e}))},n=()=>{e.preventDefault(),l((e=>{const 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())}),[o,f,r,h,p,u,i]);(0,vo.useEffect)((()=>{m()}),[m,n,t]),(0,vo.useEffect)((()=>{const e=new MutationObserver(m);return s&&e.observe(s,{childList:!0,subtree:!0,attributeFilter:Vp}),()=>{e.disconnect()}}),[c,m,s]),(0,vo.useEffect)((()=>{var e;if(c.forEach(((e,t)=>{t===a?(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===a&&c){null==(e=c["last"===n?p:0])||e.setAttribute("tabIndex","0")}}),[c,a,g,n,p]),(0,vo.useEffect)((()=>(null==s||s.addEventListener("keydown",x),()=>{null==s||s.removeEventListener("keydown",x)})),[x,s])}const Hp=(0,Es.ZP)(Co.xu)({position:"relative"}),$p=Es.ZP.div({position:"absolute",top:-4,right:-4,width:6,height:6,borderRadius:3,boxShadow:"0 0 0 1px var(--card-bg-color)"}),Wp=(0,vo.forwardRef)((function(e,t){const{disabled:n,fontSize:i,hotkey:r,icon:o,label:s,mode:a="bleed",space
1:l=3,text:c,tone:d,tooltip:u,...p}=e,h=(0,Co.Fg)(),f=d&&h.sanity.color.solid[d],m=(0,vo.useMemo)((()=>({backgroundColor:null==f?void 0:f.enabled.bg})),[f]),g=Boolean(n),x="object"===typeof n?(0,go.jsx)(Co.xv,{size:1,children:n.reason}):(0,go.jsxs)(Co.kC,{align:"center",gap:2,style:{lineHeight:0},children:[(0,go.jsx)(Co.xv,{size:1,children:s}),r&&(0,go.jsx)(Co.p8,{fontSize:0,keys:r,style:{margin:-4}})]});return(0,go.jsx)(Co.u,{padding:2,placement:"bottom",...u,content:x,disabled:!s,portal:!0,children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.zx,{"data-ui":"StatusButton",...p,"aria-label":s,disabled:g,mode:a,ref:t,children:(0,go.jsxs)(Co.kC,{gap:l,children:[(0,go.jsxs)(Hp,{children:[(0,go.jsxs)(Co.xv,{size:i,children:[(0,vo.isValidElement)(o)&&o,(0,Us.isValidElementType)(o)&&(0,vo.createElement)(o)]}),d&&(0,go.jsx)($p,{style:m})]}),c&&(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.xv,{size:i,children:c})})]})})})})})),Gp=(0,Es.ZP)(Co.xv)((e=>{let{$tone:t,theme:n}=e;const i=n.sanity.color.muted[t];return(0,Es.iv)(ne||(ne=rd(["\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)})),Xp=vo.forwardRef((function(e,t){const{tone:n,dimmed:i,muted:r,...o}=e;return(0,go.jsx)(Gp,{"data-ui":"TextWithTone","data-dimmed":i?"":void 0,"data-muted":r?"":void 0,$tone:n,muted:r,ref:t,...o})})),Yp=(0,vo.forwardRef)((function(e,t){const{children:n,content:i,disabled:r,...o}=e;return(0,go.jsx)(Co.u,{...o,content:i,disabled:r||!i,padding:2,ref:t,children:(0,go.jsx)("div",{children:n})})})),Jp=(0,vo.forwardRef)(((e,t)=>{const{push:n}=(0,Co.pm)();return(0,vo.useImperativeHandle)(t,(()=>({push:n}))),null}));Jp.displayName="ImperativeToast";const Qp={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,popoverBackground:1060,tooltip:200,modalBackground:2e3,spinner:3e3},eh=(0,vo.createContext)(Qp);function th(){return(0,vo.useContext)(eh)}function nh(e){let{children:t,zOffset:n}=e;const i=th()[n];return(0,go.jsx)(Co.li,{zOffset:i,children:t})}function ih(){const e=new WeakMap,t=new WeakMap;function n(e){const n=t.get(e);if(n)return n;const i=Array.from({length:10}).map((()=>Math.floor(255*Math.random()).toString(16).padStart(2,"0"))).join("");return t.set(e,i),i}function i(e){return Array.from(new Set(e)).map((e=>[n(e),e])).sort(((e,t)=>{let[n]=e,[i]=t;return n.localeCompare(i,"en")})).map((e=>{let[,t]=e;return t}))}function r(e,t){if(!e.length)return;const[n,...i]=e,o=t.get(n);return o?i.length?r(i,o.next):o.value:void 0}function o(e,t,n){if(!e.length)return;const[i,...r]=e,s=t.get(i)||{type:"multi-key-weak-map-node",value:void 0,next:new WeakMap};t.set(i,s),r.length?o(r,s.next,n):s.value=n}return{get:function(t){return r(i(t),e)},set:function(t,n){o(i(t),e,n)}}}const rh=(0,vo.createContext)(null);function oh(e){let{children:t}=e;const n=(0,vo.useMemo)((()=>{const e=new Map,t={};return{get:n=>{let{namespace:i,dependencies:r}=n;const o=r.map((e=>null===e?t:e)),s=e.get(i);return null==s?void 0:s.get(o)},set:n=>{let{namespace:i,dependencies:r,value:o}=n;const s=e.get(i)||ih(),a=r.map((e=>null===e?t:e));e.set(i,s),s.set(a,o)}}}),[]);return(0,go.jsx)(rh.Provider,{value:n,children:t})}function sh(){const e=(0,vo.useContext)(rh);if(!e)throw new Error("Could not find `cache` context");return e}var ah=Object.defineProperty,lh=(e,t,n)=>(((e,t,n)=>{t in e?ah(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class ch extends Error{constructor(e){let{projectId:t}=e;super("CorsOriginError"),lh(this,"projectId"),this.projectId=t}}const dh=(()=>{const e="__tmp_supports_local_storage";try{return"undefined"!==typeof localStorage&&(localStorage.setItem(e,"---"),localStorage.removeItem(e),!0)}catch(t){return!1}})(),uh={};function ph(e,t){dh?localStorage[e]=t:uh[e]=t}function hh(e){dh?localStorage.removeItem(e):delete uh[e]}const fh=/sid=[^&]{20,}/;let mh=function(){if("undefined"===typeof window||"object"!==typeof window.location)return null;const e=window.location.hash,[t]=e.match(fh)||[];if(!t)return null;const n=t.slice(t.indexOf("=")+1),i=e.replace(fh,""),r=new URL(window.location.href);return r.hash=i.length>1?i:"",history.replaceState(null,"",r),n}();const gh=()=>{const e=mh;return e&&(mh=null),e},xh=Es.ZP.svg((e=>{let{theme:t}=e;const{fg:n}=t.sanity.color.base;return(0,Es.iv)(ie||(ie=rd(["\n fill: ",";\n "])),n)}));const vh={google:()=>(0,go.jsxs)("svg",{width:"1em",height:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",children:[(0,go.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,go.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,go.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,go.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,go.jsx)(xh,{width:"1em",height:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 438.55 438.55",children:(0,go.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.
117 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){const{provider:t}=e;return t.logo?(0,go.jsx)("img",{src:t.logo,alt:"Logo for ".concat(t.name)}):void 0}};function yh(e){let{loginMethod:t,projectId:n,url:i,basePath:r}=e;const o=new URLSearchParams;return o.set("origin","".concat(window.location.origin).concat(r)),o.set("projectId",n),o.set("type",t),"".concat(i,"?").concat(o)}function bh(e){let{getClient:t,loginMethod:n,redirectOnSingle:i,...r}=e;const o=jd(t);return function(e){let{projectId:t,basePath:s}=e;const[a,l]=(0,vo.useState)(null),[c,d]=(0,vo.useState)(null);if(c)throw c;const[u]=o();(0,vo.useEffect)((()=>{u&&async function(e){let{client:t,mode:n,providers:i=[]}=e;const{providers:r,thirdPartyLogin:o,sso:s}=await t.request({uri:"/auth/providers"});if(!i.length)return r;const a=i.map((e=>{const t=r.some((t=>t.url===e.url)),n=t||o||s&&Object.values(s).some(Boolean);return{...e,custom:!t,supported:n}}));return"replace"===n?a:r.filter((e=>a.some((t=>t.url!==e.url)))).concat(a)}({client:u,...r}).then(l).catch(d)}),[u]);const p=i&&1===(null==a?void 0:a.length)&&(null==a?void 0:a[0])&&yh({loginMethod:n,projectId:t,url:a[0].url,basePath:s}),h=!a||p;return(0,vo.useEffect)((()=>{p&&(window.location.href=p)}),[p]),h?(0,go.jsxs)(Co.kC,{align:"center",direction:"column",gap:4,justify:"center",padding:6,sizing:"border",children:[(0,go.jsx)(Co.xv,{muted:!0,children:"Loading\u2026"}),(0,go.jsx)(Co.$j,{muted:!0})]}):(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Co.X6,{align:"center",size:1,children:"Choose login provider"}),(0,go.jsx)(Co.Kq,{space:2,children:a.map(((e,i)=>(0,go.jsx)(Co.zx,{icon:vh[e.name],as:"a",href:yh({loginMethod:n,projectId:t,url:e.url,basePath:s}),mode:"ghost",text:e.title},"".concat(e.url,"_").concat(i))))})]})}}const jh=e=>{if(!e)throw new Error("Invalid project id");return"__studio_auth_token_".concat(e)},wh=e=>{try{const n=(t=jh(e),dh?localStorage[t]:uh[t]);if(n){const{token:e}=JSON.parse(n);if(e&&"string"===typeof e)return e}}catch(n){console.error(n)}var t;return null},kh=e=>{try{hh(jh(e))}catch(t){console.error(t)}},Ch=async(e,t)=>{var n;try{const 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(i){if(401===i.statusCode)return kh(e.config().projectId||""),t(null),null;if(await e.request({uri:"/ping",withCredentials:!1,tag:"cors-check"}).then((()=>!0),(()=>!1)))throw new ch({projectId:null==(n=e.config())?void 0:n.projectId});if(i.isNetworkError&&!i.message&&i.request&&i.request.url){const e=new URL(i.request.url).host;throw new Error("Unknown network error attempting to reach ".concat(e))}throw i}};const _h=$s()((function(e){let{clientFactory:t,projectId:n,dataset:i,apiHost:r,loginMethod:o="dual",...s}=e;const{broadcast:a,messages:l}=function(e){const t="undefined"===typeof window?(0,So.of)():(0,Io.R)(window,"storage"),n="__studio_local_storage_messaging_".concat(e),i=new Po.x;return{messages:(0,Eo.T)(i,t.pipe((0,Yo.h)((e=>e.key===n)),(0,Ho.U)((e=>e.newValue)),(0,Yo.h)(wd),(0,Ho.U)((e=>JSON.parse(e))))).pipe((0,Jo.d)(1)),broadcast:function(e){try{ph(n,JSON.stringify(e)),hh(n),i.next(e)}catch(t){}}}}("dual_mode_auth_".concat(n)),c=null!=t?t:Ks.eI,d=l.pipe((0,Qo.O)("dual"
1===o?wh(n):null)),u={};r?u.apiHost=r:"undefined"!==typeof __SANITY_STAGING__&&!0===__SANITY_STAGING__&&(u.apiHost="https://api.sanity.work");const p=d.pipe((0,Ho.U)((e=>c({projectId:n,dataset:i,apiVersion:"2021-06-07",useCdn:!1,...e&&{token:e},withCredentials:!0,requestTagPrefix:"sanity.studio",ignoreBrowserTokenWarning:!0,allowReconfigure:!1,...u}))),(0,Go.w)((e=>(0,Ao.P)((async()=>{const t=await Ch(e,a);return{currentUser:t,client:e,authenticated:!!t}})))),(0,$o.x)(((e,t)=>Ss()(e.currentUser,t.currentUser))),(0,Jo.d)(1)),h=bh({...s,getClient:()=>p.pipe((0,Ho.U)((e=>e.client))),loginMethod:o});return{handleCallbackUrl:async function(){const e=gh();if(e&&"dual"===o){const t=c({projectId:n,dataset:i,useCdn:!0,withCredentials:!0,apiVersion:"2021-06-07",requestTagPrefix:"sanity.studio",...u});if(await Ch(t,a))a(null);else{const{token:i}=await t.request({method:"GET",uri:"/auth/fetch",query:{sid:e},tag:"auth.fetch-token"});(e=>{let{token:t,projectId:n}=e;try{ph(jh(n),JSON.stringify({token:t,time:(new Date).toISOString()}))}catch(i){console.error(i)}})({token:i,projectId:n}),a(i)}}else a("dual"===o?wh(n):null)},token:d,state:p,LoginComponent:h,logout:async function(){const e=c({projectId:n,dataset:i,useCdn:!0,withCredentials:!0,apiVersion:"2021-06-07",requestTagPrefix:"sanity.studio",...u});kh(n),await e.request({uri:"/auth/logout",method:"POST"}),a(null)}}}),(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 Sh(e){return"google"===e?"Google":"github"===e?"GitHub":"sanity"===e?"Sanity":(null==e?void 0:e.startsWith("saml-"))?"SAML/SSO":void 0}const Th="undefined"===typeof window?(0,So.of)({}):(0,Io.R)(window,"online"),Ih="undefined"===typeof window?(0,So.of)({}):(0,Io.R)(window,"offline"),Ph={type:"connecting"},Eh=(0,Ws.E)(),Ah=Eh[0];Eh[1];function Fh(e){let{bifur:t}=e;var n;return{connectionStatus$:(0,Eo.T)(t.heartbeats,Ih.pipe((0,es.j)((0,Fo._)(new Error("The browser went offline"))))).pipe((0,Ho.U)((e=>({type:"connected",lastHeartbeat:e}))),(n=(e,t,n)=>{const i=Math.min(24e4,(r=t,100*Math.pow(2,r)));var r;const o=new Date((new Date).getTime()+i),s=(0,Mo.H)(o),a=!navigator.onLine,l=(e=>{let{error:t,isOffline:n,attemptNo:i,retryAt:r}=e;return{type:"error",error:t,attemptNo:i,isOffline:n,retryAt:r}})({error:e,retryAt:o,isOffline:a,attemptNo:t}),c=Oo.C.pipe((0,ts.R)(a?Th:(0,Eo.T)(s,Th,Ah)));return(0,To.z)((0,So.of)(l),c.pipe((0,ns.q)(1)),n)},e=>{let t=[];const i=(0,Wo.K)(((e,r)=>(t.push(e),n(e,t.length,r).pipe(i))));return e.pipe((0,Ko.b)((()=>{t=[]})),i)}),(0,Qo.O)(Ph))}}const Mh=(0,Es.vJ)((e=>{let{theme:t}=e;const{color:n,fonts:i}=t.sanity;return{html:{backgroundColor:n.base.bg},"#sanity":{fontFamily:i.text.family}}}));function Oh(e){return e}function Rh(e){const t=["projectId"in e&&"`projectId` not allowed in plugin configuration","dataset"in e&&"`dataset` not allowed in plugin configuration"].filter(Xs());if(t.length)throw new Error("Invalid plugin configuration:\n".concat(t.map((e=>"\t".concat(e))).join("\n")))}function zh(e){if("function"===typeof e){const t=e;return e=>{const n=t(e);return Rh(n),n}}return Rh(e),()=>e}const Dh=(e,t,n)=>{let{document:i}=t;const 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 new Error("Expected `document.unstable_fieldActions` to be an array or a function, but received ".concat(typeof r))},Bh=[];const Lh=e=>"error"===e.severity,Zh=[{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\u2026",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 Nh(e){return"string"===typeof e.title?e.title:e.type?Nh(e.type):e.name||e.jsonType}const qh={apiVersion:"2022-09-09"},Uh=(0,Es.ZP)(Co.mh)(re||(re=rd(["\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n"])));function Vh(){return(0,go.jsx)(Uh,{children:(0,go.jsx)(Co.kC,{height:"fill",align:"center",justify:"center",children:(0,go.jsx)(Co.$j,{})})})}function Kh(e){const{text:t}=e;return(0,go.jsxs)(Co.kC,{direction:"row",justify:"center",align:"center",children:[(0,go.jsx)(Co.$j,{}),(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(Co.xv,{children:t})})]})}const Hh={referringDocuments:[],isLoading:!0};function $h(e){const t=gV();return(0,_o.m2)((()=>t.listenQuery("*[references($docId)] [0...101]",{docId:e},{tag:"use-referring-documents"}).pipe((0,Ho.U)((e=>({referringDocuments:e,isLoading:!1}))),(0,Qo.O)(Hh))),[t,e],Hh)}const Wh=()=>(0,vo.createElement)(vo.Fragment);function Gh(e){const{options:t}=SO().__internal,{defaultComponent:n,pick:i}=e;return(0,vo.useMemo)((()=>{const e=[...XR(t,[])];e.reverse();const r=e.map((e=>{let{config:t}=e;return i(t)})).filter(Boolean);return function(e,t){return n=>{let i=t=>(0,vo.createElement)(e,t);for(const e of t){const t=i;i=n=>(0,vo.createElement)(e,{...n,renderDefault:t})}return i({...n,renderDefault:Wh})}}(n,r)}),[n,t,i])}function Xh(e,t){return t.name===e||Boolean(t.type&&Xh(e,t.type))}const Yh={default:cp,media:Fp,detail:function(e){const{title:t,subtitle:n,description:i,mediaDimensions:r=xp,media:o,status:s,children:a,isPlaceholder:l}=e,c=s&&(0,go.jsx)(up,{marginLeft:3,paddingRight:1,children:rp(s,"detail")});return l?(0,go.jsxs)(dp,{"data-testid":"detail-preview",children:[!1!==o&&(0,go.jsx)(pp,{"data-testid":"detail-preview__media"}),(0,go.jsxs)(Co.xu,{flex:1,paddingLeft:!1===o?1:2,children:[(0,go.jsxs)(Co.kC,{align:"center","data-testid":"detail-preview__header",children:[(0,go.jsxs)(Co.Kq,{flex:1,space:2,children:[(0,go.jsx)(hp,{}),(0,go.jsx)(fp,{})]}),c]}),i&&(0,go.jsx)(Co.xu,{marginTop:3,children:(0,go.jsx)(mp,{})})]})]}):(0,go.jsxs)(dp,{"data-testid":"detail-preview",children:[!1!==o&&(0,go.jsx)(np,{dimensions:r,layout:"detail",media:o}),(0,go.jsxs)(Co.xu,{flex:1,paddingLeft:!1===o?1:2,children:[(0,go.jsxs)(Co.kC,{align:"center","data-testid":"detail-preview__header",children:[(0,go.jsxs)(Co.Kq,{flex:1,space:2,children:[(0,go.jsxs)(Co.xv,{textOverflow:"ellipsis",style:{color:"inherit"},children:[t&&rp(t,"detail"),!t&&(0,go.jsx)(go.Fragment,{children:"Untitled"})]}),n&&(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:rp(n,"detail")})]}),c]}),i&&(0,go.jsx)(Co.xu,{marginTop:3,children:(0,go.jsx)(gp,{muted:!0,size:1,children:rp(i,"detail")})})]}),a]})},inline:function(e){const{title:t,fallbackTitle:n="Untitled",media:i,mediaDimensions:r=Up}=e;return(0,go.jsxs)(Zp,{"data-testid":"inline-preview",children:[i&&(0,go.jsxs)(Np,{"data-testid":"inline-preview-media",children:[(o=i,s="inline",a=r,(0,Us.isValidElementType)(o)?(0,vo.createElement)(o,{layout:s,dimensions:a}):"string"===typeof o?(0,go.jsx)("div",{children:o}):o),(0,go.jsx)("span",{})]}),(0,go.jsx)(qp,{"data-testid":"inline-preview-title",size:1,children:rp(t,"inline",n)})]});var o,s,a},block:function(e){const{actions:t,title:n,subtitle:i,description:r,mediaDimensions:o=Bp,media:s,status:a,children:l}=e;return(0,go.jsxs)(Co.Kq,{"data-testid":"block-preview",space:1,children:[(0,go.jsxs)(Lp,{"data-testid":"block-preview__header",children:[s&&(0,go.jsx)(np,{dimensions:o,layout:"block",media:s}),(0,go.jsxs)(Co.xu,{flex:1,paddingLeft:s?2:1,children:[(0,go.jsx)(Co.xv,{size:1,textOverflow:"ellipsis",weight:"semibold",children:n?rp(n,"block"):"Untitled"}),i&&(0,go.jsx)(Co.xu,{marginTop:2,children:(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:rp(i,"block")})}),r&&(0,go.jsx)(Co.xu,{marginTop:3,children:(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:rp(r,"block")})})]}),(0,go.jsxs)(Co.kC,{gap:1,paddingLeft:1,children:[a&&(0,go.jsx)(Co.xu,{paddingX:2,paddingY:3,children:rp(a,"block")}),t]})]}),l&&(0,go.jsx)("div",{"data-testid":"block-preview__children",children:l})]})},blockImage:function(e){const{actions:t,title:n,subtitle:i,description:r,fallbackTitle:o="Untitled",mediaDimensions:s=zp,media:a,children:l,status:c}=e;return(0,go.jsxs)(Rp,{children:[(0,go.jsxs)(Co.Kq,{children:[(0,go.jsxs)(Mp,{paddingLeft:2,paddingRight:1,paddingY:1,children:[(0,go.jsxs)(Co.Kq,{flex:1,space:2,children:[(n||o)&&(0,go.jsx)(Co.xv,{size:1,textOverflow:"ellipsis",weight:"semibold",children:n?rp(n,"block"):o}),i&&(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:rp(i,"block")})]}),(0,go.jsxs)(Co.kC,{gap:1,paddingLeft:1,children:[c&&(0,go.jsx)(Co.xu,{paddingX:2,paddingY:3,children:rp(c,"block")}),t]})]}),(0,go.jsx)(Op,{$ratio:Dp(s),__unstable_checkered:!0,display:"flex",sizing:"border",tone:"inherit",children:(0,go.jsx)(np,{border:!1,dimensions:s,layout:"blockImage",media:a,radius:0,responsive:!0})})]}),r&&(0,go.jsx)(Co.xu,{paddingX:2,paddingY:3,children:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:rp(r,"block")})}),l&&(0,go.jsx)("div",{children:l})]})}};function Jh(){return(0,go.jsx)(Ds.$lS,{className:"sanity-studio__preview-fallback-icon"})}function Qh(e){const{icon:t,layout:n,media:i,imageUrl:r,title:o,...s}=e,a=WZ(qh),l=(0,vo.useMemo)((()=>Na()(a)),[a]),c=(0,vo.useCallback)((e=>{const{dimensions:t}=e;
1return(0,go.jsx)("img",{alt:Rd(o)?o:void 0,referrerPolicy:"strict-origin-when-cross-origin",src:l.image(i).width(t.width||100).height(t.height||100).fit(t.fit).dpr(t.dpr||1).url()||""})}),[l,i,o]),d=(0,vo.useCallback)((()=>(0,vo.createElement)(t||Jh)),[t]),u=(0,vo.useMemo)((()=>!1!==t&&((0,Us.isValidElementType)(i)||(0,vo.isValidElement)(i)?i:(0,qa.JZ)(i)?c:Rd(r)?(0,go.jsx)("img",{src:r,alt:Rd(o)?o:void 0,referrerPolicy:"strict-origin-when-cross-origin"}):d)),[t,r,i,d,c,o]),p=(0,vo.useMemo)((()=>({...s,media:u,title:o})),[u,s,o]),h=Yh[n||"default"];return(0,vo.createElement)(h,p)}const ef="undefined"===typeof window?Ro.E:(0,Io.R)(window,"resize").pipe((0,Jo.d)(1)),tf="undefined"===typeof window?Ro.E:(0,Io.R)(window,"scroll",{passive:!0,capture:!0}).pipe((0,Jo.d)(1)),nf="undefined"===typeof window?Ro.E:(0,Io.R)(window,"orientationchange").pipe((0,Jo.d)(1));const rf="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(){const e=new Po.x,t=new IntersectionObserver((t=>{t.forEach((t=>{e.next(t)}))}),{threshold:0,rootMargin:"".concat(150,"px")});return function(n){return new zo.y((e=>(t.observe(n),e.next(),()=>t.unobserve(n)))).pipe((0,is.z)((()=>e.asObservable())),(0,Yo.h)((e=>e.target===n)),(0,Ho.U)((e=>({isIntersecting:e.isIntersecting}))))}}():function(){function e(e){return()=>{return t=e.getBoundingClientRect(),n={left:0,right:window.innerWidth,top:0,bottom:window.innerHeight},i=150,t.left<=n.right+i&&t.right>=n.left-i&&t.top<=n.bottom+i&&t.bottom>=n.top-i;var t,n,i}}return function(t){const n=e(t);return(0,Eo.T)((0,So.of)(n()),ef,tf,nf).pipe((0,Ho.U)(n),(0,Ho.U)((e=>({isIntersecting:e}))))}}();const of="undefined"===typeof window?Ro.E:(0,Io.R)(document,"visibilitychange").pipe((0,Jo.d)(1));const sf={isLoading:!0},af={isLoading:!1};function lf(e){const{enabled:t=!0,ordering:n,schemaType:i,value:r}=e||{},{observeForPreview:o}=mV();return(0,_o.m2)((()=>t&&r&&i?o(r,i,{ordering:n}).pipe((0,Ho.U)((e=>({isLoading:!1,value:e.snapshot||void 0}))),(0,Wo.K)((e=>(0,So.of)({isLoading:!1,error:e})))):(0,So.of)(af)),[t,o,n,i,r],sf)}function cf(e){return function(e){var t,n;if(!Od(e))return;const i="number"===typeof e.progress?e.progress:0,r=df(e.initiated||e.createdAt),o=df(e.updated||e.updatedAt),s=df(null==(t=null==e?void 0:e.file)?void 0:t.name),a=df(null==(n=null==e?void 0:e.file)?void 0:n.type),l=df(e.previewImage);if(r&&o&&s&&a)return{progress:i,createdAt:r,updatedAt:o,file:{name:s,type:a},previewImage:l};return}(null==e?void 0:e._upload)}function df(e){return Rd(e)?e:void 0}function uf(e){const{layout:t,value:n,component:i,style:r,schemaType:o,skipVisibilityCheck:s,...a}=e,[l,c]=(0,vo.useState)(null),d=function(e){const{element:t,hideDelay:n=0}=e,[i,r]=(0,vo.useState)(!1);return(0,vo.useEffect)((()=>{if(!t)return;const e=(0,To.z)((0,So.of)(!document.hidden),of.pipe((0,Ho.U)((e=>{var t;return e.target instanceof Document&&!(null==(t=null==e?void 0:e.target)?void 0:t.hidden)})))).pipe((0,$o.x)()),i=rf(t).pipe((0,Ho.U)((e=>e.isIntersecting))),o=e.pipe((0,Go.w)((e=>e?i:(0,So.of)(!1))),(0,Go.w)((e=>e?(0,So.of)(!0):(0,So.of)(!1).pipe((0,rs.g)(n)))),(0,$o.x)()).subscribe(r);return()=>o.unsubscribe()}),[t,n]),i}({element:s?null:l,hideDelay:2e3}),u=lf({enabled:s||d,schemaType:o,value:n}),p=(0,vo.useMemo)((()=>({...r,minWidth:(null==r?void 0:r.minWidth)||1,minHeight:(null==r?void 0:r.minHeight)||1})),[r]),h=(0,vo.useMemo)((()=>cf(n)),[n]),f=(0,vo.useMemo)((()=>{var e,t;return(null==h?void 0:h.previewImage)?(0,go.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:o.icon}),[u,o,h]);return(0,go.jsx)("div",{ref:c,style:p,children:(0,vo.createElement)(i,{...a,...(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:o})})}function pf(e){const t=null==e?void 0:e.select;if(t)return Object.values(t).map((e=>String(e).split(".")))}function hf(e,t,n,i){const r=(e=>!0===e.liveEdit)(t)?(0,So.of)({snapshot:null}):e.observeForPreview({_type:"reference",_ref:Sd(n)},t),o=e.observeForPreview({_type:"reference",_ref:Td(n)},t);return(0,Do.a)([r,o]).pipe((0,Ho.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,Qo.O)({draft:null,isLoading:!0,published:null}))}const ff=e=>{let{value:t,draft:n,published:i}=e;const r=n||i;return r?Cc()({},r,t,((e,t)=>
1"undefined"===typeof t?e:t)):(o=t,{title:(0,go.jsx)("em",{children:o.title?String(o.title):"Missing document"}),subtitle:(0,go.jsx)("em",{children:o.title?"Missing document ID: ".concat(o._id):"Document ID: ".concat(o._id)}),media:()=>(0,go.jsx)(Ds.foC,{})});var o},mf=["_id","_rev","_type"],gf=[...mf,"_key"],xf={available:!0,reason:"READABLE"},vf={available:!1,reason:"PERMISSION_DENIED"},yf={available:!1,reason:"NOT_FOUND"},bf={title:"Invalid preview config",subtitle:"Check the error log in the console",media:(0,go.jsx)(Ds.foC,{})};function jf(e){return Array.isArray(e)&&(0===e.length||e.some(mo.DG))}function wf(e){const t=Array.isArray(e)&&e.find(mo.DG);return t&&t.children?t.children.filter(mo.NG).map((e=>e.text)).join(""):""}function kf(e){return Object.keys(e)}const Cf=["_id","_type","_upload","_createdAt","_updatedAt"],_f=[],Sf=(()=>{let e={};return{add:(t,n,i)=>{e[t.name]||(e[t.name]=[]),e[t.name].push({error:i,type:t,value:n})},getAll:()=>e,clear(){e={}}}})(),Tf=wo()((()=>{const e=Sf.getAll(),t=sl()(Object.keys(e).map((t=>{const n=e[t];return Hl()(n,(e=>e.error.message))}))).length;0!==t&&(console.groupCollapsed("%cHeads up! Got ".concat(1===t?"error":"".concat(t," errors")," while preparing data for preview. Click for details."),"color: #ff7e7c"),Object.keys(e).forEach((t=>{const n=e[t],i=n[0];console.group('Check the preview config for schema type "'.concat(t,'": %o'),i.type.preview);Hl()(n,(e=>e.error.message)).forEach((e=>{var t;if("returnValueError"===e.error.type){const 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){const{value:t,error:n}=e;console.log("Encountered an error when calling prepare(%o):",t),console.error(n)}})),console.groupEnd()})),console.groupEnd(),Sf.clear())}),1e3),If=e=>t=>{const n=typeof t;return null===t||"undefined"===n||"string"===n||"number"===n||"boolean"===n?_f:[Ff("returnValueError",new Error('The "'.concat(e,'" field should be a string, number, boolean, undefined or null, instead saw ').concat(Ef(t))))]},Pf={media:()=>_f,title:If("title"),subtitle:If("subtitle"),description:If("description"),imageUrl:If("imageUrl"),date:If("date")};function Ef(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(Od(e)){const n=Object.keys(e),i=n.length>3?"...":"",r="object with keys ";return"".concat(t?r:"","{").concat(n.slice(0,3).join(", ")).concat(i,"}")}if(Array.isArray(e)){const n=e.length>3?"...":"",i="array with ";return"".concat(t?i:"","[").concat(e.map((e=>Ef(e,!1)))).concat(n,"]")}return"the ".concat(typeof e," ").concat(e)}function Af(e,t){if("undefined"===typeof t)return _f;const n=Pf[e];return n&&n(t)||_f}function Ff(e,t){return Object.assign(t,{type:e})}function Mf(e){return{...e,errors:[...e.errors||[],...(t=e.returnValue,sc()(t)&&null!==t?Object.entries(t).reduce(((e,t)=>{let[n,i]=t;return[...e,...Af(n,i)]}),_f):[Ff("returnValueError",new Error("Invalid return value. Expected a plain object with at least a 'title' field, instead saw ".concat(Ef(t))))])]};var t}function Of(e){return kf(e).reduce(((t,n)=>{const i=e[n];return{...t,[n]:jf(i)?wf(i):i}}),{})}function Rf(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i;const r=null==(i=e.preview)?void 0:i.prepare;try{return{returnValue:r?r(t,n):Of(t),errors:_f}}catch(o){return{returnValue:null,errors:[Ff("prepareError",o)]}}}function zf(e,t,n){return e.errors.forEach((e=>Sf.add(t,n,e))),Tf(),bf}function Df(e){if(!function(e){const t=!(!e.options||"object"!==typeof e.options)&&e.options;if(!t||!("list"in t))return!1;const n=t.list;return Array.isArray(n)}(e))return;return e.options.list.map((e=>(0,mo.n4)(e)?e:{title:e,value:e}))}function Bf(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i,r;const o="function"===typeof(null==(i=t.preview)?void 0:i.prepare),s=(null==(r=t.preview)?void 0:r.select)||{},a=Object.keys(s),l=a.reduce(((n,i)=>{var r;const a="fields"in t?t:null,l=s[i],c=null==(r=null==a?void 0:a.fields)?void 0:r.find((e=>
1e.name===l)),d=c&&Df(c.type);if(!o&&d){const t=d&&d.find((t=>t.value===ic()(e,s[i])));n[i]=t?t.value:ic()(e,s[i])}else n[i]=ic()(e,s[i]);return n}),{}),c=Rf(t,l,n);if(c.errors.length>0)return zf(c,t,l);const d=Mf(Rf(t,l,n));return d.errors.length>0?zf(d,t,l):{...wc()(e,Cf),...c.returnValue}}function Lf(e,t){let n,i={},r=0;return function(){for(var e=arguments.length,s=new Array(e),a=0;a<e;a++)s[a]=arguments[a];return new zo.y((e=>{clearTimeout(n),n=setTimeout(o,t);const a={args:s,observer:e,completed:!1},l=r++;return i[l]=a,()=>{a.completed=!0}}))};function o(){const t=i;i={};const n=Object.keys(t).filter((e=>{const n=t[e];return n&&!n.completed}));if(0===n.length)return;const r=n.map((e=>{const n=t[e];return n&&n.args})).filter(wd);e(r).subscribe({next(e){e.forEach(((i,r)=>{const o=t[n[r]];o&&!o.completed&&o.observer.next(e[r])}))},complete(){n.forEach((e=>{const n=t[e];n&&!n.completed&&n.observer.complete()}))},error(e){n.forEach((n=>{const i=t[n];i&&!i.completed&&i.observer.error(e)}))}})}}function Zf(e,t){return e.push(...t),e}function Nf(e,t){function n(e){return t({_ref:e}
1,[["_rev"]]).pipe((0,Ho.U)((e=>Od(e)&&Boolean("_rev"in e&&(null==e?void 0:e._rev)))),(0,$o.x)(),(0,Go.w)((t=>t?(0,So.of)(xf):i(e))))}const i=Lf((function(e){const t=[...new Set(sl()(e))];return(0,Bo.D)(function(e){let t=[],n=0;const i=[];for(const 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,is.z)(r,10),(0,os.u)(Zf,[]),(0,Ho.U)((n=>e.map((e=>{let[i]=e;return n[t.indexOf(i)]})))))}),1);function r(t){return(0,Ao.P)((()=>{const n={uri:e.getDataUrl("doc",t.join(",")),json:!0,query:{excludeContent:"true"},tag:"preview.documents-availability"};return e.observable.request(n).pipe((0,Ho.U)((e=>{const n=Wa()(e.omitted||[],(e=>e.id));return t.map((e=>{const t=n[e];if(!t)return xf;if("existence"===t.reason)return yf;if("permission"===t.reason)return vf;throw new Error('Unexpected reason for omission: "'.concat(t.reason,'"'))}))})))}))}return{observeDocumentPairAvailability:function(e){const t=Sd(e),i=Td(e);return(0,Do.a)([n(t),n(i)]).pipe((0,$o.x)(zs()),(0,Ho.U)((e=>{let[t,n]=e;return{draft:t,published:n}})))}}}function qf(e,t,n){return{...e,[t]:n}}function Uf(e){return"_ref"in e}function Vf(e,t,n,i){if(!e||"object"!==typeof e)return(0,So.of)(e);const r=function(e){return Uf(e)?e._ref:"_id"in e?e._id:void 0}(e),o=r?{...e,_id:r}:{...e};"reference"===o._type&&(delete o._type,delete o._ref,delete o._weak,delete o._dataset,delete o._projectId,delete o._strengthenOnPublish);const s=function(e,t){return t.filter((t=>!(t[0]in e)))}(o,t);if(r&&s.length>0){const o=nl()(s.map((e=>e[0]))),a=Uf(e)?e._dataset:void 0,l=Uf(e)?e._projectId:void 0,c=a&&l?{projectId:l,dataset:a}:i;return n(r,o,c).pipe((0,Go.w)((i=>{return null===i?(0,So.of)(null):Vf({...(r=o,r.reduce(((e,t)=>(e[t]=void 0,e)),{})),...Uf(e)?{...e,...c}:e,...i},t,n,c);var r})))}const a={};t.forEach((e=>{const[t,...n]=e;a[t]||(a[t]=[]),a[t].push(n)}));const l=Object.keys(a).reduce(((t,r)=>{const o=a[r].filter((e=>e.length>0));return 0===o.length?t[r]=Od(e)?e[r]:void 0:t[r]=Vf(e[r],o,n,i),t}),o);return(0,So.of)(l).pipe(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new zo.y((e=>t.subscribe(e))).pipe((0,Go.w)((t=>{const n=kf(t).map((e=>{const n=t[e];return(0,Lo.b)(n)?(0,Bo.D)(n).pipe((0,Ho.U)((t=>[e,t]))):(0,So.of)([e,n])}));return e.wait?(0,Do.a)(n).pipe((0,Ho.U)((e=>e.reduce(((e,t)=>{let[n,i]=t;return qf(e,n,i)}),{})))):(0,Bo.D)(n).pipe((0,ss.J)(),(0,Xo.R)(((e,t)=>{let[n,i]=t;return qf(e,n,i)}),{}))})))}({wait:!0}))}function Kf(e){const{observeFields:t}=e;return{observePaths:(e,n,i)=>Vf(e,n.map((e=>"string"===typeof e?e.split("."):e)),t,i)}}function Hf(e){return sc()(e)}function $f(e){const{observeDocumentTypeFromId:t,observePaths:n}=e;return function e(i,r,o,s){if((0,mo.mz)(r)){if(!(0,mo.Yz)(i))return(0,So.of)({snapshot:void 0});const n={projectId:i._projectId,dataset:i._dataset};return t(i._ref,n).pipe((0,Go.w)((t=>{if(t){const o=r.to.find((e=>e.type===t));return e(i,o,{},n)}return(0,So.of)({snapshot:void 0})})))}if((0,mo.dD)(r))return function(e){return sc()(e)}(i)?t(i._ref).pipe((0,Go.w)((t=>{if(t){const n=r.to.find((e=>e.name===t));return e(i,n)}return(0,So.of)({snapshot:void 0})}))):(0,So.of)({snapshot:void 0});const a=pf(r.preview);return a?n(i,a,s).pipe((0,Ho.U)((e=>({type:r,snapshot:e&&Bf(e,r,o)})))):(0,So.of)({type:r,snapshot:i&&Hf(i)?Rf(r,i,o).returnValue:null})}}function Wf(e){return JSON.stringify(e)}const Gf=e=>qd(e)?'"'.concat(e,'": @').concat(Ud(e)):e;function Xf(e){let{ids:t,fields:n}=e;const i=[...mf,...n];return"*[_id in [".concat(t.map(Wf).join(","),"]][0...").concat(t.length,"]{").concat(i.map(Gf).join(","),"}")}const Yf=e=>e;function Jf(e){let t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Yf;for(let r=0;r<e.length;r++)if(0!==r){if(n=i(e[r]),t!==n)return!1;t=n}else t=i(e[r]);return!0}function Qf(e){const{observePaths:t,versionedClient:n}=e;let i;function r(e){const t=(()=>{if(!i){const e=(0,Bo.D)(n.listen('*[!(_id in path("_.**"))]',{},{events:["welcome","mutation"],includeResult:!1,visibility:"query",tag:"preview.global"})).pipe((0,as.B)()),t=e.pipe((0,Yo.h)((e=>"welcome"===e.type)),(0,Jo.d)({refCount:!0,bufferSize:1}));t.subscribe();const r=e.pipe((0,Yo.h)((e=>"mutation"===e.type)));i={welcome$:t,mutations$:r}}return i})();return(0,Eo.T)(t.welcome$,t.mutations$.pipe((0,Yo.h)((t=>t.documentId===e))))}function o(e){return function(t){const n=function(e){return Ec()(e.reduce(((e,t,n)=>{let[i,r]=t;const o=Fs()(r.join(","),Ic()).join(".");e[o]||(e[o]={fields:r,ids:[],map:[]});const s=e[o].ids.length;return e[o].ids[s]=i,e[o].map[s]=n,e}),{}))}(t);return e.observable.fetch(function(e){return"[".concat(e.map(Xf).join(","),"][0...").concat(e.length,"]")}(n),{},{tag:"preview.document-paths"}).pipe((0,Ho.U)((e=>function(e,t){return e.reduce(((e,n,i)=>
1(t[i].map.forEach(((r,o)=>{const s=t[i].ids[o],a=n.find((e=>e._id===s));e[r]=a||null})),e)),[])}(e,n))))}}const s=Lf(o(n),100),a=Lf(o(n),1e3);const l={},c=$s()((function(e){return Lf(o(n.withConfig(e)),10)}),(e=>e.dataset+e.projectId)),d=(0,Io.R)(document,"visibilitychange").pipe((0,Qo.O)(0),(0,Ho.U)((()=>"visible"===document.visibilityState)),(0,Go.w)((e=>e?(0,Mo.H)(0,1e4):Ro.E)),(0,as.B)());function u(e,t,n){let i=null;const o=(0,Eo.T)((0,Ao.P)((()=>null===i?Ro.E:(0,So.of)(i))),n?function(e,t,n){return d.pipe((0,Qo.O)(0)).pipe((0,Go.w)((()=>c(n)(e,t))))}(e,t,n):function(e,t){return r(e).pipe((0,Go.w)((n=>"welcome"===n.type||"query"===n.visibility?s(e,t).pipe((0,is.z)((n=>(0,To.z)((0,So.of)(n),void 0===n?a(e,t):[])))):a(e,t))))}(e,t)).pipe((0,Ko.b)((e=>i=e)),(0,Jo.d)({refCount:!0,bufferSize:1}));return{id:e,fields:t,changes$:o}}return{observeFields:function(e,t,n){const i=n?"".concat(n.projectId,":").concat(n.dataset,":").concat(e):"$current$-".concat(e);i in l||(l[i]=[]);const r=l[i];Sc()(t,sl()(r.map((e=>e.fields)))).length>0&&r.push(u(e,t,n));const o=r.filter((e=>e.fields.some((e=>t.includes(e))))).map((e=>e.changes$));return(0,Do.a)(o).pipe((0,Ho.U)((e=>e.filter(Boolean))),(0,Yo.h)((e=>Jf(e,(e=>e._rev)))),(0,Ho.U)((e=>0===e.length?null:function(e,t){return[...gf,...t].reduce(((t,n)=>{const i=function(e,t){let n;return e.some((e=>t in e&&(n=e[t],!0))),n}(e,n);return void 0!==i&&(t[n]=i),t}),{})}(e,t))),(0,$o.x)(function(e){return(t,n)=>t===n||!(!t||!n)&&"object"===typeof t&&"object"===typeof n&&e.every((e=>t[e]===n[e]))}(t)))}}}function em(e){let{client:t}=e;const n=t.withConfig({apiVersion:"1"}),{observeFields:i}=Qf({observePaths:(e,t,n)=>r(e,t,n),versionedClient:n}),{observePaths:r}=Kf({observeFields:i});function o(e,t){return r({_type:"reference",_ref:e},["_type"],t).pipe((0,Ho.U)((e=>Od(e)&&"string"===typeof e._type?e._type:void 0)),(0,$o.x)())}const s=$f({observeDocumentTypeFromId:o,observePaths:r}),{observeDocumentPairAvailability:a}=Nf(n,r),{observePathsDocumentPair:l}=function(e,t){const{observeDocumentPairAvailability:n}=Nf(e,t),i=[["_updatedAt"],["_createdAt"],["_type"]];return{observePathsDocumentPair:function(e,r){const{draftId:o,publishedId:s}=_d(e);return n(o).pipe((0,Go.w)((e=>{if(!e.draft.available&&!e.published.available)return(0,So.of)({id:s,type:null,draft:{availability:e.draft,snapshot:void 0},published:{availability:e.published,snapshot:void 0}});const n=[...r,...i];return(0,Do.a)([t({_type:"reference",_ref:o},n),t({_type:"reference",_ref:s},n)]).pipe((0,Ho.U)((t=>{let[n,i]=t;const r=Od(n)&&"_type"in n&&n._type||Od(i)&&"_type"in i&&i._type||null;return{id:s,type:"string"===typeof r?r:null,draft:{availability:e.draft,snapshot:n},published:{availability:e.published,snapshot:i}}})))})))}}}(n,r);return{observePaths:r,observeForPreview:s,observeDocumentTypeFromId:o,unstable_observeDocumentPairAvailability:a,unstable_observePathsDocumentPair:l}}const tm=e=>e.getTypeNames().map((t=>e.get(t))).filter(wd).filter((e=>{return t=e,Boolean(t.type&&"document"===t.type.name);var t})).filter((e=>!(e=>e.name.startsWith("sanity."))(e))),nm=(e,t)=>{const{phrases:n,words:i}=function(e){const t=nl()(e.map(Ja())),[n,i]=Xa()(t,(e=>/^".*"$/.test(e)));return{phrases:nl()(n).map(Ja()).map(om),words:nl()(i.map(Ja()))}}(e),[r,o]=function(e,t){const n=t.toLowerCase().trim();let 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),[s,a]=function(e,t){const n=nl()(Va()(rl()(Ja()(t)))),i=Ha()(e,n),r=el()(n,e),o=i.length/r.length;return 1===o?[1,"[Word] Exact match"]:[o/2,"[Word] Matched ".concat(i.length," of ").concat(r.length," terms: [").concat(i.join(", "),"]")]}(i,t);return[r+s,[a,o].join(", ")]},im=e=>"string"===typeof e?e:JSON.stringify(e);function rm(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const i=Wa()(e,(e=>e.typeName));return t.map(((e,r)=>{var o;const s=null==(o=i[e._type].paths||[])?void 0:o.map(((t,i)=>{const r=im(e["w".concat(i)]);if(!r)return{path:t.path,score:0,why:"No match"};const[o,s]=nm(n,r);return{path:t.path,score:o*t.weight,why:"".concat(s," (*").concat(t.weight,")")}}
1)),a=s.reduce(((e,t)=>e+t.score),0);return{hit:e,resultIndex:t.length-r,score:a,stories:s}}))}function om(e){return e.replace(/^"(.*)"$/,"$1")}const sm=/([^!@#$%^&*(),\\/?";:{}|[\]+<>\s-])+/g,am=/(^[.]+)|([.]+$)/;const lm=ll()([sl(),el(),Va()]);function cm(e,t){let n=!1;return{specs:e.map((e=>({typeName:e.name,paths:e.__experimental_search.map((e=>{const i=e.path.map((e=>"number"===typeof e&&(n=!0,t)?[]:e));return{weight:e.weight,path:Vd(i),mapWith:e.mapWith}}))}))),hasIndexedPaths:n}}const dm=e=>{let{mapWith:t,path:n}=e;return t?"".concat(t,"(").concat(n,")"):n};function um(e,t){const n=lm(t.map((e=>(e.paths||[]).map((e=>dm(e))))));return e.map(((e,t)=>n.map((e=>"".concat(e," match $t").concat(t))))).filter((e=>e.length>0)).map((e=>"(".concat(e.join(" || "),")")))}function pm(e){const t=[],n=e.replace(/("[^"]*")/g,(e=>rl()(e).length>1?(t.push(e),""):e));return[...t.map((e=>dl()(Ja()(e)))),...nl()(Va()((Ja()(n).match(sm)||[]).map((e=>e.replace(am,"")))))]}function hm(e){function t(e){return e.mapWith?"".concat(e.mapWith,"(").concat(e.field,")"):e.field}return(e||[]).map((e=>[t(e),(e.direction||"").toLowerCase()].map((e=>e.trim())).filter(Boolean).join(" "))).join(",")}function fm(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,i;const{filter:r,params:o,tag:s}=t,{specs:a,hasIndexedPaths:l}=cm(e.types,!1),c=pm(e.query),d=l?cm(e.types,!0).specs:a,u=["_type in $__types",!1===t.includeDrafts&&"!(_id in path('drafts.**'))",...um(c,d),r?"(".concat(r,")"):"",e.filter?"(".concat(e.filter,")"):""].filter(Boolean),p=a.map((e=>{const t='_type == "'.concat(e.typeName,'" => '),n="{ ".concat(e.paths.map(((e,t)=>'"w'.concat(t,'": ').concat(dm(e))))," }");return"".concat(t).concat(n)})),h=hm((null==t?void 0:t.sort)||[{field:"_id",direction:"asc"}]),f=["_type","_id"],m=p.length>0?"...select(".concat(p.join(",\n"),")"):"",g=f.join(", ")+(m?", ".concat(m):"");let x="*[".concat(u.join(" && "),"]| order(").concat(h,")[$__offset...$__limit]{").concat(g,"}");if(null==t?void 0:t.__unstable_extendedProjection){const e=null==t?void 0:t.__unstable_extendedProjection,n=f.concat(e).join(", ");x=["*[".concat(u.join(" && "),"]{").concat(n,"}"),"order(".concat(h,")[$__offset...$__limit]{").concat(g,"}")].join("|")}const v=["findability-mvi:".concat(4)].concat((null==t?void 0:t.comments)||[]).map((e=>"// ".concat(e))).join("\n"),y=v?"".concat(v,"\n").concat(x):x,b=null!=(n=null==t?void 0:t.offset)?n:0,j=(null!=(i=null==t?void 0:t.limit)?i:1e3)+b;return{query:y,params:{...mm(c),__types:a.map((e=>e.typeName)),__limit:j,__offset:b,...o||{}},options:{tag:s},searchSpec:a,terms:c}}const mm=e=>e.reduce(((e,t,n)=>(e["t".concat(n)]="".concat(t,"*"),e)),{});function gm(e,t){return"string"===typeof e?{query:e,types:t}:e.types.length?e:{...e,types:t}}function xm(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]:{};const o=gm(i,e),{query:s,params:a,options:l,searchSpec:c,terms:d}=fm(o,{...n,...r});return t.observable.fetch(s,a,l).pipe(n.unique?(0,Ho.U)(Pd):(0,Ko.b)(),(0,Ho.U)((e=>rm(c,e,d))),(null==r?void 0:r.skipSortByScore)?(0,Ko.b)():(0,Ho.U)((e=>Fs()(e,(e=>-e.score)))))}}const vm={available:!0,reason:"READABLE"},ym={available:!1,reason:"PERMISSION_DENIED"},bm={available:!1,reason:"NOT_FOUND"};function jm(e,t,n){const{publishedId:i,draftId:r}=_d(t);return e.unstable_observeDocumentPairAvailability(t).pipe((0,Go.w)((o=>{if(!o.draft.available&&!o.published.available){const e="PERMISSION_DENIED"===o.draft.reason||"PERMISSION_DENIED"===o.published.reason?ym:bm;return(0,So.of)({id:t,type:void 0,availability:e,preview:{draft:void 0,published:void 0}})}const s={_type:"reference",_ref:r},a={_type:"reference",_ref:i};return(0,Do.a)([e.observeDocumentTypeFromId(r),e.observeDocumentTypeFromId(i)]).pipe((0,Ho.U)((e=>{let[t,n]=e;return t||n}))).pipe((0,Go.w)((t=>{if(!t)return Ro.E;const l=n.to.find((e=>e.name===t));if(!l)return Ro.E;const c=[...pf(null==l?void 0:l.preview)||[],["_updatedAt"],["_createdAt"]],d=e.observePaths(s,c).pipe((0,Ho.U)((e=>e?{_id:r,...Bf(e,l)}:void 0)),(0,Qo.O)(void 0)),u=e.observePaths(a,c).pipe((0,Ho.U)((e=>e?{_id:i,...Bf(e,l)}:void 0)),(0,Qo.O)(void 0));return(0,Do.a)([d,u]).pipe((0,Ho.U)((e=>{let[t,n]=e;return{draft:t,published:n}}))).pipe((0,Ho.U)((e=>{const n=o.draft.available||o.published.available?vm:"PERMISSION_DENIED"===o.draft.reason||"PERMISSION_DENIED"===o.published.reason?ym:bm;return{type:t,id:i,availability:n,preview:{draft:Od(e.draft)?e.draft:void 0,published:Od(e.published)?e.published:void 0}}})))})))})))}function wm(e,t,n,i){return xm(n.to,e,i)(t,{includeDrafts:!0}).pipe((0,Ho.U)((e=>e.map((e=>e.hit)))),(0,Ho.U)(Id),(0,Ho.U)((e=>e.slice(0,100))),(0,is.z)((t=>{return function(e,t){return 0===t.length?(0,So.of)([]):e.observable.fetch("*[_id in $ids]._id",{ids:t},{tag:"get-counterpart-ids"})}(e,(n=t,n.filter((e=>!e.draft||!e.published)).map((e=>e.draft?e.id:Sd(e.id))))).pipe((0,Ho.U)((e=>t.map((t=>{const n=Sd(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}})))));var n})))}function km(){const e=[];return{publish(t){for(const n of e)n(t)},subscribe:t=>(e.push(t),()=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)})}}const Cm=Symbol.for("sanity.patch");function _m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{patchType:Cm,type:"setIfMissing",path:t,value:e}}function Sm(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{patchType:Cm,type:"insert",path:n,position:t,items:e}}function Tm(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{patchType:Cm,type:"set",path:t,value:e}}function Im(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{patchType:Cm,type:"unset",path:e}}var Pm=Object.defineProperty,Em=(e,t,n)=>(((e,t,n)=>{t in e?Pm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class Am{constructor(e){Em(this,"patches"),this.patches=e}static from(e){return e instanceof Am?e:new Am(Array.isArray(e)?
1sl()(e):[e])}prepend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Am.from([...sl()(t),...this.patches])}append(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Am.from([...this.patches,...sl()(t)])}prefixAll(e){return Am.from(this.patches.map((t=>function(e,t){return{...e,path:[t,...e.path]}}(t,e))))}}const Fm={warning:"caution",error:"critical"},Mm=(0,Es.ZP)(Co.xu)(oe||(oe=rd(["\n border-top: 1px solid var(--card-border-color);\n"])));function Om(e){const{children:t,status:n="warning",suffix:i,title:r,...o}=e;return(0,go.jsxs)(Co.Zb,{radius:2,tone:Fm[n],...o,"data-ui":"Alert",children:[(0,go.jsxs)(Co.kC,{padding:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsxs)(Co.xv,{size:1,children:["warning"===n&&(0,go.jsx)(Ds.foC,{}),"error"===n&&(0,go.jsx)(Ds.uIy,{})]})}),(0,go.jsxs)(Co.xu,{flex:1,marginLeft:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:r}),t&&(0,go.jsx)(Co.xu,{marginTop:3,children:t})]})]}),i&&(0,go.jsx)(Mm,{children:i})]})}function Rm(e,t){const n=(0,vo.useRef)(t||null);return(0,vo.useEffect)((()=>{n.current=e}),[e]),n.current}function zm(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:zs();const i=Rm(e);(0,vo.useEffect)((()=>{n(i,e)||t(i,e)}),[t,e,i,n])}function Dm(e,t){(0,vo.useEffect)((()=>{const n=n=>{const 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])}const Bm=(0,vo.createContext)(null);function Lm(){const e=(0,vo.useContext)(Bm);if(!e)throw new Error("FormBuilder: missing context value");return e}const Zm={constrainSize:!0,portal:!0};function Nm(e){const{schemaType:t,readOnly:n,children:i,onValueCreate:r,onItemAppend:o}=e,s=(0,vo.useId)(),a=(0,vo.useCallback)((e=>{const t=r(e);o(t)}),[r,o]),l=vo.useCallback((()=>{a(t.of[0])}),[t,a]);return n?(0,go.jsx)(Co.u,{portal:!0,content:(0,go.jsx)(Co.xu,{padding:2,sizing:"border",children:(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"This field is read-only"})}),children:(0,go.jsx)(Co.rj,{children:(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",disabled:!0,text:1===t.of.length?"Add item":"Add item..."})})}):(0,go.jsxs)(Co.rj,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[1===t.of.length?(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",onClick:l,text:"Add item"}):(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",text:"Add item\u2026"}),id:s||"",menu:(0,go.jsx)(Co.v2,{children:t.of.map(((e,t)=>{var n,i;const r=(0,mo.dD)(e)&&1===(e.to||[]).length&&e.to[0].icon,o=e.icon||(null==(n=e.type)?void 0:n.icon)||r;return(0,go.jsx)(Co.sN,{text:e.title||(null==(i=e.type)?void 0:i.name),onClick:()=>a(e),icon:o},t)}))}),popover:Zm}),i]})}const qm=e=>"error"===e?(0,go.jsx)(Ds.uIy,{}):"warning"===e?(0,go.jsx)(Ds.foC,{}):(0,go.jsx)(Ds.hQ6,{}),Um=(0,Es.ZP)(Co.xv)((e=>{let{theme:t}=e;return(0,Es.iv)(se||(se=rd(["\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 Vm(e){const{markers:t,validation:n,renderCustomMarkers:i}=e,{CustomMarkers:r}=Lm().__internal.components;return 0===t.length&&0===n.length?null:(0,go.jsxs)(Co.Kq,{space:1,children:[n.length>0&&n.map(((e,t)=>{let{message:i,level:r}=e;return(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{marginRight:2,marginBottom:t+1===n.length?0:2,children:(0,go.jsx)(Um,{size:1,"data-error":"error"===r?"":void 0,"data-warning":"warning"===r?"":void 0,"data-info":"info"===r?"":void 0,children:qm(r)})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:i||"Error"})})]},"validationItem-".concat(t))})),t.length>0&&(0,go.jsxs)(Co.xu,{marginTop:n.length>0?3:0,children:[i&&i(t),!i&&(0,go.jsx)(r,{markers:t})]})]})}function Km(){return(0,go.jsxs)(Co.xv,{size:1,children:["This is a example custom marker, please implement ",(0,go.jsx)("code",{children:"renderCustomMarkers"})," function."]})}const Hm=vo.createContext(null),$m=(0,vo.memo)((function(e){const t=(0,vo.useRef)(e);t.current=e;const n=(0,vo.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,vo.useCallback)((e=>{t.current.onChange(e)}
1),[]),r=(0,vo.useCallback)((e=>{t.current.onPathFocus(e)}),[]),o=(0,vo.useCallback)((e=>{t.current.onPathBlur(e)}),[]),s=(0,vo.useCallback)((e=>{t.current.onPathOpen(e)}),[]),a=(0,vo.useCallback)(((e,n)=>{t.current.onSetPathCollapsed(e,n)}),[]),l=(0,vo.useCallback)(((e,n)=>{t.current.onSetFieldSetCollapsed(e,n)}),[]),c=(0,vo.useCallback)(((e,n)=>{t.current.onFieldGroupSelect(e,n)}),[]),d=(0,vo.useMemo)((()=>({transformPatches:n,onChange:i,onPathFocus:r,onPathBlur:o,onPathOpen:s,onSetPathCollapsed:a,onSetFieldSetCollapsed:l,onFieldGroupSelect:c})),[i,c,o,r,s,l,a,n]);return(0,go.jsx)(Hm.Provider,{value:d,children:e.children})}));function Wm(){const e=(0,vo.useContext)(Hm);if(!e)throw new Error("Form context not provided");return e}function Gm(e,t){return Xm(e,t,new WeakSet)}function Xm(e,t,n){if(e===t)return e;if(n.has(t))return t;if(null==e||null==t)return t;if(typeof e!==typeof t)return t;if(Array.isArray(t)){n.add(t);let i=e.length===t.length;const r=[];for(let o=0;o<t.length;o++){const s=Xm(e[o],t[o],n);s!==e[o]&&(i=!1),r[o]=s}return i?e:r}if("object"===typeof t){n.add(t);const i=Object.keys(t);let r=Object.keys(e).length===i.length;const o={};for(const s of i){const i=Xm(e[s],t[s],n);i!==e[s]&&(r=!1),o[s]=i}return r?e:o}return t}const Ym=(0,vo.createContext)([]);function Jm(e){return(0,go.jsx)(Ym.Provider,{value:e.presence,children:e.children})}function Qm(e,t){const n=function(){const e=(0,vo.useContext)(Ym);if(!e)throw new Error("Form context not provided");return e}(),i=(0,vo.useRef)(n),r=Gm(i.current,n.filter((n=>(0,xo.Ny)(e,n.path)&&(t||!(0,xo.Xy)(e,n.path)))));return i.current=r,r}const eg=(0,vo.createContext)([]);function tg(e){return(0,go.jsx)(eg.Provider,{value:e.validation,children:e.children})}function ng(){const e=(0,vo.useContext)(eg);if(!e)throw new Error("Form context not provided");return e}function ig(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=ng();return(0,vo.useMemo)((()=>n.filter((n=>(0,xo.Ny)(e,n.path)&&(t||!(0,xo.Xy)(e,n.path)))).map((e=>({message:e.item.message,level:e.level,path:e.path})))),[t,e,n])}const rg=(0,vo.createContext)({actions:[],hovered:!1,onMouseEnter:()=>{},onMouseLeave:()=>{}});function og(){return(0,vo.useContext)(rg)}function sg(e){const{action:t}=e,n=(0,vo.useCallback)((()=>{t.onAction()}),[t]),i="object"===typeof t.disabled&&(0,go.jsx)(Co.xv,{size:1,children:t.disabled.reason});return(0,go.jsx)(Yp,{content:i,placement:"left",children:(0,go.jsx)(Co.sN,{disabled:Boolean(t.disabled),fontSize:1,icon:t.icon,iconRight:t.iconRight||(t.selected?Ds.KML:void 0),onClick:n,padding:3,pressed:t.selected,space:3,text:t.title,tone:t.tone})})}const ag={placement:"right",fallbackPlacements:["top","bottom"]};function lg(e){const{group:t}=e;return t.expanded?(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{padding:2,paddingBottom:1,children:(0,go.jsx)(Co.__,{muted:!0,size:0,children:t.title})}),t.children.map(((e,n)=>{var i;return(0,go.jsx)(cg,{action:e,isFirst:0===n,prevIsGroup:"group"===(null==(i=t.children[n-1])?void 0:i.type)},n)}))]}):(0,go.jsx)(Co.kS,{fontSize:1,icon:t.icon,padding:3,popover:ag,space:3,text:t.title,tone:t.tone,children:t.children.map(((e,n)=>{var i;return(0,go.jsx)(cg,{action:e,isFirst:0===n,prevIsGroup:"group"===(null==(i=t.children[n-1])?void 0:i.type)},n)}))})}function cg(e){const{action:t,isFirst:n,prevIsGroup:i}=e;return"divider"===t.type?(0,go.jsx)(Co.R,{}):"group"===t.type?(0,go.jsxs)(go.Fragment,{children:[!n&&(0,go.jsx)(Co.R,{}),(0,go.jsx)(lg,{group:t})]}):(0,go.jsxs)(go.Fragment,{children:[i&&(0,go.jsx)(Co.R,{}),(0,go.jsx)(sg,{action:t})]})}const dg={placement:"top"};function ug(e){return"renderAsButton"in e&&e.renderAsButton}const pg=(0,vo.memo)((function(e){const{focused:t,nodes:n}=e,{hovered:i}=og(),[r,o]=(0,vo.useState)(!1),s=(0,vo.useCallback)((()=>o(!0)),[]),a=(0,vo.useCallback)((()=>o(!1)),[]),l=(0,vo.useMemo)((()=>n.filter(ug)),[n]),c=(0,vo.useMemo)((()=>n.filter((e=>!ug(e)))),[n]),d=(0,vo.useMemo)((()=>{const e=c.length;if(0===e||e>1)return c;const t=c[0];return"group"===t.type?[{...t,expanded:!0}]:c}),[c]),u=(0,vo.useMemo)((()=>[...l,...d.length?[{type:"group",children:d,icon:Ds.zGg,title:"Field actions"}]:[]]),[l,d]),p=(0,vo.useMemo)((()=>({height:25,lineHeight:0,display:r||t||i?void 0:"none"})),[t,i,r]);return(0,go.jsx)(Co.kC,{gap:1,style:p,children:u.map(((e,t)=>(0,go.jsx)(hg,{node:e,onOpen:s,onClose:a,open:r},t)))})})),hg=(0,vo.memo)((function(e){const{node:t,onOpen:n,onClose:i,open:r}=e;return"divider"===t.type?(0,go.jsx)(Co.Zb,{borderLeft:!0,flex:"none"}):"action"===t.type?(0,go.jsx)(Wp,{fontSize:1,icon:t.icon,label:r?void 0:t.t
1itle,mode:Kd?"bleed":"ghost",onClick:t.onAction,padding:2,tooltip:dg}):(0,go.jsx)(mg,{node:t,onOpen:n,onClose:i,open:r})})),fg={constrainSize:!0,placement:"right",portal:!0,fallbackPlacements:["top","bottom"]};function mg(e){const{node:t,onOpen:n,onClose:i,open:r}=e;return(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Wp,{fontSize:1,icon:t.icon,label:r?void 0:t.title,mode:Kd?"bleed":"ghost",padding:2,tooltip:dg}),id:(0,vo.useId)(),menu:(0,go.jsx)(Co.v2,{children:t.children.map(((e,n)=>{var i;return(0,go.jsx)(cg,{action:e,isFirst:0===n,prevIsGroup:"group"===(null==(i=t.children[n-1])?void 0:i.type)},n)}))}),onOpen:n,onClose:i,popover:fg})}function gg(e){return e.filter(Boolean).filter((e=>!("hidden"in e)||!0!==e.hidden)).map((e=>"group"===e.type?{...e,children:gg(e.children)}:e))}const xg=(0,vo.memo)((function(e){const{actions:t,documentId:n,documentType:i,onActions:r,path:o,schemaType:s}=e,a=t.length,l=(0,vo.useRef)(a),[c,d]=(0,vo.useState)((()=>Array.from(new Array(a)))),u=(0,vo.useRef)(c),p=(0,vo.useCallback)(((e,t)=>{d((n=>{const i=[...n];return i[e]=t,i}))}),[]);return(0,vo.useEffect)((()=>{u.current!==c&&(u.current=c,r(gg(c)))}),[c,r]),(0,vo.useEffect)((()=>{if(l.current!==a){const e=Array.from(new Array(a));for(let t=0;t<a;t++)e[t]=u.current[t];l.current=a,d(e),u.current=e}}),[a]),(0,go.jsx)(go.Fragment,{children:t.map(((e,t)=>(0,go.jsx)(vg,{action:e,index:t,documentId:n,documentType:i,path:o,schemaType:s,setFieldAction:p},t)))})})),vg=(0,vo.memo)((function(e){const{action:t,documentId:n,documentType:i,index:r,path:o,schemaType:s,setFieldAction:a}=e,l=bd(t.useAction({documentId:n,documentType:i,path:o,schemaType:s}));return(0,vo.useEffect)((()=>{a(r,l)}),[r,l,a]),null})),yg=(0,vo.createContext)(null);function bg(){const e=(0,vo.useContext)(yg);if(!e)throw new Error("UserColorManager: missing context value");return e}const jg=["green","red","gray"],wg=Vs.mE.filter((e=>!jg.includes(e))),kg=e=>{const t="dark"===e;return{background:t?"900":"100",border:t?"700":"300",text:t?"200":"700"}};function Cg(e){const{anonymousColor:t,colors:n,currentUserColor:i,scheme:r}=e,o=n||(e=>{const{background:t,border:n,text:i}=kg(e);return wg.reduce(((e,r)=>(e[r]={name:r,background:Vs.VG[r][t].hex,border:Vs.VG[r][n].hex,text:Vs.VG[r][i].hex,tints:Vs.VG[r]},e)),{})})(r),s=t||(e=>{const{background:t,border:n,text:i}=kg(e);return{name:"gray",background:Vs.VG.gray[t].hex,border:Vs.VG.gray[n].hex,text:Vs.VG.gray[i].hex,tints:Vs.VG.gray}})(r),a=i||"purple";if(!o.hasOwnProperty(a))throw new Error("'colors' must contain 'currentUserColor' (".concat(a,")"));const l=Object.keys(o),c=new Map,d=new Map,u=l.reduce(((e,t)=>(e[t]=0,e)),{}),p=new Map;let h;return(null==e?void 0:e.userStore)&&e.userStore.me.subscribe((e=>{return t=e?e.id:null,h=t,void(u[a]+=t?1:-1);var t})),{get:function(e){if(!e)return s;return o[f(e)]},listen:function(e){let t=c.get(e);if(t)return t;const n=f(e);return t=g(e,n),c.set(e,t),t}};function f(e){if(e===h)return a;const t=p.get(e);if(t)return t;const n=d.get(e);if(n&&(0===u[n]||!Boolean(l.find((e=>0===u[e])))))return m(e,n);const i=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return l[Math.abs(t)%l.length]}(e);return 0===u[i]?m(e,i):m(e,function(e){let t=1/0,n=[];return l.forEach((e=>{const i=u[e];i===t?n.push(e):i<t&&(t=i,n=[e])})),e&&n.includes(e)?e:n[0]}(n))}function m(e,t){return p.set(e,t),d.set(e,t),u[t]++,t}function g(e,t){return new zo.y((n=>{const i=o[t];return n.next(i),()=>{c.delete(e),function(e,t){p.delete(e),u[t]--}(e,t)}})).pipe((0,Jo.d)({refCount:!0}))}}function _g(e){let{children:t,manager:n}=e;const{scheme:i}=Cz(),r=(0,vo.useMemo)((()=>n||Cg({scheme:i})),[n,i]);return(0,go.jsx)(yg.Provider,{value:r,children:t})}const Sg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tg=/_key\s*==\s*['"](.*)['"]/;function Ig(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,n)=>{const i=typeof t;if("number"===i)return"".concat(e,"[").concat(t,"]");if("string"===i){const i=0===n?"":".";return"".concat(e).concat(i).concat(t)}if((0,mo.Fd)(t)&&t._key)return"".concat(e,'[_key=="').concat(t._key,'"]');if(Array.isArray(t)){const[n,i]=t;return"".concat(e,"[").concat(n,":").concat(i,"]")}throw new Error("Unsupported path segment `".concat(JSON.stringify(t),"`"))}),"")}function Pg(e,t){const n=t[0];if(!n)return e;const i=t.slice(1);if((0,mo.dw)(n))return Pg(Array.isArray(e)?e[n]:void 0,i);if((0,mo.Fd)(n))return Pg(Array.isArray(e)?e.find((e=>e._key===n._key)):void 0,i);if("string"===typeof n)return Pg(Od(e)?e[n]:void 0,i);throw new Error("Unknown segment type ".concat(JSON.stringify(n)))}function Eg(e,t){return"number"===typeof t||(0,mo.Fd)(t)?"number"===typeof t?t:e.findIndex((e=>(0,mo.fU)(e)&&e._key===t._key)):-1}function Ag(e){const t=e.match(Sg);if(!t)throw new Error("Invalid path string");return t.map(Fg)}function Fg(e){return(0,mo.dw)(e)?function(e){return Number(e.replace(/[^\d]/g,""))}(e):(0,mo.Fd)(e)?function(e){const t=e.match(Tg);if(!t)throw new Error("Invalid key segment");return{_key:t[1]}}(e):(0,mo.lo)(e)?function(e){const[t,n]=e.split(":").map((e=>""===e?e:Number(e)));return[t,n]}(e):e}function Mg(e,t){return e.length===t.length&&e.every(((e,n)=>{const i=t[n];return(0,mo.Fd)(e)&&(0,mo.Fd)(i)?e._key===i._key:(0,mo.dw)(e)?Number(e)===Number(i):(0,mo.lo)(e)&&(0,mo.lo)(i)?e[0]===i[0]&&e[1]===i[1]:e===i}))}function Og(e){return(0,mo.fU)(e)?e._key:void 0}function Rg(e){const t=Og(e);return t?{_key:t}:void 0}function zg(e,t){return e.get((null==t?void 0:t.author)||null)}function Dg(e,t){return function(e,t){const n=Bg(e,t);if(!n)return;if("unchanged"===n.action)return;return n.annotation||void 0}(e,Array.isArray(t)?t:Ag(t))}function Bg(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(0===t.length)return e;const i=t[0],r=t.slice(1);if((0,mo.lo)(i))throw new Error("Index tuples are not supported in diff paths");if((0,mo.dw)(i)||(0,mo.Fd)(i)){const t=(0,mo.dw)(i)?"at index ".concat(i):"with key ".concat(i._key);if("array"!==e.type)return void"Failed to get item ".concat(t," at path ").concat(Ig(n)," (not an array)");const o=e.items.find((0,mo.dw)(i)?e=>e.toIndex===i:e=>Lg(e,i));return o?Bg(o.diff,r,n.concat(i)):void"Failed to get item ".concat(t," at path ").concat(Ig(n)," (item missing)")}if("object"!==e.type)return void"Failed to get property ".concat(i," at path ").concat(Ig(n)," (not an object)");const o=e.fields[i];if("undefined"!==typeof o)return Bg(o,r,n.concat(i));"Failed to get property ".concat(i," at path ").concat(Ig(n)," (field did not exist)")}function Lg(e,t){const n=e.diff;return!("object"!==n.type||!n.toValue)&&n.toValue._key===t}function Zg(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];t(e,n)&&("array"!==e.type?"object"!==e.type?"string"===e.type&&Ug(e,t,n):qg(e,t,n):Ng(e,t,n))}
1function Ng(e,t,n){"unchanged"!==e.action&&e.items.forEach((e=>{var i;const r="object"===e.diff.type&&(null==(i=e.diff.toValue)?void 0:i._key),o=r?{_key:r}:function(e){return"undefined"===typeof e.toIndex?e.fromIndex||0:e.toIndex}(e);Zg(e.diff,t,n.concat(o))}))}function qg(e,t,n){"unchanged"!==e.action&&Object.keys(e.fields).forEach((i=>{Zg(e.fields[i],t,n.concat(i))}))}function Ug(e,t,n){"unchanged"!==e.action&&e.segments.forEach((e=>{Zg(e,t,n)}))}function Vg(e){return zg(bg(),e)}function Kg(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=bg(),i=(0,vo.useMemo)((()=>Dg(e,t)),[e,t]);return(0,vo.useMemo)((()=>zg(n,i)),[i,n])}function Hg(e){if("diff"in e){const{diff:t,path:n=[],...i}=e,r=Dg(t,n);return(0,go.jsx)($g,{...i,annotations:r?[r]:[]})}return(0,go.jsx)($g,{...e})}function $g(e){const{annotations:t,children:n,description:i="Changed",...r}=e;if(!t)return n;const o=(0,go.jsxs)(Co.Kq,{padding:3,space:2,children:[(0,go.jsx)(Co.__,{size:1,style:{textTransform:"uppercase"},muted:!0,children:i}),(0,go.jsx)(Co.Kq,{space:2,children:t.map(((e,t)=>(0,go.jsx)(Wg,{annotation:e},t)))})]});return(0,go.jsx)(nh,{zOffset:"paneFooter",children:(0,go.jsx)(Co.u,{content:o,portal:!0,allowedAutoPlacements:["top","bottom"],...r,children:n})})}function Wg(e){let{annotation:t}=e;const{author:n,timestamp:i}=t,[r]=gN(n),o=Vg(t),s=uN(i,{minimal:!0});return(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsxs)(Co.kC,{align:"center",paddingRight:3,style:{backgroundColor:o.background,color:o.text,borderRadius:"calc(23px / 2)"},children:[(0,go.jsx)(kV,{user:n}),(0,go.jsx)(Co.gF,{paddingLeft:2,children:(0,go.jsx)(Co.xv,{muted:!0,size:1,style:{color:o.text},children:r?r.displayName:"Loading\u2026"})})]}),(0,go.jsx)(Co.xv,{as:"time",muted:!0,size:1,dateTime:i,children:s})]})}const Gg=(0,Es.ZP)(Co.Zb)(ae||(ae=rd(["\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"])),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[2])}),(e=>{let{theme:t}=e;return t.sanity.color.card.enabled.bg})),Xg=[],Yg=(0,vo.forwardRef)((function(e,t){const{annotation:n,as:i="div",children:r,className:o,diff:s,disableHoverEffect:a,path:l=Xg,style:c={},tooltip:d,...u}=e,p=(0,vo.useMemo)((()=>n||Dg(s,l)),[n,s,l]),h=Vg(p),f=(0,go.jsx)(Gg,{...u,as:i,className:o,"data-hover":a||!p?void 0:"",ref:t,radius:1,style:{...c,backgroundColor:h.background,color:h.text},children:r});return d&&p?(0,go.jsx)(Hg,{annotations:[p],description:d&&"object"===typeof d&&d.description,children:f}):f})),Jg=Es.ZP.div(le||(le=rd(["\n border-radius: ",";\n padding: ",";\n"])),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[2])}),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.space[1])})),Qg=(0,Es.ZP)(Co.xv)(ce||(ce=rd(["\n &:not([hidden]) {\n color: inherit;\n }\n"])));function ex(e){const{change:t,segment:n}=e;if("string"===typeof n)return(0,go.jsx)(Co.xu,{style:n.length>30?{maxWidth:100}:{},children:(0,go.jsx)(Co.xv,{title:n,size:1,weight:"semibold",textOverflow:"ellipsis",children:n})});const{hasMoved:i,fromIndex:r,toIndex:o,annotation:s}=n,a="undefined"===typeof o;if("undefined"===typeof r)return(0,go.jsx)(tx,{annotation:s,change:t,toIndex:o});if(a)return(0,go.jsx)(nx,{annotation:s,fromIndex:r});if(i&&"undefined"!==typeof o&&"undefined"!==typeof r)return(0,go.jsx)(ix,{annotation:s,fromIndex:r,toIndex:o});const l=(o||0)+1;return(0,go.jsx)(Co.xu,{padding:1,children:(0,go.jsxs)(Co.xv,{size:1,weight:"semibold",children:["#",l]})})}function tx(e){const{annotation:t,change:n,toIndex:i=0}=e,r=i+1,o="Added in position ".concat(r),s=(0,go.jsxs)(go.Fragment,{children:["#",r]}),a=((null==n?void 0:n.diff)?Dg(n.diff,[]):void 0)||t;return a?(0,go.jsx)(Yg,{annotation:a,tooltip:{description:o},as:Jg,children:(0,go.jsx)(Qg,{size:1,weight:"semibold",forwardedAs:"ins",style:{textDecoration:"none"},children:s})}):(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:s})}function nx(e){const{annotation:t,fromIndex:n=0}=e,i=n+1,r="Removed from position ".concat(i);return(0,go.jsx)(Yg,{annotation:t||null,as:Jg,tooltip:{description:r},children:(0,go.jsxs)(Qg,{size:1,weight:"semibold",forwardedAs:"del",children:["#",i]})})}function ix(e){const{annotation:t,fromIndex:n,toIndex:i}=e,r=i-n,o=r<0?"\u2191":"\u2193",s=Math.abs(r),a="Moved ".concat(s," position").concat(1===s?"":"s"," ").concat(r<0?"up":"down");return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{padding:1,children:(0,go.jsxs)(Qg,{size:1,weight:"semibold",children:["#",i+1]})}),(0,go.jsx)(Yg,{annotation:t,as:Jg,tooltip:{description:a},children:(0,go.jsxs)(Qg,{size:1,weight:"semibold",children:[o,Math.abs(r)]})})]})}function rx(e){const{change:t,titlePath:n}=e;return(0,go.jsx)(Co.Oo,{separator:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:"/"}),children:n.map(((e,n)=>"string"===typeof e||!t||t.showIndex?(0,go.jsx)(ex,{change:t,segment:e},n):null))})}
1function ox(e,t,n){const{currentUser:i,document:r,parent:o,value:s}=n,a=(0,vo.useRef)(!1);return(0,vo.useMemo)((()=>{let n=!1;if("boolean"===typeof e||void 0===e)return e||!1;try{n=e({document:r,parent:o,value:s,currentUser:i})}catch(l){return console.error("An error occurred while running the callback from `".concat(t,"`: ").concat(l.message)),!1}return function(e){return Od(e)&&"function"===typeof(null==e?void 0:e.then)}(n)&&!a.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):("undefined"===typeof n&&console.warn("The `".concat(t,"` option is or returned `undefined`. `").concat(t,"` should return a boolean.")),n)}),[e,r,o,s,i,t])}const sx=e=>{const{checkProperty:t=!1,checkPropertyKey:n,document:i,parent:r,value:o}=e,s=bd(o);return ox(t,n,{currentUser:xN(),document:i,parent:r,value:s})},ax=(0,vo.createContext)({path:[]});function lx(e,t){const{jsonType:n}=t,i=Array.isArray(e)?"array":typeof e;if(null!==e&&"undefined"!==i){if(i!==n)return{message:"Value is ".concat(i,", expected ").concat(n),value:e};if(function(e){return"object"===e.jsonType}(t)&&function(e){return null!==e&&!Array.isArray(e)&&"object"===typeof e}(e))for(const n of t.fields){const t=lx(e[n.name],n.type);if(t)return t}}}function cx(e){return(0,mo.ay)(e)?e._type:function(e){if(Array.isArray(e))return"array";if(null===e)return"null";return typeof e}(e)}function dx(e,t){return"added"===e.action?{toType:ux(t,e.toValue)}:"changed"===e.action?{fromType:ux(t,e.fromValue),toType:ux(t,e.toValue)}:"removed"===e.action?{fromType:ux(t,e.fromValue)}:{toType:ux(t,e.toValue)}}function ux(e,t){const n=cx(t),i=e.of.find((e=>e.name===n));return i||(1===e.of.length?e.of[0]:void 0)}const px=[["\uf050","\uf051"],["\uf052","\uf053"],["\uf054","\uf055"],["\uf056","\uf057"],["\uf058","\uf059"],["\uf05a","\uf05b"],["\uf05c","\uf05d"],["\uf05f","\uf060"],["\uf061","\uf062"],["\uf063","\uf064"],["\uf065","\uf066"],["\uf067","\uf068"],["\uf069","\uf06a"],["\uf06b","\uf06c"],["\uf06e","\uf06f"],["\uf070","\uf071"],["\uf072","\uf073"],["\uf074","\uf075"],["\uf076","\uf077"],["\uf078","\uf079"],["\uf07a","\uf07b"],["\uf07c","\uf07d"],["\uf07e","\uf07f"],["\uf080","\uf081"],["\uf082","\uf083"],["\uf084","\uf085"],["\uf086","\uf087"],["\uf088","\uf089"],["\uf08a","\uf08b"],["\uf08c","\uf08d"],["\uf08e","\uf08f"]],hx="\uf0d0",fx=[["\uf000","\uf001"],["\uf002","\uf003"],["\uf004","\uf005"],["\uf006","\uf007"],["\uf008","\uf009"],["\uf00a","\uf00b"],["\uf00c","\uf00d"],["\uf00f","\uf010"],["\uf011","\uf012"],["\uf013","\uf014"],["\uf015","\uf016"],["\uf017","\uf018"],["\uf019","\uf01a"],["\uf01b","\uf01c"],["\uf01e","\uf01f"],["\uf020","\uf021"]],mx=["\uf090","\uf091","\uf092","\uf093","\uf094","\uf095","\uf096","\uf097","\uf098","\uf099","\uf09a","\uf09b","\uf09c","\uf09d","\uf09e","\uf09f","\uf0a0","\uf0a1","\uf0a2","\uf0a3","\uf0a4","\uf0a5","\uf0a6","\uf0a7","\uf0a8","\uf0a9","\uf0aa","\uf0ab","\uf0ac","\uf0ad","\uf0ae","\uf0af","\uf0b0","\uf0b1","\uf0b2","\uf0b3","\uf0b4","\uf0b5","\uf0b6","\uf0b7","\uf0b8","\uf0b9","\uf0ba","\uf0bb","\uf0bc","\uf0bd","\uf0be","\uf0bf"],gx=new gl.diff_match_patch;function xx(e){return e.of.some(kx)}const vx=fx.map((e=>e[0])).concat(px.map((e=>e[0]))),yx=fx.map((e=>e[1])).concat(px.map((e=>e[1]))),bx=vx.concat(yx).concat(mx).concat(hx).concat("\u2060"),jx=new RegExp("".concat(bx.join("|")),"g"),wx=new RegExp("".concat(bx.join("|"),"|\n"),"g");function kx(e){return"object"===e.jsonType&&"block"===e.name}function Cx(e,t){return e.fields.children.items.filter((e=>e.diff.isChanged&&(e.diff.toValue===t||e.diff.fromValue===t))).map((e=>e.diff)).map((e=>e))[0]}function _x(e,t){const n=e.find((e=>"children"===e.name));return n&&n.type&&"array"===n.type.jsonType&&n.type.of.find((e=>e.name===t._type))||void 0}function Sx(e){return e.decorators?ml()(e.decorators,["value"],["asc"]):[]}function Tx(e,t){return Sx(t).some((t=>t.value===e))}function Ix(e,t,n,i,r){return t?t.children.map((t=>{var o;let s=(0,mo.NG)(t)?null==(o=t.text)?void 0:o.replace(jx,""):"";if((0,mo.NG)(t)){const r=Ax(e,t),o=null==r?void 0:r.fields.text;o&&o.toValue===t.text&&"string"===o.type&&"unchanged"!==o.action&&(s=o.segments.filter((e=>"removed"!==e.action)).map((e=>e.text.replace(jx,""))).join("\u2060")),t.marks&&t.marks.forEach((e=>{!!n[e]?s="".concat(n[e][0]).concat(s).concat(n[e][1]):i[e]&&(s="".concat(i[e][0]).concat(s).concat(i[e][1]))}))}else s=r[t._key];return"".concat(hx).concat(s)})).join(""):""}function Px(e,t){const n=[],i=gx.diff_main(e,t);gx.diff_cleanupEfficiency(i);let r=0,o=0;for(const[s,a]of i)switch(s){case gl.DIFF_EQUAL:n.push({type:"stringSegment",action:"unchanged",text:a}),r+=a.length,o+=a.length;break;
1case gl.DIFF_DELETE:n.push({type:"stringSegment",action:"removed",text:e.substring(r,r+a.length),annotation:null}),r+=a.length;break;case gl.DIFF_INSERT:n.push({type:"stringSegment",action:"added",text:t.substring(o,o+a.length),annotation:null}),o+=a.length}return sl()(n.map((e=>{const t=[];if(e.text.length>1){const n=[...e.text.matchAll(wx)];let i=-1;n.forEach((r=>{const o=r.index||0;o>i&&(t.push({...e,text:e.text.substring(i+1,o)}),t.push({...e,text:r[0]})),r===n[n.length-1]&&t.push({...e,text:e.text.substring(o+1)}),i=o})),0===n.length&&t.push(e)}else t.push(e);return t})))}function Ex(e){const t=[...e.toValue?e.toValue.children.filter((e=>"span"!==e._type)):[]];return(e.fromValue?e.fromValue.children.filter((e=>"span"!==e._type)):[]).forEach((e=>{t.some((t=>e._key===t._key))||t.push(e)})),ml()(t,["_key"],["asc"])}function Ax(e,t){const 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 Fx(e){return e&&Ss()(Object.keys(e),["_key","_type"])||!1}function Mx(e){const t=[...e.toValue&&e.toValue.markDefs?e.toValue.markDefs:[]];return(e.fromValue&&e.fromValue.markDefs?e.fromValue.markDefs:[]).forEach((e=>{t.some((t=>e._key===t._key))||t.push(e)})),ml()(t,["_key"],["asc"])}const Ox=[];function Rx(e){let{checked:t,color:n}=e;return(0,go.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,go.jsx)("rect",{x:"0",y:"0",width:"17",height:"17",rx:"2.5"}),"undefined"===typeof t&&(0,go.jsx)("path",{d:"M4.07996 8.5H12.92",stroke:null==n?void 0:n.text,strokeWidth:"2"}),t&&(0,go.jsx)("path",{d:"M3.5 8L7 11.5L13.5 5",stroke:null==n?void 0:n.text,strokeWidth:"2"})]})}function zx(e){let{checked:t,color:n}=e;return(0,go.jsxs)("svg",{width:"38",height:"22",viewBox:"0 0 38 22",xmlns:"http://www.w3.org/2000/svg",children:[(0,go.jsx)("rect",{width:"38",height:"22",rx:"11",fill:t?null==n?void 0:n.border:null==n?void 0:n.background}),"undefined"===typeof t&&(0,go.jsx)("rect",{x:"11",y:"3",width:"16",height:"16",rx:"8",fill:"white"}),t&&(0,go.jsx)("rect",{x:"18",y:"3",width:"16",height:"16",rx:"8",fill:"white"}),"boolean"===typeof t&&!t&&(0,go.jsx)("rect",{x:"4",y:"3",width:"16",height:"16",rx:"8",fill:"white"})]})}const Dx=Es.ZP.div(de||(de=rd(["\n display: inline-block;\n word-wrap: break-word;\n"]))),Bx=function(e){let{value:t,schemaType:n}=e;return(0,go.jsx)(Co.xu,{as:Dx,paddingX:2,paddingY:1,children:Lx(t,n)})};function Lx(e,t){const{options:n,name:i}=t,r=(null==n?void 0:n.dateFormat)||"YYYY-MM-DD",o=(null==n?void 0:n.timeFormat)||"HH:mm";return xl.W(new Date(e),"date"===i?r:"".concat(r," ").concat(o))}const Zx=e=>{let{diff:t,schemaType:n}=e;return(0,go.jsx)(Oy,{align:"center",diff:t,layout:"grid",previewComponent:Bx,schemaType:n})},Nx=(0,vo.createContext)(null);function qx(){const e=(0,vo.useContext)(Nx);if(!e)throw new Error("DocumentChange: missing context value");return e}function Ux(e){const[t,n]=(0,vo.useState)(void 0),i=WZ(qh);return(0,vo.useEffect)((()=>{if(!e)return;const t=i.observable.getDocument(e).subscribe(n);return()=>{t.unsubscribe()}}),[i,e]),e?t:void 0}const Vx=Es.ZP.div(ue||(ue=rd(["\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"])),(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 Kx(e,t){const 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 Hx(e){let t=0;if(0==e.length)return t.toString();for(let n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t&=t}return t.toString()}function $x(e){const{crop:t,diff:n,hash:i,hotspot:r,width:o=100,height:s=100,...a}=e,l=Kg(n,"crop"),c=Kg(n,"hotspot");return(0,go.jsxs)("svg",{...a,fill:"none",width:o,height:s,viewBox:"0 0 ".concat(o," ").concat(s),children:[(0,go.jsx)("defs",{children:t&&r&&(0,go.jsxs)("mask",{id:"mask-hotspot-".concat(i),children:[(0,go.jsx)("rect",{x:0,y:0,width:o,height:s,fill:"#fff"}),(0,go.jsx)(Gx,{hotspot:r,fill:"#000",offset:1,width:o,height:s,stroke:"#000",strokeWidth:3})]})}),t&&(0,go.jsx)(Hg,{diff:n,path:"crop",description:"Crop changed",children:(0,go.jsx)("g",{children:(0,go.jsx)(Wx,{crop:t,fill:Kx(l.border,.25),mask:r?"url(#mask-hotspot-".concat(i,")"):void 0,stroke:l.border,strokeWidth:1,width:o,height:s})})}),r&&(0,go.jsx)(Hg,{diff:n,path:"hotspot",description:"Hotspot changed",children:(0,go.jsx)("g",{children:(0,go.jsx)(Gx,{hotspot:r,fill:Kx(c.border,.25),stroke:c.border,strokeWidth:1,width:o,height:s})})})]})}function Wx(e){let{crop:t,width:n,height:i,...r}=e;const o={x:t.left*n,y:t.top*i,width:(1-t.right-t.left)*n,height:(1-t.bottom-t.top)*i};return(0,go.jsx)("rect",{...r,...o,style:{vectorEffect:"non-scaling-stroke"}})}function Gx(e){let{hotspot:t,offset:n=0,width:i,height:r,...o}=e;
1const s={cx:t.x*i,cy:t.y*r,rx:t.width/2*i+n,ry:t.height/2*r+n};return(0,go.jsx)("ellipse",{...o,...s,style:{vectorEffect:"non-scaling-stroke"}})}const Xx=["originalFilename"],Yx=()=>(0,go.jsx)(Co.Zb,{flex:1,tone:"transparent",padding:4,radius:2,height:"stretch",children:(0,go.jsx)(Co.kC,{align:"center",justify:"center",height:"fill",children:(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"(no image)"})})}),Jx=Es.ZP.div(pe||(pe=rd(["\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"])),Vs.VG.gray[100].hex,Vs.VG.gray[50].hex,Vs.VG.gray[50].hex,Vs.VG.gray[50].hex,Vs.VG.gray[50].hex),Qx=Es.ZP.img(he||(he=rd(["\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"]))),ev=Es.ZP.div(fe||(fe=rd(["\n svg {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n"])));function tv(e){var t,n,i,r;const{id:o,action:s,diff:a,hotspot:l,crop:c,is:d}=e,u=WZ(qh),[p,h]=vo.useState(),{value:f}=Lq(o,Xx),m=(0,qa.pz)(o),g=(0,vo.useMemo)((()=>Na()(u)),[u]),x=null===f,v=f&&f.originalFilename||"Untitled",y=g.image(o).height(190).dpr(function(){const e=Math.ceil(window.devicePixelRatio||1);return Math.min(3,Math.max(1,e))}()).fit("max"),b=(null==(n=null==(t=a.fromValue)?void 0:t.asset)?void 0:n._ref)!==(null==(r=null==(i=a.toValue)?void 0:i.asset)?void 0:r._ref),j="changed"===s?void 0:s;return(0,go.jsxs)(Co.kC,{direction:"column",height:"fill",flex:1,children:[(0,go.jsx)(Co.xu,{flex:1,padding:2,paddingBottom:0,children:(0,go.jsxs)(Co.kC,{as:Jx,direction:"column","data-changed":"from"===d&&b?"":void 0,"data-error":p?"":void 0,children:[!x&&!p&&(0,go.jsx)(Qx,{src:y.toString()||"",alt:v,"data-action":j,onError:h,width:m.width,height:m.height}),(x||p)&&(0,go.jsx)(Co.xu,{paddingY:5,children:(0,go.jsx)(Co.xv,{size:1,muted:!0,align:"center",children:x?"Image is deleted":"Error loading image"})}),(0,go.jsx)(ev,{children:(0,go.jsx)($x,{crop:c&&!(0,qa.aM)(c)?c:void 0,diff:a,hash:Hx("".concat(y.toString()||"","-").concat(d)),hotspot:l&&!(0,qa.Rq)(l)?l:void 0,width:m.width,height:m.height})})]})}),(0,go.jsx)(rb,{title:v,icon:Ds.XBm,markRemoved:b&&"from"===d,children:j?(0,go.jsx)("div",{children:j}):(0,go.jsxs)("div",{children:[m.width," \xd7 ",m.height]})})]})}const nv=["asset","crop","hotspot"],iv={flex:1},rv=Es.ZP.div(me||(me=rd(["\n display: inline-block;\n word-break: break-all;\n"]))),ov=e=>{const{value:t}=e;return(0,go.jsx)(Co.xu,{as:rv,paddingX:2,paddingY:1,children:t})},sv=Es.ZP.blockquote(ge||(ge=rd(["\n margin: 0;\n"])));function av(e){let{children:t}=e;return(0,go.jsx)("div",{children:(0,go.jsx)(sv,{children:t})})}const lv={h1:2,h2:1,h3:0,h4:0,h5:0,h6:0},cv=(0,Es.ZP)(Co.X6)(xe||(xe=rd(["\n &:not([hidden]) {\n display: inline;\n text-transform: none;\n margin: 0;\n\n &::before,\n &::after {\n content: unset;\n }\n }\n"])));function dv(e){let{style:t,children:n}=e;return(0,go.jsx)(cv,{size:lv[t],children:n})}const uv=Es.ZP.div(ve||(ve=rd(["\n text-transform: none;\n white-space: wrap;\n overflow-wrap: break-word;\n margin: 0;\n"])));function pv(e){let{children:t}=e;return(0,go.jsx)(uv,{children:t})}const hv=[];function fv(e){var t,n,i;const{diff:r,block:o,children:s}=e,a=Kg(r,hv),{path:l}=(0,vo.useContext)(ax),{onSetFocus:c}=(0,vo.useContext)(vd),d="removed"===r.action;let u=s;const p=(0,vo.useCallback)((e=>{e.stopPropagation(),d||c(l)}),[l,d,c]);var h;let f;if(u="blockquote"===o.style?(0,go.jsx)(av,{children:u}
1):o.style&&(h=o,(0,mo.DG)(h)&&h.style&&["h1","h2","h3","h4","h5","h6"].includes(h.style))?(0,go.jsx)(dv,{style:o.style,children:u}):(0,go.jsx)(pv,{children:u}),"changed"===r.origin.action&&r.origin.fields.style&&"changed"===r.origin.fields.style.action&&r.origin.fields.style.annotation){f=null==(n=null==(t=null==r?void 0:r.origin)?void 0:t.fromValue)?void 0:n.style;const e=a?{background:a.background,color:a.text}:{};u=(0,go.jsx)(Co.Zb,{padding:3,border:!0,radius:2,style:{borderStyle:"dotted"},"diff-block-action":r.action,"data-block-note":"changed_from_style_".concat(f||"undefined"),children:(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Hg,{annotations:[null==(i=r.origin.fields.style)?void 0:i.annotation],diff:r.origin.fields.style,children:(0,go.jsxs)(Co.xv,{size:0,children:["Changed block style from '",f,"' to '",o.style,"'"]})}),(0,go.jsx)(Co.xu,{style:e,children:u})]})})}return(0,go.jsx)("div",{onClick:p,"data-diff-block-action":r.action,"data-block-note":"changed_from_style_".concat(f||"undefined"),children:u})}const mv=(0,Es.ZP)(Co.xu)(ye||(ye=rd(["\n &:not([hidden]) {\n display: inline;\n align-items: center;\n\n &[data-changed] {\n cursor: pointer;\n }\n }\n"]))),gv=(0,Es.ZP)(Co.xv)(be||(be=rd(["\n &:not([hidden]) {\n display: inline;\n color: inherit;\n }\n"]))),xv=(0,Es.ZP)(Co.xu)(je||(je=rd(["\n &:not([hidden]) {\n display: inline-flex;\n align-items: center;\n\n ",' [data-ui="Text"] {\n opacity: 0.5;\n }\n }\n'])),mv),vv=(0,Es.ZP)(Co.xu)(we||(we=rd(["\n min-width: 160px;\n max-height: 40vh;\n overflow-y: auto;\n"]))),yv=Es.ZP.div(ke||(ke=rd(["\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"])),xv);function bv(e){let{children:t,diff:n,object:i,schemaType:r,path:o,...s}=e;return r?n&&"unchanged"!==n.action?(0,go.jsx)(jv,{...s,diff:n,object:i,schemaType:r,path:o,children:t}):(0,go.jsx)(yv,{children:t}):(0,go.jsx)(yv,{...s,children:"Unknown schema type"})}function jv(e){let{diff:t,children:n,object:i,schemaType:r,path:o,...s}=e;const{onSetFocus:a}=(0,vo.useContext)(vd),{path:l}=(0,vo.useContext)(ax),[c,d]=(0,vo.useState)(null),u=Kg(t,[]),p=(0,vo.useMemo)((()=>u?{background:u.background,color:u.text}:{}),[u]),h="removed"===t.action,[f,m]=(0,vo.useState)(!1),g=i&&Fx(i),x=(0,vo.useMemo)((()=>[o[0]].concat(["markDefs",{_key:i._key}])),[i._key,o]),v=(0,vo.useMemo)((()=>l.slice(0,l.findIndex((e=>(0,mo.Fd)(e)&&e._key===i._key)))),[l,i._key]),y=(0,vo.useMemo)((()=>v.concat(o)),[o,v]),b=(0,vo.useMemo)((()=>v.concat(x)),[x,v]),j="field-".concat((0,xo.BB)(b)),w=gd(),k=(0,vo.useMemo)((()=>w.filter((e=>{let[t]=e;return t.startsWith(j)})).length>0),[j,w]);(0,vo.useEffect)((()=>{!f&&k&&(m(!0),a(b))}),[k,b,a,f]);const C=(0,vo.useCallback)((e=>{e.stopPropagation(),m(!0),h||(e.preventDefault(),a(y),setTimeout((()=>a(b)),10))}),[y,h,b,a]),_=(0,vo.useCallback)((()=>{k||m(!1)}),[k]);(0,Co.O8)(_,[c]);const S="unchanged"!==t.action&&t.annotation||null,T=(0,vo.useMemo)((()=>S?[S]:[]),[S]),I=(0,go.jsx)(ax.Provider,{value:{path:b},children:(0,go.jsx)(vv,{padding:3,children:(0,go.jsxs)("div",{children:[g&&(0,go.jsxs)(Co.__,{size:1,muted:!0,children:["Empty ",r.title]}),!g&&(0,go.jsx)(Jy,{diff:t,schemaType:r})]})})});return(0,go.jsx)(yv,{...s,onClick:C,style:p,"data-changed":"","data-removed":"removed"===t.action?"":void 0,children:(0,go.jsx)(Co.J2,{content:I,open:f,ref:d,portal:!0,children:(0,go.jsx)(xv,{paddingLeft:1,children:(0,go.jsx)(Hg,{annotations:T,description:"".concat(t.action," annotation"),children:(0,go.jsxs)(mv,{style:{display:"inline-flex"},children:[(0,go.jsx)("span",{children:n}),(0,go.jsx)(Co.kC,{align:"center",paddingX:1,children:(0,go.jsx)(gv,{size:0,children:(0,go.jsx)(Ds.v4q,{})})})]})})})})})}const wv=Es.ZP.span(Ce||(Ce=rd(["\n display: inline;\n ","\n"])),(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 kv(e){let{mark:t,children:n}=e;return(0,go.jsx)(wv,{decoration:t,children:n})}const Cv=(0,Es.ZP)(Co.Zb)(_e||(_e=rd(["\n &:not([hidden]) {\n display: inline;\n cursor: pointer;\n white-space: nowrap;
1\n align-items: center;\n\n &[data-removed] {\n text-decoration: line-through;\n }\n\n "," {\n display: inline-flex;\n }\n }\n"])),mv);function _v(e){let{diff:t,object:n,schemaType:i,...r}=e;return i?t?(0,go.jsx)(Sv,{...r,diff:t,object:n,schemaType:i}):(0,go.jsx)(Cv,{children:(0,go.jsx)(BF,{schemaType:i,value:n,layout:"inline"})}):(0,go.jsxs)(Cv,{...r,border:!0,radius:1,children:["Unknown schema type: ",n._type]})}function Sv(e){let{diff:t,object:n,path:i,schemaType:r,...o}=e;const{path:s}=(0,vo.useContext)(ax),{onSetFocus:a}=(0,vo.useContext)(vd),l=Kg(t,[]),c=(0,vo.useMemo)((()=>l?{background:l.background,color:l.text}:{}),[l]),[d,u]=(0,vo.useState)(!1),p=n&&Fx(n),h="removed"===t.action,f=s.slice(0,s.findIndex((e=>(0,mo.Fd)(e)&&e._key===n._key))).concat(i),m="field-".concat((0,xo.BB)(f)),g=gd().filter((e=>{let[t]=e;return t.startsWith(m)})).length>0,x=s.slice(0,-1).concat(i).concat([xo.Zg]);(0,vo.useEffect)((()=>{g&&(u(!0),a(x))}),[x,g,a]);const v=(0,vo.useCallback)((e=>{e.stopPropagation(),u(!0),h?e.preventDefault():a(x)}),[x,h,a]),y=(0,vo.useCallback)((()=>{u(!1)}),[]),b=(0,go.jsx)(ax.Provider,{value:{path:f},children:(0,go.jsx)(Tv,{diff:t,emptyObject:p,onClose:y,schemaType:r})}),j="unchanged"!==t.action&&t.annotation||null,w=j?[j]:[];return(0,go.jsx)(Cv,{...o,onClick:v,style:c,"data-removed":"removed"===t.action?"":void 0,border:!0,radius:2,children:(0,go.jsx)(Co.J2,{content:b,open:d,portal:!0,children:(0,go.jsx)(xv,{children:(0,go.jsx)(Hg,{annotations:w,description:"".concat(t.action," inline object"),children:(0,go.jsxs)(mv,{children:[(0,go.jsx)(BF,{schemaType:r,value:n,layout:"inline"}),(0,go.jsx)(Co.kC,{align:"center",paddingX:1,children:(0,go.jsx)(gv,{size:0,children:(0,go.jsx)(Ds.v4q,{})})})]})})})})})}function Tv(e){let{diff:t,emptyObject:n,onClose:i,schemaType:r}=e;const[o,s]=(0,vo.useState)(null),a=(0,vo.useCallback)((()=>{i()}),[i]);return(0,Co.O8)(a,[o]),(0,go.jsxs)(vv,{ref:s,padding:3,children:[n&&(0,go.jsxs)(Co.__,{size:1,muted:!0,children:["Empty ",r.title]}),!n&&(0,go.jsx)(Jy,{diff:t,schemaType:r})]})}function Iv(e){let{diff:t,childDiff:n,children:i,path:r,segment:o,...s}=e;const a=t||n;return a&&"unchanged"!==a.action&&"unchanged"!==o.action?(0,go.jsx)(Pv,{...s,childDiff:n,diff:t,segment:o,path:r,children:i}):(0,go.jsx)(mv,{children:i})}function Pv(e){let{diff:t,childDiff:n,children:i,path:r,segment:o,...s}=e;const{onSetFocus:a}=vo.useContext(vd),{path:l}=vo.useContext(ax),c=(0,vo.useMemo)((()=>r.slice(-2,1)[0]),[r]),d=t&&"removed"===t.action,u=l.slice(0,l.findIndex((e=>(0,mo.Fd)(e)&&(0,mo.Fd)(c)&&e._key===c._key))).concat(r),p=(0,vo.useCallback)((e=>{e.stopPropagation(),d||(e.preventDefault(),a(u))}),[u,d,a]),h=t&&t.segments.find((e=>e.text===o.text))||t||n,f=h&&"unchanged"!==h.action&&h.annotation||null,m=f&&"unchanged"!==o.action?(0,go.jsx)(Yg,{annotation:f,as:"removed"===o.action?"del":"ins",tooltip:{description:"".concat(Js()(o.action)," text")},children:i}):null;return(0,go.jsx)(mv,{...s,onClick:p,"data-changed":"",children:(0,go.jsx)("span",{children:(0,go.jsx)(go.Fragment,{children:m||i})})})}const Ev=fx.map((e=>e[0])),Av=fx.map((e=>e[1])),Fv=px.map((e=>e[0])),Mv=px.map((e=>e[1])),Ov=Ev.concat(Fv),Rv=Av.concat(Mv),zv=Ev.concat(Av),Dv=new RegExp("".concat(zv.concat(Rv).join("|")),"g");function Bv(e){const{diff:t,schemaType:n}=e,i=t.origin.toValue||t.origin.fromValue,r=(0,vo.useMemo)((()=>t.origin.toValue?Ex(t.origin):[]),[t.origin]),o=(0,vo.useCallback)((e=>{const o=_x(n.fields,e);let s=[];if(o){s=Sx(o);const e=t.fields.children,a=e.items[0].diff&&"object"===e.items[0].diff.type&&"string"===e.items[0].diff.fields.text.type&&e.items[0].diff.fields.text.segments||[],l=[],c={};if(function(e,t){return 1===e.children.length&&"span"===e.children[0]._type&&"string"===typeof e.children[0].text&&""===e.children[0].text&&"unchanged"!==t.origin.action}(i,t)&&("added"===t.origin.action||"removed"===t.origin.action)){const e=Cx(t.origin,i.children[0])||t.origin;if(e&&"unchanged"!==e.action)return(0,go.jsx)(Yg,{annotation:e.annotation,as:"removed"===e.action?"del":"ins",tooltip:{description:"".concat(Js()(e.action)," empty text")},children:(0,go.jsx)("span",{children:"\u21b2"})},"empty-block-".concat(i._key))}let d=-1,u=-1;const p=[];let h;const f=Mx(t.origin);return a.forEach((e=>{var a,m,g;u++;const x=mx.includes(e.text),v=Ov.includes(e.text),y=Rv.includes(e.text),b=e.text===hx,j="removed"===e.action;if(b)j||d++;else if(v||y){if(v&&Fv.includes(e.text)){const t=f[Fv.indexOf(e.text)];t&&p.push({mark:t._key,symbols:[e.text,Mv[Fv.indexOf(e.text)]],object:t})}y&&Mv.includes(e.text)&&(h=p.pop())}else if(x){const o=mx.findIndex((t=>t===e.text)),s=null==(a=r[o])?void 0:a._key,c=r[o];if(s){const e=_x(n.fields,c),r=Cx(t.origin,c);l.push((0,go.jsx)(_v,{object:c,path:[{_key:i._key},"children",{_key:c._key}],diff:r,schemaType:e},"inline-object-".concat(c._key)))}}else if(e.text){const n=()=>{var n;return null==(n=t.origin.fromValue)?void 0:n.children.find((t=>t.text&&t.text.match(function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}(e.text))))},r=i.children[d]||n(),a=r&&Ax(t.origin,r);if(!r)throw new Error("Could not find child");const f=(null==(m=null==a?void 0:a.fields)?void 0:m.text)?null==(g=null==a?void 0:a.fields)?void 0:g.text:void 0,x=(0,go.jsx)(Iv,{diff:f,path:[{_key:i._key},"children",{_key:r._key}],childDiff:a,segment:e,children:Lv({diff:t,child:r,decoratorTypes:s,seg:e,segIndex:u,spanSchemaType:o})},"text-".concat(r._key,"-").concat(u));if(p.length>0&&p.forEach((e=>{c[e.mark]=c[e.mark]||[],c[e.mark].push(x)})),h){const e="annotation-".concat(h.object._key),n=l[l.length-1];if(n&&n.key!==e){const n=function(e,t){var n;return e.fields.markDefs&&e.fields.markDefs.isChanged&&"array"===e.fields.markDefs.type&&(null==(n=e.fields.markDefs.items.find((e=>e.diff&&"object"===e.diff.type&&(e.diff.toValue&&e.diff.toValue._key&&e.diff.toValue._key===t||e.diff.fromValue&&e.diff.fromValue._key&&e.diff.fromValue._key===t))))?void 0:n.diff)||void 0}(t.origin,h.mark),s=h&&o.annotations&&o.annotations.find((e=>h&&h.object&&e.name===h.object._type));l.push((0,go.jsx)(bv,{object:h.object,diff:n,path:[{_key:i._key},"children",{_key:r._key}],schemaType:s,children:(0,go.jsx)(go.Fragment,{children:c[h.mark]})},e))}h=void 0}
10===p.length&&l.push(x)}})),vo.createElement("div",{key:i._key},...l)}throw new Error("'span' schemaType not found")}),[i,t,r,n]);return(0,go.jsx)(fv,{block:t.displayValue,diff:t,children:(0,go.jsx)(go.Fragment,{children:(t.displayValue.children||[]).map((e=>o(e)))})})}function Lv(e){let{diff:t,child:n,decoratorTypes:i,seg:r,segIndex:o,spanSchemaType:s}=e;if("\n"===r.text)return(0,go.jsx)("br",{});let a=(0,go.jsx)("span",{children:r.text.replace(/ /g,"\u205f")},"text-".concat(o));const l=n&&Ax(t.origin,n),c=(0,mo.NG)(n)&&n.marks||[];return l&&(a=function(e){let{activeMarks:t,decoratorTypes:n,diff:i,children:r,seg:o,segIndex:s,spanDiff:a,spanSchemaType:l}=e;var c;let d=(0,go.jsx)("span",{children:r},"text-segment-".concat(s));const u=i.origin.fromValue&&i.fromValue&&i.fromValue.children[0].text||"",p=a&&"unchanged"!==a.action&&a.annotation||void 0,h=null==(c=null==a?void 0:a.fields)?void 0:c.marks,f=h&&"unchanged"!==h.action&&h.annotation||p;let m=[];const g=u.split(hx).filter((e=>!!e)).join(""),x=g.substring(0,g.indexOf(o.text)+o.text.length),v=x.substring(0,x.indexOf(o.text)),y=[];[...v.matchAll(Dv)].forEach((e=>{var t;const i=e[0],r=fx.concat(px).find((e=>e.indexOf(i)>-1));if(r){const e=i===r[0],o=(null==(t=n[e?Ev.indexOf(i):Av.indexOf(i)])?void 0:t.value)||i;v.lastIndexOf(i)>v.lastIndexOf(r[1])&&y.push(o)}})),m=Ul()(t,nl()(y)),f&&m.length>0&&m.some((e=>Tx(e,l)))&&(d=(0,go.jsx)(Yg,{annotation:f,as:"ins",tooltip:{description:"Changed formatting"},children:d},"diffcard-annotation-".concat(s,"-").concat(m.join("-"))));return d}({activeMarks:c,decoratorTypes:i,diff:t,children:a,seg:r,segIndex:o,spanDiff:l,spanSchemaType:s})),c&&c.length>0&&c.forEach((e=>{Tx(e,s)&&(a=(0,go.jsx)(kv,{mark:e,children:a},"decorator-".concat(e,"-").concat(n._key,"-").concat(o)))})),a}const Zv=Es.ZP.div(Se||(Se=rd(["\n word-wrap: break-word;\n"]))),Nv=e=>{let{value:t,schemaType:n}=e;return(0,go.jsx)(Co.xu,{as:Zv,padding:2,children:(0,go.jsx)(BF,{schemaType:n,value:t,layout:"default"})})},qv=Es.ZP.div(Te||(Te=rd(["\n display: inline-block;\n word-break: break-all;\n white-space: pre-wrap;\n"]))),Uv=e=>{const{value:t}=e;return(0,go.jsx)(Co.xu,{as:qv,paddingX:2,paddingY:1,children:t})},Vv=Es.ZP.div(Ie||(Ie=rd(["\n white-space: pre-wrap;\n word-wrap: break-word;\n"]))),Kv={block:e=>{const{diff:t,schemaType:n}=e,i=(0,vo.useMemo)((()=>function(e,t){const n="removed"===e.action?e.fromValue:e.toValue,i={...e,origin:e,displayValue:n};if(n){const r={},o={},s={},a=_x(t.fields,{_key:"bogus",_type:"span"});a&&Sx(a).forEach(((e,t)=>{o[e.value]=fx[t]})),Mx(i.origin).forEach(((e,t)=>{r[e._key]=px[t]})),Ex(i.origin).forEach(((e,t)=>{s[e._key]=mx[t]}));const l=Ix(i.origin,i.fromValue,o,r,s),c=Ix(i.origin,i.toValue,o,r,s),d={...n,children:[{_type:"span",_key:"pseudoSpanKey",text:c,marks:[]}]},u={displayValue:n,children:[{_type:"span",_key:"pseudoSpanKey",text:l,marks:[]}]};return{origin:e,action:"changed",type:"object",displayValue:d,fromValue:u,toValue:d,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:l,toValue:c,segments:Px(l,c).map((e=>({...e,..."unchanged"!==i.action&&i.annotation?{annotation:i.annotation}:{}})))}},fromValue:u.children[0],toValue:d.children[0]},annotation:null,fromIndex:0,toIndex:0,hasMoved:!1}],fromValue:u.children,toValue:d.children}}}}throw new Error("Can not display this diff")}(t,n)),[t,n]);return(0,go.jsx)("div",{"data-diff-action":t.action,children:(0,go.jsx)(Bv,{diff:i,schemaType:n})})},boolean:{component:e=>{let{diff:t,schemaType:n}=e;const{fromValue:i,toValue:r}=t,{title:o,options:s}=n,a="checkbox"===(null==s?void 0:s.layout)?Rx:zx,l=Kg(t,[]),c=void 0!==r&&null!==r;return(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Hg,{diff:t,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(a,{checked:i,color:l}),c&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{marginX:2,children:(0,go.jsx)(jy,{})}),(0,go.jsx)(a,{checked:r,color:l})]})]})}),c&&o&&(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:o})})]})},showHeader:!1},date:Zx,datetime:Zx,file:e=>{let{diff:t,schemaType:n}=e;const{fromValue:i,toValue:r,fields:o}=t,s=null==i?void 0:i.asset,a=null==r?void 0:r.asset,l=Ux(null==s?void 0:s._ref),c=Ux(null==a?void 0:a._ref),d=Object.entries(o).filter((e=>{let[t,n]=e;return n.isChanged&&"_type"!==t})).map((e=>{let[t]=e;return t})),u=d.includes("asset"),p=n.fields.filter((e=>"asset"!==e.name&&d.includes(e.name))).map((e=>e.name)),h=(null==l?void 0:l.size)&&l.size/1e3/1e3,f=(null==c?void 0:c.size)&&
1c.size/1e3/1e3,m=function(e,t){if(!e||!t)return 0;const n=t-e;return Math.round(n/e*100)}(h,f),g=h?h.toFixed(2):void 0,x=f?f.toFixed(2):void 0,v=(0,vo.useMemo)((()=>({display:"block",flex:1})),[]),y=l&&(0,go.jsx)(Yg,{as:"del",diff:t,path:"asset._ref",style:v,children:(0,go.jsx)(rb,{title:l.originalFilename||"Untitled",icon:Ds.$lS,children:(0,go.jsx)(Co.xv,{size:0,style:{color:"inherit"},children:"".concat(g,"MB")})})}),b=c&&(0,go.jsx)(Yg,{as:"ins",diff:t,path:"asset._ref",style:v,children:(0,go.jsx)(rb,{title:c.originalFilename||"Untitled",icon:Ds.$lS,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xv,{size:0,style:{color:"inherit"},children:"".concat(x,"MB")}),0!==m&&(0,go.jsx)(Co.Zb,{radius:2,padding:1,as:Vx,marginLeft:2,children:(0,go.jsxs)(Co.xv,{size:0,"data-number":m>0?"positive":"negative",children:[m>0&&"+",m,"%"]})})]})})}),j=(0,go.jsxs)(go.Fragment,{children:[y&&!b&&(0,go.jsx)(Hg,{diff:t,path:"asset._ref",description:"Removed",children:y}),y&&b&&(0,go.jsx)(Hg,{diff:t,path:"asset._ref",children:(0,go.jsx)(Fy,{from:y,layout:"grid",to:b})}),!y&&b&&(0,go.jsx)(Hg,{diff:t,path:"asset._ref",description:"Added",children:b})]});return(0,go.jsxs)(go.Fragment,{children:[u&&j,p.length>0&&(0,go.jsx)(Co.xu,{marginTop:u?4:3,children:(0,go.jsx)(Jy,{diff:t,schemaType:n,fields:p})})]})},image:e=>{let{diff:t,schemaType:n}=e;var i,r;const{fromValue:o,toValue:s,fields:a,isChanged:l}=t,c=null==(i=null==o?void 0:o.asset)?void 0:i._ref,d=null==(r=null==s?void 0:s.asset)?void 0:r._ref,u=Dg(t,["asset","_ref"]),p=Object.keys(a).filter((e=>a[e].isChanged&&"_type"!==e)),h=n.fields.filter((e=>!nv.includes(e.name)&&p.includes(e.name))).map((e=>e.name));let f="changed";!c&&d?f="added":!d&&c&&(f="removed");const m=p.includes("asset"),g=p.includes("crop"),x=p.includes("hotspot"),v=g||x,y=m||v,b=v&&!m,j=o&&c?(0,go.jsx)(Yg,{annotation:u,style:iv,children:(0,go.jsx)(tv,{is:"from",id:c,diff:t,action:f,hotspot:b&&x?o.hotspot:void 0,crop:b&&g?o.crop:void 0})}):(0,go.jsx)(Yx,{}),w=s&&d?(0,go.jsx)(Yg,{annotation:u,style:iv,children:(0,go.jsx)(tv,{is:"to",id:d,diff:t,hotspot:b&&x?s.hotspot:void 0,crop:b&&g?s.crop:void 0})}):(0,go.jsx)(Yx,{});if(!j&&!w)return(0,go.jsx)(Co.Zb,{padding:4,radius:2,tone:"transparent",children:(0,go.jsx)(Co.xv,{muted:!0,size:1,align:"center",children:"Image not set"})});if(!l)return d?(0,go.jsx)(Yg,{annotation:u,style:iv,children:(0,go.jsx)(tv,{id:d,is:"to",diff:t})}):null;const k=(0,go.jsx)(Fy,{align:"center",from:j,layout:"grid",to:w});return(0,go.jsxs)(go.Fragment,{children:[y&&(m?(0,go.jsx)(Hg,{annotations:u?[u]:[],description:"".concat(f[0].toUpperCase()).concat(f.slice(1)),children:k}):k),h.length>0&&(0,go.jsx)(Co.xu,{marginTop:y?4:3,children:(0,go.jsx)(Jy,{diff:t,schemaType:n,fields:h})})]})},number:e=>{let{diff:t,schemaType:n}=e;return(0,go.jsx)(Oy,{diff:t,schemaType:n,previewComponent:ov,layout:"inline"})},reference:e=>{let{diff:t,schemaType:n}=e;return(0,go.jsx)(Oy,{align:"center",diff:t,layout:"grid",path:"_ref",previewComponent:Nv,schemaType:n})},string:e=>{let{diff:t,schemaType:n}=e;const{options:i}=n;return(null==i?void 0:i.list)?(0,go.jsx)(Oy,{diff:t,previewComponent:Uv,schemaType:n}):(0,go.jsx)(Vv,{children:(0,go.jsx)(nb,{diff:t})})}};function Hv(e,t){var n;let i=e;for(;i;){const e=(null==(n=null==i?void 0:i.components)?void 0:n.diff)||$v(i,t)||Kv[i.name];if(e)return e;i=i.type}const r=["date","datetime"].includes(e.name)?e.name:e.jsonType;return Kv[r]}function $v(e,t){const n=Ox;let i;for(const r of n)if("function"===typeof r){if(i=r({schemaType:e,parentSchemaType:t}),i)return i}else console.error("Diff component resolver is not a function: ",r)}function Wv(e){return"field"===e.type}function Gv(e){return null!==e&&"undefined"!==typeof e&&""!==e}function Xv(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]:{};const o=Hv(e,r.parentSchema);if(!o){if("object"===e.jsonType&&"object"===t.type)return Yv(e,t,n,i,r);if("array"===e.jsonType&&"array"===t.type)return ey(e,t,n,i)}return ty(e,t,n,i,r)}function Yv(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]:{};const o=[],s={...r,parentSchema:e},a=e.fieldsets||e.fields.map((e=>({single:!0,field:e})));for(const l of a)l.single?o.push(...Jv(l.field,t,n,i,s)):o.push(...Qv(l,t,n,i,s));return o.length<2?o:[{type:"group",key:Ig(n)||"root",path:n,titlePath:i,changes:ny(o,i.length),schemaType:e}]}function Jv(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const{fieldFilter:o,...s}=r,a=t.fields[e.name];if(!a||!a.isChanged||o&&!o.includes(e.name))return[];const l=n.concat([e.name]),c=i.concat([e.type.title||e.name]);return Xv(e.type,a,l,c,s)}function Qv(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const{fields:o,name:s,title:a,readOnly:l,hidden:c}=e,{fieldFilter:d,...u}=r,p=c,h=l,f=i.concat([a||s]),m=[];for(const g of o){const e=t.fields[g.name];if(!e||!e.isChanged||d&&!d.includes(g.name))continue;const i=n.concat([g.name]),r=f.concat([g.type.title||g.name]);m.push(...Xv({readOnly:h,hidden:p,...g.type},e,i,r,u))}return m.length<2?m:[{type:"group",key:Ig(n)||"root",fieldsetName:s,path:n,titlePath:f,changes:ny(m,f.length),readOnly:h,hidden:p}]}function ey(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];const r=t.items.filter((e=>e.hasMoved&&e.fromIndex!==e.toIndex||"unchanged"!==e.diff.action));if(0===r.length)return[];const o=xx(e),s=[],a=r.reduce(((r,s)=>{const a=dx(s.diff,e),l=a.toType||a.fromType;if(!l)return console.warn("Could not determine schema type for item at %s",Ig(n)),r;const c=Rg(s.diff.fromValue)||Rg(s.diff.toValue)||t.items.indexOf(s),d=n.concat(c),u={itemDiff:s,parentDiff:t,parentSchema:e},p=i.concat({hasMoved:s.hasMoved,toIndex:s.toIndex,fromIndex:s.fromIndex,annotation:"unchanged"===s.diff.action?s.annotation:s.diff.annotation}),h=Xv(l,s.diff,d,p,u).map((e=>("field"===e.type&&Mg(d,e.path)&&(e.itemDiff=s),e)));return o&&h.filter(Wv).forEach(((e,t,n)=>{e.showHeader=1===n.length,e.showIndex=s.fromIndex!==s.toIndex&&s.hasMoved})),0===h.length?r.push(...ty(l,s.diff,d,p,u)):r.push(...h),r}),s);return a.length>1?[{type:"group",key:Ig(n)||"root",path:n,titlePath:i,changes:ny(a,i.length),schemaType:e}]:a}function ty(e,t,n,i){let{itemDiff:r,parentDiff:o,parentSchema:s}=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const{fromValue:a,toValue:l,type:c}=t;if("array"===c&&iy(a)&&iy(l))return[];let d;"undefined"!==typeof a&&(d=lx(a,e)),d||"undefined"===typeof l||(d=lx(l,e));let u,p=!0;const h=Hv(e,s);return h&&"function"===typeof h?u=h:h&&(u=h.component,p="undefined"===typeof h.showHeader?p:h.showHeader),[{type:"field",diff:t,path:n,error:d,itemDiff:r,parentDiff:o,titlePath:i,schemaType:e,showHeader:p,showIndex:!0,key:Ig(n)||"root",diffComponent:d?void 0:u,parentSchema:s}]}function ny(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 iy(e){return Array.isArray(e)&&0===e.length||null===e||"undefined"===typeof e}const ry=e=>"field"===e.type&&"added"===e.diff.action,oy=e=>{if("group"!==e.type)return[e];const t=[];
1return e.changes.forEach((e=>{t.push(...oy(e))})),t},sy=(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},ay=(e,t)=>{const n=Og(e[t]);if(n)return{_key:n};return Array.isArray(e)?parseInt(t,10):t},ly={diffMatchPatch:{enabled:!1}};function cy(e,t,n){if(!t)return;const i=[];if("group"===e.type){const r=oy(e),o=r.filter(ry);r.filter((e=>!ry(e))).forEach((e=>cy(e,t,n))),i.push(...uy(t,o.map((e=>e.path))))}else"added"===e.diff.action?i.push(...uy(t,[e.path])):"field"===e.type&&e.itemDiff&&e.parentDiff&&"array"===e.parentDiff.type&&e.itemDiff.hasMoved?i.push(...function(e,t,n){const i=n.slice(0,-1),{parentValue:r,fromIndex:o,fromValue:s}=function(e,t){if(e.fromValue&&"number"===typeof t.fromIndex){const n=e.fromValue[t.fromIndex];return{parentValue:e.fromValue,fromIndex:t.fromIndex,fromValue:n}}throw new Error("Failed to find item at index ".concat(t.fromIndex))}(t,e);let a;if(0===o)a={before:Ig([...i,0])};else{const e=o-1,t=Rg(r[e])||e;a={after:Ig([...i,t])}}return[{unset:[Ig(n)]},{insert:{...a,items:[s]}}]}(e.itemDiff,e.parentDiff,e.path)):i.push(...function(e,t,n){const i=(0,Vl.C)(e.toValue,e.fromValue,ly,n),r=i.filter((e=>"insert"===e.op)).map((e=>{let{after:t,items:n}=e;return{insert:{after:Ig(t),items:n}}})),o=i.filter((e=>"unset"===e.op)).reduce(((e,t)=>e.concat(Ig(t.path))),[]),s=new Set,a=[];let l=!1;const c=i.filter((e=>"set"===e.op)).reduce(((e,n)=>(l=!0,a.push(...function(e,t,n){const i=t.fromValue,r=t.toValue,o=[];for(let s=1;s<=e.length;s++){const t=e.slice(0,s),a=Ig(t);if(n.has(a))continue;const l=e[s],c=(0,mo.Fd)(l)||(0,mo.dw)(l),d=Pg(i,t),u=fy(d);if(c&&Array.isArray(d)&&!Pg(r,e.slice(0,s+1))){const e=Eg(d,l),n=d[e-1
1],r=Pg(i,t.concat(l)),c=(0,mo.fU)(n)?{_key:n._key}:e-1,u=Ig(t.concat(e<1?0:c));o.push({setIfMissing:{[a]:[]}}),o.push({insert:{after:u,items:[fy(r)]}}),s++}else"undefined"!==typeof u&&(n.add(a),o.push({setIfMissing:{[a]:u}}))}return o}(n.path,t,s)),e[Ig(n.path)]=n.value,e)),{});return[...a,...r,...o.length>0?[{unset:o}]:[],...l?[{set:c}]:[]]}(e.diff,t,e.path));n.patch.execute(i)}function dy(e,t,n){return py(e.toValue,t,n)}function uy(e,t){const n=[];for(let i=0;i<t.length;i++){const r=n.some((e=>sy(t[i],e)));r||n.push(dy(e,t[i],t))}return[{unset:[...new Set(n.map(Ig))]}]}function py(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3?arguments[3]:void 0;if(t.length<=0){if(!i)throw new Error("Root has no ancestor");return i}const r=t.slice(0,-1),o=Pg(e,r),s=[r,...n.filter((e=>!sy(e,r)))];return hy(o,r,n)?py(e,r,s,i):t}function hy(e,t,n){const i=null==n?void 0:n.some((e=>Ig(e)===Ig(t))),r=Array.isArray(e)&&e.length<=0;return i||void 0===e||null===e||r||function(e){return"object"===typeof e&&null!==e&&Object.keys(e).length<=0}(e)||function(e,t,n){if(!Od(e)||!Array.isArray(e))return!1;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;if("_type"===i||"_key"===i)continue;const r=[...t,ay(e,i)];if(!hy(e[i],r,n))return!1}return!0}(e,t,n)}function fy(e){if(Array.isArray(e))return[];if("object"!==typeof e||null===e)return;const t={};return(0,mo.fU)(e)&&(t._key=e._key),(0,mo.ay)(e)&&(t._type=e._type),t}const my=(0,vo.createContext)(null);const gy=!1;var xy=Object.defineProperty,vy=(e,t,n)=>(((e,t,n)=>{t in e?xy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class yy extends vo.Component{constructor(){super(...arguments),vy(this,"state",{})}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error("Error rendering diff component: "),console.error(e)}render(){const{error:e}=this.state;return e?(0,go.jsx)(Co.Zb,{padding:3,radius:2,tone:"critical",children:(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.uIy,{})}),(0,go.jsxs)(Co.xu,{paddingLeft:3,children:[(0,go.jsx)(Co.xv,{as:"h3",size:1,weight:"medium",children:"Rendering the changes to this field caused an error"}),gy&&(0,go.jsx)(Co.xu,{marginTop:2,children:(0,go.jsx)(Co.xv,{as:"p",size:1,children:"Check the developer console for more information"})})]})]})}):this.props.children}}const by={down:Ds.veu,right:Ds.LZ3};function jy(e){const{direction:t="right",...n}=e,i=by[t];return(0,go.jsx)(Co.xv,{muted:!0,size:1,...n,children:(0,vo.createElement)(i)})}const wy=Es.ZP.pre(Pe||(Pe=rd(["\n overflow-x: auto;\n position: relative;\n"]))),ky=Es.ZP.div(Ee||(Ee=rd(["\n position: absolute;\n top: 0;\n right: 0;\n"])));function Cy(e){const{children:t,as:n,change:i,...r}=e,o=(0,vo.useRef)(!1),[s,a]=(0,vo.useState)(!1),l=(0,vo.useCallback)((()=>a((e=>!e))),[a]),c=(0,vo.useCallback)((()=>o.current=!0),[]),d=(0,vo.useCallback)((()=>o.current=!1),[o]);return(0,vo.useEffect)((()=>{function e(e){const{metaKey:t,key:n}=e;t&&"i"===n&&o.current&&l()}return window.addEventListener("keydown",e,!1),()=>window.removeEventListener("keydown",e,!1)}),[l]),(0,go.jsx)(Co.xu,{as:n,onMouseEnter:c,onMouseLeave:d,...r,children:s?(0,go.jsx)(Sy,{change:i}):t})}const _y=e=>{let{title:t}=e;return(0,go.jsx)(Co.xu,{padding:3,display:"inline-block",as:ky,children:(0,go.jsx)(Co.__,{size:1,muted:!0,children:t})})};function Sy(e){let{change:t}=e;var n,i,r;return(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.Zb,{padding:3,tone:"transparent",as:wy,radius:1,children:[(0,go.jsx)(_y,{title:"meta"}),(0,go.jsx)(Co.EK,{language:"json",size:1,children:Iy({path:Ig(t.path),fromIndex:null==(n=t.itemDiff)?void 0:n.fromIndex,toIndex:null==(i=t.itemDiff)?void 0:i.toIndex,hasMoved:null==(r=t.itemDiff)?void 0:r.hasMoved,action:t.diff.action,isChanged:t.diff.isChanged})})]}),(0,go.jsxs)(Co.Zb,{as:wy,tone:"critical",padding:3,radius:1,children:[(0,go.jsx)(_y,{title:"from"}),(0,go.jsx)(Co.EK,{language:"json",size:1,children:Ty(t.diff.fromValue)})]}),(0,go.jsx)(Co.Zb,{children:(0,go.jsx)(jy,{direction:"down",align:"center"})}),(0,go.jsxs)(Co.Zb,{as:wy,tone:"positive",padding:3,radius:1,children:[(0,go.jsx)(_y,{title:"to"}),(0,go.jsx)(Co.EK,{language:"json",size:1,children:Ty(t.diff.toValue)})]})]})}function Ty(e){return"undefined"===typeof e?"undefined":JSON.stringify(e,null,2)}function Iy(e){const t=[];return Object.entries(e).forEach((e=>{let[n,i]=e;"undefined"!==typeof i&&null!==i&&t.push("".concat(n,": ").concat(i))})),t.join("\n")}const Py={flexShrink:0},Ey={alignItems:"stretch"},Ay={top:"flex-start",center:"center",bottom:"flex-end",default:"flex-start"},Fy=(0,vo.forwardRef)((function(e,t){const{align:n="top",layout:i="inline",from:r,to:o,style:s,...a}=e,l=(0,Co.Fg)(),c="inline"===i?Co.kC:Co.rj,d=(0,vo.useMemo)((()=>({...s,..."inline"===i?{maxWidth:"100%",display:"inline-flex"}:{gridTemplateColumns:"minmax(0, 1fr) ".concat((0,Co.hO)(l.sanity.space[5])," minmax(0, 1fr)")}}
1)),[i,s,l]),u="inline"===i?Py:Ey;return(0,go.jsxs)(c,{...a,ref:t,style:d,"data-from-to-layout":!0,children:[r&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.kC,{align:Ay[n],style:u,children:r}),(0,go.jsx)(Co.kC,{align:"center",justify:"center",padding:2,children:(0,go.jsx)(jy,{})})]}),(0,go.jsx)(Co.kC,{align:Ay[n],style:u,children:o})]})})),My={flex:1,minWidth:0,display:"block",whiteSpace:"break-spaces"};function Oy(e){const{align:t,cardClassName:n,diff:i,layout:r,path:o,previewComponent:s,schemaType:a}=e,{action:l}=i,c=function(e){const t=Gv(e.fromValue),n=Gv(e.toValue);return!t&&n?"Added":!n&&t?"Removed":"Changed"}(i);if("unchanged"===l)return(0,go.jsx)(Yg,{className:n,style:My,children:(0,vo.createElement)(s,{schemaType:a,value:i.toValue})});const d=void 0!==i.fromValue&&null!==i.fromValue&&(0,go.jsx)(Yg,{as:"del",className:n,diff:i,path:o,style:My,children:(0,vo.createElement)(s,{schemaType:a,value:i.fromValue})}),u=void 0!==i.toValue&&null!==i.toValue&&(0,go.jsx)(Yg,{as:"ins",className:n,diff:i,path:o,style:My,children:(0,vo.createElement)(s,{schemaType:a,value:i.toValue})});return d&&!u?(0,go.jsx)(Hg,{description:c,diff:i,path:o,children:d}):!d&&u?(0,go.jsx)(Hg,{description:c,diff:i,path:o,children:u}):(0,go.jsx)(Hg,{description:c,diff:i,path:o,children:(0,go.jsx)(Fy,{align:t,from:d,layout:r,to:u})})}const Ry=e=>{let{value:t,schemaType:n}=e;return(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(BF,{schemaType:n,value:t,layout:"default"})})},zy=e=>{const{diff:t,schemaType:n}=e;return(0,go.jsx)(Oy,{diff:t,schemaType:n,previewComponent:Ry,layout:"grid"})},Dy=(0,Es.ZP)(Co.zx)(Ae||(Ae=rd(["\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"])),(e=>{let{theme:t}=e;return t.sanity.color.solid.critical.enabled.bg})),By=(0,vo.forwardRef)((function(e,t){const{selected:n,...i}=e;return(0,go.jsx)(Dy,{icon:Ds.V13,selected:n,text:"Revert changes",mode:"bleed",padding:1,fontSize:1,space:2,ref:t,...i})}));function Ly(e){let{error:t}=e;return(0,go.jsx)(Co.Zb,{tone:"critical",padding:3,children:(0,go.jsxs)(Co.kC,{align:"flex-start",children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.uIy,{})})}),(0,go.jsx)(Co.xu,{flex:1,paddingLeft:3,children:(0,go.jsxs)(Co.xv,{size:1,as:"p",children:["Value error: ",t.message]})})]})})}const Zy=Es.ZP.div(Fe||(Fe=rd(["\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})),Ny=Es.ZP.div(Me||(Me=rd(["\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,Co.hO)(t.sanity.space[1])}),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.space[2])})),qy=(0,Es.ZP)(Co.J2)(Oe||(Oe=rd(["\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 Uy(e){var t;const{change:n,hidden:i,readOnly:r}=e,o=null!=(t=function(){const e=(0,vo.useContext)(my);return e&&e.readOnly||null}())?t:r,s=n.diffComponent||zy,{documentId:a,schemaType:l,rootDiff:c,isComparingCurrent:d,FieldWrapper:u=vo.Fragment}=qx(),p=JZ(a,l.name),[h,f]=(0,vo.useState)(!1),[m,g]=(0,vo.useState)(!1),[x,v]=(0,vo.useState)(null),[y,b]=Vq({id:a,type:l.name,permission:"update"}),j=(0,vo.useCallback)((()=>{cy(n,c,p)}),[n,c,p]),w=(0,vo.useCallback)((()=>{f(!0)}),[]),k=vo.useCallback((()=>{f(!1)}),[]),C=(0,vo.useCallback)((()=>{g(!0)}),[]),_=(0,vo.useCallback)((()=>{g(!1)}),[]),S=(0,vo.useCallback)((()=>f(!1)),[]);(0,Co.O8)(S,[x]);return(0,vo.useMemo)((()=>i?null:(0,go.jsxs)(Co.Kq,{space:1,as:Zy,children:[n.showHeader&&(0,go.jsx)(rx,{change:n,titlePath:n.titlePath}),(0,go.jsx)(u,{path:n.path,hasHover:m,children:(0,go.jsxs)(Cy,{change:n,as:Ny,"data-revert-field-hover":m?"":void 0,"data-error":n.error?"":void 0,"data-revert-all-hover":!0,children:[n.error?(0,go.jsx)(Ly,{error:n.error}):(0,go.jsx)(yy,{children:(0,go.jsx)(ax.Provider,{value:{path:n.path},children:(0,go.jsx)(s,{diff:n.diff,schemaType:n.schemaType})})}),d&&!b&&(null==y?void 0:y.granted)&&(0,go.jsx)(qy,{content:(0,go.jsxs)(Co.xu,{padding:3,sizing:"border",children:["Are you sure you want to revert the changes?",(0,go.jsxs)(Co.rj,{columns:2,gap:2,marginTop:2,children:[(0,go.jsx)(Co.zx,{mode:"ghost",onClick:k,children:(0,go.jsx)(Co.xv,{align:"center",children:"Cancel"})}),(0,go.jsx)(Co.zx,{tone:"critical",onClick:j,children:(0,go.jsx)(Co.xv,{align:"center",children:"Revert change"})})]})]}),open:h,portal:!0,placement:"left",ref:v,children:(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(By,{onClick:w,onMouseEnter:C,onMouseLeave:_,selected:h,disabled:o,"data-testid":"single-change-revert-button-".concat(null==n?void 0:n.key)})})})]})})]}
1)),[n,k,o,h,s,u,i,C,_,j,w,d,b,y,m])}const Vy=Es.ZP.div(Re||(Re=rd(["\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n"]))),Ky=Es.ZP.div(ze||(ze=rd(["\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,Co.hO)(t.sanity.space[1])}),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.space[2])})),Hy=(0,Es.ZP)(Co.J2)(De||(De=rd(["\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 $y(e){const{change:t,readOnly:n,hidden:i,...r}=e,{titlePath:o,changes:s,path:a}=t,{path:l}=(0,vo.useContext)(ax),{documentId:c,schemaType:d,FieldWrapper:u,rootDiff:p,isComparingCurrent:h}=qx(),f=s.every((e=>Wv(e)&&kx(e.schemaType))),m=Mg(l,a),[g,x]=function(){const e=(0,vo.useRef)(null),[t,n]=(0,vo.useState)(!1);return(0,vo.useEffect)((()=>{const t=e.current;if(!t)return()=>{};const 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=JZ(c,d.name),[y,b]=(0,vo.useState)(!1),[j,w]=(0,vo.useState)(null),[k,C]=Vq({id:c,type:d.name,permission:"update"}),_=(0,vo.useCallback)((()=>cy(t,p,v)),[t,p,v]),S=(0,vo.useCallback)((()=>{b(!0)}),[]),T=(0,vo.useCallback)((()=>{b(!1)}),[]);(0,Co.O8)((()=>b(!1)),[j]);const I=(0,vo.useMemo)((()=>i?null:(0,go.jsxs)(Co.Kq,{space:1,as:Ky,"data-revert-group-hover":x?"":void 0,"data-portable-text":f?"":void 0,children:[(0,go.jsx)(Co.Kq,{as:Vy,space:5,children:s.map((e=>(0,go.jsx)(Wy,{change:e,readOnly:n,hidden:i},e.key)))}),h&&!C&&(null==k?void 0:k.granted)&&(0,go.jsx)(Hy,{content:(0,go.jsxs)(Co.xu,{children:["Are you sure you want to revert the changes?",(0,go.jsxs)(Co.rj,{columns:2,gap:2,marginTop:2,children:[(0,go.jsx)(Co.zx,{mode:"ghost",onClick:T,children:(0,go.jsx)(Co.xv,{align:"center",children:"Cancel"})}),(0,go.jsx)(Co.zx,{tone:"critical",onClick:_,children:(0,go.jsx)(Co.xv,{align:"center",children:"Revert change"})})]})]}),portal:!0,padding:4,placement:"left",open:y,ref:w,children:(0,go.jsx)(Co.xu,{children:(0,go.jsx)(By,{onClick:S,ref:g,selected:y,disabled:n,"data-testid":"group-change-revert-button-".concat(t.fieldsetName)})})})]})),[s,T,y,n,t.fieldsetName,_,S,i,h,x,C,f,k,g]);return i?null:(0,go.jsxs)(Co.Kq,{space:1,...r,children:[(0,go.jsx)(rx,{titlePath:o}),m||!u?I:(0,go.jsx)(u,{hasHover:x,path:t.path,children:I})]})}function Wy(e){var t,n;const{change:i,hidden:r,readOnly:o}=e,{value:s}=qx(),a=sx({document:s,checkProperty:r||(null==(t=i.schemaType)?void 0:t.hidden),checkPropertyKey:"hidden",value:"field"===i.type?i.diff.toValue:void 0}),l=sx({document:s,checkProperty:o||(null==(n=i.schemaType)?void 0:n.readOnly),checkPropertyKey:"readOnly",value:"field"===i.type?i.diff.toValue:void 0});return a?null:"field"===i.type?(0,go.jsx)(Uy,{change:i,readOnly:l}):"group"===i.type?(0,go.jsx)($y,{change:i,"data-testid":"group-change-".concat(i.fieldsetName),readOnly:l}):(0,go.jsxs)(Co.xv,{children:["Unknown change type: ",(0,go.jsx)("code",{children:i.type||"undefined"})]})}function Gy(){return(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",as:"h3",children:"There are no changes"}),(0,go.jsx)(Co.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."})]})}const Xy=Es.ZP.div(Be||(Be=rd(["\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n"]))),Yy=(0,Es.ZP)(Co.J2)(Le||(Le=rd(["\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 Jy(e){let{diff:t,fields:n,schemaType:i}=e;const{documentId:r,isComparingCurrent:o,value:s}=qx(),a=JZ(r,i.name),{path:l}=(0,vo.useContext)(ax),c=0===l.length,[d,u]=(0,vo.useState)(!1),[p,h]=(0,vo.useState)(!1),f=sx({document:s,value:void 0,checkProperty:i.readOnly,checkPropertyKey:"readOnly"});if("object"!==i.jsonType)throw new Error("Only object schema types are allowed in ChangeList");const[m,g]=Vq({id:r,type:i.name,permission:"update"}),x=(0,vo.useMemo)((()=>Yv(i,t,l,[],{fieldFilter:n})),[i,n,l,t]),v=(0,vo.useMemo)((()=>n&&0===n.length?[]:function(e){return 1===e.length&&"group"===e[0].type&&0===e[0].path.length?e[0].changes:e}(x)),[x,n]),y=x[0],b=(0,vo.useCallback)((()=>{cy(y,t,a),u(!1)}),[y,t,a]),j=(0,vo.useCallback)((()=>{u(!0)}),[]),w=(0,vo.useCallback)((()=>{h(!0)}),[]),k=(0,vo.useCallback)((()=>{h(!1)}),[]),C=(0,vo.useCallback)((()=>{u(!1)}),[]),[_,S]=(0,vo.useState)(null),T=(0,vo.useCallback)((()=>u(!1)),[]);if((0,Co.O8)(T,[_]),0===v.length)return c?(0,go.jsx)(Gy,{}):null;const I=c&&v.length>1;return(0,go.jsx)(Co.Zb,{children:(0,go.jsxs)(Co.Kq,{space:5,children:[(0,go.jsx)(Co.Kq,{as:Xy,space:5,children:v.map((e=>(0,go.jsx)("div",{children:(0,go.jsx)(Wy,{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)))}),I&&o&&!g&&(null==m?void 0:m.granted)&&(0,go.jsx)(Yy,{content:(0,go.jsxs)(Co.xu,{children:["Are you sure you want to revert all ",v.length," changes?",(0,go.jsxs)(Co.rj,{columns:2,gap:2,marginTop:2,children:[(0,go.jsx)(Co.zx,{mode:"ghost",text:"Cancel",onClick:C}),(0,go.jsx)(Co.zx,{tone:"critical",text:"Revert all",onClick:b})]})]}),open:d,padding:4,placement:"left",portal:!0,ref:S,children:(0,go.jsx)(Co.Kq,{children:(0,go.jsx)(Co.zx,{tone:"critical",mode:"ghost",text:"Revert all changes",icon:Ds.V13,onClick:j,onMouseEnter:w,onMouseLeave:k,disabled:f})})})]})})}const Qy=Es.ZP.span(Ze||(Ze=rd(["\n border-radius: ",";\n"])),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[1])})),eb=(0,Es.ZP)(Co.xv)(Ne||(Ne=rd(["\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 tb(e){const{segment:t}=e,{text:n}=t;return"added"===t.action?(0,go.jsx)(Yg,{annotation:t.annotation,disableHoverEffect:!0,tooltip:{description:"Added"},as:Qy,children:(0,go.jsx)(eb,{as:"ins",style:{textDecoration:"none"},children:n})}):"removed"===t.action?(0,go.jsx)(Yg,{annotation:t.annotation,as:Qy,disableHoverEffect:!0,tooltip:{description:"Removed"},children:(0,go.jsx)(eb,{as:"del",children:n})}):(0,go.jsx)(Co.Zb,{as:"span",radius:2,style:{display:"inline"},children:n})}function nb(e){const{diff:t}=e;return(0,go.jsx)(go.Fragment,{children:(t.segments||[]).map(((e,t)=>(0,go.jsx)(tb,{segment:e},t)))})}const ib=(0,Es.ZP)(Co.xv)(qe||(qe=rd(["\n color: inherit;\n"])));function rb(e){const{title:t,action:n,icon:i,children:r,markRemoved:o}=e;return(0,go.jsxs)(Co.kC,{padding:2,align:"center",children:[i&&(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(ib,{size:4,forwardedAs:o?"del":"div",children:(0,vo.createElement)(i)})}),(0,go.jsxs)(Co.Kq,{space:2,paddingLeft:2,children:[(0,go.jsx)(ib,{size:1,weight:"semibold",forwardedAs:o?"del":"h3",textOverflow:"ellipsis",children:t}),n&&(0,go.jsx)("div",{children:n}),(0,go.jsx)(ib,{size:0,textOverflow:"ellipsis",children:r})]})]})}Es.ZP.div(Ue||(Ue=rd(["\n display: inline-block;\n word-break: break-all;\n white-space: pre-wrap;\n"])));const ob=(0,vo.createContext)({hoveredStack:[],onMouseEnter:()=>{},onMouseLeave:()=>{}});
1function sb(){return(0,vo.useContext)(ob)}function ab(e){const{actions:t,children:n,path:i}=e,{onMouseEnter:r,onMouseLeave:o}=sb(),s=sb().hoveredStack[0],a=Kd||!!s&&Ig(i)===s,l=(0,vo.useCallback)((()=>{r(i)}),[r,i]),c=(0,vo.useCallback)((()=>{o(i)}),[o,i]),d=(0,vo.useMemo)((()=>({actions:t,hovered:a,onMouseEnter:l,onMouseLeave:c})),[t,l,c,a]);return(0,go.jsx)(rg.Provider,{value:d,children:n})}function lb(e){const{children:t}=e,[n,i]=(0,vo.useState)([]),r=(0,vo.useCallback)((e=>{const t=Ig(e);i((e=>e.includes(t)?e:[t,...e]))}),[]),o=(0,vo.useCallback)((e=>{const t=Ig(e);i((e=>e.includes(t)?e.filter((e=>e!==t)):e))}),[]),s=(0,vo.useMemo)((()=>({hoveredStack:n,onMouseEnter:r,onMouseLeave:o})),[r,o,n]);return(0,go.jsx)(ob.Provider,{value:s,children:t})}const cb={publish:()=>{},subscribe:()=>(console.warn("No patch channel provided to form-builder. If you need input based patch updates, please provide one"),()=>{})};function db(e){const{__internal_fieldActions:t=Ad,__internal_patchChannel:n=cb,autoFocus:i,changesOpen:r,children:o,collapsedFieldSets:s,collapsedPaths:a,file:l,filterField:c,focusPath:d,focused:u,groups:p,id:h,image:f,members:m,onChange:g,onFieldGroupSelect:x,onPathBlur:v,onPathFocus:y,onPathOpen:b,onSetFieldSetCollapsed:j,onSetPathCollapsed:w,presence:k,readOnly:C,renderAnnotation:_,renderBlock:S,renderField:T,renderInlineBlock:I,renderInput:P,renderItem:E,renderPreview:A,schemaType:F,unstable:M,validation:O,value:R}=e,z=(0,vo.useRef)(R);(0,vo.useEffect)((()=>{z.current=R}),[R]);const D=(0,vo.useMemo)((()=>({patchChannel:n,components:{ArrayFunctions:Nm,CustomMarkers:(null==M?void 0:M.CustomMarkers)||Km,Markers:(null==M?void 0:M.Markers)||Vm},field:{actions:t},file:{assetSources:l.assetSources,directUploads:!1!==(null==l?void 0:l.directUploads)},filterField:c||(()=>!0),image:{assetSources:f.assetSources,directUploads:!1!==(null==f?void 0:f.directUploads)},getDocument:()=>z.current,onChange:g})),[t,l.assetSources,null==l?void 0:l.directUploads,c,f.assetSources,null==f?void 0:f.directUploads,g,n,null==M?void 0:M.CustomMarkers,null==M?void 0:M.Markers]),B=(0,vo.useMemo)((()=>({__internal:D,autoFocus:i,changesOpen:r,collapsedFieldSets:s,collapsedPaths:a,focusPath:d,focused:u,groups:p,id:h,members:m,readOnly:C,renderAnnotation:_,renderBlock:S,renderField:T,renderInlineBlock:I,renderInput:P,renderItem:E,renderPreview:A,schemaType:F,value:R})),[D,i,r,s,a,R,d,u,p,h,m,C,_,S,T,I,P,E,A,F]);return(0,go.jsx)(Bm.Provider,{value:B,children:(0,go.jsx)($m,{onChange:g,onFieldGroupSelect:x,onPathBlur:v,onPathFocus:y,onPathOpen:b,onSetPathCollapsed:w,onSetFieldSetCollapsed:j,children:(0,go.jsx)(Jm,{presence:k,children:(0,go.jsx)(tg,{validation:O,children:(0,go.jsx)(lb,{children:o})})})})})}function ub(e){const{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,children:o,collapsedFieldSets:s,collapsedPaths:a,focusPath:l,focused:c,groups:d,id:u,members:p,onChange:h,onPathBlur:f,onPathFocus:m,onPathOpen:g,onFieldGroupSelect:x,onSetPathCollapsed:v,onSetFieldSetCollapsed:y,presence:b,readOnly:j,schemaType:w,validation:k,value:C}=e,{file:_,image:S}=SO().form,T=Gh({defaultComponent:kF,pick:EF}),I=Gh({defaultComponent:CF,pick:AF}),P=DF(),E=Gh({defaultComponent:_F,pick:MF}),A=Gh({defaultComponent:TF,pick:OF}),F=Gh({defaultComponent:IF,pick:RF}),M=Gh({defaultComponent:PF,pick:zF}),O=(0,vo.useCallback)((e=>(0,go.jsx)(T,{...e})),[T]),R=(0,vo.useCallback)((e=>(0,go.jsx)(I,{...e})),[I]),z=(0,vo.useCallback)((e=>(0,go.jsx)(E,{...e})),[E]),D=(0,vo.useCallback)((e=>(0,go.jsx)(uf,{component:P,...e})),[P]),B=(0,vo.useCallback)((e=>(0,go.jsx)(A,{...e})),[A]),L=(0,vo.useCallback)((e=>(0,go.jsx)(F,{...e})),[F]),Z=(0,vo.useCallback)((e=>(0,go.jsx)(M,{...e})),[M]);return(0,go.jsx)(db,{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:s,collapsedPaths:a,file:_,focusPath:l,focused:c,groups:d,id:u,image:S,members:p,onChange:h,onPathBlur:f,onPathFocus:m,onPathOpen:g,onFieldGroupSelect:x,onSetPathCollapsed:v,onSetFieldSetCollapsed:y,presence:b,readOnly:j,renderAnnotation:Z,renderBlock:B,renderField:R,renderInlineBlock:L,renderInput:O,renderItem:z,renderPreview:D,schemaType:w,validation:k,value:C,children:o})}function pb(e){const{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:o,collapsedPaths:s,focusPath:a,focused:l,groups:c,id:d,members:u,onChange:p,onPathBlur:h,onPathF
1ocus:f,onPathOpen:m,onFieldGroupSelect:g,onSetFieldSetCollapsed:x,onSetPathCollapsed:v,presence:y,readOnly:b,schemaType:j,validation:w,value:k}=e;return(0,go.jsx)(ub,{__internal_fieldActions:t,__internal_patchChannel:n,autoFocus:i,changesOpen:r,collapsedFieldSets:o,collapsedPaths:s,focusPath:a,focused:l,groups:c,id:d,members:u,onChange:p,onPathBlur:h,onPathFocus:f,onPathOpen:m,onFieldGroupSelect:g,onSetPathCollapsed:v,onSetFieldSetCollapsed:x,presence:y,validation:w,readOnly:b,schemaType:j,value:k,children:(0,go.jsx)(hb,{})})}function hb(){const{focusPath:e,focused:t,groups:n,id:i,members:r,readOnly:o,renderAnnotation:s,renderBlock:a,renderField:l,renderInlineBlock:c,renderInput:d,renderItem:u,renderPreview:p,schemaType:h,value:f}=Lm(),{onChange:m,onFieldGroupSelect:g,onPathBlur:x,onPathFocus:v,onPathOpen:y,onSetFieldSetCollapsed:b,onSetPathCollapsed:j}=Wm(),w=(0,vo.useCallback)((e=>j([e],!0)),[j]),k=(0,vo.useCallback)((e=>j([e],!1)),[j]),C=(0,vo.useCallback)((()=>x(Ad)),[x]),_=(0,vo.useCallback)((()=>v(Ad)),[v]),S=(0,vo.useCallback)((e=>m(Am.from(e))),[m]),T=(0,vo.useRef)(null),I=(0,vo.useCallback)((e=>g(Ad,e)),[g]),P=(0,vo.useCallback)((e=>y([e])),[y]),E=(0,vo.useCallback)((()=>y([])),[y]),A=(0,vo.useCallback)((e=>b([e],!0)),[b]),F=(0,vo.useCallback)((e=>b([e],!1)),[b]),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:E,onFieldCollapse:w,onFieldSetCollapse:A,onFieldExpand:k,onFieldSetExpand:F,onPathFocus:v,onFieldOpen:P,onFieldGroupSelect:I,path:Ad,presence:Ad,readOnly:o,renderAnnotation:s,renderBlock:a,renderField:l,renderInlineBlock:c,renderInput:d,renderItem:u,renderPreview:p,schemaType:h,validation:Ad,value:f};return(0,go.jsx)(go.Fragment,{children:d(M)})}const fb=(0,vo.createContext)({});function mb(){return(0,vo.useContext)(fb)}function gb(e){const{children:t,activePath:n,EditReferenceLinkComponent:i,onEditReference:r,initialValueTemplateItems:o}=e,s=(0,vo.useMemo)((()=>({activePath:n,EditReferenceLinkComponent:i,onEditReference:r,initialValueTemplateItems:o})),[n,i,r,o]);return(0,go.jsx)(fb.Provider,{value:s,children:t})}(0,vo.createContext)(null);function xb(e,t){return zm(t,(0,vo.useCallback)(((t,n)=>{e.current&&!t&&n&&(0,Xl.Z)(e.current,{scrollMode:"always"})}),[e]))}const vb=(()=>{let e;return()=>{if(e)return e;e=[];for(let t=0;t<256;++t)e[t]=(t+256).toString(16).substring(1);return e}})();function yb(e){const t=vb();return function(){const e=new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:16);return(0,bl.Z)(e),e}(e).reduce(((e,n)=>e+t[n]),"").slice(0,e)}const bb={portal:!0},jb=(0,Es.ZP)(Co.Zb)((e=>{let{theme:t,$selected:n}=e;var i;const{color:r}=t.sanity;return(0,Es.iv)(Ve||(Ve=rd(["\n --card-bg-color: inherit;\n --card-fg-color: inherit;\n --card-hairline-hard-color: ",";\n "])),n?null==(i=r.selectable)?void 0:i.default.pressed.border:void 0)})),wb=(0,Es.ZP)(Co.xu)(Ke||(Ke=rd(["\n max-width: 150px;\n"]))),kb=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 Cb(e){const{presence:t}=e,{color:n}=(0,Es.Fg)().sanity,i=n.dark?"light":"dark",{selected:r}=function(){const e=(0,vo.useContext)(Yu);if(!e)throw new Error("PreviewCard: missing context value");return e}(),o=(0,vo.useMemo)((()=>Array.from(new Set(t.map((e=>e.user.id)))).map((e=>t.find((t=>t.user.id===e)))).filter(wd)),[t]),s=(0,vo.useMemo)((()=>(0,go.jsx)(wb,{padding:2,children:(0,go.jsx)(Co.xv,{align:"center",size:1,children:kb(o)})})),[o]);return(0,go.jsx)(Co.u,{content:s,...bb,children:(0,go.jsx)(jb,{scheme:r?i:void 0,$selected:r,children:(0,go.jsx)(Co.Jh,{maxLength:2,children:o.map((e=>(0,go.jsx)(kV,{user:e.user},e.user.id)))})})})}const _b=3,Sb=[0,.25,.75,1],Tb=!1,Ib=(0,Es.ZP)(Co.kC)(He||(He=rd(["\n & > div:first-child {\n flex: 1;\n min-width: 0;\n }\n"]))),Pb=(0,Es.ZP)(Co.kC)($e||($e=rd(["\n height: 23px;\n min-width: 23px;\n vertical-align: top;\n"]))),Eb=vo.createContext([]);function Ab(e){const{children:t,items:n}=e,i=(0,vo.useMemo)((()=>(0,go.jsx)(Co.Kq,{padding:1,children:n.map((e=>(0,go.jsxs)(Co.kC,{align:"center",gap:2,padding:1,children:[(0,go.jsx)("div",{children:(0,go.jsx)(kV,{user:e.user,status:"online"})}),(0,go.jsx)(Co.xv,{size:1,children:e.user.displayName})]},e.user.id)))})),[n]);return(0,go.jsx)(Co.u,{content:i,placement:"top",portal:"documentScrollElement",children:t})}const{Tracker:Fb,useReporter:Mb,useReportedValues:Ob}=pd();function Rb(e){return 4+19*e}const zb=(0,vo.memo)((function(e){let{presence:t,position:n="inside",animateArrowFrom:i="inside",maxAvatars:r=_b,stack:o=!0}=e;const s=Hl()(t||[],(e=>e.user.id)),a=Fs()(s,(e=>e.lastActiveAt)),[l,c]=o?((e,t)=>
1{const n=e.length>t?t-1:t,i=Math.max(0,e.length-n);return[e.slice(0,i),e.slice(i)]})(a,r):[[],a],d=[...c.reverse().map((e=>({key:e.user.id,element:(0,go.jsx)(kV,{animateArrowFrom:i,position:n,status:"online",user:e.user})}))),l.length>=2?{key:"counter",element:(0,go.jsx)(Co.p2,{count:l.length})}:null].filter(Boolean),u=Rb(r),p=Math.min(Rb(s.length),u);return(0,go.jsxs)(Ib,{justify:"flex-end",style:{width:u},children:[(0,go.jsx)("div",{}),(0,go.jsx)(Ab,{items:s,children:(0,go.jsx)(Pb,{direction:"row-reverse",style:{width:p},children:d.map(((e,t)=>e&&(0,go.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)))})})]})}));const Db=function(e){const t=(0,vo.useContext)(Eb),{presence:n=t,maxAvatars:i=_b}=e,r=vo.useRef(null);Mb((0,vo.useId)(),(()=>({presence:n,element:r.current,maxAvatars:i})));const o=4+19*e.maxAvatars;return(0,go.jsx)(Ib,{justify:"flex-end",ref:r,style:{minWidth:o,minHeight:23}})};const Bb=e=>{const{onIntersection:t,io:n,id:i,...r}=e,o=vo.useRef(null);return vo.useEffect((()=>{const e=o.current;if(!e)return;
1const r=n.observe(e).pipe((0,Ko.b)((e=>t(i,e)))).subscribe();return()=>r.unsubscribe()}),[n,i,t]),(0,go.jsx)("div",{ref:o,...r})},Lb=Es.ZP.div(We||(We=rd(["\n position: relative;\n"]))),Zb=Es.ZP.div(Ge||(Ge=rd(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 13;\n"]))),Nb=(0,Es.iv)(Xe||(Xe=rd(["\n overflow: hidden;\n overflow: clip;\n pointer-events: none;\n position: absolute;\n"]))),qb=(0,Es.ZP)(Bb)((e=>{let{$debug:t,margins:n}=e;return(0,Es.iv)(Ye||(Ye=rd(["\n ","\n\n z-index: 100;\n position: sticky;\n height: 1px;\n top: ",";\n background-color: ",";\n "])),Nb,n?"".concat(n[0]-1,"px"):void 0,t?"red":"none")})),Ub=(0,Es.ZP)(Bb)((e=>{let{$debug:t}=e;return(0,Es.iv)(Je||(Je=rd(["\n ","\n\n visibility: none;\n\n ","\n "])),Nb,t&&(0,Es.iv)(Qe||(Qe=rd(["\n background: rgba(255, 0, 0, 0.25);\n outline: 1px solid #00b;\n visibility: visible;\n "]))))})),Vb=(0,Es.ZP)(Bb)((e=>{let{$debug:t}=e;return(0,Es.iv)(et||(et=rd(["\n ","\n\n position: sticky;\n bottom: -1px;\n height: 1px;\n background-color: ",";\n "])),Nb,t?"blue":"transparent")})),Kb=e=>"".concat(e,"px"),Hb=e=>0-e,$b=(0,vo.forwardRef)((function(e,t){const{regions:n,render:i,children:r,margins:o}=e,s=(0,vo.useRef)(null),a=(0,vo.useMemo)((()=>o),[JSON.stringify(o)]),l=(0,vo.useMemo)((()=>(e=>{const t=new Po.x,n=new IntersectionObserver((e=>{e.forEach((e=>{t.next(e)}))}),e);return{observe:e=>new zo.y((i=>{const r=t.pipe((0,Yo.h)((t=>t.target===e))).subscribe(i);return n.observe(e),()=>{r.unsubscribe(),n.unobserve(e)}}))}})({rootMargin:a.map(Hb).map(Kb).join(" "),threshold:Sb})),[a]),[c,d]=(0,vo.useState)({}),u=(0,vo.useCallback)(((e,t)=>{d((n=>({...n,[e]:t})))}),[]),p=c["::top"],h=c["::bottom"],f=(0,vo.useMemo)((()=>p&&h?n.filter((e=>{var t;return(null==(t=e.presence)?void 0:t.length)>0})).map((e=>{const t=c[e.id];if(!t)return null;const{bottom:n,top:i}=t.boundingClientRect,r=t.boundingClientRect.top<p.boundingClientRect.bottom,o=t.boundingClientRect.top<h.boundingClientRect.top,s=t.isIntersecting?i-(t.intersectionRect.top-23):r?-p.boundingClientRect.bottom:h.boundingClientRect.top,a=t.isIntersecting?-(n-(t.intersectionRect.bottom+23)):o?h.boundingClientRect.top:-p.boundingClientRect.bottom;return{distanceTop:s,distanceBottom:a,region:e,position:s<=8?"top":a<=8?"bottom":"inside"}})).filter(Boolean):[]),[h,c,n,p]);return(0,go.jsxs)(Lb,{ref:t,children:[(0,go.jsx)(qb,{$debug:Tb,io:l,id:"::top",onIntersection:u,margins:a}),(0,go.jsx)("div",{children:r}),(0,go.jsx)(Zb,{ref:s,children:s.current&&i(f,s.current.offsetWidth)}),n.map((e=>{const t=0===e.rect.width;return(0,go.jsx)(Ub,{$debug:Tb,io:l,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,go.jsx)(Vb,{$debug:Tb,id:"::bottom",io:l,onIntersection:u})]})})),Wb={transitionProperty:"transform",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.85, 0, 0.15, 1)"};const Gb=e=>ml()(e,(e=>e.region.rect.top)),Xb=(e,t)=>e+t,Yb=e=>e.reduce(Xb,0);const Jb=e=>{let{height:t,...n}=e;return(0,go.jsx)("div",{style:{height:Math.max(0,t),...null==n?void 0:n.style}})},Qb=[0,0,0,0],ej=(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 tj(e,t){return{...ej(e,t),width:e.offsetWidth,height:e.offsetHeight}}function nj(e){const{children:t,margins:n=Qb}=e,i=Ob(),r=vo.useRef(null),o=vo.useMemo((()=>r.current?function(e,t){return e.map((e=>{let[n,i]=e;return{...i,id:n,rect:tj(i.element,t)}}))}(i,r.current):ij),[i]),s=vo.useCallback(((e,t)=>{const i=function(e){const t=function(e){return e.map(((e,t,n)=>{var i;const r=null==(i=n[t-1])?void 0:i.region.rect,o=r?(s=r).top+s.height:0;var s;return{...e,spacerHeight:e.region.rect.top-o}}))}(Gb(e)),n={top:[],inside:[],bottom:[],...Wl()(t,(e=>e.position))};return{top:Gb(n.top).map(((e,t,n)=>({...e,indent:n.slice(t+1).reduce(((e,t)=>e+t.region.rect.width),0)}))),inside:Gb(n.inside).map((e=>({...e,indent:0}))),bottom:Gb(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=Yb(i.top.map((e=>e.region.rect.height+e.spacerHeight))),o=Yb([...i.inside,...i.bottom].map((e=>e.region.rect.height+e.spacerHeight))),s=i.inside.reduce(((e,t)=>{const{distanceTop:n,distanceBottom:i}=t,r=n<=20,o=i<=20;return{nearTop:e.nearTop+(r?t.region.presence.length:0),nearBottom:e.nearBottom+(o?t.region.presence.length:0)}}),{nearTop:0,nearBottom:0});return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(rj,{closeCount:s.nearTop,margins:n,position:"top",regi
1onsWithIntersectionDetails:i.top}),(0,go.jsx)(Jb,{height:r}),(0,go.jsx)(oj,{containerWidth:t,regionsWithIntersectionDetails:i.inside}),(0,go.jsx)(Jb,{height:o}),(0,go.jsx)(rj,{closeCount:s.nearBottom,margins:n,position:"bottom",regionsWithIntersectionDetails:i.bottom})]})}),[n]);return(0,go.jsx)($b,{ref:r,margins:n,regions:o,render:s,children:t})}const ij=[],rj=(0,vo.memo)((function(e){const{closeCount:t,margins:n,position:i,regionsWithIntersectionDetails:r}=e,o="top"===i?1:-1,s=(0,vo.useMemo)((()=>r.length?sl()(Fs()(r,(e=>e.region.rect.top*o)).map((e=>e.region.presence||ij))):ij),[o,r]),[a,l,c,d]=n,u=(d||0)+(s.length>0?19*-t:0)-l,p="top"===i?a:c,h=(0,vo.useMemo)((()=>({zIndex:2,position:"sticky",display:"flex",flexDirection:"column",alignItems:"flex-end",...Wb,transform:"translate3d(".concat(u,"px, 0px, 0px)"),top:5+p,bottom:5+p})),[u,p]);return(0,go.jsx)("div",{"data-dock":i,style:h,children:(0,go.jsx)(zb,{position:i,maxAvatars:3,presence:s})},"sticky-".concat(i))}));function oj(e){const{regionsWithIntersectionDetails:t,containerWidth:n}=e;return(0,go.jsx)(go.Fragment,{children:t.map((e=>{const t=e.region.rect.left,{distanceTop:i,distanceBottom:r}=e,o=i<=20,s=r<=20,a=n-t-e.region.rect.width,{presence:l,maxAvatars:c}=e.region;return(0,go.jsx)(vo.Fragment,{children:(0,go.jsx)("div",{style:{zIndex:2,position:"absolute",pointerEvents:"all",...Wb,left:t,transform:"translate3d(".concat(o||s?a:0,"px, 0px, 0px)"),height:e.region.rect.height,top:e.region.rect.top},children:(0,go.jsx)(sj,{value:()=>"\u2912".concat(i," | ").concat(r,"\u2913"),children:(0,go.jsx)(zb,{stack:!o&&!s,position:o?"top":s?"bottom":"inside",maxAvatars:c,presence:l})})})},e.region.id)}))})}const sj=e=>e.children,aj=[0,0,0,0];const lj=function(e){let{children:t,margins:n}=e;return(0,go.jsx)(Fb,{children:(0,go.jsx)(nj,{margins:n||aj,children:t})})},cj=[],dj={error:Vs.VG.red[500].hex,warning:Vs.VG.yellow[500].hex,info:Vs.VG.blue[500].hex},uj={error:(0,go.jsx)(Ds.uIy,{"data-testid":"input-validation-icon-error"}),warning:(0,go.jsx)(Ds.foC,{"data-testid":"input-validation-icon-warning"}),info:(0,go.jsx)(Ds.hQ6,{"data-testid":"input-validation-icon-info"})},pj=(0,Es.ZP)(Co.Kq)(tt||(tt=rd(["\n max-width: 200px;\n"])));function hj(e){const{validation:t=cj,__unstable_showSummary:n,fontSize:i,placement:r="top"}=e,o=t.filter((e=>"error"===e.level)),s=t.filter((e=>"warning"===e.level)),a=t.filter((e=>"info"===e.level)),l=o.length>0,c=s.length>0,d=a.length>0,u=(0,vo.useMemo)((()=>l?uj.error:c?uj.warning:d?uj.info:void 0),[l,d,c]),p=(0,vo.useMemo)((()=>l?dj.error:c?dj.warning:d?dj.info:void 0),[l,d,c]);return(0,go.jsx)(Co.u,{content:(0,go.jsxs)(pj,{padding:3,space:3,children:[n&&(0,go.jsx)(mj,{validation:t}),!n&&(0,go.jsx)(go.Fragment,{children:t.map(((e,t)=>(0,go.jsx)(fj,{validation:e},t)))})]}),portal:!0,placement:r,fallbackPlacements:["bottom","right","left"],children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.xv,{muted:!0,size:i,weight:"semibold",style:{color:p},children:u})})})}function fj(e){const{validation:t}=e,n=(0,vo.useMemo)((()=>"error"===t.level?uj.error:"warning"===t.level?uj.warning:"info"===t.level?uj.info:void 0),[t]),i=(0,vo.useMemo)((()=>"error"===t.level?dj.error:"warning"===t.level?dj.warning:"info"===t.level?dj.info:void 0),[t]);return(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{marginRight:2,children:(0,go.jsx)(Co.xv,{size:1,style:{color:i},children:n})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.xv,{size:1,children:t.message})})]})}function mj(e){let{validation:t}=e;const n=t.filter((e=>"error"===e.level)),i=t.filter((e=>"warning"===e.level)),r=n.length,o=i.length,s="error".concat(1===r?"":"s"),a="warning".concat(1===o?"":"s"),l=r&&"".concat(r," ").concat(s),c=o&&"".concat(o," ").concat(a),d=r>0&&o>0;return(0,go.jsxs)(Co.xv,{size:1,children:[l||"",d&&(0,go.jsx)(go.Fragment,{children:" and "}),c||""]})}const gj=[],xj=(0,vo.memo)((function(e){const{description:t,inputId:n,title:i,validation:r=gj}=e,o=r.length>0;return(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xv,{as:"label",htmlFor:n,weight:"semibold",size:1,children:i||(0,go.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})}),o&&(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(hj,{fontSize:1,validation:r})})]}),t&&(0,go.jsx)(Co.xv,{muted:!0,size:1,children:t})]})})),vj=(0,Es.ZP)(Co.kC)({lineHeight:1}),yj=(0,vo.memo)((function(e){const{__unstable_actions:t,__unstable_presence:n,description:i,inputId:r,title:o,validation:s}=e;return(0,go.jsxs)(vj,{align:"flex-end",children:[(0,go.jsx)(Co.xu,{flex:1,paddingY:2,children:(0,go.jsx)(xj,{validation:s,description:i,inputId:r,title:o})}),n&&n.length>0&&(0,go.jsx)(Co.xu,{flex:"none",children:(0,go.jsx)(Db,{maxAvatars:4,presence:n})}),t&&(0,go.jsx)(Co.xu,{flex:"none",marginLeft:3,children:t})]})})),bj=(0,vo.memo)((function(e){const{validation:t,__unstable_headerActions:n,__unstable_presence:i,children:r,description:o,inputId:s,level:a,title:l,...c}=e;return(0,go.jsxs)(Co.Kq,{...c,"data-level":a,space:1,children:[l&&(0,go.jsx)(yj,{__unstable_actions:n,validation:t,__unstable_presence:i,description:o,inputId:s,title:l}),(0,go.jsx)("div",{children:r})]})})),jj=Es.ZP.legend(nt||(nt=rd(["\n /* See: https://thatemil.com/blog/2015/01/03/reset-your-fieldset/ */\n padding: 0;\n display: table;\n"]))),wj=(0,Es.ZP)(Co.kC).attrs({forwardedAs:"button"})((e=>{const{theme:t}=e,{focusRing:n,radius:i}=t.sanity,{base:r}=t.sanity.color;return(0,Es.iv)(it||(it=rd(["\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,Co.hO)(i[1]),Su({base:r,focusRing:n}))})),kj=(0,Es.ZP)(Co.xu)(rt||(rt=rd(["\n width: 9px;\n height: 9px;\n margin-right: 3px;\n\n & svg {\n transition: transform 100ms;\n }\n"]))),Cj=(0,vo.memo)((function(e){const{collapsed:t,collapsible:n,onClick:i,title:r}=e,o=(0,go.jsx)(Co.xv,{weight:"semibold",size:1,children:r||(0,go.jsx)("span",{style:{color:"var(--card-muted-fg-color)"},children:"Untitled"})});return n?(0,go.jsx)(jj,{children:(0,go.jsxs)(wj,{type:"button",onClick:i,children:[(0,go.jsx)(kj,{children:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:(0,go.jsx)(Ds.tgp,{style:{transform:"rotate(".concat(t?"0":"90deg",") translate3d(0, 0, 0)")}})})}),o]})}):(0,go.jsx)(jj,{children:o})}));function _j(e){return"function"===typeof e?e():e}const Sj=(0,Es.ZP)(Co.xu).attrs({forwardedAs:"fieldset"})(ot||(ot=rd(["\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"]))),Tj=(0,Es.ZP)(Co.kC)({lineHeight:1}),Ij=(0,Es.ZP)(Co.xu)((e=>{const{$borderLeft:t,theme:n}=e,{focusRing:i,radius:r}=n.sanity,{base:o}=n.sanity.color;return(0,Es.iv)(st||(st=rd(["\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,Co.hO)(r[1]),Su({base:o,focusRing:{...i,offset:2}}))})),Pj=[],Ej=(0,vo.forwardRef)((function(e,t){const{__unstable_headerActions:n,validation:i=Pj,__unstable_presence:r=Pj,children:o,collapsible:s,columns:a,description:l,level:c=0,onFocus:d,onCollapse:u,onExpand:p,collapsed:h,tabIndex:f,title:m,...g}=e,x=i.length>0,v=(0,Co.ts)(t),y=(0,vo.useCallback)((e=>{v.current===e.target&&d&&d(e)}),[v,d]),b=(0,vo.useCallback)((()=>h?null==p?void 0:p():null==u?void 0:u()),[h,u,p]),j=(0,vo.useMemo)((()=>h?null:(0,go.jsx)(Co.rj,{columns:a,gapX:4,gapY:5,children:_j(o)})),[o,h,a]);return(0,go.jsxs)(Sj,{"data-level":c,...g,children:[m&&(0,go.jsxs)(Tj,{align:"flex-end",children:[(0,go.jsx)(Co.xu,{flex:1,paddingY:2,children:(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Cj,{collapsed:Boolean(h),collapsible:s,onClick:s?b:void 0,title:m}),x&&(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(hj,{fontSize:1,validation:i})})]}),l&&(0,go.jsx)(Co.xv,{muted:!0,size:1,children:l})]})}),r.length>0&&(0,go.jsx)(Co.xu,{flex:"none",children:(0,go.jsx)(Db,{maxAvatars:4,presence:r})}),n&&(0,go.jsx)(Co.xu,{flex:"none",marginLeft:1,children:n})]}),(0,go.jsx)(Ij,{$borderLeft:c>0,hidden:h,marginTop:1,paddingLeft:0===c?0:3,onFocus:"number"===typeof f&&f>-1?y:void 0,ref:v,tabIndex:f,children:!h&&j})]})})),Aj=Es.ZP.div(at||(at=rd(["\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"])));function Fj(e){let{children:t,maxAvatars:n,position:i="bottom"}=e;return(0,go.jsx)(Aj,{"data-max-avatars":n,"data-position":i,children:t})}const Mj=(0,Es.ZP)(Co.zx)(lt||(lt=rd(["\n cursor: ",";\n"])),(e=>e.grid?"move":"ns-resize")),Oj=vo.createContext(null),Rj=function(e){const t=(0,vo.useContext)(Oj),{listeners:n,attributes:i}=(0,Yl.nB)({id:t});return(0,go.jsx)(Mj,{icon:Ds.VVU,mode:"bleed","data-ui":"DragHandleButton",...i,...e,...n})};const zj="moving",Dj=(0,Es.ZP)(Co.xu)(ct||(ct=rd(["\n ","\n"])),(e=>e.$moving&&(0,Es.iv)(dt||(dt=rd(["\n z-index: 10000;\n /* prevents hover-effects etc on the dragged element */\n pointer-events: none;\n "]))))),Bj={threshold:{x:0,y:.02}},Lj={coordinateGetter:Yl.is},Zj={duration:200,easing:"ease"};function Nj(e){return"x"===e?ec.K7:ec.DL}function qj(e){return"x"===e?Yl.PG:Yl.qw}const Uj=(0,vo.memo)((function(e){const{items:t,axis:n,onItemMove:i,onItemMoveStart:r,onItemMoveEnd:o,children:s,...a}=e,l=(0,Jl.Dy)((0,Jl.VT)(Jl.we),(0,Jl.VT)(Jl.Lg,Lj)),c=(0,vo.useCallback)((e=>{var t,n,r,s;const{active:a,over:l}=e;a.id!==(null==l?void 0:l.id)&&(null==i||i({fromIndex:null==(n=null==(t=a.data.current)?void 0:t.sortable)?void 0:n.index,toIndex:null==(s=null==(r=null==l?void 0:l.data.current)?void 0:r.sortable)?void 0:s.index})),null==o||o()}),[i,o]),d=(0,vo.useMemo)((()=>{return[(e={y:4},t=>{let{containerNodeRect:n,draggingNodeRect:i,transform:r}=t;return i&&n?function(e,t,n,i){const r={...e},o=i.y||0,s=i.x||0;return t.top+r.y<=n.top+o?r.y=n.top-t.top+o:t.bottom+r.y>=n.top+n.height-o&&(r.y=n.top+n.height-t.bottom-o),t.left+r.x<=n.left-s?r.x=n.left-t.left+s:t.right+r.x>=n.left+n.width+s&&(r.x=n.left+n.width-t.right+s),r}(r,i,n,e):r}),...n?[Nj(n)]:[]];var e}),[n]);return(0,go.jsx)(Jl.LB,{sensors:l,autoScroll:Bj,modifiers:d,collisionDetection:Jl.pE,onDragEnd:c,onDragStart:r,children:(0,go.jsx)(Yl.Fo,{items:t,strategy:n?qj(n):void 0,children:(0,go.jsx)(Co.rj,{...a,children:s})})})})),Vj=(0,vo.forwardRef)((function(e,t){const{id:n,children:i,disableTransition:r}=e,{setNodeRef:o,transform:s,transition:a,active:l}=(0,Yl.nB)({id:n,transition:r?null:Zj}),c=n===(null==l?void 0:l.id),d=(0,vo.useMemo)((()=>({transform:Ql.ux.Translate.toString(s),transition:a,pointerEvents:l?"none":void 0})),[s,a,l]),u=(0,vo.useCallback)((e=>{o(e),"function"===typeof t?t(e):t&&(t.current=e)}
1),[t,o]);return(0,go.jsx)(Dj,{ref:u,style:d,$moving:c,className:c?zj:"","data-index":e["data-index"],children:i})}));function Kj(e){const{onItemMove:t,onItemMoveEnd:n,onItemMoveStart:i,sortable:r,...o}=e,s=(0,vo.useCallback)((e=>{null==t||t(e)}),[t]);return r?(0,go.jsx)(Uj,{onItemMove:s,onItemMoveStart:i,onItemMoveEnd:n,...o}):(0,go.jsx)(Co.rj,{...o})}const Hj=(0,vo.forwardRef)((function(e,t){const{sortable:n,...i}=e;return(0,go.jsx)(Oj.Provider,{value:e.id,children:n?(0,go.jsx)(Vj,{ref:t,...i}):(0,go.jsx)(Dj,{ref:t,...i})})})),$j=(0,Es.ZP)(Co.Zb)(ut||(ut=rd(["\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"])),zj);function Wj(e){const{validation:t,selected:n,tone:i,presence:r,focused:o,children:s,dragHandle:a,menu:l,footer:c}=e,d=(0,vo.useRef)(null);return zm(o,((e,t)=>{var n;!e&&t&&(null==(n=d.current)||n.focus())})),(0,go.jsx)($j,{ref:d,selected:n,"aria-selected":n,radius:2,padding:1,tone:i,children:(0,go.jsxs)(Co.Kq,{space:1,children:[(0,go.jsxs)(Co.kC,{align:"center",children:[a&&(0,go.jsx)(Co.xu,{marginRight:1,paddingY:1,children:(0,go.jsx)(Rj,{paddingX:1,paddingY:3})}),(0,go.jsx)(Co.xu,{flex:1,children:s}),(r||t||l)&&(0,go.jsxs)(Co.kC,{align:"center",marginLeft:1,children:[r&&(0,go.jsx)(Co.xu,{marginLeft:1,children:r}),t&&(0,go.jsx)(Co.xu,{marginLeft:1,children:t}),l]})]}),c]})})}const Gj=Es.ZP.button(pt||(pt=rd(["\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"]))),Xj=(0,Es.ZP)(Ds.tgp)(ht||(ht=rd(["\n transform: ",";\n"])),(e=>e.open?"rotate(90deg)":"")),Yj=(0,Es.ZP)(Co.kC)(ft||(ft=rd(["\n cursor: default;\n"]))),Jj=(0,Es.ZP)(Co.xu)(mt||(mt=rd(["\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 Qj(e){const{children:t,open:n,icon:i,title:r="Details",...o}=e,[s,a]=(0,vo.useState)(n||!1),l=(0,vo.useCallback)((()=>a((e=>!e))),[]);return(0,vo.useEffect)((()=>a(n||!1)),[n]),(0,go.jsxs)(Co.xu,{...o,children:[(0,go.jsx)(Gj,{type:"button",onClick:l,children:(0,go.jsx)(Yj,{align:"center",children:(0,go.jsxs)(Co.gF,{children:[(0,go.jsx)(Jj,{"data-open":s?"":void 0,children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Xj,{open:s})})}),i&&(0,go.jsx)(Co.xu,{marginLeft:1,children:i}),(0,go.jsx)(Co.xu,{flex:1,marginLeft:1,children:(0,go.jsx)(Co.xv,{size:1,weight:"medium",children:r})})]})})}),(0,go.jsx)(Co.xu,{hidden:!s,marginTop:3,children:t})]})}const ew={warning:"caution",error:"critical",info:"positive"},tw={warning:(0,go.jsx)(Ds.foC,{}),error:(0,go.jsx)(Ds.uIy,{}),info:(0,go.jsx)(Ds.hQ6,{})};function nw(e){const{children:t,status:n="warning",title:i,...r}=e;return(0,go.jsx)(Co.Zb,{radius:2,tone:ew[n],...r,"data-ui":"Alert",children:(0,go.jsx)(Co.kC,{padding:1,children:t&&(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Qj,{icon:tw[n],title:i,children:(0,go.jsx)(Co.xu,{marginLeft:3,marginTop:3,children:t})})})})})}function iw(e){return(0,mo.m$)(e)?"object"===e.name?{}:{_type:e.name}:(0,mo.jB)(e)?[]:"string"===e.jsonType?"":"number"===e.jsonType?0:"boolean"!==e.jsonType&&void 0}function rw(e){if(!(0,mo.m$)(e))throw new Error('Invalid item type: "'.concat(e.type,'". Default array input can only contain objects (for now)'));return{...iw(e),_key:(0,vl.E2)(12)}}const ow={portal:!0,tone:"default",placement:"left",constrainSize:!0},sw=(0,vo.memo)((function(e){const{types:t,onInsert:n}=e;return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(aw,{pos:"before",types:t,onInsert:n,text:"Add item before",icon:Ds.ySV}),(0,go.jsx)(aw,{pos:"after",types:t,onInsert:n,text:"Add item after",icon:Ds.oty})]})}));function aw(e){const{types:t,onInsert:n,pos:i,text:r,icon:o}=e;return 1===(null==t?void 0:t.length)?(0,go.jsx)(Co.sN,{text:r,icon:o,onClick:()=>n(i,t[0])},i):(0,go.jsx)(Co.kS,{text:r,popover:ow,children:null==t?void 0:t.map((e=>(0,go.jsx)(Co.sN,{icon:e.icon,text:e.title,onClick:()=>n(i,e)},e.name)))},i)}const lw=()=>{},cw={isLoading:!0,result:void 0,error:void 0,retry:lw},dw={isLoading:!1,result:void 0,error:void 0,retry:lw};function uw(e,t){const n=(0,vo.useMemo)((()=>new Po.x),[]),i=(0,vo.useMemo)((()=>n.asObservable()),[n]),r=(0,vo.useCallback)((()=>{n.next({type:"retry"})}),[n]),o=(0,_o.m2)((()=>(0,To.z)((0,So.of)(null),i).pipe((0,Ho.U)((()=>e)),(0,ls.b)((e=>e?t(e).pipe((0,Ho.U)((e=>({isLoading:!1,result:e,error:void 0,retry:r}))),(0,Qo.O)(cw),(0,Wo.K)((e=>(console.error(e),(0,So.of)({isLoading:!1,result:void 0,error:e,retry:r}))))):(0,So.of)(dw))))),[t,e,i,r],cw),s=Rm(e,e);return e&&s!==e?cw:o}function pw(e){let{time:t}=e;!function(e){const[t,n]=(0,vo.useReducer)((e=>e+1),0);(0,vo.useEffect)((()=>{const t=setInterval(n,e);return()=>clearInterval(t)}),[e])}(1e3);const n=(0,tc.Z)(new Date(t));return(0,go.jsxs)("span",{title:n,children:[n," ago"]})}function hw(e){const t=e.icon;return(0,go.jsxs)(Co.kC,{padding:3,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(t,{})})}),(0,go.jsxs)(Co.xu,{flex:1,marginLeft:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:e.title}),(0,go.jsx)(Co.xu,{marginTop:3,children:(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:e.children})})]})]})}function fw(e){var t,n,i,r;const{availability:o,id:s,layout:a,preview:l,refType:c,renderPreview:d,showTypeLabel:u}=e,p=(0,Co.Ur)(),h=oV(s),f="NOT_FOUND"===o.reason,m="PERMISSION_DENIED"===o.reason,g=(null==(t=l.draft)?void 0:t._id)||(null==(n=l.published)?void 0:n._id)||s,x=(0,vo.useMemo)((()=>({_id:g,_type:c.name})),[g,c.name]),v=(0,vo.useMemo)((()=>({layout:a,schemaType:c,value:x})),[a,x,c]);return(0,go.jsxs)(Co.kC,{align:"center",children:[o.available?(0,go.jsx)(Co.xu,{flex:1,children:d(v)}):(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.kC,{align:"center",children:(0,go.jsx)(Co.xu,{flex:1,paddingY:2,children:(0,go.jsx)(Co.xv,{muted:!0,children:"Document unavailable"})})})}),(0,go.jsx)(Co.xu,{paddingLeft:3,children:(0,go.jsxs)(Co.gF,{space:3,children:[u&&(0,go.jsx)(Co.__,{size:1,muted:!0,children:c.title}),m||f?(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.u,{portal:!0,content:f?(0,go.jsxs)(hw,{title:"Not found",icon:Ds.BHU,children:["The referenced document does not exist",(0,go.jsx)("br",{}),"(id: ",(0,go.jsx)("code",{children:s}),")"]}):(0,go.jsx)(hw,{title:"Insufficcient permissions",icon:Ds.vaB,children:"The referenced document could not be accessed due to insufficient permissions"}),children:(0,go.jsx)(Xp,{tone:"default",children:(0,go.jsx)(Ds.BHU,{})})})}):null,h&&h.length>0&&(0,go.jsx)(Cb,{presence:h}),(0,go.jsxs)(Co.gF,{space:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.u,{portal:!0,content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:(null==(i=l.published)?void 0:i._updatedAt)?(0,go.jsxs)(go.Fragment,{children:["Published ",(0,go.jsx)(pw,{time:l.published._updatedAt})]}):(0,go.jsx)(go.Fragment,{children:"Not published"})})}),children:(0,go.jsx)(Xp,{tone:"default"===p.tone?"positive":"default",size:1,dimmed:!l.published,muted:!l.published,children:(0,go.jsx)(Ds.EI4,{})})})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.u,{portal:!0,content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:(null==(r=l.draft)?void 0:r._updatedAt)?(0,go.jsxs)(go.Fragment,{children:["Edited ",(0,go.jsx)(pw,{time:l.draft._updatedAt})]}):(0,go.jsx)(go.Fragment,{children:"No unpublished edits"})})}),children:(0,go.jsx)(Xp,{tone:"default"===p.tone?"caution":"default",size:1,dimmed:!l.draft,muted:!l.draft,children:(0,go.jsx)(Ds.dY8,{})})})})]})]})})]})}function mw(e){var t,n,i,r,o,s;const{referenceInfo:a,renderPreview:l,type:c,value:d,showTypeLabel:u}=e;if(a.isLoading||a.error)return(0,go.jsx)(Qh,{isPlaceholder:!0});if("NOT_FOUND"===(null==(t=a.result)?void 0:t.availability.reason)&&d._strengthenOnPublish){const e=c.to.find((e=>{var t;return e.name===(null==(t=null==d?void 0:d._strengthenOnPublish)?void 0:t.type)}));if(!e)return(0,go.jsx)("div",{children:"Invalid reference type"});if(d._strengthenOnPublish){const t=(null==(n=d._strengthenOnPublish)?void 0:n.type)?{_id:d._ref,_type:null==(i=d._strengthenOnPublish)?void 0:i.type}:d;return(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xu,{flex:1,children:l({layout:"default",schemaType:e,value:t,skipVisibilityCheck:!0})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.gF,{space:4,children:u&&(0,go.jsx)(Co.__,{size:1,muted:!0,children:e.title})})})]})}}const p=null==(r=a.result)?void 0:r.type,h=c.to.find((e=>e.name===p));return h?(0,go.jsx)(fw,{availability:null==(o=a.result)?void 0:o.availability,id:d._ref,layout:"default",preview:null==(s=a.result)?void 0:s.preview,refType:h,renderPreview:l,showTypeLabel:u}):(0,go.jsxs)(Co.Kq,{space:2,padding:2,children:["The referenced document is of invalid type: (",p||"unknown",")",(0,go.jsx)("pre",{children:JSON.stringify(d,null,2)})]})}const gw=(0,Es.ZP)(Co.Zb)(gt||(gt=rd(["\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"]))),xw=(0,vo.forwardRef)((function(e,t){const{documentType:n,as:i,...r}=e,o=n?"a":void 0,s=n?i:"div";return(0,go.jsx)(gw,{...r,"data-as":o,documentType:n,forwardedAs:s,ref:t})})),vw=(0,vo.createContext)(null);function yw(e){const{menuRef:t,containerRef:n}=e;return(0,go.jsx)(vw.Provider,{value:{menuRef:t,containerRef:n},children:e.children})}const bw={portal:!0,tone:"default"},jw={position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:.6};function ww(e){var t,n,i,r,o,s,a,l,c,d;const{schemaType:u,parentSchemaType:p,path:h,readOnly:f,onRemove:m,value:g,open:x,onInsert:v,presence:y,validation:b,inputId:j,changed:w,focused:k,children:C,inputProps:{onCh
1ange:_,focusPath:S,onPathFocus:T,renderPreview:I,elementProps:P}}=e,E=!f&&!1!==(null==(t=p.options)?void 0:t.sortable),A=p.of,F=(0,vo.useRef)(null),M=(0,vo.useRef)(null),O=(0,vo.useRef)(null),{EditReferenceLink:R,getReferenceInfo:z,selectedState:D,isCurrentDocumentLiveEdit:B}=MI({path:h,schemaType:u,value:g});xb(F,x),zm(k,((e,t)=>{var n;!e&&t&&F.current&&(null==(n=F.current)||n.focus())}));const L=e.validation.some((e=>"error"===e.level)),Z=e.validation.some((e=>"warning"===e.level)),N=g._resolvingInitialValue,q=(0,vo.useCallback)((()=>{v({items:[{...g,_key:yb()}],position:"after"})}),[v,g]),U=(0,vo.useCallback)(((e,t)=>{v({items:[{...rw(t),_key:yb()}],position:e})}),[v]),V=uw(null==g?void 0:g._ref,z),K=g._ref,H=(null==(n=V.result)?void 0:n.type)||(null==(i=null==g?void 0:g._strengthenOnPublish)?void 0:i.type),$=K&&(null==(s=null==(o=null==(r=V.result)?void 0:r.preview)?void 0:o.published)?void 0:s._id),W=(0,vo.useCallback)((()=>{_([!0===u.weak?Tm(!0,["_weak"]):Im(["_weak"]),Im(["_strengthenOnPublish"])])}),[_,u.weak]),G=H?u.to.find((e=>e.name===H)):void 0,X="pressed"===D,Y="selected"===D,J=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:f,hasErrors:L,hasWarnings:Z}),Q=!K||"_ref"===S[0],ee=(0,vo.useMemo)((()=>(0,vo.forwardRef)((function(e,t){return(0,go.jsx)(Bs.nR,{...e,intent:"edit",params:{id:null==g?void 0:g._ref,type:null==G?void 0:G.name},target:"_blank",rel:"noopener noreferrer",ref:t})}))),[null==G?void 0:G.name,null==g?void 0:g._ref]),te=(0,vo.useCallback)((()=>{T(K&&Q?[]:["_ref"])}),[K,Q,T]),ne=(0,vo.useMemo)((()=>f?null:(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{paddingY:3,paddingX:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(j,"-menuButton"),menu:(0,go.jsxs)(Co.v2,{ref:M,children:[!f&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:m}),(0,go.jsx)(Co.sN,{text:K&&Q?"Cancel replace":"Replace",icon:K&&Q?Ds.Two:Ds.bnu,onClick:te}),(0,go.jsx)(Co.sN,{text:"Duplicate",icon:Ds.TIy,onClick:q}),(0,go.jsx)(sw,{onInsert:U,types:A})]}),!f&&!Q&&K&&(0,go.jsx)(Co.R,{}),!Q&&K&&(0,go.jsx)(Co.sN,{as:ee,"data-as":"a",text:"Open in new tab",icon:Ds.buG})]}),popover:bw})})),[f,j,m,K,Q,te,q,U,A,ee]),ie=(0,vo.useCallback)((()=>{_(!0===u.weak?Tm(!0,["_weak"]):Im(["_weak"]))}),[_,u]),re=(null==g?void 0:g._weak)?"weak":"strong",oe=!0===u.weak?"weak":"strong",se=K&&!V.isLoading&&(null==g?void 0:g._strengthenOnPublish),ae=!V.isLoading&&K&&re!==oe&&!se,le=(null==(a=V.result)?void 0:a.preview.draft)||(null==(l=V.result)?void 0:l.preview.published),ce=(0,go.jsxs)(go.Fragment,{children:[B&&$&&g._strengthenOnPublish&&(0,go.jsx)(nw,{padding:1,title:u.weak?"Finalize reference":"Convert to strong reference",status:"info","data-testid":"alert-reference-published",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:[(0,go.jsx)("strong",{children:null==(d=null==(c=V.result)?void 0:c.preview.published)?void 0:d.title})," is published and this reference should now be"," ",u.weak?(0,go.jsx)(go.Fragment,{children:"finalized"}):(0,go.jsx)(go.Fragment,{children:"converted to a strong reference"}),"."]}),(0,go.jsx)(Co.zx,{onClick:W,text:(0,go.jsx)(go.Fragment,{children:"Convert to strong reference"}),tone:"positive"})]})}),ae&&(0,go.jsx)(nw,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,go.jsx)("em",{children:re}),", but according to the current schema it should be"," ",(0,go.jsxs)("em",{children:[oe,"."]})]}),(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:u.weak?(0,go.jsxs)(go.Fragment,{children:['It will not be possible to delete the "',null==le?void 0:le.title,'"-document without first removing this reference.']}):(0,go.jsxs)(go.Fragment,{children:['This makes it possible to delete the "',null==le?void 0:le.title,'"-document without first deleting this reference, leav
1ing this field referencing a nonexisting document.']})}),(0,go.jsx)(Co.zx,{onClick:ie,text:(0,go.jsxs)(go.Fragment,{children:["Convert to ",oe," reference"]}),tone:"caution"})]})}),V.error&&(0,go.jsx)(nw,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["Error: ",V.error.message]}),(0,go.jsx)(Co.zx,{onClick:V.retry,text:(0,go.jsx)(go.Fragment,{children:"Retry"}),tone:"primary"})]})})]}),de=(0,go.jsx)(yw,{menuRef:M,containerRef:O,children:(0,go.jsx)(Wj,{dragHandle:E,presence:!Q&&y.length>0&&(0,go.jsx)(Db,{presence:y,maxAvatars:1}),validation:!Q&&b.length>0&&(0,go.jsx)(hj,{validation:b}),menu:ne,footer:Q?void 0:ce,tone:Q?void 0:J,focused:k,children:Q?(0,go.jsx)(Co.xu,{padding:1,ref:O,children:(0,go.jsx)(Ej,{title:u.title,description:u.description,__unstable_presence:y,validation:b,children:C})}):(0,go.jsxs)(xw,{as:R,tone:"inherit",radius:2,documentId:null==g?void 0:g._ref,documentType:null==G?void 0:G.name,disabled:N,paddingX:2,paddingY:1,__unstable_focusRing:!0,selected:Y,pressed:X,"data-selected":!!Y||void 0,"data-pressed":!!X||void 0,...P,children:[(0,go.jsx)(mw,{value:g,referenceInfo:V,renderPreview:I,type:u}),N&&(0,go.jsx)(Co.Zb,{style:jw,tone:"transparent",radius:2,as:Co.kC,justify:"center",children:(0,go.jsxs)(Co.kC,{align:"center",justify:"center",padding:3,children:[(0,go.jsx)(Co.xu,{marginX:3,children:(0,go.jsx)(Co.$j,{muted:!0})}),(0,go.jsx)(Co.xv,{children:"Resolving initial value\u2026"})]})})]})})});return(0,go.jsx)(nu,{path:h,isChanged:w,hasFocus:Boolean(k),children:(0,go.jsx)(Co.xu,{paddingX:1,children:de})})}function kw(e){return(0,mo.m$)(e.schemaType)}function Cw(e){return(0,mo.jB)(e.schemaType)}function _w(e){return function(e){return void 0!==e._key}(e)?e:{...e,_key:yb(12)}}function Sw(e,t){const n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function Tw(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;const t=[],n=[],i=new Po.x;return r;function r(i){return new zo.y((a=>{if(t.length>=e)return o(i).pipe((0,is.z)(r)).subscribe(a);const l=i.subscribe(a);return t.push(l),()=>{Sw(t,l),Sw(n,i),l.unsubscribe(),s()}}))}function o(e){return n.push(e),i.asObservable().pipe((0,cs.P)((t=>t===e)))}function s(){for(;n.length>0&&t.length<e;)i.next(n.shift())}}const Iw=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const n=Tw(t);return function(){return(0,Bo.D)(n(e(...arguments)))}}((function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=i.metadata,o=i.storeOriginalFilename,{label:s,title:a,description:l,creditLine:c,source:d}=i;return Mw(n).pipe((0,Wo.K)((()=>(0,So.of)(null))),(0,is.z)((n=>n?Fw(e,"sanity.".concat(t,"Asset"),n):(0,So.of)(null))),(0,is.z)((i=>i?(0,So.of)({type:"complete",id:i._id,asset:i}):e.observable.assets.upload(t,n,{tag:"asset.upload",extract:r,preserveFilename:o,label:s,title:a,description:l,creditLine:c,source:d}).pipe((0,Ho.U)((e=>"response"===e.type?{type:"complete",id:e.body.document._id,asset:e.body.document}:e))))))}),4);function Pw(e,t){return e.observePaths({_type:"reference",_ref:t},["originalFilename","url","metadata","label","title","description","creditLine","source","size"])}function Ew(e,t){return Pw(e,t)}function Aw(e,t){return Pw(e,t)}function Fw(e,t,n){return e.observable.fetch("*[_type == $documentType && sha1hash == $hash][0]",{documentType:t,hash:n},{tag:"asset.find-duplicate"})}function Mw(e){return window.crypto&&window.crypto.subtle&&window.FileReader?function(e){return new zo.y((t=>{const n=new FileReader;return n.onload=()=>{t.next(n.result),t.complete()},n.onerror=e=>{t.error(e)},n.readAsArrayBuffer(e),()=>{n.abort()}}))}(e).pipe((0,is.z)((e=>crypto.subtle.digest("SHA-1",e))),(0,Ho.U)(Ow)):(0,So.of)(null)}function Ow(e){return Array.prototype.map.call(new Uint8Array(e),(e=>"00".concat(e.toString(16)).slice(-2))).join("")}const Rw=/(invalid image format)|(No exif data)/i;function zw(e){return(0,Bo.D)(function(e,t){return new zo.y((n=>{const i=new window.FileReader;return i.onerror=e=>n.error(e),i.onload=()=>{n.next(i.result),n.complete()},i.readAsArrayBuffer(void 0===t?e:e.slice(0,t)),()=>i.abort()}))}(e,128e3)).pipe((0,Ho.U)((e=>dc()(e))),(0,Wo.K)((e=>(Rw.test(e.message)||console.warn("Exif read failed, continuing anyway: ".concat(e.message)),(0,So.of)({})))))}function Dw(e){return[5,6,7,8].indexOf(e)>-1}function Bw(e,t,n){const 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)}const Lw=[{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}],Zw=["top-left","top-right","bottom-right","bottom-left","left-top","right-top","right-bottom","left-bottom"];function Nw(e,t){const n=Lw[t-1],i=e.height/e.width;e.width=120/i,e.height=e.width*i;const r=document.createElement("canvas"),o=r.getContext("2d");if(Dw(t)?(r.height=e.width,r.width=e.height):(r.width=e.width,r.height=e.height),"flip-x"===n.op&&Bw(r,!0,!1),"flip-y"===n.op&&Bw(r,!1,!0),n.degrees&&(function(e,t){const 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)}(o,{degrees:n.degrees,x:r.width/2,y:r.height/2}),Dw(t))){const e=r.width-r.height;null==o||o.translate(e/2,-e/2)}return null==o||o.drawImage(e,0,0,e.width,e.height),r}function qw(e,t){return(n=window.URL.createObjectURL(e),new zo.y((e=>{const t=new window.Image;return t.onerror=()=>{e.error(new Error('Could not load image from url "'.concat(n,'". Image may be of an unsupported format')))},t.onload=()=>
1{e.next(t),e.complete()},t.src=n,()=>{}}))).pipe((0,is.z)((e=>function(e,t){return new zo.y((n=>{const i=Zw.indexOf(t)+1,r=Nw(e,i);n.next(r.toDataURL("image/jpeg",.1)),n.complete()}))}(e,t))));var n}const Uw="_upload";function Vw(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:"uploadProgress",patches:e}}const Kw=Vw([Im([Uw])]);function Hw(e){const t=(new Date).toISOString();return Vw([Tm({progress:2,createdAt:t,updatedAt:t,file:{name:e.name,type:e.type}},[Uw])])}function $w(e,t,n){const i=((e,t,n)=>Iw(e,"image",t,n))(e,t,n).pipe((0,Yo.h)((e=>"download"!==e.stage)),(0,Ho.U)((e=>({...e,progress:2+e.percent/100*98}))),(0,Ho.U)((e=>"complete"===e.type?Vw([Tm({_type:"reference",_ref:e.asset._id},["asset"]),Tm(100,[Uw,"progress"]),Tm((new Date).toISOString(),[Uw,"updatedAt"])]):Vw([Tm(e.percent,[Uw,"progress"]),Tm((new Date).toISOString(),[Uw,"updatedAt"])])))),r=zw(t).pipe((0,is.z)((e=>qw(t,e.orientation||"top-left"))),(0,Wo.K)((e=>(console.warn('Image preprocessing failed for "%s" with the error: %s',t.name,e.message),(0,So.of)(null)))),(0,Yo.h)(Boolean),(0,Ho.U)((e=>Vw([Tm(e,[Uw,"previewImage"])]))));return(0,To.z)((0,So.of)(Hw(t)),(0,Eo.T)(i,r),(0,So.of)(Kw))}function Ww(e,t,n){const i=((e,t,n)=>Iw(e,"file",t,n))(e,t,n).pipe((0,Ho.U)((e=>"complete"===e.type?Vw([Tm({_type:"reference",_ref:e.asset._id},["asset"]),Tm(100,[Uw,"progress"]),Tm((new Date).toISOString(),[Uw,"updated"])]):Vw([Tm(e.percent,[Uw,"progress"]),Tm((new Date).toISOString(),[Uw,"updated"])]))));return(0,To.z)((0,So.of)(Hw(t)),i,(0,So.of)(Kw))}const Gw=[{type:"image",accepts:"image/*",upload:(e,t,n,i)=>$w(e,t,i)},{type:"string",accepts:"text/*",upload:(e,t,n,i)=>Ww(e,t,i).pipe((0,Ho.U)((e=>({type:"uploadProgress",patches:[Tm(e)]}))))},{type:"file",accepts:"",upload:(e,t,n,i)=>Ww(e,t,i)}].map(((e,t)=>({...e,priority:t})));function Xw(e,t){if(!e||!t)return!0;const n=Array.isArray(t)?t:t.split(","),i=e.name||"",r=(e.type||"").toLowerCase(),o=r.replace(/\/.*$/,"");return n.some((e=>{const t=e.trim().toLowerCase();return"."===t.charAt(0)?i.toLowerCase().endsWith(t):t.endsWith("/*")?o===t.replace(/\/.*$/,""):r===t}))}function Yw(e,t){return Gw.find((n=>{var i;return Xh(n.type,e)&&Xw(t,n.accepts)&&Xw(t,(null==(i=e.options)?void 0:i.accept)||"")}))||null}const Jw=["_key","_type","_weak"];function Qw(e){return Object.keys(e).every((e=>Jw.includes(e)))}function ek(e,t,n){return(0,Bo.D)(e).pipe((0,is.z)((e=>{const i={_key:e._key};return(0,So.of)(((e,t)=>{const n=(0,vl.wq)(t);return e.of.find((e=>e.name===n))})(t,e)).pipe((0,is.z)((e=>e?(0,So.of)(e):Ro.E)),(0,is.z)((t=>Qw(e)&&n?(0,To.z)((0,So.of)({type:"patch",patches:[Tm(!0,[i,"_resolvingInitialValue"])]}),(0,Ao.P)((()=>n(t,e))).pipe((0,Yo.h)(wd),(0,Ho.U)((e=>{return{type:"patch",patches:(t=e,n=[i],Object.entries(t).map((e=>{let[t,i]=e;return Tm(i,[...n,t])})))};var t,n})),(0,Wo.K)((n=>(0,So.of)({type:"error",error:n,item:e,schemaType:t})))),(0,So.of)({type:"patch",patches:[Im([i,"_resolvingInitialValue"])]})):Ro.E)))})))}const tk="before",nk="after";function ik(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(((e,t)=>e.concat(t)),[])}const rk=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ok(e,t){const n=e.slice();if(0===t.path.length){if("setIfMissing"===t.type){if(!Array.isArray(t.value))throw new Error("Cannot set value of an array to a non-array");return void 0===e?t.value:e}if("set"===t.type){if(!Array.isArray(t.value))throw new Error("Cannot set value of an array to a non-array");return t.value}if("unset"===t.type)return;if("move"===t.type){if(!t.value||!rk(t.value,"from")||!rk(t.value,"to"))throw new Error('Invalid value of \'move\' patch. Expected a value with "from" and "to" indexes, instead got: '.concat(JSON.stringify(t.value)));return function(e,t,n){const i=e.slice(),r=i[t];return i.splice(t,1),i.splice(n,0,r),i}(n,t.value.from,t.value.to)}throw new Error("Invalid array operation: ".concat(t.type))}const[i,...r]=t.path,o=function(e,t){if("number"===typeof t)return t;const n=td()(e,t);return-1!==n&&n}(e,i);if(!1===o)return n;if(0===r.length){if("insert"===t.type){const{position:n,items:i}=t;return function(e,t,n){if(t!==tk&&t!==nk)throw new Error('Invalid position "'.concat(t,'", must be either ').
1concat(tk," or ").concat(nk));for(var i=arguments.length,r=new Array(i>3?i-3:0),o=3;o<i;o++)r[o-3]=arguments[o];const s=ik(...r);if(0===e.length)return s;const a=e.length,l=Math.abs((a+n)%a)%a,c="after"===t?l+1:l,d=e.slice();return d.splice(c,0,...ik(s)),d}(e,n,o,i)}if("unset"===t.type){if("number"!==typeof o)throw new Error('Expected array index to be a number, instead got "'.concat(o,'"'));return n.splice(o,1),n}}return n[o]=hk(n[o],{...t,path:r}),n}const sk={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},ak=Object.keys(sk);const lk=new gl.diff_match_patch,ck={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},diffMatchPatch:(e,t)=>lk.patch_apply(lk.patch_fromText(t),e)[0]},dk=Object.keys(ck);function uk(e,t){return t.reduce(hk,e)}function pk(e,t){return Array.isArray(e)?ok(e,t):Xs()(e)?function(e,t){if(!dk.includes(t.type))throw new 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 new 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 ck[t.type](e,t.value)}(e,t):Qc()(e)?function(e,t){const n=id()(e);if(0===t.path.length){if("set"===t.type){if(!Qc()(t.value))throw new Error("Cannot set value of an object to a non-object");return t.value}if("unset"===t.type)return;if("setIfMissing"===t.type)return void 0===e?t.value:e;throw new Error("Invalid object operation: ".concat(t.type))}const[i,...r]=t.path;if("string"!==typeof i)throw new Error("Expected field name to be a string, instad got: ".concat(i));return 0===r.length&&"unset"===t.type?hl()(n,i):(n[i]=hk(n[i],{...t,path:r}),n)}(e,t):function(e,t){if(!ak.includes(t.type))throw new Error('Received patch of unsupported type "'.concat(t.type,'" for primitives. This is most likely a bug.'));if(t.path.length>0)throw new 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 sk[t.type](e,t.value)}(e,t)}function hk(e,t){return pk(e,t)}function fk(e){const t=bd(e),{value:n}=Lm();return Pg(n,t)}function mk(){const e=fk(["_id"]);if("string"===typeof e)return Td(e)}function gk(e){const{onPathBlur:t,onPathFocus:n,onChange:i,onSetPathCollapsed:r,onSetFieldSetCollapsed:o,onPathOpen:s,onFieldGroupSelect:a}=Wm(),{member:l,renderAnnotation:c,renderBlock:d,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=Lm().__internal,x=mk(),[v,y]=(0,vo.useState)([]),b=(0,vo.useRef)(),j=(0,vo.useRef)({});zm(l.field.focused,((e,t)=>{var n;!e&&t&&(null==(n=b.current)||n.focus())}));const w=(0,vo.useCallback)((e=>{e.currentTarget===e.target&&e.currentTarget===b.current&&n(l.field.path)}),[l.field.path,n]),k=(0,vo.useCallback)((e=>{e.currentTarget===e.target&&e.currentTarget===b.current&&t(l.field.path)}),[l.field.path,t]),C=(0,vo.useRef)(l.field.value);(0,vo.useEffect)((()=>{C.current=l.field.value}),[l.field.value]);const _=(0,vo.useCallback)((e=>{const t=Am.from(e).patches,n=t.some((e=>"unset"===e.type&&1===e.path.length));n&&(C.current=uk(C.current||[],t),Array.isArray(C.current)&&!C.current.length)?i(Am.from(Im([l.name]))):i(Am.from(e).prepend(_m([])).prefixAll(l.name))}),[i,l.name,C]),S=qq(),T=(0,Co.pm)(),I=(0,vo.useCallback)((()=>{r(l.field.path,!0)}),[r,l.field.path]),P=(0,vo.useCallback)((()=>{r(l.field.path,!1)}),[r,l.field.path]),E=(0,vo.useCallback)((e=>{r(l.field.path.concat({_key:e}),!0)}),[r,l.field.path]),A=(0,vo.useCallback)((e=>{r(l.field.path.concat({_key:e}),!1)}),[r,l.field.path]),F=(0,vo.useCallback)((e=>{s(e),r(e,!1)}),[s,r]),M=(0,vo.useCallback)((()=>{s(l.field.path),r(l.field.path,!0)}),[s,l.field.path,r]),O=(0,vo.useCallback)((e=>{if(0===e.items.length)throw new Error("Insert event should include at least one item");const t=e.items.map((e=>_w(e)));_(Am.from([Sm(t,e.position,[e.referenceItem])]));const i=t[0]._key,r=[...l.field.path,{_key:i}];n(r);const o=!1!==e.open;e.skipInitialValue?o&&F(r):ek(t,l.field.schemaType,S).pipe((0,Ko.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:()=>{o&&F(r)}})}),[_,F,l.field.path,l.field.schemaType,n,S,T]),R=(0,vo.useCallback)((e=>
1{const t=l.field.value,n=null==t?void 0:t[e.fromIndex],i=null==t?void 0:t[e.toIndex];e.fromIndex!==e.toIndex&&((null==n?void 0:n._key)&&(null==i?void 0:i._key)?_([Im([{_key:n._key}]),Sm([n],e.fromIndex>e.toIndex?"before":"after",[{_key:i._key}])]):console.error("Neither the item you are moving nor the item you are moving to have a key. Cannot continue."))}),[_,l.field.value]),z=(0,vo.useCallback)((e=>{_([_m([]),Sm([_w(e)],"before",[0])])}),[_]),D=(0,vo.useCallback)((e=>{_([_m([]),Sm([_w(e)],"after",[-1])])}),[_]),B=(0,vo.useCallback)((e=>{j.current[e]&&(j.current[e].unsubscribe(),delete j.current[e]),_([Im([{_key:e}])])}),[_]),L=(0,vo.useCallback)((e=>{n(l.field.path.concat(e))}),[l.field.path,n]),Z=(0,vo.useMemo)((()=>({onBlur:k,onFocus:w,id:l.field.id,ref:b})),[k,w,l.field.id]),N=WZ(qh),q=Lm(),U=q.__internal.image.directUploads,V=q.__internal.file.directUploads,K=(0,vo.useCallback)(((e,t)=>Xh("image",e)&&!U||Xh("file",e)&&!V?null:Yw(e,t)),[V,U]),H=(0,vo.useCallback)((e=>{let{file:t,schemaType:n,uploader:i}=e;const r=rw(n),o=r._key;O({items:[r],position:"after",referenceItem:-1,open:!1});const s=i.upload(N,t,n).pipe((0,Ho.U)((e=>Am.from(e.patches||[]).prefixAll({_key:o}))),(0,Ko.b)((e=>_(e.patches))));j.current={...j.current,[o]:s.subscribe()}}),[N,_,O]),$=(0,vo.useMemo)((()=>({level:l.field.level,members:l.field.members,value:l.field.value,readOnly:l.field.readOnly,schemaType:l.field.schemaType,changed:l.field.changed,id:l.field.id,onItemExpand:A,onItemCollapse:E,onItemClose:M,onItemOpen:F,focusPath:l.field.focusPath,focused:l.field.focused,path:l.field.path,onChange:_,onInsert:O,onItemMove:R,onItemRemove:B,onItemAppend:D,onItemPrepend:z,onPathFocus:L,resolveInitialValue:S,onUpload:H,resolveUploader:K,validation:l.field.validation,presence:l.field.presence,renderAnnotation:c,renderBlock:d,renderInlineBlock:p,renderInput:h,renderField:u,renderItem:f,renderPreview:m,elementProps:Z})),[l.field.level,l.field.members,l.field.value,l.field.readOnly,l.field.schemaType,l.field.changed,l.field.id,l.field.focusPath,l.field.focused,l.field.path,l.field.validation,l.field.presence,A,E,M,F,_,O,R,B,D,z,L,S,H,K,c,d,p,h,u,f,m,Z]),W=(0,vo.useMemo)((()=>h($)),[$,h]),G=(0,vo.useMemo)((()=>({actions:v.length>0?(0,go.jsx)(pg,{focused:l.field.focused,nodes:v}):void 0,name:l.name,index:l.index,level:l.field.level,value:l.field.value,title:l.field.schemaType.title,description:l.field.schemaType.description,collapsible:l.collapsible,collapsed:l.collapsed,changed:l.field.changed,onCollapse:I,onExpand:P,schemaType:l.field.schemaType,inputId:l.field.id,path:l.field.path,presence:l.field.presence,validation:l.field.validation,children:W,inputProps:$})),[v,l.name,l.index,l.field.focused,l.field.level,l.field.value,l.field.schemaType,l.field.id,l.field.path,l.field.presence,l.field.changed,l.field.validation,l.collapsible,l.collapsed,I,P,W,$]);return(0,go.jsxs)($m,{onFieldGroupSelect:a,onChange:_,onSetFieldSetCollapsed:o,onSetPathCollapsed:r,onPathOpen:s,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,go.jsx)(xg,{actions:g,documentId:x,documentType:l.field.schemaType.name,onActions:y,path:l.field.path,schemaType:l.field.schemaType}),(0,go.jsx)(ab,{actions:v,path:l.field.path,children:(0,vo.useMemo)((()=>u(G)),[G,u])})]})}function xk(e,t,n){return(0,mo.J1)(e)&&"string"===typeof n&&Number(n)===t?n:String(null!=t?t:"")}function vk(e){const{member:t,renderInput:n,renderField:i}=e,{field:{actions:r}}=Lm().__internal,o=mk(),[s,a]=(0,vo.useState)([]),l=(0,vo.useRef)(),[c,d]=(0,vo.useState)(),{onPathBlur:u,onPathFocus:p,onChange:h}=Wm();(0,vo.useEffect)((()=>{var e;t.field.focused&&(null==(e=l.current)||e.focus())}),[t.field.focused]);const f=(0,vo.useCallback)((()=>{u(t.field.path)}),[t.field.path,u]),m=(0,vo.useCallback)((()=>{p(t.field.path)}),[t.field.path,p]),g=(0,vo.useCallback)((e=>{h(Am.from(e).prefixAll(t.name))}),[h,t.name]),x=(0,vo.useCallback)((e=>{let n=e.currentTarget.value;if((0,mo.J1)(t.field.schemaType)){if(n=e.currentTarget.valueAsNumber,n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER)return}else(0,mo.EG)(t.field.schemaType)&&(n=e.currentTarget.checked);const i=""===n||"number"===typeof n&&isNaN(n);
1(0,mo.J1)(t.field.schemaType)&&d(i?void 0:e.currentTarget.value),h(Am.from(i?Im():Tm(n)).prefixAll(t.name))}),[t.name,t.field.schemaType,h]),v=(0,vo.useMemo)((()=>t.field.validation.filter((e=>"error"===e.level)).map((e=>e.message)).join("\n")),[t.field.validation])||void 0,y=(0,vo.useMemo)((()=>({onBlur:f,onFocus:m,id:t.field.id,ref:l,onChange:x,value:xk(t.field.schemaType,t.field.value,c),readOnly:Boolean(t.field.readOnly),placeholder:t.field.schemaType.placeholder})),[f,m,x,t.field.id,t.field.readOnly,t.field.schemaType,t.field.value,c]),b=(0,vo.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:y})),[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,y]),j=(0,vo.useMemo)((()=>n(b)),[b,n]),w=(0,vo.useMemo)((()=>({actions:s.length>0?(0,go.jsx)(pg,{focused:t.field.focused,nodes:s}):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:b})),[s,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,b]);return(0,go.jsxs)(go.Fragment,{children:[o&&r.length>0&&(0,go.jsx)(xg,{actions:r,documentId:o,documentType:t.field.schemaType.name,onActions:a,path:t.field.path,schemaType:t.field.schemaType}),(0,go.jsx)(ab,{actions:s,path:t.field.path,children:i(w)})]})}const yk=function(e){const{onPathBlur:t,onPathFocus:n,onChange:i,onPathOpen:r,onSetPathCollapsed:o,onSetFieldSetCollapsed:s,onFieldGroupSelect:a}=Wm(),{member:l,renderAnnotation:c,renderBlock:d,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=Lm().__internal,x=mk(),[v,y]=(0,vo.useState)([]),b=(0,vo.useRef)(),j=(0,vo.useRef)(l.field.value);(0,vo.useEffect)((()=>{j.current=l.field.value}),[l.field.value]),zm(l.field.focused,((e,t)=>{var n;!e&&t&&(null==(n=b.current)||n.focus())}));const w=(0,vo.useCallback)((()=>{t(l.field.path)}),[l.field.path,t]),k=(0,vo.useCallback)((()=>{n(l.field.path)}),[l.field.path,n]),C=(0,vo.useCallback)((e=>{n(l.field.path.concat(e))}),[l.field.path,n]),_=(0,vo.useCallback)((e=>{if(!(0===l.field.path.length)){const t=Am.from(e).patches;if(j.current=uk(j.current||{},t),j.current&&(0,vl.Sm)(j.current))return void i(Am.from(Im([l.name])))}i(Am.from(e).prepend(_m(iw(l.field.schemaType))).prefixAll(l.name))}),[i,l,j]),S=(0,vo.useCallback)((()=>{o(l.field.path,!0)}),[o,l.field.path]),T=(0,vo.useCallback)((()=>{o(l.field.path,!1)}),[o,l.field.path]),I=(0,vo.useCallback)((e=>{o(l.field.path.concat(e),!0)}),[o,l.field.path]),P=(0,vo.useCallback)((e=>{o(l.field.path.concat(e),!1)}),[o,l.field.path]),E=(0,vo.useCallback)((e=>{r(l.field.path.concat(e))}),[r,l.field.path]),A=(0,vo.useCallback)((()=>{r(l.field.path)}),[r,l.field.path]),F=(0,vo.useCallback)((e=>{s(l.field.path.concat(e),!1)}),[s,l.field.path]),M=(0,vo.useCallback)((e=>{s(l.field.path.concat(e),!0)}),[s,l.field.path]),O=(0,vo.useCallback)((()=>{r(l.field.path)}),[r,l.field.path]),R=(0,vo.useCallback)((()=>{r(l.field.path.slice(0,-1))}),[r,l.field.path]),z=(0,vo.useCallback)((e=>{a(l.field.path,e)}),[a,l.field.path]),D=(0,vo.useMemo)((()=>({onBlur:w,onFocus:k,id:l.field.id,ref:b})),[w,k,l.field.id]),B=(0,vo.useMemo)((()=>({elementProps:D,level:l.field.level,members:l.field.members,value:l.field.value,readOnly:l.field.readOnly,validation:l.field.validation,presence:l.field.presence,schemaType:l.field.schemaType,changed:l.field.changed,id:l.field.id,onFieldGroupSelect:z,onFieldOpen:E,onFieldClose:A,onFieldCollapse:I,onFieldExpand:P,onFieldSetExpand:F,onFieldSetCollapse:M,onPathF
1ocus:C,path:l.field.path,focusPath:l.field.focusPath,focused:l.field.focused,groups:l.field.groups,onChange:_,renderAnnotation:c,renderBlock:d,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m})),[D,l.field.level,l.field.members,l.field.value,l.field.readOnly,l.field.validation,l.field.presence,l.field.schemaType,l.field.changed,l.field.id,l.field.path,l.field.focusPath,l.field.focused,l.field.groups,z,E,A,I,P,F,M,C,_,c,d,u,p,h,f,m]),L=(0,vo.useMemo)((()=>h(B)),[B,h]),Z=(0,vo.useMemo)((()=>({actions:v.length>0?(0,go.jsx)(pg,{focused:l.field.focused,nodes:v}):void 0,name:l.name,index:l.index,level:l.field.level,value:l.field.value,validation:l.field.validation,presence:l.field.presence,title:l.field.schemaType.title,description:l.field.schemaType.description,collapsible:l.collapsible,collapsed:l.collapsed,onCollapse:S,onExpand:T,open:l.open,changed:l.field.changed,onOpen:O,onClose:R,schemaType:l.field.schemaType,inputId:l.field.id,path:l.field.path,children:L,inputProps:B})),[v,l.field.focused,l.field.level,l.field.value,l.field.validation,l.field.presence,l.field.schemaType,l.field.changed,l.field.id,l.field.path,l.name,l.index,l.collapsible,l.collapsed,l.open,S,T,O,R,L,B]);return(0,go.jsxs)($m,{onFieldGroupSelect:a,onChange:_,onSetFieldSetCollapsed:s,onPathOpen:r,onSetPathCollapsed:o,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,go.jsx)(xg,{actions:g,documentId:x,documentType:l.field.schemaType.name,onActions:y,path:l.field.path,schemaType:l.field.schemaType}),(0,go.jsx)(ab,{actions:v,path:l.field.path,children:(0,vo.useMemo)((()=>u(Z)),[Z,u])})]})};function bk(e){return{priority:0,accepts:"text/*",type:"string",upload:(t,n)=>function(e,t){return new zo.y((n=>{const i=new FileReader;return i.onerror=e=>n.error(e),i.onload=()=>{n.next(i.result),n.complete()},i.readAsText(e,t),()=>{i.abort()}}))}(n,"utf-8").pipe((0,Ho.U)((t=>null==t?void 0:t.split(/[\n\r]/).map((t=>function(e,t){let n=!1,i=!1,r=!1;return t.forEach((e=>{(0,mo.EG)(e)&&(n=!0),(0,mo.aj)(e)&&(r=!0),(0,mo.J1)(e)&&(i=!0)})),!n||"true"!==e&&"false"!==e?i&&/^\d+$/.test(e)?Number(e):r?e:void 0:"true"===e}(t,e))).filter((e=>void 0!==e)))),(0,Yo.h)((e=>Array.isArray(e))),(0,Ho.U)((e=>({type:"uploadProgress",patches:[Sm(e,"after",[-1])]}))))}}function jk(e){const{onPathBlur:t,onPathFocus:n,onChange:i,onPathOpen:r,onSetPathCollapsed:o,onSetFieldSetCollapsed:s,onFieldGroupSelect:a}=Wm(),{member:l,renderAnnotation:c,renderBlock:d,renderField:u,renderInlineBlock:p,renderInput:h,renderItem:f,renderPreview:m}=e,{field:{actions:g}}=Lm().__internal,x=mk(),[v,y]=(0,vo.useState)([]),b=(0,vo.useRef)(),j=(0,vo.useRef)(),w=WZ(qh);zm(l.field.focused,((e,t)=>{var n;!e&&t&&(null==(n=b.current)||n.focus())}));const k=(0,vo.useCallback)((e=>{e.currentTarget===e.target&&e.currentTarget===b.current&&n(l.field.path)}),[l.field.path,n]),C=(0,vo.useCallback)((e=>{e.currentTarget===e.target&&e.currentTarget===b.current&&t(l.field.path)}),[l.field.path,t]),_=(0,vo.useCallback)((e=>{const t=Am.from(e).patches,n=t.some((e=>"unset"===e.type&&1===e.path.length));if(n){const e=uk(l.field.value||[],t);if(Array.isArray(e)&&!e.length)return void i(Am.from(Im([l.name])))}i(Am.from(e).prepend(_m([])).prefixAll(l.name))}),[i,l.name,l.field.value]),S=(0,vo.useCallback)((e=>{o(l.field.path,e)}),[o,l.field.path]),T=(0,vo.useCallback)((()=>{o(l.field.path,!0)}),[o,l.field.path]),I=(0,vo.useCallback)((()=>{o(l.field.path,!1)}),[o,l.field.path]),P=(0,vo.useCallback)((e=>{_(0===e.length?Im():Tm(e))}),[_]),E=(0,vo.useCallback)((e=>{const{value:t=[]}=l.field;e.fromIndex!==e.toIndex&&P(function(e,t,n){const i=e.slice(),r=i[t];return i.splice(t,1),i.splice(n,0,r),i}(t,e.fromIndex,e.toIndex))}),[l.field,P]),A=(0,vo.useCallback)((e=>{const{value:t=[]}=l.field;P(t.concat(e))}),[l.field,P]),F=(0,vo.useCallback)((e=>{const{value:t=[]}=l.field;P([e].concat(t||[]))}),[l.field,P]),M=(0,vo.useCallback)((e=>{const{value:t=[]}=l.field,n=e.referenceIndex+("before"===e.position?-1:0);P(function(e,t,n){const i=t.slice();return i.splice(e+1,0,...n),i}(n,t,e.items))}),[l.field,P]),O=(0,vo.useCallback)((e=>{_(Im([e]))}),[_]),R=(0,vo.useCallback)((e=>{n(l.field.path.concat([e]))}),[l.field.path,n]),z=(0,vo.useMemo)((()=>({onBlur:C,onFocus:k,id:l.field.id,ref:b})),[C,k,l.field.id]),D=(0,vo.useMemo)((()=>bk(l.field.schemaType.of)),[l.field.schemaType.of]),B=(0,vo.useCallback)(((e,t)=>Xw(t,"text/*")?D:null),[D]),L=(0,vo.useCallback)((e=>{let{file:t,schemaType:n,uploader:i}=e;const r=i.upload(w,t,n).pipe((0,Ho.U)((e=>Am.from(e.patches||[]))),(0,Ko.b)((e=>_(e.patches))));j.current&&j.current.unsubscribe(),j.current=r.subscribe()}),[w,_]),Z=(0,vo.useMemo)((()=>({level:l.field.level,members:l.field.members,value:l.field.value,readOnly:l.f
1ield.readOnly,onSetCollapsed:S,schemaType:l.field.schemaType,changed:l.field.changed,id:l.field.id,elementProps:z,path:l.field.path,focusPath:l.field.focusPath,focused:l.field.focused,onChange:_,onInsert:M,onMoveItem:E,onItemRemove:O,onItemAppend:A,onItemPrepend:F,validation:l.field.validation,presence:l.field.presence,resolveUploader:B,onUpload:L,renderAnnotation:c,renderBlock:d,renderInlineBlock:p,renderInput:h,renderItem:f,onIndexFocus:R,renderPreview:m})),[l.field.level,l.field.members,l.field.value,l.field.readOnly,l.field.schemaType,l.field.changed,l.field.id,l.field.path,l.field.focusPath,l.field.focused,l.field.validation,l.field.presence,S,z,_,M,E,O,A,F,B,L,c,d,p,h,f,R,m]),N=(0,vo.useMemo)((()=>h(Z)),[Z,h]),q=(0,vo.useMemo)((()=>({actions:v.length>0?(0,go.jsx)(pg,{focused:l.field.focused,nodes:v}):void 0,name:l.name,index:l.index,level:l.field.level,value:l.field.value,title:l.field.schemaType.title,description:l.field.schemaType.description,collapsible:l.collapsible,collapsed:l.collapsed,onExpand:I,changed:l.field.changed,onCollapse:T,schemaType:l.field.schemaType,inputId:l.field.id,path:l.field.path,presence:l.field.presence,validation:l.field.validation,children:N,inputProps:Z})),[v,l.field.focused,l.field.level,l.field.value,l.field.schemaType,l.field.changed,l.field.id,l.field.path,l.field.presence,l.field.validation,l.name,l.index,l.collapsible,l.collapsed,I,T,N,Z]);return(0,go.jsxs)($m,{onFieldGroupSelect:a,onChange:_,onPathOpen:r,onSetFieldSetCollapsed:s,onSetPathCollapsed:o,onPathBlur:t,onPathFocus:n,children:[x&&g.length>0&&(0,go.jsx)(xg,{actions:g,documentId:x,documentType:l.field.schemaType.name,onActions:y,path:l.field.path,schemaType:l.field.schemaType}),(0,go.jsx)(ab,{actions:v,path:l.field.path,children:(0,vo.useMemo)((()=>u(q)),[q,u])})]})}function wk(e){return(0,mo.m$)(e.field.schemaType)}function kk(e){return(0,mo.jB)(e.field.schemaType)&&e.field.schemaType.of.every((e=>(0,mo.m$)(e)))}const Ck=(0,vo.memo)((function(e){const{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:o,renderInput:s,renderItem:a,renderPreview:l}=e;return wk(t)?(0,go.jsx)(yk,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:o,renderInput:s,renderItem:a,renderPreview:l}):function(e){return(0,mo.jB)(e.field.schemaType)&&e.field.schemaType.of.every((e=>(0,mo.jp)(e)))}(t)?(0,go.jsx)(jk,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInput:s,renderInlineBlock:o,renderItem:a,renderPreview:l}):kk(t)?(0,go.jsx)(gk,{member:t,renderAnnotation:n,renderBlock:i,renderField:r,renderInlineBlock:o,renderInput:s,renderItem:a,renderPreview:l}):(0,go.jsx)(vk,{member:t,renderField:r,renderInput:s})})),_k=["yes","true","1"],Sk=["false","no","false","0","null"],Tk=_k.concat(Sk),Ik=()=>!0;function Pk(e){const t=new Date(e.getTime()+60*e.getTimezoneOffset()*1e3),n=e.getTimezoneOffset()/60,i=e.getHours();return t.setHours(i-n),t}function Ek(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}return null}const Ak={string:{number:{test:Number,convert:Number},boolean:{test:e=>Tk.includes(e.toLowerCase()),convert:e=>_k.includes(e.toLowerCase())||!Sk.includes(e.toLowerCase())},richDate:{test:e=>(0,ba.Z)(e),convert:e=>({_type:"richDate",local:Pk(new Date(e)).toJSON(),utc:new Date(e).toJSON(),timezone:Ek(),offset:(new Date).getTimezoneOffset()})}},date:{richDate:{test:(Mk="date",e=>(e&&e._type)===Mk),convert:e=>Object.assign({},e,{_type:"richDate"})}},richDate:{datetime:{test:(Fk="utc",e=>e&&e[Fk]),convert:e=>e.utc}},number:{string:{test:Ik,convert:String},boolean:{test:Ik,convert:Number}},boolean:{string:{test:Ik,convert:e=>e?"Yes":"No"},number:{test:Ik,convert:Number}}};var Fk,Mk;function Ok(e){let{value:t,targetType:n,onChange:i}=e;const r=(0,vo.useMemo)((()=>({...t,_type:n})),[n,t]),o=(0,vo.useCallback)((()=>i(Am.from(_m(n,["_type"])),r)),[r,i,n]);return(0,go.jsx)(Co.zx,{onClick:o,text:(0,go.jsxs)(go.Fragment,{children:["Convert to ",(0,go.jsx)("code",{children:n})]})})}function Rk(e){let{value:t,onChange:n,validTypes:i}=e;const r=(0,vo.useMemo)((()=>({...t,_type:i[0]})),[i,t]),o=(0,vo.useCallback)((()=>n(Am.from(Im()),r)),[r,n]);return(0,go.jsx)(Co.zx,{onClick:o,tone:"critical",text:"Unset value"})}function zk(e){let{validTypes:t,value:n,onChange:i}=e;const r=nN(),o=1===t.length,s=r.has(t[0]);return(0,go.jsx)(Om,{status:"warning",title:(0,go.jsxs)(go.Fragment,{children:["Property value missing ",(0,go.jsx)("code",{children:"_type"})]}),children:(0,go.jsx)(Qj,{open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["Encountered an object value without a ",(0,go.jsx)("code",{children:"_type"})," property."]}),o&&!s&&(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["Either remove the ",(0,go.jsx)("code",{children:"name"})," property of the object declaration, or set"," ",(0,go.jsx)("code",{children:"_type"})," property on items."]}),!o&&(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:"The following types are valid here according to schema:"}),!o&&(0,go.jsx)(Co.Kq,{as:"ul",space:2,children:t.map((e=>(0,go.jsx)(Co.xv,{as:"li",muted:!0,size:1,children:(0,go.jsx)("code",{children:e})},e)))}),(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsxs)(Co.xv,{as:"h4",weight:"semibold",size:1,children:["Current value (",(0,go.jsx)("code",{children:"object"}),"):"]}),(0,go.jsx)(Co.Zb,{border:!0,overflow:"auto",padding:2,radius:2,tone:"inherit",children:(0,go.jsx)(Co.EK,{language:"json",children:JSON.stringify(n,null,2)})})]}),(0,go.jsxs)(Co.rj,{columns:[1,2,2],gap:1,children:[o&&(0,go.jsx)(Ok,{onChange:i,targetType:t[0],value:n}),(0,go.jsx)(Rk,{onChange:i,validTypes:t,value:n})]})]})})})}function Dk(e,t,n){return t in Ak?Object.keys(Ak[t]).filter((e=>n.includes(e))).map((e=>({from:t,to:e,...Ak[t][e]}))).filter((t=>t.test(e))):[]}const Bk=(0,vo.forwardRef)(((e,t)=>{const{value:n,actualType:i,validTypes:r,onChange:o}=e;(0,vo.useImperativeHandle)(t,(()=>({focus:()=>{}})));const s=(0,vo.useCallback)((()=>{o(Am.from(Im()))}),[o]),a=(0,vo.useCallback)((e=>{o(Am.from(Tm(e)))}),[o]),l=(0,vo.useMemo)((()=>Dk(n,i,r)),[n,i,r]);if(sc()(n)&&!("_type"in n))return(0,go.jsx)(zk,{value:n,validTypes:r,onChange:o});const c=(0,go.jsx)(Co.Kq,{padding:2,children:(0,go.jsx)(Co.zx,{onClick:s,tone:"critical",text:"Reset value"})});return(0,go.jsxs)(Om,{status:"error",suffix:c,title:(0,go.jsx)(go.Fragment,{children:"Invalid property value"}),children:[(0,go.jsx)(Co.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,go.jsx)(Qj,{marginTop:4,open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:(0,go.jsxs)(Co.Kq,{space:3,children:[1===r.length&&(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["The value of this property must be of type ",(0,go.jsx)("code",{children:r[0]})," according to the schema."]}),1===r.length&&(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:"Mismatching value types typically occur when the schema has recently been changed."}),1!==r.length&&(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:"Only the following types are valid here according to schema:"}),1!==r.length&&(0,go.jsx)(Co.Kq,{as:"ul",space:2,children:r.map((e=>(0,go.jsx)(Co.xv,{as:"li",children:(0,go.jsx)("code",{children:e})},e)))}
1),(0,go.jsxs)(Co.Kq,{marginTop:2,space:2,children:[(0,go.jsxs)(Co.xv,{size:1,weight:"semibold",children:["The current value (",(0,go.jsx)("code",{children:i}),")"]}),(0,go.jsx)(Co.Zb,{border:!0,padding:2,radius:2,tone:"inherit",children:(0,go.jsx)(Co.EK,{language:"json",size:1,children:JSON.stringify(n,null,2)})})]}),l.length>0&&(0,go.jsx)(Co.Kq,{space:1,children:l.map((e=>(0,go.jsx)(Lk,{converter:e,onConvert:a,value:n},"".concat(e.from,"-").concat(e.to))))})]})})]})}));function Lk(e){let{converter:t,onConvert:n,value:i}=e;const r=(0,vo.useCallback)((()=>n(t.convert(i))),[t,n,i]);return(0,go.jsx)(Co.zx,{onClick:r,text:(0,go.jsxs)(go.Fragment,{children:["Convert to ",(0,go.jsx)("code",{children:t.to})]})})}function Zk(e){const{error:t,onChange:n}=e,i=(0,vo.useCallback)((()=>{n(Am.from((t.value||[]).map(((e,t)=>_m((0,vl.E2)(),[t,"_key"])))))}),[t.value,n]);return(0,go.jsx)(bj,{title:t.schemaType.title,description:t.schemaType.description,children:(0,go.jsxs)(Om,{status:"warning",suffix:(0,go.jsx)(Co.Kq,{padding:2,children:(0,go.jsx)(Co.zx,{onClick:i,text:"Add missing keys",tone:"caution"})}),title:(0,go.jsx)(go.Fragment,{children:"Missing keys"}),children:[(0,go.jsx)(Co.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,go.jsx)(Qj,{marginTop:4,open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This usually happens when items are created using an API client, and the"," ",(0,go.jsx)("code",{children:"_key"})," property has not been included."]}),(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["The value of the ",(0,go.jsx)("code",{children:"_key"})," property must be a unique string."]})]})})]})})}function Nk(e){const{error:t,onChange:n}=e,i=(0,vo.useCallback)((()=>{n(Am.from((t.duplicates||[]).map((e=>{let[t,n]=e;return Tm("".concat(n,"_deduped_").concat(t),[t,"_key"])}))))}),[t.duplicates,n]);return(0,go.jsx)(bj,{title:t.schemaType.title,description:t.schemaType.description,children:(0,go.jsxs)(Om,{status:"warning",suffix:(0,go.jsx)(Co.Kq,{padding:2,children:(0,go.jsx)(Co.zx,{onClick:i,text:"Generate unique keys",tone:"caution"})}),title:(0,go.jsx)(go.Fragment,{children:"Non-unique keys"}),children:[(0,go.jsx)(Co.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,go.jsx)(Qj,{marginTop:4,open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This usually happens when items are created using an API client, and the"," ",(0,go.jsx)("code",{children:"_key"})," property of each elements has been generated non-uniquely."]}),(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["The value of the ",(0,go.jsx)("code",{children:"_key"})," property must be a unique string."]})]})})]})})}function qk(e){const{error:t,onChange:n}=e;return(0,go.jsx)(bj,{title:t.schemaType.title,description:t.schemaType.description,children:(0,go.jsxs)(Om,{status:"error",suffix:(0,go.jsx)(Co.Kq,{padding:2,children:(0,go.jsx)(Co.zx,{onClick:()=>{const e=(t.value||[]).flatMap(((e,t)=>sc()(e)?[]:[t])).reverse().map((e=>Im([e])));n(Am.from(e))},text:"Remove non-object values",tone:"critical"})}),title:(0,go.jsx)(go.Fragment,{children:"Invalid list values"}),children:[(0,go.jsx)(Co.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,go.jsx)(Qj,{marginTop:4,open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:(0,go.jsx)(Co.Kq,{space:3,children:(0,go.jsx)(Co.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 Uk(e){const{member:t}=e,{onChange:n}=Wm(),i=(0,vo.useCallback)((e=>{n(Am.from(e).prefixAll(t.fieldName))}),[n,t.fieldName]);return"INCOMPATIBLE_TYPE"===t.error.type?(0,go.jsx)(Bk,{value:t.error.value,onChange:i,actualType:t.error.resolvedValueType,validTypes:[t.error.expectedSchemaType.n
1ame]}):"MISSING_KEYS"===t.error.type?(0,go.jsx)(Zk,{error:t.error,onChange:i}):"DUPLICATE_KEYS"===t.error.type?(0,go.jsx)(Nk,{error:t.error,onChange:i}):"MIXED_ARRAY"===t.error.type?(0,go.jsx)(qk,{onChange:i,error:t.error}):(0,go.jsxs)(Co.xu,{children:["Unexpected error: ",e.member.error.type]})}Bk.displayName="InvalidValueInput";const Vk=(0,vo.memo)((function(e){var t;const{member:n,renderAnnotation:i,renderBlock:r,renderField:o,renderInlineBlock:s,renderInput:a,renderItem:l,renderPreview:c}=e,{onSetFieldSetCollapsed:d}=Wm(),u=(0,vo.useCallback)((()=>{d(n.fieldSet.path,!0)}),[n.fieldSet.path,d]),p=(0,vo.useCallback)((()=>{d(n.fieldSet.path,!1)}),[n.fieldSet.path,d]);return(0,go.jsx)(Ej,{title:n.fieldSet.title||lc()(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,go.jsx)(Uk,{member:e},n.key):(0,go.jsx)(Ck,{member:e,renderAnnotation:i,renderBlock:r,renderField:o,renderInlineBlock:s,renderInput:a,renderItem:l,renderPreview:c},e.key)))})}));function Kk(e){const t=(0,vo.useRef)(),{member:n,renderAnnotation:i,renderBlock:r,renderField:o,renderInlineBlock:s,renderInput:a,renderItem:l,renderPreview:c}=e,{onPathBlur:d,onPathFocus:u,onChange:p,onPathOpen:h,onSetPathCollapsed:f,onSetFieldSetCollapsed:m,onFieldGroupSelect:g}=Wm(),x=qq();zm(n.item.focused,((e,n)=>{var i;!e&&n&&(null==(i=t.current)||i.focus())}));const v=(0,vo.useCallback)((()=>{p(Am.from([Im([{_key:n.key}])]))}),[n.key,p]),y=(0,vo.useCallback)((e=>{h(e),f(e,!1)}),[h,f]),b=(0,Co.pm)(),j=(0,vo.useCallback)((e=>{if(0===e.items.length)throw new Error("Insert event should include at least one item");const t=e.items.map((e=>_w(e)));p(Am.from([Sm(t,e.position,[{_key:n.key}])]));const i=t[0]._key,r=[...n.item.path.slice(0,-1),{_key:i}];u(r);const o=!1!==e.open;e.skipInitialValue?o&&y(r):ek(t,n.parentSchemaType,x).pipe((0,Ko.b)((e=>{"patch"===e.type?p(Am.from(e.patches)):b.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:()=>{o&&y(r)}})}),[y,n.item.path,n.key,n.parentSchemaType,p,u,x,b]),w=(0,vo.useCallback)((()=>{d(n.item.path)}),[n.item.path,d]),k=(0,vo.useCallback)((()=>{u(n.item.path)}),[n.item.path,u]),C=(0,vo.useCallback)((e=>{u(n.item.path.concat(e))}),[n.item.path,u]),_=(0,vo.useCallback)((e=>{p(Am.from(e).prepend(_m(iw(n.item.schemaType))).prefixAll({_key:n.key}))}),[p,n.item.schemaType,n.key]),S=(0,vo.useCallback)((()=>{f(n.item.path,!0)}),[f,n.item.path]),T=(0,vo.useCallback)((()=>{f(n.item.path,!1)}),[f,n.item.path]),I=(0,vo.useCallback)((e=>{f(n.item.path.concat(e),!0)}),[f,n.item.path]),P=(0,vo.useCallback)((e=>{f(n.item.path.concat(e),!1)}),[f,n.item.path]),E=(0,vo.useCallback)((()=>{h(n.item.path)}),[h,n.item.path]),A=(0,vo.useCallback)((e=>{h(n.item.path.concat(e))}),[h,n.item.path]),F=(0,vo.useCallback)((e=>{m(n.item.path.concat(e),!1)}),[m,n.item.path]),M=(0,vo.useCallback)((e=>{m(n.item.path.concat(e),!0)}),[m,n.item.path]),O=(0,vo.useCallback)((()=>{h(n.item.path)}),[h,n.item.path]),R=!n.item.value||Qw(n.item.value),z=(0,vo.useCallback)((()=>{R&&v();const e=n.item.path.slice(0,-1);h(e),u(e)}),[R,h,n.item.path,u,v]),D=(0,vo.useCallback)((e=>{g(n.item.path,e)}),[g,n.item.path]),B=(0,vo.useMemo)((()=>({onBlur:w,onFocus:k,id:n.item.id,ref:t})),[w,k,n.item.id]),L=(0,vo.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:E,onFieldCollapse:I,onFieldSetCollapse:M,onFieldExpand:P,onFieldSetExpand:F,onFieldGroupSelect:D,onPathFocus:C,onFieldOpen:A,path:n.item.path,presence:n.item.presence,readOnly:n.item.readOnly,renderAnnotation:i,renderBlock:r,renderField:o,renderInlineBlock:s,renderInput:a,renderItem:l,renderPreview:c,schemaType:n.item.schemaType,validation:n.item.validation,value:n.item.value,elementProps:B})),[B,_,E,I,M,P,F,C,A,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,o,s,a,l,c]),Z=(0,vo.useMemo)((()=>a(L)),[L,a]),N=(0,vo.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:O,onClose:z,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:Z,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,O,z,T,S,k,w,Z,L]);return(0,go.jsx)($m,{onFieldGroupSelect:g,onChange:_,onPathOpen:h,onSetFieldSetCollapsed:m,onSetPathCollapsed:f,onPathBlur:d,onPathFocus:u,children:(0,vo.useMemo)((()=>l(N)),[N,l])})}function Hk(e){switch(e.jsonType){case"string":return"";case"number":return-0;case"boolean":return!1;default:throw new Error('Unable to create value from type "'.concat(e.jsonType,'"'))}}function $k(e){const t=(0,vo.useRef)(),{member:n,renderItem:i,renderInput:r}=e,[o,s]=(0,vo.useState)(),{onPathBlur:a,onPathFocus:l,onChange:c}=Wm();zm(n.item.focused,((e,n)=>{var i;!e&&n&&(null==(i=t.current)||i.focus())}));const d=(0,vo.useCallback)((e=>{a(n.item.path)}),[n.item.path,a]),u=(0,vo.useCallback)((e=>{l(n.item.path)}),[n.item.path,l]),p=(0,vo.useCallback)((e=>{c(Am.from(e).prefixAll(n.index))}),[c,n.index]),h=(0,vo.useCallback)((e=>{let t=e.currentTarget.value;if((0,mo.J1)(n.item.schemaType)){if(t=e.currentTarget.valueAsNumber,t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)return}else(0,mo.EG)(n.item.schemaType)&&(t=e.currentTarget.checked);const i=""===t||"number"===typeof t&&isNaN(t);(0,mo.J1)(n.item.schemaType)&&s(i?void 0:e.currentTarget.value),p(Tm(i?Hk(n.item.schemaType):t))}),[p,n.item.schemaType]),f=(0,vo.useMemo)((()=>({onBlur:d,onFocus:u,id:n.item.id,ref:t,onChange:h,value:Wk(n.item.schemaType,n.item.value,o),readOnly:Boolean(n.item.readOnly),placeholder:n.item.schemaType.placeholder})),[d,u,h,n.item.id,n.item.readOnly,n.item.schemaType,n.item.value,o]),m=(0,vo.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,vo.useMemo)((()=>r(m)),[m,r]),x=(0,vo.useCallback)((()=>{c(Am.from([Im([n.index])]))}),[n.index,c]),v=(0,vo.useCallback)((e=>{c(Am.from([Sm(e.items,e.position,[n.index])]))}),[n.index,c]),y=(0,vo.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:d,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,d,g]);return(0,go.jsx)(go.Fragment,{children:(0,vo.useMemo)((()=>i(y)),[y,i])})}function Wk(e,t,n){return Object.is(t,-0)?"":xk(e,t,n)}const Gk=(0,Es.ZP)(Co.Zb)(xt||(xt=rd(["\n max-width: ","px;\n"])),(e=>{let{theme:t}=e;return t.sanity.container[1]}));function Xk(e){const{value:t,onFocus:n,vertical:i,...r}=e,[o,s]=vo.useState(!1),[a,l]=vo.useState(null);(0,Co.O8)((()=>s(!1)),[a]);const c=vo.useCallback((e=>{"Escape"!==e.key&&"Tab"!==e.key||s(!1)}),[]),d=(0,vo.useCallback)((()=>{s((e=>!e))}),[]),u=(0,vl.wq)(t);return(0,go.jsx)(Co.J2,{open:o,ref:l,onKeyDown:c,portal:!0,constrainSize:!0,tone:"default",content:(0,go.jsx)(Gk,{margin:1,padding:3,onKeyDown:c,tabIndex:0,overflow:"auto",children:(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsxs)(Co.xv,{weight:"semibold",children:["Item of type ",(0,go.jsx)("code",{children:u})," not valid for this list"]}),(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"Why is this happening?"}),(0,go.jsxs)(Co.xv,{size:1,children:["The current schema does not declare items of type ",(0,go.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,go.jsx)(Co.xu,{children:(0,go.jsxs)(Co.xv,{size:1,children:[(0,go.jsx)(Ds.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,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,go.jsx)(Co.Zb,{padding:2,overflow:"auto",border:!0,children:(0,go.jsx)(Co.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,go.jsx)(Co.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,flex:1,onFocus:n,onClick:d,onKeyDown:c,__unstable_focusRing:!0,...r,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xu,{marginRight:3,children:(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.Tzq,{})})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsxs)(Co.xv,{size:1,textOverflow:"ellipsis",children:["Item of type ",(0,go.jsx)("code",{children:u})," not valid for this list"]})})]})})})}function Yk(e){const{member:t}=e;return"INVALID_ITEM_TYPE"===t.error.type?(0,go.jsx)(Xk,{value:t.error.value}):(0,go.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})}const Jk=(0,vo.memo)((function(e){const{member:t,renderAnnotation:n,renderBlock:i,renderInput:r,renderInlineBlock:o,renderField:s,renderItem:a,renderPreview:l}=e;return"field"===t.kind?(0,go.jsx)(Ck,{member:t,renderAnnotation:n,renderBlock:i,renderInlineBlock:o,renderInput:r,renderField:s,renderItem:a,renderPreview:l},t.key):"error"===t.kind?(0,go.jsx)(Uk,{member:t},t.key):"fieldSet"===t.kind?(0,go.jsx)(Vk,{member:t,renderAnnotation:n,renderBlock:i,renderInlineBlock:o,renderInput:r,renderField:s,renderItem:a,renderPreview:l},t.key):(console.warn(new Error("Unhandled member kind ".concat(t.kind))),null)}));function Qk(e){const{members:t,renderAnnotation:n,renderBlock:i,renderInput:r,renderInlineBlock:o,renderField:s,renderItem:a,renderPreview:l}=e,c=(0,vo.useMemo)((()=>t.map((e=>(0,go.jsx)(Jk,{member:e,renderAnnotation:n,renderBlock:i,renderField:s,renderInlineBlock:o,renderInput:r,renderItem:a,renderPreview:l},e.key)))),[t,n,i,s,o,r,a,l]);return(0,go.jsx)(go.Fragment,{children:c})}const eC=e=>{let{children:t}=e;return t};const tC=(0,vo.memo)((function(e){const t=(0,vo.useMemo)((()=>"absolutePath"in e?e.absolutePath:e.path.concat(e.relativePath)),[e]),n=(0,vo.useCallback)((()=>(0,go.jsx)(go.Fragment,{children:"Missing destination render function"})),[]);return(0,go.jsx)(nC,{...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})})),nC=(0,vo.memo)((function e(t){const{absolutePath:n,destinationRenderAnnotation:i,destinationRenderBlock:r,destinationRenderField:o,destinationRenderInlineBlock:s,destinationRenderInput:a,destinationRenderItem:l,destinationRenderPreview:c}=t,d=(0,vo.useCallback)((t=>{if((0,xo.Xy)(t.path,n)||(0,xo.Ny)(n,t.path))return a(t);if(!kw(t)&&!Cw(t))throw new Error("Expected either object input props or array input props for: ".concat(JSON.stringify(t.path)));return(0,go.jsx)(e,{...t,absolutePath:n,destinationRenderAnnotation:i,destinationRenderBlock:r,destinationRenderInput:a,destinationRenderItem:l,destinationRenderField:o,destinationRenderInlineBlock:s,destinationRenderPreview:c})}),[n,i,r,o,s,a,l,c]),u=(0,vo.useCallback)((e=>(0,xo.Ny)(n,e.path)&&(t.includeField||!(0,xo.Xy)(n,e.path))?o(e):eC(e)),[n,o,t.includeField]),p=(0,vo.useCallback)((e=>(0,xo.Ny)(n,e.path)&&(t.includeItem||!(0,xo.Xy)(n,e.path))?l(e):eC(e)),[n,l,t.includeItem]),h=(0,vo.useCallback)((e=>(0,xo.Ny)(n,e.path)&&(t.includeItem||!(0,xo.Xy)(n,e.path))?r(e):eC(e)),[n,r,t.includeItem]),f=(0,vo.useCallback)((e=>(0,xo.Ny)(n,e.path)&&(t.includeItem||!(0,xo.Xy)(n,e.path))?s(e):eC(e)),[n,s,t.includeItem]),m=(0,vo.useCallback)((e=>(0,xo.Ny)(n,e.path)&&(t.includeItem||!(0,xo.Xy)(n,e.path))?i(e):eC(e)),[n,i,t.includeItem]);if(Cw(t)){const e=(0,xo.fi)(t.path,n),i=t.members.find((t=>"item"==t.kind&&(0,mo.Fd)(e[0])&&t.key===e[0]._key));if(!i){const e=(0,xo.fi)(t.path,n)[0]._key;return(0,go.jsxs)("div",{children:["No array item with _key ",(0,go.jsxs)("code",{children:['"',e,'"']})," found at path ",JSON.stringify(t.path)]})}return"error"===i.kind?(0,go.jsx)(Yk,{member:i}):(0,go.jsx)(Kk,{member:i,renderAnnotation:m,renderBlock:h,renderInput:d,renderField:u,renderInlineBlock:f,renderItem:p,renderPreview:c})}if(kw(t)){const e=(0,xo.fi)(t.path,n),i=t.members.find((t=>"field"==t.kind&&e[0]===t.name));if(!i){const t=e[0];return(0,go.jsxs)("div",{children:["Field ",JSON.stringify(t)," not found among members \u2013 please verify that it's both defined in the schema and that it has not been conditionally hidden."]})}return(0,go.jsx)(Ck,{member:i,renderAnnotation:m,renderBlock:h,renderInput:d,renderInlineBlock:f,renderField:u,renderItem:p,renderPreview:c})}throw new Error("FormInput can only be used with arrays or objects")})),iC=(0,vo.createContext)(null);function rC(e){const{scrollElement:t}=e;return(0,go.jsx)(iC.Provider,{value:{scrollElement:t},children:e.children})}const oC=[0,0,1,0];function sC(e){const{children:t,header:n,id:i,legacy_referenceElement:r,onClose:o,type:s,width:a,autofocus:l}=e,[c,d]=(0,vo.useState)(null),u=(0,go.jsx)(lj,{margins:oC,children:(0,go.jsx)(Co.xu,{padding:4,children:t})});return"dialog"===s?(0,go.jsx)(rC,{scrollElement:c,children:(0,go.jsx)(Co.Vq,{header:n,id:i||"",onClickOutside:o,onClose:o,width:a,contentRef:d,__unstable_autoFocus:l,children:u})}):(0,go.jsx)(Gu,{header:n,onClose:o,referenceElement:r,width:a,containerRef:d,children:(0,go.jsx)(rC,{scrollElement:c,children:u})})}const aC={portal:!0,tone:"default"},lC={position:"absolute",top:0,left:0,bottom:0,right:0,opacity:.6},cC={position:"relative"};function dC(e){var t,n,i,r,o,s;const{schemaType:a,parentSchemaType:l,path:c,readOnly:d,onRemove:u,value:p,open:h,onInsert:f,onF
1ocus:m,onOpen:g,onClose:x,changed:v,focused:y,children:b,inputProps:{renderPreview:j}}=e,w=!d&&!1!==(null==(t=l.options)?void 0:t.sortable),k=l.of,C=(0,vo.useRef)(null);xb(C,h),zm(y,((e,t)=>{var n;!e&&t&&C.current&&(null==(n=C.current)||n.focus())}));const _=p._resolvingInitialValue,S=(0,vo.useCallback)((()=>{f({items:[{...p,_key:yb()}],position:"after"})}),[f,p]),T=(0,vo.useCallback)(((e,t)=>{f({items:[rw(t)],position:e})}),[f]),I=Qm(c,!0),P=(0,vo.useMemo)((()=>0===I.length?null:(0,go.jsx)(Db,{presence:I,maxAvatars:1})),[I]),E=ig(c,!0),A=(0,vo.useMemo)((()=>0===E.length?null:(0,go.jsx)(Co.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,go.jsx)(hj,{validation:E,__unstable_showSummary:!0})})),[E]),F=E.some((e=>"error"===e.level)),M=E.some((e=>"warning"===e.level)),O=(0,vo.useMemo)((()=>d?null:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(e.inputId,"-menuButton"),menu:(0,go.jsxs)(Co.v2,{children:[(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:u}),(0,go.jsx)(Co.sN,{text:"Duplicate",icon:Ds.TIy,onClick:S}),(0,go.jsx)(sw,{types:k,onInsert:T})]}),popover:aC})),[S,T,u,k,e.inputId,d]),R=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:d,hasErrors:F,hasWarnings:M}),z=(0,go.jsx)(Wj,{menu:O,presence:P,validation:A,tone:R,focused:y,dragHandle:w,selected:h,children:(0,go.jsxs)(Co.Zb,{as:"button",type:"button",tone:"inherit",radius:2,disabled:_,padding:1,onClick:g,ref:C,onFocus:m,__unstable_focusRing:!0,style:cC,children:[j({schemaType:e.schemaType,value:e.value,layout:"default",skipVisibilityCheck:!0}),_&&(0,go.jsx)(Co.Zb,{style:lC,tone:"transparent",radius:2,as:Co.kC,justify:"center",children:(0,go.jsxs)(Co.kC,{align:"center",justify:"center",padding:3,children:[(0,go.jsx)(Co.xu,{marginX:3,children:(0,go.jsx)(Co.$j,{muted:!0})}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"Resolving initial value\u2026"})]})})]})}),D=Nh(a);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(nu,{path:c,isChanged:v,hasFocus:Boolean(y),children:(0,go.jsx)(Co.xu,{paddingX:1,children:z})}),h&&(0,go.jsx)(sC,{header:d?"View ".concat(D):"Edit ".concat(D),type:(null==(i=null==(n=null==l?void 0:l.options)?void 0:n.modal)?void 0:i.type)||"dialog",width:null!=(s=null==(o=null==(r=null==l?void 0:l.options)?void 0:r.modal)?void 0:o.width)?s:1,id:p._key,onClose:x,autofocus:y,legacy_referenceElement:C.current,children:b})]})}function uC(e){var t;return(null==(t=e.components)?void 0:t.item)?e.components.item:(0,mo.dD)(e)?ww:dC}const pC={portal:!0,tone:"default"};function hC(e){var t,n,i,r,o,s,a,l,c;const d=(0,vo.useRef)(null),{schemaType:u,path:p,open:h,inputId:f,children:m,inputProps:g}=e,{readOnly:x,focused:v,renderPreview:y,onChange:b}=e.inputProps,j=(0,vo.useCallback)((()=>g.onChange(Im())),[g]),w=e.value,{EditReferenceLink:k,getReferenceInfo:C,selectedState:_,isCurrentDocumentLiveEdit:S}=MI({path:p,schemaType:u,value:w});xb(d,h),zm(v,((e,t)=>{!e&&t&&d.current&&d.current.focus()}));const T=e.validation.some((e=>"error"===e.level)),I=e.validation.some((e=>"warning"===e.level)),P=uw(null==w?void 0:w._ref,C),E=(null==(t=P.result)?void 0:t.type)||(null==(n=null==w?void 0:w._strengthenOnPublish)?void 0:n.type),A=E?u.to.find((e=>e.name===E)):void 0,F="pressed"===_,M="selected"===_,O=null==w?void 0:w._ref,R=O&&(null==(o=null==(r=null==(i=P.result)?void 0:i.preview)?void 0:r.published)?void 0:o._id),z=(0,vo.useCallback)((()=>{b([!0===u.weak?Tm(!0,["_weak"]):Im(["_weak"]),Im(["_strengthenOnPublish"])])}),[b,u.weak]),D=(0,vo.useCallback)((()=>{b(!0===u.weak?Tm(!0,["_weak"]):Im(["_weak"]))}),[b,u]),B=(0,vo.useCallback)((()=>{g.onPathFocus(["_ref"])}),[g]),L=(null==w?void 0:w._weak)?"weak":"strong",Z=!0===u.weak?"weak":"strong",N=O&&!P.isLoading&&(null==w?void 0:w._strengthenOnPublish),q=!P.isLoading&&O&&L!==Z&&!N,U=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:x,hasErrors:T,hasWarnings:I}),V=!(null==w?void 0:w._ref)||"_ref"===g.focusPath[0],K=(null==(s=P.result)?void 0:s.preview.draft)||(null==(a=P.result)?void 0:a.preview.published),H=(0,go.jsxs)(go.Fragment,{children:[S&&R&&w._strengthenOnPublish&&(0,go.jsx)(nw,{padding:1,title:u.weak?"Finalize reference":"Convert to strong reference",status:"info","data-testid":"alert-reference-published",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:[(0,go.jsx)("strong",{children:null==(c=null==(l=P.result)?void 0:l.preview.published)?void 0:c.title})," is published and this reference should now be"," ",u.weak?(0,go.jsx)(go.Fragment,{children:"finalized"}):(0,go.jsx)(go.Fragment,{children:"converted to a strong reference"}),"."]}),(0,go.jsx)(Co.zx,{onClick:z,text:(0,go.jsx)(go.Fragment,{children:"Convert to strong reference"}),tone:"positive"})]})}),q&&(0,go.jsx)(nw,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,go.jsx)("em",{children:L}),", but according to the current schema it should be"," ",(0,go.jsxs)("em",{children:[Z,"."]})]}),(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:u.weak?(0,go.jsxs)(go.Fragment,{children:['It will not be possible to delete the "',null==K?void 0:K.title,'"-document without first removing this reference.']}):(0,go.jsxs)(go.Fragment,{children:['This makes it possible to delete the "',null==K?void 0:K.title,'"-document without first deleting this reference, leav
1ing this field referencing a nonexisting document.']})}),(0,go.jsx)(Co.zx,{onClick:D,text:(0,go.jsxs)(go.Fragment,{children:["Convert to ",Z," reference"]}),tone:"caution"})]})}),P.error&&(0,go.jsx)(nw,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["Error: ",P.error.message]}),(0,go.jsx)(Co.zx,{onClick:P.retry,text:(0,go.jsx)(go.Fragment,{children:"Retry"}),tone:"primary"})]})})]}),$=(0,vo.useMemo)((()=>(0,vo.forwardRef)((function(e,t){return(0,go.jsx)(Bs.nR,{...e,intent:"edit",params:{id:null==w?void 0:w._ref,type:null==A?void 0:A.name},target:"_blank",rel:"noopener noreferrer",ref:t})}))),[null==A?void 0:A.name,null==w?void 0:w._ref]),W=(0,vo.useMemo)((()=>x?null:(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{paddingY:3,paddingX:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(f,"-menuButton"),menu:(0,go.jsxs)(Co.v2,{children:[!x&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.sN,{text:"Clear",tone:"critical",icon:Ds.XHJ,onClick:j}),(0,go.jsx)(Co.sN,{text:"Replace",icon:Ds.bnu,onClick:B})]}),!x&&(null==w?void 0:w._ref)&&(0,go.jsx)(Co.R,{}),(null==w?void 0:w._ref)&&(0,go.jsx)(Co.sN,{as:$,"data-as":"a",text:"Open in new tab",icon:Ds.buG})]}),popover:pC})})),[j,B,f,$,x,null==w?void 0:w._ref]);return(0,go.jsx)(bj,{__unstable_headerActions:e.actions,level:e.level,title:e.title,description:e.description,validation:e.validation,__unstable_presence:e.presence,children:V?(0,go.jsx)(Co.xu,{paddingY:2,children:m}):(0,go.jsx)(Co.Zb,{shadow:1,radius:1,padding:1,tone:U,children:(0,go.jsxs)(Co.Kq,{space:1,children:[(0,go.jsxs)(Co.kC,{gap:1,align:"center",children:[(0,go.jsx)(xw,{flex:1,as:k,tone:"inherit",radius:2,documentId:null==w?void 0:w._ref,documentType:null==A?void 0:A.name,paddingX:2,paddingY:1,__unstable_focusRing:!0,selected:M,pressed:F,ref:d,"data-selected":!!M||void 0,"data-pressed":!!F||void 0,children:(0,go.jsx)(mw,{value:w,referenceInfo:P,renderPreview:y,type:u})}),(0,go.jsx)(Co.xu,{children:W})]}),H]})})})}function fC(e,t){return ic()(e.options,t)}const mC=["array","file","image","reference","slug"],gC=["asset","crop","hotspot","_ref","_weak"],xC=["tags"],vC=["slug"];function yC(e,t){if(!e)return[];if(t.has(e))return[];t.add(e);return[e,...e.type?yC(e.type,t):[]]}function bC(e,t){return(0,mo.jB)(e)?function(e,t){var n;const{options:i}=e,r=(null==(n=(null==i?void 0:i.list)||[])?void 0:n.length)>0,o=xC.includes((null==i?void 0:i.layout)||"");if(r&&!o)return t;return 0}(e,t):function(e,t){var n,i,r;const{type:o,options:s}=e,a=jC(o,mC),l="object"===(null==e?void 0:e.jsonType)?e.fields:void 0,c=(null==a?void 0:a.name)||"";if(vC.includes(c))return 0;const d=mC.includes(c),u=(null!=(n=null==l?void 0:l.filter((e=>!gC.includes(e.name))).length)?n:0)>0,p=(null!=(r=null==(i=null==s?void 0:s.list)?void 0:i.length)?r:0)>0;if(u||p||!d)return t;return 0}(e,t)}function jC(e,t){return(null==e?void 0:e.name)&&t.includes(null==e?void 0:e.name)?e:e?jC(e.type,t):void 0}function wC(e){const{onMouseEnter:t,onMouseLeave:n}=og();return(0,go.jsx)(nu,{path:e.path,hasFocus:Boolean(e.inputProps.focused),isChanged:e.inputProps.changed,onMouseEnter:t,onMouseLeave:n,children:e.children})}function kC(e){const{onMouseEnter:t,onMouseLeave:n}=og();return(0,go.jsx)(bj,{__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,go.jsx)(nu,{path:e.path,hasFocus:Boolean(e.inputProps.focused),isChanged:e.inputProps.changed,children:e.children})})}function CC(e){const{onMouseEnter:t,onMouseLeave:n}=og();return(0,go.jsx)(Ej,{__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 _C(e){const{onMouseEnter:t,onMouseLeave:n}=og(),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,go.jsx)(Ej,{__unstable_headerActions:e.actions,level:e.level,title:e.title,de
1scription: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 SC(e){var t;if(null==(t=e.components)?void 0:t.field)return e.components.field;if((0,mo.EG)(e))return wC;const n=yC(e,new Set);return n.some((e=>"image"===e.name||"file"===e.name))?_C:n.some((e=>(0,mo.dD)(e)))?hC:"object"!==e.jsonType&&"array"!==e.jsonType?kC:CC}function TC(e){const{allowedDecorators:t,block:n,onChange:i}=e;let r;return e=>{r=Array.isArray(e)?e:[e],r=r.map((e=>(0,Gl.nX)(e,{allowedDecorators:t})));const o=[Sm(r,"after",[{_key:n._key}])];return i(Am.from(o))}}function IC(e){const{allowedDecorators:t,block:n,onChange:i}=e;return e=>{const r=[Tm((0,Gl.nX)(e,{allowedDecorators:t}),[{_key:n._key}])];return i(Am.from(r))}}function PC(e){const{block:t,onChange:n}=e;return()=>{const e=[Im([{_key:t._key}])];return n(Am.from(e))}}const EC=Es.ZP.div(vt||(vt=rd(["\n display: flex;\n pointer-events: all;\n"])));function AC(e){const t=(0,yl._F)(),{block:n,onChange:i,renderBlockActions:r}=e,o=(0,vo.useMemo)((()=>t.schemaTypes.decorators.map((e=>e.value))),[t]),s=(0,vo.useMemo)((()=>{if(r){const e={block:n,value:yl.q$.getValue(t),set:IC({allowedDecorators:o,block:n,onChange:i}),unset:PC({block:n,onChange:i}),insert:TC({allowedDecorators:o,block:n,onChange:i})};return r(e)}}),[r,n,t,i,o]);return s?(0,go.jsx)(EC,{contentEditable:!1,children:s}):null}const FC=Es.ZP.div((e=>{let{theme:t}=e;const{radius:n,space:i,color:r}=t.sanity,o=(0,Co.m4)(r.spot.yellow,.2);return(0,Es.iv)(yt||(yt=rd(["\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],o)})),MC=(0,Es.ZP)(nu)((()=>(0,Es.iv)(bt||(bt=rd(["\n width: 1px;\n height: 100%;\n\n & > div {\n height: 100%;\n }\n "])))));function OC(e){return e.type?OC(e.type):"block"===e.name}function RC(e){return"field"===e.kind&&"array"===e.field.schemaType.jsonType}const zC=["@@_NONEXISTENT_PATH_@@"];function DC(e){const t=(0,vo.useRef)(null),n=(null==e?void 0:e.validation)&&e.validation.length>0?e.validation:Ad,i=ig((null==e?void 0:e.path)||zC),r=(0,vo.useMemo)((()=>(null==e?void 0:e.schemaType)&&OC(null==e?void 0:e.schemaType)?n:n.concat(i)),[i,e,n]),[o,s,a]=(0,vo.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]),l=Gm(t.current,r);return t.current=l,(0,vo.useMemo)((()=>({validation:l,hasError:o,hasWarning:s,hasInfo:a})),[l,o,s,a])}const BC=(0,vo.createContext)([]);function LC(e){return(0,go.jsx)(BC.Provider,{value:e.markers,children:e.children})}function ZC(e){const t=(0,vo.useContext)(BC);if(!t)throw new Error("Form context not provided");return(0,vo.useMemo)((()=>t.filter((t=>(0,xo.Xy)(t.path,e)))),[t,e])}const NC=(0,vo.createContext)([]);function qC(e){return(0,go.jsx)(NC.Provider,{value:e.memberItems,children:e.children})}function UC(e){const t=(0,vo.useContext)(NC);if(!t)throw new Error("Form context not provided");return t.find((t=>t.key===e))}const VC=(0,Es.ZP)(Co.Zb)((e=>{var t;const{color:n,radius:i,space:r}=e.theme.sanity,o=(0,Es.iv)(jt||(jt=rd(["\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,Es.iv)(wt||(wt=rd(["\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,o,n.dark?Vs.VG.purple[950].hex:Vs.VG.purple[50].hex,o,n.muted.caution.hovered.bg,n.muted.caution.hovered.border,o,n.input.invalid.enabled.bg,n.input.invalid.hovered.border)})),KC=(0,Es.ZP)(Co.xu)(kt||(kt=rd(["\n display: block;\n width: 100%;\n user-select: none;\n pointer-events: all;\n"]))),HC=Es.ZP.div((e=>{let{theme:t,$hasChanges:n}=e;const{space:i}=t.sanity;return(0,Es.iv)(Ct||(Ct=rd(["\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,Es.iv)(_t||(_t=rd(["\n display: none;\n "]))))})),$C=(0,Es.ZP)(Co.kC)(St||(St=rd(["\n position: relative;\n\n [data-dragged] > & {\n opacity: 0.5;\n }\n"]))),WC=(0,Es.ZP)(Co.xu)(Tt||(Tt=rd(["\n width: 25px;\n position: relative;\n\n [data-dragged] & {\n visibility: hidden;\n }\n"]))),GC=(0,Es.ZP)(Co.kC)(It||(It=rd(["\n position: absolute;\n right: 0;\n [data-dragged] & {\n visibility: hidden;\n }\n"]))),XC=(0,Es.ZP)(Co.xu)(Pt||(Pt=rd(["\n max-width: 250px;\n"]))),YC={constrainSize:!0,placement:"bottom",portal:"default",tone:"default"};function JC(e){const{children:t,focused:n,isOpen:i,onOpen:r,onRemove:o,readOnly:s,value:a}=e,l=(0,vo.useId)(),c=(0,vo.useRef)(null),d=(0,vo.useRef)(!1),u=(0,vo.useMemo)((()=>"_ref"in a&&a._ref?(0,vo.forwardRef)((function(e,t){return(0,go.jsx)(Bs.nR,{...e,intent:"edit",params:{id:a._ref},ref:t})})):void 0),[a]);(0,vo.useEffect)((()=>
1{i&&(d.current=!1)}),[i]),(0,Co.qh)((0,vo.useCallback)((e=>{n&&"Tab"===e.key&&(!c.current||d.current||i||(e.preventDefault(),e.stopPropagation(),c.current.focus(),d.current=!0))}),[n,i]));const p=(0,vo.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),o()}),[o]);return(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{flex:1,children:t}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{"aria-label":"Open menu",fontSize:1,iconRight:Ds.zGg,mode:"bleed",paddingX:2,tabIndex:n?0:1}),ref:c,id:l,menu:(0,go.jsx)(Co.v2,{children:(0,go.jsxs)(go.Fragment,{children:["_ref"in a&&a._ref&&(0,go.jsx)(Co.sN,{as:u,"data-as":"a",icon:Ds.xPt,text:"Open reference"}),s&&(0,go.jsx)(Co.sN,{icon:Ds.hsE,onClick:r,text:"View"}),!s&&(0,go.jsx)(Co.sN,{icon:Ds.dY8,onClick:r,text:"Edit"}),!s&&(0,go.jsx)(Co.sN,{icon:Ds.XHJ,onClick:p,text:"Delete",tone:"critical"})]})}),popover:YC})})]})}const QC=e=>Array.isArray(e)?e.flatMap(QC):"number"===typeof e?[e]:"auto"===e?["auto"]:[];function e_(e){const{onClose:t,children:n,title:i,width:r=1,autoFocus:o}=e,s=(0,vo.useId)(),[a,l]=(0,vo.useState)(null);return(0,go.jsx)(Co.Vq,{header:i,id:s,onClickOutside:t,onClose:t,portal:"default",width:r,contentRef:l,__unstable_autoFocus:o,children:(0,go.jsx)(lj,{margins:[0,0,1,0],children:(0,go.jsx)(rC,{scrollElement:a,children:(0,go.jsx)(Co.xu,{padding:4,children:n})})})})}const t_=(0,Es.ZP)(Co.J2)(Et||(Et=rd(["\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"]))),n_=(0,Es.ZP)(Co.xu)(At||(At=rd(["\n /* Prevent overflow caused by change indicator */\n overflow-x: hidden;\n overflow-y: auto;\n"]))),i_=(0,Es.ZP)(Co.xu)(Ft||(Ft=rd(["\n box-shadow: 0 1px 0 var(--card-shadow-outline-color);\n position: relative;\n z-index: 10;\n min-height: auto;\n"]))),r_=["top","bottom"];function o_(e){const{floatingBoundary:t,referenceBoundary:n,referenceElement:i,width:r=0}=e,[o,s]=(0,vo.useState)(!1);return(0,vo.useEffect)((()=>{s(!0)}),[]),(0,go.jsx)(t_,{content:(0,go.jsx)(s_,{...e}),constrainSize:!0,"data-ui":"PopoverEditDialog",fallbackPlacements:r_,floatingBoundary:t,open:o,overflow:"auto",placement:"bottom",portal:"default",preventOverflow:!0,referenceBoundary:n,referenceElement:i,width:r})}function s_(e){const{onClose:t,referenceBoundary:n,referenceElement:i,title:r,autoFocus:o}=e;(0,Co.qh)((0,vo.useCallback)((e=>{"Escape"===e.key&&t()}),[t])),(0,Co.O8)(t,i?[i]:[],n);const[s,a]=(0,vo.useState)(null);return(0,go.jsx)(rC,{scrollElement:s,children:(0,go.jsxs)(Co.kC,{direction:"column",height:"fill",children:[(0,go.jsx)(i_,{flex:"none",padding:1,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xu,{flex:1,padding:2,children:(0,go.jsx)(Co.xv,{weight:"semibold",children:r})}),(0,go.jsx)(Co.zx,{autoFocus:Boolean(o),icon:Ds.Two,mode:"bleed",onClick:t,padding:2})]})}),(0,go.jsx)(n_,{flex:1,children:(0,go.jsx)(lj,{margins:[0,0,1,0],children:(0,go.jsx)(Co.xu,{padding:3,ref:a,children:e.children})})})]})})}function a_(e){const{autoFocus:t,defaultType:n,floatingBoundary:i,onClose:r,referenceBoundary:o,referenceElement:s,schemaType:a}=e,l=(0,vo.useMemo)((()=>function(e){var t;const n=null==(t=e.options)?void 0:t.modal;return"object"===typeof n&&null!==n?{type:(i=n.type,"dialog"===i||"popover"===i?i:void 0),width:QC(n.width)}:void 0;var i}(a)),[a]),c=(null==l?void 0:l.type)||n,d=(0,go.jsxs)(go.Fragment,{children:["Edit ",a.title]}),u=(0,vo.useCallback)((()=>{r()}),[r]),p=null==l?void 0:l.width;return"popover"===c?(0,go.jsx)(o_,{autoFocus:t,floatingBoundary:i,onClose:u,referenceBoundary:o,referenceElement:s,title:d,width:p,children:e.children}):(0,go.jsx)(e_,{onClose:u,title:d,width:p,autoFocus:t,children:e.children})}function l_(e){var t;const{floatingBoundary:n,focused:i,isFullscreen:r,onItemClose:o,onItemOpen:s,onPathFocus:a,path:l,readOnly:c,referenceBoundary:d,relativePath:u,renderAnnotation:p,renderBlock:h,renderBlockActions:f,renderCustomMarkers:m,renderField:g,renderInlineBlock:x,renderInput:v,renderItem:y,renderPreview:b,schemaType:j,selected:w,value:k}=e,{onChange:C}=Wm(),{Markers:_}=Lm().__internal.components,[S,T]=(0,vo.useState)(!1),I=ZC(l),P=(0,yl._F)(),E=UC(Ig(l)),A=(0,vo.useRef)(!1),F=(0,vo.useMemo)((()=>({anchor:{path:u,offset:0},focus:{path:u,offset:0}})),[u]),M=(0,vo.useCallback)((()=>T(!0)),[]),O=(0,vo.useCallback)((()=>T(!1)),[]),R=(0,vo.useCallback)((()=>{E&&(yl.q$.blur(P),s(E.node.path))}),[P,E,s]),z=(0,vo.useCallback)((()=>{o(),yl.q$.select(P,F),yl.q$.focus(P)}),[o,P,F]),D=(0,vo.useCallback)((()=>
1{if(!A.current)try{yl.q$.delete(P,F,{mode:"blocks"})}catch(e){console.error(e)}finally{A.current=!0}}),[P,F]);(0,vo.useEffect)((()=>()=>{A.current&&yl.q$.focus(P)}),[P]);const B=(0,vo.useMemo)((()=>r&&!f?{paddingX:5}:r&&f?{paddingLeft:5,paddingRight:2}:f?{paddingLeft:3,paddingRight:2}:{paddingX:3}),[r,f]),{validation:L,hasError:Z,hasWarning:N,hasInfo:q}=DC(null==E?void 0:E.node),U=P.schemaTypes.portableText,V=Boolean(I.length>0),K=Qm(l,!0),H=(0,vo.useMemo)((()=>K.filter((e=>(0,xo.Xy)(e.path,l)))),[l,K]),$=Z||N||q||V,W=(0,vo.useMemo)((()=>$&&(0,go.jsx)(XC,{padding:2,children:(0,go.jsx)(_,{markers:I,validation:L,renderCustomMarkers:m})})||null),[_,I,m,$,L]),G=Boolean(null==E?void 0:E.member.open),X=null==E?void 0:E.input,Y=(null==E?void 0:E.node.path)||Ad,J=null==(t=null==E?void 0:E.elementRef)?void 0:t.current,Q=(0,vo.useMemo)((()=>({__unstable_floatingBoundary:n,__unstable_referenceBoundary:d,__unstable_referenceElement:J||null,children:X,focused:i,markers:I,onClose:z,onOpen:R,onPathFocus:a,onRemove:D,open:G,parentSchemaType:U,path:Y,presence:H,readOnly:Boolean(c),renderAnnotation:p,renderBlock:h,renderDefault:c_,renderField:g,renderInlineBlock:x,renderInput:v,renderItem:y,renderPreview:b,schemaType:j,selected:w,validation:L,value:k})),[n,J,X,i,I,z,R,a,D,G,U,Y,H,c,d,p,h,g,x,v,y,b,j,w,L,k]);return(0,vo.useMemo)((()=>(0,go.jsx)(Co.xu,{ref:null==E?void 0:E.elementRef,contentEditable:!1,children:(0,go.jsx)(Co.kC,{paddingBottom:1,marginY:3,style:void 0,children:(0,go.jsxs)($C,{flex:1,children:[(0,go.jsx)(Co.u,{placement:"top",portal:"editor",disabled:!$,content:W,children:(0,go.jsx)(KC,{...B,children:h&&h(Q)})}),(0,go.jsx)(WC,{marginRight:1,children:(0,go.jsx)(GC,{children:f&&k&&i&&!c&&(0,go.jsx)(AC,{block:k,onChange:C,renderBlockActions:f})})}),r&&E&&(0,go.jsx)(HC,{$hasChanges:E.member.item.changed,onMouseOut:O,onMouseOver:M,children:(0,go.jsx)(MC,{hasFocus:i,isChanged:E.member.item.changed,path:E.member.item.path,withHoverEffect:!1})}),S&&(0,go.jsx)(FC,{})]})})})),[Q,i,O,M,B,r,E,C,c,h,f,S,W,$,k])}const c_=e=>{const{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,children:r,focused:o,markers:s,onClose:a,onOpen:l,onRemove:c,open:d,readOnly:u,renderPreview:p,schemaType:h,selected:f,value:m,validation:g}=e,x=(0,mo.Or)(m),v=g.filter((e=>"error"===e.level)).length>0,y=g.filter((e=>"warning"===e.level)).length>0,b=Boolean(s.length>0),j=f||o?"primary":"default",w=(0,vo.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),l()}),[l]);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(VC,{"data-focused":o?"":void 0,"data-image-preview":x?"":void 0,"data-invalid":v?"":void 0,"data-markers":b?"":void 0,"data-read-only":u?"":void 0,"data-selected":f?"":void 0,"data-testid":"pte-block-object","data-warning":y?"":void 0,flex:1,onDoubleClick:w,padding:x?0:1,tone:j,children:p({actions:(0,go.jsx)(JC,{isOpen:d,focused:o,onOpen:l,onRemove:c,readOnly:u,value:m}),layout:x?"blockImage":"block",schemaType:h,skipVisibilityCheck:!0,value:m})}),d&&(0,go.jsx)(a_,{floatingBoundary:t,defaultType:"dialog",onClose:a,autoFocus:o,schemaType:h,referenceBoundary:n,referenceElement:i,children:r})]})},d_=[1,2,3,4,5,6,7,8,9],u_=["\u25cf","\u25cb","\u25a0"],p_=["number","lower-alpha","lower-roman"],h_={em:"em","strike-through":"s",underline:"u",strong:"strong",code:"code"},f_={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 m_(e){return"list-level-".concat(e)}const g_=Es.ZP.div((function(e){var t;const{$level:n,theme:i}=e,{color:r,fonts:o,radius:s,space:a}=i.sanity,l=p_[(n-1)%p_.length],c=u_[(n-1)%u_.length];return(0,Es.iv)(Mt||(Mt=rd(["\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 & > 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 }
1\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",a[1],a[1],a[1],a[1],s[2],r.dark?Vs.VG.purple[950].hex:Vs.VG.purple[50].hex,r.muted.caution.enabled.border,r.muted.caution.hovered.bg,r.muted.critical.enabled.border,r.muted.critical.hovered.bg,m_(n),m_(n),l,c,o.text.family,null==(t=r.selectable)?void 0:t.primary.pressed.bg)})),x_=(0,Es.ZP)(Co.xu)(Ot||(Ot=rd(["\n position: relative;\n display: flex;\n"]))),v_=Es.ZP.div(Rt||(Rt=rd(["\n user-select: none;\n white-space: nowrap;\n"]))),y_=(0,Es.ZP)(Co.xu)(zt||(zt=rd(["\n user-select: none;\n"]))),b_=(0,Es.ZP)(Co.xu)(Dt||(Dt=rd(["\n line-height: 0;\n width: 25px;\n position: relative;\n"]))),j_=(0,Es.ZP)(Co.kC)((e=>{let{theme:t}=e;const{fonts:n,space:i}=t.sanity,r=n.text.sizes[1],o=n.text.sizes[2],s=r.lineHeight-r.ascenderHeight-r.descenderHeight,a=o.lineHeight-o.ascenderHeight-o.descenderHeight,l=0-(s+i[2]+i[2]-a)/2;return(0,Es.iv)(Bt||(Bt=rd(["\n user-select: none;\n position: absolute;\n right: 0;\n top: ","px;\n "])),l)})),w_=(0,Es.ZP)(Co.xu)(Lt||(Lt=rd(["\n max-width: 250px;\n"]))),k_=(0,Es.ZP)(Co.kC)(Zt||(Zt=rd(["\n position: relative;\n padding-left: ","px;\n"])),(e=>{let{$level:t}=e;return t?32*t:0})),C_=Es.ZP.div((e=>{let{theme:t,$hasChanges:n}=e;const{space:i}=t.sanity;return(0,Es.iv)(Nt||(Nt=rd(["\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,Es.iv)(qt||(qt=rd(["\n display: none;\n "]))))})),__=Es.ZP.div(Ut||(Ut=rd(["\n display: block;\n"]))),S_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.xv,{"data-testid":"text-style--normal",...n,children:(0,go.jsx)(__,{children:t})})},T_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h1","data-testid":"text-style--h1",size:5,...n,children:(0,go.jsx)(__,{children:t})})},I_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h2","data-testid":"text-style--h2",size:4,...n,children:(0,go.jsx)(__,{children:t})})},P_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h3","data-testid":"text-style--h3",size:3,...n,children:(0,go.jsx)(__,{children:t})})},E_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h4","data-testid":"text-style--h4",size:2,...n,children:(0,go.jsx)(__,{children:t})})},A_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h5","data-testid":"text-style--h5",size:1,...n,children:(0,go.jsx)(__,{children:t})})},F_=e=>{let{children:t,...n}=e;return(0,go.jsx)(Co.X6,{as:"h6","data-testid":"text-style--h6",size:0,...n,children:(0,go.jsx)(__,{children:t})})},M_=Es.ZP.blockquote(Vt||(Vt=rd(["\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]})),O_=e=>{let{children:t,...n}=e;return(0,go.jsx)(M_,{"data-testid":"text-style--blockquote",...n,children:(0,go.jsx)(Co.xv,{as:"p",children:t})})},R_={normal:S_,h1:T_,h2:I_,h3:P_,h4:E_,h5:A_,h6:F_,blockquote:O_};function z_(e){const{children:t,floatingBoundary:n,focused:i,isFullscreen:r,onItemClose:o,onItemOpen:s,onPathFocus:a,path:l,readOnly:c,referenceBoundary:d,renderBlock:u,renderAnnotation:p,renderBlockActions:h,renderCustomMarkers:f,renderField:m,renderInlineBlock:g,renderInput:x,renderItem:v,renderPreview:y,schemaType:b,selected:j,spellCheck:w,value:k}=e,{Markers:C}=Lm().__internal.components,[_,S]=(0,vo.useState)(!1),T=ZC(l),I=UC(Ig(l)),P=(0,yl._F)(),{onChange:E}=Wm(),A=Qm(l,!0),F=(0,vo.useMemo)((()=>A.filter((e=>(0,xo.Xy)(e.path,l)||"children"===e.path.slice(-3)[1]&&e.path.length-l.length===2))),[l,A]),M=(0,vo.useCallback)((()=>S(!0)),[]),O=(0,vo.useCallback)((()=>S(!1)),[]),{validation:R,hasError:z,hasWarning:D,hasInfo:B}=DC(null==I?void 0:I.node),L=Boolean(f)&&T.length>0,Z=z||D||L||B,N=(0,vo.useCallback)((()=>{I&&s(I.node.path)}),[s,I]),q=(0,vo.useCallback)((()=>{const e={focus:{path:l,offset:0},anchor:{path:l,offset:0}};yl.q$.delete(P,e,{mode:"blocks"}),setTimeout((()=>yl.q$.focus(P)))}),[P,l]),U=(0,vo.useMemo)((()=>(0,go.jsxs)(k_,{align:"flex-start",$level:null==k?void 0:k.level,children:[k.listItem&&(0,go.jsx)(v_,{contentEditable:!1,
1children:(0,go.jsx)(Co.xv,{"data-list-prefix":"",children:(0,go.jsx)(__,{})})}),(0,go.jsx)("div",{"data-text":"",style:void 0,children:t})]})),[k.listItem,k.level,t]),V=(0,vo.useMemo)((()=>r&&!h?{paddingX:5}:r&&h?{paddingLeft:5,paddingRight:2}:h?{paddingLeft:3,paddingRight:2}:{paddingX:3}),[r,h]),K=(0,vo.useMemo)((()=>k.listItem?{paddingY:2}:f_[k.style||"normal"]||{paddingY:2}),[k]),H=Boolean(null==I?void 0:I.member.open),$=P.schemaTypes.portableText,W=(0,vo.useMemo)((()=>{var e;return{__unstable_floatingBoundary:n,__unstable_referenceBoundary:d,__unstable_referenceElement:(null==(e=null==I?void 0:I.elementRef)?void 0:e.current)||null,children:U,focused:i,markers:T,onClose:o,onOpen:N,onPathFocus:a,onRemove:q,open:H,parentSchemaType:$,path:(null==I?void 0:I.node.path)||Ad,presence:F,readOnly:Boolean(c),renderAnnotation:p,renderBlock:u,renderDefault:D_,renderField:m,renderInput:x,renderInlineBlock:g,renderItem:v,renderPreview:y,schemaType:b,selected:j,validation:R,value:k}}),[n,i,H,T,null==I?void 0:I.elementRef,null==I?void 0:I.node.path,o,N,a,q,$,c,d,p,u,m,g,x,v,y,b,j,U,F,R,k]),G=(0,vo.useMemo)((()=>Z&&(0,go.jsx)(w_,{padding:2,children:(0,go.jsx)(C,{markers:T,renderCustomMarkers:f,validation:R})})||null),[C,T,f,Z,R]);return(0,vo.useMemo)((()=>(0,go.jsx)(Co.xu,{"data-testid":"text-block",...K,style:void 0,ref:null==I?void 0:I.elementRef,children:(0,go.jsx)(x_,{"data-testid":"text-block__wrapper",children:(0,go.jsxs)(Co.kC,{flex:1,...V,children:[(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.u,{content:G,disabled:!Z,placement:"top",portal:"editor",children:(0,go.jsx)(g_,{$level:k.level||1,"data-error":z?"":void 0,"data-list-item":k.listItem,"data-markers":L?"":void 0,"data-read-only":c,"data-testid":"text-block__text","data-warning":D?"":void 0,spellCheck:w,children:u&&u(W)})})}),(0,go.jsxs)(y_,{contentEditable:!1,children:[(0,go.jsx)(b_,{marginRight:1,children:(0,go.jsx)(j_,{children:h&&i&&!c&&(0,go.jsx)(AC,{onChange:E,block:k,renderBlockActions:h})})}),r&&I&&(0,go.jsx)(C_,{$hasChanges:I.member.item.changed,onMouseEnter:M,onMouseLeave:O,children:(0,go.jsx)(MC,{hasFocus:i,isChanged:I.member.item.changed,path:I.member.item.path,withHoverEffect:!1})})]}),_&&(0,go.jsx)(FC,{})]})})})),[W,i,M,O,z,L,D,V,r,I,E,K,c,u,h,_,w,G,Z,k])}const D_=e=>(0,go.jsx)(go.Fragment,{children:e.children}),B_=(0,Es.ZP)(Co.J2)(Kt||(Kt=rd(["\n &[data-popper-reference-hidden='true'] {\n display: none !important;\n }\n"]))),L_=["top","bottom"];function Z_(e){const{floatingBoundary:t,onClosePopover:n,onEdit:i,onDelete:r,referenceBoundary:o,referenceElement:s,title:a,open:l}=e,{sanity:c}=(0,Co.Fg)(),d=(0,vo.useRef)(null),u=(0,vo.useRef)(null),p=c.color.dark?"light":"dark";(0,Co.qh)((0,vo.useCallback)((e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),n())}),[n]));const h=(0,vo.useCallback)((e=>{var t;if(!(null==(t=u.current)?void 0:t.disabled)){e.preventDefault(),e.stopPropagation();try{r(e)}catch(n){console.error(n)}finally{u.current&&(u.current.disabled=!0)}}}),[r]),f=(0,vo.useMemo)((()=>(0,go.jsx)(Co.xu,{padding:1,children:(0,go.jsxs)(Co.gF,{space:1,children:[(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{weight:"semibold",size:1,children:a})}),(0,go.jsx)(Co.zx,{icon:Ds.dY8,mode:"bleed",onClick:i,padding:2,ref:d,alt:"Edit object"}),(0,go.jsx)(Co.zx,{ref:u,icon:Ds.XHJ,mode:"bleed",padding:2,onClick:h,tone:"critical",alt:"Remove object"})]})})),[h,i,a]);return(0,go.jsx)(B_,{constrainSize:!0,content:f,fallbackPlacements:L_,floatingBoundary:t,open:l,placement:"top",portal:!0,referenceBoundary:o,referenceElement:s,scheme:p})}const N_=(0,Es.ZP)(Co.Zb)((function(e){let{theme:t}=e;var n,i,r;const{color:o,radius:s}=t.sanity;return(0,Es.iv)(Wt||(Wt=rd(["\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 }
1\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 "])),s[2],null==(n=o.selectable)?void 0:n.primary.selected.border,null==(i=o.selectable)?void 0:i.primary.pressed.fg,null==(r=o.selectable)?void 0:r.primary.pressed.bg,o.input.default.hovered.border,o.dark?Vs.VG.purple[950].hex:Vs.VG.purple[50].hex,o.muted.caution.hovered.bg,o.muted.caution.hovered.border,o.input.invalid.enabled.bg,o.input.invalid.enabled.border,o.input.invalid.hovered.border)})),q_=Es.ZP.span(Ht||(Ht=rd(["\n display: block;\n max-width: calc(5em + 80px);\n position: relative;\n"]))),U_=(0,Es.ZP)(Co.xu)($t||($t=rd(["\n max-width: 250px;\n"])));const V_=e=>{var t;const{floatingBoundary:n,focused:i,onItemClose:r,onItemOpen:o,onPathFocus:s,path:a,readOnly:l,referenceBoundary:c,relativePath:d,renderAnnotation:u,renderBlock:p,renderCustomMarkers:h,renderField:f,renderItem:m,renderInlineBlock:g,renderInput:x,renderPreview:v,schemaType:y,selected:b,value:j}=e,{Markers:w}=Lm().__internal.components,k=(0,yl._F)(),C=ZC(a),_=UC(Ig(a)),{validation:S,hasError:T,hasInfo:I,hasWarning:P}=DC(null==_?void 0:_.node),E=k.schemaTypes.block,A=C.length>0,F=(0,vo.useMemo)((()=>({anchor:{path:d,offset:0},focus:{path:d,offset:0}})),[d]),M=(0,vo.useCallback)((()=>{yl.q$.delete(k,F,{mode:"children"}),yl.q$.focus(k)}),[F,k]),O=(0,vo.useCallback)((()=>{_&&(yl.q$.blur(k),o(_.node.path))}),[k,o,_]),R=(0,vo.useCallback)((()=>{r(),yl.q$.select(k,F),yl.q$.focus(k)}),[r,k,F]),z=Boolean(null==_?void 0:_.member.open),D=null==_?void 0:_.input,B=(null==_?void 0:_.node.path)||Ad,L=null==(t=null==_?void 0:_.elementRef)?void 0:t.current,Z=Qm(a,!0),N=(0,vo.useMemo)((()=>Z.filter((e=>(0,xo.Xy)(e.path,a)))),[a,Z]),q=(0,vo.useMemo)((()=>({__unstable_floatingBoundary:n,__unstable_referenceBoundary:c,__unstable_referenceElement:L,children:D,focused:i,onClose:R,onOpen:O,onPathFocus:s,onRemove:M,open:z,markers:C,member:null==_?void 0:_.member,parentSchemaType:E,path:B,presence:N,readOnly:Boolean(l),renderAnnotation:u,renderBlock:p,renderDefault:K_,renderField:f,renderInlineBlock:g,renderInput:x,renderItem:m,renderPreview:v,schemaType:y,selected:b,value:j,validation:S})),[n,i,D,z,C,null==_?void 0:_.member,B,R,O,s,M,E,l,c,L,u,p,f,g,x,m,v,N,y,b,S,j]),U=T||P||I||A,V=(0,vo.useMemo)((()=>U&&(0,go.jsx)(U_,{padding:2,children:(0,go.jsx)(w,{markers:C,validation:S,renderCustomMarkers:h})})||null),[w,C,h,U,S]);return(0,vo.useMemo)((()=>(0,go.jsx)("span",{ref:null==_?void 0:_.elementRef,contentEditable:!1,children:(0,go.jsx)(Co.u,{placement:"bottom",portal:"editor",disabled:!U,content:V,children:g&&(0,go.jsx)("span",{style:{position:"relative"},children:g(q)})})})),[q,null==_?void 0:_.elementRef,g,V,U])},K_=e=>{const{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,children:r,focused:o,markers:s,onClose:a,onOpen:l,onRemove:c,open:d,readOnly:u,renderPreview:p,schemaType:h,selected:f,validation:m,value:g}=e,x=s.length>0,[v,y]=(0,vo.useState)(!1),b=(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,vo.useCallback)((()=>{y(!1),l()}),[l]);(0,vo.useEffect)((()=>{y(!d&&!!o)}),[o,d]);const C=(0,vo.useMemo)((()=>j?"critical":w?"caution":f||o?"primary":void 0),[o,j,w,f]),_=(0,vo.useCallback)((()=>{y(!1)}),[]);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(N_,{"data-focused":o||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,go.jsx)(q_,{children:p({layout:"inline",schemaType:h,skipVisibilityCheck:!0,value:g,fallbackTitle:"Click to edit"})})}),i&&(0,go.jsx)(Z_,{floatingBoundary:t,onClosePopover:_,onDelete:c,onEdit:k,open:v,referenceBoundary:n,referenceElement:i,title:b}),d&&(0,go.jsx)(a_,{defaultType:"popover",onClose:a,autoFocus:o,floatingBoundary:t,referenceBoundary:n,referenceElement:i,schemaType:h,children:r})]})},H_=(0,Es.ZP)(Co.J2)(Gt||(Gt=rd(["\n &[data-popper-reference-hidden='true'] {\n display: none !important;\n }\n"]))),$_=["top","bottom"];function W_(e){const{floatingBoundary:t,onOpen:n,onRemove:i,referenceBoundary:r,referenceElement:o,title:s}=e,[a,l]=(0,vo.useState)(!1),[c,d]=(0,vo.useState)(null),[u,p]=(0,vo.useState)(null),h=(0,vo.useRef)(null),{sanity:f}=(0,Co.Fg)(),m=(0,vo.useRef)(null),g=f.color.dark?"light":"dark",x=(0,vo.useMemo)((()=>c?{getBoundingClientRect:()=>c}:null),[c]);(0,Co.qh)((0,vo.useCallback)((e=>{a&&"Escape"===e.key&&l(!1)}),[a]));const v=(0,vo.useCallback)((()=>{const e=window.getSelection();if(!e)return;const{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:r}=e;(0,vo.startTransition)((()=>p({anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:r})))}),[]);(0,vo.useEffect)((()=>(document.addEventListener("selectionchange",v,{passive:!0}),()=>{document.removeEventListener("selectionchange",v)})),[v]),(0,vo.useEffect)((()=>{var e;if(!u)return;const{anchorNode:t,focusNode:n}=u;if((null==o?void 0:o.contains(t))&&t===n){const t=null==(e=window.getSelection())?void 0:e.getRangeAt(0),n=null==t?void 0:t.getBoundingClientRect();h.current=t||null,n&&(0,vo.startTransition)((()=>d(n))),(0,vo.startTransition)((()=>l(!0)))}else n&&((0,vo.startTransition)((()=>
1{l(!1),d(null)})),h.current=null)}),[u,o]);const y=(0,vo.useCallback)((()=>{l(!1),n()}),[n]),b=(0,vo.useCallback)((()=>{l(!1),i()}),[i]);return(0,vo.useEffect)((()=>{if(!a)return;const e=()=>{h.current&&d(h.current.getBoundingClientRect())};return null==t||t.addEventListener("scroll",e,{passive:!0}),()=>{null==t||t.removeEventListener("scroll",e)}}),[a,t]),a?(0,go.jsx)(H_,{floatingBoundary:t,constrainSize:!0,content:(0,go.jsx)(Co.xu,{padding:1,children:(0,go.jsxs)(Co.gF,{space:1,children:[(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{weight:"semibold",size:1,children:s})}),(0,go.jsx)(Co.zx,{icon:Ds.dY8,mode:"bleed",onClick:y,padding:2,alt:"Edit annotation",tabIndex:0}),(0,go.jsx)(Co.zx,{icon:Ds.XHJ,mode:"bleed",padding:2,onClick:b,tone:"critical",alt:"Remove annotation",tabIndex:0})]})}),fallbackPlacements:$_,open:!0,placement:"top",portal:!0,preventOverflow:!0,ref:m,referenceBoundary:r,referenceElement:x,scheme:g}):null}const G_=Es.ZP.span((e=>{var t,n,i,r;const{$toneKey:o="default",theme:s}=e;return(0,Es.iv)(Xt||(Xt=rd(["\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=s.sanity.color.selectable)?void 0:t[o].enabled.bg,null==(n=s.sanity.color.selectable)?void 0:n[o].enabled.fg,null==(i=s.sanity.color.selectable)?void 0:i[o].enabled.fg,null==(r=s.sanity.color.selectable)?void 0:r[o].enabled.fg,s.sanity.color.dark?Vs.VG.purple[950].hex:Vs.VG.purple[50].hex,s.sanity.color.muted.caution.hovered.bg,s.sanity.color.muted.critical.hovered.bg)})),X_=(0,Es.ZP)(Co.xu).attrs({forwardedAs:"span"})(Yt||(Yt=rd(["\n max-width: 250px;\n"])));function Y_(e){var t;const{children:n,editorNodeFocused:i,floatingBoundary:r,focused:o,onItemClose:s,onItemOpen:a,onPathFocus:l,path:c,readOnly:d,referenceBoundary:u,renderAnnotation:p,renderBlock:h,renderCustomMarkers:f,renderField:m,renderInlineBlock:g,renderInput:x,renderItem:v,renderPreview:y,schemaType:b,selected:j,value:w}=e,{Markers:k=Vm}=Lm().__internal.components,C=(0,yl._F)(),_=(0,vo.useMemo)((()=>c.slice(0,c.length-2).concat(["markDefs",{_key:w._key}])),[c,w._key]),[S,T]=(0,vo.useState)(null),I=(0,vo.useMemo)((()=>c.slice(c.length-3,c.length)),[c]),P=UC(Ig(_)),{validation:E}=DC(null==P?void 0:P.node),A=ZC(c),F=(0,vo.useMemo)((()=>(0,go.jsx)("span",{"data-annotation":"",children:n})),[n]),M=(0,vo.useCallback)((()=>{P&&(yl.q$.blur(C),l(P.node.focusPath),a(P.node.path))}),[C,P,a,l]),O=(0,vo.useCallback)((()=>{s();const e=yl.q$.getSelection(C),t=(null==e?void 0:e.focus.path)&&(0,xo.Xy)(e.focus.path,I)&&e.focus.offset,n=(null==e?void 0:e.anchor.path)&&(0,xo.Xy)(e.anchor.path,I)&&e.anchor.offset;yl.q$.select(C,{anchor:{path:I,offset:n||0},focus:{path:I,offset:t||0}}),yl.q$.focus(C)}),[C,I,s]),R=(0,vo.useCallback)((()=>{yl.q$.removeAnnotation(C,b),yl.q$.focus(C)}),[C,b]),z=(0,vo.useMemo)((()=>E.length>0||A.length>0?(0,go.jsx)(Co.u,{placement:"bottom",portal:"default",content:(0,go.jsx)(X_,{padding:2,children:(0,go.jsx)(k,{markers:A,renderCustomMarkers:f,validation:E})}),children:F}):void 0),[k,A,f,F,E]),D=Qm(c,!0),B=(0,vo.useMemo)((()=>D.filter((e=>(0,xo.Xy)(e.path,c)))),[c,D]),L=Boolean(null==P?void 0:P.member.open),Z=null==P?void 0:P.input,N=(null==P?void 0:P.node.path)||Ad,q=S,U=(0,vo.useMemo)((()=>({__unstable_floatingBoundary:r,__unstable_referenceBoundary:u,__unstable_referenceElement:q,__unstable_textElementFocus:i,children:Z,focused:o,markers:A,onClose:O,onOpen:M,onPathFocus:l,onRemove:R,open:L,parentSchemaType:C.schemaTypes.block,path:N,presence:B,readOnly:Boolean(d),renderAnnotation:p,renderBlock:h,renderField:m,renderInlineBlock:g,renderInput:x,renderPreview:y,renderItem:v,renderDefault:J_,schemaType:b,selected:j,textElement:z||F,validation:E,value:w})),[C.schemaTypes.block,i,r,o,Z,L,A,z,N,O,M,l,R,d,u,q,p,h,m,g,x,v,y,B,b,j,F,E,w]),V=null==(t=b.components)?void 0:t.annotation,K=(0,vo.useCallback)((e=>{(null==P?void 0:P.elementRef)&&(P.elementRef.current=e),T(e)}
1),[P]);return(0,vo.useMemo)((()=>(0,go.jsx)("span",{ref:K,style:void 0,children:V?(0,go.jsx)(V,{...U}):(0,go.jsx)(J_,{...U})})),[V,U,K])}const J_=e=>{const{__unstable_floatingBoundary:t,__unstable_referenceBoundary:n,__unstable_referenceElement:i,children:r,focused:o,markers:s,onClose:a,onOpen:l,onRemove:c,open:d,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=s.length>0,y=(0,vo.useMemo)((()=>g?"critical":x?"caution":m?"primary":"default"),[m,g,x]);return(0,go.jsxs)(G_,{$toneKey:y,"data-link":m?"":void 0,"data-error":g?"":void 0,"data-warning":x?"":void 0,"data-markers":v||void 0,onClick:u?l:void 0,children:[h,(0,go.jsx)(W_,{floatingBoundary:t,referenceBoundary:n,referenceElement:i,onOpen:l,onRemove:c,title:p.title||p.name}),d&&(0,go.jsx)(a_,{defaultType:"popover",floatingBoundary:t,onClose:a,autoFocus:o,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:OC(e)?D_:c_}function eS(e){var t;return(null==(t=e.components)?void 0:t.inlineBlock)?e.components.inlineBlock:K_}function tS(e){var t;return(null==(t=e.components)?void 0:t.annotation)?e.components.annotation:J_}const nS=/^\d+$/;function iS(e){return e.split(/[[.\]]/g).filter(Boolean).map((e=>{return e.includes("==")?function(e){const[t,n]=e.split("==");return{[t]:(i=n,i.replace(/^['"]/,"").replace(/['"]$/,""))};var i}(e):(t=e,nS.test(t)?Number(t):t);var t}))}function rS(e){return iS(e)}Object.defineProperty;vo.Component;function oS(e){const{reference:t,children:n,observeAsset:i,waitPlaceholder:r}=e,o=null==t?void 0:t._ref,s=(0,_o.m2)((()=>i(o)),[o,i]);return(0,go.jsx)(go.Fragment,{children:o&&s?n(s):r})}function sS(e){return null===e?[]:[e]}function aS(e){return Promise.all(e.map((e=>{if("file"===e.kind&&e.webkitGetAsEntry){let n;try{n=e.webkitGetAsEntry()}catch(t){return sS(e.getAsFile())}return n?n.isDirectory?lS(n):sS(e.getAsFile()):[]}if("file"===e.kind){const 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([]))})))}function lS(e){if(e.isFile)return new Promise(((t,n)=>e.file(t,n))).then((e=>[e]));if(e.isDirectory){const t=e.createReader();return new Promise(((e,n)=>t.readEntries(e,n))).then((e=>e.filter((e=>!e.name.startsWith("."))))).then((e=>Promise.all(e.map(lS)).then(sl())))}return Promise.resolve([])}function cS(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(new Error("Cannot read image contents from webkit fake url")):new Promise(((i,r)=>{const o=new Image;o.crossOrigin="anonymous",o.referrerPolicy="strict-origin-when-cross-origin",o.onload=()=>{const e=document.createElement("canvas");e.width=o.width,e.height=o.height;const s=e.getContext("2d");null==s||s.drawImage(o,0,0,e.width,e.height);try{e.toBlob(i,t,n)}catch(a){r(a)}},o.src=e}))}const dS={opacity:0,position:"absolute"};function uS(e){return vo.forwardRef((function(t,n){const{onFiles:i,onFilesOver:r,onFilesOut:o,disabled:s,...a}=t,[l,c]=vo.useState(!1),d=vo.useRef(null),u=(0,Co.ts)(n),p=vo.useRef([]),h=(0,vo.useCallback)((e=>{null==i||i(e)}),[i]),f=(0,vo.useCallback)((e=>{e.target===u.current&&(e.ctrlKey||e.metaKey)&&"v"===e.key&&c(!0)}),[u]),m=(0,vo.useCallback)((e=>{var t;(t=e.clipboardData,t.files&&t.files.length>0?Promise.resolve(Array.from(t.files||[])):aS(Array.from(t.items||[])).then(sl())).then((e=>d.current?e.length>0?e:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg";if(!e.isContentEditable)return Promise.reject(new Error('Expected element to be contentEditable="true". Instead found a non contenteditable '.concat(e.tagName)));return new Promise((e=>setTimeout(e,10))).then((()=>Array.from(e.querySelectorAll("img")))).then((t=>(e.innerHTML="",t))).then((e=>Promise.all(e.map((e=>cS(e.src)))))).then((e=>e.map((e=>new File([e],"pasted-image.jpg",{type:t})))))}(d.current,"image/jpeg"):[])).then((e=>{var t;
1h(e),c(!1),null==(t=u.current)||t.focus()}))}),[h,u]),g=(0,vo.useCallback)((e=>{p.current=[],e.preventDefault(),e.stopPropagation();const t=e.nativeEvent.dataTransfer;i&&t&&function(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t&&t.length>0?Promise.resolve(t):aS(n).then(sl())}(t).then((e=>{e&&h(e)})),null==o||o()}),[h,i,o]),x=(0,vo.useCallback)((e=>{i&&(e.preventDefault(),e.stopPropagation())}),[i]),v=(0,vo.useCallback)((e=>{if(e.stopPropagation(),r&&u.current===e.currentTarget){p.current=[...new Set(p.current),e.currentTarget];const t=Array.from(e.dataTransfer.items).map((e=>({type:e.type,kind:e.kind})));r(t)}}),[r,u]),y=(0,vo.useCallback)((e=>{e.stopPropagation();const t=p.current.indexOf(e.currentTarget);t>-1&&p.current.splice(t,1),0===p.current.length&&(null==o||o())}),[o]),b=vo.useRef(!1);return vo.useEffect((()=>{var e;!b.current&&l&&d.current?(d.current.focus(),function(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();null==n||n.removeAllRanges(),null==n||n.addRange(t)}
1(d.current)):b.current&&!l&&(null==(e=d.current)||e.focus()),b.current=l}),[l]),(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(e,{...a,ref:u,onKeyDown:s?void 0:f,onDragOver:s?void 0:x,onDragEnter:s?void 0:v,onDragLeave:s?void 0:y,onDrop:s?void 0:g}),!s&&l&&(0,go.jsx)("div",{contentEditable:!0,onPaste:m,ref:d,style:dS})]})}))}function pS(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function hS(e){const{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,o=0-i.offset,s=t?t.bg:"var(--card-bg-color)";return[o>0&&"inset 0 0 0 ".concat(o,"px var(--card-focus-ring-color)"),n&&pS(n),o<0&&"0 0 0 ".concat(0-o,"px ").concat(s),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}function fS(e){return(0,Es.ZP)(e)((e=>{const t={width:e.$border?1:0,color:"var(--card-border-color)"};return(0,Es.iv)(Jt||(Jt=rd(["\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 "])),pS(t),(0,Co.hO)(e.theme.sanity.radius[1]),hS({base:e.theme.sanity.color.base,border:t,focusRing:e.theme.sanity.focusRing}))}))}const mS=uS(fS(Co.Zb)),gS=(0,Es.ZP)(Co.Zb)(Qt||(Qt=rd(["\n min-height: 82px;\n box-sizing: border-box;\n"]))),xS=(0,Es.ZP)(Co.kC)(en||(en=rd(["\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"]))),vS=(0,Es.ZP)(Co.Kq)(tn||(tn=rd(["\n position: relative;\n width: 60%;\n"]))),yS=(0,Es.ZP)(Co.EK)(nn||(nn=rd(["\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"])));function bS(e){let{uploadState:t,onCancel:n,onStale:i,height:r}=e;const o=t.file.name;return(0,vo.useEffect)((()=>{var e;e=t.updatedAt,(new Date).getTime()-new Date(e).getTime()>12e4&&(null==i||i())}),[t.updatedAt,i]),(0,go.jsx)(gS,{tone:"primary",padding:4,border:!0,style:{height:"".concat(r,"px")},children:(0,go.jsxs)(xS,{align:"center",justify:"space-between",height:"fill",direction:"row",gap:2,children:[(0,go.jsxs)(vS,{children:[(0,go.jsx)(Co.kC,{justify:"center",gap:[3,3,2,2],direction:["column","column","row"],children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsxs)(Co.gF,{space:2,children:["Uploading",(0,go.jsx)(yS,{size:1,children:o||"..."})]})})}),(0,go.jsx)(Co.Zb,{marginTop:3,radius:5,shadow:1,children:(0,go.jsx)(_p,{value:t.progress})})]}),n?(0,go.jsx)(Co.zx,{fontSize:2,text:"Cancel upload",mode:"ghost",tone:"critical",onClick:n}):null]})})}function jS(e,t){var n;const i=e.split(","),r=null==(n=i[0].match(/:(.*?);/))?void 0:n[1],o=atob(i[1]);let s=o.length;const a=new Uint8Array(s);for(;s--;)a[s]=o.charCodeAt(s);return new File([a],t,{type:r})}function wS(e){let{assetFromSource:t,onChange:n,type:i,resolveUploader:r,uploadWith:o,isImage:s}=e;if(!t)throw new Error("No asset given");if(!Array.isArray(t)||0===t.length)throw new Error("Returned value must be an array with at least one item (asset)");const a=t[0],l=a.assetDocumentProps,c=null==l?void 0:l.originalFilename,d=null==l?void 0:l.label,u=null==l?void 0:l.title,p=null==l?void 0:l.description,h=null==l?void 0:l.creditLine,f=null==l?void 0:l.source,m=s?[Im(["hotspot"]),Im(["crop"])]:[];switch(a.kind){case"assetDocumentId":n([_m({_type:i.name}),...m,Tm({_type:"reference",_ref:a.value},["asset"])]);break;case"file":{const e=r(i,a.value);e&&o(e,a.value,{label:d,title:u,description:p,creditLine:h,source:f});break}case"base64":(g=a.value,x=c,new Promise(((e,t)=>{const n=g.toString(),i=n.substring("data:image/".length,n.indexOf(";base64"));i||x?e(jS(g,x||"".concat((0,ul.Z)(),".").concat(i))):t(new Error("Could not find mime type for image"))}))).then((e=>{const t=r(i,e);t&&o(t,e,{label:d,title:u,description:p,creditLine:h,source:f})}));break;case"url":(function(e,t){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.onload=()=>{const e=new FileReader;e.onloadend=()=>{var r;const o=null==(r=e.result)?void 0:r.toString(),s=null==o?void 0:o.substring("data:image/".length,o.indexOf(";base64"));s||t?n(jS(e.result,t||"".concat((0,ul.Z)(),".").concat(s))):i(new Error("Could not find mime type for image"))}
1,e.readAsDataURL(r.response)},r.onerror=e=>{i(e)},r.open("GET",e),r.responseType="blob",r.send()}))})(a.value,c).then((e=>{const t=r(i,e);t&&o(t,e,{label:d,title:u,description:p,creditLine:h,source:f})}));break;default:throw new Error("Invalid value returned from asset source plugin")}var g,x}const kS=(0,Es.ZP)(Co.sN)((e=>{let{theme:t}=e;const{focusRing:n}=t.sanity,i=t.sanity.color.base;return(0,Es.iv)(rn||(rn=rd(["\n position: relative;\n\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 "])),hS({base:i,border:{width:1,color:"var(--card-border-color)"},focusRing:n}))})),CS=vo.forwardRef((function(e,t){const{icon:n,id:i,accept:r,capture:o,fontSize:s,multiple:a,onSelect:l,padding:c=3,space:d=3,textAlign:u,text:p,disabled:h,...f}=e,m="".concat(i||"","-").concat((0,vo.useId)()),g=vo.useCallback((e=>{l&&e.target.files&&l(Array.from(e.target.files))}),[l]),x=(0,go.jsxs)(Co.kC,{align:"center",justify:"flex-start",padding:c,children:[n&&(0,go.jsx)(Co.xu,{marginRight:p?d:void 0,children:(0,go.jsxs)(Co.xv,{size:s,children:[(0,vo.isValidElement)(n)&&n,(0,Us.isValidElementType)(n)&&(0,vo.createElement)(n)]})}),p&&(0,go.jsx)(Co.xv,{align:u,size:s,textOverflow:"ellipsis",children:p})]});return(0,go.jsxs)(kS,{...f,htmlFor:m,padding:0,fontSize:2,disabled:h,ref:t,children:[x,(0,go.jsx)("input",{"data-testid":"file-button-input",accept:r,capture:o,id:m,multiple:a,onChange:g,type:"file",value:"",disabled:h})]})}));function _S(e){const{onUpload:t,onReset:n,readOnly:i,accept:r,directUploads:o,browse:s,downloadUrl:a,copyUrl:l}=e,{push:c}=(0,Co.pm)(),d=(0,vo.useCallback)((()=>{navigator.clipboard.writeText(l||""),c({closable:!0,status:"success",title:"The URL is copied to the clipboard"})}),[c,l]);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Replace"})}),(0,go.jsx)(CS,{icon:Ds.rG2,mode:"bleed",onSelect:t,accept:r,text:"Upload","data-testid":"file-input-upload-button",disabled:i||!o,fontSize:2}),s,(a||l)&&(0,go.jsx)(Co.R,{}),a&&(0,go.jsx)(Co.sN,{as:"a",icon:Ds._8t,text:"Download",href:a}),l&&(0,go.jsx)(Co.sN,{icon:Ds.Kmg,text:"Copy URL",onClick:d}),(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.sN,{tone:"critical",icon:Ds.X5P,text:"Clear field",onClick:n,disabled:i,"data-testid":"file-input-clear"})]})}const SS=(0,Es.ZP)(Co.kC)(on||(on=rd(["\n pointer-events: none;\n"])));function TS(e){const{hoveringFiles:t,type:n,readOnly:i,acceptedFiles:r,rejectedFilesCount:o,directUploads:s}=e,a="file"===n,l=(0,vo.useMemo)((()=>i?(0,go.jsx)(Ds.CPA,{}):t&&o>0||!s?(0,go.jsx)(Ds.vaB,{}):a?(0,go.jsx)(Ds.bg6,{}):(0,go.jsx)(Ds.XBm,{})),[s,t,a,i,o]),c=(0,vo.useMemo)((()=>{let e="Drag or paste ".concat(n," here");return s?(i&&(e="Read only"),t&&s&&!i&&(r.length>0&&(e="Drop to upload ".concat(n)),o>0&&(e="Can't upload ".concat(o," file").concat(o>1?"s":""," here"))),e):"Can't upload files here"}),[r.length,s,t,i,o,n]);return(0,go.jsxs)(SS,{align:"center",gap:2,justify:"center",children:[(0,go.jsx)(Co.xv,{muted:!0,children:l}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:c})]})}const IS=(0,Es.ZP)(Co.zx).attrs({forwardedAs:"label"})((e=>{let{theme:t}=e;const{focusRing:n}=t.sanity,i=t.sanity.color.base;return(0,Es.iv)(sn||(sn=rd(["\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 "])),hS({base:i,border:{width:1,color:"var(--card-border-color)"},focusRing:n}))})),PS=vo.forwardRef((function(e,t){const{icon:n,id:i,accept:r,capture:o,fontSize:s,multiple:a,onSelect:l,padding:c=3,space:d=3,textAlign:u,text:p,disabled:h,...f}=e,m="".concat(i||"","-").concat((0,vo.useId)()),g=(0,Co.Fg)(),x=vo.useCallback((e=>{l&&e.target.files&&l(Array.from(e.target.files))}),[l]),v=(0,go.jsxs)(Co.kC,{align:"center",justify:"center",padding:c,children:[n&&(0,go.jsx)(Co.xu,{marginRight:p?d:void 0,children:(0,go.jsxs)(Co.xv,{size:s,children:[(0,vo.isValidElement)(n)&&n,(0,Us.isValidElementType)(n)&&(0,vo.createElement)(n)]})}),p&&(0,go.jsx)(Co.xv,{align:u,size:s,textOverflow:"ellipsis",weight:g.sanity.button.textWeight,children:p})]});return(0,go.jsxs)(IS,{...f,htmlFor:m,padding:0,fontSize:2,disabled:h,children:[v,(0,go.jsx)("input",{"data-testid":"file-button-input",accept:r,capture:o,id:m,multiple:a,onChange:x,ref:t,type:"file",value:"",disabled:h})]})}));const ES=vo.memo((function(e){const{accept:t,acceptedFiles:n,browse:i,directUploads:r,hoveringFiles:o,onUpload:s,readOnly:a,rejectedFilesCount:l,type:c}=e,[d,u]=(0,vo.useState)(null),p=(0,Co.h4)(d),h=(null==p?void 0:p.border)&&p.border.width<440;return(0,go.jsxs)(Co.kC,{align:h?void 0:"center",direction:h?"column":"row",gap:4,justify:"space-between",paddingY:h?1:void 0,ref:u,children:[(0,go.jsx)(Co.kC,{flex:1,justify:"center",children:(0,go.jsx)(TS,{acceptedFiles:n,directUploads:r,hoveringFiles:o,readOnly:a,rejectedFilesCount:l,type:c})}),(0,go.jsxs)(Co.kC,{align:"center",gap:2,justify:"center",wrap:"wrap",children:[(0,go.jsx)(PS,{accept:t,"data-testid":"file-input-upload-button",disabled:a||!r,icon:Ds.rG2,mode:"ghost",onSelect:s,text:"Upload"}),i]})]})})),AS=(0,Es.ZP)(Co.zx)(an||(an=rd(["\n width: 100%;\n"])));function FS(e){let{onClearStale:t}=e;return(0,go.jsxs)(Co.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,go.jsxs)(Co.kC,{gap:4,marginBottom:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"Incomplete upload"}),(0,go.jsx)(Co.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,go.jsx)(AS,{icon:Ds.X5P,text:"Clear upload",onClick:t,mode:"ghost"})]})}const MS=(0,Es.ZP)(Co.Zb)(ln||(ln=rd(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),OS=(0,Es.ZP)(Co.kC)(cn||(cn=rd(["\n height: 100%;\n"])));function RS(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===e)return"0 Bytes";const n=1024,i=t<0?0:t,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(e)/Math.log(n));return"".concat(parseFloat((e/Math.pow(n,o)).toFixed(i))," ").concat(r[o])}function zS(e){const{originalFilename:t,size:n,children:i,muted:r,disabled:o,onClick:s,isMenuOpen:a,onMenuOpen:l,setMenuButtonElement:c}=e,[d,u]=(0,vo.useState)(null),[p,h]=(0,vo.useState)(null),f=(0,vo.useCallback)((()=>l(!0)),[l]),m=(0,vo.useCallback)((e=>{c(e),h(e)}),[c]);return(0,Co.qh)((0,vo.useCallback)((e=>{!a||"Escape"!==e.key&&"Tab"!==e.key||(l(!1),null==p||p.focus())}),[a,l,p])),(0,Co.O8)((0,vo.useCallback)((()=>l(!1)),[l]),[d]),(0,go.jsxs)(Co.kC,{wrap:"nowrap",justify:"space-between",align:"center",children:[(0,go.jsx)(Co.Zb,{as:r||o?void 0:"button",radius:2,padding:2,tone:"inherit",onClick:s,flex:1,children:(0,go.jsxs)(Co.kC,{wrap:"nowrap",align:"center",children:[(0,go.jsx)(Co.Zb,{padding:3,tone:"transparent",shadow:1,radius:1,children:(0,go.jsx)(Co.xv,{muted:r,children:(0,go.jsx)(Ds.bg6,{})})}),(0,go.jsxs)(Co.Kq,{flex:1,space:2,marginLeft:3,children:[(0,go.jsx)(Co.xv,{size:2,textOverflow:"ellipsis",muted:r,"data-testid":"file-name",children:t}),(0,go.jsx)(Co.xv,{size:1,muted:!0,"data-testid":"file-size",children:RS(n)})]})]})}),(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.kC,{justify:"center",children:(0,go.jsx)(Co.J2,{content:(0,go.jsx)(Co.v2,{ref:u,shouldFocus:"first",children:i}),portal:!0,open:a,children:(0,go.jsx)(Co.zx,{"data-testid":"options-menu-button",icon:Ds.zGg,mode:"bleed",onClick:f,ref:m})})})})]})}function DS(){return(0,go.jsxs)(Co.kC,{align:"center",justify:"flex-start",padding:2,children:[(0,go.jsx)(Co.Od,{padding:3,radius:1,animated:!0}),(0,go.jsxs)(Co.Kq,{flex:1,space:2,marginLeft:3,children:[(0,go.jsx)(Co.JQ,{style:{width:"100%"},radius:1,animated:!0}),(0,go.jsx)(Co.JQ,{style:{width:"100%"},radius:1,animated:!0})]})]})}const BS=(0,Es.ZP)(Co.zx)(dn||(dn=rd(["\n width: 100%;\n"])));function LS(e){let{onClearValue:t}=e;return(0,go.jsxs)(Co.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,go.jsxs)(Co.kC,{gap:4,marginBottom:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"Invalid file value"}),(0,go.jsx)(Co.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,go.jsx)(BS,{icon:Ds.X5P,text:"Reset value",onClick:t,mode:"ghost"})]})}var ZS=Object.defineProperty,NS=(e,t,n)=>(((e,t,n)=>{t in e?ZS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);function qS(e){let{children:t}=e;return t}const US=["asset"];class VS extends vo.PureComponent{constructor(e){var t;super(e),t=this,NS(this,"_assetFieldPath"),NS(this,"uploadSubscription",null),NS(this,"browseButtonElement",null),NS(this,"state",{isUploading:!1,selectedAssetSource:null,hoveringFiles:[],isStale:!1,isMenuOpen:!1}),NS(this,"toast",null),NS(this,"handleRemoveButtonClick",(()=>{const{path:e,value:t}=this.props,n="string"!==typeof e.slice(-1)[0],i=Object.keys(t||{}),r=0===i.filter((e=>!["_type","_key","_upload","asset"].includes(e))).length,o=["asset"].concat(i.filter((e=>["_upload"].includes(e)))).map((e=>Im([e])));this.props.onChange(Am.from(r&&!n?Im():o))})),NS(this,"handleCancelUpload",(()=>{this.cancelUpload()})),NS(this,"handleClearUploadState",(()=>{this.setState({isStale:!1}),this.clearUploadStatus()})),NS(this,"handleStaleUpload",(()=>{this.setState({isStale:!0})}
1)),NS(this,"handleClearField",(()=>{this.props.onChange(Im(["asset"]))})),NS(this,"handleSelectFiles",(e=>{const{directUploads:t,readOnly:n}=this.props,{hoveringFiles:i}=this.state;t&&!n?this.uploadFirstAccepted(e):i.length>0&&this.handleFilesOut()})),NS(this,"handleSelectFileFromAssetSource",(e=>{this.setState({selectedAssetSource:e})})),NS(this,"handleAssetSourceClosed",(()=>{var e;this.setState({selectedAssetSource:null}),null==(e=this.browseButtonElement)||e.focus()})),NS(this,"setBrowseButtonElement",(e=>{this.browseButtonElement=e})),NS(this,"uploadWith",(function(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{schemaType:r,onChange:o,client:s}=t.props,{source:a}=i,l={metadata:ic()(r,"options.metadata"),storeOriginalFilename:ic()(r,"options.storeOriginalFilename"),source:a};t.cancelUpload(),t.setState({isUploading:!0}),o(Am.from([_m({_type:r.name})])),t.uploadSubscription=e.upload(s,n,r,l).subscribe({next:e=>{e.patches&&o(Am.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})}})})),NS(this,"handleSelectAssetFromSource",(e=>{const{onChange:t,schemaType:n,resolveUploader:i}=this.props;wS({assetFromSource:e,onChange:t,type:n,resolveUploader:i,uploadWith:this.uploadWith}),this.setState({selectedAssetSource:null})})),NS(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)})),NS(this,"handleFilesOver",(e=>{this.setState({hoveringFiles:e})})),NS(this,"handleFilesOut",(()=>{this.setState({hoveringFiles:[]})})),NS(this,"handleUpload",(e=>{let{file:t,uploader:n}=e;this.uploadWith(n,t)})),NS(this,"setToast",(e=>{this.toast=e})),this._assetFieldPath=e.path.concat(US)}clearUploadStatus(){var e;(null==(e=this.props.value)?void 0:e._upload)&&this.props.onChange(Am.from([Im(["_upload"])]))}cancelUpload(){this.uploadSubscription&&(this.uploadSubscription.unsubscribe(),this.clearUploadStatus())}uploadFirstAccepted(e){const{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){const{isUploading:t}=this.state;return(0,go.jsx)(bS,{uploadState:e,onCancel:t?this.handleCancelUpload:void 0,onStale:this.handleStaleUpload})}renderAssetSource(){const{selectedAssetSource:e}=this.state,{value:t,schemaType:n,observeAsset:i}=this.props;if(!e)return null;const r=ic()(n,"options.accept",""),o=e.component;return t&&t.asset?(0,go.jsx)(oS,{observeAsset:i,reference:t.asset,waitPlaceholder:(0,go.jsx)(DS,{}),children:e=>(0,go.jsx)(o,{selectedAssets:[e],selectionType:"single",assetType:"file",accept:r,dialogHeaderTitle:"Select file",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}):(0,go.jsx)(o,{selectedAssets:[],selectionType:"single",assetType:"file",accept:r,dialogHeaderTitle:"Select file",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}renderAsset(){const{value:e,changed:t,readOnly:n,elementProps:i}=this.props,{hoveringFiles:r,isStale:o}=this.state,s=Boolean((null==e?void 0:e._upload)||(null==e?void 0:e.asset));return!e||"undefined"===typeof e.asset||(null==e?void 0:e._upload)||(0,qa.OT)(e)?a=>(0,go.jsxs)(go.Fragment,{children:[o&&(0,go.jsx)(Co.xu,{marginBottom:2,children:(0,go.jsx)(FS,{onClearStale:this.handleClearUploadState})}),(0,go.jsx)(nu,{path:this._assetFieldPath,hasFocus:!!a.focused,isChanged:t,children:(null==e?void 0:e._upload)?this.renderUploadState(e._upload):(0,go.jsx)(mS,{...i,onFocus:this.handleFileTargetFocus,tabIndex:0,disabled:Boolean(n),onFiles:this.handleSelectFiles,onFilesOver:this.handleFilesOver,onFilesOut:this.handleFilesOut,tone:this.getFileTone(),$border:s||r.length>0,style:{padding:1},sizing:"border",radius:2,children:(0,go.jsxs)("div",{style:{position:"relative"},children:[!(null==e?void 0:e.asset)&&this.renderUploadPlaceholder(),(null==e?void 0:e.asset)&&r.length>
10?this.renderAssetMenu(this.getFileTone()):null,!(null==e?void 0:e._upload)&&(null==e?void 0:e.asset)&&this.renderPreview()]})})})]}):()=>(0,go.jsx)(LS,{onClearValue:this.handleClearField})}renderPreview(){const{value:e,readOnly:t,assetSources:n,schemaType:i,directUploads:r,observeAsset:o}=this.props,{isMenuOpen:s}=this.state,a=null==e?void 0:e.asset;if(!a)return null;const l=ic()(i,"options.accept","");let c=n&&0===(null==n?void 0:n.length)?null:(0,go.jsx)(Co.sN,{icon:Ds.W1M,text:"Browse",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(n[0])},disabled:t,"data-testid":"file-input-browse-button"});return n.length>1&&(c=n.map((e=>(0,go.jsx)(Co.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e)},icon:e.icon||Ds.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)},e.name)))),(0,go.jsx)(oS,{reference:a,observeAsset:o,waitPlaceholder:(0,go.jsx)(DS,{}),children:n=>{let{originalFilename:i,extension:o,url:a,size:d}=n;const u=i||"download.".concat(o);let p,h;return(0,qa.OT)(e)&&(h="".concat(a,"?dl"),p=a),(0,go.jsx)(zS,{size:d,originalFilename:u,muted:!t,onMenuOpen:e=>this.setState({isMenuOpen:e}),isMenuOpen:s,setMenuButtonElement:this.setBrowseButtonElement,children:(0,go.jsx)(_S,{onUpload:this.handleSelectFiles,browse:c,onReset:this.handleRemoveButtonClick,downloadUrl:h,copyUrl:p,readOnly:t,accept:l,directUploads:r})})}})}renderAssetMenu(e){const{schemaType:t,readOnly:n,directUploads:i,resolveUploader:r}=this.props,{hoveringFiles:o}=this.state,s=o.filter((e=>null==r?void 0:r(t,e))),a=o.length-s.length;return(0,go.jsx)(MS,{tone:e,children:(0,go.jsx)(OS,{align:"center",justify:"center",gap:2,flex:1,children:(0,go.jsx)(TS,{readOnly:n,hoveringFiles:o,acceptedFiles:s,rejectedFilesCount:a,directUploads:i,type:"file"})})})}renderBrowser(){const{assetSources:e,readOnly:t,directUploads:n,id:i}=this.props;return 0===e.length?null:e.length>1&&!t&&n?(0,go.jsx)(Co.j2,{id:"".concat(i,"_assetFileButton"),ref:this.setBrowseButtonElement,button:(0,go.jsx)(Co.zx,{mode:"ghost",text:"Select","data-testid":"file-input-multi-browse-button",icon:Ds.W1M}),"data-testid":"input-select-button",menu:(0,go.jsx)(Co.v2,{children:e.map((e=>(0,go.jsx)(Co.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e)},icon:e.icon||Ds.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)},e.name)))})}):(0,go.jsx)(Co.zx,{fontSize:2,text:"Browse",icon:Ds.W1M,mode:"ghost",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectFileFromAssetSource(e[0])},"data-testid":"file-input-browse-button",disabled:t,ref:this.setBrowseButtonElement})}renderUploadPlaceholder(){const{readOnly:e,schemaType:t,directUploads:n,resolveUploader:i}=this.props,{hoveringFiles:r}=this.state,o=r.filter((e=>null==i?void 0:i(t,e))),s=r.length-o.length,a=ic()(t,"options.accept","");return(0,go.jsx)("div",{style:{padding:1},children:(0,go.jsx)(Co.Zb,{tone:e?"transparent":"inherit",border:!0,padding:3,style:0===r.length?{borderStyle:"dashed"}:{borderStyle:"dashed",borderColor:"transparent"},children:(0,go.jsx)(ES,{browse:this.renderBrowser(),onUpload:this.handleSelectFiles,readOnly:e,hoveringFiles:r,acceptedFiles:o,rejectedFilesCount:s,type:"file",accept:a,directUploads:n})})})}getFileTone(){const{directUploads:e,schemaType:t,value:n,readOnly:i,resolveUploader:r}=this.props,{hoveringFiles:o}=this.state,s=o.filter((e=>null==r?void 0:r(t,e))),a=o.length-s.length;return o.length>0&&(a>0||!e)?"critical":!(null==n?void 0:n._upload)&&!i&&o.length>0?"primary":(null==n?void 0:n._upload)&&(null==n?void 0:n.asset)&&i?"transparent":"default"}render(){const{members:e,renderAnnotation:t,renderBlock:n,renderInlineBlock:i,renderItem:r,renderInput:o,renderField:s,renderPreview:a}=this.props,{selectedAssetSource:l}=this.state;return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Jp,{ref:this.setToast}),e.map((e=>"field"!==e.kind||"crop"!==e.name&&"hotspot"!==e.name?"field"===e.kind?(0,go.jsx)(Ck,{member:e,renderAnnotation:t,renderInlineBlock:i,renderBlock:n,renderInput:"asset"===e.name?this.renderAsset():o,renderField:"asset"===e.name?qS:s,renderItem:r,renderPreview:a},e.key):"fieldSet"===e.kind?(0,go.jsx)(Vk,{member:e,renderAnnotation:t,renderBlock:n,renderField:s,renderInlineBlock:i,renderInput:o,renderItem:r,renderPreview:a},e.key):"error"===e.kind?(0,go.jsx)(Uk,{member:e},e.key):(0,go.jsxs)(go.Fragment,{children:["Unknown member kind: $",e.kind]}):null)),l&&this.renderAssetSource()]})}}const KS=(0,Es.ZP)(Co.xu)(un||(un=rd(["\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"])),(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 HS(e){const{src:t,children:n}=e,[i,r]=(0,vo.useState)(!0),[o,s]=(0,vo.useState)(null),[a,l]=(0,vo.useState)(null);return(0,vo.useEffect)((()=>{s(null),l(null),r(!0);const e=new Image;e.onload=()=>{s(e),l(null),r(!1)},e.onerror=()=>{l(new Error("Could not load image from ".concat(JSON.stringify(t)))),r(!1)}
1,e.referrerPolicy="strict-origin-when-cross-origin",e.src=t}),[t]),n({image:o,error:a,isLoading:i})}const $S=["","webkit","moz","ms","o"].map((e=>"".concat(e,"backingStoreRatio")));let WS=-1;function GS(e,t){const n=t.center.x,i=t.center.y,r=t.width/2,o=t.height/2;if(r<=0||o<=0)return!1;const s={x:e.x-n,y:e.y-i};return Math.pow(s.x,2)/Math.pow(r,2)+Math.pow(s.y,2)/Math.pow(o,2)<=1}function XS(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 YS(e,t){return e.x>=t.left&&e.x<=t.left+t.width&&e.y>=t.top&&e.y<=t.top+t.height}function JS(e,t){return{x:t.center.x-t.width/2*Math.cos(e),y:t.center.y-t.height/2*Math.sin(e)}}var QS=Object.defineProperty,eT=(e,t,n)=>(((e,t,n)=>{t in e?QS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class tT{constructor(e,t){eT(this,"x"),eT(this,"y"),this.x=e,this.y=t}}class nT{constructor(e,t,n){eT(this,"y"),eT(this,"_left"),eT(this,"_right"),this.y=e,this._left=t,this._right=n}get right(){return new tT(this._right,this.y)}get left(){return new tT(this._left,this.y)}get length(){return this._right-this._left}}class iT{constructor(e){eT(this,"rect"),this.rect=e}get top(){return new nT(this.rect.top,this.rect.left,this.rect.right)}get bottom(){return new nT(this.rect.bottom,this.rect.left,this.rect.right)}}class rT{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;eT(this,"left"),eT(this,"top"),eT(this,"width"),eT(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 rT(t,i,1-t-n,1-i-r)}setTopLeft(e,t){return new rT(e,t,this.width||0,this.height||0)}setSize(e,t){return new rT(this.left||0,this.top||0,e,t)}setCenter(e,t){const n=this.width||0,i=this.height||0;return new rT(e-n/2,t-i/2,n||0,i||0)}get center(){return new tT(this.left+this.width/2,this.top+this.height/2)}get corners(){return new iT(this)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}multiply(e){return new rT((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 rT(this.left-e,this.top-e,this.width+2*e,this.height+2*e)}shrink(e){return this.grow(-e)}cropRelative(e){const 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 rT(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 rT(Math.max(t,e.left),Math.max(n,e.top),i,r)}}var oT=Object.defineProperty,sT=(e,t,n)=>(((e,t,n)=>{t in e?oT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);const aT=pc()("sanity-imagetool");function lT(e,t,n){return{x:e-n.left,y:t-n.top}}function cT(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}}const dT=(uT="canvas",class extends vo.PureComponent{constructor(){super(...arguments),sT(this,"domNode",null),sT(this,"currentPos",null),sT(this,"isDragging",!1),sT(this,"handleTouchMove",(e=>{this.isDragging&&e.preventDefault()})),sT(this,"handleDragStart",(e=>{const{onDragStart:t,readOnly:n}=this.props;if(n||!this.domNode)return;if(this.isDragging)return void aT("Start cancelled, already a drag in progress");this.isDragging=!0;const i=cT(e);aT("Drag started %o",i),t(lT(i.x,i.y,this.domNode.getBoundingClientRect())),this.currentPos=i})),sT(this,"handleDrag",(e=>{if(!this.isDragging||this.props.readOnly||!this.currentPos)return;const{onDrag:t}=this.props,n=cT(e),i=(r=n,o=this.currentPos,{x:r.x-o.x,y:r.y-o.y});var r,o;t(i),aT("moving by %o",i),this.currentPos=n})),sT(this,"handleDragEnd",(e=>{const{onDragEnd:t,readOnly:n}=this.props;if(!this.isDragging||n||!this.domNode)return;const i=cT(e);t(lT(i.x,i.y,this.domNode.getBoundingClientRect())),this.isDragging=!1,this.currentPos=null,aT("Done moving %o",i)})),sT(this,"handleDragCancel",(()=>{if(!this.isDragging||this.props.readOnly||!this.currentPos||!this.domNode)return;const{onDragEnd:e}=this.props;this.isDragging=!1,e(lT(this.currentPos.x,this.currentPos.y,this.domNode.getBoundingClientRect())),this.currentPos=null})),sT(this,"setDomNode",(e=>{this.domNode=e}))}componentDidMount(){Kd?(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(){Kd?(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(){const{readOnly:e,onDragStart:t,onDragEnd:n,onDrag:i,...r}=this.props;
1return(0,go.jsx)(uT,{ref:this.setDomNode,onTouchStart:e?void 0:this.handleDragStart,onMouseDown:e?void 0:this.handleDragStart,onTouchMove:e?void 0:this.handleDrag,...r})}});var uT;const pT=Es.ZP.div(pn||(pn=rd(["\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n"]))),hT=(0,Es.ZP)(dT)(hn||(hn=rd(["\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"]))),fT={x:.5,y:.5,height:1,width:1},mT={top:0,left:0,right:0,bottom:0};var gT=Object.defineProperty,xT=(e,t,n)=>(((e,t,n)=>{t in e?gT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);function vT(e,t){const{top:n,right:i,bottom:r,left:o}=e.crop||mT;return{value:{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:o+(t.left||0)>0?o:0}},delta:{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:o+(t.left||0)>0&&t.left||0}}}const yT=$s()((()=>{const e=window.devicePixelRatio||1,t=document.createElement("canvas").getContext("2d");var n;return e/(t&&(n=t,-1===WS&&(WS=$S.find((e=>e in n))),WS&&n[WS])||1)})),bT=["left","right","top","topLeft","topRight","bottom","bottomLeft","bottomRight"];class jT extends vo.PureComponent{constructor(){super(...arguments),xT(this,"state",{cropping:!1,cropMoving:!1,moving:!1,resizing:!1,mousePosition:null}),xT(this,"canvas"),xT(this,"handleDragStart",(e=>{let{x:t,y:n}=e;const i={x:t*this.getScale(),y:n*this.getScale()},r=GS(i,this.getHotspotRect()),o=XS(i,this.getDragHandleCoords()),s=this.getActiveCropHandleFor(i),a=YS(i,this.getCropRect());s?this.setState({cropping:s}):o?this.setState({resizing:!0}):r?this.setState({moving:!0}):a&&this.setState({cropMoving:!0})})),xT(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)})),xT(this,"handleDragEnd",(()=>{const{onChange:e,onChangeEnd:t}=this.props;this.setState({moving:!1,resizing:!1,cropping:!1,cropMoving:!1});const{hotspot:n,crop:i}=this.getClampedValue(),r=function(e){const 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),o={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(o),t&&t(o)})),xT(this,"handleMouseOut",(()=>{this.setState({mousePosition:null})})),xT(this,"handleMouseMove",(e=>{const t=e.currentTarget.getBoundingClientRect();this.setState({mousePosition:{x:(e.clientX-t.left)*this.getScale(),y:(e.clientY-t.top)*this.getScale()}})})),xT(this,"setCanvas",(e=>{this.canvas=e}))}getHotspotRect(){const{value:e,image:t}=this.props,n=e.hotspot||fT,i=(new rT).setSize(n.width,n.height).setCenter(n.x,n.y);return(new rT).setSize(t.width,t.height).shrink(8*this.getScale()).multiply(i)}getCropRect(){const{value:e,image:t}=this.props;return(new rT).setSize(t.width,t.height).shrink(8*this.getScale()).cropRelative(rT.fromEdges(e.crop||mT).clamp(new rT(0,0,1,1)))}getCropHandles(){const e=this.getCropRect(),t=12*this.getScale(),n=t/2,i=new rT(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;const i=this.getCropHandles();for(const r of bT)if(YS({x:t,y:n},i[r]))return r;return!1}emitMove(e){const{image:t,value:n,onChange:i}=this.props,r=this.getScale();i(function(e,t){const n=e&&e.hotspot||fT;return{...e,hotspot:{...n,x:n.x+t.x,y:n.y+t.y}}}(n,{x:e.x*r/t.width,y:e.y*r/t.height}))}emitCropMove(e){const{image:t,onChange:n,value:i}=this.props,r=this.getScale(),o={left:e.x*r/t.width,right:-e.x*r/t.width,top:e.y*r/t.height,bottom:-e.y*r/t.height};
1(function(e,t){return!(!e||!e.crop||e.crop.top+t.top<0||e.crop.left+t.left<0||e.crop.right+t.right<0||e.crop.bottom+t.bottom<0)})(i,o)&&n(wT(i,o))}emitCrop(e,t){const{image:n,onChange:i,value:r}=this.props,o=this.getScale();let s=0,a=0,l=0,c=0;"left"==e||"topLeft"===e||"bottomLeft"===e?s=t.x*o/n.width:"right"!=e&&"topRight"!==e&&"bottomRight"!==e||(a=-t.x*o/n.width),"top"==e||"topLeft"===e||"topRight"===e?l=t.y*o/n.height:"bottom"!=e&&"bottomLeft"!==e&&"bottomRight"!==e||(c=-t.y*o/n.height);const d={left:s,right:a,top:l,bottom:c};i(wT(vT(r,d).value,vT(r,d).delta))}emitResize(e){const{image:t,onChange:n,value:i}=this.props,r=this.getScale(),o={x:e.x*r*2/t.width,y:e.y*r*2/t.height};n(function(e,t){const n=e&&e.hotspot||fT;return{...e,hotspot:{...n,height:n.height+t.height,width:n.width+t.width}}}(i,{height:o.y,width:o.x}))}getClampedValue(){const e=this.props.value,t=rT.fromEdges(e.crop||mT).clamp(new rT(0,0,1,1)),n=e.hotspot||fT;return{crop:t,hotspot:new rT(0,0,1,1).setSize(n.width,n.height).setCenter(n.x,n.y).clamp(t)}}paintHotspot(e,t){const{image:n,readOnly:i}=this.props,r=(new rT).setSize(n.width,n.height),{hotspot:o,crop:s}=this.getClampedValue(),a=this.getScale(),l=8*a;function c(t,i,r,o,s,a,l,c){e.save(),e.drawImage(n,t,i,r,o,s,a,l,c),e.restore()}e.save(),function(){const t=r.cropRelative(s),n=r.shrink(l).cropRelative(s);e.save(),c(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();const n=r.shrink(l).multiply(o),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*a,e.stroke(),e.closePath(),e.restore()}(),e.clip(),function(){const e=r.multiply(o),t=r.shrink(l).multiply(o);c(e.left,e.top,e.width,e.height,t.left,t.top,t.width,t.height)}(),e.restore(),i||function(t){e.save();const n=10*a,i=r.shrink(l).multiply(o),s=JS(t,i);e.beginPath(),e.arc(s.x,s.y,n,0,2*Math.PI,!1),e.fillStyle="rgb(255,255,255)",e.fill(),e.closePath(),e.restore(),e.beginPath(),e.arc(s.x,s.y,n,0,2*Math.PI,!1),e.strokeStyle="rgb(0, 0, 0)",e.lineWidth=.5*a,e.stroke(),e.closePath()}(1.25*Math.PI)}getActualSize(){var e;const t=null==(e=this.canvas)?void 0:e.domNode;return t?{height:t.clientHeight,width:t.clientWidth}:{height:0,width:0}}getDragHandleCoords(){const e=this.getHotspotRect(),t=JS(1.25*Math.PI,e);return{x:t.x,y:t.y,radius:8*this.getScale()}}debug(e){e.save();const{image:t}=this.props,n=this.getHotspotRect(),i=this.getScale(),r=8*i;function o(e){a(e,r,e,t.height-r)}function s(e){a(r,e,t.width-r,e)}function a(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)",o(n.center.x),s(n.center.y),e.strokeStyle="rgba(150, 150, 150, 0.5)",s(n.top),s(n.bottom),o(n.left),o(n.right),e.restore()}
1paintBackground(e){const{image:t}=this.props,n=(new rT).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){const{readOnly:t}=this.props;e.save();const n=yT();e.scale(n,n);const 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;const{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){const 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();const n=this.getCropHandles();bT.forEach((i=>{e.fillStyle=this.state.cropping===i?"rgba(202, 54, 53, ".concat(t,")"):"rgba(230, 230, 230, ".concat(t+.4,")");const{left:r,top:o,height:s,width:a}=n[i];e.fillRect(r,o,a,s),e.beginPath(),e.fillStyle="rgba(66, 66, 66, ".concat(t,")"),e.rect(r,o,a,s),e.closePath(),e.stroke()})),e.restore()}getScale(){const e=this.getActualSize();return this.props.image.width/e.width}getCursor(){const{mousePosition:e}=this.state,{readOnly:t}=this.props;if(!e||t)return"auto";const 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";const i=XS(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");const r=GS(e,this.getHotspotRect()),o=YS(e,this.getCropRect());return r||o?"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;const e=this.canvas.domNode,t=e.getContext("2d");if(!t)return;this.paint(t);const n=e.style.cursor,i=this.getCursor();n!==i&&(e.style.cursor=i)}render(){const{image:e,readOnly:t}=this.props,n=yT();return(0,go.jsx)(pT,{children:(0,go.jsx)(hT,{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 wT(e,t){const n=e&&e.crop||mT;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 kT(e){const{image:t,maxHeight:n,maxWidth:i,children:r}=e,[o]=(0,vo.useState)((()=>{const e=document.createElement("canvas");return e.style.display="none",e}));(0,vo.useEffect)((()=>(document.body.appendChild(o),()=>{document.body.removeChild(o)})),[o]);return r((0,vo.useCallback)(((e,t,n)=>{const i=e.width/e.height,r=Math.min(e.width,n),s=Math.min(e.height,t),a=e.width>e.height,l=a?r:s*i,c=a?r/i:s;o.width=l,o.height=c;const d=o.getContext("2d");return d&&d.drawImage(e,0,0,e.width,e.height,0,0,l,c),o}),[o])(t,n,i))}function CT(e){return(0,go.jsx)(HS,{src:e.src,children:t=>{let{isLoading:n,image:i,error:r}=t;return n?(0,go.jsx)("div",{children:"Loading..."}):r?(0,go.jsx)("div",{children:r.message}):i?(0,go.jsx)(kT,{image:i,maxHeight:CT.maxHeight,maxWidth:CT.maxWidth,children:t=>(0,go.jsx)(jT,{image:t,...e})}):null}})}function _T(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 new Error("Height and width must be numbers, got ".concat(JSON.stringify(e)));return e.width/e.height}return null}function ST(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;const n=Math.pow(10,t);return Math.round(e*n)/n}
1function TT(e,t,n){const i=t.crop,r=n.aspect,o=n.align,s=1-i.left-i.right,a=1-i.top-i.bottom,l={top:-i.top/a,left:-i.left/s,width:1/s,height:1/a},c=s/a*e,d=(t.hotspot.x-i.left)/s,u=(t.hotspot.y-i.top)/a,p=t.hotspot.height/a,h=t.hotspot.width/s,f=1/h,m=1/p*c/r,g=Math.min(f,m);let x;const v=c<=r;let y,b;if(x=v?1:c/r,x>g){let e;y="letterbox";const t=x-g;e=v?1-t:g,b={width:e,height:e/c*r,left:0,top:0};const n=d*b.width-h*b.width/2;switch(o.x){case"left":b.left=v?0:-n;break;case"right":b.left=v?1-b.width:n;break;case"center":b.left=v?(1-b.width)/2:-n;break;default:throw new Error("Invalid x alignment: '".concat(o.x,"'. Must be either 'left', 'right' or 'center'"))}const i=u*b.height-p*b.height/2;switch(o.y){case"top":b.top=v?-i:0;break;case"bottom":b.top=i;break;case"center":b.top=v?-i:(1-b.height)/2;break;default:throw new Error("Invalid y alignment: '".concat(o.y,"'. Must be either 'top', 'bottom' or 'center'"))}}else if(v){y="full_width";let e=-u/c*r+.5;const t=x/c*r;e>0?e=0:-e>t-1&&(e=-(t-1)),b={width:x,height:t,left:0,top:e}}else{y="full_height";const e=x;let t=.5-d*x;t>0?t=0:-t>e-1&&(t=-(e-1)),b={width:e,height:x/c*r,top:0,left:t}}return{method:y,crop:b,image:l}}function IT(e){const t=1-e.top-e.bottom;return(1-e.left-e.right)/t}function PT(e){return 0===e?0:"".concat(e,"%")}function ET(e){return PT(ST(100*e))}CT.maxHeight=500,CT.maxWidth=1e3;const AT=Es.ZP.div(fn||(fn=rd(["\n position: relative;\n width: 100%;\n"]))),FT=pc()("sanity-imagetool");const MT=(0,vo.memo)((function(e){const{alignX:t="center",alignY:n="center",alt:i,aspectRatio:r="none",className:o="",crop:s=mT,hotspot:a=fT,onError:l,onLoad:c,src:d,srcAspectRatio:u,srcSet:p,style:h}=e,[f,m]=(0,vo.useState)(null),g=(0,vo.useRef)(null),x=(0,vo.useRef)(null),v=(0,vo.useCallback)((()=>{if(g.current)if("auto"===r){const e=g.current.parentNode;(0,vo.startTransition)((()=>m(e.offsetWidth/e.offsetHeight)))}else m(null)}),[r]);(0,vo.useEffect)((()=>{const e=x.current;return e&&e.src&&e.complete&&void 0!==e.naturalWidth&&(FT("Image '%s' already loaded, refreshing (from cache) to trigger onLoad / onError",d),e.src=e.src),v(),window.addEventListener("resize",v),()=>{window.removeEventListener("resize",v)}}),[d,v]);const y=(0,vo.useMemo)((()=>"none"===r?s?function(e,t){const n=1/t,i=t*n;return(i-(e.left+e.right)*i)/(n-(e.top+e.bottom)*n)}(s,u):u:"auto"===r?f:r||null),[r,f,s,u]),b=(0,vo.useMemo)((()=>function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=_T(e.image)||1,n=e.hotspot||fT,i=e.crop||mT,r=_T(e.container)||t*IT(i),o=e.align||{x:"center",y:"center"},s=TT(t,{hotspot:n,crop:i},{aspect:r,align:o}),a=PT(ST(100/r));return{debug:{result:s},container:{overflow:"hidden",position:"relative",width:"100%",height:a},padding:{marginTop:a},crop:{position:"absolute",overflow:"hidden",height:ET(s.crop.height),width:ET(s.crop.width),top:ET(s.crop.top),left
1:ET(s.crop.left)},image:{position:"absolute",height:ET(s.image.height),width:ET(s.image.width),top:ET(s.image.top),left:ET(s.image.left)}}}({container:{aspectRatio:y||u},image:{aspectRatio:u},hotspot:a,crop:s,align:{x:t,y:n}})),[t,n,s,a,u,y]);return(0,go.jsx)(AT,{className:"".concat(o),style:h,ref:g,children:(0,go.jsxs)("div",{style:b.container,children:[(0,go.jsx)("div",{style:b.padding}),(0,go.jsx)("div",{style:b.crop,children:(0,go.jsx)("img",{ref:x,src:d,alt:i,srcSet:p,onLoad:c,onError:l,style:b.image})})]})})}));const OT={isLoading:!0};function RT(e){const[t,n]=(0,vo.useState)(OT);return(0,vo.useEffect)((()=>{n(OT);const t=(i=e,new zo.y((e=>{const t=document.createElement("img");let n=!1;return t.onload=()=>{n=!0,e.next(t),e.complete()},t.onerror=()=>{n=!0,e.error(new Error("Could not load image from ".concat(function(e){return e.startsWith("blob:")}(i)?"blob":i)))},t.src=i,()=>{t.onload=null,t.onerror=null,n||(t.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=")}}))).subscribe({error:e=>{n({isLoading:!1,error:e})},next:e=>{n({image:e,isLoading:!1})}});var i;return()=>{t.unsubscribe()}}),[e]),t}const zT=["hotspot"],DT=[["3:4",3/4],["Square",1],["16:9",16/9],["Panorama",4]],BT={crop:mT,hotspot:fT},LT=Es.ZP.div(mn||(mn=rd(["\n min-height: 6em;\n"])));function ZT(e){return(0,go.jsx)(Co.kC,{align:"center",justify:"center",padding:4,style:{overflowWrap:"break-word"},children:e.children})}function NT(e){const{imageUrl:t,value:n,changed:i,level:r,path:o,focusPath:s=Ad,presence:a,onChange:l,schemaType:c,onPathFocus:d,readOnly:u,elementProps:p}=e,[h,f]=(0,vo.useState)(n||BT),{image:m,isLoading:g,error:x}=RT(t),v=(0,vo.useCallback)((()=>{d(zT)}),[d]);(0,vo.useEffect)((()=>{f(n||BT)}),[n]);const y="hotspot"===s[0];zm(y,(e=>{var t;!e&&y&&(null==(t=p.ref.current)||t.focus())}));const b=(0,vo.useCallback)((e=>{if(u)return;const t=c.fields.find((e=>"crop"===e.name&&"object"!==e.type.name)),n=c.fields.find((e=>"object"!==e.type.name&&"hotspot"===e.name)),i=t?{_type:t.type.name,...e.crop||mT}:e.crop,r=n?{_type:n.type.name,...e.hotspot||fT}:e.hotspot;l([Tm(i,["crop"]),Tm(r,["hotspot"])])}),[l,u,c.fields]);return(0,go.jsx)(bj,{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:a,children:(0,go.jsxs)("div",{children:[(0,go.jsx)(Co.Zb,{__unstable_checkered:!0,__unstable_focusRing:!0,tabIndex:0,ref:p.ref,onFocus:v,children:(0,go.jsx)(nu,{path:o.concat(zT),hasFocus:"hotspot"===s[0],isChanged:i,children:(0,go.jsxs)(KS,{ratio:1.5,children:[(g||x)&&(0,go.jsx)(ZT,{children:x?(0,go.jsx)(Co.Zb,{padding:4,radius:2,tone:"critical",border:!0,children:(0,go.jsxs)(Co.xv,{children:["Error: ",x.message]})}):(0,go.jsx)(Co.xv,{muted:!0,children:"Loading image\u2026 "})}),!g&&m&&(0,go.jsx)(Co.xu,{margin:1,children:(0,go.jsx)(CT,{value:h,src:m.src,readOnly:Boolean(u),onChangeEnd:b,onChange:f})})]})})}),(0,go.jsx)(Co.xu,{marginTop:3,children:(0,go.jsx)(Co.rj,{columns:DT.length,gap:1,children:DT.map((e=>{let[t,n]=e;return(0,go.jsxs)("div",{children:[(0,go.jsx)(Co.X6,{as:"h4",size:0,children:t}),(0,go.jsx)(Co.xu,{marginTop:2,children:(0,go.jsx)(KS,{ratio:n,children:(0,go.jsx)(Co.Zb,{__unstable_checkered:!0,children:!g&&m?(0,go.jsx)(MT,{aspectRatio:n,src:m.src,srcAspectRatio:m.width/m.height,hotspot:h.hotspot||fT,crop:h.crop||mT}):(0,go.jsx)(LT,{})})})})]},n)}))})})]})})}const qT=(0,Es.ZP)(Co.gF)(gn||(gn=rd(["\n position: absolute;\n top: 0;\n right: 0;\n"])));function UT(e){const{onEdit:t,children:n,showEdit:i,setHotspotButtonElement:r,setMenuButtonElement:o,onMenuOpen:s,isMenuOpen:a}=e,[l,c]=(0,vo.useState)(null),[d,u]=(0,vo.useState)(null),p=(0,vo.useCallback)((()=>s(!a)),[s,a]);(0,Co.qh)((0,vo.useCallback)((e=>{!a||"Escape"!==e.key&&"Tab"!==e.key||(s(!1),null==d||d.focus())}),[a,s,d])),(0,Co.O8)((0,vo.useCallback)((e=>{(null==d?void 0:d.contains(e.target))||s(!1)}),[d,s]),[l]);const h=(0,vo.useCallback)((e=>{o(e),u(e)}),[o]);return(0,go.jsxs)(qT,{"data-buttons":!0,space:1,padding:2,children:[i&&(0,go.jsx)(Co.zx,{"aria-label":"Open image edit dialog","data-testid":"options-menu-edit-details",icon:Ds.Rf5,mode:"ghost",onClick:t,ref:r}),(0,go.jsx)(Co.J2,{id:"image-actions-menu",content:(0,go.jsx)(Co.v2,{ref:c,shouldFocus:"first",children:n}),portal:!0,open:a,constrainSize:!0,children:(0,go.jsx)(Co.zx,{"aria-label":"Open image options menu","data-testid":"options-menu-button",icon:Ds.zGg,mode:"ghost",onClick:p,ref:h})})]})}const VT=(0,Es.ZP)(Co.Zb)(xn||(xn=rd(["\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"]))),KT=(0,Es.ZP)(Co.$j)(vn||(vn=rd(["\n position: absolute;\n"]))),HT=(0,Es.ZP)(Co.kC)((e=>{let{tone:t,drag:n}=e;const i=Co.Lg.color.light[t].card.enabled.fg,r=(0,Co.m4)(Co.Lg.color.light[t].card.enabled.bg,.8);return(0,Es.iv)(yn||(yn=rd(["\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")})),$T=(0,Es.ZP)(Co.kC)(bn||(bn=rd(["\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n"])));function WT(e){const{drag:t,readOnly:n,isRejected:i,src:r,...o}=e,[s,a]=(0,vo.useState)(!1),[l,c]=(0,vo.useState)(null),d=(0,Co.XL)(l),u=(null==d?void 0:d.width)||0,p=t?i||n?"critical":"primary":"default",h=30*document.documentElement.clientHeight/100,[f,m]=(e=>{const t=new URLSearchParams(e.split("?")[1]).get("rect");return t?[t.split(",")[2],t.split(",")[3]].map(Number):e.split("-")[1].split(".")[0].split("x").map(Number)})(r),g=(f>u?u/(f/m):m)<h?null:"".concat(30,"vh");(0,vo.useEffect)((()=>{a(!1)}),[r]);const x=(0,vo.useCallback)((()=>{a(!0)}),[]);return(0,go.jsxs)(VT,{...o,ref:c,style:{height:g},tone:"transparent",children:[(0,go.jsxs)(Co.Zb,{"data-container":!0,tone:"inherit",children:[!s&&(0,go.jsx)(YT,{cardTone:"transparent",drag:!0,content:(0,go.jsx)(KT,{})}),(0,go.jsx)("img",{src:r,"data-testid":"hotspot-image-input",alt:e.alt,onLoad:x,referrerPolicy:"strict-origin-when-cross-origin"})]}),t&&(0,go.jsx)(YT,{cardTone:p,drag:t,content:(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{marginBottom:3,children:(0,go.jsx)(Co.X6,{children:(0,go.jsx)(GT,{isRejected:i,readOnly:n})})}),(0,go.jsx)(XT,{isRejected:i,readOnly:n})]})})]})}function GT(e){let{isRejected:t,readOnly:n}=e;return t?(0,go.jsx)(Ds.vaB,{}):n?(0,go.jsx)(Ds.CPA,{}):(0,go.jsx)(Ds.XBm,{})}function XT(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,go.jsx)(Co.xv,{size:1,children:i})}function YT(e){let{cardTone:t,drag:n,content:i}=e;return(0,go.jsx)(HT,{justify:"flex-end",padding:3,tone:t,drag:n,children:(0,go.jsx)($T,{direction:"column",align:"center",justify:"center",children:i})})}const JT=(0,Es.ZP)(Co.zx)(jn||(jn=rd(["\n width: 100%;\n"])));function QT(e){let{onClearValue:t}=e;return(0,go.jsxs)(Co.Zb,{tone:"caution",padding:4,border:!0,radius:2,children:[(0,go.jsxs)(Co.kC,{gap:4,marginBottom:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"Invalid image value"}),(0,go.jsx)(Co.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,go.jsx)(JT,{icon:Ds.X5P,text:"Reset value",onClick:t,mode:"ghost"})]})}var eI=Object.defineProperty,tI=(e,t,n)=>(((e,t,n)=>{t in e?eI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);function nI(e){let{children:t}=e;return t}const iI=["asset"],rI={portal:!0};class oI extends vo.PureComponent{constructor(e){var t;super(e),t=this,tI(this,"_previewElement",null),tI(this,"_assetPath"),tI(this,"uploadSubscription",null),tI(this,"state",{isUploading:!1,selectedAssetSource:null,hoveringFiles:[],isStale:!1,hotspotButtonElement:null,menuButtonElement:null,isMenuOpen:!1}),tI(this,"toast",null),tI(this,"setPreviewElement",(e=>{this._previewElement=e})),tI(this,"setHotspotButtonElement",(e=>{this.setState({hotspotButtonElement:e})})),tI(this,"setMenuButtonElement",(e=>{this.setState({menuButtonElement:e})})),tI(this,"getUploadOptions",(e=>{const{schemaType:t,resolveUploader:n}=this.props,i=n&&n(t,e);return i?[{type:t,uploader:i}]:[]})),tI(this,"uploadWith",(function(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{schemaType:r,onChange:o,client:s}=t.props,{label:a,title:l,description:c,creditLine:d,source:u}=i,p={metadata:ic()(r,"options.metadata"),storeOriginalFilename:ic()(r,"options.storeOriginalFilename"),label:a,title:l,description:c,creditLine:d,source:u};t.cancelUpload(),t.setState({isUploading:!0}),o(_m({_type:r.name})),t.uploadSubscription=e.upload(s,n,r,p).subscribe({next:e=>{e.patches&&o(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:()=>{o([Im(["hotspot"]),Im(["crop"])]),t.setState({isUploading:!1})}})})),tI(this,"handleRemoveButtonClick",(()=>{const{value:e}=this.props,t=Object.keys(e||{}),n=0===t.filter((e=>!["_type","_key","_upload","asset","crop","hotspot"].includes(e))).length,i=["asset"].concat(t.filter((e=>["crop","hotspot","_upload"].includes(e)))).map((e=>Im([e])));this.props.onChange(n&&!this.valueIsArrayElement()?Im():i)})),tI(this,"handleFieldChange",(e=>{const{onChange:t,schemaType:n}=this.props;this.valueIsArrayElement()||!this.eventIsUnsettingLastFilledField(e)?t(e.prepend(_m({_type:n.name})).patches):t(Im())})),tI(this,"eventIsUnsettingLastFilledField",(e=>{const t=e.patches[0];if(1!==e.patches.length||"unset"!==t.type)return!1;const n=Object.keys(this.props.value||{}).filter((e=>!["_type","_key","crop","hotspot"].includes(e)));return 1===e.patches[0].path.length&&1===n.length&&n[0]===e.patches[0].path[0]})),tI(this,"valueIsArrayElement",(()=>{const{path:e}=this.props;return"string"!==typeof e.slice(-1)[0]})),tI(this,"handleOpenDialog",(()=>{const{onFieldOpen:e}=this.props;e("hotspot")}
1)),tI(this,"handleCloseDialog",(()=>{var e;const{onFieldClose:t}=this.props;t("hotspot"),null==(e=this.state.hotspotButtonElement)||e.focus()})),tI(this,"handleSelectAssetFromSource",(e=>{const{onChange:t,schemaType:n,resolveUploader:i}=this.props;wS({assetFromSource:e,onChange:t,type:n,resolveUploader:i,uploadWith:this.uploadWith,isImage:!0}),this.setState({selectedAssetSource:null})})),tI(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)})),tI(this,"handleFilesOver",(e=>{this.setState({hoveringFiles:e.filter((e=>"string"!==e.kind))})})),tI(this,"handleFilesOut",(()=>{this.setState({hoveringFiles:[]})})),tI(this,"handleCancelUpload",(()=>{this.cancelUpload()})),tI(this,"handleClearUploadState",(()=>{this.setState({isStale:!1}),this.clearUploadStatus()})),tI(this,"handleStaleUpload",(()=>{this.setState({isStale:!0})})),tI(this,"handleClearField",(()=>{this.props.onChange([Im(["asset"]),Im(["crop"]),Im(["hotspot"])])})),tI(this,"handleSelectFiles",(e=>{const{directUploads:t,readOnly:n}=this.props,{hoveringFiles:i}=this.state;t&&!n?this.uploadFirstAccepted(e):i.length>0&&this.handleFilesOut()})),tI(this,"handleSelectImageFromAssetSource",(e=>{this.setState({selectedAssetSource:e})})),tI(this,"handleAssetSourceClosed",(()=>{var e;this.setState({selectedAssetSource:null}),null==(e=this.state.menuButtonElement)||e.focus()})),tI(this,"renderHotspotInput",(e=>{const{value:t,changed:n,id:i,imageUrlBuilder:r}=this.props,o=this.isImageToolEnabled()&&t&&t.asset;return(0,go.jsx)(Co.Vq,{__unstable_autoFocus:!1,header:"Edit hotspot and crop",id:"".concat(i,"_dialog"),onClickOutside:this.handleCloseDialog,onClose:this.handleCloseDialog,width:1,children:(0,go.jsx)(lj,{children:(0,go.jsx)(Co.xu,{padding:4,children:(0,go.jsx)(Co.Kq,{space:5,children:o&&(null==t?void 0:t.asset)&&(0,go.jsx)(NT,{...this.props,imageUrl:r.image(t.asset).url(),value:t,presence:e.presence,changed:n})})})})})})),tI(this,"renderPreview",(()=>{const{value:e,schemaType:t,readOnly:n,directUploads:i,imageUrlBuilder:r,resolveUploader:o}=this.props;if(!e||!(0,qa.JZ)(e))return null;const{hoveringFiles:s}=this.state,a=s.filter((e=>o(t,e))),l=s.length-a.length,c=r.width(2e3).fit("max").image(e).dpr("undefined"!==typeof window&&window.devicePixelRatio?Math.round(Math.max(1,window.devicePixelRatio)):1).auto("format").url();return(0,go.jsx)(WT,{drag:!(null==e?void 0:e._upload)&&s.length>0,isRejected:l>0||!i,readOnly:n,src:c,alt:"Preview of uploaded image"})})),tI(this,"setToast",(e=>{this.toast=e})),this._assetPath=e.path.concat(iI)}isImageToolEnabled(){return!0===ic()(this.props.schemaType,"options.hotspot")}clearUploadStatus(){var e;(null==(e=this.props.value)?void 0:e._upload)&&this.props.onChange(Im(["_upload"]))}cancelUpload(){this.uploadSubscription&&(this.uploadSubscription.unsubscribe(),this.clearUploadStatus())}uploadFirstAccepted(e){const{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(){const{value:e,assetSources:t,schemaType:n,readOnly:i,directUploads:r,imageUrlBuilder:o,observeAsset:s}=this.props,a=null==e?void 0:e.asset;if(!a)return null;const l=ic()(n,"options.accept","image/*"),c=e&&a&&this.isImageToolEnabled();let d=t&&0===t.length?null:(0,go.jsx)(Co.sN,{icon:Ds.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&&(d=t.map((e=>(0,go.jsx)(Co.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e)},icon:e.icon||Ds.XBm,"data-testid":"file-input-browse-button-".concat(e.name),disabled:i},e.name)))),(0,go.jsx)(oS,{observeAsset:s,reference:a,children:t=>{let n,s,{_id:a,originalFilename:u,extension:p}=t;if((0,qa.JZ)(e)){const e=u||"download.".concat(p);s=o.image(a).forceDownload(e).url(),n=o.image(a).url()}return(0,go.jsx)(UT,{isMenuOpen:this.state.isMenuOpen,onEdit:this.handleOpenDialog,onMenuOpen:e=>this.setState({isMenuOpen:e}),setHotspotButtonElement:this.setHotspotButtonElement,setMenuButtonElement:this.setMenuButtonElement,showEdit:c,children:(0,go.jsx)(_S,{onUpload:this.handleSelectFiles,browse:d,onReset:this.handleRemoveButtonClick,downloadUrl:s,copyUrl:n,readOnly:i,directUploads:r,accept:l})})}})}renderBrowser(){const{assetSources:e,readOnly:t,directUploads:n,id:i}=this.props;return e&&0===e.length?null:e&&e.length>1&&!t&&n?(0,go.jsx)(Co.j2,{id:"".concat(i,"_assetImageButton"),ref:this.setMenuButtonElement,button:(0,go.jsx)(Co.zx,{"data-testid":"file-input-multi-browse-button",icon:Ds.W1M,iconRight:Ds.v4q,mode:"ghost",text:"Select"}),menu:(0,go.jsx)(Co.v2,{children:e.map((e=>(0,go.jsx)(Co.sN,{text:e.title,onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e)},icon:e.icon||Ds.XBm,disabled:t,"data-testid":"file-input-browse-button-".concat(e.name)}
1,e.name)))}),popover:rI}):(0,go.jsx)(Co.zx,{fontSize:2,text:"Select",icon:Ds.W1M,mode:"ghost",onClick:()=>{this.setState({isMenuOpen:!1}),this.handleSelectImageFromAssetSource(e[0])},"data-testid":"file-input-browse-button",disabled:t})}renderUploadPlaceholder(){const{schemaType:e,readOnly:t,directUploads:n,resolveUploader:i}=this.props,{hoveringFiles:r}=this.state,o=r.filter((t=>i(e,t))),s=r.length-o.length,a=ic()(e,"options.accept","image/*");return(0,go.jsx)("div",{style:{padding:1},children:(0,go.jsx)(Co.Zb,{tone:t?"transparent":"inherit",border:!0,padding:3,style:0===r.length?{borderStyle:"dashed"}:{borderStyle:"dashed",borderColor:"transparent"},children:(0,go.jsx)(ES,{browse:this.renderBrowser(),onUpload:this.handleSelectFiles,readOnly:t,hoveringFiles:r,acceptedFiles:o,rejectedFilesCount:s,type:"image",accept:a,directUploads:n})})})}renderUploadState(e){var t;const{isUploading:n}=this.state,i=null==(t=this._previewElement)?void 0:t.offsetHeight;return(0,go.jsx)(bS,{uploadState:e,onCancel:n?this.handleCancelUpload:void 0,onStale:this.handleStaleUpload,height:i})}renderAssetSource(){const{selectedAssetSource:e}=this.state,{value:t,schemaType:n,observeAsset:i}=this.props,r=ic()(n,"options.accept","image/*");if(!e)return null;const o=e.component;return t&&t.asset?(0,go.jsx)(oS,{observeAsset:i,reference:t.asset,children:e=>(0,go.jsx)(o,{selectedAssets:[e],assetType:"image",accept:r,selectionType:"single",onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}):(0,go.jsx)(o,{selectedAssets:[],selectionType:"single",assetType:"image",accept:r,onClose:this.handleAssetSourceClosed,onSelect:this.handleSelectAssetFromSource})}getFileTone(){const{schemaType:e,value:t,readOnly:n,directUploads:i,resolveUploader:r}=this.props,{hoveringFiles:o}=this.state,s=o.filter((t=>r(e,t))),a=o.length-s.length;return o.length>0&&(a>0||!i)?"critical":!(null==t?void 0:t._upload)&&!n&&o.length>0?"primary":n||(null==t?void 0:t._upload)&&(null==t?void 0:t.asset)?"transparent":"default"}renderAsset(){const{value:e,readOnly:t,elementProps:n}=this.props,{hoveringFiles:i,isStale:r}=this.state,o=Boolean((null==e?void 0:e._upload)||(null==e?void 0:e.asset));return!e||"undefined"===typeof e.asset||(null==e?void 0:e._upload)||(0,qa.JZ)(e)?s=>(0,go.jsxs)(go.Fragment,{children:[r&&(0,go.jsx)(Co.xu,{marginBottom:2,children:(0,go.jsx)(FS,{onClearStale:this.handleClearUploadState})}),(0,go.jsx)(nu,{path:s.path.concat(iI),hasFocus:!!s.focused,isChanged:s.changed,children:(null==e?void 0:e._upload)?this.renderUploadState(e._upload):(0,go.jsxs)(mS,{...n,onFocus:this.handleFileTargetFocus,tabIndex:0,disabled:Boolean(t),onFiles:this.handleSelectFiles,onFilesOver:this.handleFilesOver,onFilesOut:this.handleFilesOut,tone:this.getFileTone(),$border:o||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,go.jsxs)("div",{style:{position:"relative"},ref:this.setPreviewElement,children:[this.renderPreview(),this.renderAssetMenu()]})]})})]}):()=>(0,go.jsx)(QT,{onClearValue:this.handleClearField})}render(){const{members:e,renderAnnotation:t,renderBlock:n,renderField:i,renderInlineBlock:r,renderInput:o,renderItem:s,renderPreview:a}=this.props,{selectedAssetSource:l}=this.state,c=e.find((e=>"field"===e.kind&&"hotspot"===e.name));return(0,go.jsxs)(Co.Kq,{space:5,"data-testid":"image-input",children:[(0,go.jsx)(Jp,{ref:this.setToast}),e.map((e=>"field"!==e.kind||"crop"!==e.name&&"hotspot"!==e.name?"field"===e.kind?(0,go.jsx)(Ck,{member:e,renderAnnotation:t,renderBlock:n,renderInlineBlock:r,renderInput:"asset"===e.name?this.renderAsset():o,renderField:"asset"===e.name?nI:i,renderItem:s,renderPreview:a},e.key):"fieldSet"===e.kind?(0,go.jsx)(Vk,{member:e,renderAnnotation:t,renderBlock:n,renderField:i,renderInlineBlock:r,renderInput:o,renderItem:s,renderPreview:a},e.key):"error"===e.kind?(0,go.jsx)(Uk,{member:e},e.key):(0,go.jsxs)(go.Fragment,{children:["Unknown member kind: $",e.kind]}):null)),(null==c?void 0:c.open)&&(0,go.jsx)(tC,{...this.props,absolutePath:c.field.path,renderInput:this.renderHotspotInput}),l&&this.renderAssetSource()]})}}const sI=()=>{},aI={isLoading:!0,result:void 0,error:void 0,retry:sI},lI={isLoading:!1,result:void 0,error:void 0,retry:sI};function cI(e,t){const[n,i]=(0,vo.useState)(0),r=(0,vo.useCallback)((()=>{i((e=>e+1))}),[]),o=(0,vo.useMemo)((()=>({_id:e._id,_type:e._type})),[e._id,e._type]),s=(0,_o.m2)((()=>o._id?t(o).pipe((0,Ho.U)((e=>({isLoading:!1,result:e,error:void 0,retry:r,retryAttempt:n}))),(0,Qo.O)(aI),(0,Wo.K)((e=>(console.error(e),(0,So.of)({isLoading:!1,result:void 0,error:e,retry:r,retryAttempt:n}))))):(0,So.of)(lI)),[o,t,r,n],aI);return Rm(e._id,e._id)!==e._id?aI:s}const dI=(0,Es.ZP)(Co.kC)(wn||(wn=rd(["\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"]))),uI=(0,Es.ZP)(Co.kC)(kn||(kn=rd(["\n /* This limits the width of the tooltip content */\n max-width: 250px;\n"])));function pI(e){return(0,go.jsx)(uI,{padding:3,children:(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{as:"p",size:1,children:e.children})})})})}function hI(e){var t,n,i;const{refType:r,showStudioUrlIcon:o,hasStudioUrl:s,showTypeLabel:a,availability:l,preview:c,id:d,dataset:u,projectId:p}=e,h="NOT_FOUND"===(null==l?void 0:l.reason),f="PERMISSION_DENIED"===(null==l?void 0:l.reason),m=null==(t=c.published)?void 0:t.media,g=(0,vo.useMemo)((()=>
1{if(m){const e="undefined"!==typeof(null==m?void 0:m.asset)&&(0,qa.JZ)(m),t=vo.isValidElement(m);return e||t?function(e){let{dimensions:n}=e;return t?m:(0,go.jsx)("img",{src:Na()({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,vo.createElement)(r.icon):null}),[m,u,p,null==r?void 0:r.icon]);return(0,go.jsxs)(dI,{align:"center",justify:"center",flex:1,"data-testid":"preview",children:[(null==l?void 0:l.available)?(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(cp,{title:null==(n=c.published)?void 0:n.title,subtitle:null==(i=c.published)?void 0:i.subtitle,media:g||!1})}):(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.kC,{align:"center",children:(0,go.jsx)(Co.xu,{flex:1,paddingY:2,children:(0,go.jsx)(Co.xv,{muted:!0,children:"Document unavailable"})})})}),(0,go.jsx)(Co.xu,{paddingLeft:3,children:(0,go.jsxs)(Co.gF,{space:4,children:[r&&a&&(0,go.jsx)(Co.__,{size:1,muted:!0,children:r.title||r.type}),(f||h)&&(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.u,{portal:!0,content:h?(0,go.jsxs)(pI,{children:["The referenced document no longer exist and might have been deleted.",(0,go.jsx)("br",{}),"(id: ",(0,go.jsx)("code",{children:d}),")"]}):(0,go.jsx)(pI,{children:"The referenced document could not be accessed due to insufficient permissions"}),children:(0,go.jsx)(Xp,{tone:"default",children:f?(0,go.jsx)(Ds.vaB,{}):(0,go.jsx)(Ds.BHU,{})})})}),!(h||f)&&o&&(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.u,{portal:!0,content:(0,go.jsx)(uI,{padding:2,children:s?(0,go.jsx)(Co.xv,{size:1,children:"This document opens in another Studio"}):(0,go.jsxs)(Co.xv,{size:1,children:["This document cannot be opened ",(0,go.jsx)("br",{})," (unable to resolve URL to Studio)"]})}),children:(0,go.jsx)(Xp,{size:1,tone:"default",muted:!s,children:(0,go.jsx)(Ds.buG,{})})})})]})})]})}function fI(){return WZ(qh).config().projectId}function mI(e){var t;const{isLoading:n,result:i,error:r}=cI(e.document,e.getReferenceInfo),o=fI();if(n)return(0,go.jsxs)(Co.Kq,{space:2,padding:1,children:[(0,go.jsx)(Co.Qr,{style:{maxWidth:320},radius:1,animated:!0}),(0,go.jsx)(Co.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!0})]});if(r)return(0,go.jsx)(Co.Kq,{space:2,padding:1,children:(0,go.jsxs)(Om,{title:"Failed to load referenced document",children:["Error: ",r.message]})});if(!i)return null;if("PERMISSION_DENIED"===(null==(t=i.availability)?void 0:t.reason))return(0,go.jsx)(Co.Kq,{space:2,padding:1,children:"Insufficient permissions to view this document"});const s=e.referenceType.to.find((e=>e.type===i.type));return s?i&&s&&(0,go.jsx)(hI,{id:i.id,availability:i.availability,preview:i.preview,refType:s,dataset:e.referenceType.dataset,projectId:o,showTypeLabel:e.referenceType.to.length>1}):(0,go.jsxs)(Co.Kq,{space:2,padding:1,children:["Search returned a type that's not valid for this reference: \"$",i.type,'"']})}function gI(e){var t,n;const{value:i,type:r,showStudioUrlIcon:o,hasStudioUrl:s,referenceInfo:a}=e,l=fI();if(a.isLoading||a.error)return(0,go.jsxs)(Co.Kq,{space:2,padding:1,children:[(0,go.jsx)(Co.Qr,{style:{maxWidth:320},radius:1,animated:!a.error}),(0,go.jsx)(Co.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!a.error})]});const c=r.to.length>1,d=null==(t=a.result)?void 0:t.type,u=r.to.find((e=>e.type===d));return(null==(n=a.result.availability)?void 0:n.available)&&!u?(0,go.jsx)(Co.Kq,{space:2,padding:2,children:(0,go.jsxs)(Co.xv,{as:"p",children:["The referenced document is of invalid type: (",d||"unknown",")",(0,go.jsx)("pre",{children:JSON.stringify(i,null,2)})]})}):(0,go.jsx)(hI,{availability:a.result.availability,hasStudioUrl:s,showStudioUrlIcon:o,preview:a.result.preview,refType:u,projectId:l,dataset:r.dataset,id:i._ref,showTypeLabel:c})}const xI=(0,Es.ZP)(Co.J2)(Cn||(Cn=rd(["\n & > div {\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n"]))),vI=(0,Es.ZP)(Co.xv)(_n||(_n=rd(["\n word-break: break-word;\n"]))),yI=(0,vo.forwardRef)((function(e,t){const n=e.options&&e.options.length>0,i=(0,vo.useCallback)(((t,i)=>{let{content:r,hidden:o,inputElement:s,onMouseEnter:a,onMouseLeave:l}=t;return(0,go.jsx)(xI,{"data-testid":"autocomplete-popover",placement:"bottom-start",arrow:!1,constrainSize:!0,onMouseEnter:a,onMouseLeave:l,content:(0,go.jsx)("div",{ref:i,children:n?r:(0,go.jsx)(Co.xu,{padding:4,children:(0,go.jsx)(Co.kC,{align:"center",height:"fill",justify:"center",children:(0,go.jsxs)(vI,{align:"center",muted:!0,children:["No results for ",(0,go.jsxs)("strong",{children:["\u201c",e.searchString,"\u201d"]})]})})})}),open:!e.loading&&!o,ref:e.portalRef,portal:!0,referenceElement:e.referenceElement||s,matchReferenceWidth:!0})}),[n,e.searchString,e.loading,e.portalRef,e.referenceElement]);return(0,go.jsx)(Co.F2,{...e,ref:t,renderPopover:i})})),bI=(0,Es.ZP)(Co.zx)(Sn||(Sn=rd(["\n width: 100%;\n"])));function jI(e){let{value:t,onClearValue:n}=e;const i=(0,vo.useMemo)((()=>Boolean(null==t?void 0:t._ref)),[null==t?void 0:t._ref]);return(0,go.jsxs)(Co.Zb,{tone:"caution",padding:4,border:!0,radius:2,"data-testid":"alert-cross-dataset-reference-feature-disabled",children:[(0,go.jsxs)(Co.kC,{gap:4,marginBottom:i?4:void 0,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{as:"h2",size:1,weight:"semibold",children:"Unavailable feature: Cross dataset reference"}),i&&(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",size:1,children:["This feature has been disabled. Read how to enable it in"," ",(0,go.jsx)("a",{href:"https://www.sanity.io/docs/cross-dataset-references",target:"_blank",rel:"noreferrer",children:"documentation"})]}),(0,go.jsx)(Co.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,go.jsxs)(Co.xv,{as:"p",size:1,children:["Read how to enable it in"," ",(0,go.jsx)("a",{href:"https://www.sanity.io/docs/cross-dataset-references",target:"_blank",rel:"noreferrer",children:"documentation"})]})]})]}),n&&i&&(0,go.jsx)(bI,{icon:Ds.X5P,text:"Reset value",onClick:n,mode:"ghost"})]})}
1const wI={isLoading:!0,enabled:!0,features:[]};let kI;const CI={hits:[],isLoading:!1},_I=()=>!0,SI=["_ref"];function TI(e){var t,n,i;const{changed:r,focused:o,focusPath:s,getReferenceInfo:a,onChange:l,onPathFocus:c,onSearch:d,path:u,readOnly:p,schemaType:h,validation:f,value:m,elementProps:g}=e,x=fI(),[v,y]=(0,vo.useState)(CI),b=(0,vo.useCallback)((e=>{if(!e)return l(Im()),void c([]);if(!v.hits.find((t=>t.id===e)))throw new Error("Selected an item that wasnt part of the result set");l(Tm({_type:h.name,_ref:Td(e),_projectId:x,_dataset:h.dataset,_weak:h.weak,_key:null==m?void 0:m._key})),c([])}),[null==m?void 0:m._key,v.hits,h.name,h.dataset,h.weak,x,l,c]),j=(0,vo.useCallback)((()=>{l(Im())}),[l]),w=(0,vo.useCallback)((e=>{27===e.keyCode&&(null==c||c([]))}),[c]),k=(0,vo.useCallback)((e=>a(e,h)),[a,h]),C=cI((0,vo.useMemo)((()=>({_id:null==m?void 0:m._ref})),[null==m?void 0:m._ref]),k),_=function(e){const t=WZ(qh);kI||(kI=function(e){let{versionedClient:t}=e;return t.observable.request({uri:"/features",tag:"features"})}({versionedClient:t}).pipe((0,Jo.d)()));const n=(0,_o.m2)((()=>kI.pipe((0,Ho.U)((function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{isLoading:!1,enabled:Boolean(null==t?void 0:t.includes(e)),features:t}})),(0,Qo.O)(wI),(0,Wo.K)((e=>(console.error(e),(0,So.of)({isLoading:!1,enabled:!0,features:[]})))))),[e],wI);return n}("crossDatasetReferences"),S=(0,vo.useRef)(null),T=1===s.length&&"_ref"===s[0],I=g.ref;zm({hasFocusAt:T,ref:null==m?void 0:m._ref},((e,t)=>{var n;const i=(null==e?void 0:e.ref)!==t.ref;((null==e?void 0:e.hasFocusAt)!==t.hasFocusAt||i)&&t.hasFocusAt&&(null==(n=I.current)||n.focus())}));const P=(null==m?void 0:m._weak)?"weak":"strong",E=!0===h.weak?"weak":"strong",A=Boolean(null==m?void 0:m._ref),F=(0,vo.useCallback)((()=>{l(!0===h.weak?Tm(!0,["_weak"]):Im(["_weak"]))}),[l,h]),{push:M}=(0,Co.pm)(),O=(0,vo.useMemo)((()=>f.filter((e=>"error"===e.level))),[f]),R=(0,vo.useCallback)((e=>{e.currentTarget===g.ref.current&&(null==c||c([xo.Zg]))}),[g.ref,c]),z=(0,vo.useCallback)((e=>{e.currentTarget===g.ref.current&&(null==c||c(SI))}),[g.ref,c]),D=(0,vo.useCallback)((()=>{null==c||c(SI)}),[c]),B=(0,vo.useId)(),L=(0,_o.W2)((e=>e.pipe((0,Yo.h)(wd),(0,$o.x)(),(0,Go.w)((e=>(0,To.z)((0,So.of)({isLoading:!0}),d(e).pipe((0,Ho.U)((t=>({hits:t,searchString:e,isLoading:!1}))),(0,Wo.K)((e=>(M({title:"Reference search failed",description:e.message,status:"error",id:"reference-search-fail-".concat(B)}),console.error(e),(0,So.of)({hits:[]})))))))),(0,Xo.R)(((e,t)=>({...e,...t})),CI),(0,Ko.b)(y))),[B,d,M]),Z=(0,vo.useCallback)((()=>{L("")}),[L]),N=!C.isLoading&&A&&P!==E,q=(null==m?void 0:m._ref)&&(null==(n=h.studioUrl)?void 0:n.call(h,{id:null==m?void 0:m._ref,type:null==(t=null==C?void 0:C.result)?void 0:t.type}))||null,U=(0,vo.useCallback)((e=>(0,go.jsx)(Ju,{as:"button",type:"button",radius:2,children:(0,go.jsx)(Co.xu,{paddingX:3,paddingY:1,children:(0,go.jsx)(mI,{referenceType:h,document:e.hit.published,getReferenceInfo:k})})})),[h,k]),V=null==(i=C.result)?void 0:i.preview.published,K=T||!(null==m?void 0:m._ref),H=(0,vo.useRef)(null),$=(0,vo.useRef)(null);return Dm([H,$,(0,vo.useRef)(null)],(()=>{T&&c([])})),(0,go.jsxs)(go.Fragment,{children:[!_.isLoading&&!_.enabled&&(0,go.jsx)(jI,{value:m,onClearValue:j}),(_.isLoading||_.enabled)&&(0,go.jsx)(Co.Kq,{space:1,children:K?(0,go.jsx)(Co.Kq,{space:2,ref:H,children:(0,go.jsx)(nu,{path:u,isChanged:r,hasFocus:!!o,children:(0,go.jsx)("div",{ref:S,children:(0,go.jsx)(yI,{...g,"data-testid":"autocomplete",loading:v.isLoading,referenceElement:S.current,portalRef:$,id:B||"",options:v.hits.map((e=>({value:e.id,hit:e}))),onFocus:z,radius:1,placeholder:"Type to search",onKeyDown:w,readOnly:p,disabled:C.isLoading,onQueryChange:L,searchString:v.searchString,onChange:b,filterOption:_I,renderOption:U,openButton:{onClick:Z}})})})}):(0,go.jsx)(nu,{path:u,isChanged:r,hasFocus:!!o,children:(0,go.jsxs)(Co.Zb,{padding:0,border:!0,flex:1,radius:1,tone:p?"transparent":C.error||O.length>0?"critical":"default",children:[(0,go.jsxs)(Co.kC,{align:"center",padding:1,children:[q?(0,go.jsx)(Ju,{as:"a",target:"_blank",rel:"noopener noreferrer",href:q,"data-as":"a",flex:1,padding:1,paddingRight:3,radius:2,tone:"inherit",__unstable_focusRing:!0,tabIndex:0,onFocus:R,ref:g.ref,children:(0,go.jsx)(gI,{value:m,referenceInfo:C,showStudioUrlIcon:!0,hasStudioUrl:!!q,type:h})}):(0,go.jsx)(Ju,{flex:1,padding:1,paddingRight:3,radius:2,tone:"inherit",__unstable_focusRing:!0,tabIndex:0,onFocus:R,ref:g.ref,children:(0,go.jsx)(gI,{value:m,referenceInfo:C,showStudioUrlIcon:!0,type:h})}),(0,go.jsx)(Co.gF,{paddingX:1,children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg,"data-testid":"menu-button"}),id:"".concat(B,"-menuButton"),menu:(0,go.jsx)(Co.v2,{children:!p&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.sN,{text:"Clear",tone:"critical",icon:Ds.X5P,"data-testid":"menu-item-clear",onClick:j}),(0,go.jsx)(Co.sN,{text:"Replace",icon:Ds.bnu,"data-testid":"menu-item-replace",onClick:D})]})}),placement:"right",popover:{portal:!0,tone:"default"}})})]}),N&&(0,go.jsx)(nw,{padding:1,title:"Reference strength mismatch",status:"warning","data-testid":"alert-reference-strength-mismatch",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This reference is ",(0,go.jsx)("em",{children:P}),", but according to the current schema it should be ",(0,go.jsxs)("em",{children:[E,"."]})]}),(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:h.weak?(0,go.jsxs)(go.Fragment,{children:['It will not be possible to delete the "',null==V?void 0:V.title,'"-document without first removing this reference.']}):(0,go.jsxs)(go.Fragment,{children:['This makes it possible to delete the "',null==V?void 0:V.title,'"-document without first deleting this reference, leav
1ing this field referencing a nonexisting document.']})}),(0,go.jsx)(Co.zx,{onClick:F,text:(0,go.jsxs)(go.Fragment,{children:["Convert to ",E," reference"]}),tone:"caution"})]})}),C.error&&(0,go.jsx)(nw,{padding:1,title:"Unable to load reference metadata",status:"warning","data-testid":"alert-reference-info-failed",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["Error: ",C.error.message]}),(0,go.jsx)(Co.zx,{onClick:C.retry,text:(0,go.jsx)(go.Fragment,{children:"Retry"}),tone:"primary"})]})})]})})})]})}const II="cross-dataset-refs",PI={available:!0,reason:"READABLE"},EI={available:!1,reason:"PERMISSION_DENIED"},AI={available:!1,reason:"NOT_FOUND"};function FI(e){const{client:t,documentPreviewStore:n}=e,{dataset:i,projectId:r}=t.config(),o=i&&r?{dataset:i,projectId:r}:void 0;return function(e,i){return(e._type?(0,So.of)(e):n.observeDocumentTypeFromId(e._id,o).pipe((0,Ho.U)((t=>({_id:e._id,_type:t}))))).pipe((0,Go.w)((r=>{if(!r._type)return function(e,t){const n={uri:e.getDataUrl("doc",t),json:!0,query:{excludeContent:"true"},tag:"".concat(II,".availability")};return e.observable.request(n).pipe((0,Ho.U)((e=>{const n=Wa()(e.omitted||[],(e=>e.id))[t];return n?"existence"===n.reason?AI:"permission"===n.reason?EI:null:PI})))}(t,e._id).pipe((0,Ho.U)((t=>({id:e._id,type:void 0,availability:t,preview:{published:void 0}}))));const s=i.to.find((e=>e.type===r._type)),a=[...pf(null==s?void 0:s.preview)||[],["_updatedAt"],["_createdAt"]],l=n.observePaths(e,a,o).pipe((0,Ho.U)((e=>e?Bf(e,s):e)));return(0,Do.a)([l]).pipe((0,Ho.U)((t=>{let[n]=t;return{type:r._type,id:e._id,availability:PI,preview:{published:Od(n)?n:void 0}}})))})))}}function MI(e){var t,n,i,r;const{path:o,schemaType:s}=e,a=SO(),l=a.getClient(qh),c=nN(),d=mV(),u=(0,vo.useMemo)((()=>l.withConfig({apiVersion:"2021-03-25"})),[l]),{EditReferenceLinkComponent:p,onEditReference:h,activePath:f,initialValueTemplateItems:m}=mb(),g=function(e){const t=(0,vo.useRef)(e);return t.current=e,t}(fk([])),x=null==(t=g.current)?void 0:t._type,v=(0,vo.useMemo)((()=>{var e;return null==(e=c.get(x))?void 0:e.liveEdit}),[x,c]),y=!0===(null==(n=s.options)?void 0:n.disableNew),b=a.getClient,j=(0,vo.useCallback)((e=>(0,Bo.D)(async function(e,t,n,i){if(!e)return{};if("function"===typeof e.filter){const r=n.slice(0,-1),o=xo.U2(t,r);return e.filter({document:t,parentPath:r,parent:o,getClient:i})}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}(s.options,g.current,o,b)).pipe((0,is.z)((t=>{let{filter:n,params:i}=t;return wm(u,e,s,{...s.options,filter:n,params:i,tag:"search.reference"})})),(0,Wo.K)((e=>{var t;const n=e.details&&"queryParseError"===e.details.type;return(null==(t=s.options)?void 0:t.filter)&&n&&(e.message='Invalid reference filter, please check the custom "filter" option'),(0,Fo._)(e)})))),[g,o,u,s,b]),w=null==(r=null==(i=e.value)?void 0:i._strengthenOnPublish)?void 0:r.template,k=(0,vo.useMemo)((()=>(0,vo.forwardRef)((function(e,t){return p?(0,go.jsx)(p,{...e,ref:t,parentRefPath:o,template:w}):null}))),[p,o,w]),C=(0,vo.useCallback)((e=>{null==h||h({parentRefPath:o,id:e.id,type:e.type,template:e.template})}),[h,o]),_=xo.Ny(o,(null==f?void 0:f.path)||[])?null==f?void 0:f.state:"none",S=(0,vo.useMemo)((()=>y?[]:(m||[]).filter((e=>s.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(wd)),[y,m,s.to]),T=(0,vo.useCallback)((e=>jm(d,e,s)),[d,s]);return{selectedState:_,handleSearch:j,isCurrentDocumentLiveEdit:v,handleEditReference:C,EditReferenceLink:k,createOptions:S,getReferenceInfo:T}}function OI(e){const{getReferenceInfo:t,id:n,renderPreview:i}=e,{isLoading:r,result:o,error:s}=uw(n,t);if(r)return(0,go.jsxs)(Co.Kq,{space:2,padding:1,children:[(0,go.jsx)(Co.Qr,{style:{maxWidth:320},radius:1,animated:!0}),(0,go.jsx)(Co.Qr,{style:{maxWidth:200},radius:1,size:1,animated:!0})]});if(s)return(0,go.jsx)(Co.Kq,{space:2,padding:1,children:(0,go.jsx)(Om,{title:"Failed to load referenced document",children:(0,go.jsxs)(Co.xv,{muted:!0,size:1,children:["Error: ",s.message]})})});if(!o)return null;if("PERMISSION_DENIED"===o.availability.reason)return(0,go.jsx)(Co.Kq,{space:2,padding:1,children:"Insufficient permissions to view this document"});const a=e.type.to.find((e=>e.name===o.type));return a?o&&a&&(0,go.jsx)(fw,{availability:o.availability,id:o.id,layout:"default",preview:o.preview,refType:a,renderPreview:i,showTypeLabel:e.type.to.length>1}):(0,go.jsxs)(Co.Kq,{space:2,padding:1,children:["Search returned a type that's not val
1id for this reference: \"$",o.type,'"']})}const RI={display:"inline-flex"},zI={width:"100%"},DI={portal:!0,tone:"default",constrainSize:!0,fallbackPlacements:["bottom","left","top"],placement:"right",preventOverflow:!0};function BI(e){const{createOptions:t,onCreate:n,id:i,...r}=e;return t.some((e=>e.permission.granted))?t.length>1?(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{...r,disabled:e.readOnly,text:"Create new\u2026",mode:"ghost",icon:Ds.dtP}),id:i,menu:(0,go.jsx)(Co.v2,{ref:e.menuRef,children:t.map((e=>(0,go.jsx)(Co.u,{disabled:e.permission.granted,content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Vu,{operationLabel:"create this type of document"})}),portal:!0,children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.sN,{disabled:!e.permission.granted,icon:e.icon,text:e.title,onClick:()=>n(e)})})},e.id)))}),popover:DI}):(0,go.jsx)(Co.zx,{...r,text:"Create new",mode:"ghost",disabled:!t[0].permission.granted||e.readOnly,onClick:()=>n(t[0]),icon:Ds.dtP}):(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Vu,{operationLabel:"create a new reference"})}),children:(0,go.jsx)("div",{style:RI,children:(0,go.jsx)(Co.zx,{text:"Create new",mode:"ghost",disabled:!0,icon:Ds.dtP,style:zI})})})}const LI=(0,Es.ZP)(Co.J2)(Tn||(Tn=rd(["\n & > div {\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n"]))),ZI=(0,Es.ZP)(Co.xv)(In||(In=rd(["\n word-break: break-word;\n"]))),NI=(0,vo.forwardRef)((function(e,t){const n=e.options&&e.options.length>0,i=(0,vo.useCallback)(((t,i)=>{let{content:r,hidden:o,inputElement:s,onMouseEnter:a,onMouseLeave:l}=t;var c;return(0,go.jsx)(LI,{placement:"bottom-start",arrow:!1,constrainSize:!0,onMouseEnter:a,onMouseLeave:l,content:(0,go.jsx)("div",{ref:i,children:n?r:(0,go.jsx)(Co.xu,{padding:4,children:(0,go.jsx)(Co.kC,{align:"center",height:"fill",justify:"center",children:(0,go.jsxs)(ZI,{align:"center",muted:!0,children:["No results for ",(0,go.jsxs)("strong",{children:["\u201c",e.searchString,"\u201d"]}),"capybara"===(null==(c=e.searchString)?void 0:c.toLowerCase())?(0,go.jsx)(go.Fragment,{children:". What a shame. There should be more Capybaras."}):null]})})})}),open:!e.loading&&!o,ref:e.portalRef,portal:!0,referenceElement:e.referenceElement||s,matchReferenceWidth:!0})}),[n,e.searchString,e.loading,e.portalRef,e.referenceElement]);return(0,go.jsx)(Co.F2,{...e,ref:t,renderPopover:i})})),qI=(0,Es.iv)(Pn||(Pn=rd(["\n grid-template-columns: minmax(0px, 1fr);\n"]))),UI=(0,Es.iv)(En||(En=rd(["\n grid-template-columns: 1fr min-content;\n"]))),VI=(0,Es.ZP)(Co.rj)((e=>e.$narrow?qI:UI)),KI=(0,vo.forwardRef)((function(e,t){const[n,i]=(0,vo.useState)(null),r=(0,vo.useCallback)((e=>{var n,r;r=e,"function"===typeof(n=t)?n(r):n&&(n.current=r),i(e)}),[t]),o=(0,Co.XL)(n);return(0,go.jsx)(VI,{ref:r,gap:1,$narrow:((null==o?void 0:o.width)||0)<480,children:e.children})}));const HI=(0,Es.ZP)(Ju)(An||(An=rd(["\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"]))),$I={hits:[],isLoading:!1},WI=()=>!0;function GI(e){return null!==e}function XI(e){var t,n,i,r,o,s;const{createOptions:a,onChange:l,onEditReference:c,onSearch:d,schemaType:u,readOnly:p,id:h,onPathFocus:f,value:m,renderPreview:g,path:x,elementProps:v,focusPath:y}=e,{getReferenceInfo:b}=MI({path:x,schemaType:u,value:m}),[j,w]=(0,vo.useState)($I),k=(0,vo.useCallback)((e=>{const t=(0,ul.Z)(),n=[_m({}),Tm(u.name,["_type"]),Tm(t,["_ref"]),Tm(!0,["_weak"]),Tm({type:e.type,weak:u.weak,template:e.template},["_strengthenOnPublish"])].filter(wd);l(n),c({id:t,type:e.type,template:e.template}),f([])}),[l,c,f,u]),C=(0,vo.useCallback)((e=>{if(!e)return l(Im()),void f([]);const t=j.hits.find((t=>t.id===e));if(!t)throw new Error("Selected an item that wasnt part of the result set");const n=[_m({}),Tm(u.name,["_type"]),Tm(Td(e),["_ref"]),t.published&&!u.weak?Im(["_weak"]):Tm(!0,["_weak"]),t.published?Im(["_strengthenOnPublish"]):Tm({type:null==t?void 0:t.type,weak:u.weak},["_strengthenOnPublish"])].filter(wd);l(n),f([])}),[l,f,u.name,u.weak,j.hits]),_=(0,vo.useCallback)((()=>
1{l(Im())}),[l]),S=(0,vo.useCallback)((()=>{(null==m?void 0:m._ref)||_()}),[_,null==m?void 0:m._ref]),T=(0,vo.useCallback)((e=>{"Escape"===e.key&&f([])}),[f]),I=uw(null==m?void 0:m._ref,b),P=(0,vo.useRef)(null),{push:E}=(0,Co.pm)(),A=(0,_o.W2)((e=>e.pipe((0,Yo.h)(GI),(0,Go.w)((e=>(0,To.z)((0,So.of)({isLoading:!0}),d(e).pipe((0,Ho.U)((t=>({hits:t,searchString:e,isLoading:!1}))),(0,Wo.K)((e=>(E({title:"Reference search failed",description:e.message,status:"error",id:"reference-search-fail-".concat(h)}),console.error(e),(0,So.of)({hits:[]})))))))),(0,Xo.R)(((e,t)=>({...e,...t})),$I),(0,Ko.b)(w))),[h,d,E]),F=(0,vo.useCallback)((()=>{A("")}),[A]),M=(0,vo.useCallback)((e=>{"Escape"===e.key&&f([])}),[f]),O=(0,vo.useCallback)((e=>{var t,n;const i=(null==(t=e.hit.draft)?void 0:t._id)||(null==(n=e.hit.published)?void 0:n._id)||e.value;return(0,go.jsx)(HI,{forwardedAs:"button",type:"button",radius:2,tone:"inherit",children:(0,go.jsx)(Co.xu,{paddingX:3,paddingY:1,children:(0,go.jsx)(OI,{getReferenceInfo:b,id:i,renderPreview:g,type:u})})})}),[u,b,g]),R=(0,vo.useCallback)((()=>{var e,t,n,i;return(null==(t=null==(e=I.result)?void 0:e.preview.draft)?void 0:t.title)||(null==(i=null==(n=I.result)?void 0:n.preview.published)?void 0:i.title)||""}),[null==(n=null==(t=I.result)?void 0:t.preview.draft)?void 0:n.title,null==(r=null==(i=I.result)?void 0:i.preview.published)?void 0:r.title]),z=(0,vo.useCallback)((()=>f(["_ref"])),[f]),D=(0,vo.useCallback)((t=>{var n;(null==(n=P.current)?void 0:n.contains(t.relatedTarget))||e.elementProps.onBlur(t)}),[e.elementProps]),B="NOT_FOUND"===(null==(s=null==(o=null==I?void 0:I.result)?void 0:o.availability)?void 0:s.reason)&&!(null==m?void 0:m._strengthenOnPublish)&&(null==m?void 0:m._weak);zm("_ref"===(null==y?void 0:y[0]),((e,t)=>{var n;!e&&t&&(null==(n=v.ref.current)||n.focus())}));const L=(0,vo.useMemo)((()=>j.hits.map((e=>({value:e.id,hit:e})))),[j.hits]),Z=1===y.length&&"_ref"===y[0],{menuRef:N,containerRef:q}=(0,vo.useContext)(vw)||{menuRef:{current:null},containerRef:{current:null}},U=(0,vo.useRef)(null),V=(0,vo.useRef)(null),K=(0,vo.useRef)(null);return Dm([q,U,V,K,N],(()=>{Z&&S()})),(0,go.jsx)(Co.Kq,{space:1,"data-testid":"reference-input",ref:U,children:(0,go.jsxs)(Co.Kq,{space:2,children:[B?(0,go.jsx)(Om,{"data-testid":"alert-nonexistent-document",title:"Nonexistent document reference",suffix:(0,go.jsx)(Co.Kq,{padding:2,children:(0,go.jsx)(Co.zx,{text:"Clear",onClick:_})}),children:(0,go.jsxs)(Co.xv,{size:1,children:["This field is currently referencing a document that doesn't exist (ID:",(0,go.jsx)("code",{children:m._ref}),"). You can either remove the reference or replace it with another document."]})}):null,(0,go.jsxs)(KI,{ref:P,children:[(0,go.jsx)(NI,{...v,onFocus:z,onBlur:D,"data-testid":"autocomplete",loading:j.isLoading,referenceElement:P.current,options:L,radius:1,placeholder:"Type to search",onKeyDown:T,readOnly:I.isLoading||p,onQueryChange:A,searchString:j.searchString,onChange:C,filterOption:WI,renderOption:O,renderValue:R,openButton:{onClick:F},portalRef:V,value:null==m?void 0:m._ref}),a.length>0&&(0,go.jsx)(BI,{id:"".concat(h,"-selectTypeMenuButton"),readOnly:p,createOptions:a,onCreate:k,onKeyDown:M,menuRef:K})]})]})})}function YI(e){var t,n,i,r;const o=SO(),s=o.getClient(qh),a=nN(),l=mV(),{path:c,schemaType:d}=e,{EditReferenceLinkComponent:u,onEditReference:p,activePath:h,initialValueTemplateItems:f}=mb(),m=function(e){const t=(0,vo.useRef)(e);return t.current=e,t}(fk([])),g=null==(t=m.current)?void 0:t._type,x=a.get(g),v=(0,vo.useMemo)((()=>null==x?void 0:x.liveEdit),[x]),y=!0===(null==(n=d.options)?void 0:n.disableNew),b=o.getClient,j=(0,vo.useCallback)((e=>(0,Bo.D)(async function(e,t,n,i){if(!e)return{};if("function"===typeof e.filter){const r=n.slice(0,-1),o=(0,xo.U2)(t,r);return await e.filter({document:t,parentPath:r,parent:o,getClient:i})}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}(d.options,m.current,c,b)).pipe((0,is.z)((t=>{let{filter:n,params:i}=t;return wm(s,e,d,{...d.options,filter:n,params:i,tag:"search.reference"})})),(0,Wo.K)((e=>{var t;const n=e.details&&"queryParseError"===e.details.type;return(null==(t=d.options)?void 0:t.filter)&&n&&(e.message='Invalid reference filter, please check the custom "filter" option'),(0,Fo._)(e)})))),[m,c,s,d,b]),w=null==(r=null==(i=e.value)?void 0:i._strengthenOnPublish)?void 0:r.template,k=(0,vo.useMemo)((()=>(0,vo.forwardRef)((function(e,t){return u?(0,go.jsx)(u,{...e,ref:t,parentRefPath:c,template:w}):null}))),[u,c,w]),C=(0,vo.useCallback)((e=>{null==p||p({parentRefPath:c,id:e.id,type:e.type,template:e.template})}),[p,c]),_=xo.Ny(c,(null==h?void 0:h.path)||[])?null==h?void 0:h.state:"none",S=(0,vo.useMemo)((()=>y?[]:(f||[]).filter((e=>d.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(wd)),[y,f,d.to]),T=(0,vo.useCallback)(((e,t)=>jm(l,e,t)),[l]);return(0,go.jsx)(XI,{...e,onSearch:j,liveEdit:v,getReferenceInfo:T,selectedState:_,editReferenceLinkComponent:k,createOptions:S,onEditReference:C}
1)}function JI(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)=>JI(e[i],t[i])));const n=Object.keys(e),i=Object.keys(e);return n.length===i.length&&n.every((n=>JI(e[n],t[n])))}function QI(e,t){return!!e&&e.some((e=>JI(e,t)))}const eP=[];function tP(e){var t,n;const{renderPreview:i,schemaType:r,onChange:o,onPathFocus:s,value:a=[],readOnly:l,elementProps:c,path:d,changed:u}=e,p=(0,vo.useMemo)((()=>{var e;return((null==(e=r.options)?void 0:e.list)||eP).map(((e,t)=>(0,mo.fU)(e)?e:{...e,_key:"auto-generated-".concat(t)}))}),[null==(t=r.options)?void 0:t.list]),h=(0,vo.useCallback)(((e,t)=>{if(!e&&(0,mo.fU)(t))return void o(Im([{_key:t._key}]));const n=p.filter((n=>JI(t,n)?e:QI(a,n)));o(n.length>0?Tm(n):Im())}),[o,p,a]),f=(0,vo.useCallback)((e=>{s([e])}),[s]),m="grid"===(null==(n=r.options)?void 0:n.layout);return(0,go.jsx)(nu,{path:d,isChanged:u,hasFocus:!1,children:(0,go.jsx)(Co.rj,{gap:2,columns:m?Math.min(p.length,4):1,tabIndex:0,...c,children:p.map(((e,t)=>{const n=function(e,t){return e.of.find((e=>e.name===(0,vl.wq)(t)))}(r,e),o=QI(a,e),s=!n;return(0,go.jsxs)(Co.kC,{align:"center",as:"label",muted:s,children:[(0,go.jsx)(Co.XZ,{disabled:s,checked:o,onChange:t=>h(t.currentTarget.checked,e),onFocus:()=>f(t),readOnly:l}),(0,go.jsx)(Co.xu,{flex:1,marginLeft:2,children:n?i({layout:"default",schemaType:n,value:e}):(0,go.jsx)(Co.Zb,{tone:"caution",radius:2,children:(0,go.jsx)(Xk,{value:e,onFocus:()=>f(t)})})})]},t)}))})})}const nP=(0,Es.ZP)(Co.Zb)(Fn||(Fn=rd(["\n max-width: ","px;\n"])),(e=>{let{theme:t}=e;return t.sanity.container[1]}));function iP(e){const{value:t,onFocus:n,vertical:i,...r}=e,[o,s]=vo.useState(!1),[a,l]=vo.useState(null);(0,Co.O8)((()=>s(!1)),[a]);const c=vo.useCallback((e=>{"Escape"!==e.key&&"Tab"!==e.key||s(!1)}),[]),d=(0,vo.useCallback)((()=>{s((e=>!e))}),[]),u=(0,vl.wq)(t);return(0,go.jsx)(Co.J2,{open:o,ref:l,onKeyDown:c,portal:!0,constrainSize:!0,tone:"default",content:(0,go.jsx)(nP,{margin:1,padding:3,onKeyDown:c,tabIndex:0,overflow:"auto",children:(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{weight:"semibold",children:"Why is this happening?"})}),(0,go.jsxs)(Co.xv,{size:1,children:["The current schema does not declare items of type ",(0,go.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,go.jsx)(Co.xu,{children:(0,go.jsxs)(Co.xv,{size:1,children:[(0,go.jsx)(Ds.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,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,go.jsx)(Co.Zb,{padding:2,overflow:"auto",border:!0,children:(0,go.jsx)(Co.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,go.jsx)(Co.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,flex:1,onFocus:n,onClick:d,onKeyDown:c,__unstable_focusRing:!0,...r,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xu,{marginRight:3,children:(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.Tzq,{})})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsxs)(Co.xv,{size:1,textOverflow:"ellipsis",children:["Item of type ",(0,go.jsx)("code",{children:u})," not valid for this list"]})})]})})})}function rP(e){return e.map((e=>function(e){return Boolean(e&&"object"===typeof e&&"title"in e&&"value"in e)}(e)?{title:e.title||Js()(String(e.value)),value:e.value}:{title:Js()(String(e)),value:e}))}function oP(e){var t,n;const{schemaType:i,onChange:r,value:o=[],readOnly:s,path:a,changed:l,onIndexFocus:c,elementProps:d}=e,u=(0,vo.useMemo)((()=>{var e;return rP((null==(e=i.options)?void 0:e.list)||[])}),[null==(t=i.options)?void 0:t.list]),p="grid"===(null==(n=i.options)?void 0:n.layout);return(0,go.jsx)(nu,{path:a,isChanged:l,hasFocus:!1,children:(0,go.jsx)(Co.rj,{gap:2,columns:p?Math.min(u.length,4):1,...d,children:u.map(((e,t)=>{const n=function(e,t){return e.of.find((e=>e.name===(0,vl.wq)(t.value)))}(i,e),a=o.includes(e.value),l=!n;return(0,go.jsxs)(Co.kC,{align:"center",as:"label",muted:l,children:[(0,go.jsx)(Co.XZ,{disabled:l,checked:a,onChange:t=>((e,t)=>{const n=u.map((e=>e.value)).filter((n=>n===t?e:o.includes(n)));r(n.length>0?Tm(n):Im())})(t.currentTarget.checked,e.value),onFocus:()=>c(t),readOnly:s}),(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{children:e.title})}),!n&&(0,go.jsx)(iP,{value:e,onFocus:()=>c(t)})]},t)}))})})}function sP(e){return t=e,(0,mo.M1)(t.schemaType)?(0,go.jsx)(tP,{...e}):(0,go.jsx)(oP,{...e});var t}const aP=Es.ZP.div(Mn||(Mn=rd(["\n position: relative;\n"]))),lP=Es.ZP.div(On||(On=rd(["\n z-index: 13;\n opacity: 0;\n transition: opacity 300ms linear;\n"]))),cP=(0,Es.ZP)(Co.Zb)(Rn||(Rn=rd(["\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"]))),dP=(0,Es.ZP)(Co.kC)(zn||(zn=rd(["\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"])),cP,lP);function uP(e){const{children:t,message:n,onActivate:i,isOverlayActive:r}=e,[o,s]=(0,vo.useState)(!1),a=(0,vo.useCallback)((()=>{i&&i()}),[i]),l=(0,vo.useCallback)((e=>{r&&"Space"===e.code&&i&&(e.preventDefault(),i())}),[r,i]),c=(0,vo.useCallback)((()=>{s(!0)}),[]),d=(0,vo.useCallback)((()=>{s(!1)}),[]),u=(0,vo.useMemo)((()=>{const e="undefined"!==typeof window&&"ontouchstart"in window||"undefined"!==typeof navigator&&navigator.maxTouchPoints>0;let t=e?"Tap":"Click";o&&!e&&(t+=" or press space");const i=n||"".concat(t," to activate");return(0,go.jsx)(Co.xv,{weight:"semibold",children:i})}),[o,n]);return(0,go.jsxs)(aP,{onBlur:d,onClick:a,onFocus:c,onKeyDown:l,children:[r&&(0,go.jsxs)(dP,{tabIndex:0,align:"center",justify:"center",children:[(0,go.jsx)(cP,{radius:1}),(0,go.jsx)(lP,{children:u})]}),t]})}const pP=Es.ZP.span(Dn||(Dn=rd(["\n /* Make sure the annotation styling is visible */\n &[data-mark='code'] {\n mix-blend-mode: multiply;\n color: inherit;\n }\n"])));function hP(e){const{value:t,focused:n,selected:i,children:r,schemaType:o}=e,s=h_[t],a=o.component,l=(0,vo.useCallback)((e=>(0,go.jsx)(pP,{as:s,"data-mark":t,children:e.children})),[s,t]);return(0,vo.useMemo)((()=>{const e={focused:n,renderDefault:l,schemaType:o,selected:i,title:o.title,value:t};return a?(0,go.jsx)(a,{...e,children:r}):(0,go.jsx)(l,{...e,children:r})}),[a,l,r,n,o,i,t])}const fP={portal:!0,constrainSize:!0};
1function mP(e){const{disableRestoreFocusOnClose:t,menuButton:n,menuButtonProps:i,menuOptionsArray:r,onMenuClose:o}=e;return(0,go.jsx)(Co.j2,{__unstable_disableRestoreFocusOnClose:t,id:"menu-button",onClose:o,popover:fP,...i,button:n,menu:(0,go.jsx)(Co.v2,{children:r.map(((e,t)=>{const{collapsedProps:n={},expandedProps:i={},tooltipProps:r={},tooltipText:o,dividerBefore:s,fontSize:a,padding:l,text:c,icon:d,selected:u,...p}=e.props;return(0,go.jsxs)(vo.Fragment,{children:[s&&0!==t&&(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.sN,{text:c,icon:d,pressed:u,...p})]},e.key)}))})})}const gP=Es.ZP.div(Bn||(Bn=rd(["\n border-right: 1px solid var(--card-border-color);\n height: auto;\n\n &[data-hidden] {\n opacity: 0;\n }\n"])));function xP(e){const{hidden:t,...n}=e;return(0,go.jsx)(gP,{"data-ui":"CollapseMenuDivider","data-hidden":t?"":void 0,...n})}const vP=(0,Es.iv)(Ln||(Ln=rd(["\n list-style: none;\n display: flex;\n white-space: nowrap;\n\n &[data-hidden='true'] {\n opacity: 0;\n visibility: hidden;\n }\n"]))),yP=(0,Es.ZP)(Co.kC)(Zn||(Zn=rd(["\n padding: ","px;\n margin: -","px;\n box-sizing: border-box;\n"])),3,3),bP=(0,Es.ZP)(Co.kC)(Nn||(Nn=rd(["\n border-radius: inherit;\n position: relative;\n"]))),jP=(0,Es.ZP)(Co.kC)(qn||(qn=rd(["\n width: max-content;\n\n &[data-hidden='true'] {\n height: 0px;\n visibility: hidden;\n }\n"]))),wP=(0,Es.ZP)((function(e){const{callback:t,children:n,options:i,...r}=e,[o,s]=(0,vo.useState)(null);return(0,vo.useEffect)((()=>{if(!o)return;const e=new IntersectionObserver(t,i);return e.observe(o),()=>{e.unobserve(o),e.disconnect()}}),[o,t,i]),(0,go.jsx)(Co.kC,{ref:s,...r,children:n})}))(Un||(Un=rd(["\n ","\n"])),vP),kP=(0,Es.ZP)(Co.kC)(Vn||(Vn=rd(["\n ","\n"])),vP);function CP(e){return Boolean(e)}const _P=(0,vo.forwardRef)((function(e,t){const{children:n,collapsed:i,collapseText:r=!0,disableRestoreFocusOnClose:o,gap:s,menuButtonProps:a,onMenuClose:l,...c}=e,[d,u]=(0,vo.useState)(null),[p,h]=(0,vo.useState)(null),f=(0,Co.XL)(d),[m,g]=(0,vo.useState)([]),x=(0,vo.useMemo)((()=>!!(f&&d&&p)&&f.width<p.scrollWidth),[p,d,f]),v=(0,vo.useMemo)((()=>(null==a?void 0:a.button)||(0,go.jsx)(Co.zx,{icon:Ds.zGg,mode:"bleed"})),[a]),y=(0,vo.useMemo)((()=>({root:d,threshold:1,rootMargin:"2px"})),[d]),b=(0,vo.useMemo)((()=>vo.Children.toArray(n).filter(CP)),[n]),j=(0,vo.useMemo)((()=>b.filter((e=>{let{key:t}=e;return m.find((e=>e.key===t))}))),[b,m]),w=(0,vo.useMemo)((()=>i||j.length>0),[i,j.length]),k=(0,vo.useCallback)((e=>j.some((t=>t.key===e))),[j]),C=(0,vo.useCallback)(((e,t)=>{const n=k(t.key);if(e.isIntersecting||n||g((e=>[t,...e])),e.isIntersecting&&n){const e=j.filter((e=>{let{key:n}=e;return n!==t.key}));g(e)}}),[k,j]),_=(0,vo.useMemo)((()=>b.map((e=>{const{collapsedProps:t,expandedProps:n}=e.props,i=x?t:n,o=x&&r?void 0:e.props.text;return(0,vo.cloneElement)(e,{...i,text:o})}))),[b,r,x]);return i?(0,go.jsx)(mP,{disableRestoreFocusOnClose:o,menuButton:v,menuButtonProps:a,menuOptionsArray:b,onMenuClose:l}):(0,go.jsxs)(yP,{align:"center","data-ui":"CollapseMenu",overflow:"hidden",sizing:"border",ref:t,...c,children:[(0,go.jsxs)(bP,{direction:"column",flex:1,justify:"center",ref:u,children:[(0,go.jsx)(jP,{gap:s,children:_.map(((e,t)=>{const{dividerBefore:n,tooltipText:i="",tooltipProps:r={}}=e.props,o=k(e.key);return(0,go.jsxs)(vo.Fragment,{children:[n&&0!==t&&(0,go.jsx)(xP,{hidden:o}),(0,go.jsx)(wP,{options:y,callback:t=>C(t[0],e),"aria-hidden":o,"data-hidden":o,children:(0,go.jsx)(Co.u,{portal:!0,disabled:!i,content:(0,go.jsx)(Co.xu,{padding:2,sizing:"border",children:(0,go.jsx)(Co.xv,{size:1,children:i})}),...r,children:(0,go.jsx)(Co.kC,{children:(0,vo.cloneElement)(e,{disabled:e.props.disabled||o,"aria-hidden":o})})})})]},e.key)}))}),(0,go.jsx)(jP,{"data-hidden":!0,"aria-hidden":"true",gap:s,ref:h,children:b.map(((e,t)=>{const{dividerBefore:n}=e.props;return(0,go.jsxs)(vo.Fragment,{children:[n&&0!==t&&(0,go.jsx)(xP,{}),(0,go.jsx)(kP,{children:(0,vo.cloneElement)(e,{disabled:!0,"aria-hidden":!0})},e.key)]},e.key)}))})]}),w&&(0,go.jsx)(Co.kC,{marginLeft:s,children:(0,go.jsx)(mP,{disableRestoreFocusOnClose
1:o,menuButton:v,menuButtonProps:a,menuOptionsArray:j,onMenuClose:l})})]})})),SP=(0,vo.forwardRef)((function(e,t){const{collapsedProps:n={},expandedProps:i={},tooltipProps:r={},tooltipText:o,dividerBefore:s,...a}=e;return(0,go.jsx)(Co.zx,{"data-ui":"CollapseMenuButton",...a,ref:t})})),TP=Es.ZP.div(Kn||(Kn=rd(["\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"])));function IP(e){const{icon:t,active:n}=e,i=(0,vo.useMemo)((()=>({backgroundImage:"url(".concat(t,")"),filter:n?"invert(100%)":"invert(0%)"})),[n,t]);return(0,go.jsx)(TP,{style:i})}function PP(e,t,n){return e.schemaTypes.decorators.map((i=>{const r=Object.keys(n.marks||{}).find((e=>{var t;return(null==(t=n.marks)?void 0:t[e])===i.value}));let o=[];return r&&(o=[r]),{type:"format",disabled:t,icon:null==i?void 0:i.icon,key:i.value,handle:()=>{yl.q$.toggleMark(e,i.value),yl.q$.focus(e)},hotkeys:o,title:i.title}}))}function EP(e,t){return e.schemaTypes.lists.map((n=>({type:"listStyle",key:n.value,disabled:t,icon:null==n?void 0:n.icon,handle:()=>{yl.q$.toggleList(e,n.value)},title:n.title})))}
1function AP(e,t,n){const i=e.schemaTypes,r=yl.q$.focusChild(e),o=r&&r.text;return i.annotations.map((i=>{return{type:"annotation",disabled:!o||t,icon:(r=i,ic()(r,"icon")||ic()(r,"type.icon")||ic()(r,"type.to.icon")||ic()(r,"type.to[0].icon")),key:i.name,handle:t=>{t?(yl.q$.removeAnnotation(e,i),yl.q$.focus(e)):n(i)},title:i.title||lc()(i.name)};var r}))}function FP(e,t){const n=ic()(e,"to[0].icon");return e.icon||e.type&&e.type.icon||n||t}const MP={link:Ds.xPt},OP={strong:Ds.mY4,em:Ds.h32,"strike-through":Ds.dwl,underline:Ds.Adg,code:Ds.dNJ},RP={number:Ds.NvX,bullet:Ds.AEM};function zP(e,t){return e.icon?"string"===typeof e.icon?(0,go.jsx)(IP,{active:t,icon:e.icon}):e.icon:"annotation"===e.type?MP[e.key]||Ds.Tzq:"listStyle"===e.type?RP[e.key]||Ds.Tzq:OP[e.key]||Ds.Tzq}function DP(){const e=(0,yl._F)(),t=(0,yl.L9)();return(0,vo.useMemo)((()=>yl.q$.focusBlock(e)),[e,t])}function BP(e){let{hotkeys:t,onMemberOpen:n,resolveInitialValue:i,disabled:r}=e;const o=(0,yl._F)(),s=(0,vo.useCallback)((async e=>{const t=await i(e),r=yl.q$.addAnnotation(o,e,t);r&&r.markDefPath&&n(r.markDefPath)}),[o,n,i]);return(0,vo.useMemo)((()=>o?function(e,t,n,i){return[{name:"format",actions:PP(e,t,i)},{name:"list",actions:EP(e,t)},{name:"annotation",actions:AP(e,t,n)}]}(o,r,s,t):[]),[r,o,s,t])}const LP=(0,vo.memo)(_P),ZP={constrainSize:!0,portal:!0},NP={padding:2,mode:"bleed"},qP=(0,vo.memo)((function(e){const{disabled:t,groups:n,isFullscreen:i,collapsed:r}=e,o=DP(),s=(0,yl._F)(),a=(null==o?void 0:o._type)!==s.schemaTypes.block.name,l=!a&&Array.isArray(o.children)&&1===o.children.length&&""===(null==o?void 0:o.children[0].text),c=t||a,d=(0,vo.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;const n=(0,yl._F)(),i=(0,yl.L9)();return bd((0,vo.useMemo)((()=>{const e=yl.q$.activeAnnotations(n).map((e=>e._type));return t.filter((t=>"annotation"===t.type?e.includes(t.key):"listStyle"===t.type?yl.q$.hasListStyle(n,t.key):yl.q$.isMarkActive(n,t.key))).map((e=>e.key))}),[n,i]))}({actions:d}),p=(0,vo.useCallback)((()=>{yl.q$.focus(s)}),[s]),h=(0,vo.useMemo)((()=>d.map((e=>{const t="annotation"===e.type&&l,n=u.includes(e.key);return(0,vo.createElement)(SP,{disabled:c||t,...NP,dividerBefore:e.firstInGroup,icon:zP(e,n),key:e.key,onClick:()=>e.handle(n),selected:n,text:e.title||e.key,tooltipText:e.title||e.key,tooltipProps:{disabled:c||t,placement:i?"bottom":"top",portal:"default"}})}))),[d,u,c,l,i]),f=(0,vo.useMemo)((()=>({button:(0,go.jsx)(Co.zx,{icon:Ds.zGg,mode:"bleed",padding:2,disabled:c}),popover:ZP})),[c]);return(0,go.jsx)(LP,{collapsed:r,disableRestoreFocusOnClose:!0,gap:1,menuButtonProps:f,onMenuClose:p,children:h})})),UP=(0,vo.memo)(Co.j2),VP=(0,Es.ZP)(Co.sN)(Hn||(Hn=rd(["\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"]))),KP=(0,Es.ZP)(Co.zx)($n||($n=rd(["\n width: 100%;\n"]))),HP={constrainSize:!0,placement:"bottom-start",portal:"default"},$P={h1:e=>(0,go.jsx)(T_,{children:e}),h2:e=>(0,go.jsx)(I_,{children:e}),h3:e=>(0,go.jsx)(P_,{children:e}),h4:e=>(0,go.jsx)(E_,{children:e}),h5:e=>(0,go.jsx)(A_,{children:e}),h6:e=>(0,go.jsx)(F_,{children:e}),normal:e=>(0,go.jsx)(S_,{children:e}),blockquote:e=>(0,go.jsx)(O_,{"data-option":"blockquote",children:e})},WP=Object.keys($P),GP=e=>e.preventDefault(),XP={key:"style-none",style:"",title:"No style"},YP=(0,vo.memo)((function(e){const{disabled:t,items:n}=e,i=(0,yl._F)(),r=DP(),o=t||!!r&&i.schemaTypes.block.name!==r._type,s=function(e){let{items:t}=e;const n=(0,yl._F)(),i=DP(),r=(0,yl.L9)();return bd((0,vo.useMemo)((()=>t.filter((e=>yl.q$.hasBlockStyle(n,e.style))).map((e=>e.style))),[i,r]))}({items:n}),{activeItems:a,items:l}=(0,vo.useMemo)((()=>{const e=n.filter((e=>s.includes(e.style)));let t=n;return 0===e.length&&t.length>1&&(t=t.concat([XP]),e.push(XP)),{activeItems:e,items:t}}),[s,n]),c=(0,vo.useMemo)((()=>a.length>1?"Multiple":1===a.length?a[0].title:XP.title),[a]),d=(0,vo.useCallback)((e=>{if(r&&e.style!==r.style){const t=yl.q$.getSelection(i);yl.q$.toggleBlockStyle(i,e.style),yl.q$.select(i,null),t&&yl.q$.select(i,{...t})}setTimeout((()=>{yl.q$.focus(i)}))}),[i,r]),u=(0,vo.useCallback)(((e,t)=>WP.includes(e)?(0,$P[e])(t):(0,go.jsx)(Co.xv,{children:t})),[]),p=(0,vo.useMemo)((()=>(0,go.jsx)(KP,{disabled:o,iconRight:Ds.GVG,mode:"bleed",onClick:GP,padding:2,text:c})),[o,c]),h=(0,vo.useMemo)((()=>(0,go.jsx)(Co.v2,{disabled:o,children:l.map((e=>(0,go.jsx)(VP,{pressed:a.includes(e),onClick:o?void 0:()=>d(e),children:u(e.style,(null==e?void 0:e.title)||e.style)},e.key)))})),[o,a,d,l,u]);return(0,go.jsx)(UP,{popover:HP,id:"block-style-select",button:p,menu:h})})),JP=(0,vo.memo)(_P),QP={constrainSize:!0,portal:!0},eE=(0,vo.memo)((function(e){const{disabled:t,items:n,isFullscreen:i,collapsed:r}=e,o=DP(),s=(0,yl._F)(),a=o&&o._type!==s.schemaTypes.block.name,l=(0,vo.useCallback)((()=>{yl.q$.focus(s)}),[s]),c=(0,vo.useMemo)((()=>n.map((e=>
1{const n=e.type.title||Hc()(e.type.name);return(0,go.jsx)(SP,{"aria-label":"Insert ".concat(n).concat(e.inline?" (inline)":" (block)"),padding:2,mode:"bleed",disabled:t||a&&!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,a,i]),d=(0,vo.useMemo)((()=>({button:(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"bleed",padding:2,disabled:t}),popover:QP})),[t]);return(0,go.jsx)(JP,{collapsed:r,collapseText:!1,disableRestoreFocusOnClose:!0,gap:1,menuButtonProps:d,onMenuClose:l,children:c})})),tE=(0,Es.ZP)(Co.kC)(Wn||(Wn=rd(["\n width: 100%;\n"]))),nE=(0,Es.ZP)(Co.xu)(Gn||(Gn=rd(["\n width: 8em;\n"]))),iE=(0,Es.ZP)(Co.kC)(Xn||(Xn=rd(["\n border-right: 1px solid var(--card-border-color);\n"]))),rE=(0,Es.ZP)(Co.xu)(Yn||(Yn=rd(["\n ","\n"])),(e=>{let{$withInsertMenu:t}=e;return t&&(0,Es.iv)(Jn||(Jn=rd(["\n max-width: max-content;\n border-right: 1px solid var(--card-border-color);\n "])))})),oE=(0,Es.ZP)(Co.xu)(Qn||(Qn=rd(["\n border-left: 1px solid var(--card-border-color);\n"]))),sE="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),aE=(0,vo.memo)((function(e){let{actionGroups:t,blockStyles:n,disabled:i,insertMenuItems:r,isFullscreen:o,onToggleFullscreen:s}=e;const a=t.reduce(((e,t)=>e+t.actions.length),0)>0,l=r.length>0,[c,d]=(0,vo.useState)(null),u=(0,Co.XL)(c),p=!!u&&(null==u?void 0:u.width)<400,h=n.length>1;Kp({rootElement:c});const f=(0,vo.useCallback)((e=>{e.preventDefault(),e.stopPropagation()}),[]);return(0,go.jsxs)(tE,{align:"center",ref:d,onMouseDown:f,children:[h&&(0,go.jsx)(iE,{flex:p?1:void 0,children:(0,go.jsx)(nE,{padding:o?2:1,children:(0,go.jsx)(YP,{disabled:i,items:n})})}),(0,go.jsxs)(Co.kC,{flex:1,children:[a&&(0,go.jsx)(rE,{flex:p?void 0:1,padding:o?2:1,$withInsertMenu:l,children:(0,go.jsx)(qP,{disabled:i,collapsed:p,groups:t,isFullscreen:o})}),l&&(0,go.jsx)(Co.xu,{flex:p?void 0:1,padding:o?2:1,children:(0,go.jsx)(eE,{disabled:i,collapsed:p,items:r,isFullscreen:o})})]}),(0,go.jsx)(oE,{padding:o?2:1,children:(0,go.jsx)(Co.u,{content:(0,go.jsxs)(Co.kC,{align:"center",padding:1,children:[(0,go.jsx)(Co.xu,{flex:1,paddingX:1,children:(0,go.jsx)(Co.xv,{size:1,children:"".concat(o?"Collapse":"Expand"," editor")})}),(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.p8,{keys:["".concat(sE?"Cmd":"Ctrl"),"Enter"]})})]}),placement:o?"bottom":"top",portal:"default",children:(0,go.jsx)(Co.zx,{padding:2,icon:o?Ds.W5x:Ds.Qq,mode:"bleed",onClick:s})})})]})}));function lE(e){const{hotkeys:t,isFullscreen:n,readOnly:i,onMemberOpen:r,onToggleFullscreen:o}=e,s=(0,yl._F)(),a=(0,yl.L9)(),l=qq(),c=i||!a,{push:d}=(0,Co.pm)(),u=(0,vo.useCallback)((e=>{let t=!1;const n=setTimeout((()=>{t=!0,d({id:"resolving-initial-value",status:"info",title:"Resolving initial value\u2026"})}),300);return l(e,{}).then((e=>(t&&d({id:"resolving-initial-value",status:"info",duration:500,title:"Initial value resolved"}),e))).catch((t=>{d({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)))}),[d,l]),p=(0,vo.useCallback)((async e=>{const t=await u(e),n=yl.q$.insertBlock(s,e,t);n&&r(n)}),[s,r,u]),h=(0,vo.useCallback)((async e=>{const t=await u(e),n=yl.q$.insertChild(s,e,t);n&&r(n)}),[s,r,u]),f=BP({hotkeys:t,onMemberOpen:r,resolveInitialValue:u,disabled:!0}),m=(0,vo.useMemo)((()=>s.schemaTypes.styles.map((e=>({key:"style-".concat(e.value),style:e.value,styleComponent:e&&e.component,title:e.title})))),[s]),g=(0,vo.useMemo)((()=>function(e,t,n,i){const r=e.blockObjects.map(((e,t)=>({handle:()=>n(e),icon:FP(e,Ds.sTT),inline:!1,key:"block-".concat(t),type:e}))),o=e.inlineObjects.map(((e,t)=>({handle:()=>i(e),icon:FP(e,Ds.Kz2),inline:!0,key:"inline-".concat(t),type:e})));return r.concat(o).filter((e=>{var t;return!(null==(t=e.type)?void 0:t.hidden)}))}(s.schemaTypes,0,p,h)),[c,s,p,h]);return(0,go.jsx)(aE,{actionGroups:f,blockStyles:m,disabled:c,insertMenuItems:g,isFullscreen:n,onToggleFullscreen:o})}const cE=(0,Es.ZP)(Co.Zb)(ei||(ei=rd(["\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"})),dE=(0,Es.ZP)(Co.Zb)(ti||(ti=rd(["\n z-index: 10;\n line-height: 0;\n"]))),uE=(0,Es.ZP)(Co.Zb)(ni||(ni=rd(["\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"]))),pE=(0,Es.ZP)(ou)(ii||(ii=rd(["\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"]))),hE=(0,Es.ZP)(Co.W2)(ri||(ri=rd(["\n /* @todo: calculate from theme */\n /* max-width: 728px; */\n"]))),fE=(0,Es.ZP)(Co.Zb)(oi||(oi=rd(["\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"])),d_.map((e=>m_(e))).join(" "),d_.map((e=>(0,Es.iv)(si||(si=rd(["\n & > .pt-list-item-number[class~='pt-list-item-level-","'] {\n counter-increment: ",";\n }
1\n "])),e,m_(e)))),(e=>{let{theme:t}=e;return t.sanity.space[3]}),d_.map((e=>m_(e))).join(" "),(e=>{let{theme:t}=e;return t.sanity.space[2]}),d_.map((e=>m_(e))).join(" "),d_.slice(1).map((e=>(0,Es.iv)(ai||(ai=rd(["\n & > .pt-list-item-level-"," + .pt-list-item-level-"," {\n counter-reset: ",";\n }\n "])),e,e-1,m_(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,Co.hO)(n.sanity.space[5]):(0,Co.hO)(n.sanity.space[3])}),(e=>{let{$isFullscreen:t,theme:n}=e;return t?(0,Co.hO)(n.sanity.space[5]):(0,Co.hO)(n.sanity.space[3])}),(e=>{let{$isFullscreen:t,theme:n}=e;return t?(0,Co.hO)(2*n.sanity.space[5]):(0,Co.hO)(2*n.sanity.space[3])}));const mE=e=>{const{block:t,focused:n,children:i,selected:r,schemaType:o}=e,s=(0,vo.useMemo)((()=>(t.style&&R_[t.style]?R_[t.style]:R_[0])||S_),[t.style]),a=(0,vo.useCallback)((e=>(0,go.jsx)(s,{children:(0,go.jsx)(__,{"data-testid":"text-style--".concat(t.style),children:e.children})})),[s,t.style]);return(0,vo.useMemo)((()=>{const e=o.component,{title:s,value:l}=o,c={block:t,focused:n,renderDefault:a,schemaType:o,selected:r,title:s,value:l};return e?(0,go.jsx)(e,{...c,children:i}):(0,go.jsx)(a,{...c,children:i})}),[a,t,i,n,o,r])},gE=e=>(0,go.jsx)(go.Fragment,{children:e.children}),xE=e=>{const{block:t,children:n,schemaType:i,selected:r,focused:o,level:s,value:a}=e,{title:l,component:c}=i;return(0,vo.useMemo)((()=>{const e={block:t,focused:o,level:s,renderDefault:gE,schemaType:i,selected:r,title:l,value:a};return c?(0,go.jsx)(c,{...e,children:n}):(0,go.jsx)(gE,{...e,children:n})}),[c,t,n,o,s,i,r,l,a])},vE=e=>(0,go.jsx)(hP,{...e}),yE=e=>(0,go.jsx)(mE,{...e}),bE=e=>(0,go.jsx)(xE,{...e});function jE(e){const{hasFocus:t,hotkeys:n,initialSelection:i,isActive:r,isFullscreen:o,onCopy:s,onItemOpen:a,onPaste:l,onToggleFullscreen:c,path:d,readOnly:u,renderAnnotation:p,renderBlock:h,renderChild:f,scrollElement:m,setPortalElement:g,setScrollElement:x}=e,{isTopLayer:v}=(0,Co.sJ)(),y=(0,vo.useRef)(null),b=(0,yl._F)(),{element:j}=(0,Co.sz)();(0,Co.qh)((0,vo.useCallback)((e=>{v&&o&&"Escape"===e.key&&c()}),[c,o,v]));const w=(0,vo.useCallback)((()=>(0,go.jsx)(go.Fragment,{children:"Empty"})),[]),k=function(){const e=(0,yl._F)();return(0,vo.useMemo)((()=>{var t;const 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=function(e){return(0,vo.useMemo)((()=>(t,n)=>{if(yl.q$.getSelection(t)){const t=n.startContainer.parentElement;if(!t)return;(0,Xl.Z)(t,{scrollMode:"if-needed",boundary:e,block:"start",inline:"nearest"})}}),[e])}(m),_=(0,vo.useRef)(t);(0,vo.useEffect)((()=>{_.current=t}),[t]),(0,vo.useEffect)((()=>{_.current&&yl.q$.focus(b)}),[b,o]);const S=(0,vo.useMemo)((()=>(0,go.jsx)(yl.iV,{hotkeys:n,onCopy:s,onPaste:l,ref:y,renderAnnotation:p,renderBlock:h,renderChild:f,renderDecorator:vE,renderListItem:bE,renderPlaceholder:w,renderStyle:yE,scrollSelectionIntoView:C,selection:i,spellCheck:k})),[n,i,s,l,p,h,f,w,C,k]),T=(0,vo.useCallback)((e=>{a(d.concat(e))}),[a,d]);return(0,go.jsxs)(cE,{$fullscreen:o,"data-testid":"pt-editor",children:[r&&(0,go.jsx)(dE,{"data-testid":"pt-editor__toolbar-card",shadow:1,children:(0,go.jsx)(lE,{hotkeys:n,isFullscreen:o,onMemberOpen:T,onToggleFullscreen:c,readOnly:u})}),(0,go.jsxs)(uE,{flex:1,tone:u?"transparent":"default",children:[(0,go.jsx)(pE,{ref:x,children:(0,go.jsx)(hE,{padding:o?2:0,sizing:"border",width:1,children:(0,go.jsx)(fE,{$isFullscreen:o,tone:u?"transparent":"default",children:(0,go.jsx)(Co.NM,{element:o?m:j,children:S})})})}),(0,go.jsx)("div",{"data-portal":"",ref:g})]})]})}const wE=Es.ZP.div((e=>{let{theme:t}=e;const{focusRing:n,input:i}=t.sanity,r=t.sanity.color.base,o={color:t.sanity.color.input.default.enabled.border,width:i.border.width};return(0,Es.iv)(li||(li=rd(["\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 "])),pS(o),i.border.width,hS({base:r,border:o,focusRing:n}))})),kE=(0,Es.ZP)(Co.mh)(ci||(ci=rd(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n"])));function CE(e){const{focusPath:t,boundaryElement:n,onItemClose:i}=e,r=function(){const e=(0,vo.useContext)(NC);if(!e)throw new Error("Form context not provided");return e}(),o=(0,yl._F)(),s=(0,yl.L9)();(0,vo.useEffect)((()=>{var e,i,a,l;if(0===t.length)return;if((null==s?void 0:s.focus.path)&&(0,xo.Xy)(s.focus.path,t))return;const c=r.find((e=>e.member.open));if(c&&(null==(e=c.elementRef)?void 0:e.current)){n&&((0,Xl.Z)(n,{scrollMode:"if-needed",block:"start",inline:"start"}
1),(0,Xl.Z)(c.elementRef.current,{scrollMode:"if-needed",boundary:n,block:"start",inline:"start"}));const e=1===t.length,r="textBlock"===c.kind,s=r&&4===t.length&&"children"===t[1]&&"text"===t[3],d=r&&3===t.length&&"children"===t[1];if("textBlock"===c.kind){const n=d||s?t.slice(0,3):[t[0],"children",Array.isArray(null==(i=c.node.value)?void 0:i.children)&&(null==(a=c.node.value)?void 0:a.children[0]._key)&&{_key:null==(l=c.node.value)?void 0:l.children[0]._key}||0];(e||d||s)&&(yl.q$.select(o,{anchor:{path:n,offset:0},focus:{path:n,offset:0}}),yl.q$.focus(o))}}}),[n,o,t,i,r,null==s?void 0:s.focus.path])}function _E(e){const{changed:t,focused:n,focusPath:i=Ad,hasFocus:r,hotkeys:o,isActive:s,isFullscreen:a,onActivate:l,onCopy:c,onItemClose:d,onItemOpen:u,onItemRemove:p,onPaste:h,onPathFocus:f,onToggleFullscreen:m,path:g,readOnly:x,renderAnnotation:v,renderBlock:y,renderBlockActions:b,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,value:T}=e,I=(0,yl._F)(),P=(0,Co.sz)().element,[E,A]=(0,vo.useState)(null),[F,M]=(0,vo.useState)(null),O=(0,vo.useCallback)((()=>{m()}),[m]),R=function(e){const t=(0,yl._F)(),[n]=(0,vo.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,vo.useMemo)((()=>{const 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])}((0,vo.useMemo)((()=>({...o,custom:{"mod+enter":m,...(null==o?void 0:o.custom)||{}}})),[o,m])),z=T&&b?b:void 0,D=T&&j?j:void 0,[B,L]=(0,vo.useState)(null),Z=(0,vo.useCallback)((e=>{const{children:t,focused:n,path:i,selected:r,schemaType:o,value:s}=e;return(0,go.jsx)(z_,{floatingBoundary:P,focused:n,isFullscreen:a,onItemClose:d,onItemOpen:u,onItemRemove:p,onPathFocus:f,path:g.concat(i),readOnly:x,referenceBoundary:F,renderAnnotation:v,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderBlockActions:z,renderCustomMarkers:D,renderPreview:S,renderBlock:y,schemaType:o,selected:r,value:s,children:t})}),[z,D,F,a,d,u,p,f,P,g,x,v,y,w,k,C,_,S]),N=(0,vo.useCallback)((e=>{const{focused:t,path:n,selected:i,schemaType:r,value:o}=e;return(0,go.jsx)(l_,{floatingBoundary:P,focused:t,isFullscreen:a,onItemClose:d,onItemOpen:u,onItemRemove:p,onPathFocus:f,path:g.concat(n),readOnly:x,referenceBoundary:F,relativePath:n,renderAnnotation:v,renderBlock:y,renderBlockActions:z,renderCustomMarkers:D,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:r,selected:i,value:o})}),[P,F,a,d,u,p,f,g,x,v,y,z,D,w,k,C,_,S]),q=(0,vo.useCallback)((e=>{const{value:t}=e;return t._type===I.schemaTypes.block.name?Z(e):N(e)}),[I.schemaTypes.block.name,N,Z]),U=(0,vo.useCallback)((e=>{const{children:t,focused:n,path:i,selected:r,schemaType:o,value:s}=e;return s._type===I.schemaTypes.span.name?t:(0,go.jsx)(V_,{floatingBoundary:P,focused:n,onItemClose:d,onItemOpen:u,onPathFocus:f,path:g.concat(i),readOnly:x,referenceBoundary:F,relativePath:i,renderAnnotation:v,renderBlock:y,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:o,selected:r,value:s})}),[P,F,I.schemaTypes.span.name,d,u,f,g,x,v,y,j,w,k,C,_,S]),V=(0,vo.useCallback)((e=>{const{children:t,focused:i,path:r,selected:o,schemaType:s,value:a}=e;return(0,go.jsx)(Y_,{editorNodeFocused:i,floatingBoundary:P,focused:Boolean(n),onItemClose:d,onItemOpen:u,onPathFocus:f,path:g.concat(r),readOnly:x,referenceBoundary:F,renderAnnotation:v,renderBlock:y,renderCustomMarkers:j,renderField:w,renderInlineBlock:k,renderInput:C,renderItem:_,renderPreview:S,schemaType:s,selected:o,value:a,children:t})}),[P,F,n,d,u,f,g,x,v,y,j,w,k,C,_,S]),K=(0,vo.useMemo)((()=>(0,go.jsx)(jE,{hasFocus:r,hotkeys:R,isActive:s,isFullscreen:a,onItemOpen:u,onCopy:c,onPaste:h,onToggleFullscreen:O,path:g,readOnly:x,renderAnnotation:V,renderBlock:q,renderChild:U,setPortalElement:L,scrollElement:F,setScrollElement:M})),[F,R,O,r,V,q,U,s,a,c,u,h,g,x]),H=(0,Co.vI)(),$=(0,vo.useMemo)((()=>({collapsed:E,default:H.element,editor:B,expanded:H.element})),[H.element,B,E]);return CE({focusPath:i,boundaryElement:F,onItemClose:d}),(0,go.jsx)(Co.Xp,{__unstable_elements:$,children:(0,go.jsx)(uP,{onActivate:l,isOverlayActive:!s,children:(0,go.jsx)(nu,{disabled:a,hasFocus:Boolean(n),isChanged:t,path:g,children:(0,go.jsxs)(wE,{"data-focused":r?"":void 0,"data-read-only":x?"":void 0,children:[(0,go.jsx)(Co.xu,{"data-wrapper":"",ref:A,children:(0,go.jsx)(Co.h_,{__unstable_name:a?"expanded":"collapsed",children:a?(0,go.jsx)(kE,{children:K}):K})}),(0,go.jsx)("div",{"data-border":""})]})})})})}function SE(e){const{onChange:t,onIgnore:n,resolution:i,readOnly:r}=e,o=(0,vo.useCallback)((()=>{i&&t({type:"mutation",patches:i.patches})}),[t,i]);return i?(0,go.jsx)(Om,{suffix:(0,go.jsxs)(Co.Kq,{padding:2,children:[i.action&&(0,go.jsxs)(Co.rj,{columns:[1,2],gap:1,children:[(0,go.jsx)(Co.zx,{mode:"ghost",onClick:n,text:"Ignore"}),!r&&(0,go.jsx)(Co.zx,{onClick:o,text:i.action,tone:"caution"})]}),(0,go.jsx)(Co.xu,{padding:3,children:i.action&&(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:"NOTE: It\u2019s 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,go.jsx)(go.Fragment,{children:"Invalid Portable Text Editor value"}),children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:i.description}),(0,go.jsx)(Co.Zb,{border:!0,overflow:"auto",padding:2,tone:"inherit",children:(0,go.jsx)(Co.EK,{language:"json",children:JSON.stringify(i.item,null,2)})})]})}):null}function TE(e,t){const n=typeof e;return n===typeof t&&("object"===n?zs()(e,t):e===t)}function IE(e,t){if(e===t)return!0;
1if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length<t.length)return!1;for(let n=0,i=t.length;n<i;n++)if(!TE(t[n],e[n]))return!1;return!0}function PE(e,t){return t.some((t=>{return n=t.path,i=e,(0===n.length||IE(i,n)&&!IE(n,i))&&("set"===t.type||"unset"===t.type);var n,i}))}function EE(e,t){return t.reduce(((e,t)=>"object"===typeof t?fc()(e,t):ic()(e,t)),e)}function AE(e){const{elementProps:t,focused:n,focusPath:i,hotkeys:r,markers:o=Ad,members:s,onChange:a,onCopy:l,onItemRemove:c,onInsert:d,onPaste:u,onPathFocus:p,path:h,readOnly:f,renderBlockActions:m,renderCustomMarkers:g,schemaType:x,value:v}=e,{onBlur:y}=t;(0,vo.useImperativeHandle)(t.ref,(()=>({focus(){j.current&&yl.q$.focus(j.current)}})));const{subscribe:b}=function(e){const{path:t}=e,{patchChannel:n}=Lm().__internal,i=(0,vo.useCallback)((e=>n.subscribe((n=>{let{snapshot:i,patches:r}=n;const o=r.filter((e=>IE(e.path,t))).map((e=>({...e,path:e.path.slice(t.length)})));o.length&&e({shouldReset:PE(t,r),snapshot:Od(i)?EE(i,t):{},patches:o})}))),[t,n]);return{subscribe:i}}({path:h}),j=(0,vo.useRef)(null),[w,k]=(0,vo.useState)(!1),[C,_]=(0,vo.useState)(null),[S,T]=(0,vo.useState)(!1),[I,P]=(0,vo.useState)(!1),E=(0,Co.pm)(),A=(0,vo.useRef)([]),F=(0,vo.useMemo)((()=>new Po.x),[]),M=(0,vo.useMemo)((()=>F.asObservable()),[F]),O=(0,vo.useRef)(null),R=(0,vo.useCallback)((()=>{j.current&&T((e=>!e))}),[]);(0,vo.useEffect)((()=>{C&&v!==C.value&&_(null)}),[C,v]),(0,vo.useEffect)((()=>b((e=>{let{patches:t,snapshot:n}=e;F.next({patches:t,snapshot:n})}))),[F,b]);const z=(0,vo.useMemo)((()=>{var t;const n=[];for(const e of s)if("item"===e.kind){if(!OC(e.item.schemaType))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});const i=e.item.members.find((e=>"field"===e.kind&&"children"===e.name));if(i&&"field"===i.kind&&kk(i))for(const e of i.field.members)"item"===e.kind&&"span"!==e.item.schemaType.name&&n.push({kind:"inlineObject",member:e,node:e.item});const r=e.item.members.filter(RC).find((e=>"markDefs"===e.name));if(r)for(const e of r.field.members)"item"===e.kind&&"object"===e.item.schemaType.jsonType&&n.push({kind:"annotation",member:e,node:e.item})}}const i=n.map((t=>{const n=Ig(t.node.path),i=A.current.find((e=>e.key===n));let r;return"textBlock"!==t.kind&&(r=(0,go.jsx)(tC,{absolutePath:t.node.path,...e})),i?((t.member.open||i.node.value!==t.node.value)&&(i.input=r),i.member=t.member,i.node=t.node,i):{kind:t.kind,key:n,member:t.member,node:t.node,elementRef:(0,vo.createRef)(),input:r}}));return A.current=i,i}),[s,e]),D=n||function(e){return 1===e.length||3===e.length&&"children"===e[1]}(i);(0,vo.useEffect)((()=>{D&&P(!0)}),[D]);const B=(0,vo.useCallback)((e=>{switch(e.type){case"mutation":case"undo":case"redo":a(FE(e.patches));break;case"selection":(0,vo.startTransition)((()=>{e.selection&&p(e.selection.focus.path)}));break;case"focus":P(!0);break;case"blur":y(e.event);break;case"invalidValue":_(e);break;case"error":E.push({status:e.level,description:e.description})}}),[y,a,p,E]);(0,vo.useEffect)((()=>{k(!1)}),[v]);const L=(0,vo.useCallback)((()=>{k(!0)}),[]),Z=(0,vo.useMemo)((()=>C&&C.resolution?(0,go.jsx)(Co.xu,{marginBottom:2,children:(0,go.jsx)(SE,{onChange:B,onIgnore:L,resolution:C.resolution,readOnly:f})}):null),[B,L,C,f]),N=(0,vo.useCallback)((()=>{I||(P(!0),j.current&&yl.q$.focus(j.current))}),[I]);return(0,go.jsxs)(Co.xu,{ref:O,children:[!w&&Z,(!C||w)&&(0,go.jsx)(LC,{markers:o,children:(0,go.jsx)(qC,{memberItems:z,children:(0,go.jsx)(yl.q$,{ref:j,patches$:M,onChange:B,maxBlocks:void 0,readOnly:f,schemaType:x,value:v,children:(0,go.jsx)(_E,{...e,hasFocus:D,hotkeys:r,isActive:I,isFullscreen:S,onActivate:N,onItemRemove:c,onCopy:l,onInsert:d,onPaste:u,onToggleFullscreen:R,renderBlockActions:m,renderCustomMarkers:g})})})})]})}function FE(e){return e.map((e=>({...e,patchType:Cm})))}function ME(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function OE(e){const{base:t,border:n,focusRing:i}=e,r=i.offset+i.width,o=0-i.offset,s=t?t.bg:"var(--card-bg-color)";return[o>0&&"inset 0 0 0 ".concat(o,"px var(--card-focus-ring-color)"),n&&ME(n),o<0&&"0 0 0 ".concat(0-o,"px ").concat(s),r>0&&"0 0 0 ".concat(r,"px var(--card-focus-ring-color)")].filter(
1Boolean).join(",")}const RE=(0,Es.ZP)(Co.Zb)((e=>{const{theme:t}=e,{focusRing:n,input:i,radius:r}=t.sanity,o=t.sanity.color.input,s=(0,Co.hO)(t.sanity.space[1]);return{position:"relative",borderRadius:"".concat(r[1],"px"),color:o.default.enabled.fg,boxShadow:ME({color:o.default.enabled.border,width:i.border.width}),"& > .content":{position:"relative",lineHeight:0,margin:"-".concat(s," 0 0 -").concat(s)},"& > .content > div":{display:"inline-block",verticalAlign:"top",padding:"".concat(s," 0 0 ").concat(s)},"&:not([data-read-only])":{cursor:"text"},"@media(hover:hover)":{"&:not([data-disabled]):not([data-read-only]):hover":{borderColor:o.default.hovered.border}},"&:not([data-disabled]):not([data-read-only])[data-focused]":{boxShadow:OE({border:{color:o.default.enabled.border,width:i.border.width},focusRing:n})},"*:disabled + &":{color:o.default.disabled.fg,backgroundColor:o.default.disabled.bg,boxShadow:ME({color:o.default.disabled.border,width:i.border.width})}}})),zE=Es.ZP.input((e=>{const{theme:t}=e,n=t.sanity.fonts.text,i=t.sanity.color.input,r=t.sanity.space[2],o=t.sanity.fonts.text.sizes[2];return{appearance:"none",background:"none",border:0,borderRadius:0,outline:"none",fontSize:(0,Co.hO)(o.fontSize),lineHeight:o.lineHeight/o.fontSize,fontFamily:n.family,fontWeight:n.weights.regular,margin:0,display:"block",minWidth:"1px",maxWidth:"100%",boxSizing:"border-box",paddingTop:(0,Co.hO)(r-o.ascenderHeight),paddingRight:(0,Co.hO)(r),paddingBottom:(0,Co.hO)(r-o.descenderHeight),paddingLeft:(0,Co.hO)(r),"&:not(:invalid):not(:disabled)":{color:i.default.enabled.fg},"&:not(:invalid):disabled":{color:i.default.disabled.fg}}})),DE=(0,Es.ZP)(Co.xu)((e=>{const{theme:t}=e,n=t.sanity.color.input;return(0,Es.iv)(di||(di=rd(["\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)})),BE=(0,Es.ZP)(Co.xu)(ui||(ui=rd(['\n // This is needed to make textOverflow="ellipsis" work properly for the Text primitive\n max-width: 100%;\n']))),LE=(0,vo.forwardRef)(((e,t)=>{const{disabled:n,onChange:i,onFocus:r,placeholder:o,readOnly:s,value:a=[],...l}=e,c=(0,vo.useMemo)((()=>o||("undefined"!==typeof window&&"ontouchstart"in window?"Enter tag\u2026":"Enter tag and press ENTER\u2026")),[o]),[d,u]=(0,vo.useState)(""),p=!n&&!s,[h,f]=(0,vo.useState)(!1),m=(0,Co.ts)(t),g=(0,vo.useRef)(null),x=(0,vo.useCallback)((e=>{if((0,Co.Re)(e.target)&&e.target.closest('[data-ui="Tag"]'))return;const t=m.current;t&&setTimeout((()=>t.focus()),0)}),[m]),v=(0,vo.useCallback)((()=>{f(!1)}),[]),y=(0,vo.useCallback)((e=>{u(e.currentTarget.value)}),[]),b=(0,vo.useCallback)((e=>{f(!0),r&&r(e)}),[r]),j=(0,vo.useCallback)((e=>{if("Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),i&&d)){const e=a.concat([{value:d}]);u(""),i&&i(e)}}),[d,i,a]),w=(0,vo.useCallback)((e=>{if(!i)return;const t=a.slice(0);t.splice(e,1),i(t)}),[i,a]);return(0,vo.useEffect)((()=>{const e=m.current;e&&(e.style.width="0",e.style.width="".concat(e.scrollWidth,"px"))}),[m,d]),(0,go.jsxs)(RE,{"data-disabled":n?"":void 0,"data-focused":h?"":void 0,"data-read-only":s?"":void 0,"data-ui":"TagInput",onPointerDown:x,overflow:"auto",padding:1,ref:g,children:[p&&(0,go.jsx)(DE,{hidden:Boolean(d||a.length),padding:3,children:(0,go.jsx)(Co.xv,{textOverflow:"ellipsis",children:c})}),(0,go.jsxs)("div",{className:"content",children:[a.map(((e,t)=>(0,go.jsx)(BE,{children:(0,go.jsx)(ZE,{enabled:p,index:t,muted:!p,onRemove:w,tag:e})},"tag-".concat(t)))),(0,go.jsx)("div",{children:(0,go.jsx)(zE,{...l,disabled:!p,onBlur:v,onChange:y,onFocus:b,onKeyDown:j,ref:m,type:"text",value:d})},"tag-input")]})]})}));function ZE(e){const{enabled:t,index:n,muted:i,onRemove:r,tag:o}=e,s=(0,vo.useCallback)((()=>{r(n)}),[n,r]);return(0,go.jsx)(Co.Zb,{"data-ui":"Tag",padding:1,radius:2,tone:"transparent",children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.xu,{flex:1,padding:1,children:(0,go.jsx)(Co.xv,{muted:i,textOverflow:"ellipsis",children:o.value})}),t&&(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.zx,{icon:Ds.Two,mode:"bleed",onClick:s,padding:1})})]})})}function NE(e){const{onChange:t,readOnly:n,value:i=[],elementProps:r}=e,o=(0,vo.useMemo)((()=>null==i?void 0:i.map((e=>({value:e})))),[i]),s=(0,vo.useCallback)((e=>{t(0===e.length?Im():Tm(e.map((e=>e.value))))}),[t]);return(0,go.jsx)(LE,{onChange:s,readOnly:n,value:o,...r})}LE.displayName="TagInput";const qE={portal:!0,tone:"default"};function UE(e){const{member:t,sortable:n,onRemove:i}=e,r=(0,vo.useId)();return(0,go.jsx)(Co.xu,{paddingX:1,children:(0,go.jsx)(Wj,{dragHandle:n,tone:"caution",menu:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(r,"-menuButton"),menu:(0,go.jsx)(Co.v2,{children:(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:i})}),popover:qE}),children:"INVALID_ITEM_TYPE"===t.error.type?(0,go.jsx)(iP,{value:t.error.value}):(0,go.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})})})}function VE(e){const{hoveringFiles:t,types:n,resolveUploader:i}=e,r=t.filter((e=>n.some((t=>i(t,e))))),o=t.length-r.length,s=n.length>1;return(0,go.jsx)(go.Fragment,{children:r.length>0?(0,go.jsxs)(go.Fragment,{children:[(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.rG2,{})}),(0,go.jsxs)(Co.xv,{children:["Drop to upload"," ",s&&(0,go.jsxs)(go.Fragment,{children:[r.length," file",r.length>
11?"s":""]})]})]}),o>0&&(0,go.jsx)(Co.xu,{marginTop:4,children:(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsx)(Co.xv,{muted:!0,size:1,children:(0,go.jsx)(Ds.vaB,{})}),(0,go.jsxs)(Co.xv,{muted:!0,size:1,children:[o," file",o>1?"s":""," can't be uploaded here"]})]})})]}):(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.vaB,{})}),(0,go.jsxs)(Co.xv,{children:["Can't upload ",t.length>1?"any of these files":"this file"," here"]})]})})}const KE=(0,Es.ZP)(Co.mh)(pi||(pi=rd(["\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"]))),HE=Es.ZP.div(hi||(hi=rd(["\n position: relative;\n"])));function $E(e,t,n){return e.map((e=>({type:e,uploader:t(e,n)}))).filter((e=>e.uploader))}const WE=function(e){const t=uS(e);return vo.forwardRef((function(e,n){const{children:i,resolveUploader:r,onUpload:o,types:s,...a}=e,{push:l}=(0,Co.pm)(),c=vo.useCallback(((e,t)=>{const{type:n,uploader:i}=t;
1null==o||o({file:e,schemaType:n,uploader:i})}),[o]),d=vo.useCallback((e=>{if(!r)return;const t=e.map((e=>({file:e,uploaderCandidates:$E(s,r,e)}))),n=t.filter((e=>e.uploaderCandidates.length>0)),i=t.filter((e=>0===e.uploaderCandidates.length));if(i.length>0){const e=i.length>1;l({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,go.jsxs)(Co.kC,{padding:2,children:[(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.xv,{weight:"semibold",children:e.file.name})}),(0,go.jsx)(Co.xu,{paddingLeft:2,children:(0,go.jsxs)(Co.xv,{size:1,children:["(",e.file.type,")"]})})]},t)))})}n.forEach((e=>{c(e.file,Fs()(e.uploaderCandidates,(e=>e.uploader.priority))[0])}))}),[l,r,s,c]),[u,p]=vo.useState([]),h=vo.useCallback((()=>p([])),[]);return(0,go.jsx)(HE,{children:(0,go.jsxs)(t,{...a,ref:n,onFiles:d,onFilesOver:p,onFilesOut:h,children:[r&&u.length>0&&(0,go.jsx)(KE,{zOffset:10,children:(0,go.jsx)(VE,{hoveringFiles:u,types:s,resolveUploader:r})}),i]})})}))}(fS(Co.Zb));function GE(e,t,n){return function(e,t,n){let i=t-1,r=t;const o=e.length;for(;i>-1||r<o;){const t=e[r];if(r<o&&n(t,r))return r;const s=e[i];if(i>-1&&n(s,i))return i;i--,r++}return-1}(e,t,(e=>e===n))}const XE={portal:!0,tone:"default"},YE=vo.forwardRef((function(e,t){const{sortable:n,value:i,insertableTypes:r,onInsert:o,onRemove:s,readOnly:a,inputId:l,validation:c,children:d,presence:u,schemaType:p}=e,h=c.filter((e=>"error"===e.level)).length>0,f=c.filter((e=>"warning"===e.level)).length>0,m=(0,vo.useCallback)(((e,t)=>{o({position:e,items:[Hk(t)]})}),[o]),g=(0,vo.useCallback)((()=>{i&&o({position:"after",items:[i]})}),[o,i]),x=(0,vo.useMemo)((()=>h?"critical":f?"caution":void 0),[h,f]),v=(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(l,"-menuButton"),popover:XE,menu:(0,go.jsxs)(Co.v2,{children:[(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:s}),(0,go.jsx)(Co.sN,{text:"Duplicate",icon:Ds.TIy,onClick:g}),(0,go.jsx)(sw,{types:r,onInsert:m})]})});return(0,go.jsx)(Wj,{tone:x,menu:!a&&v,dragHandle:!a&&n,presence:0===u.length?null:(0,go.jsx)(Db,{presence:u,maxAvatars:1}),validation:c.length>0?(0,go.jsx)(Co.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,go.jsx)(hj,{validation:c})}):null,children:(0,go.jsx)(Co.kC,{align:p?"flex-end":"center",ref:t,children:(0,go.jsx)(Co.kC,{align:"flex-end",flex:1,children:(0,go.jsx)(Co.xu,{flex:1,marginRight:2,children:d})})})})}));function JE(e){const{schemaType:t,readOnly:n,children:i,onValueCreate:r,onItemAppend:o}=e,s=(0,vo.useId)(),a=vo.useCallback((e=>{o(r(e))}),[r,o]),l=vo.useCallback((()=>{a(t.of[0])}),[t,a]),c=(0,vo.useMemo)((()=>({constrainSize:!0,portal:!0})),[]);return n?(0,go.jsx)(Co.u,{portal:!0,content:(0,go.jsx)(Co.xu,{padding:2,sizing:"border",children:(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"This field is read-only"})}),children:(0,go.jsx)(Co.rj,{children:(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",disabled:!0,text:1===t.of.length?"Add item":"Add item..."})})}):(0,go.jsxs)(Co.rj,{gap:1,style:{gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))"},children:[1===t.of.length?(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",onClick:l,text:"Add item"}):(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{icon:Ds.dtP,mode:"ghost",text:"Add item\u2026"}),id:s||"",menu:(0,go.jsx)(Co.v2,{children:t.of.map(((e,t)=>{var n,i;const r=(0,mo.dD)(e)&&1===(e.to||[]).length&&e.to[0].icon,o=e.icon||(null==(n=e.type)?void 0:n.icon)||r;return(0,go.jsx)(Co.sN,{text:e.title||(null==(i=e.type)?void 0:i.name),onClick:()=>a(e),icon:o},t)}))}),popover:c}),i]})}var QE=Object.defineProperty,eA=(e,t,n)=>(((e,t,n)=>{t in e?QE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class tA extends vo.PureComponent{constructor(e){super(e),eA(this,"_element",null),eA(this,"handleAppend",(e=>{const{value:t=[],onIndexFocus:n,onItemAppend:i}=this.props;i(e),n(t.length)})),eA(this,"handlePrepend",(e=>{const{onIndexFocus:t,value:n=[],onItemPrepend:i}=this.props;i(e),t(n.length)})),eA(this,"handleSortEnd",(e=>{const{onIndexFocus:t,onMoveItem:n,value:i}=this.props;i&&n(e),t(e.toIndex)})),eA(this,"handleItemMoveStart",(()=>{this.setState({disableTransition:!1})})),eA(this,"handleItemMoveEnd",(()=>{this.setState({disableTransition:!0})})),eA(this,"renderArrayItem",(e=>{var t;const{schemaType:n}=this.props,i=!1!==(null==(t=n.options)?void 0:t.sortable);return(0,go.jsx)(YE,{...e,sortable:i,insertableTypes:n.of})})),this.state={disableTransition:!1}}focus(){this._element&&this._element.focus()}getSnapshotBeforeUpdate(e){var t;const{focusPath:n=[],value:i=[]}=e,{focusPath:r=[],value:o=[]}=this.props;if(n[0]===r[0]&&i.length!==o.length){const e=r[0],n=window.getSelection();if(!((null==n?void 0:n.focusNode)instanceof HTMLElement))return null;const 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;const{onIndexFocus:r}=this.props;if((null==n?void 0:n.restoreSelection)&&e.value){const t=e.value[n.prevFocusedIndex],o=GE(this.props.value||[],n.prevFocusedIndex,t);if(-1===o)return;const s=null==(i=this._element)?void 0:i.querySelector("[data-item-index='".concat(o,"'] input,textarea"));if(s instanceof HTMLInputElement){s.focus();try{s.setSelectionRange(n.restoreSelection.start,n.restoreSelection.end)}catch{}}r(o)}}render(){const{schemaType:e,members:t,readOnly:n,renderInput:i,onUpload:r,onItemRemove:o,resolveUploader:s,elementProps:a,arrayFunctions:l=JE}=this.props,c=!n&&!1!==ic()(e,"options.sortable"),d=t.map((e=>({id:"".concat(e.key,"-").concat("item"===e.kind?e.item.value:"error"),member:e})));return(0,go.jsxs)(Co.Kq,{space:3,"data-testid":"array-primitives-input",children:[(0,go.jsx)(WE,{types:e.of,resolveUploader:s,onUpload:r,...a,tabIndex:0,children:(0,go.jsx)(Co.Kq,{space:1,children:0===d.length?(0,go.jsx)(Co.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:e.placeholder||(0,go.jsx)(go.Fragment,{children:"No items"})})}):(0,go.jsx)(Co.Zb,{padding:1,border:!0,children:(0,go.jsx)(Kj,{onItemMove:this.handleSortEnd,onItemMoveStart:this.handleItemMoveStart,onItemMoveEnd:this.handleItemMoveEnd,items:d.map((e=>e.id)),sortable:c,gap:1,children:d.map(((e,t)=>{let{member:n,id:r}=e;return(0,go.jsxs)(Hj,{id:r,sortable:c,disableTransition:this.state.disableTransition,children:["item"===n.kind&&(0,go.jsx)($k,{member:n,renderItem:this.renderArrayItem,renderInput:i}),"error"===n.kind&&(0,go.jsx)(UE,{sortable:c,member:n,onRemove:()=>o(t)})]},n.key)}))})})})}),(0,go.jsx)(l,{onChange:this.props.onChange,onItemAppend:this.handleAppend,onItemPrepend:this.handlePrepend,onValueCreate:Hk,readOnly:this.props.readOnly,schemaType:this.props.schemaType,value:this.props.value})]})}}const nA=(0,Es.ZP)(Co.kC)(fi||(fi=rd(["\n min-height: 35px;\n"]))),iA=(0,Es.ZP)(Co.kC)(mi||(mi=rd(["\n position: absolute;\n top: 0;\n right: 0;\n height: 35px;\n"]))),rA=(0,Es.ZP)(Co.Zb)(gi||(gi=rd(["\n position: absolute;\n top: 0;\n left: 0;\n"]))),oA=(0,Es.ZP)(Co.Zb)(xi||(xi=rd(["\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"])),rA,rA,zj);function sA(e){const{validation:t,selected:n,tone:i,presence:r,children:o,dragHandle:s,menu:a,footer:l,...c}=e;return(0,go.jsxs)(oA,{forwardedAs:Co.kC,direction:"column",border:!0,selected:n,"aria-selected":n,radius:2,tone:i,...c,children:[o,s&&(0,go.jsx)(rA,{margin:1,radius:2,display:"flex",tone:"inherit","data-ui":"DragHandleCard",children:(0,go.jsx)(Rj,{grid:!0,padding:2,mode:"ghost"})}),r&&(0,go.jsx)(iA,{align:"center",marginX:1,children:r}),(0,go.jsxs)(nA,{align:"center",paddingX:1,sizing:"border",justify:"space-between",children:[(0,go.jsx)(Co.kC,{children:t}),(0,go.jsx)(Co.xu,{children:l}),a]})]})}const aA=(0,Es.ZP)(Co.Zb)(vi||(vi=rd(["\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"])));const lA={portal:!0,tone:"default"},cA={position:"absolute",top:0,left:0,bottom:0,right:0};function dA(e){var t,n,i,r,o,s;const{schemaType:a,parentSchemaType:l,path:c,readOnly:d,onRemove:u,value:p,open:h,onInsert:f,onF
1ocus:m,onOpen:g,onClose:x,changed:v,focused:y,children:b,inputProps:{renderPreview:j}}=e,w=!d&&!1!==(null==(t=l.options)?void 0:t.sortable),k=l.of,C=(0,vo.useRef)(null);xb(C,h),zm(y,((e,t)=>{var n;!e&&t&&C.current&&(null==(n=C.current)||n.focus())}));const _=p._resolvingInitialValue,S=(0,vo.useCallback)((()=>{f({items:[{...p,_key:yb()}],position:"after"})}),[f,p]),T=(0,vo.useCallback)(((e,t)=>{f({items:[rw(t)],position:e})}),[f]),I=Qm(c,!0),P=(0,vo.useMemo)((()=>0===I.length?null:(0,go.jsx)(Db,{presence:I,maxAvatars:1})),[I]),E=ig(c,!0),A=(0,vo.useMemo)((()=>0===E.length?null:(0,go.jsx)(Co.xu,{marginLeft:1,paddingX:1,paddingY:3,children:(0,go.jsx)(hj,{validation:E,__unstable_showSummary:!0})})),[E]),F=E.some((e=>"error"===e.level)),M=E.some((e=>"warning"===e.level)),O=(0,vo.useMemo)((()=>d?null:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(e.inputId,"-menuButton"),menu:(0,go.jsxs)(Co.v2,{children:[(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:u}),(0,go.jsx)(Co.sN,{text:"Duplicate",icon:Ds.TIy,onClick:S}),(0,go.jsx)(sw,{types:k,onInsert:T})]}),popover:lA})),[S,T,u,k,e.inputId,d]),R=function(e){let{readOnly:t,hasErrors:n,hasWarnings:i}=e;return t?"transparent":n?"critical":i?"caution":"default"}({readOnly:d,hasErrors:F,hasWarnings:M}),z=(0,go.jsx)(sA,{menu:O,presence:P,validation:A,tone:R,radius:2,border:!0,focused:y,dragHandle:w,selected:h,children:(0,go.jsxs)(aA,{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:a,value:p,layout:"media",withBorder:!1,withShadow:!1}),_&&(0,go.jsx)(Co.Zb,{as:Co.kC,style:cA,children:(0,go.jsxs)(Co.kC,{align:"center",justify:"center",gap:1,padding:1,children:[(0,go.jsx)(Co.xu,{padding:3,children:(0,go.jsx)(Co.$j,{muted:!0})}),(0,go.jsx)(Co.xv,{muted:!0,size:1,children:"Resolving initial value\u2026"})]})})]})}),D=Nh(a);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(nu,{path:c,isChanged:v,hasFocus:Boolean(y),children:z}),h&&(0,go.jsx)(sC,{header:d?"View ".concat(D):"Edit ".concat(D),type:(null==(i=null==(n=null==l?void 0:l.options)?void 0:n.modal)?void 0:i.type)||"dialog",width:null!=(s=null==(o=null==(r=null==l?void 0:l.options)?void 0:r.modal)?void 0:o.width)?s:1,id:p._key,onClose:x,autofocus:y,legacy_referenceElement:C.current,children:b})]})}const uA=(0,Es.ZP)(Co.Zb)(yi||(yi=rd(["\n max-width: ","px;\n"])),(e=>{let{theme:t}=e;return t.sanity.container[1]}));function pA(e){const{value:t,onFocus:n,vertical:i,...r}=e,[o,s]=vo.useState(!1),[a,l]=vo.useState(null);(0,Co.O8)((()=>s(!1)),[a]);const c=vo.useCallback((e=>{"Escape"!==e.key&&"Tab"!==e.key||s(!1)}),[]),d=(0,vo.useCallback)((()=>{s((e=>!e))}),[]),u=(0,vl.wq)(t);return(0,go.jsx)(Co.J2,{open:o,ref:l,onKeyDown:c,portal:!0,constrainSize:!0,tone:"default",content:(0,go.jsx)(uA,{margin:1,padding:3,onKeyDown:c,tabIndex:0,overflow:"auto",children:(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{weight:"semibold",children:"Why is this happening?"})}),(0,go.jsxs)(Co.xv,{size:1,children:["The current schema does not declare items of type ",(0,go.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,go.jsx)(Co.xu,{children:(0,go.jsxs)(Co.xv,{size:1,children:[(0,go.jsx)(Ds.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,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:"JSON representation of this item:"}),(0,go.jsx)(Co.Zb,{padding:2,overflow:"auto",border:!0,children:(0,go.jsx)(Co.EK,{size:1,as:"pre",language:"json",children:JSON.stringify(t,null,2)})})]})]})}),children:(0,go.jsx)(Co.Zb,{as:"button",type:"button",radius:2,tone:"inherit",paddingX:2,paddingY:3,style:{height:"100%"},onFocus:n,onClick:d,onKeyDown:c,__unstable_focusRing:!0,...r,children:(0,go.jsxs)(Co.Kq,{space:4,marginTop:2,children:[(0,go.jsx)(Co.xu,{margin:1,children:(0,go.jsx)(Co.xv,{align:"center",size:4,children:(0,go.jsx)(Ds.Tzq,{})})}),(0,go.jsxs)(Co.xv,{align:"center",size:1,children:["Items of type ",(0,go.jsx)("code",{children:u}
1)," is not valid for this list"]})]})})})}const hA={portal:!0,tone:"default"};function fA(e){const{member:t,sortable:n}=e,i=(0,vo.useId)(),{onChange:r}=Wm(),o=(0,vo.useCallback)((()=>{r(Am.from([Im([{_key:t.key}])]))}),[r,t.key]);return(0,go.jsx)(sA,{dragHandle:n,tone:"caution",style:{height:"100%"},menu:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:"bleed",icon:Ds.zGg}),id:"".concat(i,"-menuButton"),menu:(0,go.jsx)(Co.v2,{children:(0,go.jsx)(Co.sN,{text:"Remove",tone:"critical",icon:Ds.XHJ,onClick:o})}),popover:hA}),children:"INVALID_ITEM_TYPE"===t.error.type?(0,go.jsx)(pA,{value:t.error.value,vertical:!0}):(0,go.jsxs)("div",{children:["Unexpected Error: ",t.error.type]})})}const mA=[];function gA(e){var t;const{arrayFunctions:n=Nm,elementProps:i,members:r,onChange:o,onInsert:s,onItemMove:a,onUpload:l,readOnly:c,renderAnnotation:d,renderBlock:u,renderField:p,renderInlineBlock:h,renderInput:f,renderPreview:m,resolveUploader:g,schemaType:x,value:v=mA}=e,y=(0,vo.useCallback)((e=>{s({items:[e],position:"before",referenceItem:0})}),[s]),b=(0,vo.useCallback)((e=>{s({items:[e],position:"after",referenceItem:-1})}),[s]),j=!1!==(null==(t=x.options)?void 0:t.sortable),w=(0,vo.useCallback)((e=>(0,go.jsx)(dA,{...e})),[]),k=(0,vo.useMemo)((()=>r.map((e=>e.key))),[r]);return(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(WE,{types:x.of,resolveUploader:g,onUpload:l,...i,tabIndex:0,children:(0,go.jsxs)(Co.Kq,{"data-ui":"ArrayInput__content",space:3,children:[0===(null==r?void 0:r.length)&&(0,go.jsx)(Co.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:x.placeholder||(0,go.jsx)(go.Fragment,{children:"No items"})})}),(null==r?void 0:r.length)>0&&(0,go.jsx)(Co.Zb,{border:!0,radius:1,children:(0,go.jsx)(Kj,{columns:[2,3,4],gap:3,padding:1,margin:1,items:k,onItemMove:a,sortable:j,children:r.map((e=>(0,go.jsxs)(Hj,{sortable:j,id:e.key,flex:1,children:["item"===e.kind&&(0,go.jsx)(Kk,{member:e,renderAnnotation:d,renderBlock:u,renderInlineBlock:h,renderItem:w,renderField:p,renderInput:f,renderPreview:m}),"error"===e.kind&&(0,go.jsx)(fA,{sortable:j,member:e})]},e.key)))})})]})}),(0,go.jsx)(n,{onChange:o,onItemAppend:b,onItemPrepend:y,onValueCreate:rw,readOnly:c,schemaType:x,value:v})]})}const xA=[];function vA(e){var t;const{arrayFunctions:n=Nm,elementProps:i,members:r,onChange:o,onInsert:s,onItemMove:a,onUpload:l,focusPath:c,readOnly:d,renderAnnotation:u,renderBlock:p,renderField:h,renderInlineBlock:f,renderInput:m,renderItem:g,renderPreview:x,resolveUploader:v,schemaType:y,value:b=xA}=e,[j,w]=(0,vo.useState)(null),{space:k}=(0,Co.Fg)().sanity,C=(0,vo.useCallback)((e=>{s({items:[e],position:"before",referenceItem:0})}),[s]),_=(0,vo.useCallback)((e=>{s({items:[e],position:"after",referenceItem:-1})}),[s]),S=function(e,t){const n=(0,vo.useRef)(e),i=n.current,r=t(i,e);return(0,vo.useEffect)((()=>{r||(n.current=e)})),r?i:e}((0,vo.useMemo)((()=>r.map((e=>e.key))),[r]),zs()),{scrollElement:T}=function(){const e=(0,vo.useContext)(iC);if(!e)throw new Error("VirtualizerScrollInstance: missing context value");return e}(),I=(0,vo.useRef)(null),P=(0,vo.useMemo)((()=>(0,mo.Fd)(c[0])?c[0]._key:c[0]),[c]),E=(0,vo.useCallback)((e=>{const t={...e};if(null!==j&&(t.startIndex=Math.min(e.startIndex,j),t.endIndex=Math.max(e.endIndex,j)),P){const e=S.findIndex((e=>e===P));-1!==e&&(t.startIndex=Math.min(t.startIndex,e),t.endIndex=Math.max(t.endIndex,e))}return(0,Os.MK)(t)}),[j,P,S]),A=(0,vo.useCallback)(((e,t)=>{if(!e.scrollElement)return;const n=e.scrollElement,i=()=>{var e,i;const r=null!=(i=null==(e=I.current)?void 0:e.offsetTop)?i:0;t(n.scrollTop-r)};return i(),e.scrollElement.addEventListener("scroll",i,{capture:!1,passive:!0}),()=>{n.removeEventListener("scroll",i)}}),[]),F=(0,vo.useCallback)((()=>53),[]),M=(0,Ms.MG)({count:r.length,estimateSize:F,getScrollElement:(0,vo.useCallback)((()=>T),[T]),observeElementOffset:A,rangeExtractor:E,getItemKey:(0,vo.useCallback)((e=>S[e]),[S])}),O=M.getVirtualItems(),R=(0,vo.useCallback)((e=>{var t,n;const{active:i}=e;w(null==(n=null==(t=i.data.current)?void 0:t.sortable)?void 0:n.index)}),[]),z=(0,vo.useCallback)((()=>{w(null)}),[]),D=!1!==(null==(t=y.options)?void 0:t.sortable);return(0,go.jsxs)(Co.Kq,{space:3,ref:I,children:[(0,go.jsx)(WE,{types:y.of,resolveUploader:v,onUpload:l,...i,tabIndex:0,children:(0,go.jsx)(Co.Kq,{"data-ui":"ArrayInput__c
1ontent",space:3,children:0===r.length?(0,go.jsx)(Co.Zb,{padding:3,border:!0,style:{borderStyle:"dashed"},radius:2,children:(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:y.placeholder||(0,go.jsx)(go.Fragment,{children:"No items"})})}):(0,go.jsx)(Co.Zb,{border:!0,radius:1,style:{height:"".concat(M.getTotalSize()+O.length*k[1]+k[1],"px"),width:"100%",position:"relative"},children:(0,go.jsx)(Kj,{axis:"y",gap:1,paddingY:1,items:S,onItemMove:a,onItemMoveStart:R,onItemMoveEnd:z,sortable:D,style:{position:"absolute",top:0,left:0,width:"100%",transform:"translateY(".concat(O[0].start,"px)")},children:O.map((t=>{const n=r[t.index];return(0,go.jsxs)(Hj,{ref:M.measureElement,sortable:D,"data-index":t.index,id:n.key,children:["item"===n.kind&&(0,go.jsx)(Kk,{member:n,renderAnnotation:u,renderBlock:p,renderField:h,renderInlineBlock:f,renderInput:m,renderItem:g,renderPreview:x}),"error"===n.kind&&(0,go.jsx)(UE,{sortable:D,member:n,onRemove:()=>e.onItemRemove(n.key)})]},t.key)}))})})})}),(0,go.jsx)(n,{onChange:o,onItemAppend:_,onItemPrepend:C,onValueCreate:rw,readOnly:d,schemaType:y,value:b})]})}function yA(e){var t;return"grid"===(null==(t=e.schemaType.options)?void 0:t.layout)?(0,go.jsx)(gA,{...e}):(0,go.jsx)(vA,{...e})}const bA=["string","number","boolean"];function jA(e){return function(e){return 1===e.of.length&&Xh("string",e.of[0])}(e)&&function(e){var t;return"tags"===(null==(t=e.options)?void 0:t.layout)}(e)?NE:function(e){var t;return Boolean(null==(t=e.options)?void 0:t.list)}(e)?sP:function(e){return e.of.every((e=>bA.includes(e.jsonType)))}(e)?tA:function(e){return e.of.some((e=>Xh("block",e)))}(e)?AE:yA}function wA(e){return(0,mo.n4)(e)?e:{title:lc()("".concat(e)),value:e}}const kA={title:"",value:void 0};function CA(e){var t,n;const{value:i,readOnly:r,validationError:o,schemaType:s,onChange:a,path:l,changed:c,focused:d,elementProps:u}=e,p=(0,vo.useMemo)((()=>{var e;return((null==(e=s.options)?void 0:e.list)||[]).map(wA)}),[null==(t=s.options)?void 0:t.list]),h=p.find((e=>e.value===i)),f=s.options&&"radio"===s.options.layout,m=(0,vo.useCallback)((e=>{const t=Number(e);return p[t]}),[p]),g=(0,vo.useCallback)((e=>String(p.indexOf(e))),[p]),x=(0,vo.useId)(),v=vo.useCallback((e=>{a(Am.from("undefined"===typeof(null==e?void 0:e.value)?Im():Tm(e.value)))}),[a]),y=(0,vo.useCallback)((e=>{const t=m(e.currentTarget.value);v(t||kA)}),[v,m]),b=f?(0,go.jsx)(_A,{...u,value:h,inputId:x,items:p,direction:(null==(n=s.options)?void 0:n.direction)||"vertical",customValidity:o,onChange:v,readOnly:r}):(0,go.jsx)(Co.Ph,{...u,customValidity:o,value:g(h),readOnly:r,onChange:y,children:[kA,...p].map(((e,t)=>(0,go.jsx)("option",{value:t-1,children:e.title},"".concat(t-1))))});return(0,go.jsx)(nu,{path:l,isChanged:c,hasFocus:!!d,children:b})}const _A=(0,vo.forwardRef)((function(e,t){const{items:n,value:i,onChange:r,onFocus:o,readOnly:s,customValidity:a,direction:l,inputId:c}=e,d="horizontal"===l?Co.gF:Co.Kq;return(0,go.jsx)(Co.Zb,{border:!0,padding:3,radius:1,children:(0,go.jsx)(d,{space:3,role:"group",children:n.map(((e,n)=>(0,go.jsx)(SA,{customValidity:a,inputId:c,item:e,onChange:r,onFocus:o,readOnly:s,ref:0===n?t:null,value:i},n)))})})})),SA=(0,vo.forwardRef)((function(e,t){const{customValidity:n,inputId:i,item:r,onChange:o,onFocus:s,readOnly:a,value:l}=e,c=(0,vo.useCallback)((()=>{o(r)}),[r,o]);return(0,go.jsxs)(Co.kC,{as:"label",align:"center",children:[(0,go.jsx)(Co.Y8,{ref:t,checked:l===r,onChange:c,onFocus:s,readOnly:a,customValidity:n,name:i}),(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:r.title})})]})}));function TA(e){const{validationError:t,elementProps:n}=e;return(0,go.jsx)(Co.oi,{...n,customValidity:t,"data-testid":"string-input"})}function IA(e,t){for(const n of((e,t)=>{if("function"===typeof e)throw new 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]:[]})(null==e?void 0:e.validation,e))for(const e of n._rules)if(e.flag===t)return e;return null}function PA(e){const{schemaType:t,validationError:n,elementProps:i}=e,r=IA(t,"min"),o=IA(t,"integer"),s=IA(t,"precision"),a="number"===typeof(null==r?void 0:r.constraint)&&(null==r?void 0:r.constraint)>=0,l=o||0===(null==s?void 0:s.constraint),c=a?l?"numeric":"decimal":"text";return(0,go.jsx)(Co.oi,{...i,type:"number",step:"any",inputMode:c,customValidity:n,placeholder:t.placeholder,pattern:a?"[d]*":void 0,max:Number.MAX_SAFE_INTEGER,min:Number.MIN_SAFE_INTEGER,"data-testid":"number-input"})}const EA=(0,Es.ZP)(Co.xu)(bi||(bi=rd(["\n align-self: center;
1\n"]))),AA=(0,Es.ZP)(Co.xu)(ji||(ji=rd(["\n line-height: 0;\n"])));function FA(e){const{fieldNames:t,onChange:n,readOnly:i,value:r}=e,o=t.length,s=(0,vo.useCallback)((e=>{n(Im([e]))}),[n]);return(0,go.jsxs)(Om,{status:"warning",title:(0,go.jsxs)(go.Fragment,{children:[1===o&&(0,go.jsx)(go.Fragment,{children:"Unknown field found"}),o>1&&(0,go.jsx)(go.Fragment,{children:"Unknown fields found"})]}),children:[(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:1===o?(0,go.jsx)(go.Fragment,{children:"Encountered a field that is not defined in the schema."}):(0,go.jsxs)(go.Fragment,{children:["Encountered ",o," fields that are not defined in the schema."]})}),(0,go.jsxs)(Qj,{marginTop:4,open:gy,title:(0,go.jsx)(go.Fragment,{children:"Developer info"}),children:[(0,go.jsx)(Co.xu,{marginBottom:3,children:(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:1===o?(0,go.jsx)(go.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,go.jsx)(go.Fragment,{children:"These fields are not defined in the document\u2019s 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,go.jsx)(Co.Kq,{as:"ul",space:3,children:t.map((e=>(0,go.jsx)(MA,{fieldName:e,onUnsetClick:s,readOnly:i,value:null==r?void 0:r[e]},e)))})]})]})}function MA(e){let{fieldName:t,onUnsetClick:n,readOnly:i,value:r}=e;const o=(0,vo.useCallback)((()=>{n(t)}),[t,n]);return(0,go.jsx)(Co.Zb,{as:"li",padding:3,radius:2,shadow:1,tone:"caution",children:(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsxs)(Co.Zb,{border:!0,radius:1,children:[(0,go.jsx)(Co.Zb,{borderBottom:!0,padding:3,children:(0,go.jsx)(Co.EK,{weight:"medium",children:t})}),(0,go.jsx)(Co.xu,{overflow:"auto",padding:3,children:(0,go.jsx)(Co.EK,{language:"json",children:JSON.stringify(r,null,2)})})]}),i&&(0,go.jsxs)(Co.xv,{as:"p",muted:!0,size:1,children:["This field is ",(0,go.jsx)("strong",{children:"read only"})," according to the document\u2019s schema and cannot be unset. If you want to be able to unset this in Studio, make sure you remove the"," ",(0,go.jsx)("code",{children:"readOnly"})," field from the enclosing type in the schema."]}),!i&&(0,go.jsx)(Co.zx,{icon:Ds.XHJ,onClick:o,tone:"critical",text:(0,go.jsx)(go.Fragment,{children:"Remove field"})})]})})}const OA=(0,Es.ZP)(Co.Zb)(wi||(wi=rd(["\n margin-bottom: ","px;\n padding-bottom: ","px;\n"])),(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]})),RA=(0,vo.forwardRef)((function(e,t){const{onClick:n}=e,i=vo.useCallback((()=>{null==n||n(e.name)}),[e.name,n]);return(0,go.jsx)(Co.OK,{"data-testid":"group-tab-".concat(name),size:1,id:"".concat(e.name,"-tab"),label:e.title,ref:t,...e,onClick:i})})),zA=e=>{const{name:t,title:n,...i}=e,{selected:r}=e;return(0,go.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})},DA=(0,Es.ZP)(Co.iX)(ki||(ki=rd(["\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"]))),BA=e=>{let{inputId:t,groups:n,onClick:i,shouldAutoFocus:r=!0,disabled:o}=e;return(0,go.jsx)(Co.td,{space:2,"data-testid":"field-group-tabs",children:n.map((e=>(0,go.jsx)(RA,{"aria-controls":"".concat(t,"-field-group-fields"),autoFocus:r&&e.selected,disabled:o||e.disabled,icon:null==e?void 0:e.icon,name:e.name,onClick:i,selected:Boolean(e.selected),title:e.title||e.name},"".concat(t,"-").concat(e.name,"-tab"))))})},LA=e=>{let{disabled:t,groups:n,inputId:i,onSelect:r,shouldAutoFocus:o=!0}=e;var s;const a=(0,vo.useCallback)((e=>{r(e.currentTarget.value)}),[r]);return(0,go.jsx)(Co.Ph,{"aria-label":"Field groups",autoFocus:o,"data-testid":"field-group-select",disabled:t,fontSize:2,muted:!0,onChange:a,value:null==(s=n.find((e=>e.selected)))?void 0:s.name,children:n.map((e=>(0,go.jsx)(zA,{"aria-controls":"".concat(i,"-field-group-fields"),disabled:e.disabled,name:e.name,selected:Boolean(e.selected),title:e.title||e.name},"".concat(i,"-").concat(e.name,"-tab"))))})},ZA=vo.memo((function(e){let{disabled:t=!1,onClick:n,...i}=e;const r=(0,vo.useCallback)((e=>{null==n||n(e)}),[n]);return(0,go.jsxs)(DA,{"data-testid":"field-group-root",children:[(0,go.jsx)(BA,{...i,disabled:t,onClick:r}),(0,go.jsx)(LA,{...i,disabled:t,onSelect:r})]})})),NA=(0,vo.memo)((function(e){const{schemaType:t,groups:n,members:i,onChange:r,renderAnnotation:o,renderBlock:s,renderInlineBlock:a,renderInput:l,renderField:c,renderItem:d,renderPreview:u,level:p,value:h,id:f,onFieldGroupSelect:m}=e,{columns:g}=t.options||{},x=(0,vo.useMemo)((()=>
1{if(!t.fields)return null;const e=t.fields.map((e=>e.name)),n=Object.keys(h||{}).filter((t=>!t.startsWith("_")&&!e.includes(t)));return 0===n.length?null:(0,go.jsx)(FA,{fieldNames:n,value:h,onChange:r})}),[r,t.fields,h]),v=(0,vo.useCallback)((()=>(0,go.jsx)(Qk,{members:i,renderAnnotation:o,renderBlock:s,renderField:c,renderInlineBlock:a,renderInput:l,renderItem:d,renderPreview:u})),[i,o,s,c,a,l,d,u]);return 0===i.length?null:(0,go.jsxs)(Co.Kq,{space:5,children:[n.length>0?(0,go.jsx)(OA,{$level:p,"data-testid":"field-groups",children:(0,go.jsx)(ZA,{groups:n,inputId:f,onClick:m,shouldAutoFocus:!1})}):null,g?(0,go.jsx)(Co.rj,{columns:g,gap:4,marginTop:1,children:v()}):v(),x]})}));function qA(e){const{date:t,focused:n,isCurrentMonth:i,isToday:r,onSelect:o,selected:s}=e,a=(0,vo.useCallback)((()=>{o(t)}),[t,o]);return(0,go.jsx)("div",{"aria-selected":s,"data-ui":"CalendarDay",children:(0,go.jsx)(Co.Zb,{"aria-label":t.toDateString(),"aria-pressed":s,as:"button",__unstable_focusRing:!0,"data-weekday":!0,"data-focused":n?"true":"",role:"button",tabIndex:-1,onClick:a,padding:3,radius:2,selected:s,tone:r||s?"primary":"default",children:(0,go.jsx)(Co.xv,{muted:!s&&!i,style:{textAlign:"center"},weight:i?"medium":"regular",children:t.getDate()})})})}const UA=["January","February","March","April","May","June","July","August","September","October","November","December"],VA=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],KA=gc()(0,24),HA=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],$A=[1,2,3,4,5,6],WA=e=>{return(t=(e=>{const t=(0,oa.Z)(e);return(0,sa.Z)({start:t,end:(0,aa.Z)(t)})})(e),t.map((e=>[e,...$A.map((t=>(0,la.Z)(e,t)))]))).map((e=>({number:(0,ca.Z)(e[0]),days:e})));var t};function GA(e){return(0,go.jsx)(Co.xu,{"aria-hidden":e.hidden||!1,"data-ui":"CalendarMonth",children:(0,go.jsxs)(Co.rj,{gap:1,style:{gridTemplateColumns:"repeat(7, minmax(44px, 46px))"},children:[VA.map((e=>(0,go.jsx)(Co.xu,{paddingY:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"medium",style:{textAlign:"center"},children:e})},e))),WA(e.date).map(((t,n)=>t.days.map(((t,i)=>{const r=e.focused&&(0,da.Z)(t,e.focused),o=e.selected&&(0,da.Z)(t,e.selected),s=(0,da.Z)(t,new Date),a=e.focused&&(0,ua.Z)(t,e.focused);return(0,go.jsx)(qA,{date:t,focused:r,isCurrentMonth:a,isToday:s,onSelect:e.onSelect,selected:o},"".concat(n,"-").concat(i))}))))]})})}const XA=!1,YA=!1,JA=vo.forwardRef((function(e,t){let{onChange:n,onBlur:i,onKeyPress:r,value:o,...s}=e;const[a,l]=vo.useState(),c=vo.useCallback((e=>{l(e.currentTarget.value)}),[]),d=vo.useCallback((e=>{e.currentTarget.value!=="".concat(o)&&n&&n(e),l(void 0)}),[n,o]),u=vo.useCallback((e=>{d(e),i&&i(e)}),[d,i]),p=vo.useCallback((e=>{"Enter"===e.key&&d(e),r&&r(e)}),[d,r]);return(0,go.jsx)(Co.oi,{...s,"data-testid":"date-input",ref:t,value:void 0===a?o:a,onChange:c,onBlur:u,onKeyPress:p})})),QA=e=>{let{onChange:t,...n}=e;const i=vo.useCallback((e=>{const n=parseInt(e.currentTarget.value,10);isNaN(n)||t(n)}),[t]);return(0,go.jsx)(JA,{...n,onChange:i,inputMode:"numeric"})},eF=(0,go.jsx)("span",{"data-preserve-focus":!0,style:{overflow:"hidden",position:"absolute",outline:"none"},tabIndex:-1}),tF=(0,vo.forwardRef)((function(e,t){const{selectTime:n,onFocusedDateChange:i,selectedDate:r=new Date,focusedDate:o=r,timeStep:s=1,onSelect:a,...l}=e,c=(0,vo.useCallback)((e=>i(e)),[i]),d=(0,vo.useCallback)((e=>c((0,pa.Z)((0,ha.Z)(o,e),1))),[o,c]),u=(0,vo.useCallback)((e=>d(Number(e.currentTarget.value))),[d]),p=(0,vo.useCallback)((e=>c((0,fa.Z)(o,e))),[o,c]),h=(0,vo.useCallback)((e=>c((0,ma.Z)(o,e))),[o,c]),f=(0,vo.useCallback)((e=>{a((0,ga.Z)((0,xa.Z)(e,r.getHours()),r.getMinutes()))}),[a,r]),m=(0,vo.useCallback)((e=>{const t=Number(e.currentTarget.value);a((0,ga.Z)(r,t))}),[a,r]),g=(0,vo.useCallback)((e=>{const t=Number(e.currentTarget.value);a((0,xa.Z)(r,t))}),[a,r]);(0,vo.useCallback)(((e,t)=>{a((0,xa.Z)((0,ga.Z)(r,t),e))}),[a,r]);const x=(0,Co.ts)(t),v=(0,vo.useCallback)((()=>{var e,t;null==(t=null==(e=x.current)?void 0:e.querySelector('[data-focused="true"]'))||t.focus()}),[x]),y=(0,vo.useCallback)((e=>{var t,n;HA.includes(e.key)&&(e.preventDefault(),e.target.hasAttribute("data-calendar-grid")?v():("ArrowUp"===e.key&&i((0,la.Z)(o,-7)),"ArrowDown"===e.key&&i((0,la.Z)(o,7)),"ArrowLeft"===e.key&&i((0,la.Z)(o,-1)),"ArrowRight"===e.key&&i((0,la.Z)(o,1)),null==(n=null==(t=x.current)?void 0:t.querySelector("[data-preserve-focus]"))||n.focus()))}),[x,v,i,o]);(0,vo.useEffect)((()=>{v()}),[v]),(0,vo.useEffect)((()=>{var e;
1(null==(e=document.activeElement)?void 0:e.matches("[data-calendar-grid], [data-calendar-grid] [data-preserve-focus]"))&&v()}),[x,v,o]),(0,vo.useCallback)((()=>f((0,la.Z)(new Date,-1))),[f]),(0,vo.useCallback)((()=>f(new Date)),[f]),(0,vo.useCallback)((()=>f((0,la.Z)(new Date,1))),[f]);const b=(0,vo.useCallback)((()=>a(new Date)),[a]);return(0,go.jsxs)(Co.xu,{"data-ui":"Calendar",...l,ref:x,children:[(0,go.jsxs)(Co.xu,{padding:2,children:[XA,(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(nF,{moveFocusedDate:p,onChange:u,value:null==o?void 0:o.getMonth()})}),(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(iF,{moveFocusedDate:p,onChange:h,value:o.getFullYear()})})]}),(0,go.jsxs)(Co.xu,{"data-calendar-grid":!0,onKeyDown:y,marginTop:2,overflow:"hidden",tabIndex:0,children:[(0,go.jsx)(GA,{date:o,focused:o,onSelect:f,selected:r}),eF]})]}),n&&(0,go.jsxs)(Co.xu,{padding:2,style:{borderTop:"1px solid var(--card-border-color)"},children:[(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsxs)(Co.kC,{align:"center",flex:1,children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.Ph,{"aria-label":"Select hour",value:null==r?void 0:r.getHours(),onChange:g,children:KA.map((e=>(0,go.jsx)("option",{value:e,children:"".concat(e).padStart(2,"0")},e)))})}),(0,go.jsx)(Co.xu,{paddingX:1,children:(0,go.jsx)(Co.xv,{children:":"})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.Ph,{"aria-label":"Select minutes",value:null==r?void 0:r.getMinutes(),onChange:m,children:gc()(0,60,s).map((e=>(0,go.jsx)("option",{value:e,children:"".concat(e).padStart(2,"0")},e)))})})]}),(0,go.jsx)(Co.xu,{marginLeft:2,children:(0,go.jsx)(Co.zx,{text:"Set to current time",mode:"bleed",onClick:b})})]}),YA]})]})}));function nF(e){const{moveFocusedDate:t,onChange:n,value:i}=e,r=(0,vo.useCallback)((()=>t(-1)),[t]),o=(0,vo.useCallback)((()=>t(1)),[t]);return(0,go.jsxs)(Co.kC,{flex:1,children:[(0,go.jsx)(Co.zx,{"aria-label":"Go to previous month",onClick:r,mode:"bleed",icon:Ds.wyc,paddingX:2,radius:0}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.Ph,{radius:0,value:i,onChange:n,children:UA.map(((e,t)=>(0,go.jsx)("option",{value:t,children:e},t)))})}),(0,go.jsx)(Co.zx,{"aria-label":"Go to next month",mode:"bleed",icon:Ds.XCv,onClick:o,paddingX:2,radius:0})]})}function iF(e){const{moveFocusedDate:t,onChange:n,value:i}=e,r=(0,vo.useCallback)((()=>t(-12)),[t]),o=(0,vo.useCallback)((()=>t(12)),[t]);return(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.zx,{"aria-label":"Previous year",onClick:r,mode:"bleed",icon:Ds.wyc,paddingX:2,radius:0}),(0,go.jsx)(QA,{value:i,onChange:n,radius:0,style:{width:65}}),(0,go.jsx)(Co.zx,{"aria-label":"Next year",onClick:o,mode:"bleed",icon:Ds.XCv,paddingX:2,radius:0})]})}const rF=vo.forwardRef((function(e,t){const{value:n=new Date,onChange:i,...r}=e,[o,s]=vo.useState(),a=vo.useCallback((e=>{i(e),s(void 0)}),[i]);return(0,go.jsx)(tF,{...r,ref:t,selectedDate:n,onSelect:a,focusedDate:o||n,onFocusedDateChange:s})})),oF=(0,vo.forwardRef)((function(e,t){const{value:n,inputValue:i,onInputChange:r,onChange:o,selectTime:s,timeStep:a,...l}=e,[c,d]=(0,vo.useState)(null),u=(0,Co.ts)(t),p=(0,vo.useRef)(null),[h,f]=(0,vo.useState)(!1);(0,Co.O8)((()=>f(!1)),[c]);const m=(0,vo.useCallback)((()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()}),[u]),g=(0,vo.useCallback)((e=>{"Escape"===e.key&&f(!1)}),[]),x=(0,vo.useCallback)((()=>f(!0)),[]),v=(0,go.jsx)(Co.xu,{padding:1,children:(0,go.jsx)(Co.zx,{ref:p,icon:Ds.Que,mode:"bleed",padding:2,onClick:x,style:{display:"block"},"data-testid":"select-date-button"})});return(0,go.jsx)(JA,{ref:u,...l,value:i,onChange:r,suffix:h?(0,go.jsx)(Co.li,{zOffset:1e3,children:(0,go.jsx)(Co.J2,{constrainSize:!0,"data-testid":"date-input-dialog",portal:!0,content:(0,go.jsx)(Co.xu,{overflow:"auto",children:(0,go.jsx)(Ls.ZP,{onDeactivation:m,children:(0,go.jsx)(rF,{selectTime:s,timeStep:a,onKeyUp:g,value:n,onChange:o})})}),open:!0,placement:"bottom",ref:d,radius:2,children:v})}):v})})),sF=new Date,aF=vo.forwardRef((function(e,t){const{id:n,deserialize:i,formatInputValue:r,onChange:o,parseInputValue:s,placeholder:a,readOnly:l,selectTime:c,seri
1alize:d,timeStep:u,value:p,...h}=e,[f,m]=vo.useState(null);(0,vo.useEffect)((()=>{m(null)}),[p]);const g=vo.useCallback((e=>{const t=e.currentTarget.value,n=""===t?null:s(t);null===n?(o(null),"undefined"===typeof p&&f&&m(null)):n.isValid?o(d(n.date)):m(t)}),[s,o,p,f,d]),x=vo.useCallback((e=>{o(e?d(e):null)}),[d,o]),v=(0,Co.ts)(t),y=f?s(f):p?i(p):null,b=f||((null==y?void 0:y.isValid)?r(y.date):p);return l?(0,go.jsx)(Co.oi,{value:b,readOnly:!0}):(0,go.jsx)(oF,{...h,id:n,selectTime:c,timeStep:u,placeholder:a||"e.g. ".concat(r(sF)),ref:v,value:null==y?void 0:y.date,inputValue:b||"",readOnly:Boolean(l),onInputChange:g,onChange:x,customValidity:null==y?void 0:y.error})}));const lF="YYYY-MM-DD",cF="HH:mm";function dF(e){return e.toISOString()}function uF(e){const t=new Date(e);return(n=t)instanceof Date&&!isNaN(n.valueOf())?{isValid:!0,date:t}:{isValid:!1,error:'Invalid date value: "'.concat(e,'"')};var n}const pF="YYYY-MM-DD",hF=pF;const fF=e=>(0,xl.Q)(e,pF),mF=e=>(0,xl.W)(e,pF);const gF=(0,Es.ZP)(Co.Kx)(Ci||(Ci=rd(["\n &[data-as='textarea'] {\n resize: vertical;\n }\n"])));const xF=(e,t)=>{var n;const i=null==(n=t.options)?void 0:n.maxLength,r={truncate:"number"===typeof i?i:200,symbols:!0};return e?vc()(e,r):""};const vF={document:NA,object:NA,array:function(e){return(0,vo.useMemo)((()=>{var t;return Array.isArray(null==(t=e.schemaType.options)?void 0:t.list)}),[e.schemaType])?(0,go.jsx)(sP,{...e}):(t=e,(0,mo.d7)(t.schemaType)?(0,go.jsx)(tA,{...e}):(0,go.jsx)(yA,{...e}));var t},boolean:function(e){var t;const{id:n,value:i,schemaType:r,readOnly:o,elementProps:s}=e,a="boolean"!==typeof i,l=i||!1,c="checkbox"===((null==(t=r.options)?void 0:t.layout)||"switch")?Co.XZ:Co.rs,d=o?"transparent":void 0;return(0,go.jsx)(Co.Zb,{border:!0,"data-testid":"boolean-input",radius:1,tone:d,children:(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(AA,{padding:3,children:(0,go.jsx)(c,{label:r.title,...s,checked:l,disabled:o,indeterminate:a,style:{margin:-4}})}),(0,go.jsx)(Co.xu,{flex:1,paddingY:3,children:(0,go.jsx)(xj,{description:r.description,inputId:n,title:r.title})}),(0,go.jsx)(EA,{paddingX:3,paddingY:1,children:(0,go.jsx)(Fj,{maxAvatars:1,position:"top"})})]})})},number:PA,text:function(e){const{schemaType:t,validationError:n,value:i,elementProps:r}=e;return(0,go.jsx)(gF,{customValidity:n,value:i||"",placeholder:t.placeholder,rows:"number"===typeof t.rows?t.rows:10,...r})},email:function(e){const{validationError:t,elementProps:n}=e;return(0,go.jsx)(Co.oi,{...n,type:"email",inputMode:"email",customValidity:t})},datetime:function(e){const{onChange:t,schemaType:n,value:i,elementProps:r}=e,{dateFormat:o,timeFormat:s,timeStep:a}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dateFormat:e.dateFormat||lF,timeFormat:e.timeFormat||cF,timeStep:"timeStep"in e&&Number(e.timeStep)||1,calendarTodayLabel:e.calendarTodayLabel||"Today"}}(n.options),l=(0,vo.useCallback)((e=>{let n=e;null!==n&&a>1&&(n=function(e,t){if(!t||1===t)return e;const n=(0,va.Z)(e),i=(0,ya.Z)(n),r=i%t;return dF(0!==r?(0,ga.Z)(n,i-r):n)}(n,a)),t(null===n?Im():Tm(n))}),[t,a]),c=vo.useCallback((e=>(0,xl.W)(e,"".concat(o," ").concat(s))),[o,s]),d=vo.useCallback((e=>(0,xl.Q)(e,"".concat(o," ").concat(s))),[o,s]);return(0,go.jsx)(aF,{...r,onChange:l,deserialize:uF,formatInputValue:c,parseInputValue:d,placeholder:n.placeholder,selectTime:!0,serialize:dF,timeStep:a,value:i})},date:function(e){const{readOnly:t,onChange:n,schemaType:i,elementProps:r,value:o}=e,{dateFormat:s}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dateFormat:e.dateFormat||hF,calendarTodayLabel:e.calendarTodayLabel||"Today"}}(i.options),a=(0,vo.useCallback)((e=>{n(null===e?Im():Tm(e))}),[n]),l=(0,vo.useCallback)((e=>(0,xl.W)(e,s)),[s]),c=(0,vo.useCallback)((e=>(0,xl.Q)(e,s)),[s]);return(0,go.jsx)(aF,{...r,deserialize:fF,formatInputValue:l,onChange:a,parseInputValue:c,placeholder:i.placeholder,readOnly:t,selectTime:!1,serialize:mF,value:o})},url:function(e){var t,n;const{schemaType:i,validationError:r,elementProps:o}=e,s=IA(i,"uri"),a=(null==(n=null==(t=null==s?void 0:s.constraint)?void 0:t.options)?void 0:n.allowRelative)?"text":"url";return(0,go.jsx)(Co.oi,{type:a,inputMode:"url",customValidity:r,...o}
1)},image:function(e){var t;const n=null==(t=e.schemaType.options)?void 0:t.sources,{image:i}=Lm().__internal,r=mV(),o=WZ(qh),s=Lm().__internal.image.directUploads,a=(0,vo.useCallback)(((e,t)=>s?Yw(e,t):null),[s]),l=vo.useMemo((()=>n||i.assetSources),[i,n]),c=vo.useMemo((()=>Na()(o)),[o]),d=(0,vo.useCallback)((e=>Ew(r,e)),[r]);return(0,go.jsx)(oI,{...e,client:o,assetSources:l,directUploads:i.directUploads,imageUrlBuilder:c,observeAsset:d,resolveUploader:a})},file:function(e){var t;const n=null==(t=e.schemaType.options)?void 0:t.sources,i=mV(),{file:r}=Lm().__internal,o=WZ(qh),s=(0,vo.useCallback)(((e,t)=>r.directUploads?Yw(e,t):null),[r.directUploads]),a=(0,vo.useMemo)((()=>n||r.assetSources),[r,n]),l=(0,vo.useCallback)((e=>Aw(i,e)),[i]);return(0,go.jsx)(VS,{...e,client:o,assetSources:a,directUploads:r.directUploads,observeAsset:l,resolveUploader:s})},string:TA,slug:function(e){var t;const{getDocument:n}=Lm().__internal,{path:i,value:r,schemaType:o,validation:s,onChange:a,readOnly:l,elementProps:c}=e,d=null==(t=o.options)?void 0:t.source,u=(0,vo.useMemo)((()=>s.filter((e=>"error"===e.level))),[s]),p=function(){const{getClient:e}=SO(),t=nN(),n=xN(),i=tN(),r=YZ();return(0,vo.useMemo)((()=>({projectId:i,dataset:r,getClient:e,schema:t,currentUser:n})),[e,t,n,i,r])}(),h=(0,vo.useCallback)((e=>{a(e?Am.from([_m({_type:o.name}),Tm(e,["current"])]):Am.from(Im([])))}),[a,o.name]),[f,m]=function(e,t){const[n,i]=vo.useState(null),r=vo.useRef(0);return[n,vo.useCallback((t=>{const 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])]}((()=>{if(!d)return Promise.reject(new Error('Source is missing. Check source on type "'.concat(o.name,'" in schema')));const e=n()||{_type:o.name},t=function(e,t,n){const i=e.slice(0,-1);return{parentPath:i,parent:xo.U2(t,i),...n}}(i,e,p);return async function(e,t,n){return"function"===typeof e?e(t,n):xo.U2(t,e)}(d,e,t).then((e=>async function(e,t,n){var i;return e?((null==(i=t.options)?void 0:i.slugify)||xF)(e,t,n):e}(e||"",o,t))).then((e=>h(e)))}),[d,n,o,i,p,h]),g="pending"===(null==f?void 0:f.status),x=vo.useCallback((e=>h(e.currentTarget.value)),[h]);return(0,go.jsx)(Co.Kq,{space:3,children:(0,go.jsxs)(Co.kC,{children:[(0,go.jsxs)(Co.xu,{flex:1,children:[(0,go.jsx)(Co.oi,{customValidity:u.length>0?u[0].message:"",disabled:g,onChange:x,value:(null==r?void 0:r.current)||"",readOnly:l,...c}),"error"===(null==f?void 0:f.status)&&(0,go.jsx)(Co.Zb,{padding:2,tone:"critical",children:f.error.message})]}),d&&(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.zx,{mode:"ghost",type:"button",disabled:l||g,onClick:m,text:"pending"===(null==f?void 0:f.status)?"Generating\u2026":"Generate"})})]})})},crossDatasetReference:function(e){const{path:t,schemaType:n}=e,i=SO(),r=i.getClient(qh),o=mV(),s=i.getClient,a=(0,vo.useMemo)((()=>r.withConfig({dataset:n.dataset,apiVersion:"2022-03-07",ignoreBrowserTokenWarning:!0}).clone()),[r,n.dataset]),l=function(e){const t=(0,vo.useRef)(e);return t.current=e,t}(fk([])),c=(0,vo.useCallback)((e=>(0,Bo.D)(async function(e,t,n,i){if(!e)return{};if("function"===typeof e.filter){const r=n.slice(0,-1),o=(0,xo.U2)(t,r);return await e.filter({document:t,parentPath:r,parent:o,getClient:i})}return{filter:e.filter,params:"filterParams"in e?e.filterParams:void 0}}(n.options,l.current,t,s)).pipe((0,is.z)((t=>{let{filter:i,params:r}=t;return function(e,t,n,i){return xm(n.to.map((e=>({name:e.type,__experimental_search:e.__experimental_search}))),e,i)(t,{includeDrafts:!1}).pipe((0,Ho.U)((e=>e.map((e=>e.hit)))),(0,Ho.U)(Id),(0,Ho.U)((e=>e.map((e=>({id:e.id,type:e.type,published:e.published}))))))}(a,e,n,{...n.options,filter:i,params:r,tag:"search.cross-dataset-reference"})})),(0,Wo.K)((e=>{var t;const 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,Fo._)(e)})))),[a,l,t,n,s]),d=(0,vo.useMemo)((()=>FI({client:a,documentPreviewStore:o})),[a,o]);return(0,go.jsx)(TI,{...e,getReferenceInfo:d,onSearch:c})}};function yF(e){return Xh("array",e)?jA(e):Xh("reference",e)?YI:Xh("str
1ing",e)?function(e){return fC(e,"list")?CA:TA}(e):Xh("number",e)?function(e){return fC(e,"list")?CA:PA}(e):void 0}function bF(e){var t;if(null==(t=e.components)?void 0:t.input)return e.components.input;const n=yF(e);if(n)return n;const i=yC(e,new Set).reduce(((e,t)=>(e[t.name]=t,e)),{}),r=Object.values(i).find((e=>vF[e.name]));if(r)return vF[r.name];throw new Error("Could not find input component for schema type `".concat(e.name,"`"))}function jF(e){var t;return(null==(t=e.components)?void 0:t.preview)?e.components.preview:Qh}function wF(e){const{componentResolver:t,componentProps:n}=e;if(!n.schemaType)throw new Error("the `schemaType` property must be defined");const i=t(n.schemaType),r=(0,vo.useCallback)((e=>{var n;if(!(null==(n=e.schemaType)?void 0:n.type))throw new Error("Attempted to render form component of non-existent parent type");const{components:i,...r}=e.schemaType,o=t(r);return(0,vo.createElement)(o,e)}),[t]);return(0,vo.createElement)(i,{...n,renderDefault:r})}function kF(e){return wF({componentProps:e,componentResolver:bF})}function CF(e){return wF({componentProps:e,componentResolver:SC})}function _F(e){return wF({componentProps:e,componentResolver:uC})}function SF(e){return wF({componentProps:e,componentResolver:jF})}function TF(e){return wF({componentProps:e,componentResolver:Q_})}function IF(e){return wF({componentProps:e,componentResolver:eS})}function PF(e){return wF({componentProps:e,componentResolver:tS})}function EF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.input}function AF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.field}function FF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.preview}function MF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.item}function OF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.block}function RF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.inlineBlock}function zF(e){var t,n;return null==(n=null==(t=e.form)?void 0:t.components)?void 0:n.annotation}function DF(){return Gh({defaultComponent:SF,pick:FF})}function BF(e){const t=DF();return(0,go.jsx)(uf,{...e,component:t})}const LF=e=>{let{asset:t,assetType:n,referringDocuments:i}=e;const r=i.length,o=r>0,s=t.originalFilename?(0,go.jsx)("strong",{children:t.originalFilename}):"this ".concat(n);return o?(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.Zb,{borderBottom:!0,marginTop:2,paddingBottom:2,marginBottom:1,children:(0,go.jsxs)(Co.xv,{as:"h2",size:[1,1,2,2],weight:"regular",textOverflow:"ellipsis",children:[r," ",1===r?"document is":"documents are"," using ",s]})}),i.map((e=>(0,go.jsx)(ZF,{document:e},e._id)))]}):(0,go.jsxs)(Co.xv,{size:[1,1,2,2],as:"h2",weight:"regular",children:["No documents are using ",s]})},ZF=e=>{let{document:t}=e;const n=nN(),i=(0,vo.useCallback)((e=>(0,go.jsx)(Bs.nR,{...e,params:{id:t._id,type:t._type},intent:"edit"})),[t]);return(0,go.jsx)(Co.Zb,{as:i,paddingY:2,paddingX:1,radius:2,"data-as":"a",tabIndex:0,children:(0,go.jsx)(Co.kC,{align:"center",gap:2,children:(0,go.jsx)(BF,{layout:"default",value:{_type:"reference",_ref:t._id},schemaType:n.get(t._type)})})},t._id)},NF={maxWidth:"100%",height:"120px",objectFit:"contain",objectPosition:"center"},qF={gridColumn:"span 1",overflow:"hidden",display:"flex",alignSelf:"center",justifyContent:"center"},UF={height:"100%"},VF=e=>{let{asset:t,assetType:n,hasResults:i=!1}=e;const r="image"===n,o=t.originalFilename?(0,go.jsxs)(go.Fragment,{children:["The ",n," ",(0,go.jsx)("strong",{children:t.originalFilename})]}):"this ".concat(n);return i?(0,go.jsx)(Co.Zb,{tone:"caution",padding:[3,3,4],border:!0,radius:2,marginBottom:3,children:(0,go.jsxs)(Co.rj,{columns:3,gap:[2,3,4],children:[(0,go.jsxs)(Co.kC,{gap:[3,4],align:"center",style:{gridColumn:r?"span 2":"span 3"},children:[(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.foC,{})}),(0,go.jsxs)(Co.xv,{size:1,children:[o," cannot be deleted because it's being used. In order to delete the ",n," you need the remove all uses of it."]})]}),r&&(0,go.jsx)(Co.Zb,{__unstable_checkered:!0,border:!0,radius:1,style:qF,children:(0,go.jsx)(Co.kC,{align:"center",justify:"center",style:UF,children:(0,go.jsx)("img",{src:"".concat(t.url,"?w=200"),style:NF,alt:"Preview of image",referrerPolicy:"str
1ict-origin-when-cross-origin"})})})]})}):(0,go.jsx)(Co.Zb,{paddingX:[2,3,4],paddingY:[3,3,3,4],children:(0,go.jsxs)(Co.rj,{columns:3,gap:3,children:[(0,go.jsx)(Co.kC,{style:{gridColumn:r?"span 2":"span 3"},align:"center",children:(0,go.jsxs)(Co.xv,{children:["You are about to delete the ",n,t.originalFilename&&(0,go.jsxs)(go.Fragment,{children:[" ",(0,go.jsx)("strong",{children:t.originalFilename})]})," ","and its metadata.",(0,go.jsx)("br",{}),(0,go.jsx)("br",{}),"Are you sure?"]})}),r&&(0,go.jsx)(Co.Zb,{__unstable_checkered:!0,border:!0,radius:1,style:qF,children:(0,go.jsx)(Co.kC,{align:"center",justify:"center",style:UF,children:(0,go.jsx)("img",{src:"".concat(t.url,"?w=200"),style:NF,alt:"Preview of image",referrerPolicy:"strict-origin-when-cross-origin"})})})]})})},KF="confirmDelete",HF="listUsage";function $F(e){let{asset:t,assetType:n="image",mode:i=HF,isDeleting:r=!1,onClose:o,onDelete:s}=e;const{isLoading:a,referringDocuments:l}=$h(t._id),c=i===HF?"Documents using ".concat(n):"Delete ".concat(n),[d,u]=(0,vo.useState)(!1),[p,h]=(0,vo.useState)(!0),[f,m]=(0,vo.useState)([]),g=i===KF,x=f.length>0,v=i===HF||x,y=i===KF&&!x,b=g?(0,go.jsxs)(Co.rj,{padding:2,gap:2,columns:2,children:[(0,go.jsx)(Co.zx,{mode:"bleed",text:"Cancel",onClick:o}),(0,go.jsx)(Co.zx,{text:"Delete",tone:"critical",icon:Ds.XHJ,onClick:s,loading:r,disabled:!d})]}):void 0;return(0,vo.useEffect)((()=>{const e=l.reduce(((e,t)=>t._id.startsWith("drafts.")?e.concat(t._id.slice(7)):e),[]),t=l.filter((t=>!e.includes(t._id)));m(t),u(0===t.length&&!a),h(a)}),[a,l]),(0,go.jsxs)(Co.Vq,{__unstable_autoFocus:!p,footer:b,header:c,id:"asset-dialog",onClickOutside:o,onClose:o,width:1,children:[p&&(0,go.jsx)(Co.xu,{padding:4,children:(0,go.jsx)(Kh,{text:"Loading..."})}),!p&&(0,go.jsxs)(Co.Kq,{paddingX:y?0:[2,3,4],paddingY:y?0:[3,3,3,4],space:1,children:[i===KF&&(0,go.jsx)(VF,{asset:t,assetType:n,hasResults:x}),v&&(0,go.jsx)(LF,{asset:t,referringDocuments:f,assetType:n})]})]})}function WF(e){let{isSelected:t,border:n=!0,onAction:i}=e;const r=t?"default":"bleed",o=t?"primary":"default";return(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{padding:2,mode:n?"ghost":r,icon:Ds.zGg,tone:n?"default":o}),id:"asset-menu",portal:!0,menu:(0,go.jsxs)(Co.v2,{children:[(0,go.jsx)(Co.sN,{text:"Show uses",icon:Ds.xPt,onClick:()=>{i({type:"showUsage"})}}),(0,go.jsx)(Co.sN,{text:"Delete",icon:Ds.XHJ,tone:"critical",onClick:()=>{i({type:"delete"})}})]}),placement:"right"})}const GF="undefined"!==typeof window&&window.devicePixelRatio?Math.round(window.devicePixelRatio):1,XF=Es.ZP.img(_i||(_i=rd(["\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"]))),YF=(0,Es.ZP)(Co.Zb)(Si||(Si=rd(["\n position: relative;\n z-index: 1;\n padding-bottom: 100%;\n"]))),JF=Es.ZP.div(Ti||(Ti=rd(["\n position: relative;\n display: inherit;\n"]))),QF=Es.ZP.div(Ii||(Ii=rd(["\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"])),JF,JF),eM=vo.memo((function(e){const t=WZ(qh),n=(0,Co.pm)(),i=(0,vo.useRef)(),{asset:r,onClick:o,onKeyPress:s,onDeleteFinished:a,isSelected:l}=e,[c,d]=(0,vo.useState)(!1),[u,p]=(0,vo.useState)(!1),[h,f]=(0,vo.useState)(!1);(0,vo.useEffect)((()=>()=>{i.current&&i.current.unsubscribe()}),[]);const m=(0,vo.useCallback)((()=>{p(!0)}),[p]),g=(0,vo.useCallback)((()=>{d(!1),p(!1)}),[d,p]),x=(0,vo.useCallback)((()=>{d(!0)}),[d]),v=(0,vo.useCallback)((e=>{n.push({closable:!0,status:"error",title:"Image could not be deleted",description:e.message})}),[n]),y=(0,vo.useCallback)((()=>{n.push({status:"success",title:"Image was deleted"})}),[n]),b=(0,vo.useCallback)((()=>{f(!0),i.current=t.observable.delete(r._id).subscribe({next:()=>{f(!1),a(r._id),p(!1),y()},error:e=>{f(!1),v(e),console.error("Could not delete asset",e)}})}),[r._id,v,y,a,t.observable]),j=(0,vo.useCallback)((e=>{"delete"===e.type&&m(),"showUsage"===e.type&&x()}),[m,x]),{originalFilename:w,_id:k,url:C}=r,_=200*Math.max(1,GF),S=C.includes(".gif")?"".concat(C,"?h=").concat(_,"&fit=max&fm=jpg"):"".concat(C,"?h=").concat(_,"&fit=max");return(0,go.jsxs)(JF,{children:[(0,go.jsx)(Co.zx,{tone:"primary",selected:l,tabIndex:0,"data-id":k,mode:"ghost",onKeyPress:s,padding:0,style:{padding:2},children:(0,go.jsxs)(YF,{__unstable_checkered:!0,children:[(0,go.jsx)(XF,{alt:w,src:S,onClick:o,"data-id":k}),h&&(0,go.jsx)(Vh,{})]})}),(0,go.jsx)(QF,{children:(0,go.jsx)(WF,{isSelected:l,onAction:j})}),(c||u)&&(0,go.jsx)($F,{asset:r,mode:u?"confirmDelete":"listUsage",onClose:g,onDelete:b,isDeleting:h})]})})),tM=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],nM=["B","kiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],iM=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],rM=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],oM=(e,t,n)=>{let i=e;
1return"string"===typeof t||Array.isArray(t)?i=e.toLocaleString(t,n):!0!==t&&void 0===n||(i=e.toLocaleString(void 0,n)),i};const sM={"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"}};const aM=Es.ZP.span(Pi||(Pi=rd(["\n background-color: transparent;\n flex-shrink: 0;\n"]))),lM=(0,Es.ZP)(Co.kC)(Ei||(Ei=rd([""]))),cM=(0,Es.ZP)(Co.xv)(Ai||(Ai=rd([""]))),dM=(0,Es.ZP)(Co.Zb)(Fi||(Fi=rd(["\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"])),cM,(e=>e.isSelected&&(0,Es.iv)(Mi||(Mi=rd(["\n --card-muted-fg-color: var(--card-bg-color);\n --card-fg-color: var(--card-bg-color);\n "]))))),uM=(0,Es.ZP)(Co.zx)(Oi||(Oi=rd(["\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,Es.iv)(Ri||(Ri=rd(["\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 "])),aM,lM)),(e=>!e.isSelected&&(0,Es.iv)(zi||(zi=rd(["\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 "]))))),pM=(0,Es.ZP)(Co.xv)(Di||(Di=rd(["\n overflow-wrap: anywhere;\n"]))),hM={position:"relative"},fM={flexShrink:0},mM={minWidth:0},gM={zIndex:3,marginTop:"-0.5rem",marginBottom:"-0.5rem"},xM=e=>{const t=WZ(qh),n=(0,Co.pm)(),i=(0,vo.useRef)(),[r,o]=(0,vo.useState)(!1),[s,a]=(0,vo.useState)(!1),[l,c]=(0,vo.useState)(!1),[d,u]=(0,vo.useState)(!1),{asset:p,onClick:h,onKeyPress:f,onDeleteFinished:m,isSelected:g,isMobile:x}=e,{originalFilename:v,_id:y,mimeType:b,size:j,_createdAt:w}=p,k=uN(w,{agoSuffix:!0}),C=function(e){return(null==sM?void 0:sM[e])?sM[e].title:function(e){const t=e.replace("x-","").split("/")[1];return t.charAt(0).toUpperCase()+t.slice(1)}(e)}(b),_=function(e){let{bits:t=!1,binary:n=!1,signed:i=!1,minimumFractionDigits:r,maximumFractionDigits:o,locale:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e;if(!Number.isFinite(a))throw new TypeError("Expected a finite number, got ".concat(typeof a,": ").concat(a));const l=t?n?rM:iM:n?nM:tM;if(i&&0===a)return" 0 ".concat(l[0]);const c=a<0,d=c?"-":i?"+":"";let u;if(c&&(a=-a),void 0!==r&&(u={minimumFractionDigits:r}),void 0!==o&&(u={maximumFractionDigits:o,...u}),a<1){const e=oM(a,s,u);return"".concat(d+e," ").concat(l[0])}const p=Math.min(Math.floor(n?Math.log(a)/Math.log(1024):Math.log10(a)/3),l.length-1);a/=(n?1024:1e3)**p,u||(a=a.toPrecision(3));const h=oM(Number(a),s,u),f=l[p];return"".concat(d+h," ").concat(f)}(j),S=(v||"").length>37,T=()=>{a(!0)},I=()=>{c(!0),i.current=t.observable.delete(p._id).subscribe({next:()=>{c(!1),null==m||m(p._id),a(!1),n.push({status:"success",title:"File was deleted"})},error:e=>{var t;c(!1),t=e,n.push({closable:!0,status:"error",title:"File could not be deleted",description:t.message}),console.error("Could not delete asset",e)}})},P=()=>{o(!1),a(!1)},E=()=>{o(!0)},A=()=>{u(!d)};return x?(0,go.jsxs)(Co.Zb,{paddingBottom:2,style:hM,children:[(0,go.jsxs)(Co.rj,{columns:4,gap:1,style:{position:"relative",gridTemplateColumns:"1fr 30px",opacity:l?.5:1},children:[(0,go.jsx)(uM,{asset:p,mode:"bleed",padding:0,"data-id":y,onClick:h,paddingY:1,children:(0,go.jsxs)(Co.kC,{gap:2,flex:2,align:"center",children:[(0,go.jsx)(Co.Zb,{as:aM,padding:2,tone:"transparent",radius:2,children:(0,go.jsx)(Co.xv,{muted:!0,size:2,style:fM,children:(0,go.jsx)(Ds.$lS,{})})}),(0,go.jsx)(Co.xv,{size:1,align:"left",textOverflow:"ellipsis",style:mM,children:v})]})}),(0,go.jsx)(Co.kC,{justify:"flex-end",align:"center",paddingRight:1,style:gM,children:(0,go.jsx)(Co.zx,{mode:"bleed",fontSize:1,padding:2,onClick:A,icon:d?Ds.g8U:Ds.v4q})})]}),d&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsxs)(Co.rj,{marginTop:3,columns:3,gap:1,children:[(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Size"}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:_})]}),(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Type"}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:C})]}),(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Date added"}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:k})]})]}),(0,go.jsxs)(Co.Kq,{space:2,marginTop:3,children:[(0,go.jsx)(Co.zx,{fontSize:1,tone:"default",mode:"ghost",text:"Show uses",onClick:E,icon:Ds.xPt}),(0,go.jsx)(Co.zx,{fontSize:1,tone:"critical",mode:"ghost",text:"Delete",icon:Ds.XHJ,disabled:g,title:g?"Cannot delete current file":"Delete file",onClick:T})]})]}),(r||s)&&(0,go.jsx)($F,{assetType:"file",asset:p,mode:s?"confirmDelete":"listUsage",onClose:P,onDelete:I,isDeleting:l})]}):(0,go.jsxs)(dM,{asset:p,paddingBottom:1,style:hM,radius:0,overflow:"hidden",isSelected:g,"aria-selected":"true",children:[(0,go.jsxs)(Co.rj,{columns:4,gap:1,"data-id":y,paddingY:1,style:{position:"relative",gridTemplateColumns:"3fr 1fr 1fr 2fr 30px",opacity:l?.5:1},children:[(0,go.jsx)(uM,{asset:p,mode:"bleed","data-id":y,onClick:h,padding:0,onKeyPress:f,title:"Select the file ".concat(v),isSelected:g,children:(0,go.jsxs)(lM,{gap:2,flex:2,paddingRight:1,align:"center",onClick:h,onKeyPress:f,"data-id":y,title:"Select the file ".concat(v),children:[(0,go.jsx)(Co.Zb,{as:aM,padding:2,tone:"transparent",radius:2,style:fM,children:(0,go.jsx)(Co.xv,{muted:!0,size:2,children:(0,go.jsx)(Ds.$lS,{})})}),S&&(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:v})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:(0,go.jsx)(Co.xv,{size:1,align:"left",textOverflow:"ellipsis",style:mM,children:v})}),!S&&(0,go.jsx)(Co.xv,{size:1,align:"left",textOverflow:"ellipsis",style:mM,children:v})]})}),(0,go.jsx)(lM,{align:"center",children:(0,go.jsx)(Co.xv,{size:1,muted:!0,children:_})}),(0,go.jsx)(lM,{align:"center",children:(0,go.jsx)(Co.xu,{children:(0,go.jsx)(pM,{size:1,muted:!0,textOverflow:"ellipsis",children:C})})}),(0,go.jsx)(lM,{align:"center",children:(0,go.jsx)(Co.xv,{as:"time",size:1,muted:!0,dateTime:w,children:k})}),(0,go.jsx)(lM,{justify:"flex-end",align:"center",paddingX:1,paddingY:1,style:gM,children:(0,go.jsx)(WF,{border:!1,isSelected:!1,onAction:e=>{"delete"===e.type&&T(),"showUsage"===e.type&&E()}})})]}),(r||s)&&(0,go.jsx)($F,{assetType:"file",asset:p,mode:s?"confirmDelete":"listUsage",onClose:P,onDelete:I,isDeleting:l})]})},vM={paddingLeft:"2.2rem"},yM={gridTemplateColumns:"3fr 1fr 1fr 2fr 30px"};function bM(e){const t=(0,Co.d2)()<2,{assets:n,onClick:i,onKeyPress:r,onDeleteFinished:o,selectedAssets:s,isLoading:a}=e;return(0,go.jsxs)(Co.xu,{padding:4,children:[(0,go.jsx)(Co.Zb,{borderBottom:!0,paddingBottom:2,marginBottom:1,children:t?(0,go.jsx)(Co.rj,{style:yM,children:(0,go.jsx)(Co.xu,{flex:2,paddingLeft:5,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Filename"})})}):(0,go.jsxs)(Co.rj,{gap:1,style:yM,children:[(0,go.jsx)(Co.xu,{flex:2,style:vM,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Filename"})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Size"})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Type"})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Date added"})})]})}),(0,go.jsxs)(Co.Kq,{children:[a&&0===n.length&&(0,go.jsx)(Co.xu,{paddingTop:4,paddingBottom:2,children:(0,go.jsx)(Co.kC,{justify:"center",children:(0,go.jsx)(Co.$j,{muted:!0}
1)})}),n.map((e=>(0,go.jsx)(xM,{asset:e,isMobile:t,isSelected:s.some((t=>t._id===e._id)),onClick:i,onKeyPress:r,onDeleteFinished:o},e._id)))]})]})}const jM=200,wM="sanity.imageAsset",kM=e=>{const t=["image/*","audio/*","video/*"],n=e.split(",").map((e=>e.trim())).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(n.wildcards," \n extension in [").concat(n.extensions,"] ||\n mimeType in [").concat(n.mimes,"]\n )")},CM=(0,Es.ZP)(Co.rj)(Bi||(Bi=rd(["\n grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));\n"]))),_M=(0,Es.ZP)(Co.Zb)(Li||(Li=rd(["\n border-top: 1px solid var(--card-border-color);\n position: sticky;\n bottom: 0;\n z-index: 200;\n"]))),SM=vo.memo(vo.forwardRef((function(e,t){const n=WZ(qh),i=(0,vo.useMemo)((()=>n.withConfig({apiVersion:"2023-02-14"})),[n]),r=(0,vo.useRef)("default-asset-source-".concat(ra()())),o=(0,vo.useRef)(0),s=(0,vo.useRef)(),[a,l]=(0,vo.useState)([]),[c,d]=(0,vo.useState)(!1),[u,p]=(0,vo.useState)(!1),[h,f]=(0,vo.useState)(!0),{selectedAssets:m,assetType:g="image",dialogHeaderTitle:x="Select image",onClose:v,onSelect:y,accept:b}=e,j=b?b.split(",").map((e=>e.trim())).join(", "):"",w=!h&&b&&b.length>0,k=b&&"image/*"===b&&"image"===g,C=(0,vo.useCallback)((e=>{const t=e*jM,n=t+jM,r="image"===g,o=r?"asset.image-list":"asset.file-list",a=r?wM:"sanity.fileAsset";f(!0),"undefined"!==typeof b&&(s.current=i.observable.fetch(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jM,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wM,i=arguments.length>3?arguments[3]:void 0;const r=i.length>0?kM(i):"";return'\n *[_type == "'.concat(n,'" ').concat(r,"] | 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")}(t,n,a,b),{},{tag:o}).subscribe((e=>{d(e.length<jM),l((t=>t.concat(e))),f(!1)})))}),[g,b,i]),_=(0,vo.useCallback)((e=>{l((t=>t.filter((t=>t._id!==e))))}),[l]),S=(0,vo.useCallback)((e=>{if(a.find((t=>t._id===e))){y([{kind:"assetDocumentId",value:e}])}}),[a,y]),T=(0,vo.useCallback)((e=>{e.preventDefault(),S(e.currentTarget.getAttribute("data-id"))}),[S]),I=(0,vo.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),S(e.currentTarget.getAttribute("data-id")))}),[S]),P=(0,vo.useCallback)((()=>{v&&v()}),[v]),E=(0,vo.useCallback)((e=>{e.preventDefault(),C(++o.current)}),[C]);(0,vo.useEffect)((()=>(C(o.current),()=>{s.current&&s.current.unsubscribe()})),[C]),(0,vo.useEffect)((()=>{h||o.current&&0!==o.current||p(!0)}),[h]);const A=(0,vo.useMemo)((()=>(0,go.jsxs)(Co.xu,{padding:4,children:[(0,go.jsx)(CM,{gap:2,children:a.map((e=>(0,go.jsx)(eM,{asset:e,isSelected:m.some((t=>t._id===e._id)),onClick:T,onKeyPress:I,onDeleteFinished:_},e._id)))}),h&&0===a.length&&(0,go.jsx)(Co.kC,{justify:"center",children:(0,go.jsx)(Co.$j,{muted:!0})}),!h&&0===a.length&&(0,go.jsx)(Co.xv,{align:"center",muted:!0,children:"No images"})]})),[a,_,T,I,h,m]),F=(0,vo.useMemo)((()=>(0,go.jsx)(bM,{isLoading:h,assets:a,selectedAssets:m,onClick:T,onKeyPress:I,onDeleteFinished:_})),[h,a,m,T,I,_]);return(0,go.jsxs)(Co.Vq,{__unstable_autoFocus:u,header:x,id:r.current,onClickOutside:P,onClose:P,ref:t,width:2,children:[w&&!k&&(0,go.jsx)(Co.Zb,{tone:"primary",marginTop:4,marginX:4,padding:[3,3,4],border:!0,radius:2,children:(0,go.jsxs)(Co.kC,{gap:[3,4],align:"center",children:[(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.hQ6,{})}),(0,go.jsxs)(Co.xv,{size:1,children:["Only showing assets of accepted types: ",(0,go.jsx)("b",{children:j})]})]})}),"image"===g&&A,"file"===g&&F,a.length>0&&!c&&(0,go.jsx)(_M,{tone:"default",padding:4,children:(0,go.jsx)(Co.kC,{direction:"column",children:(0,go.jsx)(Co.zx,{type:"button",icon:Ds._8t,loading:h,onClick:E,text:"Load more",tone:"primary"})})})]})}))),TM={name:"sanity-default",title:"Uploaded files",component:SM,icon:Ds.TAM},IM={name:"sanity-default",title:"Uploaded images",component:SM,icon:Ds.XBm};function PM(e){return e.reduce(((e,t)=>(e[t.name]=t,e)),{})}function EM(e,t){return e[t]}const AM=[{fieldPath:"_updatedAt",icon:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.nSX,name:"boolean",operators:[{name:"booleanEqual",type:"item"},{type:"divider"},{name:"notDefined",type:"item"}],type:"field"},{fieldType:"date",icon:Ds.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:Ds.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:Ds.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:Ds.$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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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:Ds.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 FM(e){let{documentId:t,schemaType:n}=e;const i=mV(),{draft:r,published:o,isLoading:s}=(0,_o.m2)((()=>hf(i,n,t,"")),[t,i,n]),a=(0,vo.useMemo)((()=>({_id:t,_type:n.name})),[t,n.name]),l=ff({draft:r,published:o,value:a});return s?(0,go.jsx)(Co.Od,{animated:!0,marginLeft:1,radius:2,style:{width:"10ch",height:"1em"}}):(0,go.jsx)(go.Fragment,{children:l.title||t.slice(0,8)})}const MM="yyyy-MM-dd";function OM(e){let{value:t}=e;const n=(null==t?void 0:t.date)?new Date(t.date):null;return n&&(0,ba.Z)(n)?(0,go.jsx)(go.Fragment,{children:(0,ja.Z)(n,MM)}):null}function RM(e){let{value:t}=e;const n=(null==t?void 0:t.date)?new Date(t.date):null;return n&&(0,ba.Z)(n)?(0,go.jsx)(go.Fragment,{children:(0,ja.Z)(n,MM)}):null}function zM(e){let{value:t}=e;const 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,ba.Z)(i)&&(0,ba.Z)(n)?(0,go.jsxs)(go.Fragment,{children:[(0,ja.Z)(n,MM)," \u2192 ",(0,ja.Z)(i,MM)]}):null}function DM(e){let{value:t}=e;return(0,go.jsx)(go.Fragment,{children:t})}function BM(e){let{value:t}=e;return(0,go.jsxs)(go.Fragment,{children:[t," ",(0,La.Z)("item",t)]})}function LM(e){let{value:t}=e;const n=nN(),i=t._ref,r=n.get(t._type);return r?(0,go.jsx)(FM,{documentId:i,schemaType:r}):null}function ZM(e){let{value:t}=e;return(0,go.jsx)(go.Fragment,{children:t})}const NM=(0,vo.createContext)(void 0);function qM(){const e=(0,vo.useContext)(NM);if(void 0===e)throw new Error("useSearchState must be used within an SearchProvider");return e}function UM(e){let{value:t,onChange:n}=e;const[i,r]=(0,vo.useState)(null!=t?t:""),{state:{fullscreen:o}}=qM(),s=(0,vo.useCallback)((e=>{r(e.currentTarget.value);const t=parseFloat(e.currentTarget.value);n(Number.isFinite(t)?t:null)}),[n]);return(0,go.jsx)(Co.oi,{fontSize:o?2:1,onChange:s,placeholder:"Value",radius:2,step:"any",type:"number",value:i})}
1function VM(e){let{onChange:t,value:n}=e;var i,r;const[o,s]=(0,vo.useState)(null!=(i=null==n?void 0:n.max)?i:""),[a,l]=(0,vo.useState)(null!=(r=null==n?void 0:n.min)?r:""),{state:{fullscreen:c}}=qM(),d=(0,vo.useCallback)((e=>{var i;s(e.currentTarget.value);const r=parseFloat(e.currentTarget.value);t({max:Number.isFinite(r)?r:null,min:null!=(i=null==n?void 0:n.min)?i:null})}),[null==n?void 0:n.min,t]),u=(0,vo.useCallback)((e=>{var i;l(e.currentTarget.value);const r=parseFloat(e.currentTarget.value);t({max:null!=(i=null==n?void 0:n.max)?i:null,min:Number.isFinite(r)?r:null})}),[null==n?void 0:n.max,t]);return(0,go.jsxs)(Co.kC,{gap:2,children:[(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.oi,{fontSize:c?2:1,onChange:u,placeholder:"Min value",radius:2,step:"any",type:"number",value:a})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.oi,{fontSize:c?2:1,onChange:d,placeholder:"Max value",radius:2,step:"any",type:"number",value:o})})]})}function KM(e,t){const n=t.split("."),i=n[0];if(i&&(0,mo.m$)(e)){const t=e.fields.find((e=>e.name===i));if(t){const e=n.slice(1).join(".");return e?KM(t.type,e):t}}}const HM=(0,Es.ZP)(Co.xu)(Zi||(Zi=rd(["\n @supports (-webkit-overflow-scrolling: touch) {\n * [data-ui='Box'] {\n background-attachment: scroll;\n }\n }\n"]))),$M=(0,Es.ZP)(Co.__)(Ni||(Ni=rd(["\n max-width: 150px;\n"])));function WM(e){let{documentId:t,presence:n,schemaType:i}=e;const r=mV(),{draft:o,published:s,isLoading:a}=(0,_o.m2)((()=>hf(r,i,t,"")),[t,r,i]),l=(0,vo.useMemo)((()=>({_id:t,_type:i.name})),[t,i.name]),c=(0,vo.useMemo)((()=>a?null:(0,go.jsxs)(Co.gF,{space:3,children:[n&&n.length>0&&(0,go.jsx)(Cb,{presence:n}),(0,go.jsx)($M,{size:0,muted:!0,textOverflow:"ellipsis",children:i.title})]})),[a,n,i.title]);return(0,go.jsx)(HM,{children:(0,go.jsx)(Qh,{...ff({draft:o,published:s,value:l}),isPlaceholder:null==a||a,layout:"default",icon:i.icon,status:c})})}function GM(e){let{compact:t,disableIntentLink:n,documentId:i,documentType:r,onClick:o,...s}=e;const a=nN().get(r),l=oV(i),c=(0,vo.useMemo)((()=>({id:i,type:null==a?void 0:a.name})),[i,null==a?void 0:a.name]),{onClick:d,href:u}=(0,Bs.PM)({intent:"edit",params:c}),p=(0,vo.useCallback)((e=>{n||d(e),null==o||o()}),[n,o,d]);return a?(0,go.jsx)(Co.xu,{...s,children:(0,go.jsx)(Ju,{as:"a","data-as":"a",flex:1,href:n?void 0:u,onClick:p,padding:t?1:2,radius:2,tabIndex:-1,children:(0,go.jsx)(WM,{documentId:i,presence:l,schemaType:a})})}):null}const XM="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),YM=XM?"Cmd":"Ctrl",JM=Co.Lg.space[1];function QM(e){let{allowEmptyQueries:t,terms:n}=e;const i=!!t||n.query.length>0,r=!!n.filter,o=n.types.length>0;return i||r||o}function eO(e){return tm(e).filter((e=>!(!1===e.__experimental_omnisearch_visibility)))}function tO(e,t){var n,i;return(null!=(n=e.title)?n:e.name).localeCompare(null!=(i=t.title)?i:t.name)}const nO={error:null,hits:[],loading:!1,terms:{query:"",types:[]}};function iO(e){return null!==e}function rO(e){var t;return{...e,terms:{...e.terms,filter:null==(t=e.terms.filter)?void 0:t.trim(),query:e.terms.query.trim()}}}function oO(e){let{allowEmptyQueries:t,initialState:n,onComplete:i,onError:r,onStart:o,schema:s}=e;const[a,l]=(0,vo.useState)(n),c=WZ(qh),d=(0,vo.useMemo)((()=>xm(eO(s),c,{tag:"search.global",unique:!0})),[c,s]),u=(0,_o.W2)((e=>e.pipe((0,Yo.h)(iO),(0,Ho.U)(rO),(0,$o.x)(Ss()),(0,ds.D)((e=>(0,Mo.H)((null==e?void 0:e.debounceTime)||300))),(0,Ko.b)(o),(0,Go.w)((e=>(0,To.z)((0,So.of)({...nO,loading:!0,options:e.options,terms:e.terms}),(0,Zo.s)((()=>QM({allowEmptyQueries:t,terms:e.terms})),d(e.terms,e.options).pipe((0,Ho.U)((e=>({hits:e}))),(0,Ko.b)((e=>{let{hits:t}=e;return null==i?void 0:i(t)})),(0,Wo.K)((t=>(null==r||r(t),(0,So.of)({...nO,error:t,loading:!1,options:e.options,terms:e.terms}))))),(0,So.of)(Ro.E).pipe((0,Ko.b)((()=>null==i?void 0:i([]))))),(0,So.of)({loading:!1})))),(0,Xo.R)(((e,t)=>({...e,...t})),nO),(0,Ko.b)(l))),[t,d]);return{handleSearch:(0,vo.useCallback)((e=>u(e)),[u]),searchState:a}}const sO=40;function aO(e){let{availableCharacters:t=sO,types:n}=e;const i=n.reduce(function(){let e=t;return function(n,i,r){const o=lO(i);return e-=o.length,(0===r||t>o.length&&e>o.length)&&n.push(i),n}}(),[]),r=n.length-i.length;return n.length?["".concat(i.map(lO).join(", ")),...r?["+".concat(r," more")]:[]].join(" "):"All types"}function lO(e){var t;return null!=(t=e.title)?t:e.name}const cO=()=>!0,dO=(0,Es.ZP)(Co.xv)(qi||(qi=rd(["\n word-break: break-word;\n"]))),uO=(0,vo.forwardRef)((function(e,t){let{onSelect:n,types:i=[],value:r}=e;const o=(0,vo.useRef)(null),s=nN(),{state:{fullscreen:a}}=qM(),l=(0,vo.useId)(),[c,d]=(0,vo.useState)([]),{handleSearch:u,searchState:p}=oO({allowEmptyQueries:!0,initialState:{hits:[],loading:!1,error:null,terms:{query:"",types:i}},onComplete:e=>{d(e.map((e=>({hit:e,value:e.hit._id}))))},schema:s}),h=(0,vo.useCallback)((()=>{u({debounceTime:0,options:{limit:100},terms:{query:"",types:i}})}),[u,i]),f=(0,vo.useCallback)((e=>{u(e?{options:{limit:100},terms:{query:e||"",types:i}}:{debounceTime:0,options:{limit:0},terms:{query:"",types:i}})}),[u,i]),m=(0,vo.useCallback)((e=>{var t;const i=null==(t=c.find((t=>t.value===e)))?void 0:t.hit.hit;i&&(null==n||n({_ref:Td(i._id),_type:i._type}))}),[c,n]),g=(0,vo.useMemo)((()=>{const e=aO({types:i});return i.length>0?"Search for ".concat(e):"Search all documents"}),[i]),x=(0,vo.useCallback)((e=>{const t=e.hit.hit._type;return(0,go.jsx)(GM,{compact:!0,disableIntentLink:!0,documentId:e.value,documentType:t})}),[]),v=(0,vo.useCallback)(((e,t)=>{const{content:n,hidden:i,onMouseEnter:r,onMouseLeave:s}
1=e,a=c&&c.length>0;return(0,go.jsx)(Co.J2,{arrow:!1,constrainSize:!0,content:(0,go.jsx)("div",{ref:t,children:a?n:p.terms.query&&(0,go.jsx)(Co.xu,{padding:4,children:(0,go.jsx)(Co.kC,{align:"center",height:"fill",justify:"center",children:(0,go.jsxs)(dO,{align:"center",muted:!0,children:["No results for ",(0,go.jsxs)("strong",{children:["\u201c",p.terms.query,"\u201d"]})]})})})}),matchReferenceWidth:!0,onMouseEnter:r,onMouseLeave:s,open:!p.loading&&!i,overflow:"auto",placement:"bottom-start",radius:2,referenceElement:o.current})}),[c,p.loading,p.terms.query]);return(0,go.jsx)("div",{ref:o,children:(0,go.jsx)(Co.F2,{"aria-label":g,filterOption:cO,fontSize:a?2:1,id:l,loading:p.loading,openButton:{onClick:h},options:c,onQueryChange:f,onSelect:m,placeholder:g,radius:2,ref:t,renderOption:x,renderPopover:v,value:null==r?void 0:r._ref})})}));function pO(e){let{fieldDefinition:t,onChange:n,value:i}=e;const{onClose:r,state:{documentTypesNarrowed:o,fullscreen:s}}=qM(),a=nN(),l=(0,vo.useCallback)((e=>n(e)),[n]),c=(0,vo.useMemo)((()=>t?t.documentTypes.filter((e=>o.includes(e))).flatMap((e=>{const n=a.get(e);if(n){const e=KM(n,t.fieldPath);if((0,mo.jB)(null==e?void 0:e.type))return null==e?void 0:e.type.of.filter(mo.dD).flatMap((e=>e.to));if((0,mo.dD)(null==e?void 0:e.type))return null==e?void 0:e.type.to}return[]})).reduce(((e,t)=>(e.findIndex((e=>e.name===(null==t?void 0:t.name)))<0&&e.push(t),e)),[]):[]),[o,t,a]),d=(0,vo.useCallback)((()=>l(null)),[l]),u=(0,vo.useCallback)((()=>{null==r||r()}),[r]);return(0,go.jsx)(Co.xu,{style:{width:"min(calc(100vw - 40px), 420px)"},children:(null==i?void 0:i._ref)&&(null==i?void 0:i._type)?(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.Zb,{padding:1,radius:1,shadow:1,children:(0,go.jsx)(GM,{compact:!0,documentId:i._ref,documentType:i._type,onClick:u})}),(0,go.jsx)(Co.zx,{fontSize:s?2:1,mode:"ghost",onClick:d,text:"Clear",tone:"critical"})]}):(0,go.jsx)(uO,{onSelect:l,types:c,value:i})})}function hO(e){let{onClick:t,selected:n,title:i,value:r}=e;const o=(0,vo.useCallback)((()=>t(r)),[t,r]);return(0,go.jsx)(Co.sN,{onClick:o,padding:3,pressed:n,tone:"default",children:(0,go.jsx)(Co.kC,{align:"center",justify:"space-between",gap:3,children:(0,go.jsxs)(Co.Kq,{paddingRight:2,space:2,children:[(0,go.jsx)(Co.xv,{size:1,weight:"regular",children:i}),r&&(0,go.jsx)(Co.EK,{muted:!0,size:0,children:r})]})})})}function fO(e){let{fieldDefinition:t,onChange:n,value:i}=e;const r=(0,vo.useId)(),{state:{documentTypesNarrowed:o}}=qM(),s=nN(),a=(0,vo.useMemo)((()=>{if(!t)return[];return t.documentTypes.filter((e=>o.includes(e))).map((e=>{const n=s.get(e);if(n){const e=KM(n,t.fieldPath);return null==e?void 0:e.type.options}return null})).filter(wd).map((e=>e.list)).flatMap((e=>null==e?void 0:e.map((e=>{return t=e,(0,mo.n4)(t)?t:{title:lc()("".concat(t)),value:t};var t})))).filter(wd).reduce(((e,t)=>{const n=e.findIndex((e=>e.value===(null==t?void 0:t.value)));if(n>-1){const i=e[n];e[n]={...e[n],title:nl()([...i.title,t.title]).sort()}}else e.push({...t,title:[t.title]});return e}),[])}),[o,t,s]),l=(0,vo.useCallback)((e=>{n(e)}),[n]);return(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{mode:"ghost",padding:3,children:(0,go.jsxs)(Co.kC,{align:"center",gap:2,justify:"space-between",children:[(0,go.jsx)(Co.xv,{size:1,weight:"regular",children:i||"Select..."}),(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.GVG,{})})})]})}),id:r||"",menu:(0,go.jsx)(Co.v2,{children:a.map(((e,t)=>(0,go.jsx)(hO,{onClick:l,selected:e.value===i,title:e.title.join(", "),value:e.value||""},t)))}),popover:{constrainSize:!0,placement:"bottom-start",portal:!1,radius:2}})}const mO=()=>(0,go.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,go.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"})}),gO=()=>(0,go.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,go.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"})}),xO=()=>(0,go.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,go.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"})}),vO=()=>(0,go.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,go.jsx)("path",{d:"M16.952 19.632L8 13.56V12.072L16.952 6V7.896L9.728 12.768V12.864L16.952 17.736V19.632Z",fill:"currentColor"})});function yO(e){return JSON.stringify(e)}const bO={arrayCountEqual:{buttonLabel:"has",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") == ").concat(yO(n)):null},initialValue:null,inputComponent:UM,label:"quantity is",type:"arrayCountEqual"},arrayCountGt:{buttonLabel:"has >",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") > ").concat(yO(n)):null},icon:gO,initialValue:null,inputComponent:UM,label:"quantity greater than",type:"arrayCountGt"},arrayCountGte:{buttonLabel:"has \u2265",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") >= ").concat(yO(n)):null},icon:mO,initialValue:null,inputComponent:UM,label:"quantity greater than or equal to",type:"arrayCountGte"},arrayCountLt:{buttonLabel:"has <",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") < ").concat(yO(n)):null},icon:vO,initialValue:null,inputComponent:UM,label:"quantity less than",type:"arrayCountLt"},arrayCountLte:{buttonLabel:"has \u2264",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") <= ").concat(yO(n)):null},icon:xO,initialValue:null,inputComponent:UM,label:"quantity less than or equal to",type:"arrayCountLte"},arrayCountNotEqual:{buttonLabel:"does not have",buttonValueComponent:BM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"count(".concat(t,") != ").concat(yO(n)):null},initialValue:null,inputComponent:UM,label:"quantity is not",type:"arrayCountNotEqual"},arrayCountRange:{buttonLabel:"has between",buttonValueComponent:function(e){let{value:t}=e;return(0,go.jsxs)(go.Fragment,{children:[t.min," \u2192 ",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(yO(null==n?void 0:n.min)," && count(").concat(t,") < ").concat(yO(null==n?void 0:n.max)):""},initialValue:null,inputComponent:VM,label:"quantity is between",type:"arrayCountRange"},arrayListIncludes:{buttonLabel:"includes",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(yO(n)," in ").concat(t):null},initialValue:null,inputComponent:fO,label:"includes",type:"arrayListIncludes"},arrayListNotIncludes:{buttonLabel:"does not include",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(yO(n)," in ").concat(t,")"):null},initialValue:null,inputComponent:fO,label:"does not include",type:"arrayListNotIncludes"},arrayReferenceIncludes:{buttonLabel:"includes",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(yO(n._ref)," in ").concat(t,"[]._ref"):null},initialValue:null,inputComponent:pO,label:"includes",type:"arrayReferenceIncludes"},arrayReferenceNotIncludes:{buttonLabel:"does not include",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"!(".concat(yO(n._ref)," in ").concat(t,"[]._ref)"):null},initialValue:null,inputComponent:pO,label:"does not include",type:"arrayReferenceNotIncludes"}},jO=(0,vo.createContext)(null);function wO(e){let{children:t,workspace:n}=e;return(0,go.jsx)(jO.Provider,{value:n,children:t})}function kO(){const e=(0,vo.useContext)(jO);if(!e)throw new Error("Workspace: missing context value");return e}const CO=(0,vo.createContext)(null);function _O(e){let{children:t,...n}=e;const i=(0,vo.useContext)(CO),{unstable_sources:r}=kO();if("source"in n){const{source:e}=n;return(0,go.jsx)(CO.Provider,{value:e,children:t})}if("name"in n){const{name:e}=n,o=r.find((t=>t.name===e));if(!o)throw new Error("Could not find source with name `".concat(e,"` in current workspace"));return i===o?(0,go.jsx)(go.Fragment,{children:t}):(0,go.jsx)(CO.Provider,{value:o,children:t})}throw new Error("Invalid props passed into SourceProvider. A `name` or a `source` object is required.")}function SO(){const e=(0,vo.useContext)(CO);if(!e)throw new Error("Could not find `source` context");return e}function TO(e){return(0,go.jsx)(Co.xu,{...e,children:(0,go.jsxs)(Co.kC,{align:"flex-start",ga
1p:3,children:[(0,go.jsx)(Xp,{tone:"caution",children:(0,go.jsx)(Ds.foC,{})}),(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Xp,{size:1,tone:"caution",weight:"semibold",children:"No valid asset sources found."}),(0,go.jsx)(Xp,{size:1,tone:"caution",children:"Currently, only the default asset source is supported."}),(0,go.jsx)(Xp,{size:1,tone:"caution",children:"Please ensure it's enabled in your studio configuration file."})]})]})})}function IO(e){let{reference:t}=e;const n=mV(),i=(0,vo.useCallback)((e=>Aw(n,e)),[n]);return(0,go.jsx)(oS,{observeAsset:i,reference:t,waitPlaceholder:(0,go.jsx)(EO,{}),children:e=>(0,go.jsx)(PO,{asset:e})})}function PO(e){let{asset:t}=e;return(0,go.jsx)(Co.Zb,{padding:2,shadow:1,children:(0,go.jsxs)(Co.kC,{align:"center",justify:"space-between",wrap:"nowrap",children:[(0,go.jsx)(Co.Zb,{padding:3,radius:1,shadow:1,tone:"transparent",children:(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.bg6,{})})}),(0,go.jsxs)(Co.Kq,{flex:1,space:2,marginLeft:3,children:[(0,go.jsx)(Co.xv,{size:2,textOverflow:"ellipsis",muted:!0,children:(null==t?void 0:t.originalFilename)||t._id}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:RS(t.size)})]})]})})}function EO(){return(0,go.jsx)(Co.Zb,{padding:2,shadow:1,children:(0,go.jsxs)(Co.kC,{align:"center",justify:"flex-start",children:[(0,go.jsx)(Co.Zb,{padding:3,radius:1,shadow:1,tone:"transparent",children:(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.bg6,{})})}),(0,go.jsxs)(Co.Kq,{flex:1,space:2,marginLeft:3,children:[(0,go.jsx)(Co.JQ,{animated:!0,style:{width:"100%"},radius:1}),(0,go.jsx)(Co.JQ,{animated:!0,style:{width:"100%"},radius:1})]})]})})}const AO=(0,Es.ZP)(Co.Zb)(Ui||(Ui=rd(["\n position: relative;\n padding-bottom: 100%;\n"]))),FO=Es.ZP.img(Vi||(Vi=rd(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: block;\n object-fit: contain;\n"]))),MO=(0,Es.ZP)(Co.kC)(Ki||(Ki=rd(["\n height: 100%;\n position: absolute;\n width: 100%;\n"])));function OO(e){let{reference:t}=e;const n=mV(),i=(0,vo.useCallback)((e=>Ew(n,e)),[n]);return(0,go.jsx)(oS,{observeAsset:i,reference:t,children:e=>(0,go.jsx)(RO,{asset:e})})}function RO(e){let{asset:t}=e;const[n,i]=(0,vo.useState)(!1),r="".concat(t.url,"?h=800&fit=max"),o=(0,vo.useCallback)((()=>i(!0)),[]);return(0,go.jsxs)(AO,{__unstable_checkered:!0,border:!0,children:[!n&&(0,go.jsx)(MO,{align:"center",justify:"center",children:(0,go.jsx)(Co.$j,{})}),(0,go.jsx)(FO,{onLoad:o,src:r})]})}function zO(e){let{reference:t}=e;return t?t._type.startsWith("sanity.fileAsset")?(0,go.jsx)(IO,{reference:t}):t._type.startsWith("sanity.imageAsset")?(0,go.jsx)(OO,{reference:t}):null:null}const DO={file:"sanity.fileAsset",image:"sanity.imageAsset"},BO=(0,Es.ZP)(Co.xu)(Hi||(Hi=rd(["\n width: min(calc(100vw - 40px), 320px);\n"])));function LO(e){return function(t){let{onChange:n,value:i}=t;const[r,o]=(0,vo.useState)(null),[s,a]=(0,vo.useState)(null),{state:{fullscreen:l}}=qM(),{file:c,image:d}=SO().form,u=(0,vo.useMemo)((()=>{switch(e){case"file":return c.assetSources.filter((e=>e.name===TM.name));case"image":return d.assetSources.filter((e=>e.name===IM.name));default:throw Error("Unknown asset source found")}}),[c.assetSources,d.assetSources]),p=(0,vo.useId)(),h=WZ(qh),f=(0,vo.useCallback)((()=>{a(null),n(null)}),[n]),m=(0,vo.useCallback)((()=>{o(null)}),[]),g=(0,vo.useCallback)((e=>{const t=e[0];a(t),m()}),[m]),x=(0,vo.useCallback)((e=>o(e)),[]);(0,vo.useEffect)((()=>{"assetDocumentId"===(null==s?void 0:s.kind)&&"string"===typeof(null==s?void 0:s.value)&&e&&n({_ref:s.value,_type:DO[e]})}),[h,n,s]);const v=null==r?void 0:r.component,y=l?2:1,b=i?"Change ".concat(e):"Select ".concat(e),j=ic()(e,"options.accept","image"===e?"image/*":"");return(0,go.jsx)(BO,{children:(0,go.jsxs)(Co.Kq,{space:3,children:[r&&v&&(0,go.jsx)(Co.h_,{children:(0,go.jsx)(v,{assetType:e,dialogHeaderTitle:"Select ".concat(e),onClose:m,onSelect:g,selectedAssets:[],selectionType:"single",accept:j})}),i&&(0,go.jsx)(zO,{reference:i}),(0,go.jsxs)(Co.kC,{gap:2,children:[0===u.length&&(0,go.jsx)(TO,{padding:2}),u.length>0&&(0,go.jsx)(go.Fragment,{children:u.length>1?(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{fontSize:y,icon:i?Ds.UEU:Ds.W1M,iconRight:Ds.v4q,mode:"ghost",style:{flex:i?1:0},text:b}),id:p,menu:(0,go.jsx)(Co.v2,{children:u.map((e=>(0,go.jsx)(Co.sN,{fontSize:y,icon:e.icon||Ds.XBm,onClick:()=>x(e),text:e.title},e.name)))}),popover:{constrainSize:!0,portal:!1,radius:2}}):(0,go.jsx)(Co.zx,{fontSize:y,icon:i?Ds.UEU:Ds.W1M,mode:"ghost",onClick:()=>x(u[0]),style:{flex:i?1:0},text:b})}),i&&(0,go.jsx)(Co.zx,{fontSize:l?2:1,mode:"ghost",onClick:f,style:{flex:1},text:"Clear",tone:"critical"})]})]})})}}const ZO={assetFileEqual:{buttonLabel:"is",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref == ").concat(yO(n._ref)):null},initialValue:null,inputComponent:LO("file"),label:"is",type:"assetFileEqual"},assetFileNotEqual:{buttonLabel:"is not",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref != ").concat(yO(n._ref)):null},initialValue:null,inputComponent:LO("file"),label:"is not",type:"assetFileNotEqual"},assetImageEqual:{buttonLabel:"is",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref == ").concat(yO(n._ref)):null},initialValue:null,inputComponent:LO("image"),label:"is",type:"assetImageEqual"},assetImageNotEqual:{buttonLabel:"is not",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,".asset._ref != ").concat(yO(n._ref)):null},initialValue:null,inputComponent:LO("image"),label:"is not",type:"assetImageNotEqual"}};const NO={booleanEqual:{buttonLabel:"is",buttonValueComponent:function(e){let{value:t}=e;return(0,go.jsx)(go.Fragment,{children:t?"True":"False"})},groqFilter:e=>{let{fieldPath:t,value:n}=e;return"undefined"!==typeof n&&t?"".concat(t," == ").concat(yO(n)):null},initialValue:!0,inputComponent:function(e){let{onChange:t,value:n}=e;const{state:{fullscreen:i}}=qM(),r=(0,vo.useCallback)((e=>{t("true"===e.currentTarget.value)}),[t]);return(0,go.jsxs)(Co.Ph,{fontSize:i?2:1,onChange:r,radius:2,value:String(null==n||n),children:[(0,go.jsx)("option",{value:"true",children:"True"}),(0,go.jsx)("option",{value:"false",children:"False"})]})},label:"is",type:"booleanEqual"}},qO={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"}},UO="Include time",VO=(0,Es.ZP)(Co.xv)($i||($i=rd(["\n cursor: default;
1\n"])));function KO(e){let{onChange:t,value:n}=e;return(0,go.jsxs)(Co.kC,{align:"center",gap:2,justify:"flex-end",marginTop:1,children:[(0,go.jsx)(Co.Kq,{children:(0,go.jsx)(VO,{muted:!0,onClick:t,size:1,weight:"medium",children:UO})}),(0,go.jsx)(Co.rs,{checked:n,label:UO,onChange:t})]})}const HO=(0,vo.createContext)(void 0);function $O(){const e=(0,vo.useContext)(HO);if(void 0===e)throw new Error("useCalendar must be used within an CalendarContext.Provider");return e}const WO=["January","February","March","April","May","June","July","August","September","October","November","December"],GO=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];gc()(0,24);const XO=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],YO=[1,2,3,4,5,6];function JO(e){const{focusedDate:t}=$O(),{fontSize:n,moveFocusedDate:i,onNowClick:r}=e,o=(0,vo.useCallback)((()=>i(-1)),[i]),s=(0,vo.useCallback)((()=>i(1)),[i]);return(0,go.jsxs)(Co.kC,{align:"center",flex:1,justify:"space-between",children:[(0,go.jsxs)(Co.gF,{paddingLeft:2,space:1,children:[(0,go.jsx)(Co.xv,{weight:"medium",children:WO[t.getMonth()]}),(0,go.jsx)(Co.xv,{weight:"medium",children:t.getFullYear()})]}),(0,go.jsxs)(Co.xu,{children:[(0,go.jsx)(Co.zx,{fontSize:n,text:"Today",mode:"bleed",onClick:r}),(0,go.jsx)(Co.zx,{"aria-label":"Go to previous month",onClick:o,mode:"bleed",icon:Ds.wyc}),(0,go.jsx)(Co.zx,{"aria-label":"Go to next month",mode:"bleed",icon:Ds.XCv,onClick:s})]})]})}const QO=Es.ZP.svg((e=>{let{theme:t}=e;return(0,Es.iv)(Wi||(Wi=rd(["\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)})),eR=(0,Es.ZP)(Co.Zb)(Gi||(Gi=rd(["\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 tR(e){let{date:t,onSelect:n}=e;const i=(0,vo.useCallback)((()=>{n(t)}),[t,n]),{date:r,endDate:o,focusedDate:s,fontSize:a,selectRange:l}=$O(),c=r&&(0,da.Z)(t,r),d=l&&r&&(0,da.Z)(t,r),u=l&&o&&(0,da.Z)(t,o),p=(0,ua.Z)(t,s),h=s&&(0,da.Z)(t,s),f=(0,da.Z)(t,new Date),m=r&&o&&!d&&!u&&(0,wa.Z)(t,r)&&(0,ka.Z)(t,o);return(0,go.jsxs)(eR,{__unstable_focusRing:!0,"aria-label":t.toDateString(),"aria-pressed":c,"data-end-date":!!u||void 0,"data-focused":h?"true":"","data-ui":"CalendarDay","aria-selected":c,"data-start-date":!!d||void 0,"data-within-range":!!m||void 0,forwardedAs:"button",onClick:i,padding:3,radius:2,role:"button",selected:c||d||u,tabIndex:-1,tone:m?"primary":"default",children:[f&&(0,go.jsx)(QO,{height:"100%",preserveAspectRatio:"xMidYMid meet",vectorEffect:"non-scaling-stroke",viewBox:"0 0 100 100",width:"100%",children:(0,go.jsx)("circle",{cx:"50",cy:"50",r:"40%"})}),(0,go.jsx)(Co.xv,{align:"center",muted:!c&&!p,size:a,weight:f?"medium":"regular",children:t.getDate()})]})}const nR=e=>{return(t=(e=>{const t=(0,oa.Z)(e);return(0,sa.Z)({start:t,end:(0,aa.Z)(t)})})(e),t.map((e=>[e,...YO.map((t=>(0,la.Z)(e,t)))]))).map((e=>({number:(0,ca.Z)(e[0]),days:e})));var t},iR=(0,Es.ZP)(Co.rj)(Xi||(Xi=rd(["\n grid-template-columns: repeat(7, minmax(44px, auto));\n"])));function rR(e){let{hidden:t,onSelect:n}=e;const{focusedDate:i,fontSize:r}=$O();return(0,go.jsx)(Co.xu,{"aria-hidden":t||!1,"data-ui":"CalendarMonth",children:(0,go.jsxs)(iR,{children:[GO.map((e=>(0,go.jsx)(Co.xu,{paddingBottom:3,paddingTop:2,children:(0,go.jsx)(Co.xv,{align:"center",size:r,weight:"medium",children:e})},e))),nR(i).map(((e,t)=>e.days.map(((e,i)=>(0,go.jsx)(tR,{date:e,onSelect:n},"".concat(t,"-").concat(i))))))]})})}const oR=(0,go.jsx)("span",{"data-preserve-focus":!0,style:{overflow:"hidden",position:"absolute",outline:"none"},tabIndex:-1});function sR(e){const{date:t,endDate:n,fontSize:i,onSelect:r,selectRange:o,selectTime:s}=e,[a,l]=(0,vo.useState)(null),[c,d]=(0,vo.useState)(!1),[u,p]=(0,vo.useState)(t||new Date),h=(0,vo.useRef)(t||null),f=(0,vo.useRef)(n||null),m=(0,vo.useCallback)((()=>{var e;null==(e=null==a?void 0:a.querySelector('[data-focused="true"]'))||e.focus()}
1),[a]),g=(0,vo.useCallback)((e=>{const i=(0,Ca.Z)(e,{hours:e.getHours(),minutes:e.getMinutes(),seconds:0,milliseconds:0}),s=t&&(0,ka.Z)(i,t),a=n&&(0,wa.Z)(i,n);if(o){if(s||a)return void r({date:i,endDate:null});r(c?{date:t||null,endDate:i}:{date:i,endDate:t?null:n||null})}else r({date:i})}),[t,n,r,c,o]),x=(0,vo.useCallback)((()=>{const e=new Date;o?p(e):r({date:e})}),[r,o,p]),v=(0,vo.useCallback)((e=>{var t;XO.includes(e.key)&&(e.preventDefault(),e.target.hasAttribute("data-calendar-grid")?m():("ArrowUp"===e.key&&p((0,la.Z)(u,-7)),"ArrowDown"===e.key&&p((0,la.Z)(u,7)),"ArrowLeft"===e.key&&p((0,la.Z)(u,-1)),"ArrowRight"===e.key&&p((0,la.Z)(u,1)),null==(t=null==a?void 0:a.querySelector("[data-preserve-focus]"))||t.focus()))}),[a,m,u,p]),y=(0,vo.useCallback)((e=>p((0,fa.Z)(u,e))),[u,p]);return(0,vo.useEffect)((()=>{m()}),[m]),(0,vo.useEffect)((()=>{var e;(null==(e=document.activeElement)?void 0:e.matches("[data-calendar-grid], [data-calendar-grid] [data-preserve-focus]"))&&m()}),[m,u]),(0,vo.useEffect)((()=>{var e,i;const o=(null==t?void 0:t.getTime())!==(null==(e=h.current)?void 0:e.getTime()),s=(null==n?void 0:n.getTime())!==(null==(i=f.current)?void 0:i.getTime()),a=o&&!s,l=!o&&s,c=t&&n&&(0,wa.Z)(t,n);a&&(c&&(d(!0),r({date:t,endDate:null})),d(!!t),t&&p(t)),l&&(c&&(d(!0),r({date:n,endDate:null})),d(!!t&&!n),n&&p(n)),o&&s&&(d(!0),t&&p(t)),h.current=t||null,f.current=n||null}),[t,n,r]),(0,go.jsx)(HO.Provider,{value:{date:t,endDate:n,focusedDate:u,fontSize:i,selectRange:o,selectTime:s},children:(0,go.jsxs)(Co.xu,{"data-ui":"Calendar",ref:l,children:[(0,go.jsx)(Co.kC,{children:(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(JO,{fontSize:i,moveFocusedDate:y,onNowClick:x})})}),(0,go.jsxs)(Co.xu,{"data-calendar-grid":!0,onKeyDown:v,marginTop:2,overflow:"hidden",tabIndex:0,children:[(0,go.jsx)(rR,{onSelect:g}),oR]})]})})}function aR(e){let{date:t,endDate:n,onChange:i,selectRange:r,selectTime:o}=e;const{state:{fullscreen:s}}=qM(),a=(0,vo.useCallback)((e=>{i(e)}),[i]);return(0,go.jsx)(sR,{date:t,endDate:n,fontSize:s?2:1,onSelect:a,selectRange:r,selectTime:o})}const lR=(0,Es.ZP)(Co.xu)((e=>{let{background:t,smallClearButton:n}=e;return(0,Es.iv)(Yi||(Yi=rd(["\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)")})),cR=(0,vo.forwardRef)((function(e,t){const{background:n,smallClearButton:i,...r}=e;return(0,go.jsx)(lR,{background:n,smallClearButton:i,children:(0,go.jsx)(Co.oi,{...r,ref:t})})}));function dR(e){let t,{date:n,dateOnly:i,roundDay:r}=e;switch(r){case"end":t=(0,_a.Z)(n);break;case"start":t=(0,Sa.Z)(n);break;default:t=n}return i?t.toISOString().split("T")[0]:t.toISOString()}
1const uR={exampleDate:"Jan 1, 2000",pattern:"MMM d, yyyy"},pR={exampleDate:"Jan 1, 2000 12:00 AM",pattern:"MMM d, yyyy p"},hR=Es.ZP.span((e=>{let{theme:t}=e;return(0,Es.iv)(Ji||(Ji=rd(["\n font-weight: ",";\n "])),t.sanity.fonts.text.weights.medium)})),fR=(0,Es.ZP)(Co.xv)(Qi||(Qi=rd(["\n color: ",";\n"])),Vs.VG.red[500].hex);function mR(e){let{isDateTime:t,onChange:n,placeholderDate:i,isDateTimeFormat:r,value:o,...s}=e;const a=(0,vo.useMemo)((()=>r?pR.pattern:uR.pattern),[r]),[l,c]=(0,vo.useState)(void 0),[d,u]=(0,vo.useState)((()=>{if(!o)return"";const e=new Date(o);return(0,ja.Z)(e,a)})),p=(0,vo.useMemo)((()=>{const e=i||new Date;return(0,ja.Z)(e,a)}),[a,i]),h=(0,vo.useCallback)((e=>{let{dateString:i,triggerOnChange:r}=e;if(!i)return;const o=(0,Ta.Z)(i,a,new Date),s=(0,ba.Z)(o);s&&(r&&n(dR({date:o,dateOnly:!t})),u((0,ja.Z)(o,a))),c(s?void 0:"Invalid ".concat(t?"datetime":"date"))}),[a,t,n]),f=(0,vo.useCallback)((()=>{h({dateString:d,triggerOnChange:!0})}),[d,h]),m=(0,vo.useCallback)((e=>{u(e.currentTarget.value)}),[]),g=(0,vo.useCallback)((()=>{n(null),c(void 0),u("")}),[n]),x=(0,vo.useCallback)((e=>{"Enter"===e.key&&h({dateString:d,triggerOnChange:!0})}),[d,h]);return(0,vo.useEffect)((()=>{const e=o&&new Date(o);e&&h({dateString:(0,ja.Z)(e,a),triggerOnChange:!1})}),[a,h,r,o]),(0,go.jsx)(Co.u,{content:(0,go.jsxs)(Co.kC,{gap:2,children:[(0,go.jsx)(fR,{size:1,children:(0,go.jsx)(Ds.uIy,{})}),(0,go.jsxs)(Co.xv,{muted:!0,size:1,children:["Must be in the format"," ",(0,go.jsx)(hR,{children:r?pR.exampleDate:uR.exampleDate})]})]}),disabled:!l,padding:3,placement:"top",portal:!0,children:(0,go.jsx)("div",{children:(0,go.jsx)(cR,{...s,clearButton:!!d,customValidity:l,onBlur:f,onChange:m,onClear:g,onKeyDown:x,placeholder:p,value:d})})})}function gR(e){let{isDateTime:t,onChange:n,value:i}=e;const{state:{fullscreen:r}}=qM(),o=(0,vo.useCallback)((e=>{let{date:r}=e;if(r){const e=dR({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]),s=(0,vo.useCallback)((()=>{const e=!(null==i?void 0:i.includeTime),r=(null==i?void 0:i.date)?new Date(i.date):null;let o=null;r&&(o=dR({date:r,dateOnly:!t})),n({includeTime:e,date:o})}),[t,n,i]),a=(0,vo.useCallback)((e=>{n({includeTime:null==i?void 0:i.includeTime,date:e||null})}),[n,null==i?void 0:i.includeTime]);return(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(mR,{"aria-label":"Date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:a,radius:2,value:null==i?void 0:i.date}),(0,go.jsx)(aR,{date:(null==i?void 0:i.date)?new Date(i.date):void 0,onChange:o,selectTime:t}),t&&(0,go.jsx)(KO,{onChange:s,value:!!(null==i?void 0:i.includeTime)})]})}function xR(e){return(0,go.jsx)(gR,{...e,isDateTime:!1})}function vR(e){let{direction:t,isDateTime:n,onChange:i,value:r}=e;const{state:{fullscreen:o}}=qM(),s=(0,vo.useMemo)((()=>{switch(t){case"after":return"end";case"before":return"start";default:return}}),[t]),a=(0,vo.useCallback)((e=>{let{date:t}=e,o=null;t&&(o=dR({date:t,dateOnly:!n,roundDay:(null==r?void 0:r.includeTime)?void 0:s})),i({includeTime:null==r?void 0:r.includeTime,date:o})}),[n,i,s,null==r?void 0:r.includeTime]),l=(0,vo.useCallback)((()=>{const e=!(null==r?void 0:r.includeTime),t=(null==r?void 0:r.date)?new Date(r.date):null;let o=null;t&&(o=dR({date:t,dateOnly:!n,roundDay:e?"start":s})),i({includeTime:e,date:o})}),[n,i,s,r]),c=(0,vo.useCallback)((e=>{i({includeTime:null==r?void 0:r.includeTime,date:e||null})}),[i,null==r?void 0:r.includeTime]);return(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(mR,{"aria-label":"Date",fontSize:o?2:1,isDateTime:n,isDateTimeFormat:n&&(null==r?void 0:r.includeTime),onChange:c,radius:2,value:null==r?void 0:r.date}),(0,go.jsx)(aR,{date:(null==r?void 0:r.date)?new Date(r.date):void 0,onChange:a,selectTime:n}),n&&(0,go.jsx)(KO,{onChange:l,value:!!(null==r?void 0:r.includeTime)})]})}function yR(e){let{onChange:t,value:n}=e;const[i,r]=(0,vo.useState)((null==n?void 0:n.unitValue)||""),o=(0,vo.useRef)("days"),s=(0,vo.useRef)((null==n?void 0:n.unitValue)||null),{state:{fullscreen:a}}=qM(),l=(0,vo.useCallback)((()=>{t({unit:null==o?void 0:o.current,unitValue:null==s?void 0:s.current})}),[t]),c=(0,vo.useCallback)((e=>{o.current=e.currentTarget.value,l()}),[l]),d=(0,vo.useCallback)((e=>{r(e.currentTarget.value);const t=parseFloat(e.currentTarget.value);s.current=Number.isFinite(t)?t:null,l()}),[l]);return(0,go.jsxs)(Co.kC,{gap:2,children:[(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.oi,{"aria-label":"Unit value",fontSize:a?2:1,onChange:d,pattern:"\\d*",radius:2,step:"1",type:"number",value:i})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsxs)(Co.Ph,{"aria-label":"Select unit",fontSize:a?2:1,onChange:c,radius:2,value:null==n?void 0:n.unit,children:[(0,go.jsx)("option",{value:"days",children:"Days"}),(0,go.jsx)("option",{value:"months",children:"Months"}),(0,go.jsx)("option",{value:"years",children:"Years"})]})})]})}function bR(e){let{isDateTime:t,onChange:n,value:i}=e;const{state:{fullscreen:r}}=qM(),o=(0,vo.useMemo)((()=>(0,la.Z)(new Date,-7)),[]),s=(0,vo.useMemo)((()=>new Date),[]),a=(0,vo.useCallback)((e=>{let{date:r,endDate:o}=e;n(jR({date:r,endDate:o,includeTime:null==i?void 0:i.includeTime,isDateTime:t}))}),[t,n,null==i?void 0:i.includeTime]),l=(0,vo.useCallback)((()=>{const e=!(null==i?void 0:i.includeTime);n(jR({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]),c=(0,vo.useCallback)((e=>{n({includeTime:null==i?void 0:i.includeTime,dateMax:e||null,dateMin:(null==i?void 0:i.dateMin)||null})}),[n,i]),d=(0,vo.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,go.jsx)("div",{children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.kC,{direction:"column",gap:3,children:[(0,go.jsx)(mR,{"aria-label":"Start date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:d,placeholderDate:o,radius:2,value:null==i?void 0:i.dateMin}),(0,go.jsx)(mR,{"aria-label":"End date",fontSize:r?2:1,isDateTime:t,isDateTimeFormat:t&&(null==i?void 0:i.includeTime),onChange:c,placeholderDate:s,radius:2,value:null==i?void 0:i.dateMax})]}),(0,go.jsx)(aR,{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:a,selectRange:!0,selectTime:t}),t&&(0,go.jsx)(KO,{onChange:l,value:!!(null==i?void 0:i.includeTime)})]})})}function jR(e){let{date:t,endDate:n,includeTime:i,isDateTime:r}=e;return i?{includeTime:i,dateMax:n?dR({date:n,dateOnly:!r,roundDay:"start"}):null,dateMin:t?dR({date:t,dateOnly:!r,roundDay:"start"}):null}:{includeTime:i,dateMax:n?dR({date:n,dateOnly:!r,roundDay:"end"}):null,dateMin:t?dR({date:t,dateOnly:!r,roundDay:"start"}):null}}function wR(e){return(0,go.jsx)(gR,{...e,isDateTime:!0})}const kR={buttonLabel:"after",buttonValueComponent:RM,initialValue:null,label:"is after"},CR={buttonLabel:"before",buttonValueComponent:RM,initialValue:null,label:"is before"},_R={buttonLabel:"is",buttonValueComponent:OM,initialValue:{date:null,includeTime:!1},label:"is"},SR={buttonLabel:"last",buttonValueComponent:function(e){let{value:t}=e;var n;return(0,go.jsxs)(go.Fragment,{children:[Math.floor(null!=(n=null==t?void 0:t.unitValue)?n:0)," ",t.unit]})},label:"is in the last"},TR={buttonLabel:"is not",buttonValueComponent:OM,initialValue:{date:null,includeTime:!1},label:"is not"},IR={buttonLabel:"is between",initialValue:null,label:"is between"},PR={dateAfter:{...kR,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," > ").concat(yO(null==n?void 0:n.date)):null},inputComponent:function(e){return(0,go.jsx)(vR,{...e,direction:"after",isDateTime:!1})},type:"dateAfter"},dateBefore:{...CR,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," < ").concat(yO(null==n?void 0:n.date)):null},inputComponent:function(e){return(0,go.jsx)(vR,{...e,direction:"before",isDateTime:!1})},type:"dateBefore"},dateEqual:{..._R,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," == ").concat(yO(n.date)):null},inputComponent:xR,type:"dateEqual"},dateLast:{...SR,groqFilter:e=>{let{fieldPath:t,value:n}=e;const i="number"===typeof(null==n?void 0:n.unitValue)?Math.floor(n.unitValue):void 0,r=Number.isFinite(i)?(0,Ia.Z)(new Date,{days:"days"===(null==n?void 0:n.unit)?i:0,months:"months"===(null==n?void 0:n.unit)?i:0,years:"years"===(null==n?void 0:n.unit)?i:0}).toISOString().split("T")[0]:null;return r&&t?"".concat(t," > ").concat(yO(r)):null},inputComponent:yR,initialValue:{unit:"days",unitValue:7},type:"dateLast"},dateNotEqual:{...TR,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"".concat(t," != ").concat(yO(n.date)):null},inputComponent:xR,type:"dateNotEqual"},dateRange:{...IR,buttonValueComponent:zM,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(yO(n.dateMin)," && ").concat(t," <= ").concat(yO(n.dateMax)):null},initialValue:{includeTime:!1,dateMax:(0,Pa.Z)().toISOString(),dateMin:null},inputComponent:function(e){return(0,go.jsx)(bR,{...e,isDateTime:!1})},type:"dateRange"},dateTimeAfter:{...kR,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"dateTime(".concat(t,") > dateTime(").concat(yO(n.date),")"):null},inputComponent:function(e){return(0,go.jsx)(vR,{...e,direction:"after",isDateTime:!0})},type:"dateTimeAfter"},dateTimeBefore:{...CR,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n.date)&&t?"dateTime(".concat(t,") < dateTime(").concat(yO(n.date),")"):null},inputComponent:function(e){return(0,go.jsx)(vR,{...e,direction:"before",isDateTime:!0})},type:"dateTimeBefore"},dateTimeEqual:{..._R,groqFilter:e=>{let{fieldPath:t,value:n}=e;const i=(null==n?void 0:n.date)&&new Date(n.date);if(!i||!(0,ba.Z)(i)||!t)return null;const r=((null==n?void 0:n.includeTime)?(0,Ea.Z)(i):(0,Sa.Z)(i)).toISOString(),o=((null==n?void 0:n.includeTime)?(0,Aa.Z)(i):(0,_a.Z)(i)).toISOString();return"dateTime(".concat(t,") > dateTime(").concat(yO(r),") && dateTime(").concat(t,") < dateTime(").concat(yO(o),")")},inputComponent:wR,type:"dateTimeEqual"},dateTimeLast:{...SR,groqFilter:e=>{let{fieldPath:t,value:n}=e;const i="number"===typeof(null==n?void 0:n.unitValue)?Math.floor(n.unitValue):void 0,r=Number.isFinite(i)?(0,Ia.Z)(new Date,{days:"days"===(null==n?void 0:n.unit)?i:0,months:"months"===(null==n?void 0:n.unit)?i:0,years:"years"===(null==n?void 0:n.unit)?i:0}).toISOString():null;return r&&t?"dateTime(".concat(t,") > dateTime(").concat(yO(r),")"):null},initialValue:{unit:"days",unitValue:7},inputComponent:yR,type:"dateTimeLast"},dateTimeNotEqual:{...TR,groqFilter:e=>{let{fieldPath:t,value:n}=e;const i=(null==n?void 0:n.date)&&new Date(n.date);if(!i||!(0,ba.Z)(i)||!t)return null;const r=((null==n?void 0:n.includeTime)?(0,Ea.Z)(i):(0,Sa.Z)(i)).toISOString(),o=((null==n?void 0:n.includeTime)?(0,Aa.Z)(i):(0,_a.Z)(i)).toISOString();return"dateTime(".concat(t,") < dateTime(").concat(yO(r),") || dateTime(").concat(t,") > dateTime(").concat(yO(o),")")},inputComponent:wR,type:"dateTimeNotEqual"},dateTimeRange:{...IR,buttonValueComponent:zM,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(yO(n.dateMin),") && dateTime(").concat(t,") <= dateTime(").concat(yO(n.dateMax),")"):null},initialValue:{includeTime:!1,dateMax:(0,Pa.Z)().toISOString(),dateMin:null},inputComponent:function(e){return(0,go.jsx)(bR,{...e,isDateTime:!0})},type:"dateTimeRange"}};function ER(e){let{onChange:t,value:n}=e;const{state:{fullscreen:i}}=qM(),r=(0,vo.useCallback)((e=>t(e.currentTarget.value||null)),[t]);return(0,go.jsx)(Co.oi,{fontSize:i?2:1,onChange:r,placeholder:"Value",radius:2,value:n||""})}const AR={...bO,...ZO,...NO,...PR,...qO,...{numberEqual:{buttonLabel:"is",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," == ").concat(yO(n)):null},initialValue:null,inputComponent:UM,label:"is",type:"numberEqual"},numberGt:{buttonLabel:">",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," > ").concat(yO(n)):null},icon:gO,initialValue:null,inputComponent:UM,label:"greater than",type:"numberGt"},numberGte:{buttonLabel:"\u2265",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," >= ").concat(yO(n)):null},icon:mO,initialValue:null,inputComponent:UM,label:"greater than or equal to",type:"numberGte"},numberLt:{buttonLabel:"<",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," < ").concat(yO(n)):null},icon:vO,initialValue:null,inputComponent:UM,label:"less than",type:"numberLt"},numberLte:{buttonLabel:"\u2264",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," <= ").concat(yO(n)):null},icon:xO,initialValue:null,inputComponent:UM,label:"less than or equal to",type:"numberLte"},numberNotEqual:{buttonLabel:"is not",buttonValueComponent:DM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return Number.isFinite(n)&&t?"".concat(t," != ").concat(yO(n)):null},initialValue:null,inputComponent:UM,label:"is not",type:"numberNotEqual"},numberRange:{buttonLabel:"is between",buttonValueComponent:function(e){let{value:t}=e;return(0,go.jsxs)(go.Fragment,{children:[t.min," \u2192 ",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(yO(null==n?void 0:n.min)," && ").concat(t," < ").concat(yO(null==n?void 0:n.max)):""},initialValue:null,inputComponent:VM,label:"is between",type:"numberRange"}},...{portableTextEqual:{buttonLabel:"is",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") == ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is",type:"portableTextEqual"},portableTextMatches:{buttonLabel:"contains",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") match ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"contains",type:"portableTextMatches"},portableTextNotEqual:{buttonLabel:"is not",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"pt::text(".concat(t,") != ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is not",type:"portableTextNotEqual"},portableTextNotMatches:{buttonLabel:"does not contain",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(pt::text(".concat(t,") match ").concat(yO(n),")"):null},initialValue:null,inputComponent:ER,label:"does not contain",type:"portableTextNotMatches"}},...{referenceEqual:{buttonLabel:"is",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,"._ref == ").concat(yO(n._ref)):null},initialValue:null,inputComponent:pO,label:"is",type:"referenceEqual"},referenceNotEqual:{buttonLabel:"is not",buttonValueComponent:LM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return(null==n?void 0:n._ref)&&t?"".concat(t,"._ref != ").concat(yO(n._ref)):null},initialValue:null,inputComponent:pO,label:"is not",type:"referenceNotEqual"},referencesAssetFile:{buttonLabel:"\u2192",buttonValueComponent:LM,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(yO(t._ref),")"):null},initialValue:null,inputComponent:LO("file"),label:"file",type:"referencesAssetFile"},referencesAssetImage:{buttonLabel:"\u2192",buttonValueComponent:LM,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(yO(t._ref),")"):null},initialValue:null,inputComponent:LO("image"),label:"image",type:"referencesAssetImage"},referencesDocument:{buttonLabel:"\u2192",buttonValueComponent:LM,groqFilter:e=>{let{value:t}=e;return(null==t?void 0:t._ref)?"references(".concat(yO(t._ref),")"):null},initialValue:null,inputComponent:pO,label:"document",type:"referencesDocument"}},...{slugEqual:{buttonLabel:"is",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current == ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is",type:"slugEqual"},slugMatches:{buttonLabel:"contains",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current match ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"contains",type:"slugMatches"},slugNotEqual:{buttonLabel:"is not",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t,".current != ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is not",type:"slugNotEqual"},slugNotMatches:{buttonLabel:"does not contain",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(t,".current match ").concat(yO(n),")"):null},initialValue:null,inputComponent:ER,label:"does not contain",type:"slugNotMatches"}},...{stringEqual:{buttonLabel:"is",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," == ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is",type:"stringEqual"},stringListEqual:{buttonLabel:"is",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," == ").concat(yO(n)):null},initialValue:null,inputComponent:fO,label:"is",type:"stringListEqual"},stringListNotEqual:{buttonLabel:"is not",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," != ").concat(yO(n)):null},initialValue:null,inputComponent:fO,label:"is not",type:"stringListNotEqual"},stringMatches:{buttonLabel:"contains",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," match ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"contains",type:"stringMatches"},stringNotEqual:{buttonLabel:"is not",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"".concat(t," != ").concat(yO(n)):null},initialValue:null,inputComponent:ER,label:"is not",type:"stringNotEqual"},stringNotMatches:{buttonLabel:"does not contain",buttonValueComponent:ZM,groqFilter:e=>{let{fieldPath:t,value:n}=e;return n&&t?"!(".concat(t," match ").concat(yO(n),")"):null},initialValue:null,inputComponent:ER,label:"does not contain",type:"stringNotMatches"}}},FR=Object.values(AR),MR=[],OR=[],RR=[],zR=(e,t,n)=>{let{schema:i}=t;const 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 new Error("Expected `schema.types` to be an array or a function, but received ".concat(typeof r))},DR=async(e,t,n)=>{let{document:i}=t;const r=null==i?void 0:i.productionUrl;return r?await r(e,n):e},BR=(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 new Error("Expected `tools` to be an array or a function, but received ".concat(typeof i))},LR=(e,t,n)=>{let{schema:i}=t;const 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 new Error("Expected `schema.templates` to be an array or a function, but received ".concat(typeof r))},ZR=(e,t,n)=>{let{document:i}=t;const 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 new Error("Expected `document.badges` to be an array or a function, but received ".concat(typeof r))},NR=(e,t,n)=>{let{document:i}=t;const 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 new Error("Expected `document.actions` to be an array or a function, but received ".concat(typeof r))},qR=(e,t,n)=>{let{document:i}=t;const r=null==i?void 0:i.newDocumentOptions;if(!r)return e;if("function"!==typeof r)throw new Error("Expected `document.resolveNewDocumentOptions` to be a function, but received ".concat(typeof r));return r(e,n)},UR=(e,t,n)=>{let{form:i}=t;var r;const o=null==(r=null==i?void 0:i.file)?void 0:r.assetSources;if(!o)return e;if("function"===typeof o)return o(e,n);if(Array.isArray(o))return[...e,...o];throw new Error("Expected `form.file.assetSources` to be an array or a function, but received ".concat(typeof o))},VR=(e,t,n)=>{let{form:i}=t;var r;const o=null==(r=null==i?void 0:i.image)?void 0:r.assetSources;if(!o)return e;if("function"===typeof o)return o(e,n);if(Array.isArray(o))return[...e,...o];throw new Error("Expected `form.image.assetSources` to be an array or a function, but received ".concat(typeof o))},KR=(e,t,n)=>{let{document:i}=t;const 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 new Error("Expected `document.unstable_languageFilter` to be an array or a function, but received ".concat(typeof r))},HR=(e,t,n)=>{let{document:i}=t;const 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 new Error("Expected `document.inspectors` to be an array or a function, but received ".concat(typeof r))};var $R=Object.defineProperty,WR=(e,t,n)=>(((e,t,n)=>{t in e?$R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);
1class GR extends Error{constructor(e){let{propertyName:t,path:n,cause:i}=e;const r=Od(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)),WR(this,"propertyName"),WR(this,"path"),WR(this,"cause"),this.propertyName=t,this.cause=i,this.path=n}}const XR=(e,t)=>{let{plugins:n=[],...i}=e;const r={config:i,path:[...t,i.name]};return[...n.flatMap((e=>XR(e,[...t,i.name]))),r]};function YR(e){let{config:t,context:n,initialValue:i,propertyName:r,...o}=e;const s=XR(t,[]);if("reducer"in o)return s.reduce(((e,t)=>{let{config:i,path:s}=t;try{return o.reducer(e,i,n)}catch(a){throw new GR({propertyName:r,path:s,cause:a})}}),i);const a=o.asyncReducer;return(async()=>{let e=i;for(const{config:i,path:o}of s)try{e=await a(e,i,n)}catch(t){throw new GR({propertyName:r,path:o,cause:t})}return e})()}var JR=Object.defineProperty,QR=(e,t,n)=>(((e,t,n)=>{t in e?JR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class ez extends Error{constructor(e){let{causes:t,name:n,type:i}=e;const r=t.filter(Boolean).map((e=>Od(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=>"\t- ".concat(e))).join("\n"),"\n\n")),QR(this,"name"),QR(this,"type"),QR(this,"causes"),this.name=n,this.causes=t,this.type=i}}class tz extends Error{constructor(e){super("SchemaError"),this.schema=e}}function nz(e){const t=e.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0);return Math.abs(16807*t%2147483647)/2147483647}const iz=Es.ZP.text(er||(er=rd(["\n font-family: ",";\n font-weight: ",";\n font-size: 16px;\n transform: translateY(1px);\n"])),(e=>{let{theme:t}=e;return t.sanity.fonts.heading.family}),(e=>{let{theme:t}=e;return t.sanity.fonts.heading.weights.bold}));function rz(e,t){const n=nz("".concat(e," ").concat(t)),i=Vs.mE.filter((e=>"gray"!==e)),r=i[Math.floor(n*i.length)],o=["300","400","500","600","700"],s=nz(n.toString()),a=o[Math.floor(s*o.length)],l=Vs.VG[r][a].hex,c=e.split(/\s/g).map((e=>e.replace(/\\W/g,""))).filter(Boolean).slice(0,2).map((e=>e.charAt(0).toUpperCase())),d=(0,jl._j)(l,.4),u=(0,jl.$n)(l,.4),p=(0,jl.WC)(l,"readable",d)?(0,jl.WC)(l,"readable",u)?(0,jl.XV)(l):u:d;return(0,go.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:[(0,go.jsx)("rect",{width:32,height:32,rx:2,fill:l}),(0,go.jsx)(iz,{x:"50%",y:"50%",textAnchor:"middle",alignmentBaseline:"middle",dominantBaseline:"middle",fill:p,children:c})]})}const oz=e=>"error"===e.severity;function sz(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return(0,Us.isValidElementType)(e)?(0,vo.createElement)(e):(0,vo.isValidElement)(e)?e:rz(t,n)}function az(e,t){if(!Array.isArray(e)&&"missingConfigFile"in e)throw new ez({name:"",type:"configuration file",causes:["No `sanity.config.ts` file found","No `sanity.config.js` file found"]});const n=function(e){const t=e||"";if("string"!==typeof t||t.length>0&&!t.startsWith("/"))throw new ez({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 Mz("At least one workspace is required.");(function(e){const t=1===e.length,n=new Map;e.forEach(((e,i)=>{const{name:r,title:o}=e,s=Pz(o,i);if(!r&&!t)throw new Mz("All workspaces must have a `name`, unless only a single workspace is defined. Workspace ".concat(s," did not define a `name`."),{workspace:e,index:i});const a=t&&"undefined"===typeof r?"default":r;if("string"!==typeof a)throw new Mz("Workspace at index ".concat(i," defined an invalid `name` - must be a string."),{workspace:e,index:i});const l=a.toLowerCase(),c=n.get(l);if(c){const t=Pz(c.workspace.title,c.index);throw new Mz("`name`s must be unique. Workspace ".concat(t," and workspace ").concat(s," both have the `name` `").concat(a,"`"),{workspace:e,index:i})}if(n.set(l,{index:i,workspace:e}),!/^[a-z0-9][a-z0-9_-]*$/i.test(a))throw new Mz("All workspace `name`s must consist of only a-z, 0-9, underscore and dashes, and cannot begin with an underscore or dash. Worksp
1ace ".concat(s," has the invalid name `").concat(a,"`"),{workspace:e,index:i})}))})(t),function(e){e.length>1&&e.every(Oz);e.every(Rz);const[t,...n]=e,i=(t.basePath||"/").substring(1).split("/").filter(Boolean).length;n.forEach(((e,n)=>{const r=(e.basePath||"/").substring(1).split("/").length;if(i!==r)throw new Mz("All workspace `basePath`s must have the same amount of segments. Workspace `".concat(Iz(t,n),"` had ").concat(i," segment").concat(1===i?"":"s"," `").concat(t.basePath,"` but workspace `").concat(Iz(e,n),"` had ").concat(r," segment").concat(1===r?"":"s"," `").concat(e.basePath,"`"),{workspace:e,index:n})}));const r=new Map;e.forEach(((e,t)=>{const n=(e.basePath||"").toLowerCase(),i=r.get(n);if(i)throw new Mz("`basePath`s must be unique. Workspaces `".concat(i,"` and `").concat(Iz(e,t),"` both have the `basePath` `").concat(n,"`"),{workspace:e,index:t});r.set(n,Iz(e,t))}))}(t)}({workspaces:i})}catch(o){throw new ez({name:"",type:"workspace",causes:[o.message]})}const r=i.map((e=>{let{unstable_sources:t=[],...i}=e;const r=[i,...t].map((e=>{const t=e.unstable_clientFactory||Ks.eI,{projectId:n,dataset:i,apiHost:r}=e,s=e.auth||_h({clientFactory:t,dataset:i,projectId:n,apiHost:r});let a;try{a=YR({propertyName:"schema.types",config:e,context:{projectId:n,dataset:i},initialValue:[],reducer:zR})}catch(o){throw new ez({name:e.name,type:"source",causes:[o]})}const l=function(e){const t=(0,ta.Fv)(e.types).getTypes(),n=(0,ta._T)(t),i=n.some((e=>e.problems.some(Lh))),r=ea.V.compile({name:e.name,types:i?[]:[...e.types,...Zh].filter(Boolean)});return r._validation=n,(0,na.PA)(r)}({name:e.name,types:a}),c=l._validation,d=null==c?void 0:c.filter((e=>e.problems.some(oz)));if(c&&(null==d?void 0:d.length))throw new tz(l);const u=s.state.pipe((0,Ho.U)((t=>{let{client:n,authenticated:i,currentUser:r}=t;return function(e){let{config:t,client:n,currentUser:i,schema:r,authenticated:s,auth:a}=e;var l,c,d,u;const{dataset:p,projectId:h}=t,f=function(e,t){const n=e.withConfig({apiVersion:"2022-06-30"}),{dataset:i,url:r,requestTagPrefix:o="sanity.studio"}=n.config(),s="".concat(r.replace(/\/+$/,""),"/socket/").concat(i).replace(/^http/,"ws"),a="".concat(s,"?tag=").concat(o),l=t.token?{token$:t.token}:{};return(0,Qs.W0)(a,l)}(n,a),m=[],g={},x=e=>{if(!e||!e.apiVersion)throw new Error("Missing required `apiVersion` option");return g[e.apiVersion]||(g[e.apiVersion]=n.withConfig(e)),g[e.apiVersion]},v={client:n,getClient:x,currentUser:i,dataset:p,projectId:h,schema:r},y=n;let b,j;v.client=[...Object.keys(n),...Object.keys(y.__proto__)].reduce(((e,t)=>{const i=Object.hasOwnProperty.call(n,t)?y[t]:y.__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'),i)})}),{});try{b=YR({config:t,context:v,propertyName:"schema.templates",reducer:LR,initialValue:r.getTypeNames().filter((e=>!/^sanity\./.test(e))).map((e=>r.get(e))).filter(wd).filter((e=>{var t;return"document"===(null==(t=e.type)?void 0:t.name)})).map((e=>({id:e.name,schemaType:e.name,title:e.title||e.name,icon:e.icon,value:e.initialValue||{_type:e.name}})))})}catch(o){throw new ez({name:t.name,type:"source",causes:[o]})}try{j=YR({config:t,context:v,initialValue:[],propertyName:"tools",reducer:BR})}catch(o){throw new ez({name:t.name,type:"source",causes:[o]})}if(j.some((e=>{let{name:t}=e;return"tool"===t})))throw new Error('A tool cannot have the name "tool". Please enter a different name.');const w=b.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}))),k=b.reduce(((e,t)=>(e.set(t.id,t),e)),new Map),C=e=>{const{schemaType:n}=e,i=YR({config:t,context:{...v,creationContext:e},initialValue:w,propertyName:"document.resolveNewDocumentOptions",reducer:qR}),o=[];if(o.length)throw new ez({name:t.name,type:"source",causes:o});return i.map(((e,t)=>{const n=k.get(e.templateId);if(!n)throw new Error("Could not find template with ID `".concat(e.templateId,"`"));const i=r.get(n.schemaType);if(!i)throw new Error("Could not find matching schema type `".concat(n.schemaType,"` for template `").concat(n.id,"`"));const o=e.title||n.title,s=(null==i?void 0:i.title)===o||null==i?void 0:i.title;return{id:"".concat(e.templateId,"-").concat(t),templateId:e.templateId,type:"initialValueTemplateItem",title:o,subtitle:e.subtitle||s,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((e=>{var t;return!n||n===(null==(t=k.get(e.templateId))?void 0:t.schemaType)}))};let _;try{_=C({type:"global"})}catch(o){m.push(o)}if(m.length)throw new ez({name:t.name,type:"source",causes:m});return{type:"source",name:t.name,title:t.title||Js()(t.name),schema:r,getClient:x,dataset:p,projectId:h,tools:j,currentUser:i,authenticated:s,templates:b,auth:a,document:{actions:e=>YR({config:t,context:{...v,...e},initialValue:OR,propertyName:"document.actions",reducer:NR}),badges:e=>YR({config:t,context:{...v,...e},initialValue:MR,propertyName:"document.badges",reducer:ZR}),unstable_fieldActions:e=>YR({config:t,context:{...v,...e},initialValue:Bh,propertyName:"document.unstable_fieldActions",reducer:Dh}),inspectors:e=>YR({config:t,context:{...v,...e},initialValue:Ad,propertyName:"document.inspectors",reducer:HR}),resolveProductionUrl:e=>YR({config:t,context:{...v,...e},initialValue:void 0,propertyName:"resolveProductionUrl",asyncReducer:DR}),resolveNewDocumentOptions:C,unstable_languageFilter:e=>YR({config:t,context:{...v,...e},initialValue:RR,propertyName:"document.unstable_languageFilter",reducer:KR})},form:{file:{assetSources:YR({config:t,context:v,initialValue:[TM],propertyName:"formBuilder.file.assetSources",reducer:UR}),directUploads:void 0===(null==(c=null==(l=t.form)?void 0:l.file)?void 0:c.directUploads)||t.form.file.directUploads},image:{assetSources:YR({config:t,context:v,initialValue:[IM],propertyName:"formBuilder.image.assetSources",reducer:VR}),directUploads:void 0===(null==(u=null==(d=t.form)?void 0:d.image)?void 0:u.directUploads)||t.form.image.directUploads}}
1,search:{filters:AM,operators:FR},__internal:{bifur:f,staticInitialValueTemplateItems:_,options:t}}}({config:e,client:n,currentUser:r,schema:l,authenticated:i,auth:s})})),(0,Jo.d)(1));return{name:e.name,projectId:e.projectId,dataset:e.dataset,title:e.title||Js()(e.name),auth:s,schema:l,source:u}})),s=i.title||Js()(i.name);return{type:"workspace-summary",auth:r[0].auth,basePath:lz(n,i.basePath),dataset:i.dataset,schema:r[0].schema,icon:sz(i.icon,s,"".concat(i.projectId," ").concat(i.dataset)),name:i.name||"default",projectId:i.projectId,theme:i.theme||Co.Lg,title:s,subtitle:i.subtitle,__internal:{sources:r}}}));return{type:"prepared-config",workspaces:r}}function lz(e,t){const n=[e,t||""].map((e=>e.replace(/^\/+/g,"").replace(/\/+$/g,""))).filter(Boolean).join("/");return"/".concat(n)}function cz(e){const{projectId:t,dataset:n,schema:i,currentUser:r,getClient:o}=e;return(0,vo.useMemo)((()=>({projectId:t,dataset:n,schema:i,currentUser:r,getClient:o})),[t,n,i,r,o])}function dz(e){const{projectId:t,dataset:n,schema:i,currentUser:r,getClient:o}=e;return{projectId:t,dataset:n,schema:i,currentUser:r,getClient:o}}function uz(e){const{title:t}=e;return(0,go.jsx)(Co.xu,{padding:3,children:(0,go.jsx)(Co.xv,{weight:"bold",children:t})})}const pz=(0,vo.createContext)(null),hz=(0,vo.createContext)(null);function fz(){return(0,Co.ue)()?"dark":"light"}function mz(e){let{children:t,scheme:n}=e;const i=fz(),r="system"===n?i:n;return(0,go.jsx)(Co.f6,{scheme:r,theme:Co.Lg,children:t})}const gz="sanityStudio:ui:colorScheme";function xz(e){let{children:t,onSchemeChange:n,scheme:i}=e;return i?(0,go.jsx)(bz,{scheme:i,onSchemeChange:n,children:t}):(0,go.jsx)(vz,{onSchemeChange:n,children:t})}function vz(e){let{children:t,onSchemeChange:n}=e;const i=(0,vo.useMemo)((()=>{let e;const t=new Set;return{subscribe:n=>(e||(e=yz(localStorage.getItem(gz))||"system"),t.add(n),()=>{t.delete(n)}),getSnapshot:()=>e,setSnapshot:n=>{e=yz(n);for(const e of t)e()},getServerSnapshot:()=>"system"}}),[]),r=(0,vo.useSyncExternalStore)(i.subscribe,i.getSnapshot,i.getServerSnapshot);return(0,vo.useEffect)((()=>{"function"===typeof n&&n(r),localStorage.setItem(gz,r)}),[n,r]),(0,go.jsx)(hz.Provider,{value:i.setSnapshot,children:(0,go.jsx)(pz.Provider,{value:r,children:(0,go.jsx)(mz,{scheme:r,children:t})})})}function yz(e){switch(e){case"dark":case"light":return e;default:return"system"}}function bz(e){let{children:t,onSchemeChange:n,scheme:i}=e;return(0,go.jsx)(hz.Provider,{value:"function"===typeof n&&n,children:(0,go.jsx)(pz.Provider,{value:i,children:(0,go.jsx)(mz,{scheme:i,children:t})})})}function jz(){const e=(0,vo.useContext)(hz);if(null===e)throw new Error("Could not find `ColorSchemeSetValueContext` context");return e}function wz(){const e=(0,vo.useContext)(pz);if(null===e)throw new Error("Could not find `ColorSchemeValueContext` context");return e}function kz(){const e=wz(),t=fz();return"system"===e?t:e}function Cz(){const e=kz(),t=jz();return(0,vo.useMemo)((()=>({scheme:e,setScheme:t})),[e,t])}function _z(e){const t=wz();return(0,vo.useMemo)((()=>[{title:"System",name:"system",label:"Use system appearance",selected:"system"===t,onSelect:()=>e("system"),icon:Ds.ugZ},{title:"Dark",name:"dark",label:"Use dark appearance",selected:"dark"===t,onSelect:()=>e("dark"),icon:Ds.kLh},{title:"Light",name:"light",label:"Use light appearance",selected:"light"===t,onSelect:()=>e("light"),icon:Ds.NWY}]),[t,e])}const Sz=(0,vo.createContext)(null);function Tz(e){let{config:t,children:n,basePath:i}=e;const{workspaces:r}=(0,vo.useMemo)((()=>az(t,{basePath:i})),[t,i]);return(0,go.jsx)(Sz.Provider,{value:r,children:n})}function Iz(e,t){let{name:n,title:i}=e;return"string"===typeof n&&n.trim().length>0?n:Pz(i,t)}function Pz(e,t){const n="string"===typeof e&&e.trim().length>0?' (titled "'.concat(e,'")'):"";return"at index ".concat(t).concat(n)}function Ez(){const e=(0,vo.useContext)(Sz);if(!e)throw new Error("Could not find `workspaces` context");return e}var Az=Object.defineProperty,Fz=(e,t,n)=>(((e,t,n)=>{t in e?Az(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);
1class Mz extends Error{constructor(e,t){super(e),Fz(this,"index"),Fz(this,"identifier"),this.index=null==t?void 0:t.index,this.identifier=(null==t?void 0:t.workspace)&&Iz(t.workspace,t.index)}}function Oz(e,t){const{name:n,basePath:i}=e;if(i&&"string"===typeof i)return!0;if("undefined"===typeof i)throw new Mz("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 Mz("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 Rz(e,t){const{name:n,basePath:i}=e;if(i&&"/"!==i&&!/^\/[a-z0-9/_-]*[a-z0-9_-]+$/i.test(i))throw new Mz("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 zz(){return(0,go.jsx)(Co.Zb,{height:"fill",children:(0,go.jsx)(Co.kC,{align:"center",height:"fill",justify:"center",padding:4,sizing:"border",children:(0,go.jsx)(Co.W2,{width:0,children:(0,go.jsx)(Co.Zb,{padding:4,radius:2,shadow:1,tone:"caution",children:(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsxs)(Co.Kq,{flex:1,marginLeft:3,space:3,children:[(0,go.jsx)(Co.xv,{as:"h1",size:1,weight:"bold",children:"No configured tools"}),(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:"Please configure a tool in your Studio configuration."}),(0,go.jsx)(Co.xv,{as:"p",muted:!0,size:1,children:(0,go.jsx)("a",{href:"https://www.sanity.io/docs/studio-tools",rel:"noreferrer",target:"_blank",children:"Learn how to add a tool \u2192"})})]})]})})})})})}function Dz(e){const{toolName:t}=e;return(0,go.jsx)(Co.Zb,{height:"fill",children:(0,go.jsx)(Co.kC,{align:"center",height:"fill",justify:"center",padding:4,sizing:"border",children:(0,go.jsx)(Co.W2,{width:0,children:(0,go.jsx)(Co.Zb,{padding:4,radius:2,shadow:1,tone:"caution",children:(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsx)(Co.Kq,{flex:1,marginLeft:3,space:3,children:(0,go.jsxs)(Co.xv,{as:"h1",size:1,weight:"bold",children:["Tool not found: ",(0,go.jsx)("code",{children:t})]})})]})})})})})}function Bz(){return(0,go.jsxs)(Co.kC,{as:Co.Zb,justify:"center",align:"center",height:"fill",direction:"column",gap:4,children:[(0,go.jsx)(Co.xv,{muted:!0,children:"Loading\u2026"}),(0,go.jsx)(Co.$j,{muted:!0})]})}const Lz={error:"critical",warning:"caution"},Zz=Es.ZP.code(tr||(tr=rd(["\n && {\n background: none;\n color: inherit;\n }\n"]))),Nz=(0,Es.ZP)(Co.xv)(nr||(nr=rd(["\n white-space: pre-line;\n"])));function qz(e){const{problemGroups:t}=e,n=(0,vo.useMemo)((()=>{const e=[];for(const n of t)for(const t of n.problems)e.push({group:n,problem:t});return e}),[t]);return(0,go.jsx)(Co.Kq,{as:"ul",space:4,children:n.map(((e,t)=>{let{group:n,problem:i}=e;const r="error"===i.severity,o="warning"===i.severity,s=function(e){const t=e.path[0];if("type"===t.kind)return{name:t.name,type:t.type};return null}(n);return(0,go.jsxs)(Co.Zb,{border:!0,padding:4,radius:2,tone:Lz[i.severity],children:[(0,go.jsxs)(Co.kC,{children:[(0,go.jsx)(Co.xu,{marginRight:3,children:(0,go.jsxs)(Co.xv,{muted:!0,size:1,children:[r&&(0,go.jsx)(Ds.uIy,{}),o&&(0,go.jsx)(Ds.foC,{})]})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(Co.xv,{size:1,weight:"semibold",children:s?(0,go.jsxs)(go.Fragment,{children:[lc()(s.type),' type "',s.name,'"']}):null})})]}),(0,go.jsx)(Co.xu,{marginTop:4,children:(0,go.jsx)(Co.Zb,{border:!0,overflow:"auto",padding:2,tone:"inherit",children:(0,go.jsx)(Co.Oo,{separator:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:"\u2192"}),children:n.path.map(((e,t)=>"type"===e.kind?(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Zz,{children:"".concat(Uz(e.name),":").concat(e.type)})},t):"property"===e.kind?(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Zz,{children:e.name})},t):null))})})}),(0,go.jsx)(Co.xu,{as:"ul",marginTop:4,children:(0,go.jsx)(Co.xu,{as:"li",children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Nz,{muted:!0,size:1,children:i.message}),i.helpId&&(0,go.jsx)(Co.xv,{muted:!0,size:1,children:(0,go.jsx)("a",{href:(0,$c.h)(i.helpId),target:"_blank",rel:"noopener noreferrer",children:"View documentation \u2192"})})]})})})]},t)}))})}function Uz(e){if(null==e?void 0:e.startsWith("<unnamed_type_@_index")){const t=e.slice(1,-1).split("_");return"[".concat(t[4],"]")}return e}function Vz(e){const t=e._validation,n=null==t?void 0:t.filter((e=>e.problems.some((e=>
1"warning"===e.severity))));0!==(null==n?void 0:n.length)&&(console.groupCollapsed("\u26a0\ufe0f Schema has ".concat(null==n?void 0:n.length," warnings")),null==n||n.forEach((e=>{const t=function(e){return e.map((e=>"type"===e.kind?"".concat(e.name||"<unnamed>","(").concat(e.type,")"):"property"===e.kind?e.name:null)).filter(Boolean).join(" > ")}(e.path);console.group("%cAt ".concat(t),"color: #FF7636"),e.problems.forEach((e=>{console.log(e.message)})),console.groupEnd()})),console.groupEnd())}function Kz(e){let{schema:t}=e;var n;const i=(null==(n=t._validation)?void 0:n.filter((e=>e.problems.some((e=>"error"===e.severity)))))||[];return(0,vo.useEffect)((()=>Vz(t)),[t]),(0,go.jsx)(Co.Zb,{height:"fill",overflow:"auto",paddingY:[4,5,6,7],paddingX:4,sizing:"border",children:(0,go.jsx)(Co.W2,{width:1,children:(0,go.jsxs)(Co.Kq,{space:5,children:[(0,go.jsx)(Co.X6,{as:"h1",children:"Schema errors"}),(0,go.jsx)(qz,{problemGroups:i})]})})})}function Hz(e){return(0,go.jsx)(Co.Zb,{height:"fill",sizing:"border",tone:"caution",display:"flex",children:(0,go.jsx)(Co.kC,{direction:"row",justify:"center",flex:1,align:"center",children:(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Co.X6,{as:"h1",children:"Workspace not found"}),(0,go.jsx)(Co.gF,{children:(0,go.jsx)(Co.zx,{text:"Go to default workspace",onClick:e.onNavigateToDefaultWorkspace,mode:"ghost"})})]})})})}const $z=(0,vo.createContext)(null);function Wz(e){return(0,vo.useMemo)((()=>function(e){return e.map((e=>{const t=e.basePath||"/";return{workspace:e,name:e.name,basePath:t,basePathRegex:new RegExp("^".concat(Nl()(t),"(\\/|$)"),"i")}}))}(e)),[e])}function Gz(e,t){const n=Wz(t),i=(0,vo.useMemo)((()=>function(e){const t=e.map((e=>e.basePath.substring(1).split("/"))).reduce(((e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n].toLowerCase())return e.slice(0,n);return e}));return new RegExp("^".concat(function e(t){let[n,...i]=t;return n?"(\\/".concat(Nl()(n)).concat(e(i),"(\\/|$))?"):""}(t),"$"),"i")}(n)),[n]),[r]=(0,vo.useState)((()=>e.location.pathname)),o=(0,vo.useMemo)((()=>({subscribe:t=>e.listen(t),getSnapshot:()=>e.location.pathname,getServerSnapshot:()=>r,selector:e=>function(e){let{pathname:t,workspaces:n,basePathRegex:i}=e;const[r]=n;for(const{workspace:o,basePath:s,basePathRegex:a}of n)if(a.test(t)||"/"===s)return{type:"match",workspace:o};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 new Error("Unknown type: ".concat(e.type))}}})),[i,e,r,n]);return(0,Ll.useSyncExternalStoreWithSelector)(o.subscribe,o.getSnapshot,o.getServerSnapshot,o.selector,o.isEqual)}const Xz=(0,vo.createContext)(null);function Yz(e){let{children:t,history:n}=e;return(0,go.jsx)(Xz.Provider,{value:n,children:t})}const Jz=(0,vo.memo)((function(e){let{children:t,history:n,activeWorkspace:i,setActiveWorkspace:r}=e;const o=(0,vo.useMemo)((()=>({activeWorkspace:i,setActiveWorkspace:r})),[i,r]);return(0,go.jsx)($z.Provider,{value:o,children:(0,go.jsx)(Yz,{history:n,children:t})})}));function Qz(e){let{children:t,LoadingComponent:n,NotFoundComponent:i,unstable_history:r}=e;const o=Ez(),s=(0,vo.useMemo)((()=>r||("undefined"===typeof document?(0,Bl.PP)():(0,Bl.lX)())),[r]),a=(0,vo.useCallback)((e=>{const t=o.find((t=>t.name===e));t&&s.push(t.basePath)}),[s,o]),l=(0,vo.useCallback)((()=>{a(o[0].name)}),[a,o]),c=Gz(s,o);switch((0,vo.useEffect)((()=>{"redirect"===c.type&&s.replace(c.pathname)}),[s,c]),c.type){case"match":return(0,go.jsx)(Jz,{activeWorkspace:c.workspace,history:s,setActiveWorkspace:a,children:t});case"redirect":return(0,go.jsx)(n,{});case"not-found":return(0,go.jsx)(i,{onNavigateToDefaultWorkspace:l});default:throw new Error("Unknown type: ".concat(c.type))}}function eD(){const e=(0,vo.useContext)($z);if(!e)throw new Error("Could not find `ActiveWorkspaceMatcher` context");return e}const tD={"logged-in":"","logged-out":"Signed out","no-access":""},nD=(0,Es.ZP)(Co.Zb)(ir||(ir=rd(["\n width: 35px;\n height: 35px;\n\n svg {\n width: 100%;\n height: 100%;\n }\n"]))),iD=e=>(0,Us.isValidElementType)(e)?(0,vo.createElement)(e):(0,vo.isValidElement)(e)?e:void 0;function rD(e){const{state:t,subtitle:n,selected:i,title:r,icon:o,iconRight:s}=e,a=(0,vo.useMemo)((()=>iD(o)),[o]),l=(0,vo.useMemo)((()=>iD(s)),[s]);return(0,go.jsxs)(Co.kC,{align:"center",flex:"none",gap:3,children:[(0,go.jsx)(nD,{radius:2,tone:"transparent",children:a}),(0,go.jsxs)(Co.Kq,{flex:1,space:2,children:[(0,go.jsx)(Co.xv,{textOverflow:"ellipsis",weight:"medium",children:r}),n&&(0,go.jsx)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:n})]}),t&&tD[t]&&(0,go.jsx)(Co.xu,{paddingLeft:1,children:(0,go.jsx)(Co.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:tD[t]})}),(i||l)&&(0,go.jsxs)(Co.kC,{align:"center",gap:4,paddingLeft:3,paddingRight:2,children:[i&&(0,go.jsx)(Co.xv,{children:(0,go.jsx)(Ds.KML,{})}),l&&(0,go.jsx)(Co.xv,{muted:!0,children:l})]})]})}const oD=jd((e=>(0,Do.a)(e.map((e=>e.auth.state.pipe((0,Ho.U)((t=>[e.name,t])))))).pipe((0,Ho.U)((e=>Object.fromEntries(e)))))),sD=[{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"}],aD=(0,Es.ZP)(Co.xv)(rr||(rr=rd(["\n a {\n color: inherit;\n }\n"])));
1function lD(e){const{children:t,footer:n,header:i}=e;return(0,go.jsxs)(Co.Kq,{space:6,children:[(0,go.jsx)(Co.Zb,{border:!0,radius:3,overflow:"auto",children:(0,go.jsxs)(Co.Kq,{children:["object"===typeof i&&(0,go.jsx)(Co.xu,{children:i}),"string"===typeof i&&(0,go.jsx)(Co.xu,{paddingY:4,children:(0,go.jsx)(Co.X6,{align:"center",size:1,children:i})}),(0,go.jsx)(Co.xu,{paddingX:1,children:(0,go.jsx)(Co.Zb,{borderTop:Boolean(i),borderBottom:Boolean(n),children:t})}),n&&(0,go.jsx)(Co.xu,{children:n})]})}),(0,go.jsxs)(Co.kC,{direction:"column",gap:4,justify:"center",align:"center",children:[(0,go.jsx)(Co.xv,{size:3,children:(0,go.jsx)(Wc.hn,{})}),(0,go.jsx)(Co.kC,{align:"center",gap:2,children:sD.map(((e,t)=>(0,go.jsxs)(vo.Fragment,{children:[(0,go.jsx)(aD,{muted:!0,size:1,children:(0,go.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.title})}),t<sD.length-1&&(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"\u2022"})]},e.title)))})]})]})}function cD(){var e;const t=Ez(),{activeWorkspace:n,setActiveWorkspace:i}=eD(),[r]=oD(t),[o,s]=(0,vo.useState)((null==n?void 0:n.name)||null),a=1===t.length?t[0]:t.find((e=>e.name===o)),l=null==(e=null==a?void 0:a.auth)?void 0:e.LoginComponent,c=(0,vo.useCallback)((()=>s(null)),[]);return r?l&&a?(0,go.jsxs)(Co.Kq,{space:2,children:[t.length>1&&(0,go.jsx)(Co.kC,{children:(0,go.jsx)(Co.zx,{fontSize:1,icon:Ds.Y4O,mode:"bleed",onClick:c,padding:2,text:"Choose another workspace"})}),(0,go.jsx)(lD,{header:(0,go.jsx)(Co.xu,{padding:3,children:(0,go.jsx)(rD,{icon:a.icon,title:a.title,subtitle:null==a?void 0:a.subtitle})}),children:(0,go.jsx)(Co.Kq,{padding:2,paddingBottom:3,paddingTop:4,children:(0,vo.createElement)(l,{...hl()(a,["type","__internal"]),key:o})})})]}):(0,go.jsx)(lD,{header:"Choose your workspace",footer:(0,go.jsx)(Co.Kq,{padding:1,children:(0,go.jsx)(Co.zx,{as:"a",href:"https://beta.sanity.io/docs/platform/studio/config/workspaces",icon:Ds.dtP,justify:"flex-start",mode:"bleed",rel:"noopener noreferrer",target:"__blank",text:"Add workspace"})}),children:(0,go.jsx)(Co.Kq,{space:1,paddingX:1,paddingY:2,children:t.map((e=>{const t=r[e.name].authenticated?"logged-in":e.auth.LoginComponent?"logged-out":"no-access";return(0,go.jsx)(Co.Zb,{as:"button",radius:2,padding:2,onClick:()=>{"logged-in"===t&&e.name!==n.name&&i(e.name),"logged-out"===t&&s(e.name)},children:(0,go.jsx)(rD,{icon:null==e?void 0:e.icon,iconRight:Ds.XCv,state:t,subtitle:null==e?void 0:e.subtitle,title:(null==e?void 0:e.title)||e.name})},e.name)}))})}):(0,go.jsx)(Bz,{})}const dD=(0,Es.ZP)(Co.v2)(or||(or=rd(["\n max-width: 350px;\n min-width: 250px;\n"])));function uD(e){const{scheme:t}=Cz(),n=Ez(),{activeWorkspace:i,setActiveWorkspace:r}=eD(),[o]=oD(n),{navigateUrl:s}=(0,Bs.tv)(),a=(0,vo.useMemo)((()=>({constrainSize:!0,scheme:t,portal:!0})),[t]);return(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{icon:Ds.GVG,mode:"bleed",...e,disabled:!o}),id:"workspace-menu",menu:(0,go.jsxs)(dD,{children:[(0,go.jsx)(Co.xu,{paddingX:3,paddingY:3,children:(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Workspaces"})}),o&&n.map((e=>{const t=o[e.name].authenticated?"logged-in":e.auth.LoginComponent?"logged-out":"no-access";return(0,go.jsx)(Co.sN,{onClick:()=>{"logged-in"===t&&e.name!==i.name&&r(e.name),"logged-out"===t&&s({path:e.basePath})},padding:2,pressed:e.name===i.name,children:(0,go.jsx)(rD,{icon:null==e?void 0:e.icon,selected:e.name===i.name,state:t,subtitle:null==e?void 0:e.subtitle,title:(null==e?void 0:e.title)||e.name})},e.name)}))]}),popover:a})}function pD(){return(0,go.jsx)(Co.Zb,{height:"fill",children:(0,go.jsx)(Co.kC,{align:"center",justify:"center",height:"fill",children:(0,go.jsx)(Co.W2,{width:0,children:(0,go.jsx)(cD,{})})})})}function hD(){return(0,go.jsx)(go.Fragment,{children:"TODO: implement config errors screen"})}function fD(){const[e,t]=(0,vo.useState)(null),[n,i]=(0,vo.useState)(null);if(n)throw n;const{activeWorkspace:r}=eD(),o=(0,vo.useCallback)((()=>{var e,t;null==(t=(e=r.auth).logout)||t.call(e)}),[r]);(0,vo.useEffect)((()=>{const e=r.auth.state.subscribe({next:e=>{let{currentUser:n}=e;t(n)},error:i});return()=>{e.unsubscribe()}}),[r]);const s=Sh(null==e?void 0:e.provider),a=s?" through ".concat(s):"";return(0,go.jsx)(Co.Zb,{height:"fill",children:(0,go.jsx)(Co.Vq,{id:"not-authorized-dialog",header:"Not authorized",width:1,footer:(0,go.jsx)(Co.Kq,{paddingX:3,paddingY:2,children:(0,go.jsx)(Co.zx,{text:"Sign out",onClick:o})}),children:(0,go.jsxs)(Co.Kq,{paddingX:4,paddingY:5,space:4,children:[(0,go.jsx)(Co.xv,{children:"You are not authorized to access this studio. Maybe you could ask someone to invite you to collaborate on this project?"}),(0,go.jsxs)(Co.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,go.jsxs)("strong",{children:[null==e?void 0:e.name," (",null==e?void 0:e.email,")"]}),a,"."]})]})})})}const mD=Es.ZP.label(sr||(sr=rd(["\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"])));function gD(e){const{projectId:t}=e,n=window.location.origin,i=(0,vo.useMemo)((()=>{const 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,vo.useEffect)((()=>{const e=()=>{window.location.reload()};return window.addEventListener("focus",e),()=>{window.removeEventListener("focus",e)}}),[]),(0,go.jsx)(Co.Zb,{height:"fill",children:(0,go.jsx)(Co.Vq,{id:"cors-error-dialog",header:"Before you continue...",width:1,children:(0,go.jsxs)(Co.Kq,{paddingX:4,paddingY:5,space:4,children:[(0,go.jsxs)(Co.xv,{children:["To access your content, you need to ",(0,go.jsx)("b",{children:"add the following URL as a CORS origin"})," to your Sanity project."]}),(0,go.jsx)(mD,{"aria-hidden":"true",children:"CORS URL to be added"}),(0,go.jsx)(Co.oi,{value:n,readOnly:!0}),(0,go.jsx)(Co.zx,{as:"a",href:i,target:"_blank",rel:"noopener noreferrer",tone
1:"primary",children:(0,go.jsxs)(Co.kC,{align:"center",justify:"center",gap:3,children:[(0,go.jsx)(Co.xv,{weight:"medium",children:"Continue"}),(0,go.jsx)(Co.xv,{weight:"medium",children:(0,go.jsx)(Ds.buG,{})})]})})]})})})}function xD(e){let{children:t,heading:n="An error occured"}=e;const[{error:i},r]=(0,vo.useState)({error:null}),o=Od(i)&&"string"===typeof i.message&&i.message,s=Od(i)&&"string"===typeof i.stack&&i.stack,a=(0,vo.useCallback)((()=>r({error:null})),[r]);return(0,_l.H)(a),i instanceof ch?(0,go.jsx)(gD,{projectId:null==i?void 0:i.projectId}):i instanceof tz?(0,go.jsx)(Kz,{schema:i.schema}):i?(0,go.jsx)(Co.Zb,{height:"fill",overflow:"auto",paddingY:[4,5,6,7],paddingX:4,sizing:"border",tone:"critical",children:(0,go.jsx)(Co.W2,{width:3,children:(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Co.X6,{children:n}),(0,go.jsx)("div",{children:(0,go.jsx)(Co.zx,{onClick:a,text:"Retry",tone:"default"})}),(0,go.jsx)(Co.Zb,{border:!0,radius:2,overflow:"auto",padding:4,tone:"inherit",children:(0,go.jsxs)(Co.Kq,{space:4,children:[o&&(0,go.jsx)(Co.EK,{size:1,children:(0,go.jsxs)("strong",{children:["Error: ",o]})}),s&&(0,go.jsx)(Co.EK,{size:1,children:s})]})})]})})}):(0,go.jsx)(Co.SV,{onCatch:r,children:t})}const vD=(0,Es.ZP)(Co.Zb)(ar||(ar=rd(["\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"]))),yD=(0,vo.createContext)({onSearchFullscreenOpenChange:()=>"",searchFullscreenOpen:!1,searchFullscreenPortalEl:null});function bD(){const{name:e,title:t,tools:n}=kO(),i=(0,Bs.z)((0,vo.useCallback)((e=>"string"===typeof e.tool?e.tool:void 0),[])),r=(0,vo.useMemo)((()=>n.find((e=>e.name===i))),[i,n]),[o,s]=(0,vo.useState)(!1),[a,l]=(0,vo.useState)(null),c=(0,vo.useMemo)((()=>{const n=t||Js()(e);return i?"".concat(n," \u2013 ").concat(Js()(i)):n}),[i,e,t]);(0,vo.useEffect)((()=>{document.title=c}),[c]);const d=(0,vo.useCallback)((e=>{s(e)}),[]),u=(0,vo.useMemo)((()=>({searchFullscreenOpen:o,searchFullscreenPortalEl:a,onSearchFullscreenOpenChange:d})),[o,a,d]),p=Gh({defaultComponent:CZ,pick:EZ});return(0,go.jsxs)(Co.kC,{"data-ui":"ToolScreen",direction:"column",height:"fill","data-testid":"studio-layout",children:[(0,go.jsx)(yD.Provider,{value:u,children:(0,go.jsx)(p,{})}),0===n.length&&(0,go.jsx)(zz,{}),n.length>0&&!r&&i&&(0,go.jsx)(Dz,{toolName:i}),o&&(0,go.jsx)(vD,{ref:l,overflow:"auto"}),(0,go.jsx)(xD,{heading:"The ".concat(null==r?void 0:r.name," tool crashed"),children:(0,go.jsx)(Co.Zb,{flex:1,hidden:o,children:r&&i&&(0,go.jsx)(Bs.NZ,{scope:i,children:(0,go.jsx)(vo.Suspense,{fallback:(0,go.jsx)(jD,{}),children:(0,vo.createElement)(r.component,{tool:r})})})})},null==r?void 0:r.name)]})}function jD(){return(0,go.jsxs)(Co.kC,{justify:"center",align:"center",height:"fill",direction:"column",gap:4,children:[(0,go.jsx)(Co.xv,{muted:!0,children:"Loading\u2026"}),(0,go.jsx)(Co.$j,{muted:!0})]})}const wD=Es.ZP.div(lr||(lr=rd(["\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"]))),kD=(0,go.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,go.jsxs)("g",{clipPath:"url(#clip0)",children:[(0,go.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,go.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,go.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,go.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,go.jsx)("defs",{children:(0,go.jsx)("clipPath",{id:"clip0",children:(0,go.jsx)("rect",{width:"12",height:"12",fill:"white"})})})]}),CD=(0,go.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,go.jsx)("g",{clipPath:"url(#clip0)",children:(0,go.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,go.jsx)("defs",{children:(0,go.jsx)("clipPath",{id:"clip0",children:(0,go.jsx)("rect",{width:"12",height:"12",fill:"white"})})})]}),_D=(0,go.jsxs)("svg",{width:"17",height:"9",viewBox:"0 0 17 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,go.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,go.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,go.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"})]}),SD=e=>{let{provider:t}=e;const n=null==t?void 0:t.startsWith("saml-"),i=n?"saml":t;return(0,go.jsxs)(wD,{"data-logo":i,children:["google"===t&&kD,"github"===t&&CD,"sanity"===t&&(0,go.jsx)(Wc.xN,{}),n&&_D]})},TD=(0,Es.ZP)(Co.v2)(cr||(cr=rd(["\n min-width: 200px;\n max-width: 300px;\n"]))),ID=(0,Es.ZP)(Co.xu)(dr||(dr=rd(["\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 PD(e){let{setScheme:t}=e;const n=_z(t);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Appearance"})}),n.map((e=>{let{icon:t,label:n,name:i,onSelect:r,selected:o,title:s}=e;return(0,go.jsx)(Co.sN,{"aria-label":n,icon:t,onClick:r,pressed:o,text:s,iconRight:o&&(0,go.jsx)(Ds.KML,{})},i)}))]})}function ED(){const{currentUser:e,projectId:t,auth:n}=kO(),i=kz(),r=jz(),o=Boolean(e&&Wd(e,"administrator")),s=Sh(null==e?void 0:e.provider),a=(0,vo.useMemo)((()=>({placement:"bottom-end",portal:!0,preventOverflow:!0,scheme:i,constrainSize:!0})),[i]);return(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{mode:"bleed",padding:0,paddingX:1,children:(0,go.jsxs)(Co.kC,{align:"center",gap:1,children:[(0,go.jsx)(kV,{user:"me",size:1}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:(0,go.jsx)(Ds.v4q,{})})]})}),id:"user-menu",menu:(0,go.jsxs)(TD,{children:[(0,go.jsx)(Co.Zb,{padding:2,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.u,{disabled:!s,portal:!0,content:s&&(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsxs)(Co.xv,{size:1,children:["Signed in with ",s]})}),children:(0,go.jsxs)(ID,{marginRight:3,children:[(0,go.jsx)(kV,{size:1,user:"me"}),(null==e?void 0:e.provider)&&(0,go.jsx)(SD,{provider:e.provider})]})}),(0,go.jsxs)(Co.Kq,{space:2,flex:1,children:[(0,go.jsx)(Co.xv,{size:2,weight:"medium",textOverflow:"ellipsis",children:null==e?void 0:e.name}),(0,go.jsx)(Co.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:null==e?void 0:e.email})]})]})}),r&&(0,go.jsx)(PD,{setScheme:r}),(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.sN,{as:"a","aria-label":"Manage project",href:"https://sanity.io/manage/project/".concat(t),target:"_blank",text:"Manage project",icon:Ds.IEm}),o&&(0,go.jsx)(Co.sN,{as:"a","aria-label":"Invite members",href:"https://sanity.io/manage/project/".concat(t,"/members"),target:"_blank",text:"Invite members",icon:Ds.oyc}),n.logout&&(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.sN,{iconRight:Ds.Ow9,text:"Sign out",disabled:!n.logout,...n.logout&&{onClick:n.logout}})]})]}),popover:a})}const AD=(0,Es.ZP)(Co.xu)(ur||(ur=rd(["\n max-width: 300px;\n"])));function FD(e){const{option:t,currentUser:n,onClick:i,preview:r}=e,o=(0,vo.useMemo)((()=>({template:t.templateId,type:t.schemaType})),[t.schemaType,t.templateId]),{onClick:s,href:a}=(0,Bs.PM)({intent:"create",params:o}),l=(0,vo.useCallback)((e=>{s(e),i(t)}),[s,i,t]);return(0,go.jsx)(Co.u,{disabled:t.hasPermission,portal:!0,content:(0,go.jsx)(AD,{padding:2,children:(0,go.jsx)(Vu,{currentUser:n,operationLabel:"create this document"})}),children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.Zb,{as:t.hasPermission?"a":"button",disabled:!t.hasPermission,href:a,marginBottom:1,onClick:l,padding:"inline"===r?3:4,radius:2,children:(0,go.jsx)(Co.xv,{size:"inline"===r?1:void 0,children:t.title})})})},t.id)}const MD=(0,Es.ZP)(Co.kC)(pr||(pr=rd(["\n min-height: 100px;\n"]))),OD=Es.ZP.strong(hr||(hr=rd(["\n word-break: break-all;\n"])));function RD(e){const{currentUser:t,loading:n,onDocumentClick:i,options:r,preview:o,searchQuery:s,textInputElement:a}=e,l=r.length>0&&!n,c=(0,vo.useCallback)((()=>{i()}),[i]),d=(0,vo.useCallback)((e=>{var t;return!1===(null==(t=r[e])?void 0:t.hasPermission)}),[r]),u=(0,vo.useCallback)((e=>(0,go.jsx)(FD,{currentUser:t,onClick:c,option:e,preview:o},e.id)),[t,c,o]);return n?(0,go.jsx)(MD,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,go.jsxs)(Co.gF,{space:2,children:[(0,go.jsx)(Co.$j,{muted:!0,size:1}),(0,go.jsx)(Co.xv,{muted:!0,size:1,children:"Loading\u2026"})]})}):!l&&s?(0,go.jsx)(MD,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,go.jsxs)(Co.xv,{align:"center",muted:!0,size:1,children:["No results found for ",(0,go.jsxs)(OD,{children:["\u201c",s,"\u201d"]})]})}):l?(0,go.jsx)(Mu,{activeItemDataAttr:"data-hovered",ariaLabel:"New document",autoFocus:Kd?void 0:"input",getItemDisabled:d,inputElement:a,itemHeight:33,items:r,overscan:5,padding:"inline"===o?1:2,paddingBottom:0,renderItem:u}):(0,go.jsx)(MD,{align:"center",flex:1,height:"fill",justify:"center",padding:4,sizing:"border",children:(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:"No documents found"})})}const zD=(0,Es.ZP)(Co.J2)((()=>(0,Es.iv)(fr||(fr=rd(["\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]})))),DD=(0,Es.ZP)(Co.Vq)((()=>(0,Es.iv)(mr||(mr=rd(["\n [data-ui='DialogCard'] {\n justify-content: flex-start;\n }\n "]))))),BD=(0,Es.ZP)(Co.xu)(gr||(gr=rd(["\n max-width: 300px;\n"]))),LD=(0,Es.ZP)(Co.kC)(xr||(xr=rd([""]))),ZD=(0,Es.ZP)(Co.Zb)(vr||(vr=rd(["\n min-height: max-content;\n"]))),ND=(0,Es.ZP)(Co.Zb)(yr||(yr=rd(["\n min-height: max-content;\n"]))),qD=(0,Es.ZP)(Co.kC)((e=>{const{$maxDisplayedItems:t,$itemHeight:n}=e;return(0,Es.iv)(br||(br=rd(["\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 UD(e){const{canCreateDocument:t,modal:n="popover",loading:i,options:r}=e,[o,s]=(0,vo.useState)(!1),[a,l]=(0,vo.useState)(""),[c,d]=(0,vo.useState)(null),[u,p]=(0,vo.useState)(null),[h,f]=(0,vo.useState)(null),[m,g]=(0,vo.useState)(null),{scheme:x}=Cz(),v=xN(),y=r.length>0,b=!t||!y,j="Search",w="Create new document",k=(0,vo.useMemo)((()=>function(e,t){return e.map((e=>({...e,title:(null==e?void 0:e.title)||e.id}))).sort(((e,t)=>e.title.localeCompare(t.title))).filter((e=>function(e,t){const n=t.title.toLowerCase();return e.trim().toLowerCase().split(/[\s\-_]+/).every((e=>n.includes(e)))}(t,e))).sort(((e,n)=>function(e,t,n){const i=t.title.toLowerCase(),r=n.title.toLowerCase(),o=e.trim().toLowerCase();return i.startsWith(o)&&!r.startsWith(o)?-1:r.startsWith(o)&&!i.startsWith(o)?1:i.includes(o)&&!r.includes(o)?-1:r.includes(o)&&!i.includes(o)?1:0}(t,e,n)))}(r,a)),[r,a]),C=(0,vo.useCallback)((e=>{l(e.currentTarget.value)}),[]),_=(0,vo.useCallback)((()=>s((e=>!e))),[]),S=(0,vo.useCallback)((()=>{s(!1),l(""),null==h||h.focus()}),[h]),T=(0,vo.useCallback)((e=>{"ArrowDown"!==e.key||o||s(!0)}),[o]),I=(0,vo.useCallback)((e=>{"Escape"!==e.key&&"Tab"!==e.key||!o||S()}),[S,o]);(0,Co.O8)((()=>{o&&S()}),[h,u,c]);const P=(0,vo.useMemo)((()=>({currentUser:v,loading:i,onDocumentClick:_,options:k,searchQuery:a,preview:"popover"===n?"inline":"default",textInputElement:m})),[v,k,_,i,n,m,a]),E=(0,vo.useMemo)((()=>({border:!1,defaultValue:a,disabled:i,icon:Ds.W1M,onChange:C,placeholder:j,ref:g})),[C,i,j,a]),A=(0,vo.useMemo)((()=>({"aria-label":w,disabled:b||i,icon:Ds.j29,mode:"bleed",onClick:_,ref:f,selected:o})),[b,_,i,o,w]),F=(0,vo.useMemo)((()=>y?t?(0,go.jsx)(Co.xv,{size:1,children:"New document..."}):(0,go.jsx)(Vu,{currentUser:v,operationLabel:"create any document"}):(0,go.jsx)(Co.xv,{size:1,children:"No document types"})),[t,v,y]),M=(0,vo.useMemo)((()=>({content:(0,go.jsx)(BD,{padding:2,children:F}),disabled:i||o,placement:"bottom",portal:!0,scheme:x})),[i,o,x,F]);return"dialog"===n?(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.u,{...M,children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.zx,{...A})})}),o&&(0,go.jsx)(DD,{header:w,id:"create-new-document-dialog",onClickOutside:S,onClose:S,ref:p,scheme:x,width:1,children:(0,go.jsxs)(LD,{direction:"column",flex:1,height:"fill",children:[(0,go.jsx)(ND,{padding:2,borderBottom:!0,children:(0,go.jsx)(Co.oi,{...E})}),(0,go.jsx)(Co.kC,{direction:"column",overflow:"hidden",children:(0,go.jsx)(RD,{...P})})]})})]}):(0,go.jsx)(zD,{constrainSize:!0,onKeyDown:I,open:o,portal:!0,radius:3,ref:d,scheme:x,content:(0,go.jsxs)(LD,{direction:"column",flex:1,forwardedAs:Ls.ZP,height:"fill",returnFocus:!0,children:[(0,go.jsx)(ZD,{sizing:"border",children:(0,go.jsxs)(Co.Kq,{children:[(0,go.jsx)(Co.xu,{paddingX:3,paddingY:3,children:(0,go.jsx)(Co.xu,{paddingY:1,children:(0,go.jsx)(Co.__,{size:1,muted:!0,children:w})})}),(0,go.jsx)(Co.Zb,{borderTop:!0,borderBottom:!0,padding:1,children:(0,go.jsx)(Co.oi,{...E,fontSize:1,radius:1})})]})}),(0,go.jsx)(qD,{$itemHeight:33,$maxDisplayedItems:10,direction:"column",overflow:"hidden",children:(0,go.jsx)(RD,{...P})})]}),children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.u,{...M,children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.zx,{...A,"aria-expanded":o,"aria-haspopup":"true",onKeyDown:T})})})})})}const VD=(0,Es.ZP)(Co.Zb)(jr||(jr=rd(["\n background: transparent;\n margin: calc((-35px + 11px) / 2);\n"]))),KD=(0,vo.memo)((function(e){const{presence:t,focused:n,onFocus:i}=e,[r,o]=(0,vo.useState)(null),s=ml()(t.locations||[],["lastActiveAt"],["desc"]).find((e=>e.documentId)),a=Boolean(null==s?void 0:s.documentId);(0,vo.useEffect)((()=>{n&&r&&(r.focus(),r.setAttribute("data-selected","")),n||null==r||r.removeAttribute("data-selected")}),[r,n]);const l=(0,vo.useCallback)((()=>{i(t.user.id)}),[i,t.user.id]),c=(0,vo.useMemo)((()=>(0,vo.forwardRef)((function(e,t){return(null==s?void 0:s.path)?(0,go.jsx)(Bs.nR,{...e,intent:"edit",params:{id:null==s?void 0:s.documentId,path:xo.BB(null==s?void 0:s.path)},ref:t}):null}))),[s]);return(0,go.jsx)(Co.sN,{as:s?c:"div","data-as":s?"a":"div",onFocus:l,paddingY:a?4:3,paddingLeft:4,paddingRight:3,ref:o,children:(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(VD,{children:(0,go.jsx)(kV,{size:1,user:t.user,status:a?"editing":"inactive"},t.user.id)}),(0,go.jsxs)(Co.Kq,{space:2,marginLeft:4,children:[(0,go.jsx)(Co.xv,{textOverflow:"ellipsis",children:t.user.displayName}),!a&&(0,go.jsx)(Co.xv,{size:0,muted:!0,textOverflow:"ellipsis",children:"Not in a document"})]})]})})})),HD=(0,Es.ZP)(Co.Zb)(wr||(wr=rd(["\n background: transparent;\n"]))),$D=(0,Es.ZP)(Co.v2)(kr||(kr=rd(["\n max-width: 350px;\n min-width: 250px;\n"]))),WD=(0,Es.ZP)(Co.Kq)(Cr||(Cr=rd(["\n position: sticky;\n bottom: 0;\n"])));function GD(e){const{collapse:t}=e,n=function(){const[e,t]=(0,vo.useState)([]),n=xV();return(0,vo.useEffect)((()=>{const e=n.globalPresence$.subscribe(t);return()=>{e.unsubscribe()}}),[n]),e}(),{projectId:i}=kO(),{scheme:r}=Cz(),o=n.length>0,[s,a]=(0,vo.useState)(),l=(0,vo.useCallback)((e=>{a(e)}),[]),c=(0,vo.useCallback)((()=>{a("")}),[]),d=(0,vo.useMemo)((()=>t?(0,go.jsx)(Wp,{icon:Ds.oyc,mode:"bleed",tone:o?"positive":void 0}):(0,go.jsx)(Co.zx,{mode:"bleed",padding:1,children:(0,go.jsx)(HD,{children:(0,go.jsx)(Co.Jh,{maxLength:4,children:n.map((e=>(0,go.jsx)(kV,{user:e.user},e.user.id)))})})})),[t,o,n]),u=(0,vo.useMemo)((()=>({constrainSize:!0,portal:!0,scheme:r})),[r]);return(0,go.jsx)(Co.j2,{button:d,id:"global-presence-menu",onClose:c,menu:(0,go.jsxs)($D,{padding:1,children:[o&&(0,go.jsx)(Co.Kq,{children:n.map((e=>(0,go.jsx)(KD,{focused:s===e.user.id,onFocus:l,presence:e},e.user.id)))}),!o&&(0,go.jsx)(Co.xu,{paddingX:3,paddingY:4,children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{weight:"semibold",size:2,children:"
1No one else is here"}),(0,go.jsx)(Co.xv,{size:1,muted:!0,children:"Invite people to the project to see their online status."})]})}),(0,go.jsxs)(WD,{space:1,children:[(0,go.jsx)(Co.R,{}),(0,go.jsx)(Co.sN,{as:"a",href:"https://sanity.io/manage/project/".concat(i),iconRight:Ds.IEm,onFocus:c,paddingY:4,rel:"noopener noreferrer",target:"_blank",text:"Manage members"})]})]}),popover:u})}const XD={duration:.2},YD={open:{opacity:1},closed:{opacity:0}},JD={open:{x:"0%"},closed:{x:"-100%"}},QD=(0,Es.ZP)(Co.mh)(_r||(_r=rd(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"]))),eB=(0,Es.ZP)((0,Xc.E)(Co.Zb))(Sr||(Sr=rd(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: var(--card-shadow-penumbra-color);\n"]))),tB=(0,Es.ZP)((0,Xc.E)(Co.Zb))(Tr||(Tr=rd(["\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 nB(e){let{setScheme:t}=e;const n=_z(t);return(0,go.jsx)(go.Fragment,{children:(0,go.jsxs)(Co.Zb,{borderTop:!0,flex:"none",padding:3,overflow:"auto",children:[(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.__,{size:1,muted:!0,children:"Appearance"})}),(0,go.jsx)(Co.Kq,{as:"ul",marginTop:1,space:1,children:n.map((e=>{let{icon:t,label:n,name:i,onSelect:r,selected:o,title:s}=e;return(0,go.jsx)(Co.Kq,{as:"li",children:(0,go.jsx)(Co.zx,{"aria-label":n,icon:t,iconRight:o&&(0,go.jsx)(Ds.KML,{}),justify:"flex-start",mode:"bleed",onClick:r,selected:o,text:s})},i)}))})]})})}const iB=(0,vo.memo)((function(e){const{activeToolName:t,isOpen:n,onClose:i,tools:r}=e,o=jz(),{auth:s,currentUser:a,projectId:l}=kO(),c=Ez(),d=MZ(),u=Boolean(a&&Wd(a,"administrator")),p=(0,vo.useCallback)((e=>{"Escape"===e.key&&i()}),[i]);return(0,go.jsx)(Yc.M,{children:n&&(0,go.jsx)(Ls.ZP,{autoFocus:!0,returnFocus:!0,children:(0,go.jsxs)(QD,{onKeyDown:p,children:[(0,go.jsx)(eB,{animate:"open","data-open":n,exit:"closed",initial:"closed",onClick:i,transition:XD,variants:YD}),(0,go.jsxs)(tB,{animate:"open","data-open":n,display:"flex",exit:"closed",height:"fill",initial:"closed",shadow:1,transition:XD,variants:JD,children:[(0,go.jsx)(Co.Zb,{borderBottom:!0,children:(0,go.jsxs)(Co.Kq,{space:3,padding:3,children:[(0,go.jsxs)(Co.kC,{align:"center",children:[(0,go.jsx)(Co.kC,{flex:1,align:"center",paddingRight:2,children:(0,go.jsxs)(Co.kC,{flex:1,align:"center",children:[(0,go.jsx)(Co.xu,{children:(0,go.jsx)(kV,{size:1,user:"me"})}),(0,go.jsx)(Co.xu,{flex:1,marginLeft:2,title:(null==a?void 0:a.name)||(null==a?void 0:a.email),children:(0,go.jsx)(Co.xv,{textOverflow:"ellipsis",children:(null==a?void 0:a.name)||(null==a?void 0:a.email)})})]})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Co.zx,{icon:Ds.Two,mode:"bleed",onClick:i,title:"Close menu"})})]}),c.length>1&&(0,go.jsx)(uD,{text:"Select workspace",justify:"flex-start"})]})}),(0,go.jsxs)(Co.kC,{direction:"column",flex:1,justify:"space-between",overflow:"auto",children:[(0,go.jsx)(Co.Zb,{flex:"none",padding:3,children:(0,go.jsx)(d,{activeToolName:t,closeSidebar:i,context:"sidebar",isSidebarOpen:n,tools:r})}),(0,go.jsxs)(Co.kC,{direction:"column",children:[o&&(0,go.jsx)(nB,{setScheme:o}),(0,go.jsx)(Co.Zb,{borderTop:!0,flex:"none",padding:3,children:(0,go.jsxs)(Co.Kq,{as:"ul",space:1,children:[(0,go.jsx)(Co.Kq,{as:"li",children:(0,go.jsx)(Co.zx,{"aria-label":"Manage project",as:"a",href:"https://sanity.io/manage/project/".concat(l),icon:Ds.IEm,justify:"flex-start",mode:"bleed",target:"_blank",text:"Manage project"})}),u&&(0,go.jsx)(Co.Kq,{as:"li",children:(0,go.jsx)(Co.zx,{"aria-label":"Invite members",as:"a",href:"https://sanity.io/manage/project/".concat(l,"/members"),icon:Ds.oyc,justify:"flex-start",mode:"bleed",target:"_blank",text:"Invite members"})})]})})]})]}),s.logout&&(0,go.jsx)(Co.Zb,{flex:"none",padding:3,borderTop:!0,children:(0,go.jsx)(Co.Kq,{children:(0,go.jsx)(Co.zx,{iconRight:Ds.Ow9,justify:"flex-start",mode:"bleed",onClick:s.logout,text:"Sign out"})})})]})]})})})}));function rB(){var e;const t=(null==(e=nN()._validation)?void 0:e.filter((e=>e.problems.some((e=>
1"warning"===e.severity)))))||[],{scheme:n}=Cz(),i=(0,vo.useId)(),[r,o]=(0,vo.useState)(!1),[s,a]=(0,vo.useState)(null),l=(0,vo.useCallback)((()=>o(!0)),[]),c=(0,vo.useCallback)((()=>{o(!1),s&&s.focus()}),[s]);return 0===t.length?null:(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Wp,{icon:Ds.foC,label:"Found configuration issues",mode:"bleed",onClick:l,ref:a,selected:r,tone:"caution",tooltip:{scheme:n}}),r&&(0,go.jsx)(Co.Vq,{header:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.xv,{weight:"semibold",children:"Configuration issues"}),(0,go.jsx)(Co.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:n,id:i,children:(0,go.jsxs)(Co.Kq,{space:4,padding:4,children:[(0,go.jsxs)(Co.X6,{as:"h2",size:1,children:["Found ",t.length," schema warnings"]}),(0,go.jsx)(qz,{problemGroups:t})]})})]})}function oB(e){const{title:t,children:n,href:i,onClick:r}=e;return(0,go.jsx)(Co.zx,{"aria-label":t,as:"a","data-testid":"logo",href:i,mode:"bleed",onClick:r,padding:0,children:n})}const sB=(0,wl.ZP)("mod+".concat("k")),aB=(0,wl.ZP)("escape");function lB(e){let{children:t,hasValidTerms:n,onClose:i,onOpen:r,open:o}=e;const s=(0,vo.useRef)(!1),{dispatch:a,searchCommandList:l,setOnClose:c,state:{result:d}}=qM(),u=(0,vo.useCallback)((()=>{var e;a({index:null!=(e=null==l?void 0:l.getTopIndex())?e:-1,type:"LAST_ACTIVE_INDEX_SET"}),i()}),[a,i,l]);return function(e){let{open:t,onClose:n,onOpen:i}=e;const{isTopLayer:r}=(0,Co.sJ)(),o=(0,vo.useCallback)((()=>{null==n||n()}),[n]),s=(0,vo.useCallback)((e=>{sB(e)&&(e.preventDefault(),t?o():null==i||i()),aB(e)&&t&&r&&o()}),[o,r,t,i]);(0,Co.qh)(s)}({onClose:u,onOpen:r,open:o}),(0,vo.useEffect)((()=>{c(u)}),[u,c]),(0,vo.useEffect)((()=>{n&&!d.loaded||!s.current||a({index:0,type:"LAST_ACTIVE_INDEX_SET"})}),[a,n,d.loaded]),(0,vo.useEffect)((()=>{n||!s.current||o||a({type:"ORDERING_RESET"})}),[a,n,o]),(0,vo.useEffect)((()=>{(null==s?void 0:s.current)||(s.current=!0)}),[]),o?(0,go.jsx)("div",{children:t}):null}function cB(e){return e.reduce(((e,t)=>(e[t.type]=t,e)),{})}function dB(e,t){return t?e[t]:void 0}function uB(e,t){var n;return null==(n=dB(e,t))?void 0:n.initialValue}function pB(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 hB(e){let{fieldDefinitions:t,filterDefinitions:n,filters:i,operatorDefinitions:r}=e;return i.filter((e=>vB({filter:e,filterDefinitions:n,fieldDefinitions:t,operatorDefinitions:r}))).map((e=>{var i;return null==(i=dB(r,e.operatorType))?void 0:i.groqFilter({fieldPath:xB({filter:e,fieldDefinitions:t,filterDefinitions:n}),value:null==e?void 0:e.value})})).filter((e=>!Cl()(e))).filter(wd).join(" && ")}function fB(e,t){return(null==t?void 0:t.fieldId)?e[t.fieldId]:void 0}function mB(e){return[e.filterName,...e.fieldId?[e.fieldId]:[]].join("-")}function gB(e){let{fieldDefinitions:t,filters:n,types:i}=e;const r=i.map((e=>e.name)),o=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)),s=Ha()(...o),a=[];return r.length>0&&a.push(r),s.length>0&&a.push(s),Ha()(...a).sort()}function xB(e){let{filter:t,fieldDefinitions:n,filterDefinitions:i}=e;const r=fB(n,t),o=EM(i,t.filterName);if(o)switch(o.type){case"field":return null==r?void 0:r.fieldPath;case"pinned":return null==o?void 0:o.fieldPath;default:return}}function vB(e){let{filter:t,filterDefinitions:n,fieldDefinitions:i,operatorDefinitions:r}=e;const o=EM(n,t.filterName),s=dB(r,t.operatorType),a=fB(i,t);if(!o)return!1;if(!s)return!1;if(t.fieldId&&!a)return!1;if("field"===o.type){if(!(null==a?void 0:a.fieldPath))return!1;if(!t.fieldId)return!1;if(!s.groqFilter({fieldPath:a.fieldPath,value:t.value}))return!1}if("pinned"===o.type){if(!s.groqFilter({fieldPath:o.fieldPath,value:t.value}))return!1}return!0}const yB=(0,wl.ZP)("escape"),bB=Es.ZP.div(Ir||(Ir=rd(["\n background: transparent;\n height: 100%;\n left: 0;\n position: fixed;\n top: 0;\n width: 100%;\n z-index: -1;\n"])));function jB(e){let{anchorElement:t,children:n,onClose:i}=e;const{isTopLayer:r}=(0,Co.sJ)(),o=(0,vo.useCallback)((e=>{yB(e)&&r&&i()}),[r,i]);(0,Co.qh)(o);const s=function(e){const[t,n]=(0,vo.useState)(e&&wB(e)),i=(0,vo.useCallback)((()=>{e&&n(wB(e))}),[e]);return(0,vo.useEffect)((()=>{e&&n(wB(e))}),[e]),(0,vo.useEffect)((()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i))),[i]),t}(t||null);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(bB,{onClick:i}),(0,go.jsx)(Ls.ZP,{autoFocus:!1,returnFocus:!0,children:(0,go.jsx)(Co.Zb,{display:"flex",overflow:"hidden",radius:2,style:{maxHeight:"min(calc(100vh - ".concat(s,"px - ").concat(5,"px - ").concat(JM,"px), ").concat(500,"px"),zIndex:1},children:(0,go.jsx)(Co.kC,{children:n})})})]})}function wB(e){const t=e.getBoundingClientRect();return t.y+t.height+5}const kB=(0,Es.ZP)(Co.xu)(Pr||(Pr=rd(["\n border-bottom: 1px solid ",";\n flex-shrink: 0;\n"])),(e=>{let{theme:t}=e;return t.sanity.color.base.border})),CB=(0,Es.ZP)(Co.kC)(Er||(Er=rd(["\n box-sizing: border-box;\n"]))),_B=(0,vo.forwardRef)((function(e,t){let{ariaInputLabel:n,onChange:i,onClear:r,typeFilter:o}=e;const{state:{fullscreen:s}}=qM();return(0,go.jsx)(kB,{children:(0,go.jsx)(CB,{align:"center",flex:1,padding:1,children:(0,go.jsx)(cR,{"aria-label":n,autoComplete:"off",border:!1,clearButton:!!o,fontSize:s?2:1,icon:Ds.W1M,muted:!0,onChange:i,onClear:r,placeholder:"Filter",ref:t,smallClearButton:!0,spellCheck:!1,radius:2,value:o})})})}));function SB(e){let{documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,schema:r,titleFilter:o,types:s}=e;const a=Object.values(n).filter((e=>{return t=o,e.titlePath.join("/").toLowerCase().includes(t.toLowerCase());var t})).map((e=>{const t=EM(i,e.filterName);
1return t?pB(t,e.id):null})).filter(wd),l=function(e){let{fieldDefinitions:t,filterDefinitions:n,titleFilter:i}=e;const r=Object.values(n).filter(AB).filter((e=>PB(e,i))).map((e=>pB(e))),o=Object.values(n).filter(EB).filter((e=>PB(e,i))).reduce(((e,t)=>(e[t.group]=e[t.group]||[],e[t.group].push(pB(t)),e)),{});return[...TB({fieldDefinitions:t,filterDefinitions:n,filters:r,id:"pinned-ungrouped",tone:"primary"}),...Object.entries(o).flatMap((e=>{let[i,r]=e;return TB({fieldDefinitions:t,filterDefinitions:n,filters:r,headerTitle:i,id:i,tone:"primary"})}))]}({fieldDefinitions:n,filterDefinitions:i,titleFilter:o});return 0===t.length?[...l,...TB({fieldDefinitions:n,filterDefinitions:i,filters:a,headerTitle:"All fields",id:"field"})]:[...l,...IB({documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,filters:a,schema:r,types:s})]}function TB(e){let{fieldDefinitions:t,filterDefinitions:n,filters:i,id:r,headerTitle:o,tone:s}=e;const a={title:o||"",tone:s||"default",type:"header"},l=i.map((e=>({fieldDefinition:fB(t,e),filterDefinition:EM(n,e.filterName),filter:e,group:r,tone:s||"default",type:"filter"})));return l.length>0?[...o?[a]:[],...l]:[]}function IB(e){let{documentTypesNarrowed:t,fieldDefinitions:n,filterDefinitions:i,filters:r,schema:o,types:s}=e;const a=r.filter((e=>{const i=fB(n,e);return function(e,t){return 0===Sc()(e,(null==t?void 0:t.documentTypes)||[]).length}(t,i)}));return[...t.length>1&&s.length>1?TB({fieldDefinitions:n,filterDefinitions:i,filters:a,headerTitle:"Shared fields",id:"shared",tone:"primary"}):[],...t.map((e=>{const t=o.get(e);return{title:(null==t?void 0:t.title)||Js()(null==t?void 0:t.name)||"(Unknown type)",documentType:e}})).sort(((e,t)=>e.title.localeCompare(t.title))).map((e=>{let{documentType:t,title:o}=e;const s=r.filter((e=>{const i=fB(n,e);return function(e,t){return null==t?void 0:t.documentTypes.some((t=>e.includes(t)))}([t],i)}));return TB({fieldDefinitions:n,filterDefinitions:i,filters:s,id:o,headerTitle:o})})).flat()]}function PB(e,t){return e.title.toLowerCase().includes(t.toLowerCase())}function EB(e){return"pinned"===e.type&&"undefined"!==typeof(null==e?void 0:e.group)}function AB(e){return"pinned"===e.type&&"undefined"===typeof(null==e?void 0:e.group)}function FB(e){let{filter:t,maxLength:n}=e;const{state:{definitions:i}}=qM(),r=(0,vo.useMemo)((()=>{const e=EM(i.filters,t.filterName);switch(null==e?void 0:e.type){case"field":{const e=fB(i.fields,t);return(null==e?void 0:e.titlePath)?e.titlePath[e.titlePath.length-1]:null}case"pinned":return e.title;default:return null}}),[i,t]);return r?n&&r.length>n?(0,go.jsxs)("span",{children:[r.slice(0,n),"\u2026"]}):(0,go.jsx)("span",{children:r}):null}function MB(e){let{filter:t}=e;var n;const{state:{definitions:i}}=qM(),r=null==(n=EM(i.filters,t.filterName))?void 0:n.icon;return r?(0,vo.createElement)(r):(0,go.jsx)(Ds.Tzq,{})}function OB(e){let{filter:t,small:n=!0}=e;var i;const{state:{definitions:r}}=qM(),o=fB(r.fields,t);return(0,go.jsxs)(Co.Kq,{space:n?2:3,children:[(null==o?void 0:o.titlePath)&&(null==(i=o.titlePath)?void 0:i.length)>1&&(0,go.jsx)(Co.xu,{marginLeft:4,children:(0,go.jsx)(Co.xv,{muted:!0,size:n?0:1,children:o.titlePath.slice(0,-1).map(((e,t)=>(0,go.jsxs)(vo.Fragment,{children:[(0,go.jsx)("span",{children:e}),t!==o.titlePath.length-2&&(0,go.jsx)("span",{style:{opacity:.75,paddingLeft:"0.25em",paddingRight:"0.25em"},children:(0,go.jsx)(Ds.XCv,{})})]},t)))})}),(0,go.jsxs)(Co.kC,{align:"flex-start",gap:3,children:[(0,go.jsx)(Co.xu,{style:{flexShrink:0},children:(0,go.jsx)(Co.xv,{size:n?1:2,children:(0,go.jsx)(MB,{filter:t})})}),(0,go.jsx)(Co.xv,{size:n?1:2,weight:"medium",children:(0,go.jsx)(FB,{filter:t})})]})]})}function RB(e){return(0,vo.isValidElement)(e)?function(e){var t;return(null==(t=(new DOMParser).parseFromString(e,"text/html"))?void 0:t.body.textContent)||""}((0,Gc.Dq)(e)):e}function zB(e){let{children:t,fieldDefinition:n,filterDefinition:i,visible:r}=e;const{state:{documentTypesNarrowed:o}}=qM(),s=nN(),a=(0,vo.useMemo)((()=>(null==n?void 0:n.documentTypes)?n.documentTypes.map((e=>{const t=s.get(e);
1return(null==t?void 0:t.title)||Js()(null==t?void 0:t.name)})).filter(wd).sort():[]),[null==n?void 0:n.documentTypes,s]),l=(0,vo.useMemo)((()=>{if(null==n?void 0:n.documentTypes){const e=n.documentTypes.map((e=>{const t=s.get(e);if(t){const e=KM(t,n.fieldPath);return(null==e?void 0:e.type.description)&&RB(null==e?void 0:e.type.description)}return null})).filter(wd).sort(),t=nl()(e);if(1===t.length)return t[0]}}),[null==n?void 0:n.documentTypes,null==n?void 0:n.fieldPath,s]);return(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.Zb,{tone:"default",radius:2,style:{maxWidth:"250px"},children:(0,go.jsxs)(Co.Kq,{padding:3,space:4,children:[n&&(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsx)(Co.__,{muted:!0,size:0,children:"Field name"}),(0,go.jsx)(Co.gF,{children:(0,go.jsx)(Co.Zb,{tone:"caution",padding:1,radius:2,children:(0,go.jsx)(Co.EK,{size:0,children:null==n?void 0:n.name})})})]}),l&&(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsx)(Co.__,{muted:!0,size:0,children:"Field description"}),(0,go.jsx)(Co.xv,{muted:!0,size:0,children:DB(l)})]}),(null==i?void 0:i.description)&&(0,go.jsx)(Co.xv,{muted:!0,size:0,children:DB(i.description)}),!o.length&&a.length>0&&(0,go.jsxs)(Co.Kq,{space:2,children:[(0,go.jsxs)(Co.kC,{align:"center",gap:1,children:[(0,go.jsx)(Co.__,{muted:!0,size:0,children:"Used in document types"}),(0,go.jsx)(Co.Zb,{padding:1,radius:2,tone:"transparent",children:(0,go.jsx)(Co.xv,{size:0,muted:!0,children:a.length})})]}),(0,go.jsxs)(Co.xv,{size:0,weight:"regular",muted:!0,children:[a.slice(0,10).join(", "),(null==a?void 0:a.length)>10?" +".concat(a.length-10," more"):""]})]})]})}),disabled:!r,fallbackPlacements:["left"],placement:"right",portal:!0,children:t})}function DB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:256;return e.length>t?"".concat(e.slice(0,t-1),"\u2026"):e}const BB=vo.memo((function(e){let{item:t,onClose:n,...i}=e;const[r,o]=(0,vo.useState)(!1),{dispatch:s,state:{filters:a}}=qM(),l=(0,vo.useCallback)((()=>{s({filter:t.filter,type:"TERMS_FILTERS_ADD"}),null==n||n()}),[s,t.filter,n]),c=!!a.find((e=>mB(e)===mB(t.filter))),d=(0,vo.useRef)(),u=(0,vo.useCallback)((()=>{d.current=setTimeout((()=>o(!0)),500)}),[]),p=(0,vo.useCallback)((()=>{o(!1),clearTimeout(d.current)}),[]);(0,vo.useEffect)((()=>()=>clearTimeout(d.current)),[]);const h=!(!t.fieldDefinition&&!t.filterDefinition.description);return(0,go.jsx)(Co.xu,{...i,children:(0,go.jsx)(Co.zx,{disabled:c,fontSize:1,justify:"flex-start",mode:"bleed",onClick:c?void 0:l,onMouseEnter:u,onMouseLeave:p,padding:0,style:{position:"relative",whiteSpace:"normal",width:"100%"},tabIndex:-1,tone:null==t?void 0:t.tone,children:(0,go.jsx)(zB,{fieldDefinition:t.fieldDefinition,filterDefinition:t.filterDefinition,visible:h&&r,children:(0,go.jsx)(Co.xu,{padding:3,children:(0,go.jsx)(OB,{filter:t.filter})})})})})})),LB=vo.memo((function(e){let{item:t}=e;return(0,go.jsx)(Co.xu,{paddingTop:1,children:(0,go.jsx)(Co.Zb,{borderBottom:!0,padding:3,tone:null==t?void 0:t.tone,children:(0,go.jsx)(Co.__,{muted:!0,size:0,textOverflow:"ellipsis",children:t.title})})})}));function ZB(e){let{onClose:t}=e;const[n,i]=(0,vo.useState)(null),[r,o]=(0,vo.useState)(""),s=(0,vo.useCallback)((e=>o(e.currentTarget.value)),[o]),a=(0,vo.useCallback)((()=>o("")),[]),l=nN(),{state:{documentTypesNarrowed:c,definitions:d,filters:u,terms:{types:p}}}=qM(),h=(0,vo.useMemo)((()=>SB({documentTypesNarrowed:c,fieldDefinitions:d.fields,filterDefinitions:d.filters,schema:l,titleFilter:r,types:p})),[c,d.fields,d.filters,l,r,p]),f=(0,vo.useCallback)((e=>"filter"===e.type?(0,go.jsx)(BB,{item:e,onClose:t,paddingBottom:1}):"header"===e.type?(0,go.jsx)(LB,{item:e}):null),[t]),m=(0,vo.useCallback)((e=>{const t=h[e];return"filter"!==t.type||!!u.find((e=>mB(e)===mB(t.filter)))}),[h,u]),g=(0,vo.useCallback)((e=>{const t=h[e];switch(t.type){case"filter":return[...t.group?[t.group]:[],mB(t.filter)].join("-");case"header":return"".concat(t.type,"-").concat(t.title);default:return e}}),[h]);return(0,go.jsxs)(Co.kC,{direction:"column",style:{width:"300px"}
1,children:[(0,go.jsx)(_B,{ariaInputLabel:"Filter by title",onChange:s,onClear:a,ref:i,typeFilter:r}),(0,go.jsxs)(Co.kC,{children:[h.length>0&&(0,go.jsx)(Mu,{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,go.jsx)(Co.xu,{padding:3,children:(0,go.jsxs)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:["No matches for '",r,"'"]})})]})]})}function NB(){const[e,t]=(0,vo.useState)(!1),[n,i]=(0,vo.useState)(null),{state:{fullscreen:r}}=qM(),o=(0,vo.useCallback)((()=>t(!1)),[]),s=(0,vo.useCallback)((()=>t(!0)),[]);return(0,go.jsx)(Co.J2,{__unstable_margins:[5,0,0,0],content:(0,go.jsx)(jB,{anchorElement:n,onClose:o,children:(0,go.jsx)(ZB,{onClose:o})}),open:e,placement:"bottom-start",radius:2,portal:!0,children:(0,go.jsx)(Co.zx,{fontSize:1,icon:Ds.dtP,mode:"bleed",onClick:s,padding:r?3:2,ref:i,selected:e,space:2,text:"Add filter"})})}const qB=vo.memo((function(e){let{selected:t,type:n,...i}=e;var r,o;const{dispatch:s}=qM(),a=(0,vo.useCallback)((()=>{s({type:"TERMS_TYPE_ADD",schemaType:n})}),[s,n]),l=(0,vo.useCallback)((()=>{s({type:"TERMS_TYPE_REMOVE",schemaType:n})}),[s,n]),c=(0,vo.useCallback)((()=>{t?l():a()}),[a,l,t]);return(0,go.jsx)(Co.xu,{...i,children:(0,go.jsx)(Co.zx,{fontSize:1,iconRight:t&&Ds.KML,justify:"flex-start",mode:"bleed",onClick:c,style:{width:"100%"},tabIndex:-1,text:null!=(o=n.title)?o:n.name,tone:t?"primary":"default"},null!=(r=n.title)?r:n.name)})})),UB=(0,Es.ZP)(Co.xu)(Ar||(Ar=rd(["\n border-top: 1px solid ",";\n flex-shrink: 0;\n"])),(e=>{let{theme:t}=e;return t.sanity.color.base.border}));function VB(){const[e,t]=(0,vo.useState)(null),[n,i]=(0,vo.useState)(""),r=(0,vo.useRef)(null),o=nN(),{dispatch:s,state:{terms:{types:a}}}=qM(),[l,c]=(0,vo.useState)(a),d=function(e,t,n,i){return(0,vo.useMemo)((()=>{const[r,o]=Xa()(function(e,t){return eO(e).filter((e=>function(e,t){var n;return!t||(null!=(n=e.title)?n:e.name).toLowerCase().includes(null==t?void 0:t.toLowerCase())}(e,t))).sort(tO)}(e,i),(e=>n.includes(e))),s=r.length>0,a=r.length>0,l=[];return s&&l.push({title:"Selected",type:"header"}),r.forEach((e=>l.push({item:e,selected:t.includes(e),type:"item"}))),s&&a&&l.push({type:"divider"}),o.forEach((e=>l.push({item:e,selected:t.includes(e),type:"item"}))),l}),[e,t,n,i])}(o,a,l,n),u=(0,vo.useCallback)((e=>i(e.currentTarget.value)),[i]),p=(0,vo.useCallback)((()=>i("")),[]),h=(0,vo.useCallback)((()=>{var e,t;c([]),s({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)}),[s]),f=(0,vo.useCallback)((e=>{const t=d[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}}),[d]),m=(0,vo.useCallback)((e=>"divider"===e.type?(0,go.jsx)(Co.xu,{paddingY:1,children:(0,go.jsx)(Co.R,{})}):"header"===e.type?(0,go.jsx)(Co.xu,{margin:1,paddingBottom:2,paddingTop:3,children:(0,go.jsx)(Co.__,{muted:!0,size:0,children:e.title})}):"item"===e.type?(0,go.jsx)(qB,{paddingBottom:1,selected:e.selected,type:e.item}):null),[]),g=(0,vo.useCallback)((e=>"item"!==d[e].type),[d]),x=(0,vo.useCallback)((e=>{const t=d[e];return"item"===t.type&&t.selected}),[d]);return(0,go.jsxs)(Co.kC,{direction:"column",style:{width:"250px"},children:[(0,go.jsx)(_B,{ariaInputLabel:"Filter by document type",onChange:u,onClear:p,ref:t,typeFilter:n}),(0,go.jsxs)(Co.kC,{children:[d.length>0&&(0,go.jsx)(Mu,{activeItemDataAttr:"data-hovered",ariaLabel:"Document types",ariaMultiselectable:!0,autoFocus:"input",getItemDisabled:g,getItemSelected:x,getItemKey:f,inputElement:e,itemHeight:37,items:d,overscan:20,padding:1,paddingBottom:0,ref:r,renderItem:m}),!d.length&&(0,go.jsx)(Co.xu,{padding:3,children:(0,go.jsxs)(Co.xv,{muted:!0,size:1,textOverflow:"ellipsis",children:["No matches for '",n,"'"]})})]}),!n&&a.length>0&&(0,go.jsx)(KB,{onClick:h,selectedTypes:a})]})}function KB(e){let{onClick:t,selectedTypes:n}=e;return(0,go.jsx)(UB,{padding:1,children:(0,go.jsx)(Co.Kq,{children:(0,go.jsx)(Co.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"})})})}const HB=(0,Es.ZP)(Co.zx)((e=>{let{theme:t}=e;const{regular:n}
1=t.sanity.fonts.text.weights;return(0,Es.iv)(Fr||(Fr=rd(["\n [data-ui='Text'] {\n font-weight: ",";\n }\n "])),n)}));function $B(){const[e,t]=(0,vo.useState)(!1),[n,i]=(0,vo.useState)(null),[r,o]=(0,vo.useState)(null),{state:{fullscreen:s,terms:{types:a}}}=qM(),l=(0,vo.useCallback)((()=>t(!1)),[]),c=(0,vo.useCallback)((()=>t(!0)),[]);(0,Co.O8)(l,[n,r]);const d=(0,vo.useMemo)((()=>aO({types:a})),[a]);return(0,go.jsx)(Co.J2,{__unstable_margins:[5,0,0,0],content:(0,go.jsx)(jB,{anchorElement:n,onClose:l,children:(0,go.jsx)(VB,{})}),open:e,placement:"bottom-start",portal:!0,radius:2,ref:o,children:(0,go.jsx)(HB,{fontSize:1,iconRight:Ds.GVG,mode:"ghost",onClick:c,padding:s?3:2,ref:i,selected:e,style:{maxWidth:"100%"},text:d,tone:"default"})})}const WB=(0,Es.ZP)(Co.xu)(Mr||(Mr=rd(["\n flex-shrink: ",";\n"])),(e=>{let{$flexShrink:t=0}=e;return t}));function GB(e){let{filter:t,fontSize:n=1,showContent:i=!0}=e;const{state:{definitions:r,fullscreen:o}}=qM(),s=dB(r.operators,t.operatorType),a=null==s?void 0:s.buttonValueComponent;return(0,go.jsxs)(Co.kC,{align:"center",gap:1,children:[(0,go.jsx)(WB,{$flexShrink:o?1:0,children:(0,go.jsx)(Xp,{tone:"default",size:n,textOverflow:"ellipsis",weight:"semibold",children:(0,go.jsx)(FB,{filter:t,maxLength:o?25:40})})}),i&&(null==s?void 0:s.buttonLabel)&&(0,go.jsx)(WB,{$flexShrink:0,children:(0,go.jsx)(Xp,{tone:"default",size:n,textOverflow:"ellipsis",weight:"regular",children:s.buttonLabel})}),i&&a&&(0,go.jsx)(WB,{$flexShrink:1,children:(0,go.jsx)(Xp,{tone:"default",size:n,textOverflow:"ellipsis",weight:"semibold",children:(0,go.jsx)(a,{value:null==t?void 0:t.value})})})]})}function XB(e){return(0,go.jsx)(Co.xu,{...e,children:(0,go.jsxs)(Co.kC,{align:"flex-start",gap:3,children:[(0,go.jsx)(Xp,{tone:"critical",children:(0,go.jsx)(Ds.uIy,{})}),(0,go.jsxs)(Co.Kq,{space:4,children:[(0,go.jsx)(Xp,{size:1,tone:"critical",weight:"semibold",children:"An error occurred whilst displaying this filter."}),(0,go.jsx)(Xp,{size:1,tone:"critical",children:"This may indicate invalid options defined in your schema."})]})]})})}function YB(e){let{onClick:t,operator:n,selected:i}=e;const r=(0,vo.useCallback)((()=>t(n.type)),[t,n.type]);return(0,go.jsx)(Co.sN,{onClick:r,padding:3,pressed:i,tone:"default",children:(0,go.jsxs)(Co.kC,{align:"center",justify:"space-between",gap:3,children:[(0,go.jsx)(Co.xu,{paddingRight:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"regular",children:n.label})}),(null==n?void 0:n.icon)&&(0,go.jsx)(Co.xv,{muted:!0,size:1,children:(0,vo.createElement)(n.icon)})]})})}function JB(e){let{filter:t,operator:n}=e;var i;const r=(0,vo.useId)(),{dispatch:o,state:s}=qM(),a=null==(i=EM(s.definitions.filters,t.filterName))?void 0:i.operators,l=(0,vo.useCallback)((e=>{o({filterKey:mB(t),operatorType:e,type:"TERMS_FILTERS_SET_OPERATOR"})}),[o,t]);return!n||!a||a.length<=1?null:(0,go.jsx)(Co.gF,{children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{mode:"ghost",padding:3,children:(0,go.jsxs)(Co.kC,{align:"center",gap:2,justify:"space-between",children:[(0,go.jsx)(Co.xv,{size:s.fullscreen?2:1,weight:"regular",children:n.label}),(0,go.jsx)(Co.xu,{marginLeft:1,children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.GVG,{})})})]})}),id:r||"",menu:(0,go.jsx)(Co.v2,{children:a.map(((e,t)=>{if("item"===e.type){const i=dB(s.definitions.operators,e.name);return i?(0,go.jsx)(YB,{onClick:l,operator:i,selected:n.type===e.name},t):null}return"divider"===e.type?(0,go.jsx)(Co.R,{},t):null}))}),placement:"bottom-start",popover:{constrainSize:!0,portal:!1,radius:2}})})}function QB(e){let{filter:t}=e;const[n,i]=(0,vo.useState)(null),{dispatch:r,state:{definitions:o,fullscreen:s}}=qM(),a=EM(o.filters,t.filterName),l=dB(o.operators,t.operatorType),c=fB(o.fields,t),d=mB(t),u=(0,vo.useCallback)((()=>{r({filterKey:mB(t),type:"TERMS_FILTERS_REMOVE"})}),[r,t]),p=(0,vo.useCallback)((e=>{r({filterKey:d,type:"TERMS_FILTERS_SET_VALUE",value:e})}),[r,d]),h=(0,vo.useCallback)((e=>{i(e)}),[]),f=null==l?void 0:l.inputComponent;return n?(0,go.jsx)(XB,{padding:4}):(0,go.jsx)(Co.SV,{onCatch:h,children:(0,go.jsx)(Ls.ZP,{autoFocus:!Kd,returnFocus:!0,children:(0,go.jsxs)(Co.kC,{direction:"column-reverse",children:[f&&(0,go.jsx)(Co.Zb,{borderTop:!0,padding:3,children:(0,go.jsx)(f,{fieldDefinition:c,onChange:p,value:t.value},t.operatorType)}),(0,go.jsx)(Co.Zb,{padding:3,children:(0,go.jsxs)(Co.Kq,{space:3,children:[(0,go.jsxs)(Co.kC,{align:"flex-start",ga
1p:3,justify:"space-between",children:[(0,go.jsx)(Co.xu,{paddingBottom:1,paddingLeft:1,paddingRight:2,paddingTop:s?2:1,children:(0,go.jsx)(OB,{filter:t,small:!s})}),s&&(0,go.jsx)(Co.zx,{fontSize:2,icon:Ds.XHJ,mode:"bleed",onClick:u,padding:2,tone:"critical"})]}),(null==a?void 0:a.description)&&(0,go.jsx)(Co.Zb,{border:!0,padding:3,radius:2,tone:"transparent",children:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:a.description})}),(0,go.jsx)(JB,{filter:t,operator:l})]})})]})})})}const eL=(0,Es.ZP)(Co.kC)(Or||(Or=rd(["\n max-width: 480px;\n min-width: 150px;\n overflow: hidden;\n overflow: clip;\n width: 100%;\n"])));function tL(e){let{filter:t}=e;return(0,go.jsxs)(eL,{direction:"column",children:[(0,go.jsx)(QB,{filter:t}),false]})}const nL=(0,Es.ZP)(Co.zx)(Rr||(Rr=rd(["\n border-radius: ",";\n"])),(e=>{let{theme:t}=e;return"0 ".concat((0,Co.hO)(t.sanity.radius[2])," ").concat((0,Co.hO)(t.sanity.radius[2])," 0")})),iL=(0,Es.ZP)(Co.Zb)(zr||(zr=rd(["\n position: absolute;\n right: 0;\n"]))),rL=Es.ZP.div(Dr||(Dr=rd(["\n align-items: center;\n display: inline-flex;\n max-width: 100%;\n position: relative;\n"]))),oL=(0,Es.ZP)(Co.zx)(Br||(Br=rd(["\n border: none;\n width: 100%;\n"])));function sL(e){let{filter:t,initialOpen:n}=e;const[i,r]=(0,vo.useState)(n),{dispatch:o,state:{definitions:s,fullscreen:a}}=qM(),l=(0,vo.useCallback)((()=>r(!1)),[]),c=(0,vo.useCallback)((()=>r(!0)),[]),d=(0,vo.useCallback)((()=>o({filterKey:mB(t),type:"TERMS_FILTERS_REMOVE"})),[o,t]),u=(0,vo.useCallback)((e=>{["Backspace","Delete"].includes(e.key)&&d()}),[d]),p=vB({fieldDefinitions:s.fields,filter:t,filterDefinitions:s.filters,operatorDefinitions:s.operators});return(0,go.jsx)(Co.J2,{__unstable_margins:[5,0,0,0],content:(0,go.jsx)(jB,{onClose:l,children:(0,go.jsx)(tL,{filter:t})}),constrainSize:!0,open:i,overflow:"auto",placement:"bottom-start",portal:!0,radius:2,children:(0,go.jsxs)(rL,{children:[(0,go.jsx)(Co.Zb,{__unstable_focusRing:!0,display:"flex",radius:2,tone:p?"primary":"transparent",children:(0,go.jsx)(oL,{mode:"bleed",onClick:c,onKeyDown:u,paddingLeft:a?3:2,paddingRight:a?3:5,paddingY:a?3:2,children:(0,go.jsx)(GB,{filter:t,showContent:p})})}),!a&&(0,go.jsx)(iL,{__unstable_focusRing:!0,display:"flex",radius:2,tone:p?"primary":"transparent",children:(0,go.jsx)(nL,{"aria-label":"Delete filter",fontSize:1,icon:Ds.Two,mode:"bleed",onClick:d,onKeyDown:u,padding:2,radius:2})})]})})}function aL(){const{dispatch:e,state:{filters:t,fullscreen:n,lastAddedFilter:i,terms:{types:r}}}=qM(),o=(0,vo.useRef)(!1),s=(0,vo.useCallback)((()=>{e({type:"TERMS_FILTERS_CLEAR"}),e({type:"TERMS_TYPES_CLEAR"})}),[e]),a=t.length>0||r.length>0;(0,vo.useEffect)((()=>{o.current=!0}),[]);const l=i&&mB(i),c=()=>(0,go.jsx)(Co.zx,{fontSize:1,mode:"bleed",onClick:s,padding:n?3:2,text:"Clear filters",tone:"critical"});return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsxs)(Co.kC,{align:"flex-start",gap:3,justify:"space-between",padding:2,children:[(0,go.jsxs)(Co.kC,{flex:1,gap:2,wrap:"wrap",children:[(0,go.jsx)($B,{}),null==t?void 0:t.map((e=>{const t=mB(e);return(0,go.jsx)(sL,{filter:e,initialOpen:o.current&&l===t},t)})),!n&&(0,go.jsx)(NB,{})]}),a&&!n&&(0,go.jsx)(c,{})]}),n&&(0,go.jsxs)(Co.kC,{justify:"space-between",paddingBottom:2,paddingX:2,children:[(0,go.jsx)(NB,{}),a&&(0,go.jsx)(c,{})]}),false]})}function lL(){return(0,go.jsx)(Co.kC,{align:"center",direction:"column",gap:4,paddingX:4,paddingY:5,children:(0,go.jsxs)(Co.gF,{space:3,children:[(0,go.jsx)(Co.xv,{muted:!0,children:"Use"}),(0,go.jsx)(Co.xv,{muted:!0,children:(0,go.jsx)(Ds.d$S,{})}),(0,go.jsx)(Co.xv,{muted:!0,children:"to refine your search"})]})})}function cL(e){let{availableCharacters:t,types:n}=e;const i=(0,vo.useMemo)((()=>aO({availableCharacters:t,types:n})),[t,n]);return(0,go.jsx)(Co.Zb,{border:!0,padding:2,radius:2,children:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:i})})}const dL=(0,Es.ZP)(Co.Zb)(Lr||(Lr=rd(["\n cursor: default;\n"])));function uL(e){let{filter:t}=e;return(0,go.jsx)(dL,{border:!0,padding:2,radius:2,tone:"primary",children:(0,go.jsx)(GB,{filter:t})})}const pL=40,hL=(0,Es.ZP)(Co.zx)(Zr||(Zr=rd(["\n border-radius: ",";\n cursor: default;\n width: 100%;\n"])),(e=>{let{theme:t}=e;return(0,Co.hO)(t.sanity.radius[2])})),fL=(0,Es.ZP)(Co.xu)(Nr||(Nr=rd(["\n flex-shrink: 3;\n"]))),mL=(0,Es.ZP)(Co.xu)(qr||(qr=rd(["\n flex-shrink: 2;
1\n"]))),gL=Es.ZP.div(Ur||(Ur=rd(["\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"])),hL);function xL(e){let{index:t,maxVisibleTypePillChars:n=pL,value:i,...r}=e;var o;const{dispatch:s,recentSearchesStore:a}=qM(),l=n-i.query.length,c=(0,vo.useCallback)((()=>{if(s({type:"TERMS_SET",filters:null==i?void 0:i.filters,terms:i}),a){const e=null==a?void 0:a.addSearch(i,null==i?void 0:i.filters);s({recentSearches:e,type:"RECENT_SEARCHES_SET"})}}),[s,a,i]),d=(0,vo.useCallback)((e=>{if(e.stopPropagation(),a){const e=null==a?void 0:a.removeSearchAtIndex(t);s({recentSearches:e,type:"RECENT_SEARCHES_SET"})}}),[s,t,a]);return(0,go.jsx)(Co.xu,{...r,children:(0,go.jsx)(hL,{mode:"bleed",onClick:c,paddingLeft:3,paddingRight:1,paddingY:1,tabIndex:-1,children:(0,go.jsxs)(Co.kC,{align:"stretch",children:[(0,go.jsxs)(Co.gF,{paddingY:2,children:[(0,go.jsx)(Co.xv,{muted:!0,size:1,children:(0,go.jsx)(Ds.T39,{})}),(0,go.jsx)(Co.xv,{children:"\u200b"})]}),(0,go.jsxs)(Co.kC,{align:"stretch",flex:1,gap:2,justify:"flex-start",marginLeft:3,wrap:"wrap",children:[i.query&&(0,go.jsx)(mL,{paddingY:2,children:(0,go.jsx)(Co.xv,{muted:!0,textOverflow:"ellipsis",children:i.query})}),i.types.length>0&&(0,go.jsx)(fL,{children:(0,go.jsx)(cL,{availableCharacters:l,types:i.types})}),null==(o=null==i?void 0:i.filters)?void 0:o.map(((e,t)=>(0,go.jsx)(uL,{filter:e},t)))]}),(0,go.jsx)(Co.kC,{align:"center",children:(0,go.jsx)(gL,{onClick:d,children:(0,go.jsx)(Co.kC,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.Two,{})})})})})]})})})}const vL=(0,Es.ZP)(Co.Zb)(Vr||(Vr=rd(["\n overflow-x: hidden;\n overflow-y: auto;\n position: relative;\n"])));function yL(e){let{inputElement:t}=e;const{dispatch:n,recentSearchesStore:i,state:{filtersVisible:r,fullscreen:o,recentSearches:s}}=qM(),a=(0,vo.useRef)(null),l=(0,vo.useCallback)((()=>{var e;if(i){const e=i.removeSearch();n({recentSearches:e,type:"RECENT_SEARCHES_SET"})}null==(e=null==a?void 0:a.current)||e.focusInputElement()}),[n,i]),c=(0,Co.d2)(),d=(0,vo.useMemo)((()=>c<2?20:40),[c]),u=(0,vo.useCallback)(((e,t)=>{let{virtualIndex:n}=t;return(0,go.jsx)(xL,{index:n,maxVisibleTypePillChars:d,paddingBottom:1,value:e})}),[d]),p=!!s.length;return(0,go.jsx)(vL,{borderTop:p||!p&&!r&&o,flex:1,children:s.length?(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.xu,{paddingBottom:2,paddingTop:4,paddingX:3,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:"Recent searches"})}),(0,go.jsx)(Co.xu,{children:(0,go.jsx)(Mu,{activeItemDataAttr:"data-hovered",ariaLabel:"Recent searches",inputElement:t,initialIndex:0,itemHeight:36,items:s,paddingX:2,paddingY:1,renderItem:u})}),(0,go.jsx)(Co.xu,{paddingBottom:2,paddingTop:1,paddingX:2,children:(0,go.jsx)(Co.zx,{fontSize:1,justify:"flex-start",mode:"bleed",onClick:l,padding:2,tone:"default",children:(0,go.jsx)(Co.xv,{muted:!0,size:1,children:"Clear recent searches"})})})]}):!r&&o&&(0,go.jsx)(lL,{})})}const bL=(0,Es.F4)(Kr||(Kr=rd(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"]))),jL=(0,Es.ZP)(Ds.L4p)(Hr||(Hr=rd(["\n animation: "," 500ms linear infinite;\n"])),bL),wL=(0,Es.ZP)(Co.xu)($r||($r=rd(["\n position: relative;\n"]))),kL=Es.ZP.div(Wr||(Wr=rd(["\n background: ",";\n border-radius: 100%;\n height: 6px;\n position: absolute;\n right: 2px;\n top: 2px;\n width: 6px;\n"])),(e=>{let{theme:t}=e;var n;return null==(n=t.sanity.color.selectable)?void 0:n.primary.enabled.fg})),CL=(0,vo.forwardRef)((function(e,t){let{ariaInputLabel:n,onClose:i}=e;const r=(0,vo.useRef)(!1),{dispatch:o,state:{filters:s,filtersVisible:a,fullscreen:l,result:{loading:c},terms:{types:d,query:u}}}=qM(),p=(0,vo.useCallback)((()=>o({type:"FILTERS_VISIBLE_SET",visible:!a})),[o,a]),h=(0,vo.useCallback)((e=>o({type:"TERMS_QUERY_SET",query:e.currentTarget.value})),[o]),f=(0,vo.useCallback)((()=>{o({type:"TERMS_QUERY_SET",query:""})}),[o]);(0,vo.useEffect)((()=>{l||o({type:"FILTERS_VISIBLE_SET",visible:!0})}),[o,l]),(0,vo.useEffect)((()=>{r.current=!0}),[]);const m=s.length>0||d.length>0;return(0,go.jsx)(Co.Zb,{flex:"none",children:(0,go.jsxs)(Co.kC,{align:"center",flex:1,gap:l?2:1,padding:l?2:1,children:[l&&(0,go.jsx)(Co.Zb,{children:(0,go.jsx)(Co.zx,{"aria-label":"Close search",icon:Ds.Y4O,mode:"bleed",onClick:i})}),(0,go.jsx)(Co.xu,{flex:1,children:(0,go.jsx)(cR,{"aria-label":n,autoComplete:"off",background:l,border:!1,clearButton:!!u,fontSize:2,icon:c?jL:Ds.W1M,onChange:h,onClear:f,placeholder:"Search",radius:l?2:1,ref:t,smallClearButton:l,spellCheck:!1,value:u})}),l&&(0,go.jsxs)(wL,{children:[(0,go.jsx)(Co.zx,{"aria-expanded":a,"aria-label":"Toggle filters",height:"fill",icon:Ds.d$S,mode:"bleed",onClick:p,padding:3,selected:a,tone:"default"}),m&&(0,go.jsx)(kL,{})]})]})})}));function _L(){return(0,go.jsx)(Co.W2,{width:0,children:(0,go.jsxs)(Co.Kq,{"aria-live":"assertive",space:4,paddingX:4,paddingY:5,children:[(0,go.jsx)(Co.xv,{align:"center",muted:!0,weight:"semibold",children:"No results found"}),(0,go.jsx)(Co.xv,{align:"center",muted:!0,size:1,children:"Try another keyword or adju
1st your filters"})]})})}function SL(){return(0,go.jsxs)(Co.kC,{align:"center","aria-live":"assertive",direction:"column",flex:1,gap:3,marginY:2,padding:4,children:[(0,go.jsx)(Co.xu,{marginBottom:1,children:(0,go.jsx)(Xp,{tone:"critical",children:(0,go.jsx)(Ds.foC,{})})}),(0,go.jsx)(Xp,{size:2,tone:"critical",weight:"semibold",children:"Something went wrong while searching"}),(0,go.jsx)(Xp,{size:1,tone:"critical",children:"Please try again or check your connection"})]})}const TL={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"}},IL=[TL.relevance,{type:"divider"},TL.createdAsc,TL.createdDesc,{type:"divider"},TL.updatedAsc,TL.updatedDesc],PL=(0,Es.ZP)(Co.kC)(Gr||(Gr=rd(["\n box-sizing: border-box;\n"])));function EL(e){return"divider"===e.type}function AL(e){let{ordering:t}=e;const{dispatch:n,state:{ordering:i}}=qM(),r=(0,vo.useCallback)((()=>{n({ordering:t,type:"ORDERING_SET"})}),[n,t]),o=(0,vo.useMemo)((()=>Ss()(i,t)),[i,t]);return(0,go.jsx)(Co.sN,{onClick:r,padding:3,pressed:o,tone:"default",children:(0,go.jsx)(Co.kC,{align:"center",justify:"space-between",paddingRight:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"medium",children:t.title})})})}function FL(){const{state:{ordering:e}}=qM(),t=(0,vo.useId)(),n=IL.find((t=>Ss()(e,t)&&!EL(t)));return n?(0,go.jsx)(Co.Zb,{borderBottom:!0,children:(0,go.jsx)(PL,{align:"center",flex:1,padding:2,children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{mode:"bleed",padding:2,children:(0,go.jsxs)(Co.kC,{align:"center",gap:1,justify:"space-between",children:[(0,go.jsx)(Co.xu,{marginRight:1,children:(0,go.jsx)(Co.xv,{size:1,children:(0,go.jsx)(Ds.fzI,{})})}),(0,go.jsx)(Co.gF,{space:2,children:(0,go.jsx)(Co.xv,{size:1,weight:"medium",children:n.title})})]})}),id:t||"",menu:(0,go.jsx)(Co.v2,{children:IL.map(((e,t)=>EL(e)?(0,go.jsx)(Co.R,{},t):(0,go.jsx)(AL,{ordering:e},t)))}),placement:"bottom-start",popover:{portal:!0,radius:2}})})}):null}const ML=(0,Es.ZP)(Co.Zb)(Xr||(Xr=rd(["\n cursor: help;\n left: 0;\n position: absolute;\n top: 0;\n"])));function OL(e){let{data:t}=e;const{score:n}=t;let i="default";n<=.1?i="critical":n>=.5&&(i="primary");const r=t.stories.filter((e=>e.score>0));return(0,go.jsx)(go.Fragment,{children:(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.Kq,{space:2,children:r.length?(0,go.jsx)(go.Fragment,{children:r.map((e=>(0,go.jsxs)(Co.gF,{space:3,children:[(0,go.jsx)(Co.EK,{size:0,weight:"semibold",children:e.path}),(0,go.jsx)(Co.EK,{size:0,children:e.why})]},e.path)))}):(0,go.jsx)(Co.EK,{size:0,children:"No matches"})})}),placement:"bottom-start",portal:!0,children:(0,go.jsx)(ML,{padding:1,shadow:1,tone:i,children:(0,go.jsxs)(Co.EK,{size:0,children:["score: ",n]})})})})}const RL=(0,Es.ZP)(Co.kC)(Yr||(Yr=rd(["\n opacity: ",";\n overflow-x: hidden;\n overflow-y: auto;\n position: relative;\n transition: 300ms opacity;\n width: 100%;\n"])),(e=>{let{$loading:t}=e;return t?.5:1}));function zL(e){let{inputElement:t}=e;const{dispatch:n,onClose:i,recentSearchesStore:r,setSearchCommandList:o,state:{debug:s,filters:a,fullscreen:l,lastActiveIndex:c,result:d,terms:u}}=qM(),p=!!d.hits.length,h=!d.hits.length&&d.loaded,f=d.error,m=(0,vo.useCallback)((()=>{if(r){const e=r.addSearch(u,a);n({recentSearches:e,type:"RECENT_SEARCHES_SET"})}null==i||i()}),[n,a,i,r,u]),g=(0,vo.useCallback)((e=>(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(GM,{documentId:Td(e.hit._id)||"",documentType:e.hit._type,onClick:m,paddingBottom:2}),s&&(0,go.jsx)(OL,{data:e})]})),[s,m]);return(0,go.jsx)(Co.kC,{children:(0,go.jsx)(Co.Zb,{borderTop:l||!!(f||p||h),flex:1,children:(0,go.jsxs)(Co.kC,{direction:"column",height:"fill",children:[p&&(0,go.jsx)(FL,{}),(0,go.jsx)(RL,{$loading:d.loading,"aria-busy":d.loading,flex:1,children:f?(0,go.jsx)(SL,{}):(0,go.jsxs)(go.Fragment,{children:[p&&(0,go.jsx)(Mu,{activeItemDataAttr:"data-hovered",ariaLabel:"Search results",fixedHeight:!0,initialIndex:c,inputElement:t,itemHeight:59,items:d.hits,overscan:4,padding:2,paddingBottom:0,ref:o,renderItem:g}),h&&(0,go.jsx)(_L,{})]})})]})})})}const DL=(0,Es.ZP)(Co.Zb)(Jr||(Jr=rd(["\n flex-direction: column;\n overflow: hidden;\n overflow: clip;\n pointer-events: all;\n position: relative;\n"]))),BL=(0,Es.ZP)(Co.xu)(Qr||(Qr=rd(["\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 LL(e){let{onClose:t,onOpen:n,open:i}=e;const[r,o]=(0,vo.useState)(null),{scheme:s}=Cz(),{state:{filtersVisible:a,terms:l}}=qM(),c=QM({terms:l});return(0,go.jsx)(lB,{hasValidTerms:c,onClose:t,onOpen:n,open:i,children:(0,go.jsx)(Co.h_,{children:(0,go.jsx)(Ls.ZP,{autoFocus:!Kd,returnFocus:!0,children:(0,go.jsx)(BL,{children:(0,go.jsxs)(DL,{display:"flex",height:"fill",scheme:s,tone:"default",children:[(0,go.jsx)(CL,{ariaInputLabel:c?"Search results":"Recent searches",onClose:t,ref:o}),a&&(0,go.jsx)(Co.Zb,{borderTop:!0,flex:"none",children:(0,go.jsx)(aL,{})}),c?(0,go.jsx)(zL,{inputElement:r}):(0,go.jsx)(yL,{inputElement:r})]})})})})})}const ZL=(0,Es.ZP)(Co.kC)(eo||(eo=rd(["\n position: absolute;\n right: 0;\n top: 0;\n\n & > :first-child {\n margin-right: 1px;\n }\n"]))),NL=(0,Es.ZP)(Co.kC)(to||(to=rd(["\n min-width: 253px;\n max-width: 350px;\n position: relative;\n"]))),qL=(0,Es.ZP)(Co.oi)(no||(no=rd(["\n padding-right: 60px;\n"]))),UL=(0,vo.forwardRef)((function(e,t){let{onOpen:n}=e;const{dispatch:i,state:{terms:r}}=qM(),o=(0,vo.useCallback)((e=>{i({type:"TERMS_QUERY_SET",query:e.currentTarget.value}),n()}),[i,n]),s=(0,vo.useCallback)((e=>{"Enter"===e.key&&n()}),[n]);return(0,go.jsxs)(NL,{align:"center",children:[(0,go.jsx)(qL,{"aria-autocomplete":"list","aria-expanded":"false",autoComplete:"off",icon:Ds.W1M,"data-testid":"studio-search",onChange:o,onClick:n,onKeyDown:s,placeholder:"Search",radius:2,ref:t,role:"combobox",value:r.query}),(0,go.jsxs)(ZL,{align:"center",height:"fill",marginRight:2,children:[(0,go.jsx)(Co.WB,{children:YM}),(0,go.jsx)(Co.WB,{children:"k".toUpperCase()})]})]})})),VL=Es.ZP.div(io||(io=rd(["\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})),KL=(0,Es.ZP)(Co.Zb)(ro||(ro=rd(["\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,Es.iv)(oo||(oo=rd(["\n left: ","px;\n "])),t.x):(0,Es.iv)(so||(so=rd(["\n left: 50%;\n transform: translateX(-50%);\n "])))}),(e=>{let{$position:t}=e;return"min(calc(100vh - ".concat(t.y,"px - ").concat(JM,"px), ").concat(735,"px)")}),(e=>{let{$position:t}=e;return t.y}),2*JM,800);function HL(e){let{disableFocusLock:t,onClose:n,onOpen:i,open:r,position:o}=e;const[s,a]=(0,vo.useState)(null),[l,c]=(0,vo.useState)(null),{isTopLayer:d,zIndex:u}=(0,Co.sJ)(),{scheme:p}
1=Cz(),{onClose:h,state:{filtersVisible:f,terms:m}}=qM(),g=QM({terms:m}),x=(0,vo.useCallback)((()=>{d&&h&&r&&h()}),[d,h,r]);return(0,Co.O8)(x,[s]),(0,go.jsx)(lB,{hasValidTerms:g,onClose:n,onOpen:i,open:r,children:(0,go.jsx)(Co.h_,{children:(0,go.jsxs)(Ls.ZP,{autoFocus:!Kd,disabled:t,returnFocus:!0,children:[(0,go.jsx)(VL,{style:{zIndex:u}}),(0,go.jsxs)(KL,{$position:o,overflow:"hidden",radius:2,ref:a,scheme:p,shadow:2,style:{zIndex:u},children:[(0,go.jsx)(CL,{ariaInputLabel:g?"Search results":"Recent searches",onClose:n,ref:c}),f&&(0,go.jsx)(Co.Zb,{borderTop:!0,flex:"none",children:(0,go.jsx)(aL,{})}),g?(0,go.jsx)(zL,{inputElement:l}):(0,go.jsx)(yL,{inputElement:l})]})]})})})}function $L(){const[e,t]=(0,vo.useState)(null),[n,i]=(0,vo.useState)(!1),r=(0,vo.useCallback)((()=>i(!1)),[]),o=(0,vo.useCallback)((()=>i(!0)),[]),s=function(e){const[t,n]=(0,vo.useState)(null),i=(0,vo.useCallback)((()=>{e&&n(WL(e))}),[e]);return(0,vo.useEffect)((()=>{e&&n(WL(e))}),[e]),(0,vo.useEffect)((()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i))),[i]),t}(e);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(UL,{onOpen:o,ref:t}),s&&(0,go.jsx)(HL,{onClose:r,onOpen:o,open:n,position:s})]})}function WL(e){const t=e.getBoundingClientRect();return{x:window.innerWidth-t.x>800?t.x-JM:null,y:t.y-JM}}const GL=2;function XL(e,t){const n=JL?window.localStorage.getItem(e):void 0;return n?JSON.parse(n):{version:t,recentSearches:[]}}function YL(e){let{lsKey:t,schema:n,fieldDefinitions:i,filterDefinitions:r,operatorDefinitions:o,version:s}=e;const a=function(e){let{lsKey:t,storedSearch:n}=e;if(n.version!==GL){const e={version:GL,recentSearches:[]};return window.localStorage.setItem(t,JSON.stringify(e)),e}return n}({lsKey:t,storedSearch:XL(t,s)});return function(e){let{fieldDefinitions:t,filterDefinitions:n,lsKey:i,operatorDefinitions:r,storedSearch:o,studioSchema:s,version:a}=e;const l=eO(s).map((e=>e.name)),c=o.recentSearches.filter((e=>e.terms.typeNames.every((e=>l.includes(e)))&&e.filters.every((e=>vB({fieldDefinitions:t,filter:e,filterDefinitions:n,operatorDefinitions:r}))))),d={version:GL,recentSearches:c};d.recentSearches.length<o.recentSearches.length&&window.localStorage.setItem(i,JSON.stringify(d));return XL(i,a)}({studioSchema:n,storedSearch:a,lsKey:t,filterDefinitions:r,fieldDefinitions:i,operatorDefinitions:o,version:s}).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)))})))}const JL=(()=>{const e="__tmp__can_use";try{return"undefined"!==typeof localStorage&&(localStorage.setItem(e,"---"),localStorage.removeItem(e),!0)}catch(t){return!1}})();function QL(e,t){var n;const i=eO(e).map((e=>e.name)),{documentTypes:r,objectTypes:o}=((null==(n=e._original)?void 0:n.types)||[]).filter((e=>!rZ(e)||i.includes(e.name))).filter((e=>"slug"!==e.name)).filter((e=>!e.name.startsWith("sanity."))).reduce(((e,t)=>(rZ(t)&&(e.documentTypes[t.name]=t),oZ(t)&&(e.objectTypes[t.name]=t),e)),{documentTypes:{},objectTypes:{}})||{documentTypes:{},objectTypes:{}};return function(e,t,n){function i(r){let{acc:o,defType:s,depth:a=0,documentType:l,prevFieldPath:c,prevTitlePath:d}=r;var u;const p=a<=3,h=s.name.startsWith("_"),f=(null==s?void 0:s.title)?RB(s.title):Js()(s.name),m=c?"".concat(c,".").concat(s.name):s.name,g=d?[...d,f]:[f];if(!p)return;const x=n[s.type],v=t[s.type],y=oZ(s)?s:null,b=v||x||y;b?null==(u=null==b?void 0:b.fields)||u.forEach((e=>i({acc:o,defType:e,depth:a+1,documentType:l,prevFieldPath:m,prevTitlePath:g}))):e.includes(s.type)&&o.push({documentTypes:l&&!h?[l]:[],fieldPath:m,filterName:sZ(s),id:"",name:s.name,titlePath:g,title:f,type:s.type})}return Object.values(t).reduce(((e,t)=>{const n=t.fields.reduce(((e,n)=>(i({acc:e,defType:n,documentType:t.name}),e)),[]);return e.push(...n),e}),[]).reduce(((e,t)=>{const 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(nZ).sort(aZ)}(t.reduce(((e,t)=>("field"===t.type&&e.push(t.fieldType),e)),[]),r,o)}function eZ(e){return e.reduce(((e,t)=>(e[t.id]=t,e)),{})}function tZ(e){return[e.type,e.fieldPath,e.filterName,e.documentTypes.join(",")].join("-")}function nZ(e){return{...e,id:tZ(e)}}function iZ(e){return"array"===e.type}function rZ(e){return"document"===e.type}function oZ(e){return"object"===e.type}function sZ(e){if(function(e){var t;return!!function(e){return"string"===e.type}(e)&&!!(null==(t=e.options)?void 0:t.list)&&e.options.list.length>0}(e))return"stringList";if(iZ(e)){if(e.of.some((e=>"reference"===e.type)))return"arrayReferences";if(e.of.find((e=>"block"===e.type)))return"portableText";if(function(e){var t;return!!iZ(e)&&e.of.every((e=>["boolean","number","string"].includes(e.type)))&&!!(null==(t=e.options)?void 0:t.list)&&e.options.list.length>0}(e))return"arrayList"}return e.type}function aZ(e,t){const n=e.titlePath.slice(0,-1).join("/"),i=t.t
1itlePath.slice(0,-1).join("/");return e.title.localeCompare(t.title)||n.localeCompare(i)||e.fieldPath.localeCompare(t.fieldPath)}function lZ(e){return"undefined"!==typeof e.__recent}const cZ="core:studio:navbar:search:";pc()(cZ);const dZ=function(e){const t="".concat(cZ).concat(e);return pc()&&pc().enabled(t)?pc()(t):pc()(cZ)}("reducer");function uZ(e,t){let n="\ud83d\udd0d";switch(t.type.startsWith("SEARCH_REQUEST")&&(n="\ud83d\udea8"),t.type.startsWith("RECENT_SEARCHES")&&(n="\ud83d\udcbe"),dZ(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:TL.relevance,terms:pZ(e.terms)};case"ORDERING_SET":return{...e,ordering:t.ordering,terms:pZ(e.terms)};case"PAGE_INCREMENT":return{...e,pageIndex:e.pageIndex+1,terms:pZ(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":{const n={...t.filter,value:uB(e.definitions.operators,t.filter.operatorType)},i=[...e.filters,n];return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:i,types:e.terms.types}),filters:i,lastAddedFilter:n,terms:{...e.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:i,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_CLEAR":{const t=[];return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:t,types:e.terms.types}),filters:t,terms:{...e.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:t,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_REMOVE":{const n=e.filters.findIndex((e=>mB(e)===t.filterKey)),i=[...e.filters.slice(0,n),...e.filters.slice(n+1)];return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:i,types:e.terms.types}),filters:i,terms:{...e.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:i,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_SET_OPERATOR":{const n=e.filters.find((e=>mB(e)===t.filterKey)),i=dB(e.definitions.operators,null==n?void 0:n.operatorType),r=dB(e.definitions.operators,t.operatorType),o=null==r?void 0:r.initialValue,s=(null==i?void 0:i.inputComponent)!=(null==r?void 0:r.inputComponent),a=e.filters.map((e=>mB(e)===t.filterKey?{...e,operatorType:t.operatorType,...s?{value:o}:{}}:e));return{...e,filters:a,terms:{...e.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:a,operatorDefinitions:e.definitions.operators})}}}case"TERMS_FILTERS_SET_VALUE":{const n=e.filters.map((e=>mB(e)===t.filterKey?{...e,value:t.value}:e));return{...e,filters:n,terms:{...e.terms,filter:hB({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:pZ({...e.terms,query:t.query})};case"TERMS_SET":{const n=t.filters||[],i=[...e.terms.types||[],...t.terms.types].sort(tO);return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:n,types:i}),filters:n,lastAddedFilter:null,pageIndex:0,result:{...e.result,loaded:!1},terms:{...t.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,filters:n,operatorDefinitions:e.definitions.operators})}}}case"TERMS_TYPE_ADD":{const n=[...e.terms.types||[],t.schemaType].sort(tO),i=gB({fieldDefinitions:e.definitions.fields,filters:[],types:n}),r=e.filters.filter((t=>{const n=fB(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:pZ({...e.terms,filter:hB({fieldDefinitions:e.definitions.fields,filterDefinitions:e.definitions.filters,operatorDefinitions:e.definitions.operators,filters:r}),types:n})}}case"TERMS_TYPE_REMOVE":{const n=(e.terms.types||[]).filter((e=>e!==t.schemaType));return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:e.filters,types:n}),pageIndex:0,result:{...e.result,loaded:!1},terms:pZ({...e.terms,types:n})}}case"TERMS_TYPES_CLEAR":{const t=[];return{...e,documentTypesNarrowed:gB({fieldDefinitions:e.definitions.fields,filters:e.filters,types:t}),pageIndex:0,result:{...e.result,loaded:!1},terms:pZ({...e.terms,types:[]})}}default:return e}}function pZ(e){if(lZ(e)){const{__recent:t,...n}=e;return n}return e}function hZ(e){let{children:t,fullscreen:n}=e;const i=(0,vo.useRef)(null),[r,o]=(0,vo.useState)(null),s=WZ(qh),a=nN(),l=xN(),{search:{operators:c,filters:d}}=SO(),{dataset:u,projectId:p}=s.config(),{fieldDefinitions:h,filterDefinitions:f,operatorDefinitions:m}=(0,vo.useMemo)((()=>({fieldDefinitions:eZ(QL(a,d)),filterDefinitions:PM(d),operatorDefinitions:cB(c)})),[d,c,a]),g=(0,vo.useMemo)((()=>function(e){let{dataset:t,fieldDefinitions:n,filterDefinitions:i,operatorDefinitions:r,projectId:o,schema:s,user:a,version:l=GL}=e;if(!t||!o||!JL||!a)return;const c="".concat("search::recent","__").concat(o,":").concat(t,":").concat(a.id);return{addSearch:(e,t)=>{const o=(t||[]).map((e=>
1({fieldId:e.fieldId,filterName:e.filterName,operatorType:e.operatorType,value:e.value}))).filter((e=>vB({fieldDefinitions:n,filter:e,filterDefinitions:i,operatorDefinitions:r}))),a={created:(new Date).toISOString(),filters:o,terms:{query:e.query.trim(),typeNames:e.types.map((e=>e.name))}},d=JSON.stringify(hl()(a,"created")),u={version:l,recentSearches:[a,...XL(c,l).recentSearches.filter((e=>JSON.stringify(hl()(e,"created"))!==d))].slice(0,5)};return window.localStorage.setItem(c,JSON.stringify(u)),YL({fieldDefinitions:n,filterDefinitions:i,lsKey:c,operatorDefinitions:r,schema:s,version:l})},getRecentSearches:()=>YL({fieldDefinitions:n,filterDefinitions:i,lsKey:c,operatorDefinitions:r,schema:s,version:l}),removeSearch:()=>{const e={...XL(c,l),recentSearches:[]};return window.localStorage.setItem(c,JSON.stringify(e)),YL({fieldDefinitions:n,filterDefinitions:i,lsKey:c,operatorDefinitions:r,schema:s,version:l})},removeSearchAtIndex:e=>{const t=XL(c,l);if(e<0||e>t.recentSearches.length)return YL({fieldDefinitions:n,filterDefinitions:i,lsKey:c,operatorDefinitions:r,schema:s,version:l});const o={...t,recentSearches:[...t.recentSearches.slice(0,e),...t.recentSearches.slice(e+1)]};return window.localStorage.setItem(c,JSON.stringify(o)),YL({fieldDefinitions:n,filterDefinitions:i,lsKey:c,operatorDefinitions:r,schema:s,version:l})}}}({dataset:u,fieldDefinitions:h,filterDefinitions:f,operatorDefinitions:m,projectId:p,schema:a,user:l,version:GL})),[l,u,h,f,m,p,a]),x=(0,vo.useMemo)((()=>null==g?void 0:g.getRecentSearches()),[g]),v=(0,vo.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:TL.relevance,pageIndex:0,recentSearches:i,result:{error:null,hasMore:null,hits:[],loaded:!1,loading:!1},terms:{query:"",types:[]},definitions:r}}({currentUser:l,fullscreen:n,recentSearches:x,definitions:{fields:h,operators:m,filters:f}})),[l,h,f,n,m,x]),[y,b]=(0,vo.useReducer)(uZ,v),{documentTypesNarrowed:j,filters:w,ordering:k,pageIndex:C,result:_,terms:S}=y,T=(0,vo.useRef)(!1),I=(0,vo.useRef)(v.ordering),P=(0,vo.useRef)(v.pageIndex),E=(0,vo.useRef)(v.terms),{handleSearch:A,searchState:F}=oO({initialState:{..._,terms:S},onComplete:e=>b({hits:e,type:"SEARCH_REQUEST_COMPLETE"}),onError:e=>b({error:e,type:"SEARCH_REQUEST_ERROR"}),onStart:()=>b({type:"SEARCH_REQUEST_START"}),schema:a}),M=QM({terms:S}),O=j.map((e=>a.get(e))),R=w.filter((e=>vB({fieldDefinitions:h,filter:e,filterDefinitions:f,operatorDefinitions:m}))),z=(0,vo.useCallback)((e=>{i.current=e}),[]);return(0,vo.useEffect)((()=>{const e=!Ss()(k,I.current),t=C!==P.current,n=!Ss()(S,E.current);if(e||t||n){const e=(null==k?void 0:k.customMeasurementLabel)||"".concat(k.sort.field," ").concat(k.sort.direction);A({options:{comments:[...lZ(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,...O?{types:O}:{}}}),P.current=C}I.current=k,E.current=S}),[R.length,w,O,A,M,k,C,F.terms,S]),(0,vo.useEffect)((()=>{!M&&(null==T?void 0:T.current)&&_.hits.length>0&&b({type:"SEARCH_CLEAR"}),T.current=!0}),[b,M,_.hits,S.query,S.types]),(0,go.jsx)(NM.Provider,{value:{dispatch:b,onClose:null==i?void 0:i.current,recentSearchesStore:g,searchCommandList:r,setSearchCommandList:o,setOnClose:z,state:{...y,fullscreen:n}},children:t})}const fZ="3.14.1";function mZ(){const e=WZ({apiVersion:"1"}),t=(0,vo.useMemo)((()=>function(e){return e.withConfig({apiVersion:"1"}).observable.request({url:"/help",query:{m:["sanity@".concat(fZ)]},tag:"module.version-check",json:!0}).pipe((0,Ho.U)((e=>({...e}))))}(e)),[e]);return $d(t)}function gZ(e){let{error:t,isLoading:n,value:i}=e;var r;const o=null==(r=null==i?void 0:i.resources)?void 0:r.sectionArray,s=null==i?void 0:i.latestVersion;return n?(0,go.jsx)(Co.kC,{align:"center",justify:"center",padding:3,children:(0,go.jsx)(Co.$j,{})}):(0,go.jsxs)(go.Fragment,{children:[(void 0===i||t)&&(0,go.jsx)("div",{children:xZ}),!t&&(null==o?void 0:o.map((e=>e?(0,go.jsx)(vZ,{subSection:e},e._key):null))),(0,go.jsxs)(Co.xu,{padding:3,children:[(0,go.jsxs)(Co.xv,{size:1,muted:!0,weight:"medium",textOverflow:"ellipsis",children:["Sanity Studio version ",fZ]}),!t&&s&&(0,go.jsx)(Co.xu,{paddingTop:2,children:(0,go.jsxs)(Co.xv,{size:1,muted:!0,textOverflow:"ellipsis",children:["Latest version is ",s]})})]})]})}const xZ=(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(Co.sN,{as:"a",text:"Join our community",size:0,href:"https://www.sanity.io/exchange/community",target:"_blank",muted:!1}),(0,go.jsx)(Co.sN,{as:"a",text:"Help and support",size:0,href:"https://www.sanity.io/contact/support",target:"_blank",muted:!1}),(0,go.jsx)(Co.sN,{as:"a",text:"Contact sales",size:0,href:"https://www.sanity.io/contact/sales?ref=studio",target:"_blank",muted:!1}),(0,go.jsx)(Co.R,{})]});function vZ(e){let{subSection:t}=e;var n;return(0,go.jsxs)(go.Fragment,{children:[t.sectionTitle&&(0,go.jsx)(Co.Zb,{padding:2,paddingTop:3,marginLeft:1,children:(0,go.jsx)(Co.__,{muted:!0,size:1,children:t.sectionTitle})}),null==(n=null==t?void 0:t.items)?void 0:n.map((e=>{if(!e||!e.title)return null;switch(e._type){case"externalLink":return e.url?(0,go.jsx)(Co.sN,{as:"a",tone:"default",text:e.title,size:0,href:e.url,target:"_blank"},e._key):null;case"internalAction":return e.type?"show-welcome-modal"===e.type&&(0,go.jsx)(Co.sN,{text:e.title,size:0},e._key):null;default:return null}})),(0,go.jsx)(Co.R,{})]})}
1const yZ=(0,Es.ZP)(Co.v2)(ao||(ao=rd(["\n max-width: 300px;\n min-width: 200px;\n"])));function bZ(){const{scheme:e}=Cz(),{value:t,error:n,isLoading:i}=mZ();return(0,go.jsx)(Co.kC,{children:(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:"Help and resources "})}),scheme:e,placement:"bottom",portal:!0,children:(0,go.jsx)("div",{children:(0,go.jsx)(Co.j2,{button:(0,go.jsx)(Co.zx,{"aria-label":"Help and resources",icon:Ds.BHU,mode:"bleed",fontSize:2}),id:"menu-button-resources",menu:(0,go.jsx)(yZ,{children:(0,go.jsx)(gZ,{error:n,isLoading:i,value:t})}),popover:{constrainSize:!0,placement:"bottom",portal:!0,scheme:e}})})})})}const jZ=(0,Es.ZP)(Co.mh)(lo||(lo=rd(["\n min-height: auto;\n position: relative;\n\n &[data-search-open='true'] {\n top: 0;\n position: sticky;\n }\n"]))),wZ=(0,Es.ZP)(Co.Zb)(co||(co=rd(["\n line-height: 0;\n"]))),kZ=(0,Es.ZP)(Co.kC)(uo||(uo=rd(["\n width: max-content;\n"])));function CZ(){const{name:e,tools:t,...n}=kO(),i=(0,Co.Ur)().theme,r=Ez(),o=(0,Bs.z)(),{scheme:s}=Cz(),{href:a,onClick:l}=(0,Bs.rJ)({state:{}}),c=(0,Co.d2)(),d="string"===typeof o.tool?o.tool:void 0,u=function(){const{__internal:{staticInitialValueTemplateItems:e}}=SO(),[t,n]=Xq({templateItems:e});return{canCreateDocument:(null==t?void 0:t.some((t=>e.some((e=>e.id===t.id)))))||!1,loading:n,options:(0,vo.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=>t.id===e.id)))?void 0:n.granted)||!1}}))),[t,e])}}(),{onSearchFullscreenOpenChange:p,searchFullscreenOpen:h,searchFullscreenPortalEl:f}=(0,vo.useContext)(yD),m=Gh({defaultComponent:uz,pick:FZ}),g=MZ(),[x,v]=(0,vo.useState)(!1),y=(0,vo.useRef)(o),b=(0,vo.useRef)(e);(0,vo.useEffect)((()=>{y.current.tool===o.tool&&e===b.current||v(!1),y.current=o,b.current=e}),[e,o]);const[j,w]=(0,vo.useState)(null),[k,C]=(0,vo.useState)(null),_=(0,vo.useMemo)((()=>({brandingCenter:c<=1,resources:c>1,collapsedPresenceMenu:c<=1,loginStatus:c>1,searchFullscreen:c<=1,configIssues:c>1&&gy,workspaces:c>=3&&r.length>1,tools:c>=3})),[c,r.length]),S="string"===typeof e&&"root"!==e?Js()(e):null,T=n.title||S||"Studio";(0,vo.useEffect)((()=>{p(h)}),[h,p]),(0,vo.useEffect)((()=>{p&&!_.searchFullscreen&&p(!1)}),[p,_.searchFullscreen]);const I=(0,vo.useCallback)((()=>{p(!0)}),[p]),P=(0,vo.useCallback)((()=>{p(!1),null==k||k.focus()}),[p,k]),E=(0,vo.useCallback)((()=>{v(!1),null==j||j.focus()}),[j]),A=(0,vo.useCallback)((()=>{v(!0)}),[]);return(0,go.jsxs)(jZ,{zOffset:100,"data-search-open":h,children:[(0,go.jsx)(wZ,{"data-testid":"navbar","data-ui":"Navbar",padding:2,scheme:"dark",shadow:i.__legacy||"dark"===s?1:void 0,sizing:"border",children:(0,go.jsxs)(Co.kC,{align:"center",justify:"space-between",children:[(0,go.jsxs)(kZ,{align:"center",flex:_.brandingCenter?void 0:1,children:[!_.tools&&(0,go.jsx)(Co.xu,{marginRight:1,children:(0,go.jsx)(Co.zx,{mode:"bleed",icon:Ds.Oqj,onClick:A,ref:w})}),!_.brandingCenter&&(0,go.jsx)(Co.xu,{marginRight:1,children:(0,go.jsx)(oB,{href:a,onClick:l,title:T,children:(0,go.jsx)(m,{title:T})})}),_.workspaces&&(0,go.jsx)(Co.xu,{marginRight:2,children:(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:"Select workspace"})}),placement:"bottom",portal:!0,scheme:s,children:(0,go.jsx)(Co.xu,{children:(0,go.jsx)(uD,{})})})}),(0,go.jsx)(Co.xu,{marginRight:_.brandingCenter?void 0:2,children:(0,go.jsx)(UD,{...u,modal:_.brandingCenter?"dialog":"popover"})}),(0,go.jsx)(Co.li,{children:(0,go.jsx)(hZ,{fullscreen:_.searchFullscreen,children:(0,go.jsxs)(Co.NM,{element:document.body,children:[(0,go.jsx)(Co.Xp,{element:f,children:_.searchFullscreen&&(0,go.jsx)(LL,{onClose:P,onOpen:I,open:h})}),!_.searchFullscreen&&(0,go.jsx)($L,{})]})})}),_.tools&&(0,go.jsx)(Co.Zb,{flex:1,marginX:2,overflow:"visible",paddingRight:1,children:(0,go.jsx)(g,{activeToolName:d,closeSidebar:E,context:"topbar",isSidebarOpen:!1,tools:t})})]}),_.brandingCenter&&(0,go.jsx)(Co.xu,{marginX:1,children:(0,go.jsx)(oB,{href:a,onClick:l,title:T,children:(0,go.jsx)(m,{title:T})})}),(0,go.jsxs)(Co.kC,{gap:2,children:[(_.configIssues||_.resources)&&(0,go.jsx)(Co.Zb,{borderRight:!0,children:(0,go.jsxs)(Co.kC,{gap:1,paddingX:2,children:[_.configIssues&&(0,go.jsx)(rB,{}),_.resources&&(0,go.jsx)(bZ,{})]})}),(0,go.jsxs)(Co.kC,{align:"center",gap:1,children:[(0,go.jsx)(GD,{collapse:_.collapsedPresenceMenu}),_.tools&&(0,go.jsx)(ED,{}),_.searchFullscreen&&(0,go.jsx)(Co.zx,{"aria-label":"Open search",icon:Ds.W1M,mode:"bleed",onClick:I,ref:C})]})]})]})}),!_.tools&&(0,go.jsx)(iB,{activeToolName:d,isOpen:x,onClose:E,tools:t})]})}const _Z=(0,vo.forwardRef)((function(e,t){const{name:n,...i}=e,r=(0,Bs.z)((0,vo.useCallback)((e=>({...e,tool:n,[n]:void 0})),[n]));return(0,go.jsx)(Bs.Px,{state:r,...i,ref:t})}));function SZ(e){const{activeToolName:t,tools:n}=e,{scheme:i}=Cz(),[r,o]=(0,vo.useState)(null);Kp({rootElement:r,navigation:["arrows"]});const s=(0,vo.useMemo)((()=>({popover:{constrainSize:!0,portal:!0,scheme:i}}
1)),[i]),a=(0,vo.useMemo)((()=>n.map(((e,n)=>{const r=(null==e?void 0:e.title)||Js()(e.name)||void 0,o=(0,vo.forwardRef)((function(t,n){return(0,go.jsx)(_Z,{...t,ref:n,name:e.name})}));return(0,go.jsx)(SP,{as:o,"data-as":"a",collapsedProps:{tooltipText:e.title},icon:e.icon||Ds.Tzq,mode:"bleed",selected:t===e.name,text:r,tooltipProps:{scheme:i}},"".concat(e.name,"-").concat(n))}))),[t,i,n]);return(0,go.jsx)(_P,{"data-testid":"tool-collapse-menu",gap:1,menuButtonProps:s,ref:o,children:a})}function TZ(e){const{activeToolName:t,isVisible:n,tools:i}=e;return(0,vo.useMemo)((()=>(0,go.jsx)(Co.Kq,{as:"ul",space:1,children:i.map((e=>{const i=(null==e?void 0:e.title)||Js()(e.name)||void 0,r=(0,vo.forwardRef)((function(t,n){return(0,go.jsx)(_Z,{...t,ref:n,name:e.name})}));return(0,go.jsx)(Co.Kq,{as:"li",children:(0,go.jsx)(Co.zx,{as:r,icon:e.icon||Ds.BWR,justify:"flex-start",mode:"bleed",selected:t===e.name,tabIndex:n?0:-1,text:i})},e.name)}))})),[t,n,i])}function IZ(e){const{context:t,isSidebarOpen:n,...i}=e;return"sidebar"===t?(0,go.jsx)(TZ,{isVisible:n,...i}):(0,go.jsx)(SZ,{...i})}function PZ(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.toolMenu}function EZ(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.navbar}function AZ(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.layout}function FZ(e){var t,n;return null==(n=null==(t=e.studio)?void 0:t.components)?void 0:n.logo}function MZ(){return Gh({defaultComponent:IZ,pick:PZ})}const OZ=Fd.__sanityErrorChannel;function RZ(){const{push:e}=(0,Co.pm)();return(0,vo.useEffect)((()=>{if(OZ)return OZ.subscribe((t=>{t.error&&(function(e){if(e instanceof tz)return!0;if(e instanceof ch)return!0;if(e instanceof ez)return!0;return!1}(t.error)||(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 zZ(e){let{children:t,AuthenticateComponent:n=pD,LoadingComponent:i=Bz,NotAuthenticatedComponent:r=fD}=e;const[o,s]=(0,vo.useState)(null);if(o)throw o;const[a,l]=(0,vo.useState)("loading"),{activeWorkspace:c}=eD();return(0,vo.useEffect)((()=>{var e,t;null==(t=(e=c.auth).handleCallbackUrl)||t.call(e).catch(s)}),[c.auth]),(0,vo.useEffect)((()=>{const e=c.auth.state.subscribe({next:e=>{let{authenticated:t,currentUser:n}=e;var i;0!==(null==(i=null==n?void 0:n.roles)?void 0:i.length)?l(t?"logged-in":"logged-out"):l("unauthorized")},error:s});return()=>{e.unsubscribe()}}),[c]),"loading"===a?(0,go.jsx)(i,{}):"unauthorized"===a?(0,go.jsx)(r,{}):"logged-out"===a?(0,go.jsx)(n,{}):(0,go.jsx)(go.Fragment,{children:t})}function DZ(e){let{children:t}=e;const n=eD().activeWorkspace.theme;if(n.__legacy){const e=n.__dark?"dark":"light";return(0,go.jsx)(hz.Provider,{value:!1,children:(0,go.jsx)(pz.Provider,{value:e,children:(0,go.jsx)(Co.f6,{scheme:e,theme:n,tone:"transparent",children:(0,go.jsx)(Co.li,{children:t})})})})}return(0,go.jsx)(Co.f6,{theme:n,tone:"transparent",children:(0,go.jsx)(Co.li,{children:t})})}const BZ={toast:[100,11e3]};function LZ(e){const t={}.toolSwitcher||{},n=t.order||[],i=t.hidden||[];if(!n.length&&!i.length)return e;const r=e.reduce(((e,t)=>{const 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]){const n=e[t.name].tool.title;return console.warn('Tools with duplicate name "'.concat(t.name,'" found ("').concat(i,'" and "').concat(n,'")')),e}const r=n.indexOf(t.name);return e[t.name]={tool:t,index:-1===r?1/0:r},e}),{}),o=e.filter((e=>-1===i.indexOf(e.name)));return o.sort(((e,t)=>{const n=r[e.name],i=r[t.name],o=n?n.index:1/0,s=i?i.index:1/0;return o===s?0:o-s})),o}function ZZ(e,t){const n=function(e,t){const n=LZ(e)[0];return t&&!t.tool&&n?Object.assign({},t,{tool:n.name}):t}(e,function(e,t){return t&&LZ(e).find((e=>e.name===t.space))?{...t,tool:t.space,space:void 0}:t}(e,t));return n}function NZ(e){let{children:t,LoadingComponent:n,workspace:i}=e;const{basePath:r,tools:o}=i,s=function(){const e=(0,vo.useContext)(Xz);
1if(!e)throw new Error("Could not find `RouterHistoryProvider` context");return e}(),a=(0,vo.useMemo)((()=>function(e){const{basePath:t="/",tools:n}=e,i=Bs.BC.create("/:tool",(e=>{const t=n.find((t=>t.name===e.tool));return t?Bs.BC.scope(t.name,"/",t.router):Bs.BC.create("/")}));return Bs.BC.create(t,[Bs.BC.intents("/intent"),i])}({basePath:r,tools:o})),[r,o]),[l,c]=function(e,t,n){var i;const r=(0,vo.useMemo)((()=>{const n=t.getBasePath(),i=new RegExp("^".concat(Nl()(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)?function(e,t){return{type:"state",state:e.decode(t)||{},isNotFound:e.isNotFound(t)}}(t,e):null}}),[e,t]),o=(0,Ll.useSyncExternalStoreWithSelector)(r.subscribe,r.getSnapshot,r.getServerSnapshot,r.selector,Ss()),s=(0,vo.useRef)(o);(0,vo.useEffect)((()=>{var i;if("state"===(null==o?void 0:o.type)&&!(null==(i=o.state)?void 0:i.intent)){const i=ZZ(n,o.state);i&&i!==o.state&&e.replace(t.encode(i))}}),[null==o?void 0:o.state,null==o?void 0:o.type,e,t,n]),(0,vo.useEffect)((()=>{const i=qZ(o,t,n,s);i?e.replace(i):s.current=o}),[o,e,t,n]);const a=(0,vo.useMemo)((()=>i=>{let{path:o,replace:a}=i;const l=qZ(r.selector(o),t,n,s),c="string"===typeof l?l:o;a?e.replace(c):e.push(c)}),[e,t,r,n]);return[null!=(i=null==o?void 0:o.state)?i:null,a]}(s,a,o);return l?(0,go.jsx)(Bs.pG,{onNavigate:c,router:a,state:l,children:t}):(0,go.jsx)(n,{})}function qZ(e,t,n,i){var r,o;if("state"===(null==e?void 0:e.type)&&(null==(r=e.state)?void 0:r.intent)){const r=function(e,t,n){const{intent:i,params:r,payload:o}=n;if("string"!==typeof i)throw new Error("intent must be a string");if(!Od(r))throw new Error("intent params must be a string");const s=LZ(e),a=(null==t?void 0:t.tool)?s.find((e=>e.name===t.tool)):null,l=(a?[a,...s]:s).find((e=>e&&"function"===typeof e.canHandleIntent&&e.canHandleIntent(i,r,t&&t[e.name])));if(null==l?void 0:l.getIntentState){const e=l.getIntentState(i,r,t&&t[l.name],o);return{type:"state",isNotFound:!1,state:{...t,tool:l.name,[l.name]:e}}}return{type:"intent",isNotFound:!0,intent:{name:i,params:r}}}(n,"state"===(null==(o=i.current)?void 0:o.type)?i.current.state:{},e.state);if("state"===(null==r?void 0:r.type))return t.encode(r.state)}return null}function UZ(e){let{children:t,LoadingComponent:n}=e;const[i,r]=(0,vo.useState)(null);if(i)throw i;const{activeWorkspace:o}=eD(),[s,a]=(0,vo.useState)(null);return(0,vo.useEffect)((()=>{const e=(0,Do.a)(o.__internal.sources.map((e=>{let{source:t}=e;return t.pipe((0,Wo.K)((e=>{if(e instanceof ez)return(0,So.of)(e);throw e})))}))).pipe((0,Ho.U)((e=>{const t=e.filter((e=>e instanceof ez));if(t.length)throw new ez({name:o.name,causes:t,type:"workspace"});return e})),(0,Ho.U)((e=>{let[t,...n]=e;return{...o,...t,unstable_sources:[t,...n],type:"workspace"}}))).subscribe({next:a,error:r});return()=>e.unsubscribe()}),[o]),s?(0,go.jsx)(wO,{workspace:s,children:(0,go.jsx)(_O,{source:s.unstable_sources[0],children:(0,go.jsx)(NZ,{LoadingComponent:n,workspace:s,children:t})})}):(0,go.jsx)(n,{})}function VZ(e){let{ConfigErrorsComponent:t,...n}=e;const[{error:i},r]=(0,vo.useState)({error:null});if(i)throw i;return(0,go.jsx)(Co.SV,{onCatch:r,children:(0,go.jsx)(UZ,{...n})})}function KZ(e){let{children:t,config:n,basePath:i,onSchemeChange:r,scheme:o,unstable_history:s,unstable_noAuthBoundary:a}=e;const l=(0,go.jsx)(VZ,{LoadingComponent:Bz,ConfigErrorsComponent:hD,children:(0,go.jsx)(oh,{children:t})});return(0,go.jsx)(xz,{onSchemeChange:r,scheme:o,children:(0,go.jsxs)(Co.VW,{paddingY:7,zOffset:BZ.toast,children:[(0,go.jsx)(RZ,{}),(0,go.jsx)(xD,{children:(0,go.jsx)(Tz,{config:n,basePath:i,children:(0,go.jsx)(Qz,{unstable_history:s,NotFoundComponent:Hz,LoadingComponent:Bz,children:(0,go.jsx)(DZ,{children:(0,go.jsx)(_g,{children:a?l:(0,go.jsx)(zZ,{LoadingComponent:Bz,AuthenticateComponent:pD,NotAuthenticatedComponent:fD,children:l})})})})})})]})})}function HZ(){const e=Gh({defaultComponent:bD,pick:AZ});return(0,go.jsx)(e,{})}function $Z(e){const{basePath:t,config:n,onSchemeChange:i,scheme:r,unstable_globalStyles:o,unstable_history:s,unstable_noAuthBoundary:a}=e;return(0,go.jsxs)(KZ,{basePath:t,config:n,onSchemeChange:i,scheme:r,unstable_history:s,unstable_noAuthBoundary:a,children:[o&&(0,go.jsx)(Mh,{}),(0,go.jsx)(HZ,{})]})}function WZ(e){const t=SO();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,Es.ZP)(Co.kC)(po||(po=rd([""]))),(0,Es.ZP)(Co.xu).attrs({padding:4})(ho||(ho=rd([""]))),Tl().registerLanguage(Pl()),Tl().registerLanguage(Al()),Tl().registerLanguage(Ml()),Tl().registerLanguage(Rl()),Tl().registerLanguage(Dl());const GZ="connecting";function XZ(e,t){const n=gV();return(0,_o.m2)((()=>n.pair.documentEvents(e,t).pipe((0,Ho.U)((e=>e.type)),(0,Ho.U)((e=>"reconnect"!==e)),(0,Go.w)((e=>e?(0,So.of)("connected"):(0,Mo.H)(200).pipe((0,us.h)("reconnecting")))),(0,Qo.O)(GZ),(0,$o.x)())),[n.pair,e,t],GZ)}function YZ(){return SO().dataset}function JZ(e,t){const n=gV();return(0,_o.m2)((()=>n.pair.editOperations(e,t)),[t,n.pair,e])}function QZ(e,t){const n=gV();return(0,_o.m2)((()=>n.pair.operationEvents(e,t)),[n.pair,e,t])}function eN(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";const i=gV();return(0,_o.m2)((()=>{const r=i.pair.editState(e,t).pipe((0,as.B)());return"low"===n?(0,Eo.T)(r.pipe((0,ns.q)(1)),r.pipe((0,ps.T)(1),(0,ds.D)((()=>(0,Mo.H)(1e3))))):i.pair.editState(e,t)}),[i.pair,e,t,n])}function tN(){return SO().projectId}function nN(){return SO().schema}const iN={isSyncing:!0},rN={isSyncing:!1};function oN(e,t){const n=gV();return(0,_o.m2)((()=>n.pair.consistencyStatus(e,t).pipe((0,Ho.U)((e=>e?rN:iN)))),[n.pair,t,e],rN)}function sN(){return SO().templates}const aN=5e3,lN=2e4,cN=6e4,dN=36e5;function uN(e){let{minimal:t,agoSuffix:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=pN(e,{minimal:t,agoSuffix:n}),[,r]=(0,vo.useReducer)((e=>e+1),0);return(0,vo.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}function pN(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e instanceof Date?e:new Date(e);if(!n.getTime())return{timestamp:"",refreshInterval:null};const i=Date.now(),r=(0,Fa.Z)(i,n),o=(0,Ma.Z)(i,n);if(r||o)return t.minimal&&0===o?{timestamp:(0,ja.Z)(n,"MMM d"),refreshInterval:null}:t.minimal?{timestamp:(0,ja.Z)(n,"MMM d, yyyy"),refreshInterval:null}:{timestamp:(0,ja.Z)(n,"MMM d, yyyy, hh:mm a"),refreshInterval:null};const s=(0,Oa.Z)(i,n),a=(0,La.Z)("week",s);if(s)return t.minimal?{timestamp:t.agoSuffix?"".concat(s,"w ago"):"".concat(s,"w"),refreshInterval:dN}:{timestamp:t.agoSuffix?"".concat(s," ").concat(a," ago"):"".concat(s," ").concat(a),refreshInterval:dN};const l=(0,Ra.Z)(i,n),c=(0,La.Z)("days",l);if(l){if(t.minimal){const e=t.agoSuffix?"".concat(l,"d ago"):"".concat(l,"d");return{timestamp:1===l?"yesterday":e,refreshInterval:dN}}const e=t.agoSuffix?"".concat(l," ").concat(c," ago"):"".concat(l," ").concat(c);return{timestamp:1===l?"yesterday":e,refreshInterval:dN}}const d=(0,za.Z)(i,n),u=(0,La.Z)("hour",d);if(d)return t.minimal?{timestamp:t.agoSuffix?"".concat(d,"h ago"):"".concat(d,"h"),refreshInterval:cN}:{timestamp:t.agoSuffix?"".concat(d," ").concat(u," ago"):"".concat(d," ").concat(u),refreshInterval:cN};const p=(0,Da.Z)(i,n),h=(0,La.Z)("minute",p);if(p)return t.minimal?{timestamp:t.agoSuffix?"".concat(p,"m ago"):"".concat(p,"m"),refreshInterval:lN}:{timestamp:t.agoSuffix?"".concat(p," ").concat(h," ago"):"".concat(p," ").concat(h),refreshInterval:lN};const f=(0,Ba.Z)(i,n),m=(0,La.Z)("second",f);return f>10?t.minimal?{timestamp:t.agoSuffix?"".concat(f,"s ago"):"".concat(f,"s"),refreshInterval:aN}:{timestamp:t.agoSuffix?"".concat(f," ").concat(m," ago"):"".concat(f," ").concat(m),refreshInterval:aN}:{timestamp:"just now",refreshInterval:aN}}const hN={validation:[],isValidating:!1};function fN(e,t){const n=gV();return(0,_o.m2)((()=>n.pair.validation(e,t)),[n.pair,e,t],hN)}const mN=jd((e=>{let[t,n]=e;return(0,Bo.D)(t.getUser(n).catch((e=>(console.error(e),null))))}));function gN(e){const t=pV();return mN((0,vo.useMemo)((()=>[t,e]),[e,t]))}function xN(){const{currentUser:e}=SO();return e}const vN=e=>{const t=e.LOCAL,n=e.document.HEAD;return t?{...t,_type:(n||t)._type,_rev:(n||t)._rev,_updatedAt:(new Date).toISOString()}:t},yN=e=>({type:"snapshot",document:e}),bN=e=>e.document,jN=e=>{const t=new Po.x,n=new No.X(!0),i=new Po.x,r=new Po.x,o=new Po.x,s=new Po.x,a=e.pipe((0,Xo.R)(((e,t)=>"snapshot"===t.type?(e&&e.commit(),(e=>{const t=new rc.W6(e);return t.onMutation=e=>{let{mutation:n,remote:r}=e;i.next({type:"mutation",document:vN(t),mutations:n.mutations,origin:r?"remote":"local"})},t.onRemoteMutation=e=>{o.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=>s.next(e),t})(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,Yo.h)((e=>null!==e)),(0,$o.x)(),(0,hs._)(1),(0,fs.x)()),l=e.pipe((0,Yo.h)((e=>"mutation"===e.type)),(0,ms.M)(a),(0,Ho.U)((e=>{let[t,n]=e;return n.arrive(new rc.mm(t)),vN(n)}))),c=t.pipe((0,ms.M)(a),(0,Ko.b)((e=>{let[t,n]=e;"mutation"===t.type&&n.add(new rc.mm({mutations:t.mutations})),"commit"===t.type&&n.commit()})),(0,es.j)(Ro.E),(0,as.B)()),d=e=>{return n={type:"mutation",mutations:e},t.next(n);var n},u=(0,Eo.T)(a.pipe((0,Ho.U)((e=>e.LOCAL))),i.pipe((0,Ho.U)(bN)),r.pipe((0,Ho.U)(bN)),l).pipe((0,Ho.U)(yN),(0,hs._)(1),(0,fs.x)()),p=(0,Eo.T)(a.pipe((0,Ho.U)((e=>e.document.HEAD)),(0,Ho.U)(yN)),o).pipe((0,hs._)(1),(0,fs.x)());return{updates$:(0,Eo.T)(u,c,i,r),consistency$:n.pipe((0,$o.x)(),(0,hs._)(1),(0,fs.x)()),remoteSnapshot$:p,commitRequest$:s,addMutation:e=>d([e]),addMutations:d,commit:()=>{a.pipe((0,ns.q)(1),(0,Ko.b)((e=>e.commit()))).subscribe()}}},wN=(e,t)=>{const n=jN(t),i=(e=>t=>{const{_id:n,_rev:i,_updatedAt:r,...o}=t;return{_id:e,...o}})(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()}},kN={type:"pending",phase:"begin"},CN={type:"pending",phase:"end"};function _N(e){return"mutation"===e.type}function SN(e){return e.transactionTotalEvents>1}function TN(e){const t=Wl()(e.filter((e=>"mutation"===e.type)),(e=>e.transactionId));return Object.values(t).every((e=>e.length===e[0].transactionTotalEvents))}function IN(e,t){return{type:"snapshot",documentId:e,document:t}}const PN=e=>t=>"reconnect"!==t.type&&"pending"!==t.type&&t.documentId===e;function EN(e){return t=>({...t,version:e})}function AN(e,t){const{publishedId:n,draftId:i}=t,r=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{publishedId:i,draftId:r}=t;return(0,Ao.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,ls.b)((e=>"welcome"===e.type?o().pipe((0,ls.b)((e=>[IN(r,e.draft),IN(i,e.published)]))):(0,So.of)(e))),(0,Xo.R)(((e,t)=>{if(!_N(t))return{next:[t],buffer:[]};const n=e.buffer.length>0,i=SN(t);if(!i&&!n)return{next:[t],buffer:[]};if(!i)return{next:[],buffer:e.buffer.concat(t)};const r=e.buffer.concat(t);return TN(r)?{next:r.concat(CN),buffer:[]}:{next:1===r.length?[kN]:[],buffer:r}}),{next:[],buffer:[]}),(0,is.z)((e=>e.next)));function o(){return e.observable.getDocuments([r,i],{tag:"document.snapshots"}).pipe((0,Ho.U)((e=>{let[t,n]=e;return{draft:t,published:n}})))}}(e,t).pipe((0,as.B)()),o=r.pipe((0,Yo.h)((e=>"reconnect"===e.type))),s=wN(i,r.pipe((0,Yo.h)(PN(i)))),a=wN(n,r.pipe((0,Yo.h)(PN(n)))),l=r.pipe((0,Yo.h)((e=>"pending"===e.type))),c=(0,Eo.T)(s.commitRequest$,a.commitRequest$).pipe((0,is.z)((t=>function(e,t){return(0,Bo.D)(function(e,t){const{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,Ko.b)({error:e=>{"statusCode"in e&&"number"===typeof e.statusCode&&e.statusCode>=400&&e.statusCode<=500?t.cancel(e):t.failure(e)},next:()=>t.success()}))}(e,t))),(0,es.j)(Ro.E),(0,as.B)());return{transactionsPendingEvents$:l,draft:{...s,events:(0,Eo.T)(c,o,s.events).pipe((0,Ho.U)(EN("draft"))),consistency$:s.consistency$,remoteSnapshot$:s.remoteSnapshot$.pipe((0,Ho.U)(EN("draft")))},published:{...a,events:(0,Eo.T)(c,o,a.events).pipe((0,Ho.U)(EN("published"))),consistency$:a.consistency$,remoteSnapshot$:a.remoteSnapshot$.pipe((0,Ho.U)(EN("published")))}}}function FN(e,t){const n=Object.create(null);return function(){const i=t(...arguments);return i in n||(n[i]=e(...arguments)),n[i]}}const MN=(e,t)=>{var n;return!0===(null==(n=e.get(t))?void 0:n.liveEdit)};function ON(e,t,n){var i,r;const o=e.config();return"".concat(null!=(i=o.dataset)?i:"","-").concat(null!=(r=o.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}const RN=FN(((e,t,n)=>new zo.y((n=>{n.next(AN(e,t))})).pipe((0,hs._)(1),(0,fs.x)())),ON);function zN(e){return"snapshot"===e.type}function DN(e){return{snapshots$:e.events.pipe((0,Yo.h)(zN),(0,Ho.U)((e=>e.document)),(0,hs._)(1),(0,fs.x)()),patch:e.patch,create:e.create,createIfNotExists:e.createIfNotExists,createOrReplace:e.createOrReplace,delete:e.delete,mutate:e.mutate,commit:e.commit}}const BN=FN(((e,t,n)=>RN(e,t,n).pipe((0,Ho.U)((e=>{let{published:t,draft:n,transactionsPendingEvents$:i}=e;return{transactionsPendingEvents$:i,published:DN(t),draft:DN(n)}})),(0,hs._)(1),(0,fs.x)())),((e,t,n)=>{var i,r;const o=e.config();return"".concat(null!=(i=o.dataset)?i:"","-").concat(null!=(r=o.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)})),LN={enabled:!0},ZN={enabled:!1},NN=FN(((e,t,n)=>{const i=MN(e.schema,n);return BN(e.client,t,n).pipe((0,Go.w)((e=>(0,Do.a)([e.draft.snapshots$,e.published.snapshots$,e.transactionsPendingEvents$.pipe((0,Ho.U)((e=>"begin"===e.phase?LN:ZN)),(0,Qo.O)(ZN))]))),(0,Ho.U)((e=>{let[r,o,s]=e;return{id:t.publishedId,type:n,draft:r,published:o,liveEdit:i,ready:!0,transactionSyncLock:s}})),(0,Qo.O)({id:t.publishedId,type:n,draft:null,published:null,liveEdit:i,ready:!1,transactionSyncLock:null}),(0,hs._)(1),(0,fs.x)())}),((e,t,n)=>ON(e.client,t,n))),qN=FN(((e,t,n)=>BN(e.client,t,n).pipe((0,Go.w)((i=>(0,Do.a)([i.draft.snapshots$,i.published.snapshots$]).pipe((0,Ho.U)((r=>{let[o,s]=r;return{...e,idPair:t,typeName:n,snapshots:{draft:o,published:s},draft:i.draft,published:i.published}}))))),(0,hs._)(1),(0,fs.x)())),((e,t,n)=>{var i,r;const o=e.client.config();return"".concat(null!=(i=o.dataset)?i:"","-").concat(null!=(r=o.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)})),UN={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;const o=t.observable.transaction().delete(i.publishedId);return MN(n,r)?o.commit({tag:"document.delete"}):o.delete(i.draftId).commit({tag:"document.delete",skipCrossDatasetReferenceValidation:!0})}};function VN(e){return(0,mo.Yk)(e)?e._strengthenOnPublish?hl()(e,["_strengthenOnPublish"].concat(e._strengthenOnPublish.weak?[]:["_weak"])):e:"object"===typeof e&&e?Array.isArray(e)?e.map(VN):Object.fromEntries(Object.entries(e).map((e=>{let[t,n]=e;return[t,VN(n)]}))):e}const KN={disabled:e=>{let{schema:t,typeName:n,snapshots:i}=e;return MN(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 new Error('cannot execute "publish" when draft is missing');const r=VN(hl()(i.draft,"_updatedAt")),o=t.observable.transaction();if(!i.draft)throw new Error('cannot execute "publish" when draft is missing');return i.published?(o.patch(n.publishedId,{unset:["_revision_lock_pseudo_field_"],ifRevisionID:i.published._rev}),o.createOrReplace({...r,_id:n.publishedId,_type:i.draft._type})):o.create({...r,_id:n.publishedId,_type:i.draft._type}),o.delete(n.draftId),o.commit({tag:"document.publish",visibility:"async"})}},HN={disabled:()=>!1,execute:function(e){let{schema:t,snapshots:n,idPair:i,draft:r,published:o,typeName:s}=e,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=arguments.length>2?arguments[2]:void 0;MN(t,s)?o.mutate([o.createIfNotExists({_type:s,...l}),...o.patch(a)]):r.mutate([r.createIfNotExists({...l,...n.published,_id:i.draftId,_type:s}),...r.patch(a)])}},$N={disabled:()=>!1,execute:e=>{let{draft:t,published:n}=e;return t.commit(),n.commit(),Ro.E}},WN={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"})}},GN={disabled:e=>{let{schema:t,snapshots:n,typeName:i}=e;return MN(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({...hl()(i.published,"_updatedAt"),_id:n.draftId,_type:i.published._type})),r.commit({tag:"document.unpublish",visibility:"async",skipCrossDatasetReferenceValidation:!0}
1)}},XN=["_createdAt","_updatedAt"],YN={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:o}=e;const s=r.draft||r.published;if(!s)throw new Error("cannot execute on empty document");return i.observable.create({...hl()(s,XN),_id:MN(n,o)?t:Sd(t),_type:s._type},{tag:"document.duplicate"})}},JN={disabled:()=>!1,execute:(e,t)=>{let{historyStore:n,schema:i,idPair:r,typeName:o}=e;const s=MN(i,o)?r.publishedId:r.draftId;return n.restore(r.publishedId,s,t)}},QN=FN(((e,t,n)=>RN(e,t,n).pipe((0,Go.w)((e=>{let{draft:t,published:n}=e;return(0,Do.a)([t.consistency$,n.consistency$])})),(0,Ho.U)((e=>{let[t,n]=e;return t&&n})),(0,$o.x)(),(0,hs._)(1),(0,fs.x)())),((e,t,n)=>{var i,r;const o=e.config();return"".concat(null!=(i=o.dataset)?i:"","-").concat(null!=(r=o.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)}));const eq={del:UN,delete:UN,publish:KN,patch:HN,commit:$N,discardChanges:WN,unpublish:GN,duplicate:YN,restore:JN},tq=(e,t,n)=>{const i=eq[e];return(0,Ao.P)((()=>{return(0,Eo.T)((0,So.of)(null),"undefined"===typeof(e=i.execute(t,...n))?(0,So.of)(null):e);var e})).pipe((0,gs.Z)())},nq=new Po.x;function iq(e,t,n,i){nq.next({operationName:e,idPair:t,typeName:n,extraArgs:i})}const rq=["publish","unpublish","discardChanges","delete"],oq=FN((e=>{const t=nq.pipe((0,xs.v)((e=>e.idPair.publishedId)),(0,is.z)((t=>t.pipe((0,Go.w)((t=>qN(e,t.idPair,t.typeName).pipe((0,ns.q)(1),(0,Go.w)((n=>{const i=rq.includes(t.operationName);i&&(n.published.commit(),n.draft.commit());const r=QN(e.client,t.idPair,t.typeName).pipe((0,Yo.h)(Boolean));return(i?r.pipe((0,ns.q)(1)):(0,So.of)(!0)).pipe((0,Go.w)((()=>tq(t.operationName,n,t.extraArgs))))})),(0,Ho.U)((()=>({type:"success",args:t}))),(0,Wo.K)((e=>(0,So.of)({type:"error",args:t,error:e}))))))))),(0,as.B)()),n=t.pipe((0,Yo.h)((e=>"success"===e.type&&"patch"===e.args.operationName)),(0,vs.p)(1e3,qo.z,{leading:!0,trailing:!0}),(0,Ko.b)((e=>{iq("commit",e.args.idPair,e.args.typeName,[])})));return(0,Eo.T)(t,n.pipe((0,es.j)(Ro.E)))}),(e=>{var t,n;const i=e.client.config();return"".concat(null!=(t=i.dataset)?t:"","-").concat(null!=(n=i.projectId)?n:"")})),sq=FN(((e,t,n)=>RN(e,t,n).pipe((0,Go.w)((e=>{let{published:t,draft:n}=e;return(0,Eo.T)(t.remoteSnapshot$,n.remoteSnapshot$)})))),ON),aq={isValidating:!0,validation:[]};const lq=[],cq=FN(((e,t,n)=>{let{draftId:i,publishedId:r}=t;const o=NN(e,{draftId:i,publishedId:r},n).pipe((0,Ho.U)((e=>{let{draft:t,published:n}=e;return t||n})),(0,vs.p)(200,qo.z,{trailing:!0}),(0,$o.x)(((e,t)=>(null==e?void 0:e._rev)===(null==t?void 0:t._rev)||zs()(hl()(e,"_rev","_updatedAt"),hl()(t,"_rev","_updatedAt")))),(0,as.B)()),s=o.pipe((0,Ho.U)((e=>{return t=e,(0,Ac.u4)(t,((e,t)=>((0,mo.Yk)(t)&&e.add(t._ref),e)),new Set);var t})),(0,is.z)((e=>(0,Bo.D)(e)))).pipe((0,xs.v)((e=>e),void 0,(()=>(0,Mo.H)(18e5))),(0,is.z)((t=>t.pipe((0,ys.E)(),(0,is.z)((t=>((e,t)=>e(t).pipe((0,Ho.U)((e=>{let{published:t}=e;return t.available}))))(e.observeDocumentPairAvailability,t).pipe((0,Ho.U)((e=>[t,e])))))))),(0,Xo.R)(((e,t)=>{let[n,i]=t;return Boolean(e[n])===i?e:i?{...e,[n]:i}:hl()(e,n)}),{}),(0,$o.x)(zs()),(0,Jo.d)({refCount:!0,bufferSize:1})),a=e=>{let{id:t}=e;return(0,Uo.n)(s.pipe((0,cs.P)(),(0,Ho.U)((e=>e[t]))))},l=s.pipe((0,ps.T)(1),(0,vs.p)(1e3,qo.z,{leading:!0,trailing:!0}));return(0,Do.a)([o,(0,To.z)((0,So.of)(null),l)]).pipe((0,Ho.U)((e=>{let[t]=e;return t})),(0,Fc.q)((t=>(0,Ao.P)((()=>(null==t?void 0:t._type)?(0,To.z)((0,So.of)({isValidating:!0,revision:t._rev}),(0,na.aj)(e.getClient,t,e.schema,{getDocumentExists:a}).pipe((0,Ho.U)((e=>({validation:e,isValidating:!1}))))):(0,So.of)({validation:lq,isValidating:!1}))))),(0,Xo.R)(((e,t)=>({...e,...t})),aq),(0,hs._)(1),(0,fs.x)())}),((e,t,n)=>{var i,r;const o=e.client.config();return"".concat(null!=(i=o.dataset)?i:"","-").concat(null!=(r=o.projectId)?r:"","-").concat(t.publishedId,"-").concat(n)})),dq=FN(((e,t,n)=>RN(e,t,n).pipe((0,Go.w)((e=>{let{draft:t,published:n}=e;return(0,Eo.T)(t.events,n.events)})))),ON);function uq(e){return{disabled:"NOT_READY",execute:()=>{throw new Error("Called ".concat(e," before it was ready."))}}}const pq={commit:uq("commit"),delete:uq("delete"),del:uq("del"),publish:uq("publish"),patch:uq("patch"),discardChanges:uq("discardChanges"),unpublish:uq("unpublish"),duplicate:uq("duplicate"),restore:uq("restore")},hq=(e,t,n)=>function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return iq(e,t,n,r)};function fq(e,t,n){return{disabled:t.disabled(n),execute:hq(e,n.idPair,n.typeName)}}function mq(e){return{commit:fq("commit",$N,e),delete:fq("delete",UN,e),del:fq("delete",UN,e),publish:fq("publish",KN,e),patch:fq("patch",HN,e),discardChanges:fq("discardChanges",WN,e),unpublish:fq("unpublish",GN,e),duplicate:fq("duplicate",YN,e),restore:fq("restore",JN,e)}}const gq=FN(((e,t,n)=>{const i=oq(e),r=qN(e,t,n).pipe((0,Ho.U)(mq));return(0,To.z)((0,So.of)(pq),(0,Eo.T)(i.pipe((0,is.z)((()=>Ro.E))),r)).pipe((0,Jo.d)({refCount:!0,bufferSize:1}))}),((e,t,n)=>ON(e.client,t,n))),xq=(e,t,n,i)=>(0,Ao.P)((()=>e.observable.fetch(t,n,{tag:i.tag,filterResponse:!0}))),vq=(e,t,n,i)=>(0,Ao.P)((()=>e.listen(t,n,{events:["welcome","mutation","reconnect"],includeResult:!1,visibility:"query",tag:i.tag}
1)));function yq(e){return"welcome"===e.type}function bq(e){return sc()(e)}const jq=["_key","_ref","_weak","_type"];function wq(e){return e&&e.length>0?'"'.concat(e,'"'):e}function kq(e,t){const n=e=>'Template "'.concat(t.id,'" initial value: ').concat(e);if(!bq(e))throw new Error(n("resolved to a non-object"));if(e._type&&t.schemaType!==e._type)throw new Error(n('includes "_type"-property ('.concat(e._type,") that does not match template (").concat(t.schemaType,")")));try{return Cq(e)}catch(i){throw i.message=n(i.message),i}}function Cq(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Array.isArray(e))return e.map(((e,n)=>{if(Array.isArray(e))throw new Error('multidimensional arrays are not supported (at path "'.concat((0,xo.BB)(t),'")'));return Cq(e,t.concat(n),!0)}));if(!bq(e))return e;const i=n&&!e._key?{_key:(0,vl.E2)()}:{};return t.length>0&&!e._type&&e._ref&&(i._type="reference"),e._ref&&_q(e,t),Object.keys(e).reduce(((n,i)=>(n[i]=Cq(e[i],t.concat([i])),n)),i)}function _q(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e._type&&e.type)throw new Error('Reference is missing "_type", but has a "type" property at path "'.concat((0,xo.BB)(t),'"'));const n=Object.keys(e).filter((e=>!jq.includes(e)));if(n.length>0){const e=n.length>1?"properties":"property";throw new Error("Disallowed ".concat(e," found in reference: ").concat(n.map(wq).join(", "),' at path "').concat((0,xo.BB)(t),'"'))}}function Sq(e,t){const n={...e,...t};return Object.keys(n).forEach((i=>{const r=t[i],o=e[i];bq(r)&&bq(o)&&(n[i]=Sq(o,r))})),n}function Tq(e){return bq(e)&&"function"===typeof e.serialize}async function Iq(e,t,n){return"function"===typeof e?e(t,n):e}async function Pq(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(Tq(t))return Pq(e,t.serialize(),n,i);const{id:r,schemaType:o,value:s}=t;if(!s)throw new Error('Template "'.concat(r,'" has invalid "value" property'));let a=await Iq(s,n,i);if(!bq(a))throw new Error('Template "'.concat(r,'" has invalid "value" property - must be a plain object or a resolver function returning a plain object'));bq(a)&&!Object.keys(a).length&&(a={_type:o}),a=kq(a,t);const l=e.get(o);if(!l)throw new Error('Could not find schema type with name "'.concat(o,'".'));const c=Sq(await Aq(l,n,Eq,i)||{},a);return kq(c,t)}const Eq=10;function Aq(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Eq,i=arguments.length>3?arguments[3]:void 0;return n<=0?Promise.resolve(void 0):(0,mo.m$)(e)?Mq(e,t,n,i):(0,mo.jB)(e)?Fq(e,t,n,i):Iq(e.initialValue,t,i)}async function Fq(e,t,n,i){const r=await Iq(e.initialValue,void 0,i);if(Array.isArray(r))return Promise.all(r.map((async r=>{const o=function(e,t){const n=(0,vl.wq)(t);return"object"===n&&1===e.of.length?e.of[0]:e.of.find((e=>e.name===n))}(e,r);return(0,mo.m$)(o)?{...r,...await Aq(o,t,n-1,i),_key:(0,vl.E2)()}:r})))}async function Mq(e,t,n,i){const r={...await Iq(e.initialValue,t,i)||{}},o={};await Promise.all(e.fields.map((async e=>{const r=await Aq(e.type,t,n-1,i);void 0!==r&&null!==r&&(o[e.name]=r)})));const s=Sq(o,r);if(!(0,vl.Ru)(s))return"object"!==e.name&&(s._type=e.name),s}const Oq={type:"loading"};function Rq(e){if(Cd(e))throw new Error("editOpsOf does not expect a draft id.");return{publishedId:e,draftId:Sd(e)}}function zq(e){let{getClient:t,documentPreviewStore:n,historyStore:i,initialValueTemplates:r,schema:o}=e;const s=n.unstable_observeDocumentPairAvailability,a=t(qh),l={client:a,getClient:t,observeDocumentPairAvailability:s,historyStore:i,schema:o};return{checkoutPair:e=>AN(a,e),initialValue:(e,t)=>function(e,t,n,i,r){const o=n.observePaths({_type:"reference",_ref:Sd(i.documentId)},["_type"]),s=n.observePaths({_type:"reference",_ref:Td(i.documentId)},["_type"]);return(0,Eo.T)(o.pipe((0,Ho.U)((e=>({draft:e})))),s.pipe((0,Ho.U)((e=>({published:e}))))).pipe((0,Xo.R)(((e,t)=>({...e,...t})),{}),(0,Yo.h)((e=>"draft"in e&&"published"in e)),(0,Ho.U)((e=>e.draft||e.published)),(0,$o.x)(((e,t)=>Boolean(e)!==Boolean(t))),(0,bs.b)(25)).pipe((0,Go.w)((n=>{if(n)return(0,So.of)({type:"success",value:null});if(!i.templateName)return(0,So.of)({isResolving:!1,initialValue:void 0});const o=t.find((e=>e.id===i.templateName));if(!o)return console.warn('Template "%s" not defined, using empty initial value',i.templateName),(0,So.of)({isResolving:!1,initialValue:void 0});const s=(0,Bo.D)(Pq(e,o,i.templateParams,r)).pipe((0,Ho.U)((e=>({isResolving:!1,initialValue:e})))).pipe((0,Wo.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();const t={type:"error",error:e};return(0,So.of)(t)})));return(0,Eo.T)((0,So.of)({isResolving:!0}),s).pipe((0,Go.w)((e=>{let{isResolving:t,initialValue:n,resolveError:i}=e;if(i)return(0,So.of)({type:"error",message:"Failed to resolve initial value"});if(t)return(0,So.of)(Oq);const r={type:"success",value:n};return(0,So.of)(r)})))})),(0,Qo.O)(Oq),(0,$o.x)())}(o,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]:{};const r="string"===typeof t?t:t.fetch,o="string"===typeof t?t:t.listen,s=vq(e,o,n,i).pipe((0,is.z)(((e,t)=>0!==t||yq(e)?(0,So.of)(e):(0,Fo._)((()=>new Error("reconnect"===e.type?"Could not establish EventSource connection":'Received unexpected type of first event "'.concat(e.type,'"')))))),(0,as.B)()),[a,l]=(0,Vo.u)(s,yq),c=e=>!i.transitions||"mutation"!==e.type||i.transitions.includes(e.transition);return(0,Eo.T)(a.pipe((0,ns.q)(1)),l.pipe((0,Yo.h)(c),(0,vs.p)(i.throttleTime||1e3,qo.z,{leading:!0,trailing:!0}))).pipe((0,Fc.q)((()=>
1xq(e,r,n,i))))}(a,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,So.of)(n);const i="*[_id in [$documentId, $draftId]]._type",r=Td(t),o=Sd(r);return e.observable.fetch(i,{documentId:r,draftId:o}).pipe((0,Ho.U)((e=>e[0])))}(a,e,t),pair:{consistencyStatus:(e,t)=>QN(l.client,Rq(e),t),documentEvents:(e,t)=>dq(l.client,Rq(e),t),editOperations:(e,t)=>gq(l,Rq(e),t),editState:(e,t)=>NN(l,Rq(e),t),operationEvents:(e,t)=>oq({client:a,historyStore:i,schema:o}).pipe((0,Yo.h)((n=>n.args.idPair.publishedId===e&&n.args.typeName===t)),(0,Ho.U)((e=>{const{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)=>cq(l,Rq(e),t)}}}const Dq={isLoaded:!1,documentType:void 0};function Bq(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";const n=gV(),i=Td(e),r=Boolean(t&&"*"!==t),o=(0,vo.useMemo)((()=>({documentType:t,isLoaded:!0})),[t]),[s,a]=(0,vo.useState)(r?o:Dq);return(0,vo.useEffect)((()=>a(Dq)),[i,t]),(0,vo.useEffect)((()=>{if(r)return;const e=n.resolveTypeForDocument(i,t).subscribe((e=>a({documentType:e,isLoaded:!0})));return()=>e.unsubscribe()}),[n,i,t,r]),r?o:s}function Lq(e,t){const n=mV();return $d((0,vo.useMemo)((()=>e?n.observePaths({_type:"reference",_ref:e},t):(0,So.of)(void 0)),[e,n,t]))}function Zq(e){const{documentId:t,documentType:n,templateName:i,templateParams:r}=e,o=bd(r),s=gV(),a=Nq(),l=(0,vo.useMemo)((()=>({_id:t,_type:n})),[t,n]),[c,d]=(0,vo.useState)({loading:!1,error:null,value:l});return(0,vo.useEffect)((()=>{const e={documentId:t,documentType:n,templateName:i,templateParams:o};if(!i)return void d({loading:!0,error:null,value:l});const r=s.initialValue(e,a).subscribe((e=>{"loading"===e.type&&d({loading:!0,error:null,value:l}),"success"===e.type&&d({loading:!1,error:null,value:e.value?{...l,...e.value}:l}),"error"===e.type&&d({loading:!1,error:e.error,value:l})}));return d({loading:!0,error:null,value:l}),()=>r.unsubscribe()}),[l,t,s,n,i,o,a]),c}function Nq(){const e=SO(),t=nN(),n=xN(),i=tN(),r=YZ(),o=e.getClient;return(0,vo.useMemo)((()=>({projectId:i,dataset:r,getClient:o,schema:t,currentUser:n})),[o,t,n,i,r])}function qq(){const e=Nq();return(0,vo.useCallback)(((t,n)=>Aq(t,n,Eq,e)),[e])}const Uq=jd((function(e){let{client:t,grantsStore:n,schema:i,id:r,permission:o,type:s}=e;if("*"===s)return(0,So.of)({granted:!1,reason:"Type specified was `*`"});const a=Boolean(function(e,t){const n=e.get(t);if(!n)throw new Error("No such schema type: ".concat(t));return n}(i,s).liveEdit);return BN(t,{draftId:Sd(r),publishedId:Td(r)},s).pipe((0,Go.w)((e=>(0,Do.a)([e.draft.snapshots$,e.published.snapshots$]).pipe((0,Ho.U)((e=>{let[t,n]=e;return{draft:t,published:n}}))))),(0,Go.w)((e=>{let{draft:t,published:i}=e;const r=function(e){let{grantsStore:t,permission:n,draft:i,published:r,liveEdit:o}=e;const s=i||r,a=s===i?"draft":"published",{checkDocumentPermission:l}=t;switch(n){case"delete":return o?[["delete published document (live-edit)",l("update",r)]]:[["delete draft document",l("update",i)],["delete published document",l("update",r)]];case"discardDraft":return o?[]:[["delete draft document",l("update",i)]];case"publish":return o?[]:[["update published document at its current state",l("update",r)],["delete draft document",l("update",i)],["create published document from draft",l("create",i&&{...i,_id:Td(i._id)})]];case"unpublish":return o?[]:[["update draft document at its current state",l("create",i)],["delete published document",l("update",r)],["create draft document from published version",l("create",r&&{...r,_id:Sd(r._id)})]];case"update":return o?[["update published document (live-edit)",l("update",r)]]:[["update ".concat(a," document"),l("update",s)]];case"duplicate":return o?[["create new published document from existing document (live-edit)",l("create",{...r,_id:"dummy-id"})]]:[["create new draft document from existing ".concat(a," document"),l("create",{...s,_id:Sd("dummy-id")})]];default:throw new Error("Could not match permission: ".concat(n))}}({grantsStore:n,permission:o,draft:t,published:i,liveEdit:a}).map((e=>{let[t,n]=e;return n.pipe((0,Ho.U)((e=>{let{granted:n,reason:i}=e;return{granted:n,reason:n?"":"not allowed to ".concat(t,": ").concat(i),label:t,permission:o}})))}));return r.length?(0,Do.a)(r).pipe((0,Ho.U)((e=>{const t=e.every((e=>e.granted));return{granted:t,reason:t?"":"Unable to ".concat(o,":\n\t").concat(e.filter((e=>!e.granted)).map((e=>e.reason)).join("\n\t"))}}))):(0,So.of)({granted:!0,reason:""})})))}));function Vq(e){let{id:t,type:n,permission:i,client:r,schema:o,grantsStore:s}=e;const a=WZ(qh),l=nN(),c=hV(),d=(0,vo.useMemo)((()=>r||a),[a,r]),u=(0,vo.useMemo)((()=>o||l),[l,o]),p=(0,vo.useMemo)((()=>s||c),[c,s]);return Uq((0,vo.useMemo)((()=>({client:d,schema:u,grantsStore:p,id:t,permission:i,type:n}
1)),[d,p,t,i,u,n]))}function Kq(e){let{grantsStore:t,document:n,permission:i}=e;const{checkDocumentPermission:r}=t;return r(i,n)}const Hq=jd(Kq);function $q(e){let{document:t,permission:n,...i}=e;const r=hV();return Hq({grantsStore:i.grantsStore||r,document:t,permission:n})}function Wq(e){return"object"===typeof e&&null!==e&&"serialize"in e?Wq(e.serialize()):e}const Gq=jd((function(e){let{grantsStore:t,templateItems:n,templates:i,schema:r,context:o}=e;return(null==n?void 0:n.length)?(0,Do.a)(n.map(Wq).map((async e=>{const t=i.find((t=>t.id===e.templateId));if(!t)throw new Error('template not found: "'.concat(e.templateId,'"'));const n=await Pq(r,t,e.parameters,o);return{template:t,item:e,resolvedInitialValue:n}})).map((e=>(0,Bo.D)(e).pipe((0,Go.w)((e=>{let{item:n,resolvedInitialValue:i,template:o}=e;const s=r.get(o.schemaType);if(!s)throw new Error('schema type not found: "'.concat(o.schemaType,'"'));const a=null==s?void 0:s.liveEdit,{initialDocumentId:l="dummy-id"}=n;return Kq({grantsStore:t,permission:"create",document:{_id:a?Td(l):Sd(l),...i}}).pipe((0,Ho.U)((e=>{let{granted:t,reason:r}=e;const a=n.title||o.title;return{...n,granted:t,reason:r,resolvedInitialValue:i,template:o,title:a,subtitle:s.title===a?void 0:s.title,description:n.description||o.description,icon:n.icon||o.icon}})))})))))):(0,So.of)([])}));function Xq(e){let{templateItems:t,...n}=e;const i=nN(),r=sN(),o=hV(),s=Nq();return Gq({templateItems:t,grantsStore:n.grantsStore||o,schema:n.schema||i,templates:n.templates||r,context:s})}const Yq="_debug_",Jq="undefined"===typeof window?(0,So.of)({}):(0,Io.R)(window,"hashchange"),Qq=(0,To.z)((0,So.of)(0),Jq).pipe((0,Ho.U)((()=>"undefined"===typeof document?"#":document.location.hash)),(0,$o.x)(),(0,Ho.U)((e=>e.substring(1).split(";").filter((e=>e.toLowerCase().startsWith(Yq))).map((e=>e.substring(Yq.length)))))),eU=Qq.pipe((0,Ho.U)((e=>e.find((e=>e.startsWith("roles="))))),(0,Ho.U)((e=>(null==e?void 0:e.split("roles=")[1].split(",").map((e=>e.trim())))||[]))),tU=[{filter:'_id in path("**")',permissions:["read","create","history","update"]}],nU=[{filter:'_id in path("**")',permissions:["read","history"]}],iU={administrator:[{filter:'_id in path("**")',permissions:["read","create","history","update"]}],editor:tU,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:nU,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:nU,write:tU},rU=eU.pipe((0,Ho.U)((e=>e.length?e.filter((e=>Boolean(e)&&e in iU)).flatMap((e=>iU[e]||[])):null)));const oU=new Map;async function sU(e,t,n){oU.has(t)||oU.set(t,(0,Mc.Q)("*[".concat(t,"]")));const i=oU.get(t),r=function(e){const t={};return null!==e&&(t.identity=e.id),t}(e),{identity:o}=r,s={...r},a=await(await(0,Mc.k)(i,{dataset:[n],identity:o,params:s})).get();return 1===(null==a?void 0:a.length)}function aU(e){let{client:t,currentUser:n}=e;const i=t.withConfig({apiVersion:"2021-06-07"}),r=(0,Ao.P)((()=>(0,So.of)(i.config()))).pipe((0,Go.w)((e=>{let{projectId:t,dataset:n}=e;if(!t||!n)throw new Error("Missing projectId or dataset");return async function(e,t,n){return await e.request({uri:"/projects/".concat(t,"/datasets/").concat(n,"/acl"),tag:"acl.get",withCredentials:!0})}(i,t,n)}))),o=rU.pipe((0,Go.w)((e=>e?(0,So.of)(e):r)),(0,hs._)(1),(0,Oc.f)(1e3));return{checkDocumentPermission:(e,t)=>o.pipe((0,Go.w)((i=>async function(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"};const r=[];for(const s of t)await sU(e,s.filter,i)&&r.push(s);const o=r.some((e=>e.permissions.some((e=>e===n))));return{granted:o,reason:o?"Matching grant":"No matching grants found"}}(n,i,e,t))),(0,$o.x)(zs()))}}async function lU(e,t){const n=t?{headers:{Authorization:"Bearer ".concat(t)}}:{credentials:"include"};return function(e){const t=e.body;if(!t)throw new Error("Failed to read body from response");let n,i=!1;return new ReadableStream({start(e){n=t.getReader();const r=new TextDecoder;let o="";n.read().then((function t(s){if(s.done){if(i)return;return o=o.trim(),0===o.length?void e.close():(e.enqueue(JSON.parse(o)),void e.close())}o+=r.decode(s.value,{stream:!0});const a=o.split("\n");for(let r=0;r<a.length-1;++r){const t=a[r].trim();if(0!==t.length)try{e.enqueue(JSON.parse(t))}catch(l){return e.error(l),i=!0,void n.cancel()}}
1return o=a[a.length-1],n.read().then(t).catch((t=>e.error(t)))})).catch((t=>e.error(t)))},cancel(){i=!0,n.cancel()}})}(await fetch(e,n))}var cU=Object.defineProperty,dU=(e,t,n)=>(((e,t,n)=>{t in e?cU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);function uU(e){return{id:e,hasAttrs:!1,attrs:null,rev:null,events:[],aligned:!1}}function pU(e,t){const n=t.events.findIndex((t=>e.id===t.transactionId));return n>=0?n+1:t.rev?t.rev===e.id?0:-1:0}function hU(e,t){if(e.hasAttrs=!0,t){if(e.attrs={...t},"string"!=typeof e.attrs._rev)throw new Error("snapshot has no _rev");e.rev=e.attrs._rev,delete e.attrs._rev}else e.attrs=null,e.rev=null;e.events=[]}class fU{constructor(e){dU(this,"timeline"),dU(this,"earliestTransactionId",null),dU(this,"_states"),this.timeline=e,this._states={draft:uU(e.draftId),published:uU(e.publishedId)}}appendRemoteSnapshotEvent(e){const t=this._states[e.version];if("snapshot"===e.type)return this._maybeInvalidateHistory(),void hU(t,e.document);"remoteMutation"===e.type&&(t.aligned?(this._apply(t,e),this.timeline.addRemoteMutation(e)):t.hasAttrs?t.events.push(e):hU(t,e.head))}prependHistoryEvent(e){if(!this.acceptsHistory)throw new Error("cannot prepend history at this point");for(const t of Object.values(this._states))if(!t.aligned){const n=pU(e,t);n>=0&&this._alignAtIndex(t,n)}this.timeline.addTranslogEntry(e),this.earliestTransactionId=e.id}didReachEarliestEntry(){for(const e of Object.values(this._states))if(!e.aligned){if(null!==e.attrs)throw new 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(const n of e.events.slice(0,t))this._apply(e,n);for(const 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,Rc.a)(e.attrs,t.effects.apply),e.rev=t.transactionId}_maybeInvalidateHistory(){if(this._isComplete){for(const e of Object.values(this._states))e.aligned=!1;this.earliestTransactionId=null,this.timeline.reset()}}}var mU=Object.defineProperty,gU=(e,t,n)=>(((e,t,n)=>{t in e?mU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class xU{constructor(e,t,n,i){gU(this,"timeline"),gU(this,"start"),gU(this,"end"),gU(this,"doc"),gU(this,"_startDocument"),gU(this,"_endDocument"),gU(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 vU(this.endDocument())}endDocument(){return this._endDocument||(this._endDocument=this.timeline.replayBackwardsUntil(this.end.end,this.doc)),this._endDocument}startAttributes(){return vU(this.startDocument())}startDocument(){if(!this.start)throw new 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 new Error("start required");this._diff=this.timeline.calculateDiff(this.startDocument(),this.endDocument(),this.start.index+1,this.end.index)}return this._diff}}function vU(e){return e.draft||e.published}var yU=Object.defineProperty,bU=(e,t,n)=>(((e,t,n)=>{t in e?yU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class jU{constructor(e){bU(this,"timeline"),bU(this,"client"),bU(this,"handler"),bU(this,"version",0),bU(this,"selectionState","inactive"),bU(this,"_aligner"),bU(this,"_fetchMore",!1),bU(this,"_fetchAtLeast",0),bU(this,"_isRunning",!1),bU(this,"_isSuspended",!1),bU(this,"_didErr",!1),bU(this,"_since",null),bU(this,"_sinceTime",null),bU(this,"_rev",null),bU(this,"_revTime",null),bU(this,"_reconstruction"),this.timeline=e.timeline,this.client=e.client,this.handler=e.handler,this._aligner=new fU(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";const 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 Boolean(this._rev)&&("range"===this.selectionState||"rev"===this.selectionState)}findRangeForNewRev(e){const t=this.timeline.isLatestChunk(e)?null:this.timeline.createTimeId(e);if(!this._since)return[null,t];const n=this.sinceTime;return n&&n.index<e.index?[this._since,t]:["@lastPublished",t]}findRangeForNewSince(e){const 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 xU(this.timeline,this._aligner.currentDocument,e,t))}currentDiff(){return this._reconstruction?this._reconstruction.diff():null}currentObjectDiff(){const e=this.currentDiff();if(e){if("null"===e.type)return null;if("object"!==e.type)throw new 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;if(this._aligner.acceptsHistory&&!this.timeline.reachedEarliestEntry&&("loading"===this.selectionState||this._fetchMore||this.timeline.chunkCount<=this._fetchAtLeast)&&!this._isSuspended){try{await this.fetchMoreTransactions()}catch(t){return this._didErr=!0,void(null==(e=this.handler)||e.call(this,t,this))}await this.tick()}}async fetchMoreTransactions(){const e=this.timeline.publishedId,t=this.timeline.draftId,n=this.client.config();let 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));const o=this.client.getUrl("/data/history/".concat(n.dataset,"/transactions/").concat(e,",").concat(t,"?").concat(i)),s=(await lU(o,n.token)).getReader();let a=0;for(;;){const e=await s.read();if(e.done)break;if("error"in e.value)throw new Error(e.value.error.description||e.value.error.type);if(a++,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&&(a<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 wU(e){return e.draft||e.published}var kU=Object.defineProperty,CU=(e,t,n)=>(((e,t,n)=>{t in e?kU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class _U{constructor(e,t,n,i){CU(this,"type","array"),CU(this,"value"),CU(this,"length"),CU(this,"annotation"),CU(this,"extractor"),CU(this,"content"),CU(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 new Error("out of bounds");const t=this.elements[e];return t||(this.elements[e]=IU(this.content.elements[e],this.value[e],this.extractor))}annotationAt(e){const t=this.content.metas[e];return this.extractor.fromMeta(t)}}class SU{constructor(e,t,n,i){CU(this,"type","object"),CU(this,"value"),CU(this,"keys"),CU(this,"annotation"),CU(this,"extractor"),CU(this,"content"),CU(this,"fields",{}),this.content=e,this.value=t,this.annotation=n,this.extractor=i,this.keys=Object.keys(e.fields)}get(e){const t=this.fields[e];if(t)return t;const n=this.content.fields[e];return n?this.fields[e]=IU(n,this.value[e],this.extractor):void 0}}class TU{constructor(e,t,n,i){CU(this,"type","string"),CU(this,"value"),CU(this,"annotation"),CU(this,"extractor"),CU(this,"content"),this.content=e,this.value=t,this.annotation=n,this.extractor=i}sliceAnnotation(e,t){const n=[];let i=0;function r(e,t){if(n.length>0){const o=n[n.length-1];if(i=o.annotation,r=t,i&&r?i.author===r.author&&i.chunk===r.chunk:!i&&!r)return void(o.text+=e)}var i,r;n.push({text:e,annotation:t})}for(const o of this.content.parts){const n=o.value.length,s=Math.max(0,e-i);if(s<n){const e=Math.min(n,t-i);if(e<=0)break;r(o.value.slice(s,e),this.extractor.fromValue(o))}i+=n}return n}}function IU(e,t,n){const i=n.fromValue(e);if(e.content)switch(e.content.type){case"array":return new _U(e.content,t,i,n);case"object":return new SU(e.content,t,i,n);case"string":return new TU(e.content,t,i,n)}return(0,Dc.r)(t,i)}function PU(e,t,n){return n?AU(e,n.transactionIndex+1,n.chunk.index):t?AU(e,t.start,t.index):null}function EU(e,t){return t?AU(e,t.transactionIndex,t.chunk.index):null}
1function AU(e,t,n){const i=e.transactionByIndex(t);if(!i)return null;const r=e.chunkByTransactionIndex(t,n);return r?{chunk:r,timestamp:i.timestamp,author:i.author}:null}var FU=Object.defineProperty,MU=(e,t,n)=>(((e,t,n)=>{t in e?FU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class OU{constructor(){MU(this,"_postive",[]),MU(this,"_negative",[])}addToEnd(e){e.index=this._postive.length,this._postive.push(e)}addToBeginning(e){0!=this.length?(e.index=-(this._negative.length+1),this._negative.push(e)):this.addToEnd(e)}mergeAtEnd(e,t){if(0===this.length)return void this.addToEnd(e);const 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)return void this.addToEnd(e);const 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 RU(e,t){if(e.end!==t.start)throw new Error("chunks are not next to each other");const n=BU(e.draftState,t.draftState),i=BU(e.publishedState,t.publishedState);if("delete"===e.type&&"editDraft"===t.type)return[e,{...t,type:"create",draftState:n,publishedState:i}];if("delete"===t.type){if("missing"===n&&"present"===i)return[e,{...t,type:"discardDraft",draftState:n,publishedState:i}];if("present"===n&&"missing"===i)return[e,{...t,type:"unpublish",draftState:n,publishedState:i}]}if(("create"===(s=e.type)||"editDraft"===s)&&"editDraft"===t.type&&(r=e.endTimestamp,o=t.startTimestamp,Date.parse(o)-Date.parse(r)<3e5)){const r=new Set;for(const t of e.authors)r.add(t);for(const e of t.authors)r.add(e);return{index:0,id:t.id,type:e.type,start:e.start,end:t.end,startTimestamp:e.startTimestamp,endTimestamp:t.endTimestamp,authors:r,draftState:n,publishedState:i}}var r,o,s;return[e,{...t,draftState:n,publishedState:i}]}function zU(e){const t=Boolean(e);return e&&LU(null==e?void 0:e.apply)?"deleted":t?"upsert":"unedited"}function DU(e){const t=Boolean(e.draftEffect),n=Boolean(e.publishedEffect),i=e.draftEffect&&LU(e.draftEffect.apply),r=e.publishedEffect&&LU(e.publishedEffect.apply),o=function(e){const t=zU(e.draftEffect),n=zU(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";if("upsert"===t)return"editLive"}return"editLive"}(e);return{index:0,id:e.id,type:o,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 BU(e,t){return"unknown"===t?e:t}function LU(e){return 0===e[0]&&null===e[1]}var ZU=Object.defineProperty,NU=(e,t,n)=>(((e,t,n)=>{t in e?ZU(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);class qU{constructor(e){NU(this,"reachedEarliestEntry",!1),NU(this,"publishedId"),NU(this,"draftId"),NU(this,"_transactions",new OU),NU(this,"_chunks",new OU),NU(this,"_possiblePendingTransactions",new Map),NU(this,"_recreateTransactionsFrom"),NU(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){const t=[],n=this._chunks.firstIdx;for(let i=this._chunks.lastIdx;i>=n;i--)t.push(e(this._chunks.get(i),i));return t}reset(){this._transactions=new OU,this._chunks=new OU,this._possiblePendingTransactions=new Map,this._recreateTransactionsFrom=void 0,this.reachedEarliestEntry=!1}addRemoteMutation(e){this._trace&&this._trace.push({type:"addRemoteMutation",event:e});const 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;){const e=this._chunks.last;if(!(this._recreateTransactionsFrom<e.end))break;this._chunks.removeFromEnd()}this._recreateTransactionsFrom=void 0}}_addChunksFromTransactions(){const e=this._transactions.firstIdx,t=this._transactions.lastIdx;for(let n=this._chunks.length>0?this._chunks.last.end:e;n<=t;n++){const e=this._transactions.get(n);this._chunks.mergeAtEnd(DU(e),RU)}if(0==this._chunks.length)return;for(let n=this._chunks.first.start-1;n>=e;n--){const e=this._transactions.get(n);this._chunks.mergeAtBeginning(DU(e),RU)}}_invalidateTransactionFrom(e){(void 0===this._recreateTransactionsFrom||e<this._recreateTransactionsFrom)&&(this._recreateTransactionsFrom=e)}_createInitialChunk(){var e;if(this.reachedEarliestEntry){if("initial"===(null==(e=this._chunks.first)?void 0:e.type))return;const t=this._transactions.first;if(!t)return;const n=DU(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";const t=e.split("/",3),n=t.shift(),i=t.shift(),r=Number(n);for(let o=this._chunks.lastIdx;o>=this._chunks.firstIdx;o--){const e=this._chunks.get(o);if(e.id===i)return e;if(Date.parse(e.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--){const 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;for(;;){const n=this._chunks.get(t);if(!n)throw new Error("transaction does not belong in any chunk");if(e>=n.end)t++;else{if(!(e<n.start))return n;t--}}}replayBackwardsBetween(e,t,n){let i=n.draft,r=n.published;for(let o=t;o>=e;o--){const e=this._transactions.get(o);e.draftEffect&&(i=(0,Rc.a)(i,e.draftEffect.revert)),e.publishedEffect&&(r=(0,Rc.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){let r=zc.re(e.draft,null),o=zc.re(e.published,null);const s=function(e,t){return"null"===zc.oL(e)?t:e}(r,o),a=wU(e);let l=null;for(let c=n;c<=i;c++){const e=this._chunks.get(c);l||(l=e);for(let t=e.start;t<e.end;t++){const n=this._transactions.get(t),i={chunk:e,transactionIndex:t},s=r,a=o;n.draftEffect&&(r=zc.af(r,n.draftEffect.apply,i)),n.publishedEffect&&(o=zc.af(o,n.publishedEffect.apply,i));const l="null"!==zc.oL(s),c="null"!==zc.oL(r);"null"!==zc.oL(o)&&!c&&(o=zc.ZI(s,o)),c&&!l&&(r=zc.ZI(a,r))}}return function(e,t,n,i,r,o){const s=IU(n,i,{fromValue:n=>PU(e,t,n.endMeta),fromMeta:n=>PU(e,t,n)}),a=IU(r,o,{fromValue:t=>EU(e,t.startMeta),fromMeta:t=>EU(e,t)});return(0,Dc.t)(s,a)}(this,l,s,a,"null"===zc.oL(r)?o:r,wU(t))}}const UU=Object.create(null),VU=(e,t,n)=>{const i=Td(t),r=Sd(t),o="".concat(i,"@").concat(n),s=UU[o];if(s)return s;const a=e.config().dataset,l="/data/history/".concat(a,"/documents/").concat(i,",").concat(r,"?revision=").concat(n),c=e.request({url:l}).then((e=>{const t=e.documents||[],n=t.find((e=>e._id===i));return t.find((e=>e._id===r))||n}));return UU[o]=c,c},KU=e=>{let{client:t,documentId:n,documentType:i}=e;const r=new qU({enableTrace:gy,publishedId:n});return new jU({client:t,documentId:n,documentType:i,timeline:r})};function HU(e,t){return Array.isArray(e)?t(e.map((e=>HU(e,t))).filter((e=>"undefined"!==typeof e))):Od(e)?t(Object.keys(e).reduce(((n,i)=>{const r=HU(e[i],t);return"undefined"!==typeof r&&(n[i]=r),n}),{})):t(e)}const $U=(e,t)=>HU(e,(e=>(0,mo.Yk)(e)?t(e):e));function WU(e,t,n,i){return(0,Bo.D)(VU(e,t,i)).pipe((0,is.z)((n=>{if(!n)throw new Error("Unable to find document with ID ".concat(t," at revision ").concat(i));const r=(o=n,(0,Ac.u4)(o,((e,t)=>(0,mo.Yk)(t)&&!e.includes(t._ref)?[...e,t._ref]:e),[])).map((e=>'"'.concat(e,'": defined(*[_id=="').concat(e,'"]._id)'))).join(",");var o;return e.observable.fetch("{".concat(r,"}")).pipe((0,Ho.U)((e=>((e,t)=>$U(e,(e=>t[e._ref]?e:void 0)))(n,e))))})),(0,Ho.U)((e=>{const{_updatedAt:t,...i}=e;return{...i,_id:n}})),(0,is.z)((t=>e.observable.createOrReplace(t,{visibility:"async"}))))}function GU(e){let{client:t}=e;return{getDocumentAtRevision:(e,n)=>VU(t,e,n),getHistory:(e,n)=>function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=Array.isArray(t)?t:[t],{time:r,revision:o}=n;if(r&&o)throw new Error("getHistory can't handle both time and revision parameters");const s=e.config().dataset;let a="/data/history/".concat(s,"/documents/").concat(i.join(","));if(o)a="".concat(a,"?revision=").concat(o);else{const e=r||(new Date).toISOString();a="".concat(a,"?time=").concat(e)}return e.request({url:a})}(t,e,n),getTransactions:e=>(async(e,t)=>{const n=Array.isArray(t)?t:[t],i=e.config().dataset,r="/data/history/".concat(i,"/transactions/").concat(n.join(","));return(await e.request({url:r,query:{excludeContent:"true",includeIdentifiedDocumentsOnly:"true"}}
1)).toString("utf8").split("\n").filter(Boolean).map((e=>JSON.parse(e)))})(t,e),restore:(e,n,i)=>WU(t,e,n,i),getTimelineController:KU}}const XU={chunks:[],diff:null,hasMoreChunks:!1,isLoading:!1,onOlderRevision:!1,realRevChunk:null,revTime:null,selectionState:"inactive",sinceAttributes:null,sinceTime:null,timelineDisplayed:null,timelineReady:!1};function YU(e){let{documentId:t,documentType:n,onError:i,rev:r,since:o}=e;const s=fV(),a=(0,vo.useRef)(null),l=(0,vo.useRef)(XU),c=WZ(qh),d=(0,vo.useMemo)((()=>s.getTimelineController({client:c,documentId:t,documentType:n})),[c,t,n,s]),u=(0,vo.useMemo)((()=>new No.X(d)),[d]);(0,vo.useEffect)((()=>(d.setRange(o||null,r||null),u.next(d),d.handler=(e,t)=>{e?u.error(e):setTimeout((()=>{t.setRange(o||null,r||null),u.next(t)}),0)},d.resume(),()=>d.suspend())),[r,o,d,u]),(0,vo.useEffect)((()=>(a.current||(a.current=sq(c,{draftId:"drafts.".concat(t),publishedId:t},n).subscribe((e=>{d.handleRemoteMutation(e)}))),()=>{a.current&&(a.current.unsubscribe(),a.current=null)})),[c,d,t,n]);return(0,vo.useMemo)((()=>({findRangeForRev:e=>d.findRangeForNewRev(e),findRangeForSince:e=>d.findRangeForNewSince(e),loadMore:()=>{d.setLoadMore(!0),l.current.isLoading=!0},getSnapshot:()=>l.current,subscribe:e=>{const t=u.pipe((0,Ko.b)((e=>e.setLoadMore(!1))),(0,Ho.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,$o.x)(bo()),(0,Wo.K)((e=>(null==i||i(e),(0,So.of)(XU)))),(0,Ko.b)((e=>{l.current=e})),(0,Ko.b)(e)).subscribe();return()=>t.unsubscribe()}})),[d,i,u])}function JU(e,t){return(0,Ll.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,null,t)}const QU=[["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"]],eV=(0,Ao.P)((()=>(0,Mo.H)(0,1e4))).pipe((0,es.j)(["pqSMwf6hH","pnLYqNfv5","priDVVmy8","p0NFOU0j8","pTDl2jw8d","pHMeQnTse","pDQYzJbyS","pZyoPHKUs","p4Tyi2Be5","pb9vii060","pE8yhOisw","p7Fd2C6Cj","p3exSgYCx","pbIQRYViC","p8GJaTEhN","p27ewL8aM","pYg97z75S","pdLr4quHv","pkJXiDgg6","pkl4UAKcA","pNoExists"]),(0,Ho.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:Zc()(QU)}]}))),(0,Jo.d)()),tV=e=>{if("rollCall"===e.type)return{type:"rollCall",userId:e.i,sessionId:e.session};if("state"===e.type){const{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 new Error("Got unknown presence event: ".concat(JSON.stringify(e)))},nV="presence_session_id";const iV=function(){try{return window.sessionStorage.getItem(nV)}catch(e){}return null}()||function(e){try{window.sessionStorage.setItem(nV,e)}catch(t){}return e}((0,Bc.x0)(16));function rV(e){const{bifur:t,connectionStatusStore:n,userStore:i}=e,[r,o]=((e,t)=>[e.request("presence").pipe((0,Ho.U)(tV)).pipe((0,as.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}):Ro.E])(t,iV),s=new No.X([]),a=s.pipe((0,$o.x)()),l=e=>o({type:"state",locations:e}),c=r.pipe((0,Yo.h)((e=>"rollCall"===e.type)),(0,Yo.h)((e=>e.sessionId!==iV))),d=(0,Mo.H)(0,3e4),u=(0,Ao.P)((()=>
1(0,Eo.T)(a,c))).pipe((0,Go.w)((()=>d)),(0,ms.M)(s),(0,Ho.U)((e=>{let[,t]=e;return t})),(0,js.e)(200),(0,Go.w)((e=>l(e))),(0,es.j)(Ro.E),(0,as.B)()),p=(0,Ao.P)((()=>o({type:"rollCall"}))).pipe((0,es.j)(Ro.E)),h=n.connectionStatus$.pipe((0,Ho.U)((e=>e.type)),(0,Yo.h)((e=>"connected"===e||"error"===e)),(0,$o.x)()),f=Qq.pipe((0,Ho.U)((e=>e.find((e=>e.startsWith("presence="))))),(0,Ho.U)((e=>(null==e?void 0:e.split("presence=")[1].split(",").map((e=>e.trim())))||[]))),m=f.pipe((0,Yo.h)((e=>e.includes("fake_others"))),(0,Ko.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,ws.c)(eV)),g=f.pipe((0,Ho.U)((e=>e.includes("show_own")))),x=(0,Eo.T)(p,r).pipe((0,Yo.h)((e=>"state"===e.type||"disconnect"===e.type))),v=(0,Eo.T)(x,m).pipe((0,Xo.R)(((e,t)=>{return"disconnect"===t.type?hl()(e,t.sessionId):{...e,[t.sessionId]:(n=t,{lastActiveAt:n.timestamp,locations:n.locations,sessionId:n.sessionId,userId:n.userId})};var n}),{})),y=h.pipe((0,Go.w)((e=>"connected"===e?(0,Eo.T)(v,u):Oo.C)),(0,Ho.U)((e=>Object.values(e))),(0,Go.w)((e=>{const t=nl()(e.map((e=>e.userId)));return(0,Bo.D)(i.getUsers(t)).pipe((0,Ho.U)((t=>e.map((e=>({user:t.find((t=>t.id===e.userId)),session:e}))).filter(b))))})),(0,ts.R)((0,Io.R)(window,"beforeunload").pipe((0,Go.w)((()=>o({type:"disconnect"}))))),(0,Jo.d)({refCount:!0,bufferSize:1}));function b(e){return Boolean(e.user&&e.session)}const j=y.pipe((0,Ho.U)((e=>{const t=Wl()(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,ms.M)(g),(0,Ho.U)((e=>{let[t,n]=e;return t.filter((e=>{if(n)return!0;return!e.sessions.some((e=>e.sessionId===iV))}))})),(0,Ho.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:sl()((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=>{s.next(e)},reportLocations:l,debugPresenceParam$:f,globalPresence$:j,documentPresence:e=>y.pipe((0,ms.M)(g),(0,Go.w)((t=>{let[n,i]=t;return(0,Bo.D)(n).pipe((0,Yo.h)((e=>i||e.session.sessionId!==iV)),(0,ks.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,Cs.q)())})))}}function oV(e){const t=xV(),[n,i]=(0,vo.useState)([]);return(0,vo.useEffect)((()=>{const n=t.documentPresence(e).subscribe(i);return()=>{n.unsubscribe()}}),[e,t]),n}const sV={get:(e,t)=>{const n=localStorage.getItem(e);return(0,So.of)(null===n?t:((e,t)=>{try{return JSON.parse(e)}catch(n){return console.warn("Failed to parse settings: ".concat(n.message)),t}})(n,t))},set:(e,t)=>("undefined"===typeof t||null===t?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t)),(0,So.of)(t))},aV=Object.create(null),lV={get:(e,t)=>(0,So.of)(e in aV?aV[e]:t),set:(e,t)=>("undefined"===typeof t||null===t?delete aV[e]:aV[e]=t,(0,So.of)(t))};let cV=null;function dV(){return function(){if(null!==cV)return cV;const e="__test__";try{localStorage.setItem(e,e),localStorage.removeItem(e),cV=!0}catch(t){cV=!1}return cV}()?sV:lV}const uV=[{id:"<system>",displayName:"Sanity",imageUrl:"https://public.sanity.io/logos/favicon-192.png"}];function pV(){const{getClient:e,currentUser:t}=SO(),n=sh(),i=e(qh);return(0,vo.useMemo)((()=>{const e=n.get({namespace:"userStore",dependencies:[i,t]})||function(e){let{client:t,currentUser:n}=e;const i=t.withConfig({apiVersion:"2021-06-07"}),r=new(qc())((async e=>{const t=await i.request({uri:"/users/".concat(e.join(",")),withCredentials:!0,tag:"users.get"}),n=(Array.isArray(t)?t:[t]).reduce(((e,t)=>((null==t?void 0:t.id)&&(e[t.id]=t),e)),{});return e.map((e=>n[e]||null))}),{batchScheduleFn:e=>Vc()(e)}),o=n&&{id:n.id,displayName:n.name,imageUrl:n.profileImage};return r.prime("me",o),(null==o?void 0:o.id)&&r.prime(o.id,o),uV.forEac
1h((e=>r.prime(e.id,e))),{getUser:async e=>{try{return await r.load(e)}catch(t){if(403===t.statusCode)return Promise.resolve(null);throw t}},getUsers:async e=>(await r.loadMany(e)).filter((e=>Od(e)&&"string"===typeof e.id))}}({client:i,currentUser:t});return n.set({namespace:"userStore",dependencies:[i,t],value:e}),e}),[i,t,n])}function hV(){const{getClient:e}=SO(),t=e(qh),n=xN(),i=sh();return(0,vo.useMemo)((()=>{const e=i.get({namespace:"grantsStore",dependencies:[t,n]})||aU({client:t,currentUser:n});return i.set({namespace:"grantsStore",dependencies:[t,n],value:e}),e}),[t,n,i])}function fV(){const e=WZ(qh),t=sh();return(0,vo.useMemo)((()=>{const n=t.get({namespace:"historyStore",dependencies:[e]})||GU({client:e});return t.set({namespace:"historyStore",dependencies:[e],value:n}),n}),[e,t])}function mV(){const e=WZ(qh),t=sh();return(0,vo.useMemo)((()=>{const n=t.get({namespace:"documentPreviewStore",dependencies:[e]})||em({client:e});return t.set({namespace:"documentPreviewStore",dependencies:[e],value:n}),n}),[e,t])}function gV(){const e=SO().getClient,t=nN(),n=sN(),i=sh(),r=fV(),o=mV();return(0,vo.useMemo)((()=>{const s=i.get({namespace:"documentStore",dependencies:[e,o,r,t]})||zq({getClient:e,documentPreviewStore:o,historyStore:r,initialValueTemplates:n,schema:t});return i.set({namespace:"documentStore",dependencies:[e,o,r,t],value:s}),s}),[e,o,r,i,t,n])}function xV(){const{__internal:{bifur:e}}=SO(),t=sh(),n=pV(),i=function(){const{bifur:e}=SO().__internal,t=sh();return(0,vo.useMemo)((()=>{const n=t.get({namespace:"connectionStatusStore",dependencies:[e]})||Fh({bifur:e});return t.set({namespace:"connectionStatusStore",dependencies:[e],value:n}),n}),[e,t])}();return(0,vo.useMemo)((()=>{const r=t.get({namespace:"presenceStore",dependencies:[e,i,n]})||rV({bifur:e,connectionStatusStore:i,userStore:n});return t.set({namespace:"presenceStore",dependencies:[e,i,n],value:r}),r}),[e,i,t,n])}function vV(){const e=sh(),t=kO();return(0,vo.useMemo)((()=>{const n=e.get({dependencies:[t],namespace:"settingsStore"})||function(){const e=dV(),t=new Po.x,n=(e,t)=>"".concat(e,"::").concat(t),i=t.pipe((0,Go.w)((t=>e.set(t.key,t.value).pipe((0,Ho.U)((e=>({key:t.key,value:e}))))))),r=(t,n)=>(0,Eo.T)(e.get(t,n),i.pipe((0,Yo.h)((e=>e.key===t)),(0,Ho.U)((e=>e.value)))),o=(e,n)=>{t.next({key:e,value:n})},s=e=>({forKey:t=>{const i=n(e,t);return{listen:e=>r(i,e),set:e=>o(i,e),del:()=>o(i,void 0)}},listen:(t,i)=>r(n(e,t),i),set:(t,i)=>o(n(e,t),i),del:t=>o(n(e,t),void 0),forNamespace:t=>s(n(e,t))});return{forNamespace:s}}();return e.set({dependencies:[t],namespace:"settingsStore",value:n}),n}),[e,t])}const yV=/[^\p{Alpha}\p{White_Space}]/gu,bV=/\p{White_Space}+/u,jV={small:0,medium:1,large:2};function wV(e){const t=e.replace(yV,"").split(bV);return 1===t.length?"".concat(t[0].charAt(0)).toUpperCase():"".concat(t[0].charAt(0)).concat(t[t.length-1].charAt(0))}function kV(e){const{user:t,...n}=e;return Od(t)?n.withTooltip?(0,go.jsx)(CV,{...n,user:t}):(0,go.jsx)(_V,{...n,user:t}):(0,go.jsx)(SV,{...e,user:t})}function CV(e){const{user:{displayName:t}}=e;return(0,go.jsx)(Co.u,{content:(0,go.jsx)(Co.xu,{padding:2,children:(0,go.jsx)(Co.xv,{size:1,children:t})}),placement:"top",portal:!0,children:(0,go.jsx)("div",{style:{display:"inline-block"},children:(0,go.jsx)(_V,{...e})})})}const _V=(0,vo.forwardRef)((function(e,t){const{user:n,animateArrowFrom:i,position:r,size:o,status:s,tone:a}=e,[l,c]=(0,vo.useState)(null),d=function(e){const t=bg();return(0,_o.m2)(e?t.listen(e):(0,Ro.c)(),[e],t.get(null))}(n.id),u=l||null==n?void 0:n.imageUrl;return(0,go.jsx)(Co.qE,{animateArrowFrom:i,arrowPosition:r,color:d.name,"data-legacy-tone":a,initials:(null==n?void 0:n.displayName)&&wV(n.displayName),src:u,onImageLoadError:c,ref:t,size:"string"===typeof o?jV[o]:o,status:s})}));function SV(e){let{user:t,...n}=e;const[i]=gN(t);return i?(0,go.jsx)(kV,{...n,user:i}):null}(0,Es.ZP)(Co.xv)(fo||(fo=rd(["\n white-space: initial;\n"])));function TV(e){let{children:t,id:n}=e;return t($h(n))}function IV(e,t,n){var i;if(0===t.length)return{...e||{},value:n};const[r,...o]=t,s=(0,mo.Fd)(r)?r._key:String(r),a=null!=(i=null==e?void 0:e.children)?i:{};return{value:null==e?void 0:e.value,children:{...a,[s]:IV(a[s]||{},o,n)}}}const PV=20,EV={name:"all-fields",title:"All fields",hidden:!1};function AV(e,t){return[...t.map(((e,n)=>
1({type:"expandPath",path:t.slice(0,n+1)}))),...FV(e,t)]}function FV(e,t){return 0===t.length?[]:(n=e,(0,mo.m$)(n.schemaType)?MV(e,t):function(e){return(0,mo.M1)(e.schemaType)}(e)?OV(e,t):[]);var n}function MV(e,t){var n,i;if(0===t.length)return[];const[r,...o]=t,s=e._allMembers.find((e=>"fieldSet"===e.kind&&e.fieldSet.members.some((e=>"field"===e.kind&&e.name===r)))),a=(s?s.fieldSet.members:e._allMembers).find((e=>null!==e&&"field"===e.kind&&e.name===r)),l=e.schemaType.fields.find((e=>e.name===r)),c=null==(n=e.groups.find((e=>e.selected)))?void 0:n.name,d=null==(i=(e.schemaType.groups||[]).find((e=>e.default)))?void 0:i.name,u=[];return c&&(c===EV.name||l&&bc()(l.group).includes(c))||u.push({type:"setSelectedGroup",path:e.path,groupName:d||EV.name}),s&&u.push({type:"expandFieldSet",path:s.fieldSet.path}),a&&(kk(a)?u.push(...OV(a.field,o)):wk(a)&&u.push(...MV(a.field,o))),u}function OV(e,t){if(0===t.length)return[];const[n,...i]=t;if(!(0,mo.Fd)(n))throw new Error("Expected path segment to be an object with a _key property");const r=e.members.find((e=>e.key===n._key));return r?FV(r.item,i):[]}function RV(e,t){const{currentUser:n,document:i,parent:r,value:o}=t;return"boolean"===typeof e||void 0===e?Boolean(e):!0===e({document:i,parent:r,value:o,currentUser:n})}function zV(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(!1===(null==e?void 0:e.collapsible)||!1===(null==e?void 0:e.collapsable))return{collapsible:!1,collapsed:!1};const n="boolean"===typeof(null==e?void 0:e.collapsed)?e.collapsed:t>=3||void 0,i=!0===(null==e?void 0:e.collapsible)||!0===(null==e?void 0:e.collapsable)||!0===n||void 0;return{collapsible:i,collapsed:n}}function DV(e,t,n){return n.name===EV.name||void 0!==t&&(0===e.length&&n.name===EV.name||bc()(t).includes(n.name))}function BV(e){return"undefined"===typeof e||Od(e)}function LV(e,t){return!(!e||t)||!Ss()(e,t)}function ZV(e){var t,n,i,r,o,s,a,l,c,d,u,p,h,f,m,g,x,v;const{parent:y,field:b,index:j}=e,w=(0,xo.s6)([...y.path,b.name]),k=bC(b.type,y.level+1),C=y.value,_=y.comparisonValue;if(!BV(C))throw new Error("Unexpected non-object value");const S=b.group?bc()(b.group):[],T=DV(y.groups,b.group,y.selectedGroup);if((0,mo.m$)(b.type)){const e=null==C?void 0:C[b.name],a=Od(_)?null==_?void 0:_[b.name]:void 0;if(!BV(e))return{kind:"error",key:b.name,fieldName:b.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:b.type,resolvedValueType:(0,vl.wq)(e),value:e}};const l={value:e,parent:y.value,document:y.document,currentUser:y.currentUser};if(RV(b.type.hidden,l))return{kind:"hidden",key:"field-".concat(b.name),name:b.name,index:j};const c=y.readOnly||RV(b.type.readOnly,l),d=null==(n=null==(t=y.fieldGroupState)?void 0:t.children)?void 0:n[b.name],u=null==(r=null==(i=y.collapsedPaths)?void 0:i.children)?void 0:r[b.name],p=null==(s=null==(o=y.collapsedFieldSets)?void 0:o.children)?void 0:s[b.name],h=NV({schemaType:b.type,currentUser:y.currentUser,parent:y.value,document:y.document,value:e,changed:LV(e,a),comparisonValue:a,presence:y.presence,validation:y.validation,fieldGroupState:d,path:w,level:k,focusPath:y.focusPath,openPath:y.openPath,collapsedPaths:u,collapsedFieldSets:p,readOnly:c,changesOpen:y.changesOpen});if(null===h)return null;const f=zV(b.type.options,k),m=u?u.value:f.collapsed;return{kind:"field",key:"field-".concat(b.name),name:b.name,index:j,inSelectedGroup:T,groups:S,open:(0,xo.Ny)(w,y.openPath),field:h,collapsed:m,collapsible:f.collapsible}}if((0,mo.jB)(b.type)){const e=null==C?void 0:C[b.name],t=Od(_)?null==_?void 0:_[b.name]:void 0;if((0,mo.M1)(b.type)){const n="undefined"!==typeof e;if(n&&("undefined"!==typeof(P=e)&&!Array.isArray(P))){const t=(0,vl.wq)(e);return{kind:"error",key:b.name,fieldName:b.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:b.type,resolvedValueType:t,value:e}}}if(n&&!function(e){return 0===e.length||e.every((e=>Od(e)))}(e))return{kind:"error",key:b.name,fieldName:b.name,error:{type:"MIXED_ARRAY",schemaType:b.type,value:e}};if(n&&!(null==(I=e)?void 0:I.every((e=>Od(e)&&"_key"in e))))return{kind:"error",key:b.name,fieldName:b.name,error:{type:"MISSING_KEYS",value:e,schemaType:b.type}};const i=n?function(e){const 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:b.name,fieldName:b.name,error:{type:"DUPLICATE_KEYS",duplicates:i,schemaType:b.type}};const r=null==(l=null==(a=y.fieldGroupState)?void 0:a.children)?void 0:l[b.name],o=null==(d=null==(c=y.collapsedPaths)?void 0:c.children)?void 0:d[b.name],s=null==(p=null==(u=y.collapsedFieldSets)?void 0:u.children)?void 0:p[b.name],h=y.readOnly||RV(b.type.readOnly,{value:e,parent:y.value,document:y.document,currentUser:y.currentUser}),f=function(e){if(20===e.level)return null;const t={value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser};if(RV(e.schemaType.hidden,t))return null;const n=e.readOnly||RV(e.schemaType.readOnly,t),i=Array.isArray(e.value)?e.value:[],r=e.presence.filter((t=>(0,xo.Xy)(t.path,e.path))),o=r.length?r:Ad,s=e.validation.filter((t=>(0,xo.Xy)(t.path,e.path))).map((e=>({level:e.level,message:e.item.message,path:e.path}))),a=i.flatMap(((t,n)=>function(e){var t,n,i,r,o,s,a;const{arrayItem:l,parent:c,index:d}=e,u=function(e,t){const n=(0,vl.wq)(t);return"object"===n&&1===e.of.length?e.of[0]:e.of.find((e=>e.name===n))}(c.schemaType,l),p=l._key;if(!u){return{kind:"error",key:p,index:d,error:{type:"INVALID_ITEM_TYPE",resolvedValueType:(0,vl.wq)(l),value:l,validTypes:c.schemaType.of}}}const h=(0,xo.s6)([...c.path,{_key:p}]),f=c.level+1,m={value:c.value,parent:e.parent,document:c.document,currentUser:c.currentUser},g=c.readOnly||RV(c.schemaType.readOnly,m),x=null==(n=null==(t=c.fieldGroupState)?void 0:t.children)?void 0:n[p],v=null==(r=null==(i=c.collapsedPaths)?void 0:i.children)?void 0:r[p],y=null==(s=null==(o=c.collapsedFieldSets)?void 0:o.children)?void 0:s[p],b=Array.isArray(c.comparisonValue)&&c.comparisonValue.find((e=>e._key===l._key))||void 0,j=NV({schemaType:u,level:f,document:c.document,value:l,comparisonValue:b,changed:LV(l,b),path:h,focusPath:c.focusPath,openPath:c.openPath,currentUser:c.currentUser,collapsedPaths:v,collapsedFieldSets:y,presence:c.presence,validation:c.validation,fieldGroupState:x,readOnly:g},!1),w=zV(u.options,f),k=null!=(a=null==v?void 0:v.value)?a:w.collapsed;return{kind:"item",key:p,index:d,open:(0,xo.Ny)(h,c.openPath),collapsed:k,collapsible:!0,parentSchemaType:c.schemaType,item:j}}({arrayItem:t,parent:e,index:n})));return{changed:a.some((e=>"item"===e.kind&&e.item.changed)),value:e.value,readOnly:n,schemaType:e.schemaType,focused:(0,xo.Xy)(e.path,e.focusPath),focusPath:(0,xo.vC)(e.path,e.focusPath),path:e.path,id:(0,xo.BB)(e.path),level:e.level,validation:s,presence:o,members:a}}({schemaType:b.type,parent:y.value,currentUser:y.currentUser,document:y.document,value:e,changed:LV(e,t),comparisonValue:t,fieldGroupState:r,focusPath:y.focusPath,openPath:y.openPath,presence:y.presence,validation:y.validation,collapsedPaths:o,collapsedFieldSets:s,level:k,path:w,readOnly:h});return null===f?null:{kind:"field",key:"field-".concat(b.name),name:b.name,index:j,open:(0,xo.Ny)(w,y.openPath),inSelectedGroup:T,groups:S,collapsible:!1,
1collapsed:!1,field:f}}{if(!function(e){return"undefined"===typeof e||Array.isArray(e)}(e)){const t=(0,vl.wq)(e);return{kind:"error",key:b.name,fieldName:b.name,error:{type:"INCOMPATIBLE_TYPE",expectedSchemaType:b.type,resolvedValueType:t,value:e}}}const n=null==(f=null==(h=y.fieldGroupState)?void 0:h.children)?void 0:f[b.name],i=null==(g=null==(m=y.collapsedPaths)?void 0:m.children)?void 0:g[b.name],r=null==(v=null==(x=y.collapsedFieldSets)?void 0:x.children)?void 0:v[b.name],o=y.readOnly||RV(b.type.readOnly,{value:e,parent:y.value,document:y.document,currentUser:y.currentUser}),s=function(e){if(e.level===PV)return null;const t={comparisonValue:e.comparisonValue,value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser};if(RV(e.schemaType.hidden,t))return null;const n=e.readOnly||RV(e.schemaType.readOnly,t),i=Array.isArray(e.value)?e.value:[],r=e.presence.filter((t=>(0,xo.Xy)(t.path,e.path))),o=r.length?r:Ad,s=e.validation.filter((t=>(0,xo.Xy)(t.path,e.path))).map((e=>({level:e.level,message:e.item.message,path:e.path}))),a=i.flatMap(((t,n)=>function(e){var t,n;const{arrayItem:i,parent:r,index:o}=e,s=function(e,t){const n=(0,vl.wq)(t);return null==e?void 0:e.of.find((e=>e.name===n||e.jsonType===n))}(r.schemaType,i),a=(0,xo.s6)([...r.path,o]),l=null==(t=r.value)?void 0:t[o],c=null==(n=r.comparisonValue)?void 0:n[o],d=r.level+1,u="".concat((null==s?void 0:s.name)||"invalid-type","-").concat(String(o));if(!s)return{kind:"error",key:u,index:o,error:{type:"INVALID_ITEM_TYPE",validTypes:r.schemaType.of,resolvedValueType:(0,vl.wq)(s),value:l}};const p=r.readOnly||RV(s.readOnly,{value:l,parent:r.value,document:r.document,currentUser:r.currentUser}),h=qV({...r,path:a,schemaType:s,level:d,value:l,comparisonValue:c,readOnly:p});return{kind:"item",key:u,index:o,parentSchemaType:r.schemaType,open:(0,xo.Xy)(a,r.openPath),item:h}}({arrayItem:t,parent:e,index:n})));return{changed:a.some((e=>"item"===e.kind&&e.item.changed)),value:e.value,readOnly:n,schemaType:e.schemaType,focused:(0,xo.Xy)(e.path,e.focusPath),focusPath:(0,xo.vC)(e.path,e.focusPath),path:e.path,id:(0,xo.BB)(e.path),level:e.level,validation:s,presence:o,members:a}}({changed:LV(e,t),comparisonValue:t,schemaType:b.type,parent:y.value,currentUser:y.currentUser,document:y.document,value:e,fieldGroupState:n,focusPath:y.focusPath,openPath:y.openPath,presence:y.presence,validation:y.validation,collapsedPaths:i,collapsedFieldSets:r,level:k,path:w,readOnly:o});return null===s?null:{kind:"field",key:"field-".concat(b.name),name:b.name,index:j,inSelectedGroup:T,groups:S,open:(0,xo.Ny)(w,y.openPath),collapsible:!1,collapsed:!1,field:s}}}{const e=null==C?void 0:C[b.name],t=Od(_)?null==_?void 0:_[b.name]:void 0,n={value:e,parent:y.value,document:y.document,currentUser:y.currentUser};if(RV(b.type.hidden,n))return null;const i=y.readOnly||RV(b.type.readOnly,n),r=qV({...y,comparisonValue:t,value:e,schemaType:b.type,path:w,readOnly:i});return{kind:"field",key:"field-".concat(b.name),name:b.name,index:j,open:(0,xo.Ny)(w,y.openPath),inSelectedGroup:T,groups:S,collapsible:!1,collapsed:!1,field:r}}var I,P}function NV(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var n;if(e.level===PV)return null;const i={value:e.value,parent:e.parent,document:e.document,currentUser:e.currentUser},r=e.readOnly||RV(e.schemaType.readOnly,i),o=e.schemaType.groups||[],s=null==(n=o.find((e=>e.default))||EV)?void 0:n.name,a=[EV,...o].flatMap((t=>{var n;const r=RV(t.hidden,i),o=t.name===((null==(n=e.fieldGroupState)?void 0:n.value)||s),a=e.changesOpen?t.name===EV.name:o,l=!!e.changesOpen&&!a;return r?[]:[{disabled:l,icon:null==t?void 0:t.icon,name:t.name,selected:a,title:t.title}]})),l=a.find((e=>e.selected)),c=e.schemaType.fieldsets?e.schemaType.fieldsets:e.schemaType.fields.map((e=>({single:!0,field:e}))),d=c.flatMap(((t,n)=>{var i,o,s,c;if(t.single){const i=ZV({field:t.field,parent:{...e,readOnly:r,groups:a,selectedGroup:l},index:n});return i?[i]:[]}const d=t.fields.map((e=>e.name)),u=RV(t.hidden,{currentUser:e.currentUser,document:e.document,parent:e.value,value:wc()(e.value,d)}),p=RV(t.readOnly,{currentUser:e.currentUser,document:e.document,parent:e.value,value:wc()(e.value,d)}),h=t.fields.flatMap((t=>{if(u)return[{kind:"hidden",key:"field-".concat(t.name),name:t.name,index:n}];const i=ZV({field:t,parent:{...e,readOnly:r||p,groups:a,selectedGroup:l},index:n});return i?[i]:[]})),f=zV(t.options,e.level),m=null!=(s=null==(o=((null==(i=e.collapsedFieldSets)?void 0:i.children)||{}
1)[t.name])?void 0:o.value)?s:f.collapsed;return[{kind:"fieldSet",key:"fieldset-".concat(t.name),_inSelectedGroup:DV(a,t.group,l),groups:t.group?bc()(t.group):[],fieldSet:{path:(0,xo.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==(c=null==t?void 0:t.options)?void 0:c.columns}}]})),u=o.length>0,p=e.presence.filter((t=>(0,xo.Xy)(t.path,e.path))),h=p.length?p:Ad,f=e.validation.filter((t=>(0,xo.Xy)(t.path,e.path))).map((e=>({level:e.level,message:e.item.message,path:e.path}))),m=d.filter((e=>"hidden"!==e.kind));if(0===m.length&&t)return null;const g=u?a.flatMap((e=>{if(e.name===EV.name)return e;return 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))))))?e:[]})):[],x=m.flatMap((e=>{if("error"===e.kind)return[e];if("field"===e.kind)return e.inSelectedGroup?[e]:[];const 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:LV(e.value,e.comparisonValue),schemaType:e.schemaType,readOnly:r,path:e.path,id:(0,xo.BB)(e.path),level:e.level,focused:(0,xo.Xy)(e.path,e.focusPath),focusPath:(0,xo.vC)(e.path,e.focusPath),presence:h,validation:f,_allMembers:d,members:x,groups:g}}function qV(e){const t=e.presence.filter((t=>(0,xo.Xy)(t.path,e.path))),n=t.length?t:Ad,i=e.validation.filter((t=>(0,xo.Xy)(t.path,e.path))).map((e=>({level:e.level,message:e.item.message,path:e.path})));return{schemaType:e.schemaType,changed:LV(e.value,e.comparisonValue),value:e.value,level:e.level,id:(0,xo.BB)(e.path),readOnly:e.readOnly,focused:(0,xo.Xy)(e.path,e.focusPath),path:e.path,presence:n,validation:i}}function UV(e,t){let{comparisonValue:n,value:i,fieldGroupState:r,collapsedFieldSets:o,collapsedPaths:s,focusPath:a,openPath:l,presence:c,validation:d,readOnly:u,changesOpen:p}=t;const h=xN(),f=(0,vo.useRef)(null);return(0,vo.useLayoutEffect)((()=>{f.current=null}),[e]),(0,vo.useMemo)((()=>{const t=function(e){return NV(e)}({schemaType:e,document:i,fieldGroupState:r,collapsedFieldSets:o,collapsedPaths:s,value:i,comparisonValue:n,focusPath:a,openPath:l,readOnly:u,path:(0,xo.s6)([]),level:0,currentUser:h,presence:c,validation:d,changesOpen:p}),m=Gm(f.current,t);return f.current=m,m}),[e,i,r,o,s,n,a,l,u,h,c,d,p])}function VV(e){return e.map(HV)}function KV(e,t){return sl()(t.map((t=>function(e,t){return sl()(Object.keys(t).filter((n=["id","ifRevisionID","query"],e=>!n.includes(e))).map((n=>{if("unset"===n)return t.unset.map((t=>({type:"unset",path:rS(t),origin:e})));if("insert"===n){const n="before"in t.insert?"before":"after";return{type:"insert",position:n,path:rS(t.insert[n]),items:t.insert.items,origin:e}}return Object.keys(t[n]).map((i=>"set"===n?{type:"set",path:rS(i),value:t[n][i],origin:e}:"inc"===n||"dec"===n?{type:n,path:rS(i),value:t[n][i],origin:e}:"setIfMissing"===n?{type:"setIfMissing",path:rS(i),value:t[n][i],origin:e}:"diffMatchPatch"===n?{type:n,path:rS(i),value:t[n][i],origin:e}:(console.warn(new Error("Unsupported patch type: ".concat(n))),null))).filter(Boolean)})));var n}(e,t))))}function HV(e){if(e.patchType!==Cm&&e.type)throw new Error('Patch is missing "patchType" - import and use "'.concat(e.type,'()" from "sanity/form"'));if(e.patchType!==Cm)throw new Error('Patch is missing "patchType" - import and use the patch method helpers from "sanity/form"');const t=(0,rc.kC)(e.path||[]);if("insert"===e.type){const{position:n,items:i}=e;return{insert:{[n]:t,items:i}}}if("unset"===e.type)return{unset:[t]};if(!e.type)throw new Error("Missing patch type in patch ".concat(JSON.stringify(e)));return t?{[e.type]:{[t]:e.value}}:{[e.type]:e.value}}(0,vo.memo)((function(e){const{transform:t}=e,n=Wm(),i=(0,vo.useCallback)((e=>{const i=e.patches,r=t(i);n.onChange(Am.from(r))}),[n,t]),r=(0,vo.useMemo)((()=>({...n,onChange:i})),[n,i]);return(0,go.jsx)(Hm.Provider,{value:r,children:e.children})}));Co.Lg.fonts.code.family,Co.Lg.fonts.text.family,Vs.Sn.hex,Vs.ix.hex,Vs.iN[500].hex,Vs.ix.hex,Vs.Sn.hex,Vs.MA[500].hex,Vs.MA[500].hex,Vs.MA[500].hex,Vs.Q6[500].hex,Vs.iN[500].hex,Vs.ek[500].hex,Vs.er[500].hex,Vs.iN[500].hex,Vs.iN[500].hex,Vs.ek[500].hex,Vs.er[500].hex,Vs.Q6[500].hex,Vs.Sn.hex,Vs.ix.hex;Co.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.