sanity-plugin-media 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- const e=["onValueChange","value"];var t,n,i,a,l,o,r,s,d,c,u,p,h,g,m,y,f,v,b,x,C,w,I,T,k,_,S,R,E,z,A,O,D,q,j,L,F,U,P,M,N;function V(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},l=Object.keys(e);for(i=0;i<l.length;i++)n=l[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(i=0;i<l.length;i++)n=l[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}import{useClient as Y,useDocumentStore as $,WithReferringDocuments as W,useSchema as G,SanityPreview as K,useFormValue as Z,definePlugin as J}from"sanity";import{ThLargeIcon as ee,ThListIcon as te,SortIcon as ne,SelectIcon as ie,CloseIcon as ae,AddCircleIcon as le,SearchIcon as oe,PlugIcon as re,ClipboardIcon as se,DownloadIcon as de,ErrorOutlineIcon as ce,ChevronDownIcon as ue,AddIcon as pe,WarningOutlineIcon as he,EditIcon as ge,ArrowUpIcon as me,ArrowDownIcon as ye,TrashIcon as fe,ComposeIcon as ve,Icon as be,UploadIcon as xe,WarningFilledIcon as Ce,CheckmarkCircleIcon as we,ChevronUpIcon as Ie,ImageIcon as Te}from"@sanity/icons";import{jsx as ke,jsxs as _e,Fragment as Se}from"react/jsx-runtime";import{Inline as Re,Button as Ee,MenuButton as ze,Menu as Ae,MenuItem as Oe,MenuDivider as De,Box as qe,Flex as je,Label as Le,Text as Fe,TextInput as Ue,studioTheme as Pe,Card as Me,MenuGroup as Ne,useMediaIndex as Ve,Tooltip as Qe,Switch as Be,Popover as Xe,Stack as He,Dialog as Ye,TextArea as $e,TabList as We,Tab as Ge,TabPanel as Ke,Container as Ze,Spinner as Je,Checkbox as et,Grid as tt,useToast as nt,ThemeProvider as it,ToastProvider as at,useLayer as lt,PortalProvider as ot,Portal as rt}from"@sanity/ui";import{useRef as st,useEffect as dt,createContext as ct,useContext as ut,useState as pt,forwardRef as ht,useCallback as gt,memo as mt,Component as yt}from"react";import ft from"is-hotkey";import vt from"groq";import{useSelector as bt,useDispatch as xt,Provider as Ct}from"react-redux";import{createAction as wt,createSlice as It,createSelector as Tt,combineReducers as kt,configureStore as _t}from"@reduxjs/toolkit";import{nanoid as St}from"nanoid";import{ofType as Rt,combineEpics as Et,createEpicMiddleware as zt}from"redux-observable";import{iif as At,throwError as Ot,of as Dt,from as qt,empty as jt,Subject as Lt,Observable as Ft,merge as Ut}from"rxjs";import{delay as Pt,mergeMap as Mt,filter as Nt,withLatestFrom as Vt,catchError as Qt,switchMap as Bt,bufferTime as Xt,debounceTime as Ht,first as Yt,map as $t,takeUntil as Wt}from"rxjs/operators";import{hues as Gt,white as Kt,black as Zt}from"@sanity/color";import Jt,{css as en,createGlobalStyle as tn}from"styled-components";import nn from"pluralize";import{useNProgress as an}from"@tanem/react-nprogress";import ln,{components as on}from"react-select";import{Virtuoso as rn,VirtuosoGrid as sn,GroupedVirtuoso as dn}from"react-virtuoso";import{yupResolver as cn}from"@hookform/resolvers/yup";import{Controller as un,useForm as pn}from"react-hook-form";import*as hn from"yup";import gn from"date-fns/format";import mn from"filesize";import yn from"copy-to-clipboard";import{useIntentLink as fn}from"sanity/router";import{FileIcon as vn,defaultStyles as bn}from"react-file-icon";import xn from"react-select/creatable";import Cn from"date-fns/formatRelative";import{useDropzone as wn}from"react-dropzone";const In=(e,t)=>{const n=st(!1);function i(i){ft(e,i)&&(n.current=!0,t&&t())}const a=()=>{n.current=!1};return dt((()=>(window.addEventListener("keydown",i),window.addEventListener("keyup",a),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",a)})),[]),n},Tn={type:"divider"},kn={altText:{assetTypes:["file","image"],field:"altText",name:"altText",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Alt text",type:"string",value:""},description:{assetTypes:["file","image"],field:"description",name:"description",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Description",type:"string",value:""},fileName:{assetTypes:["file","image"],field:"originalFilename",name:"filename",operatorType:"includes",operatorTypes:["includes","doesNotInclude"],title:"File name",type:"string",value:""},height:{assetTypes:["image"],field:"metadata.dimensions.height",name:"height",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"Height",type:"number",value:400},inCurrentDocument:{assetTypes:["file","image"],name:"inCurrentDocument",operatorType:"is",options:[{name:"true",title:"True",value:vt(t||(t=H(["_id in $documentAssetIds"])))},{name:"false",title:"False",value:vt(n||(n=H(["!(_id in $documentAssetIds)"])))}],selectOnly:!0,title:"In use in current document",type:"select",value:"true"},inUse:{assetTypes:["file","image"],name:"inUse",operatorType:"is",options:[{name:"true",title:"True",value:vt(i||(i=H(["count(*[references(^._id)]) > 0"])))},{name:"false",title:"False",value:vt(a||(a=H(["count(*[references(^._id)]) == 0"])))}],title:"In use",type:"select",value:"true"},isOpaque:{assetTypes:["image"],field:"metadata.isOpaque",name:"isOpaque",operatorType:"equalTo",options:[{name:"true",title:"True",value:"false"},{name:"false",title:"False",value:"true"}],title:"Has transparency",type:"select",value:"true"},orientation:{assetTypes:["image"],name:"orientation",operatorType:"is",operatorTypes:["is","isNot"],options:[{name:"portrait",title:"Portrait",value:"metadata.dimensions.aspectRatio < 1"},{name:"landscape",title:"Landscape",value:"metadata.dimensions.aspectRatio > 1"},{name:"square",title:"Square",value:"metadata.dimensions.aspectRatio == 1"}],title:"Orientation",type:"select",value:"portrait"},size:{assetTypes:["file","image"],field:"size",modifier:"kb",modifiers:[{name:"kb",title:"KB",fieldModifier:e=>"round(".concat(e," / 1000)")},{name:"mb",title:"MB",fieldModifier:e=>"round(".concat(e," / 1000000)")}],name:"size",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"File size",type:"number",value:0},tag:{assetTypes:["file","image"],field:"opt.media.tags",name:"tag",operatorType:"references",operatorTypes:["references","doesNotReference",null,"empty","notEmpty"],title:"Tags",type:"searchable"},title:{assetTypes:["file","image"],field:"title",name:"title",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Title",type:"string",value:""},type:{assetTypes:["file","image"],name:"type",operatorType:"is",operatorTypes:["is","isNot"],options:[{name:"image",title:"Image",value:'mimeType match "image*"'},{name:"video",title:"Video",value:'mimeType match "video*"'},{name:"audio",title:"Audio",value:'mimeType match "audio*"'},{name:"pdf",title:"PDF",value:'mimeType == "application/pdf"'}],title:"File type",type:"select",value:"image"},width:{assetTypes:["image"],field:"metadata.dimensions.width",name:"width",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"Width",type:"number",value:400}},_n={doesNotInclude:{fn:(e,t)=>e?"!(".concat(t," match '*").concat(e,"*')"):void 0,label:"does not include"},doesNotReference:{fn:(e,t)=>e?"!references('".concat(e,"')"):void 0,label:"does not include"},empty:{fn:(e,t)=>"!defined(".concat(t,")"),hideInput:!0,label:"is empty"},equalTo:{fn:(e,t)=>e?"".concat(t," == ").concat(e):void 0,label:"is equal to"},greaterThan:{fn:(e,t)=>e?"".concat(t," > ").concat(e):void 0,label:"is greater than"},greaterThanOrEqualTo:{fn:(e,t)=>e?"".concat(t," >= ").concat(e):void 0,label:"is greater than or equal to"},includes:{fn:(e,t)=>e?"".concat(t," match '*").concat(e,"*'"):void 0,label:"includes"},is:{fn:(e,t)=>"".concat(e),label:"is"},isNot:{fn:(e,t)=>"!(".concat(e,")"),label:"is not"},lessThan:{fn:(e,t)=>e?"".concat(t," < ").concat(e):void 0,label:"is less than"},lessThanOrEqualTo:{fn:(e,t)=>e?"".concat(t," <= ").concat(e):void 0,label:"is less than or equal to"},notEmpty:{fn:(e,t)=>"defined(".concat(t,")"),hideInput:!0,label:"is not empty"},references:{fn:(e,t)=>e?"references('".concat(e,"')"):void 0,label:"includes"}},Sn=[{direction:"desc",field:"_createdAt"},{direction:"asc",field:"_createdAt"},null,{direction:"desc",field:"_updatedAt"},{direction:"asc",field:"_updatedAt"},null,{direction:"asc",field:"originalFilename"},{direction:"desc",field:"originalFilename"},null,{direction:"desc",field:"size"},{direction:"asc",field:"size"}],Rn=[kn.tag,Tn,kn.inUse,kn.inCurrentDocument,Tn,kn.title,kn.altText,kn.description,Tn,kn.isOpaque,Tn,kn.fileName,kn.size,kn.type,Tn,kn.orientation,kn.width,kn.height],En="3rem 100px auto 1.5rem",zn="3rem 100px auto 5.5rem 5.5rem 3.5rem 8.5rem 2rem",An=ct(void 0),On=e=>{const{children:t,onSelect:n}=e,i={onSelect:n};return ke(An.Provider,{value:i,children:t})},Dn=()=>{const e=ut(An);if(void 0===e)throw new Error("useAssetSourceActions must be used within an AssetSourceDispatchProvider");return e},qn=()=>Y({apiVersion:"2022-10-01"}),jn={_createdAt:{asc:"Last created: Oldest first",desc:"Last created: Newest first"},_updatedAt:{asc:"Last updated: Oldest first",desc:"Last updated: Newest first"},mimeType:{asc:"MIME type: A to Z",desc:"MIME type: Z to A"},originalFilename:{asc:"File name: A to Z",desc:"File name: Z to A"},size:{asc:"File size: Smallest first",desc:"File size: Largest first"}},Ln=(e,t)=>jn[e][t],Fn=e=>function(t){return At((()=>!!e),t.pipe(Pt(3e3),Mt((e=>Math.random()>.5?Ot({message:"Test error",statusCode:500}):Dt(e)))),t)},Un=e=>{let{assetTypes:t,searchFacets:n,searchQuery:i}=e;const a=t.map((e=>"sanity.".concat(e,"Asset"))),r=vt(l||(l=H(["\n _type in ",' && !(_id in path("drafts.**"))\n '])),JSON.stringify(a)),s=n.reduce(((e,t)=>{var n;if("number"===t.type){const{field:n,modifier:i,modifiers:a,operatorType:l,value:o}=t,r=_n[l],s=null==a?void 0:a.find((e=>e.name===i)),d=(null==s?void 0:s.fieldModifier)?s.fieldModifier(n):n,c=r.fn(o,d);c&&e.push(c)}if("searchable"===t.type){const{field:n,operatorType:i,value:a}=t,l=_n[i].fn(null==a?void 0:a.value,n);l&&e.push(l)}if("select"===t.type){const{field:i,operatorType:a,options:l,value:o}=t,r=_n[a],s=null==(n=null==l?void 0:l.find((e=>e.name===o)))?void 0:n.value,d=r.fn(s,i);d&&e.push(d)}if("string"===t.type){const{field:n,operatorType:i,value:a}=t,l=_n[i].fn(a,n);l&&e.push(l)}return e}),[]);return[r,...i?[vt(o||(o=H(["[_id, altText, assetId, description, originalFilename, title, url] match '*","*'"])),i.trim())]:[],...s].join(" && ")},Pn=(e,t)=>function(n){return n.pipe(Mt((()=>qt(e.fetch(vt(r||(r=H(['count(*[_type == "','" && name.current == $name])'])),"media.tag"),{name:t})))),Mt((e=>e>0?Ot({message:"Tag already exists",statusCode:409}):Dt(!0))))},Mn=e=>e.reduce(((e,t)=>{var n;const i=null==t?void 0:t.tag;return i&&e.push({label:null==(n=null==i?void 0:i.name)?void 0:n.current,value:null==i?void 0:i._id}),e}),[]),Nn={tagsAddComplete:wt("actions/tagsAddComplete",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsAddError:wt("actions/tagsAddError",(function(e){let{assets:t,error:n,tag:i}=e;return{payload:{assets:t,error:n,tag:i}}})),tagsAddRequest:wt("actions/tagsAddRequest",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsRemoveComplete:wt("actions/tagsRemoveComplete",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsRemoveError:wt("actions/tagsRemoveError",(function(e){let{assets:t,error:n,tag:i}=e;return{payload:{assets:t,error:n,tag:i}}})),tagsRemoveRequest:wt("actions/tagsRemoveRequest",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}}))},Vn={showTagCreate:wt("dialog/showTagCreate"),showTagEdit:wt("dialog/showTagEdit",(function(e){let{tagId:t}=e;return{payload:{tagId:t}}}))},Qn=It({name:"tags",initialState:{allIds:[],byIds:{},creating:!1,creatingError:void 0,fetchCount:-1,fetching:!1,fetchingError:void 0,panelVisible:!0},extraReducers:e=>{e.addCase(Vn.showTagCreate,(e=>{delete e.creatingError})).addCase(Vn.showTagEdit,((e,t)=>{const{tagId:n}=t.payload;delete e.byIds[n].error})).addMatcher((e=>[Nn.tagsAddComplete.type,Nn.tagsAddError.type,Nn.tagsRemoveComplete.type,Nn.tagsRemoveError.type].includes(e.type)),((e,t)=>{const{tag:n}=t.payload;e.byIds[n._id].updating=!1})).addMatcher((e=>[Nn.tagsAddRequest.type,Nn.tagsRemoveRequest.type].includes(e.type)),((e,t)=>{const{tag:n}=t.payload;e.byIds[n._id].updating=!0}))},reducers:{createComplete(e,t){const{tag:n}=t.payload;e.creating=!1,e.allIds.includes(n._id)||e.allIds.push(n._id),e.byIds[n._id]={_type:"tag",picked:!1,tag:n,updating:!1}},createError(e,t){e.creating=!1,e.creatingError=t.payload.error},createRequest(e,t){e.creating=!0,delete e.creatingError},deleteComplete(e,t){const{tagId:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),delete e.byIds[n]},deleteError(e,t){const{error:n,tag:i}=t.payload,a=null==i?void 0:i._id;e.byIds[a].error=n,e.byIds[a].updating=!1},deleteRequest(e,t){var n,i;const a=null==(i=null==(n=t.payload)?void 0:n.tag)?void 0:i._id;e.byIds[a].picked=!1,e.byIds[a].updating=!0,Object.keys(e.byIds).forEach((t=>{delete e.byIds[t].error}))},fetchComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.allIds.push(t._id),e.byIds[t._id]={_type:"tag",picked:!1,tag:t,updating:!1}})),e.fetching=!1,e.fetchCount=n.length||0,delete e.fetchingError},fetchError(e,t){const{error:n}=t.payload;e.fetching=!1,e.fetchingError=n},fetchRequest:{reducer:(e,t)=>{e.fetching=!0,delete e.fetchingError},prepare:()=>({payload:{query:vt(s||(s=H(['\n {\n "items": *[\n _type == "','"\n && !(_id in path("drafts.**"))\n ] {\n _createdAt,\n _updatedAt,\n _id,\n _rev,\n _type,\n name\n } | order(name.current asc),\n }\n '])),"media.tag")}})},listenerCreateQueue(e,t){},listenerCreateQueueComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.byIds[t._id]={_type:"tag",picked:!1,tag:t,updating:!1},e.allIds.includes(t._id)||e.allIds.push(t._id)}))},listenerDeleteQueue(e,t){},listenerDeleteQueueComplete(e,t){const{tagIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]}))},listenerUpdateQueue(e,t){},listenerUpdateQueueComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.byIds[t._id]&&(e.byIds[t._id].tag=t)}))},panelVisibleSet(e,t){const{panelVisible:n}=t.payload;e.panelVisible=n},sort(e){e.allIds.sort(((t,n)=>{const i=e.byIds[t].tag.name.current,a=e.byIds[n].tag.name.current;return i<a?-1:i>a?1:0}))},updateComplete(e,t){const{tag:n}=t.payload;e.byIds[n._id].tag=n,e.byIds[n._id].updating=!1},updateError(e,t){const{error:n,tag:i}=t.payload,a=null==i?void 0:i._id;e.byIds[a].error=n,e.byIds[a].updating=!1},updateRequest(e,t){const{tag:n}=t.payload;e.byIds[null==n?void 0:n._id].updating=!0}}}),Bn=e=>e.tags.byIds,Xn=Tt([Bn,e=>e.tags.allIds],((e,t)=>t.map((t=>e[t])))),Hn=Tt([Bn,(e,t)=>t],((e,t)=>e[t])),Yn=Qn.actions;var $n=Qn.reducer;const Wn=It({name:"search",initialState:{facets:[],query:""},reducers:{facetsAdd(e,t){e.facets.push(t.payload.facet)},facetsClear(e){e.facets=[]},facetsRemove(e,t){e.facets=e.facets.filter((e=>e.name!==t.payload.facetName))},facetsUpdate(e,t){const{modifier:n,name:i,operatorType:a,value:l}=t.payload;e.facets.forEach(((t,o)=>{t.name===i&&("number"===t.type&&n&&(t.modifier=n),a&&(t.operatorType=a),void 0!==l&&(e.facets[o].value=l))}))},querySet(e,t){var n;e.query=null==(n=t.payload)?void 0:n.searchQuery}}}),Gn=Tt((e=>e.search.facets),(e=>!!(null==e?void 0:e.find((e=>"tag"===e.name))))),Kn=Tt([e=>e.tags.byIds,e=>e.search.facets,(e,t)=>t],((e,t,n)=>{var i,a,l;const o=null==t?void 0:t.find((e=>"tag"===e.name));if("searchable"===(null==o?void 0:o.type)){const t=null==(i=o.value)?void 0:i.value;if(t)return(null==(l=null==(a=e[t])?void 0:a.tag)?void 0:l._id)===n&&"references"===(null==o?void 0:o.operatorType)}return!1})),Zn=Wn.actions;var Jn=Wn.reducer;const ei={uploadComplete:wt("uploads/uploadComplete",(function(e){let{asset:t}=e;return{payload:{asset:t}}}))},ti=Sn[0],ni={allIds:[],assetTypes:[],byIds:{},fetchCount:-1,fetching:!1,fetchingError:void 0,lastPicked:void 0,order:{direction:ti.direction,field:ti.field,title:Ln(ti.field,ti.direction)},pageIndex:0,pageSize:50,view:"grid"},ii=It({name:"assets",initialState:ni,extraReducers:e=>{e.addCase(ei.uploadComplete,((e,t)=>{const{asset:n}=t.payload;e.byIds[n._id]={_type:"asset",asset:n,picked:!1,updating:!1}})).addCase(Nn.tagsAddComplete,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsAddError,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsAddRequest,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!0}))})).addCase(Nn.tagsRemoveComplete,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsRemoveError,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsRemoveRequest,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!0}))}))},reducers:{clear(e){e.allIds=[]},deleteComplete(e,t){const{assetIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]})),e.pageIndex=Math.floor(e.allIds.length/e.pageSize)-1},deleteError(e,t){var n,i,a,l;const{assetIds:o,error:r}=t.payload,s=null==(l=null==(a=null==(i=null==(n=null==r?void 0:r.response)?void 0:n.body)?void 0:i.error)?void 0:a.items)?void 0:l.map((e=>e.error));null==o||o.forEach((t=>{e.byIds[t].updating=!1})),null==s||s.forEach((t=>{e.byIds[t.id].error=t.description}))},deleteRequest(e,t){const{assets:n}=t.payload;n.forEach((t=>{e.byIds[null==t?void 0:t._id].updating=!0})),Object.keys(e.byIds).forEach((t=>{delete e.byIds[t].error}))},fetchComplete(e,t){var n;const i=(null==(n=t.payload)?void 0:n.assets)||[];i&&i.forEach((t=>{e.allIds.includes(t._id)||e.allIds.push(t._id),e.byIds[t._id]={_type:"asset",asset:t,picked:!1,updating:!1}})),e.fetching=!1,e.fetchCount=i.length||0,delete e.fetchingError},fetchError(e,t){const n=t.payload;e.fetching=!1,e.fetchingError=n},fetchRequest:{reducer:(e,t)=>{e.fetching=!0,delete e.fetchingError},prepare:e=>{let{params:t={},queryFilter:n,selector:i="",sort:a=vt(c||(c=H(["order(_updatedAt desc)"])))}=e;const l=a||i?"|":"";return{payload:{params:t,query:vt(u||(u=H(['\n {\n "items": *[',"] {\n _id,\n _type,\n _createdAt,\n _updatedAt,\n altText,\n description,\n extension,\n metadata {\n dimensions,\n exif,\n isOpaque,\n },\n mimeType,\n opt {\n media\n },\n originalFilename,\n size,\n title,\n url\n } "," "," ",",\n }\n "])),n,l,a,i)}}}},insertUploads(e,t){const{results:n}=t.payload;Object.entries(n).forEach((t=>{let[n,i]=t;i&&!e.allIds.includes(n)&&e.allIds.push(i)}))},listenerCreateQueue(e,t){},listenerCreateQueueComplete(e,t){const{assets:n}=t.payload;null==n||n.forEach((t=>{var n;(null==(n=e.byIds[null==t?void 0:t._id])?void 0:n.asset)&&(e.byIds[t._id].asset=t)}))},listenerDeleteQueue(e,t){},listenerDeleteQueueComplete(e,t){const{assetIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]}))},listenerUpdateQueue(e,t){},listenerUpdateQueueComplete(e,t){const{assets:n}=t.payload;null==n||n.forEach((t=>{var n;(null==(n=e.byIds[null==t?void 0:t._id])?void 0:n.asset)&&(e.byIds[t._id].asset=t)}))},loadNextPage(){},loadPageIndex(e,t){e.pageIndex=t.payload.pageIndex},orderSet(e,t){var n;e.order=null==(n=t.payload)?void 0:n.order,e.pageIndex=0},pick(e,t){const{assetId:n,picked:i}=t.payload;e.byIds[n].picked=i,e.lastPicked=i?n:void 0},pickAll(e){e.allIds.forEach((t=>{e.byIds[t].picked=!0}))},pickClear(e){e.lastPicked=void 0,Object.values(e.byIds).forEach((t=>{e.byIds[t.asset._id].picked=!1}))},pickRange(e,t){const n=e.allIds.findIndex((e=>e===t.payload.startId)),i=e.allIds.findIndex((e=>e===t.payload.endId)),a=[n,i].sort(((e,t)=>e-t));e.allIds.slice(a[0],a[1]+1).forEach((t=>{e.byIds[t].picked=!0})),e.lastPicked=e.allIds[i]},sort(e){e.allIds.sort(((t,n)=>{const i=e.byIds[t].asset[e.order.field],a=e.byIds[n].asset[e.order.field];return i<a?"asc"===e.order.direction?-1:1:i>a?"asc"===e.order.direction?1:-1:0}))},updateComplete(e,t){const{asset:n}=t.payload;e.byIds[n._id].updating=!1,e.byIds[n._id].asset=n},updateError(e,t){const{asset:n,error:i}=t.payload,a=null==n?void 0:n._id;e.byIds[a].error=i.message,e.byIds[a].updating=!1},updateRequest(e,t){var n,i;const a=null==(i=null==(n=t.payload)?void 0:n.asset)?void 0:i._id;e.byIds[a].updating=!0},viewSet(e,t){var n;e.view=null==(n=t.payload)?void 0:n.view}}}),ai=Tt([e=>e.assets.byIds,(e,t)=>t],((e,t)=>e[t])),li=Tt([e=>e.assets.byIds,e=>e.assets.allIds],((e,t)=>t.map((t=>e[t])))),oi=Tt([li],(e=>e.length)),ri=Tt([li],(e=>e.filter((e=>null==e?void 0:e.picked)))),si=Tt([ri],(e=>e.length)),di=ii.actions;var ci,ui,pi=ii.reducer;const hi=en(m||(m=H(["\n ::-webkit-scrollbar {\n width: 14px;\n }\n\n ::-webkit-scrollbar-thumb {\n border-radius: 10px;\n border: 4px solid rgba(0, 0, 0, 0);\n background: ",";\n background-clip: padding-box;\n\n &:hover {\n background: ",";\n background-clip: padding-box;\n }\n }\n"])),null==(ci=Gt.gray)?void 0:ci[800].hex,null==(ui=Gt.gray)?void 0:ui[400].hex),gi=tn(y||(y=H(["\n .media__custom-scrollbar {\n ",'\n }\n\n // @sanity/ui overrides\n\n // Custom scrollbar on Box (used in Dialogs)\n div[data-ui="Box"] {\n ','\n }\n\n // Dialog background color\n div[data-ui="Dialog"] {\n background-color: rgba(15, 17, 18, 0.9);\n }\n\n'])),hi,hi),mi=bt,yi=It({name:"dialog",initialState:{items:[]},extraReducers:e=>{e.addCase(Vn.showTagCreate,(e=>{e.items.push({id:"tagCreate",type:"tagCreate"})})),e.addCase(Vn.showTagEdit,((e,t)=>{const{tagId:n}=t.payload;e.items.push({id:n,tagId:n,type:"tagEdit"})}))},reducers:{clear(e){e.items=[]},inlineTagCreate(e,t){const{assetId:n,tag:i}=t.payload;e.items.forEach((e=>{"assetEdit"===e.type&&e.assetId===n&&(e.lastCreatedTag={label:i.name.current,value:i._id})}))},inlineTagRemove(e,t){const{tagIds:n}=t.payload;e.items.forEach((e=>{"assetEdit"===e.type&&(e.lastRemovedTagIds=n)}))},remove(e,t){var n;const i=null==(n=t.payload)?void 0:n.id;e.items=e.items.filter((e=>e.id!==i))},showConfirmAssetsTagAdd(e,t){const{assetsPicked:n,closeDialogId:i,tag:a}=t.payload,l="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:Nn.tagsAddRequest({assets:n,tag:a}),confirmText:"Yes, add tag to ".concat(l),title:"Add tag ".concat(a.name.current," to ").concat(l,"?"),id:"confirm",headerTitle:"Confirm tag addition",tone:"primary",type:"confirm"})},showConfirmAssetsTagRemove(e,t){const{assetsPicked:n,closeDialogId:i,tag:a}=t.payload,l="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:Nn.tagsRemoveRequest({assets:n,tag:a}),confirmText:"Yes, remove tag from ".concat(l),headerTitle:"Confirm tag removal",id:"confirm",title:"Remove tag ".concat(a.name.current," from ").concat(l,"?"),tone:"critical",type:"confirm"})},showConfirmDeleteAssets(e,t){const{assets:n,closeDialogId:i}=t.payload,a="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:di.deleteRequest({assets:n.map((e=>e.asset))}),confirmText:"Yes, delete ".concat(a),description:"This operation cannot be reversed. Are you sure you want to continue?",title:"Permanently delete ".concat(a,"?"),id:"confirm",headerTitle:"Confirm deletion",tone:"critical",type:"confirm"})},showConfirmDeleteTag(e,t){const{closeDialogId:n,tag:i}=t.payload;e.items.push({closeDialogId:n,confirmCallbackAction:Yn.deleteRequest({tag:i}),confirmText:"Yes, delete ".concat("tag"),description:"This operation cannot be reversed. Are you sure you want to continue?",title:"Permanently delete ".concat("tag","?"),id:"confirm",headerTitle:"Confirm deletion",tone:"critical",type:"confirm"})},showAssetEdit(e,t){const{assetId:n}=t.payload;e.items.push({assetId:n,id:n,type:"assetEdit"})},showSearchFacets(e){e.items.push({id:"searchFacets",type:"searchFacets"})},showTags(e){e.items.push({id:"tags",type:"tags"})}}}),fi=yi.actions;var vi=yi.reducer;const bi=()=>{const e=xt(),t=mi((e=>e.assets.view));return _e(Re,{space:0,style:{whiteSpace:"nowrap"},children:[ke(Ee,{fontSize:1,icon:ee,mode:"grid"===t?"default":"ghost",onClick:()=>e(di.viewSet({view:"grid"})),style:{borderBottomRightRadius:0,borderTopRightRadius:0}}),ke(Ee,{fontSize:1,icon:te,mode:"table"===t?"default":"ghost",onClick:()=>e(di.viewSet({view:"table"})),style:{borderBottomLeftRadius:0,borderTopLeftRadius:0}})]})},xi=()=>{var e;const t=xt(),n=mi((e=>e.assets.order));return ke(ze,{button:ke(Ee,{fontSize:1,icon:ne,iconRight:ie,mode:"ghost",padding:3,text:Ln(n.field,n.direction)}),id:"order",menu:ke(Ae,{children:null==(e=Sn)?void 0:e.map(((e,i)=>e?ke(Oe,{disabled:n.field===e.field&&n.direction===e.direction,fontSize:1,onClick:()=>t(di.orderSet({order:{direction:e.direction,field:e.field}})),padding:2,text:Ln(e.field,e.direction)},i):ke(De,{},i)))})})},Ci=e=>{const{loading:t}=e,{animationDuration:n,isFinished:i,progress:a}=an({animationDuration:300,isAnimating:t});return ke(qe,{style:{opacity:i?0:1,transition:"opacity ".concat(n,"ms linear")},children:ke(qe,{style:{height:"1px",background:"rgba(255, 255, 255, 0.5)",position:"absolute",left:0,top:0,transition:"width ".concat(n,"ms linear"),width:"".concat(100*a,"%")}})})},wi=Jt(qe)(f||(f=H(["\n background: rgba(255, 255, 255, 0.05);\n border-radius: ","px;\n"])),(e=>e.theme.sanity.radius[2])),Ii=e=>{const{children:t,facet:n}=e,i=xt();return ke(wi,{padding:[2,2,1],children:_e(je,{align:["flex-start","flex-start","center"],direction:["column","column","row"],children:[ke(qe,{paddingBottom:[3,3,0],paddingLeft:1,paddingRight:2,paddingTop:[1,1,0],children:ke(Le,{size:0,style:{whiteSpace:"nowrap"},children:n.title})}),_e(je,{align:"center",children:[t,ke(qe,{marginLeft:1,paddingX:2,children:ke(Fe,{muted:!0,size:0,children:ke(ae,{onClick:()=>{i(Zn.facetsRemove({facetName:n.name}))}})})})]})]})})},Ti=t=>{const{onValueChange:n,value:i}=t,a=V(t,e);return ke(Ue,B(B({},a),{},{onChange:e=>{const t=e.target.value;(""===t||/^[0-9\b]+$/.test(t))&&n(parseInt(t,10)||"")},value:null!=i?i:""}))},ki=e=>{var t;const{facet:n}=e,i=xt(),a=null==n?void 0:n.modifiers,l=(null==n?void 0:n.modifier)?null==a?void 0:a.find((e=>e.name===(null==n?void 0:n.modifier))):null==a?void 0:a[0],o=null!=(t=n.operatorType)?t:"greaterThan";return _e(Ii,{facet:n,children:[(null==n?void 0:n.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[o].label}),id:"operators",menu:ke(Ae,{children:n.operatorTypes.map(((e,t)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},t)))})}),ke(qe,{marginX:1,style:{maxWidth:"50px"},children:ke(Ti,{fontSize:1,onValueChange:e=>{i(Zn.facetsUpdate({name:n.name,value:e}))},padding:2,radius:2,width:2,value:null==n?void 0:n.value})}),a&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:null==l?void 0:l.title}),id:"modifier",menu:ke(Ae,{children:a.map((e=>ke(Oe,{disabled:e.name===n.modifier,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,modifier:e.name}))})(e),padding:2,text:e.title},e.name)))})})]})},_i=e=>{var t;const{facet:n}=e,i=xt(),a=null==n?void 0:n.options,l=null==a?void 0:a.find((e=>e.name===(null==n?void 0:n.value))),o=null!=(t=null==n?void 0:n.operatorType)?t:"is";return _e(Ii,{facet:n,children:[(null==n?void 0:n.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,style:{marginRight:"4px"},text:_n[o].label}),id:"operators",menu:ke(Ae,{children:n.operatorTypes.map(((e,t)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},t)))})}),ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:null==l?void 0:l.title}),id:"list",menu:ke(Ae,{children:null==a?void 0:a.map(((e,t)=>ke(Oe,{disabled:e.name===(null==l?void 0:l.name),fontSize:1,onClick:()=>{return e=a[t],void i(Zn.facetsUpdate({name:n.name,value:e.name}));var e},padding:2,text:e.title},e.name)))})})]})},Si=e=>{const{facet:t}=e,n=xt(),i=t.operatorType;return _e(Ii,{facet:t,children:[(null==t?void 0:t.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[i].label}),id:"operators",menu:ke(Ae,{children:t.operatorTypes.map(((e,a)=>e?ke(Oe,{disabled:e===i,fontSize:1,onClick:()=>(e=>{n(Zn.facetsUpdate({name:t.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},a)))})}),!_n[i].hideInput&&ke(qe,{marginLeft:1,style:{maxWidth:"125px"},children:ke(Ue,{fontSize:1,onChange:e=>{n(Zn.facetsUpdate({name:t.name,value:e.target.value}))},padding:2,radius:2,width:2,value:null==t?void 0:t.value})})]})};var Ri,Ei,zi,Ai,Oi,Di,qi,ji,Li,Fi,Ui,Pi,Mi,Ni,Vi;const Qi=null==(Oi=null==(Ai=null==(zi=null==(Ei=null==(Ri=Pe)?void 0:Ri.color)?void 0:Ei.dark)?void 0:zi.primary)?void 0:Ai.spot)?void 0:Oi.blue,Bi=null==(Fi=null==(Li=null==(ji=null==(qi=null==(Di=Pe)?void 0:Di.color)?void 0:qi.dark)?void 0:ji.default)?void 0:Li.base)?void 0:Fi.bg,Xi=null==(Ui=Pe)?void 0:Ui.radius,Hi=null==(Pi=Pe)?void 0:Pi.space,Yi=null==(Vi=null==(Ni=null==(Mi=Pe)?void 0:Mi.fonts)?void 0:Ni.text)?void 0:Vi.sizes,$i={control:(e,t)=>{let{isDisabled:n,isFocused:i}=t,a="inset 0 0 0 1px ".concat(Gt.gray[900].hex);return i&&(a="inset 0 0 0 1px ".concat(Gt.gray[900].hex,", 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important")),B(B({},e),{},{backgroundColor:Bi,color:Kt.hex,border:"none",borderRadius:Xi[2],boxShadow:a,fontSize:Yi[1].fontSize,minHeight:"25px",opacity:n?.5:"inherit",outline:"none",transition:"none","&:hover":{boxShadow:"inset 0 0 0 1px ".concat(Pe.color.dark.default.input.default.hovered.border)}})},input:e=>B(B({},e),{},{color:Kt.hex,fontFamily:Pe.fonts.text.family,marginLeft:Hi[2]}),menuList:e=>B(B({},e),{},{padding:0}),noOptionsMessage:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,fontSize:Yi[1].fontSize,lineHeight:"1em"}),option:(e,t)=>{let{isFocused:n}=t;return B(B({},e),{},{backgroundColor:n?Qi:"transparent",borderRadius:Xi[2],color:n?Zt.hex:"inherit",fontSize:Yi[1].fontSize,lineHeight:"1em",padding:"4px 6px","&:hover":{backgroundColor:Qi,color:Zt.hex}})},placeholder:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,marginLeft:Hi[2],paddingBottom:"2px"}),singleValue:e=>B(B({},e),{},{color:Kt.hex,lineHeight:"1em",paddingBottom:"1px"}),valueContainer:e=>B(B({},e),{},{margin:0,padding:0})},Wi=e=>ke(qe,{padding:1,children:ke(on.Option,B(B({},e),{},{children:ke(qe,{paddingY:1,children:ke(Fe,{size:1,style:{color:"inherit"},textOverflow:"ellipsis",children:e.children})})}))}),Gi={ClearIndicator:e=>ke(on.ClearIndicator,B(B({},e),{},{children:ke(qe,{paddingRight:1,style:{transform:"scale(0.85)"},children:ke(Fe,{muted:!0,size:0,children:ke(ae,{})})})})),DropdownIndicator:null,IndicatorSeparator:null,Menu:e=>ke(on.Menu,B(B({},e),{},{children:ke(Me,{radius:1,shadow:2,children:e.children})})),MenuList:e=>{const{children:t}=e;if(Array.isArray(t)){const e=t.length>5?165:33*t.length;return ke(rn,{className:"media__custom-scrollbar",itemContent:e=>{const n=t[e];return ke(Wi,B({},n.props))},style:{height:e},totalCount:t.length})}return ke(on.MenuList,B(B({},e),{},{children:t}))},NoOptionsMessage:e=>ke(on.NoOptionsMessage,B(B({},e),{},{children:e.children})),Option:Wi,SingleValue:e=>ke(on.SingleValue,B(B({},e),{},{children:ke(qe,{paddingLeft:2,children:ke(Fe,{size:1,style:{color:"inherit",lineHeight:"2em"},textOverflow:"ellipsis",children:e.children})})}))},Ki=e=>{const{facet:t}=e,n=xt(),i=mi((e=>Xn(e))),a=mi((e=>e.tags.fetching)),l=Mn(i),o=t.operatorType;return _e(Ii,{facet:t,children:[(null==t?void 0:t.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[o].label}),id:"operators",menu:ke(Ae,{children:t.operatorTypes.map(((e,i)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{n(Zn.facetsUpdate({name:t.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},i)))})}),!_n[o].hideInput&&ke(qe,{marginX:1,style:{width:"160px"},children:ke(ln,{components:Gi,instanceId:"facet-searchable",isClearable:!0,isDisabled:a,isSearchable:!0,name:"tags",noOptionsMessage:()=>"No tags",onChange:e=>{return i=e,void n(Zn.facetsUpdate({name:t.name,value:i}));var i},options:l,placeholder:a?"Loading...":"Select...",styles:$i,value:null==t?void 0:t.value})})]})},Zi=Jt(je)(v||(v=H(["\n > * {\n margin-bottom: ","px;\n }\n"])),(e=>e.theme.sanity.space[2])),Ji=e=>{const{layout:t="inline"}=e,n=mi((e=>e.search.facets)),i=n.map((e=>"number"===e.type?ke(ki,{facet:e},e.name):"searchable"===e.type?ke(Ki,{facet:e},e.name):"select"===e.type?ke(_i,{facet:e},e.name):"string"===e.type?ke(Si,{facet:e},e.name):null));if("inline"===t)return 0===n.length?null:ke(qe,{marginBottom:2,children:ke(Re,{space:2,children:i})});if("stack"===t)return ke(Zi,{align:"flex-start",direction:"column",children:i});throw Error("Invalid layout")},ea=()=>{const e=xt(),t=mi((e=>e.assets.assetTypes)),n=mi((e=>e.search.facets)),i=!mi((e=>e.selected.document)),a=Rn.filter((e=>{if("group"===e.type||"divider"===e.type)return!0;if(i)return!(null==e?void 0:e.selectOnly);return e.assetTypes.filter((e=>t.includes(e))).length>0})).filter(((e,t,n)=>{const i=n[t-1];return("divider"!==e.type||0!==t&&t!==n.length-1)&&("divider"!==e.type||"divider"!==(null==i?void 0:i.type))})),l=a.filter((e=>e)).length-n.length>0,o=function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ke(Se,{children:null==t?void 0:t.map(((t,a)=>{if("divider"===t.type)return ke(De,{},a);if("group"===t.type)return ke(Ne,{text:t.title,title:t.title,children:o(t.facets,i+1)},"group-".concat(i,"-").concat(a));if(t){const i=!!n.find((e=>e.name===t.name));return ke(Oe,{disabled:i,fontSize:1,onClick:()=>e(Zn.facetsAdd({facet:t})),padding:2,text:t.title},t.name)}return null}))})};return _e(je,{children:[ke(ze,{button:ke(Ee,{disabled:!l,fontSize:1,icon:le,mode:"bleed",text:"Add filter",tone:"primary"}),id:"facets",menu:ke(Ae,{children:o(a)}),placement:"right-start",portal:!0}),n.length>0&&ke(Ee,{fontSize:1,mode:"bleed",onClick:()=>e(Zn.facetsClear()),text:"Clear"})]})},ta=()=>_e("svg",{"data-sanity-icon":"media__tag",fill:"currentColor",height:"1em",stroke:"currentColor",strokeWidth:"0",viewBox:"0 0 512 512",width:"1em",children:[ke("path",{d:"M435.25 48h-122.9a14.46 14.46 0 00-10.2 4.2L56.45 297.9a28.85 28.85 0 000 40.7l117 117a28.85 28.85 0 0040.7 0L459.75 210a14.46 14.46 0 004.2-10.2v-123a28.66 28.66 0 00-28.7-28.8z",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32"}),ke("path",{d:"M384 160a32 32 0 1132-32 32 32 0 01-32 32z"})]}),na=()=>{const e=mi((e=>e.search.query)),t=xt();return _e(qe,{style:{position:"relative"},children:[ke(Ue,{fontSize:1,icon:oe,onChange:e=>{t(Zn.querySet({searchQuery:e.currentTarget.value}))},placeholder:"Search",radius:2,value:e}),e.length>0&&ke(je,{align:"center",justify:"center",onClick:()=>{t(Zn.querySet({searchQuery:""}))},style:{cursor:"pointer",height:"100%",opacity:.75,position:"absolute",right:0,top:0,width:"2em",zIndex:1},children:ke(ae,{})})]})},ia=()=>{var e;const t=xt(),n=mi((e=>e.assets.fetching)),i=mi((e=>e.assets.pageIndex)),a=mi((e=>e.search.facets)),l=mi((e=>e.tags.panelVisible)),o=Ve();return _e(qe,{paddingY:2,style:{borderBottom:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),zIndex:2},children:[ke(qe,{marginBottom:2,children:ke(je,{align:"flex-start",direction:["column","column","column","column","row"],justify:"space-between",children:_e(je,{flex:1,style:{alignItems:"flex-start",flex:1,height:"100%",justifyContent:o<2?"space-between":"flex-start",position:"relative",width:"100%"},children:[ke(qe,{marginX:2,style:{minWidth:"200px"},children:ke(na,{})}),_e(qe,{display:["none","none","block"],children:[ke(Ji,{}),ke(ea,{})]}),ke(qe,{display:["block","block","none"],marginX:2,children:_e(Re,{space:2,style:{whiteSpace:"nowrap"},children:[ke(Ee,{fontSize:1,mode:"ghost",onClick:()=>{t(fi.showSearchFacets())},text:"Filters".concat(a.length>0?" (".concat(a.length,")"):""),tone:"primary"}),ke(Ee,{fontSize:1,mode:"ghost",onClick:()=>{t(fi.showTags())},text:"Tags",tone:"primary"})]})})]})})}),ke(qe,{children:_e(je,{align:"center",justify:["space-between"],children:[ke(qe,{marginX:2,children:ke(bi,{})}),_e(je,{marginX:2,children:[ke(xi,{}),ke(qe,{display:["none","none","block"],marginLeft:2,children:ke(Ee,{fontSize:1,icon:ke(qe,{style:{transform:"scale(0.75)"},children:ke(ta,{})}),onClick:()=>{t(Yn.panelVisibleSet({panelVisible:!l}))},mode:l?"default":"ghost",text:l?"Tags":""})})]})]})}),ke(Ci,{loading:n},i)]})},aa=It({name:"debug",initialState:{badConnection:!1,enabled:!1},reducers:{setBadConnection(e,t){e.badConnection=t.payload},toggleEnabled(e){e.enabled=!e.enabled}}}),la=aa.actions;var oa=aa.reducer;const ra=()=>{const e=xt(),t=mi((e=>e.debug.badConnection)),n=mi((e=>e.debug.enabled));return In("alt+ctrl+shift+/",(()=>{e(la.toggleEnabled())})),n?ke(qe,{padding:4,style:{bottom:0,left:0,pointerEvents:"none",position:"fixed",width:"100%"},children:_e(je,{align:"center",children:[ke(qe,{marginRight:3,children:ke(Fe,{muted:!0,size:1,children:ke(re,{})})}),ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:t?"Bad connection: +3000ms & 50% chance to fail":"No connection throttling"})}),fallbackPlacements:["right","left"],placement:"bottom",children:ke(Be,{checked:t,onChange:t=>{const n=t.target.checked;e(la.setBadConnection(n))},style:{pointerEvents:"auto"}})})]})}):null},sa=(e,t)=>{const n="undefined"!=typeof window&&window.devicePixelRatio?Math.round(window.devicePixelRatio):1,i=(null==t?void 0:t.height)?(null==t?void 0:t.height)*Math.max(1,n):void 0,a=t.width*Math.max(1,n),l=new URLSearchParams;return l.append("fit","max"),l.append("w",a.toString()),i&&l.append("h",i.toString()),"".concat(e.url,"?").concat(l.toString())},da=e=>Object.keys(e).reduce(((t,n)=>{const i=e[n];return"object"==typeof i&&null!==i&&i.constructor!==Array?t[n]=da(i):""===i||void 0===i||0===(null==i?void 0:i.length)?t[n]=null:t[n]="string"==typeof i&&i?e[n].trim():e[n],t}),{}),ca=e=>"sanity.fileAsset"===e._type,ua=e=>"sanity.imageAsset"===e._type,pa=e=>"".concat(e.metadata.dimensions.width,"x").concat(e.metadata.dimensions.height,"px"),ha=e=>{const{disabled:t,url:n}=e,i=st(),[a,l]=pt(!1);return dt((()=>()=>{i.current&&clearTimeout(i.current)}),[]),ke(Xe,{content:ke(Fe,{muted:!0,size:1,children:"Copied!"}),open:a,padding:2,placement:"top",radius:1,children:ke(Ee,{disabled:t,fontSize:1,icon:se,mode:"ghost",onClick:()=>{i.current&&clearTimeout(i.current),l(!0),yn(n),i.current=setTimeout((()=>{l(!1)}),1250)},text:"Copy URL"})})},ga=e=>{let{label:t,value:n}=e;return _e(je,{justify:"space-between",children:[ke(Fe,{size:1,style:{opacity:.8,width:"40%"},textOverflow:"ellipsis",children:t}),ke(Fe,{size:1,style:{opacity:.4,textAlign:"right",width:"60%"},textOverflow:"ellipsis",children:n})]})},ma=e=>{var t;const{asset:n,item:i}=e,a=null==(t=null==n?void 0:n.metadata)?void 0:t.exif;return _e(qe,{marginTop:3,children:[ke(qe,{children:_e(He,{space:3,children:[ke(ga,{label:"Size",value:mn(null==n?void 0:n.size,{base:10,round:0})}),ke(ga,{label:"MIME type",value:null==n?void 0:n.mimeType}),ke(ga,{label:"Extension",value:(null==n?void 0:n.extension).toUpperCase()}),ua(n)&&ke(ga,{label:"Dimensions",value:pa(n)})]})}),a&&_e(Se,{children:[ke(qe,{marginY:4,style:{background:"#222",height:"1px",width:"100%"}}),ke(qe,{children:_e(He,{space:3,children:[a.ISO&&ke(ga,{label:"ISO",value:a.ISO}),a.FNumber&&ke(ga,{label:"Aperture",value:"ƒ/".concat(a.FNumber)}),a.FocalLength&&ke(ga,{label:"Focal length",value:"".concat(a.FocalLength,"mm")}),a.ExposureTime&&ke(ga,{label:"Exposure time",value:"1/".concat(1/a.ExposureTime)}),a.DateTimeOriginal&&ke(ga,{label:"Original date",value:gn(new Date(a.DateTimeOriginal),"PPp")})]})})]}),ke(qe,{marginTop:5,children:_e(Re,{space:2,children:[ke(Ee,{disabled:!i||(null==i?void 0:i.updating),fontSize:1,icon:de,mode:"ghost",onClick:()=>{window.location.href="".concat(n.url,"?dl=").concat(n.originalFilename)},text:"Download"}),ke(ha,{disabled:!i||(null==i?void 0:i.updating),url:n.url})]})})]})},ya=e=>ke(Ye,B(B({},e),{},{style:{position:"fixed"}})),fa=e=>{const{assetId:t}=e,n=$();return ke(W,{documentStore:n,id:t,children:e=>{let{isLoading:t,referringDocuments:n}=e;return ke(va,{isLoading:t,referringDocuments:n})}})},va=e=>{const{isLoading:t,referringDocuments:n}=e,i=G(),a=n.reduce(((e,t)=>t._id.startsWith("drafts.")?e.concat(t._id.slice(7)):e),[]),l=n.filter((e=>!a.includes(e._id)));return t?ke(Fe,{size:1,children:"Loading..."}):0===l.length?ke(Fe,{size:1,children:"No documents are referencing this asset"}):ke(Me,{flex:1,marginBottom:2,padding:2,radius:2,shadow:1,children:ke(He,{space:2,children:null==l?void 0:l.map((e=>ke(ba,{doc:e,schemaType:i.get(e._type)},e._id)))})})},ba=e=>{const{doc:t,schemaType:n}=e,{onClick:i}=fn({intent:"edit",params:{id:t._id}});return n?ke(Ee,{mode:"bleed",onClick:i,padding:2,style:{width:"100%"},children:ke(K,{layout:"default",schemaType:n,value:t})},t._id):ke(qe,{padding:2,children:_e(Fe,{size:1,children:["A document of the unknown type ",ke("em",{children:t._type})]})})},xa=Jt(qe)(b||(b=H(["\n text {\n font-family: "," !important;\n font-size: 8px !important;\n font-weight: 500 !important;\n }\n"])),(e=>e.theme.sanity.fonts.text.family)),Ca=e=>{const{extension:t,onClick:n,width:i}=e;return ke(je,{align:"center",justify:"center",onClick:n,style:{height:"100%"},children:ke(xa,{style:{width:i},children:ke(vn,t?B({extension:t},bn[t]):{})})})},wa=e=>{const{asset:t}=e;return 0===t.mimeType.search("audio")?ke(je,{align:"center",justify:"center",style:{height:"100%"},children:ke("audio",{controls:!0,src:t.url,style:{width:"100%"}})}):0===t.mimeType.search("video")?ke("video",{controls:!0,src:t.url,style:{height:"100%",width:"100%"}}):ke(Ca,{extension:t.extension,width:"50%"})},Ia=Jt(ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}})),Ta=e=>{const{description:t,error:n,label:i,name:a}=e;return _e(Se,{children:[ke(qe,{marginY:3,children:_e(Re,{space:2,children:[ke(Fe,{as:"label",htmlFor:a,size:1,weight:"semibold",children:i}),n&&ke(Fe,{size:1,children:ke(Qe,{content:ke(qe,{padding:2,children:_e(Fe,{muted:!0,size:1,children:[ke(Ia,{style:{marginRight:"0.1em"}}),n.message]})}),fallbackPlacements:["top","left"],placement:"right",portal:!0,children:ke(Ia,{})})})]})}),t&&ke(qe,{marginY:3,children:ke(Fe,{htmlFor:a,muted:!0,size:1,children:t})})]})},ka=ht(((e,t)=>{const{description:n,disabled:i,error:a,extension:l,label:o,name:r,placeholder:s,value:d}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:o,name:r}),_e(je,{children:[ke(qe,{style:{flexGrow:1},children:ke(Ue,{autoComplete:"off",autoFocus:!0,defaultValue:d,disabled:i,id:r,name:r,placeholder:s,ref:t})}),ke(qe,{style:{width:"70px"},children:ke(Ue,{defaultValue:".".concat(l),disabled:!0})})]})]})}));var _a,Sa,Ra,Ea,za,Aa,Oa,Da,qa,ja,La,Fa;const Ua=null==(za=null==(Ea=null==(Ra=null==(Sa=null==(_a=Pe)?void 0:_a.color)?void 0:Sa.dark)?void 0:Ra.primary)?void 0:Ea.spot)?void 0:za.blue,Pa=null==(ja=null==(qa=null==(Da=null==(Oa=null==(Aa=Pe)?void 0:Aa.color)?void 0:Oa.dark)?void 0:Da.primary)?void 0:qa.spot)?void 0:ja.gray,Ma=null==(La=Pe)?void 0:La.radius,Na=null==(Fa=Pe)?void 0:Fa.space,Va={control:(e,t)=>{let{isDisabled:n,isFocused:i}=t,a="inset 0 0 0 1px ".concat(Gt.gray[900].hex);return i&&(a="inset 0 0 0 1px ".concat(Gt.gray[900].hex,", 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important")),B(B({},e),{},{background:n?Pe.color.dark.default.input.default.disabled.bg:"transparent",color:Kt.hex,border:"none",borderRadius:Ma[1],boxShadow:a,minHeight:"35px",outline:"none",transition:"none","&:hover":{boxShadow:"inset 0 0 0 1px ".concat(Pe.color.dark.default.input.default.hovered.border)}})},indicatorsContainer:(e,t)=>{let{isDisabled:n}=t;return B(B({},e),{},{opacity:n?.25:1})},input:e=>B(B({},e),{},{color:Kt.hex,fontFamily:Pe.fonts.text.family,marginLeft:Na[2]}),menuList:e=>B({},e),multiValue:(e,t)=>{let{isDisabled:n}=t;return B(B({},e),{},{backgroundColor:Pa,borderRadius:Ma[2],opacity:n?.5:1})},multiValueRemove:e=>B(B({},e),{},{paddingLeft:0,"&:hover":{background:"transparent",color:"inherit"}}),noOptionsMessage:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,lineHeight:"1em"}),option:(e,t)=>{let{isFocused:n}=t;return B(B({},e),{},{backgroundColor:n?Ua:"transparent",borderRadius:Ma[2],color:n?Zt.hex:"inherit",fontFamily:Pe.fonts.text.family,padding:"4px 8px","&:hover":{backgroundColor:Ua,color:Zt.hex}})},placeholder:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,marginLeft:Na[2]}),valueContainer:e=>B(B({},e),{},{marginBottom:Na[0],marginLeft:Na[1],marginTop:Na[0],padding:0})},Qa=e=>ke(qe,{paddingX:1,paddingY:1,children:ke(on.Option,B(B({},e),{},{children:_e(je,{align:"center",children:[e.data.__isNew__&&ke(pe,{style:{marginRight:"3px"}}),e.children]})}))}),Ba={DropdownIndicator:e=>ke(on.DropdownIndicator,B(B({},e),{},{children:ke(qe,{paddingX:2,children:ke(Fe,{size:1,children:ke(ue,{})})})})),IndicatorSeparator:null,Menu:e=>ke(on.Menu,B(B({},e),{},{children:ke(Me,{radius:1,shadow:2,children:e.children})})),MenuList:e=>{const{children:t}=e;if(Array.isArray(t)){const e=t.length>5?185:37*t.length;return ke(rn,{className:"media__custom-scrollbar",itemContent:e=>{const n=t[e];return ke(Qa,B({},n.props))},style:{height:e},totalCount:t.length})}return ke(on.MenuList,B(B({},e),{},{children:t}))},MultiValueLabel:e=>ke(qe,{paddingLeft:1,paddingRight:0,paddingY:1,children:ke(Fe,{size:2,weight:"medium",children:ke(on.MultiValueLabel,B({},e))})}),MultiValueRemove:e=>ke(on.MultiValueRemove,B(B({},e),{},{children:ke(ae,{color:"#1f2123"})})),Option:Qa},Xa=e=>{const{control:t,description:n,disabled:i,error:a,label:l,name:o,onCreateTag:r,options:s,placeholder:d,value:c}=e,u=mi((e=>e.tags.creating)),p=mi((e=>e.tags.fetching));return _e(qe,{style:{zIndex:2},children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke(un,{control:t,defaultValue:c,name:o,render:e=>{let{onBlur:t,onChange:n,value:a}=e;return ke(xn,{components:Ba,instanceId:"tags",isClearable:!1,isDisabled:u||i||p,isLoading:u,isMulti:!0,name:o,noOptionsMessage:()=>"No tags",onBlur:t,onChange:n,onCreateOption:r,options:s,placeholder:p?"Loading...":d,styles:Va,value:a})}})]})},Ha=ht(((e,t)=>{const{description:n,disabled:i,error:a,label:l,name:o,placeholder:r,value:s}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke(Ue,{autoComplete:"off",autoFocus:!0,defaultValue:s,disabled:i,id:o,name:o,placeholder:r,ref:t})]})})),Ya=ht(((e,t)=>{const{description:n,disabled:i,error:a,label:l,name:o,placeholder:r,rows:s,value:d}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke($e,{autoComplete:"off",defaultValue:d,disabled:i,id:o,name:o,placeholder:r,ref:t,rows:s})]})})),$a=e=>{const{disabled:t,isValid:n,lastUpdated:i,onClick:a}=e;let l;return l=n?i?_e(Se,{children:["Last updated",ke("br",{})," ",gn(new Date(i),"PPp")]}):"No unpublished changes":"There are validation errors that need to be fixed before this document can be published",ke(Qe,{content:ke(qe,{padding:3,style:{maxWidth:"185px"},children:ke(Fe,{muted:!0,size:1,children:l})}),disabled:"ontouchstart"in window,placement:"top",children:ke(qe,{children:ke(Ee,{disabled:t,fontSize:1,onClick:a,text:"Save and close",tone:"primary"})})})},Wa=Jt.img(x||(x=H(["\n --checkerboard-color: ",";\n\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n\n ","\n"])),Gt.gray[900].hex,(e=>e.showCheckerboard&&en(C||(C=H(["\n background-image: linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),\n linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),\n linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0;\n "]))))),Ga=hn.object().shape({originalFilename:hn.string().required("Filename cannot be empty")}),Ka=e=>{var t,n;const i=null==(t=null==e?void 0:e.originalFilename)?void 0:t.toLowerCase().lastIndexOf(".".concat(e.extension));return null==(n=null==e?void 0:e.originalFilename)?void 0:n.slice(0,i)},Za=e=>{var t,n,i;const{children:a,dialog:{assetId:l,id:o,lastCreatedTag:r,lastRemovedTagIds:s}}=e,d=qn(),c=xt(),u=mi((e=>ai(e,String(l)))),p=mi(Xn),h=st(!1),[g,m]=pt(null==u?void 0:u.asset),[y,f]=pt("details"),v=u?null==u?void 0:u.asset:g,b=Mn(p),x=mi((C=v,e=>{var t,n,i;const a=null==(i=null==(n=null==(t=null==C?void 0:C.opt)?void 0:t.media)?void 0:n.tags)?void 0:i.reduce(((t,n)=>{const i=e.tags.byIds[n._ref];return(null==i?void 0:i.tag)&&t.push(i),t}),[]);return a&&(null==a?void 0:a.length)>0?Mn(a):null}));var C;const I=e=>({altText:(null==e?void 0:e.altText)||"",description:(null==e?void 0:e.description)||"",originalFilename:e?Ka(e):void 0,opt:{media:{tags:x}},title:(null==e?void 0:e.title)||""}),T=null==x?void 0:x.map((e=>e.label)).join(","),{control:k,formState:{errors:_,isDirty:S,isValid:R},getValues:E,handleSubmit:z,register:A,reset:O,setValue:D}=pn({defaultValues:I(null==u?void 0:u.asset),mode:"onChange",resolver:cn(Ga)}),q=!u||(null==u?void 0:u.updating),j=()=>{(null==u?void 0:u.asset)&&c(fi.showConfirmDeleteAssets({assets:[u],closeDialogId:null==u?void 0:u.asset._id}))},L=e=>{const{result:t,transition:n}=e;t&&"update"===n&&(m(t),O(I(t)))},F=async e=>{var t;if(!(null==u?void 0:u.asset))return;const n=da(e);c(di.updateRequest({asset:null==u?void 0:u.asset,closeDialogId:null==u?void 0:u.asset._id,formData:B(B({},n),{},{opt:{media:B(B({},n.opt.media),{},{tags:(null==(t=n.opt.media.tags)?void 0:t.map((e=>({_ref:e.value,_type:"reference",_weak:!0}))))||null})},originalFilename:"".concat(n.originalFilename,".").concat(null==u?void 0:u.asset.extension)})}))};dt((()=>{if(!(null==u?void 0:u.asset))return;const e=d.listen(vt(w||(w=H(["*[_id == $id]"]))),{id:null==u?void 0:u.asset._id}).subscribe(L);return()=>{null==e||e.unsubscribe()}}),[]),dt((()=>{h.current&&O({opt:{media:{tags:x}}},{errors:!0,dirtyFields:!0,isDirty:!0}),h.current=!0}),[T]),dt((()=>{if(r){const e=(E("opt.media.tags")||[]).concat([r]);D("opt.media.tags",e,{shouldDirty:!0})}}),[r]),dt((()=>{if(s){const e=(E("opt.media.tags")||[]).filter((e=>!s.includes(e.value)));D("opt.media.tags",e,{shouldDirty:!0})}}),[s]);return v?_e(ya,{footer:ke((()=>ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{disabled:q,fontSize:1,mode:"bleed",onClick:j,text:"Delete",tone:"critical"}),ke($a,{disabled:q||!S||!R,isValid:R,lastUpdated:v._updatedAt,onClick:z(F)})]})})),{}),header:"Asset details",id:o,onClose:()=>{c(fi.remove({id:o}))},width:3,children:[_e(je,{direction:["column-reverse","column-reverse","row-reverse"],children:[_e(qe,{flex:1,marginTop:[5,5,0],padding:4,children:[_e(We,{space:2,children:[ke(Ge,{"aria-controls":"details-panel",disabled:q,id:"details-tab",label:"Details",onClick:()=>f("details"),selected:"details"===y,size:2}),ke(Ge,{"aria-controls":"references-panel",disabled:q,id:"references-tab",label:"References",onClick:()=>f("references"),selected:"references"===y,size:2})]}),_e(qe,{as:"form",marginTop:4,onSubmit:z(F),children:[!u&&ke(Me,{marginBottom:3,padding:3,radius:2,shadow:1,tone:"critical",children:ke(Fe,{size:1,children:"This file cannot be found – it may have been deleted."})}),ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ke,{"aria-labelledby":"details",hidden:"details"!==y,id:"details-panel",children:_e(He,{space:3,children:[ke(Xa,{control:k,disabled:q,error:null==(n=null==(t=null==_?void 0:_.opt)?void 0:t.media)?void 0:n.tags,label:"Tags",name:"opt.media.tags",onCreateTag:e=>{c(Yn.createRequest({assetId:null==v?void 0:v._id,name:e}))},options:b,placeholder:"Select or create...",value:x}),ke(ka,{disabled:q,error:null==_?void 0:_.originalFilename,extension:(null==v?void 0:v.extension)||"",label:"Filename",name:"originalFilename",ref:A,value:Ka(v)}),ke(Ha,{disabled:q,error:null==_?void 0:_.title,label:"Title",name:"title",ref:A,value:null==v?void 0:v.title}),ke(Ha,{disabled:q,error:null==_?void 0:_.altText,label:"Alt Text",name:"altText",ref:A,value:null==v?void 0:v.altText}),ke(Ya,{disabled:q,error:null==_?void 0:_.description,label:"Description",name:"description",ref:A,rows:3,value:null==v?void 0:v.description})]})}),ke(Ke,{"aria-labelledby":"references",hidden:"references"!==y,id:"references-panel",children:ke(qe,{marginTop:5,children:(null==u?void 0:u.asset)&&ke(fa,{assetId:null==u?void 0:u.asset._id})})})]})]}),_e(qe,{flex:1,padding:4,children:[_e(qe,{style:{aspectRatio:"1"},children:[ca(v)&&ke(wa,{asset:v}),ua(v)&&ke(Wa,{draggable:!1,showCheckerboard:!(null==(i=null==v?void 0:v.metadata)?void 0:i.isOpaque),src:sa(v,{height:600,width:600})})]}),v&&ke(qe,{marginTop:4,children:ke(ma,{asset:v,item:u})})]})]}),a]}):null},Ja=e=>{const{children:t,dialog:n}=e,i=xt(),a=()=>{i(fi.remove({id:null==n?void 0:n.id}))},l=()=>{(null==n?void 0:n.closeDialogId)&&i(fi.remove({id:null==n?void 0:n.closeDialogId})),(null==n?void 0:n.confirmCallbackAction)&&i(n.confirmCallbackAction),a()},o=()=>_e(je,{align:"center",children:[ke(qe,{paddingX:1,children:ke(he,{})}),ke(qe,{marginLeft:2,children:null==n?void 0:n.headerTitle})]});return _e(ya,{footer:ke((()=>ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{fontSize:1,mode:"bleed",onClick:a,text:"Cancel"}),ke(Ee,{fontSize:1,onClick:l,text:null==n?void 0:n.confirmText,tone:null==n?void 0:n.tone})]})})),{}),header:ke(o,{}),id:"confirm",onClose:a,width:1,children:[ke(qe,{paddingX:4,paddingY:4,children:_e(He,{space:3,children:[(null==n?void 0:n.title)&&ke(Fe,{size:1,children:n.title}),(null==n?void 0:n.description)&&ke(Fe,{muted:!0,size:1,children:ke("em",{children:n.description})})]})}),t]})},el=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=gt((()=>{i(fi.clear())}),[]);return _e(ya,{header:"Filters",id:n,onClose:a,width:1,children:[_e(qe,{padding:3,children:[ke(Ji,{layout:"stack"}),ke(ea,{})]}),t]})},tl=hn.object().shape({name:hn.string().required("Name cannot be empty")}),nl=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=mi((e=>e.tags.creating)),l=mi((e=>e.tags.creatingError)),{formState:{errors:o,isDirty:r,isValid:s},handleSubmit:d,register:c,setError:u}=pn({defaultValues:{name:""},mode:"onChange",resolver:cn(tl)}),p=a,h=async e=>{const t=da(e);i(Yn.createRequest({name:t.name}))};dt((()=>{l&&u("name",{message:null==l?void 0:l.message})}),[l]);return _e(ya,{footer:ke((()=>ke(qe,{padding:3,children:ke(je,{justify:"flex-end",children:ke($a,{disabled:p||!r||!s,isValid:s,onClick:d(h)})})})),{}),header:"Create Tag",id:n,onClose:()=>{i(fi.clear())},width:1,children:[_e(qe,{as:"form",padding:4,onSubmit:d(h),children:[ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ha,{disabled:p,error:null==o?void 0:o.name,label:"Name",name:"name",ref:c})]}),t]})},il=hn.object().shape({name:hn.string().required("Name cannot be empty")}),al=e=>{const{children:t,dialog:{id:n,tagId:i}}=e,a=qn(),l=xt(),o=mi((e=>Hn(e,String(i)))),[r,s]=pt(null==o?void 0:o.tag),d=o?null==o?void 0:o.tag:r,c=e=>{var t;return{name:(null==(t=null==e?void 0:e.name)?void 0:t.current)||""}},{formState:{errors:u,isDirty:p,isValid:h},handleSubmit:g,register:m,reset:y,setError:f}=pn({defaultValues:c(null==o?void 0:o.tag),mode:"onChange",resolver:cn(il)}),v=!o||(null==o?void 0:o.updating),b=async e=>{var t;if(!(null==o?void 0:o.tag))return;const n=da(e);l(Yn.updateRequest({closeDialogId:null==(t=null==o?void 0:o.tag)?void 0:t._id,formData:{name:{_type:"slug",current:n.name}},tag:null==o?void 0:o.tag}))},x=()=>{var e;(null==o?void 0:o.tag)&&l(fi.showConfirmDeleteTag({closeDialogId:null==(e=null==o?void 0:o.tag)?void 0:e._id,tag:null==o?void 0:o.tag}))},C=e=>{const{result:t,transition:n}=e;t&&"update"===n&&(s(t),y(c(t)))};dt((()=>{var e;(null==o?void 0:o.error)&&f("name",{message:null==(e=o.error)?void 0:e.message})}),[null==o?void 0:o.error]),dt((()=>{if(!(null==o?void 0:o.tag))return;const e=a.listen(vt(I||(I=H(["*[_id == $id]"]))),{id:null==o?void 0:o.tag._id}).subscribe(C);return()=>{null==e||e.unsubscribe()}}),[]);const w=()=>{var e;return ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{disabled:v,fontSize:1,mode:"bleed",onClick:x,text:"Delete",tone:"critical"}),ke($a,{disabled:v||!p||!h,isValid:h,lastUpdated:null==(e=null==o?void 0:o.tag)?void 0:e._updatedAt,onClick:g(b)})]})})};return d?_e(ya,{footer:ke(w,{}),header:"Edit Tag",id:n,onClose:()=>{l(fi.remove({id:n}))},width:1,children:[_e(qe,{as:"form",padding:4,onSubmit:g(b),children:[!o&&ke(Me,{marginBottom:3,padding:3,radius:2,shadow:1,tone:"critical",children:ke(Fe,{size:1,children:"This tag cannot be found – it may have been deleted."})}),ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ha,{disabled:v,error:null==u?void 0:u.name,label:"Name",name:"name",ref:m})]}),t]}):null},ll=Jt(je)(T||(T=H(["\n height: ","px;\n"])),32),ol=Jt(je)(k||(k=H(["\n @media (pointer: fine) {\n visibility: hidden;\n }\n\n @media (hover: hover) and (pointer: fine) {\n ",":hover & {\n visibility: visible;\n }\n }\n"])),ll),rl=e=>{const{disabled:t,icon:n,onClick:i,tone:a,tooltip:l}=e;return ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{muted:!0,size:1,children:l})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{disabled:t,fontSize:1,icon:n,mode:"bleed",onClick:i,padding:2,tone:a})})},sl=e=>{var t,n;const{actions:i,tag:a}=e,l=xt(),o=mi(ri),r=mi(Gn),s=mi((e=>{var t;return Kn(e,null==(t=null==a?void 0:a.tag)?void 0:t._id)}));return _e(ll,{align:"center",flex:1,justify:"space-between",paddingLeft:3,children:[ke(qe,{flex:1,children:ke(Fe,{size:1,style:{color:(null==a?void 0:a.updating)?Gt.gray[800].hex:Gt.gray[500].hex,userSelect:"none"},textOverflow:"ellipsis",children:null==(n=null==(t=null==a?void 0:a.tag)?void 0:t.name)?void 0:n.current})}),_e(ol,{align:"center",style:{flexShrink:0},children:[(null==i?void 0:i.includes("search"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(s?ae:oe,{}),onClick:s?()=>{l(Zn.facetsRemove({facetName:"tag"}))}:()=>{var e,t,n;const i=B(B({},kn.tag),{},{value:{label:null==(t=null==(e=null==a?void 0:a.tag)?void 0:e.name)?void 0:t.current,value:null==(n=null==a?void 0:a.tag)?void 0:n._id}});l(r?Zn.facetsUpdate({name:"tag",operatorType:"references",value:i.value}):Zn.facetsAdd({facet:i}))},tooltip:s?"Remove filter":"Filter by tag"}),(null==i?void 0:i.includes("edit"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(ge,{}),onClick:()=>{var e;l(Vn.showTagEdit({tagId:null==(e=null==a?void 0:a.tag)?void 0:e._id}))},tone:"primary",tooltip:"Edit tag"}),(null==i?void 0:i.includes("applyAll"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(me,{}),onClick:()=>{l(fi.showConfirmAssetsTagAdd({assetsPicked:o,tag:a.tag}))},tone:"primary",tooltip:"Add tag to selected assets"}),(null==i?void 0:i.includes("removeAll"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(ye,{}),onClick:()=>{l(fi.showConfirmAssetsTagRemove({assetsPicked:o,tag:a.tag}))},tone:"critical",tooltip:"Remove tag from selected assets"}),(null==i?void 0:i.includes("delete"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(fe,{}),onClick:()=>{l(fi.showConfirmDeleteTag({tag:a.tag}))},tone:"critical",tooltip:"Delete tag"})]})]})},dl=mt((e=>{let{isScrolling:t,item:n}=e;var i;return"string"==typeof n?ke(je,{align:"center",justify:"space-between",paddingX:3,style:{height:"".concat(32,"px")},children:ke(Le,{size:0,children:n})},n):ke(sl,{actions:t?void 0:n.actions,tag:n},null==(i=n.tag)?void 0:i._id)})),cl=()=>{const e=mi(ri),t=mi(Xn),[n,i]=pt(!1),a=null==e?void 0:e.reduce(((e,t)=>{var n,i,a,l;const o=(null==(l=null==(a=null==(i=null==(n=null==t?void 0:t.asset)?void 0:n.opt)?void 0:i.media)?void 0:a.tags)?void 0:l.map((e=>e._ref)))||[];return e=e.concat(o)}),[]),l=[...new Set(a)],o=l.reduce(((t,n)=>{const i=e.every((e=>{var t,i,a,l;return(null!=(l=null==(a=null==(i=null==(t=e.asset.opt)?void 0:t.media)?void 0:i.tags)?void 0:a.findIndex((e=>e._ref===n)))?l:-1)>=0}));return i?t.appliedToAll.push(n):t.appliedToSome.push(n),t}),{appliedToAll:[],appliedToSome:[]}),r=t.filter((e=>o.appliedToAll.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["delete","edit","removeAll","search"]}))),s=t.filter((e=>o.appliedToSome.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["applyAll","delete","edit","removeAll","search"]}))),d=t.filter((e=>!l.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["applyAll","delete","edit","search"]})));let c=[];return 0===e.length?c=t.map((e=>B(B({},e),{},{actions:["delete","edit","search"]}))):((null==r?void 0:r.length)>0&&(c=[...c,1===e.length?"Used":"Used by all",...r]),(null==s?void 0:s.length)>0&&(c=[...c,"Used by some",...s]),(null==d?void 0:d.length)>0&&(c=[...c,"Unused",...d])),ke(rn,{className:"media__custom-scrollbar",computeItemKey:e=>{const t=c[e];return"string"==typeof t?t:t.tag._id},isScrolling:i,itemContent:e=>ke(dl,{isScrolling:n,item:c[e]}),style:{flex:1,overflowX:"hidden"},totalCount:c.length})},ul=e=>{var t,n;const{allowCreate:i,light:a,title:l}=e,o=xt(),r=mi((e=>e.tags.creating)),s=mi((e=>e.tags.fetching));return ke(Se,{children:_e(je,{align:"center",justify:"space-between",paddingLeft:3,style:{background:a?null==(t=Gt.gray)?void 0:t[900].hex:Zt.hex,borderBottom:"1px solid ".concat(null==(n=Gt.gray)?void 0:n[900].hex),height:"".concat(32,"px")},children:[_e(Re,{space:2,children:[ke(Le,{size:0,children:l}),s&&ke(Le,{size:0,style:{opacity:.3},children:"Loading..."})]}),i&&ke(qe,{marginRight:1,children:ke(Ee,{disabled:r,fontSize:1,icon:ve,mode:"bleed",onClick:()=>{o(Vn.showTagCreate())},style:{background:"transparent",boxShadow:"none"}})})]})})},pl=()=>{const e=mi(si),t=mi(Xn),n=mi((e=>e.tags.fetching)),i=-1!==mi((e=>e.tags.fetchCount)),a=!n&&(null==t?void 0:t.length)>0,l=!!(e>0);return _e(je,{direction:"column",flex:1,style:{background:Zt.hex,height:"100%"},children:[ke(ul,{allowCreate:!0,light:l,title:l?"Tags (in selection)":"Tags"}),i&&!a&&ke(qe,{padding:3,children:ke(Fe,{size:1,style:{color:Gt.gray[700].hex},children:ke("em",{children:"No tags"})})}),a&&ke(cl,{})]})},hl=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=gt((()=>{i(fi.clear())}),[]);return _e(ya,{header:"All Tags",id:n,onClose:a,width:1,children:[ke(qe,{style:{height:"100%",minHeight:"420px"},children:ke(pl,{})}),t]})},gl=()=>{const e=mi((e=>e.dialog.items)),t=(e,n)=>{if(0===e.length||n>=e.length)return null;const i=e[n],a=t(e,n+1);return"assetEdit"===i.type?ke(Za,{dialog:i,children:a},n):"confirm"===i.type?ke(Ja,{dialog:i,children:a},n):"searchFacets"===i.type?ke(el,{dialog:i,children:a},n):"tagCreate"===i.type?ke(nl,{dialog:i,children:a},n):"tagEdit"===i.type?ke(al,{dialog:i,children:a},n):"tags"===i.type?ke(hl,{dialog:i,children:a},n):null};return t(e,0)},ml=ct(void 0),yl=e=>{const{children:t,open:n}=e,i={open:n};return ke(ml.Provider,{value:i,children:t})},fl=e=>{const{onClose:t}=e,{open:n}=(()=>{const e=ut(ml);if(void 0===e)throw new Error("useDropzoneActions must be used within an DropzoneDispatchProvider");return e})(),{onSelect:i}=Dn(),a=mi((e=>e.assets.assetTypes)),l=mi((e=>e.selected.document));return ke(qe,{paddingY:2,children:_e(je,{align:"center",justify:"space-between",children:[ke(qe,{flex:1,marginX:3,children:_e(Re,{style:{whiteSpace:"nowrap"},children:[ke(Fe,{textOverflow:"ellipsis",weight:"semibold",children:ke("span",{children:i?"Insert ".concat(a.join(" or ")):"Browse Assets"})}),l&&ke(qe,{display:["none","none","block"],children:_e(Fe,{children:[ke("span",{style:{margin:"0 0.5em"},children:ke(be,{symbol:"arrow-right"})}),ke("span",{style:{textTransform:"capitalize"},children:l._type})]})})]})}),_e(je,{marginX:2,children:[ke(Ee,{fontSize:1,icon:xe,mode:"bleed",onClick:n,text:"Upload ".concat(1===a.length?nn(a[0]):"assets"),tone:"primary"}),t&&ke(qe,{style:{flexShrink:0},children:ke(Ee,{disabled:!t,icon:ae,mode:"bleed",onClick:t,radius:2})})]})]})})},vl=Tt([e=>e.assets.allIds,e=>e.uploads.allIds],((e,t)=>{const n=e.map((e=>({id:e,type:"asset"})));return[...t.map((e=>({id:e,type:"upload"}))),...n]})),bl=Jt(je)(_||(_=H(["\n box-sizing: border-box;\n height: 100%;\n overflow: hidden;\n padding: 2px;\n position: relative;\n width: 100%;\n"]))),xl=Jt(je)(S||(S=H(["\n border: 1px solid transparent;\n height: 100%;\n pointer-events: ",";\n position: relative;\n transition: all 300ms;\n user-select: none;\n width: 100%;\n\n border: ",";\n\n ","\n"])),(e=>e.updating?"none":"auto"),(e=>e.picked?"1px solid ".concat(e.theme.sanity.color.spot.orange," !important"):"1px solid inherit"),(e=>!e.updating&&en(R||(R=H(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n border: 1px solid ",";\n }\n }\n "])),Gt.gray[500].hex))),Cl=Jt(je)(E||(E=H(["\n cursor: ",";\n height: ","px;\n transition: all 300ms;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),(e=>e.selected?"default":"pointer"),32,Gt.gray[950].hex),wl=Jt(Ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}}));var Il=mt((e=>{var t,n;const{id:i,selected:a}=e,l=In("shift"),o=xt(),r=mi((e=>e.assets.lastPicked)),s=mi((e=>ai(e,i))),d=null==s?void 0:s.asset,c=null==s?void 0:s.error,u=null==(n=null==(t=null==s?void 0:s.asset)?void 0:t.metadata)?void 0:n.isOpaque,p=null==s?void 0:s.picked,h=null==s?void 0:s.updating,{onSelect:g}=Dn();if(!d)return null;const m=h?.5:1,y=a||h?.25:1;return ke(bl,{children:_e(xl,{direction:"column",picked:p,updating:s.updating,children:[_e(qe,{flex:1,style:{cursor:a?"default":"pointer",position:"relative"},children:[_e("div",{onClick:e=>{e.stopPropagation(),g?g([{kind:"assetDocumentId",value:d._id}]):l.current?o(p?di.pick({assetId:d._id,picked:!p}):di.pickRange({startId:r||d._id,endId:d._id})):o(fi.showAssetEdit({assetId:d._id}))},style:{height:"100%",opacity:y},children:[ca(d)&&ke(Ca,{extension:d.extension,width:"80px"}),ua(d)&&ke(Wa,{draggable:!1,showCheckerboard:!u,src:sa(d,{height:250,width:250}),style:{draggable:!1,transition:"opacity 1000ms"}})]}),a&&!h&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,opacity:m,position:"absolute",top:0,width:"100%"},children:ke(Fe,{size:2,children:ke(we,{})})}),h&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Je,{})})]}),_e(Cl,{align:"center",onClick:e=>{e.stopPropagation(),g?o(fi.showAssetEdit({assetId:d._id})):l.current&&!p?o(di.pickRange({startId:r||d._id,endId:d._id})):o(di.pick({assetId:d._id,picked:!p}))},paddingX:1,style:{opacity:m},children:[g?ke(ge,{style:{flexShrink:0,opacity:.5}}):ke(et,{checked:p,readOnly:!0,style:{flexShrink:0,pointerEvents:"none",transform:"scale(0.8)"}}),ke(qe,{marginLeft:2,children:ke(Fe,{muted:!0,size:0,textOverflow:"ellipsis",children:d.originalFilename})})]}),c&&ke(qe,{padding:3,style:{position:"absolute",right:0,top:0},children:ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{size:1,children:c})}),placement:"left",portal:!0,children:ke(Fe,{size:1,children:ke(wl,{color:"critical"})})})})]})})}));const Tl=async e=>{const t=await(e=>new Promise((t=>{const n=window.URL.createObjectURL(e),i=new Image;i.onload=()=>{window.URL.revokeObjectURL(n),t(i)},i.src=n})))(e),n=await(i=t,new Promise((e=>{const t=i.width/i.height,n=document.createElement("canvas");n.width=180,n.height=Math.max(180/t,1);try{const a=n.getContext("2d");null==a||a.drawImage(i,0,0,180,180/t),n.toBlob(e,"image/jpeg")}catch(e){console.warn("Unable to generate preview image:",e)}})));var i;if(!n)throw Error("Unable to generate file Blob");return window.URL.createObjectURL(n)};function kl(e,t){const n=e.indexOf(t);return n>-1&&e.splice(n,1),e}const _l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;const t=[],n=[],i=new Lt;function a(o){return new Ft((r=>{if(t.length>=e)return l(o).pipe(Mt(a)).subscribe(r);const s=o.subscribe(r);return t.push(s),()=>{for(kl(t,s),kl(n,o),s.unsubscribe();n.length>0&&t.length<e;)i.next(n.shift())}}))}function l(e){return n.push(e),i.asObservable().pipe(Yt((t=>t===e)))}return a},Sl=e=>Array.prototype.map.call(new Uint8Array(e),(e=>"00".concat(e.toString(16)).slice(-2))).join(""),Rl=e=>window.crypto&&window.crypto.subtle&&window.FileReader?(e=>new Ft((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(Mt((e=>window.crypto.subtle.digest("SHA-1",e))),$t(Sl)):Ot({message:"Unable to generate hash: uploads are only allowed in secure contexts",statusCode:500}),El=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const n=_l(t);return function(){return qt(n(e(...arguments)))}}(((e,t,n,i)=>Dt(null).pipe(Mt((()=>((e,t,n)=>e.observable.fetch("*[_type == $documentType && sha1hash == $hash][0]",{documentType:t,hash:n}))(e,"sanity.".concat(t,"Asset"),i))),Mt((e=>e?Ot({message:"Asset already exists",statusCode:409}):Dt(null))),Mt((()=>e.observable.assets.upload(t,n,{extract:["blurhash","exif","location","lqip","palette"],preserveFilename:!0}).pipe($t((e=>"response"===e.type?{asset:e.body.document,id:e.body.document._id,type:"complete"}:e)))))))),zl=It({name:"uploads",initialState:{allIds:[],byIds:{}},extraReducers:e=>{e.addCase(ei.uploadComplete,((e,t)=>{const{asset:n}=t.payload;e.byIds[n.sha1hash]&&(e.byIds[n.sha1hash].status="complete")}))},reducers:{checkRequest(e,t){},checkComplete(e,t){const{results:n}=t.payload;Object.keys(n).forEach((t=>{const n=e.allIds.indexOf(t);if(n>=0&&e.allIds.splice(n,1),e.byIds[t]){const n=e.byIds[t].objectUrl;n&&window.URL.revokeObjectURL(n),delete e.byIds[t]}}))},previewReady(e,t){const{blobUrl:n,hash:i}=t.payload;e.byIds[i]&&(e.byIds[i].objectUrl=n)},uploadCancel(e,t){const{hash:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),e.byIds[n]&&delete e.byIds[n]},uploadError(e,t){const{hash:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),delete e.byIds[n]},uploadRequest(e,t){},uploadProgress(e,t){const{event:n,uploadHash:i}=t.payload;e.byIds[i].percent=n.percent,e.byIds[i].status="uploading"},uploadStart(e,t){const{uploadItem:n}=t.payload;e.allIds.includes(n.hash)||e.allIds.push(n.hash),e.byIds[n.hash]=n}}}),Al=Tt([e=>e.uploads.byIds,(e,t)=>t],((e,t)=>e[t]));Tt([e=>e.uploads.byIds,e=>e.uploads.allIds],((e,t)=>t.map((t=>e[t]))));const Ol=zl.actions;var Dl=zl.reducer;const ql=Jt(je)(A||(A=H(["\n box-sizing: border-box;\n height: 100%;\n overflow: hidden;\n padding: 2px;\n position: relative;\n width: 100%;\n"]))),jl=e=>{const{id:t}=e,n=xt(),i=mi((e=>Al(e,t)));if(!i)return null;const a=mn(i.size,{base:10,round:0}),l=Math.round(i.percent||0),o="complete"===i.status,r="uploading"===i.status,s="queued"===i.status;let d;o&&(d="Verifying"),r&&(d="".concat(l,"%")),s&&(d="Queued");return ke(ql,{children:_e(je,{direction:"column",flex:1,style:{background:Gt.gray[950].hex,border:"1px solid transparent",height:"100%",position:"relative"},children:[ke("div",{style:{background:Gt.gray[600].hex,bottom:0,height:"1px",left:0,position:"absolute",width:"100%",transform:"scaleX(".concat(.01*l,")"),transformOrigin:"bottom left",transition:"all 1000ms ease-out"}}),_e(qe,{flex:1,style:{position:"relative"},children:["image"===i.assetType&&(null==i?void 0:i.objectUrl)&&ke(Wa,{draggable:!1,src:i.objectUrl,style:{opacity:.4}}),"file"===i.assetType&&ke("div",{style:{height:"100%",opacity:.1},children:ke(Ca,{width:"80px"})}),!o&&100!==l&&ke(je,{align:"center",direction:"column",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:"Cancel"})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{fontSize:4,icon:ae,mode:"bleed",onClick:()=>{n(Ol.uploadCancel({hash:i.hash}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical"})})})]}),_e(je,{align:"center",justify:"space-between",paddingX:2,style:{height:"".concat(32,"px")},children:[ke(qe,{flex:1,marginRight:1,children:_e(Fe,{size:0,textOverflow:"ellipsis",children:[i.name," (",a,")"]})}),ke(Fe,{size:0,style:{flexShrink:0},weight:"semibold",children:d})]})]})})},Ll=mt((e=>{let{item:t,selected:n}=e;return"asset"===(null==t?void 0:t.type)?ke(Il,{id:t.id,selected:n}):"upload"===(null==t?void 0:t.type)?ke(jl,{id:t.id}):null})),Fl=Jt.div(O||(O=H(["\n height: ","px;\n width: ","px;\n"])),220,240),Ul=Jt.div(D||(D=H(["\n display: grid;\n grid-template-columns: repeat(auto-fill, ","px);\n justify-content: center;\n margin: 0 auto;\n"])),240),Pl=e=>{const{items:t,onLoadMore:n}=e,i=mi((e=>e.selected.assets)),a=i&&i.map((e=>e._id))||[],l=null==t?void 0:t.length;return 0===l?null:ke(sn,{className:"media__custom-scrollbar",computeItemKey:e=>{const n=t[e];return null==n?void 0:n.id},components:{Item:Fl,List:Ul},endReached:n,itemContent:e=>{const n=t[e],i=a.includes(null==n?void 0:n.id);return ke(Ll,{item:n,selected:i})},overscan:48,style:{overflowX:"hidden"},totalCount:l})},Ml=e=>{const{field:t,title:n}=e,i=xt(),a=mi((e=>e.assets.order)),l=a.field===t;return ke(Le,{muted:!t,size:0,children:_e(qe,{onClick:t?()=>{if(t&&n)if(l){const e="asc"===a.direction?"desc":"asc";i(di.orderSet({order:{field:t,direction:e}}))}else i(di.orderSet({order:{field:t,direction:"asc"}}))}:void 0,style:{cursor:t?"pointer":"default",display:"inline",whiteSpace:"nowrap"},children:[ke("span",{style:{marginRight:"0.4em"},children:n}),l&&"asc"===(null==a?void 0:a.direction)&&ke(Ie,{}),l&&"desc"===(null==a?void 0:a.direction)&&ke(ue,{})]})})};var Nl;const Vl=Jt(je)(q||(q=H(["\n cursor: pointer;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),null==(Nl=Gt.gray)?void 0:Nl[900].hex),Ql=()=>{var e;const t=xt(),n=mi((e=>e.assets.fetching)),i=mi(oi),a=mi(si),l=Ve(),{onSelect:o}=Dn(),r=a===i;return _e(tt,{style:{alignItems:"center",background:Zt.hex,borderBottom:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),gridColumnGap:l<3?0:"16px",gridTemplateColumns:zn,height:l<3?0:"".concat(32,"px"),letterSpacing:"0.025em",position:"sticky",textTransform:"uppercase",top:0,visibility:l<3?"hidden":"visible",width:"100%",zIndex:1},children:[o?ke(Ml,{}):ke(Vl,{align:"center",justify:"center",onClick:e=>{e.stopPropagation(),t(r?di.pickClear():di.pickAll())},style:{height:"100%",position:"relative"},children:ke(et,{checked:!n&&r,readOnly:!0,style:{pointerEvents:"none",transform:"scale(0.8)"}})}),ke(Ml,{}),ke(Ml,{field:"originalFilename",title:"Filename"}),ke(Ml,{title:"Resolution"}),ke(Ml,{field:"mimeType",title:"MIME type"}),ke(Ml,{field:"size",title:"Size"}),ke(Ml,{field:"_updatedAt",title:"Last updated"}),ke(Ml,{})]})};var Bl;const Xl=Jt(tt)(j||(j=H(["\n align-items: center;\n cursor: ",";\n height: 100%;\n pointer-events: ",";\n user-select: none;\n white-space: nowrap;\n\n ","\n"])),(e=>e.selected?"default":"pointer"),(e=>e.updating?"none":"auto"),(e=>{var t;return!e.updating&&en(L||(L=H(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n "])),null==(t=Gt.gray)?void 0:t[950].hex)})),Hl=Jt(je)(F||(F=H(["\n cursor: pointer;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),null==(Bl=Gt.gray)?void 0:Bl[900].hex),Yl=Jt(Ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}}));var $l=mt((e=>{var t,n;const{id:i,selected:a}=e,l=In("shift"),o=xt(),r=mi((e=>e.assets.lastPicked)),s=mi((e=>ai(e,i))),d=Ve(),c=null==s?void 0:s.asset,u=null==s?void 0:s.error,p=null==(n=null==(t=null==s?void 0:s.asset)?void 0:t.metadata)?void 0:n.isOpaque,h=null==s?void 0:s.picked,g=null==s?void 0:s.updating,{onSelect:m}=Dn();if(!c)return null;const y=g?.5:1,f=a||g?.1:1;return _e(Xl,{onClick:a?void 0:e=>{e.stopPropagation(),m?m([{kind:"assetDocumentId",value:c._id}]):l.current?o(h?di.pick({assetId:c._id,picked:!h}):di.pickRange({startId:r||c._id,endId:c._id})):o(fi.showAssetEdit({assetId:c._id}))},selected:a,style:{gridColumnGap:d<3?0:"16px",gridRowGap:0,gridTemplateColumns:d<3?En:zn,gridTemplateRows:d<3?"auto":"1fr"},updating:s.updating,children:[ke(Hl,{onClick:e=>{e.stopPropagation(),m?o(fi.showAssetEdit({assetId:c._id})):l.current&&!h?o(di.pickRange({startId:r||c._id,endId:c._id})):o(di.pick({assetId:c._id,picked:!h}))},style:{alignItems:"center",gridColumn:1,gridRowStart:1,gridRowEnd:"span 5",height:"100%",justifyContent:"center",opacity:y,position:"relative"},children:m?ke(ge,{style:{flexShrink:0,opacity:.5}}):ke(et,{checked:h,readOnly:!0,style:{pointerEvents:"none",transform:"scale(0.8)"}})}),ke(qe,{style:{gridColumn:2,gridRowStart:1,gridRowEnd:"span 5",height:"90px",width:"100px"},children:_e(je,{align:"center",justify:"center",style:{height:"100%",position:"relative"},children:[_e(qe,{style:{height:"100%",opacity:f,position:"relative"},children:[ca(c)&&ke(Ca,{extension:c.extension,width:"40px"}),ua(c)&&ke(Wa,{draggable:!1,showCheckerboard:!p,src:sa(c,{height:100,width:100})})]}),g&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Je,{})}),a&&!g&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Fe,{size:2,children:ke(we,{})})})]})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:3,gridRow:d<3?2:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:c.originalFilename})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:d<3?3:4,gridRow:d<3?3:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:ua(c)&&pa(c)})}),ke(qe,{style:{display:d<3?"none":"block",gridColumn:5,gridRow:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:c.mimeType})}),ke(qe,{style:{display:d<3?"none":"block",gridColumn:6,gridRow:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:mn(c.size,{base:10,round:0})})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:d<3?3:7,gridRow:d<3?4:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:Cn(new Date(c._updatedAt),new Date)})}),ke(je,{align:"center",justify:"center",style:{gridColumn:d<3?4:8,gridRowStart:"1",gridRowEnd:d<3?"span 5":"auto",opacity:y},children:u&&ke(qe,{padding:2,children:ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{size:1,children:u})}),placement:"left",portal:!0,children:ke(Fe,{size:1,children:ke(Yl,{color:"critical"})})})})})]})}));const Wl=e=>{const{id:t}=e,n=xt(),i=mi((e=>Al(e,t))),a=Ve();if(!i)return null;const l=mn(i.size,{base:10,round:0}),o=Math.round(i.percent||0),r="complete"===i.status,s="uploading"===i.status,d="queued"===i.status;let c;r&&(c="Verifying"),s&&(c="".concat(o,"%")),d&&(c="Queued");return _e(tt,{style:{alignItems:"center",background:Gt.gray[950].hex,gridColumnGap:a<3?0:"16px",gridRowGap:0,gridTemplateColumns:a<3?En:zn,gridTemplateRows:a<3?"auto":"1fr",height:"100%",position:"relative"},children:[ke("div",{style:{background:Gt.gray[600].hex,bottom:0,height:"1px",left:0,position:"absolute",width:"100%",transform:"scaleX(".concat(.01*o,")"),transformOrigin:"bottom left",transition:"all 1000ms ease-out"}}),ke(qe,{style:{gridColumn:2,gridRowStart:a<3?1:"auto",gridRowEnd:a<3?"span 4":"auto",height:"90px",width:"100px"},children:_e(qe,{style:{height:"100%",position:"relative"},children:["image"===i.assetType&&(null==i?void 0:i.objectUrl)&&ke(Wa,{draggable:!1,src:i.objectUrl,style:{opacity:.25}}),"file"===i.assetType&&ke("div",{style:{height:"100%",opacity:.1},children:ke(Ca,{width:"40px"})}),!r&&100!==o&&ke(je,{align:"center",justify:"center",style:{position:"absolute",height:"100%",left:0,top:0,width:"100%"},children:ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:"Cancel"})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{fontSize:3,icon:ae,mode:"bleed",onClick:()=>{n(Ol.uploadCancel({hash:i.hash}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical"})})})]})}),ke(qe,{style:{gridColumn:a<3?3:"3/8",gridRow:a<3?"2/4":"auto",marginLeft:a<3?3:0},children:_e(He,{space:3,children:[_e(Fe,{muted:!0,size:1,textOverflow:"ellipsis",children:[i.name," (",l,")"]}),ke(Fe,{size:1,textOverflow:"ellipsis",weight:"semibold",children:c})]})})]})},Gl=mt((e=>{let{item:t,selected:n}=e;return"asset"===(null==t?void 0:t.type)?ke(qe,{style:{height:"100px"},children:ke($l,{id:t.id,selected:n})}):"upload"===(null==t?void 0:t.type)?ke(qe,{style:{height:"100px"},children:ke(Wl,{id:t.id})}):null})),Kl=e=>{const{items:t,onLoadMore:n}=e,i=mi((e=>e.selected.assets)),a=i&&i.map((e=>e._id))||[],l=null==t?void 0:t.length;return 0===l?null:ke(dn,{className:"media__custom-scrollbar",computeItemKey:e=>{const n=t[e];return(null==n?void 0:n.id)||e},endReached:n,groupCounts:Array(1).fill(l),groupContent:()=>ke(Ql,{}),itemContent:e=>{const n=t[e],i=a.includes(null==n?void 0:n.id);return ke(Gl,{item:n,selected:i})},style:{overflowX:"hidden"}})},Zl=()=>{const e=xt(),t=mi((e=>e.assets.fetchCount)),n=mi((e=>e.assets.fetching)),i=mi((e=>e.tags.panelVisible)),a=mi((e=>e.assets.view)),l=mi(vl),o=(()=>{var e,t;const n=null==(t=null==(e=Pe)?void 0:e.container)?void 0:t.map((e=>window.matchMedia("(max-width: ".concat(e,"px)")))),i=()=>n.findIndex((e=>e.matches)),[a,l]=pt(i());return dt((()=>{const e=()=>{l(i)};return n.forEach((t=>{try{t.addEventListener("change",e)}catch(n){try{t.addListener(e)}catch(e){}}})),()=>{try{n.forEach((t=>t.removeEventListener("change",e)))}catch(t){try{n.forEach((t=>t.removeListener(e)))}catch(e){}}}}),[]),a})(),r=t>=0,s=l.length>0,d=()=>{n||e(di.loadNextPage())};dt((()=>{o<=1&&i&&e(Yn.panelVisibleSet({panelVisible:!1}))}),[o]);return ke(qe,{flex:1,style:{width:"100%"},children:!s&&r&&!n?ke(qe,{padding:4,children:ke(Fe,{size:1,weight:"semibold",children:"No results for the current query"})}):_e(Se,{children:["grid"===a&&ke(Pl,{items:l,onLoadMore:d}),"table"===a&&ke(Kl,{items:l,onLoadMore:d})]})})},Jl=()=>{const e=mi((e=>e.notifications.items)),t=nt();return dt((()=>{if(e.length>0){const n=e[e.length-1];t.push({closable:!0,status:n.status,title:n.title})}}),[e.length]),null},eo=()=>{var e,t;const n=xt(),i=mi(ri);return 0===i.length?null:ke(je,{align:"center",justify:"flex-start",style:{background:null==(e=Gt.gray)?void 0:e[900].hex,borderBottom:"1px solid ".concat(null==(t=Gt.gray)?void 0:t[900].hex),height:"".concat(32,"px"),position:"relative",width:"100%"},children:_e(je,{align:"center",paddingX:3,children:[ke(qe,{paddingRight:2,children:_e(Le,{size:0,style:{color:"inherit"},children:[i.length," ",nn("asset",i.length)," selected"]})}),ke(Ee,{mode:"bleed",onClick:()=>{n(di.pickClear())},padding:2,style:{background:"none",boxShadow:"none"},tone:"default",children:ke(Le,{size:0,children:"Deselect"})}),ke(Ee,{mode:"bleed",onClick:()=>{n(fi.showConfirmDeleteAssets({assets:i}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical",children:ke(Le,{size:0,children:"Delete"})})]})})};var to=It({name:"selected",initialState:{assets:[],document:void 0,documentAssetIds:[]},reducers:{}}).reducer;const no=It({name:"notifications",initialState:{items:[]},reducers:{add(e,t){const{asset:n,status:i,title:a}=t.payload;e.items.push({asset:n,status:i,title:a})}}}),io=no.actions;var ao=no.reducer;const lo=Et(((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.deleteRequest.match),Mt((e=>{const{assets:t}=e.payload,n=t.map((e=>e._id));return Dt(t).pipe(Mt((()=>i.observable.delete({query:vt(p||(p=H(["*[_id in ","]"])),JSON.stringify(n))}))),Mt((()=>Dt(di.deleteComplete({assetIds:n})))),Qt((e=>Dt(di.deleteError({assetIds:n,error:e})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.fetchRequest.match),Vt(t),Bt((e=>{let[t,n]=e;var a,l;const o=null==(a=t.payload)?void 0:a.params,r=null==(l=t.payload)?void 0:l.query;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(r,o))),Mt((e=>{const{items:t}=e;return Dt(di.fetchComplete({assets:t}))})),Qt((e=>Dt(di.fetchError({message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500})))))})))}),((e,t)=>e.pipe(Nt(di.deleteComplete.match),Vt(t),Bt((e=>{let[t,n]=e;if(0===n.assets.allIds.length){const e=Math.floor(n.assets.allIds.length/n.assets.pageSize);return Dt(di.loadPageIndex({pageIndex:e}))}return jt()})))),((e,t)=>e.pipe(Nt(di.loadNextPage.match),Vt(t),Bt((e=>{let[t,n]=e;return Dt(di.loadPageIndex({pageIndex:n.assets.pageIndex+1}))})))),((e,t)=>e.pipe(Nt(di.loadPageIndex.match),Vt(t),Bt((e=>{let[t,n]=e;var i,a,l,o,r,s;const d=n.assets.pageSize,c=t.payload.pageIndex*d,u=c+d,p=null==(i=null==n?void 0:n.selected.document)?void 0:i._id,m=null==(a=null==n?void 0:n.selected)?void 0:a.documentAssetIds,y=Un({assetTypes:n.assets.assetTypes,searchFacets:n.search.facets,searchQuery:n.search.query}),f=B(B({},p?{documentId:p}:{}),{},{documentAssetIds:m});return Dt(di.fetchRequest({params:f,queryFilter:y,selector:vt(h||(h=H(["[","...","]"])),c,u),sort:vt(g||(g=H(["order("," ",")"])),null==(o=null==(l=n.assets)?void 0:l.order)?void 0:o.field,null==(s=null==(r=n.assets)?void 0:r.order)?void 0:s.direction)}))})))),(e=>e.pipe(Nt(di.listenerCreateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.asset));return Dt(di.listenerCreateQueueComplete({assets:t}))})))),(e=>e.pipe(Nt(di.listenerDeleteQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.assetId));return Dt(di.listenerDeleteQueueComplete({assetIds:t}))})))),(e=>e.pipe(Nt(di.listenerUpdateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.asset));return Dt(di.listenerUpdateQueueComplete({assets:t}))})))),(e=>e.pipe(Nt(di.orderSet.match),Mt((()=>Dt(di.clear(),di.loadPageIndex({pageIndex:0})))))),(e=>e.pipe(Rt(Zn.facetsAdd.type,Zn.facetsClear.type,Zn.facetsRemove.type,Zn.facetsUpdate.type,Zn.querySet.type),Ht(400),Mt((()=>Dt(di.clear(),di.loadPageIndex({pageIndex:0})))))),(e=>e.pipe(Rt(di.insertUploads.type,di.listenerUpdateQueueComplete.type,di.updateComplete.type),Mt((()=>Dt(di.sort()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Nn.tagsAddRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a,tag:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>{const e=ri(n),t=null==e?void 0:e.filter((e=>t=>{var n,i,a,l,o;return(null!=(o=null==(l=null==(a=null==(i=null==(n=null==t?void 0:t.asset)?void 0:n.opt)?void 0:i.media)?void 0:a.tags)?void 0:l.findIndex((t=>t._ref===(null==e?void 0:e._id))))?o:-1)<0})(l)),a=t.reduce(((e,t)=>{var n;return e.patch(null==(n=null==t?void 0:t.asset)?void 0:n._id,(e=>{let{tag:t}=e;return e=>e.setIfMissing({opt:{}}).setIfMissing({"opt.media":{}}).setIfMissing({"opt.media.tags":[]}).append("opt.media.tags",[{_key:St(),_ref:null==t?void 0:t._id,_type:"reference",_weak:!0}])})({tag:l}))}),i.transaction());return qt(a.commit())})),Mt((()=>Dt(Nn.tagsAddComplete({assets:a,tag:l})))),Qt((e=>Dt(Nn.tagsAddError({assets:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:l})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Nn.tagsRemoveRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a,tag:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>{const e=ri(n).reduce(((e,t)=>{var n;return e.patch(null==(n=null==t?void 0:t.asset)?void 0:n._id,(e=>{let{asset:t,tag:n}=e;return e=>{var i;return e.ifRevisionId(null==(i=null==t?void 0:t.asset)?void 0:i._rev).unset(['opt.media.tags[_ref == "'.concat(n._id,'"]')])}})({asset:t,tag:l}))}),i.transaction());return qt(e.commit())})),Mt((()=>Dt(Nn.tagsRemoveComplete({assets:a,tag:l})))),Qt((e=>Dt(Nn.tagsRemoveError({assets:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:l})))))})))}),(e=>e.pipe(Rt(di.orderSet.type,di.viewSet.type,Zn.facetsAdd.type,Zn.facetsClear.type,Zn.facetsRemove.type,Zn.facetsUpdate.type,Zn.querySet.type),Mt((()=>Dt(di.pickClear()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.updateRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{asset:a,closeDialogId:l,formData:o}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>qt(i.patch(a._id).setIfMissing({opt:{}}).setIfMissing({"opt.media":{}}).set(o).commit()))),Mt((e=>Dt(di.updateComplete({asset:e,closeDialogId:l})))),Qt((e=>Dt(di.updateError({asset:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500}})))))})))}),(e=>e.pipe(Rt(di.deleteComplete.type,di.updateComplete.type,Yn.deleteComplete.type,Yn.updateComplete.type),Nt((e=>{var t;return!!(null==(t=null==e?void 0:e.payload)?void 0:t.closeDialogId)})),Mt((e=>{var t;const n=null==(t=null==e?void 0:e.payload)?void 0:t.closeDialogId;return n?Dt(yi.actions.remove({id:n})):jt()})))),(e=>e.pipe(Nt(Yn.createComplete.match),Mt((e=>{const{assetId:t,tag:n}=null==e?void 0:e.payload;return t?Dt(yi.actions.inlineTagCreate({tag:n,assetId:t})):n._id?Dt(yi.actions.remove({id:"tagCreate"})):jt()})))),(e=>e.pipe(Nt(Yn.listenerDeleteQueueComplete.match),Mt((e=>{const{tagIds:t}=null==e?void 0:e.payload;return Dt(yi.actions.inlineTagRemove({tagIds:t}))})))),(e=>e.pipe(Nt(di.deleteError.match),Mt((e=>{const{assetIds:t}=e.payload,n=t.length;return Dt(no.actions.add({status:"error",title:"Unable to delete ".concat(n," ").concat(nn("asset",n),". Please review any asset errors and try again.")}))})))),(e=>e.pipe(Nt(di.deleteComplete.match),Mt((e=>{const{assetIds:t}=e.payload,n=t.length;return Dt(no.actions.add({status:"info",title:"".concat(n," ").concat(nn("asset",n)," deleted")}))})))),(e=>e.pipe(Nt(Nn.tagsAddComplete.match),Mt((e=>{var t,n;const i=null==(n=null==(t=null==e?void 0:e.payload)?void 0:t.assets)?void 0:n.length;return Dt(no.actions.add({status:"info",title:"Tag added to ".concat(i," ").concat(nn("asset",i))}))})))),(e=>e.pipe(Nt(Nn.tagsRemoveComplete.match),Mt((e=>{var t,n;const i=null==(n=null==(t=null==e?void 0:e.payload)?void 0:t.assets)?void 0:n.length;return Dt(no.actions.add({status:"info",title:"Tag removed from ".concat(i," ").concat(nn("asset",i))}))})))),(e=>e.pipe(Nt(di.updateComplete.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=e.length;return Dt(no.actions.add({status:"info",title:"".concat(t," ").concat(nn("asset",t)," updated")}))})))),(e=>e.pipe(Rt(di.fetchError.type,di.updateError.type,Yn.createError.type,Yn.deleteError.type,Yn.fetchError.type,Yn.updateError.type,Ol.uploadError.type),Mt((e=>{var t;const n=null==(t=e.payload)?void 0:t.error;return Dt(no.actions.add({status:"error",title:"An error occured: ".concat(n.message)}))})))),(e=>e.pipe(Nt(Yn.createComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag created"})))))),(e=>e.pipe(Nt(Yn.deleteComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag deleted"})))))),(e=>e.pipe(Nt(Yn.updateComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag updated"})))))),((e,t)=>e.pipe(Nt(Yn.updateComplete.match),Vt(t),Mt((e=>{let[t,n]=e;var i,a,l,o,r;const{tag:s}=t.payload,d=null==(i=n.search.facets)?void 0:i.find((e=>"tag"===e.name)),c=n.tags.byIds[s._id];return"searchable"===(null==d?void 0:d.type)&&(null==(a=d.value)?void 0:a.value)===s._id?Dt(Wn.actions.facetsUpdate({name:"tag",value:{label:null==(o=null==(l=null==c?void 0:c.tag)?void 0:l.name)?void 0:o.current,value:null==(r=null==c?void 0:c.tag)?void 0:r._id}})):jt()})))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.createRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assetId:a,name:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Pn(i,l),Mt((()=>i.observable.create({_type:"media.tag",name:{_type:"slug",current:l}}))),Mt((e=>Dt(Qn.actions.createComplete({assetId:a,tag:e})))),Qt((e=>Dt(Qn.actions.createError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},name:l})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.deleteRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{tag:a}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(vt(d||(d=H(['*[\n _type in ["sanity.fileAsset", "sanity.imageAsset"]\n && references(*[_type == "media.tag" && name.current == $tagName]._id)\n ] {\n _id,\n _rev,\n opt\n }']))),{tagName:a.name.current}))),Mt((e=>{const t=e.map((e=>({id:e._id,patch:{ifRevisionID:e._rev,unset:['opt.media.tags[_ref == "'.concat(a._id,'"]')]}}))).reduce(((e,t)=>e.patch(t.id,t.patch)),i.transaction());return t.delete(a._id),qt(t.commit())})),Mt((()=>Dt(Qn.actions.deleteComplete({tagId:a._id})))),Qt((e=>Dt(Qn.actions.deleteError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:a})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.fetchRequest.match),Vt(t),Bt((e=>{let[t,n]=e;const{query:a}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(a))),Mt((e=>{const{items:t}=e;return Dt(Qn.actions.fetchComplete({tags:t}))})),Qt((e=>Dt(Qn.actions.fetchError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500}})))))})))}),(e=>e.pipe(Nt(Qn.actions.listenerCreateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tag));return Dt(Qn.actions.listenerCreateQueueComplete({tags:t}))})))),(e=>e.pipe(Nt(Qn.actions.listenerDeleteQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tagId));return Dt(Qn.actions.listenerDeleteQueueComplete({tagIds:t}))})))),(e=>e.pipe(Nt(Qn.actions.listenerUpdateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tag));return Dt(Qn.actions.listenerUpdateQueueComplete({tags:t}))})))),(e=>e.pipe(Rt(Qn.actions.listenerCreateQueueComplete.type,Qn.actions.listenerUpdateQueueComplete.type),Xt(1e3),Nt((e=>e.length>0)),Mt((()=>Dt(Qn.actions.sort()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.updateRequest.match),Vt(t),Mt((e=>{let[t,n]=e;var a;const{closeDialogId:l,formData:o,tag:r}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Pn(i,null==(a=null==o?void 0:o.name)?void 0:a.current),Mt((()=>qt(i.patch(r._id).set({name:{_type:"slug",current:null==o?void 0:o.name.current}}).commit()))),Mt((e=>Dt(Qn.actions.updateComplete({closeDialogId:l,tag:e})))),Qt((e=>Dt(Qn.actions.updateError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:r})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Ol.uploadStart.match),Mt((t=>{const{file:n,uploadItem:a}=t.payload;return Ut(Dt(null).pipe(Mt((()=>(e=>Dt(null).pipe(Mt((()=>qt(Tl(e))))))(n))),Mt((e=>Dt(Ol.previewReady({blobUrl:e,hash:a.hash}))))),Dt(null).pipe(Mt((()=>El(i,a.assetType,n,a.hash))),Wt(e.pipe(Nt(Ol.uploadCancel.match),Nt((e=>e.payload.hash===a.hash)))),Mt((e=>"complete"===(null==e?void 0:e.type)?Dt(ei.uploadComplete({asset:e.asset})):"progress"===(null==e?void 0:e.type)&&"upload"===(null==e?void 0:e.stage)?Dt(Ol.uploadProgress({event:e,uploadHash:a.hash})):jt())),Qt((e=>Dt(Ol.uploadError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},hash:a.hash}))))))})))}),((e,t)=>e.pipe(Nt(Ol.uploadRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{file:i,forceAsAssetType:a}=t.payload;return Dt(t).pipe(Mt((()=>Rl(i))),Nt((e=>!!!n.uploads.byIds[e])),Mt((e=>{const t={_type:"upload",assetType:a||(i.type.indexOf("image")>=0?"image":"file"),hash:e,name:i.name,size:i.size,status:"queued"};return Dt(Ol.uploadStart({file:i,uploadItem:t}))})))})))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Ol.checkRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a}=t.payload,l=a.map((e=>e._id)),o=Un({assetTypes:n.assets.assetTypes,searchFacets:n.search.facets,searchQuery:n.search.query}),r=vt(z||(z=H(["\n *["," && _id in $documentIds].sha1hash\n "])),o);return Dt(t).pipe(Pt(1e3),Mt((()=>i.observable.fetch(r,{documentIds:l}))),Mt((e=>{const t=a.reduce(((t,n)=>(t[n.sha1hash]=e.includes(n.sha1hash)?n._id:null,t)),{});return Dt(Ol.checkComplete({results:t}),di.insertUploads({results:t}))})))})))}),(e=>e.pipe(Nt(ei.uploadComplete.match),Mt((e=>Dt(Ol.checkRequest({assets:[e.payload.asset]}))))))),oo=kt({assets:pi,debug:oa,dialog:vi,notifications:ao,search:Jn,selected:to,tags:$n,uploads:Dl}),ro=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),so=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];var n,i;return Array.isArray(e)&&e.forEach((e=>{so(e,t)})),ro(e)&&("reference"===(null==(n=null==e?void 0:e.asset)?void 0:n._type)&&(null==(i=null==e?void 0:e.asset)?void 0:i._ref)&&t.push(e.asset._ref),Object.values(e).forEach((e=>{so(e,t)}))),t},co=e=>{const t=so(e);return[...new Set(t.sort())]};class uo extends yt{constructor(e){super(e);const t=zt({dependencies:{client:e.client}});this.store=_t({reducer:oo,middleware:e=>e({serializableCheck:!1,thunk:!1}).prepend(t),devTools:!0,preloadedState:{assets:B(B({},ni),{},{assetTypes:(null==e?void 0:e.assetType)?[e.assetType]:["file","image"]}),selected:{assets:e.selectedAssets||[],document:e.document,documentAssetIds:e.document?co(e.document):[]}}}),t.run(lo)}render(){return ke(Ct,{store:this.store,children:this.props.children})}}const po=()=>{var e;return mi((e=>e.tags.panelVisible))?ke(qe,{style:{position:"relative",width:250},children:ke(qe,{className:"media__custom-scrollbar",style:{borderLeft:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),height:"100%",overflowX:"hidden",overflowY:"auto",position:"absolute",right:0,top:0,width:"100%"},children:ke(pl,{})})}):null},ho=Jt.div(U||(U=H(["\n color: white;\n height: 100%;\n min-height: 100%;\n right: 0;\n top: 0;\n width: 100%;\n\n &:focus {\n outline: none;\n }\n"]))),go=Jt.div(P||(P=H(["\n align-items: center;\n background: rgba(0, 0, 0, 0.75);\n display: flex;\n height: 100%;\n justify-content: center;\n position: absolute;\n right: 0;\n top: 0;\n width: 100%;\n z-index: 3;\n"])));const mo=e=>{const{children:t}=e,{onSelect:n}=Dn(),i=xt(),a=mi((e=>e.assets.assetTypes)),l=1===a.length&&"image"===a[0],{getRootProps:o,getInputProps:r,isDragActive:s,open:d}=wn({accept:l?"image/*":"",getFilesFromEvent:async e=>{var t;let n;if("drop"===e.type&&"dataTransfer"in e&&(n=null==(t=null==e?void 0:e.dataTransfer)?void 0:t.files),"change"===e.type){const t=null==e?void 0:e.target;(null==t?void 0:t.files)&&(n=t.files)}if(!n)return[];const a=await async function(e){const t=Array.from(e),n=[];for(const e of t)try{await e.slice(0,1).arrayBuffer(),n.push(e)}catch(e){}return n}(n);return(null==n?void 0:n.length)!==a.length&&i(io.add({status:"error",title:"Unable to upload some items (folders and packages aren't supported)"})),a},noClick:!0,noDrag:!!n,onDrop:async e=>{e.forEach((e=>i(Ol.uploadRequest({file:e,forceAsAssetType:1===a.length?a[0]:void 0}))))}});return ke(yl,{open:d,children:_e(ho,B(B({},o()),{},{children:[ke("input",B({},r())),s&&ke(go,{children:ke(je,{direction:"column",justify:"center",style:{color:Kt.hex},children:ke(Fe,{size:3,style:{color:"inherit"},children:"Drop files to upload"})})}),t]}))})},yo=e=>{let{onClose:t}=e;const n=qn(),i=xt(),a=e=>{const{documentId:t,result:n,transition:a}=e;"appear"===a&&i(di.listenerCreateQueue({asset:n})),"disappear"===a&&i(di.listenerDeleteQueue({assetId:t})),"update"===a&&i(di.listenerUpdateQueue({asset:n}))},l=e=>{const{documentId:t,result:n,transition:a}=e;"appear"===a&&i(Yn.listenerCreateQueue({tag:n})),"disappear"===a&&i(Yn.listenerDeleteQueue({tagId:t})),"update"===a&&i(Yn.listenerUpdateQueue({tag:n}))};return dt((()=>{i(di.loadPageIndex({pageIndex:0})),i(Yn.fetchRequest());const e=n.listen(vt(M||(M=H(['*[_type in ["sanity.fileAsset", "sanity.imageAsset"] && !(_id in path("drafts.**"))]'])))).subscribe(a),t=n.listen(vt(N||(N=H(['*[_type == "','" && !(_id in path("drafts.**"))]'])),"media.tag")).subscribe(l);return()=>{null==e||e.unsubscribe(),null==t||t.unsubscribe()}}),[]),_e(mo,{children:[ke(gl,{}),ke(Jl,{}),ke(Me,{display:"flex",height:"fill",children:_e(je,{direction:"column",flex:1,children:[ke(fl,{onClose:t}),ke(ia,{}),_e(je,{flex:1,children:[_e(je,{align:"flex-end",direction:"column",flex:1,style:{position:"relative"},children:[ke(eo,{}),ke(Zl,{})]}),ke(po,{})]}),ke(ra,{})]})})]})},fo=e=>{const t=qn();return ke(uo,{assetType:null==e?void 0:e.assetType,client:t,document:null==e?void 0:e.document,selectedAssets:null==e?void 0:e.selectedAssets,children:ke(it,{scheme:"dark",theme:Pe,children:ke(at,{children:_e(On,{onSelect:null==e?void 0:e.onSelect,children:[ke(gi,{}),ke(yo,{onClose:null==e?void 0:e.onClose})]})})})})},vo=()=>{const[e]=pt((()=>document.createElement("div")));return dt((()=>(e.classList.add("media-portal"),document.body.appendChild(e),()=>{document.body.removeChild(e)})),[]),e};var bo={title:"Media Tag",icon:ta,name:"media.tag",type:"document",fields:[{title:"Name",name:"name",type:"slug"}],preview:{select:{name:"name"},prepare(e){const{name:t}=e;return{media:ta,title:null==t?void 0:t.current}}}};const xo={icon:Te,name:"media",title:"Media"},Co=B(B({},xo),{},{component:e=>{const{onClose:t}=e,n=vo(),i=Z([]);In("escape",t);const a=e=>{e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()},{zIndex:l}=lt();return ke(ot,{element:n,children:ke(rt,{children:ke(qe,{onDragEnter:a,onDragLeave:a,onDragOver:a,onDrop:a,onMouseUp:a,style:{bottom:0,height:"auto",left:0,position:"fixed",top:0,width:"100%",zIndex:l},children:ke(fo,B({document:i},e))})})})}}),wo=B(B({},xo),{},{component:()=>ke(je,{direction:"column",height:"fill",flex:1,children:ke(fo,{})})}),Io=J({name:"media",form:{file:{assetSources:e=>[...e,Co]},image:{assetSources:e=>[...e,Co]}},schema:{types:[bo]},tools:e=>[...e,wo]});export{Io as media,Co as mediaAssetSource};
1
+ const e=["onValueChange","value"];var t,n,i,a,l,o,r,s,d,c,u,p,h,g,m,y,f,v,b,x,C,w,I,T,k,_,S,R,E,z,A,O,D,q,j,L,F,U,P,M,N;function V(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},l=Object.keys(e);for(i=0;i<l.length;i++)n=l[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(i=0;i<l.length;i++)n=l[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}import{useClient as Y,useDocumentStore as $,WithReferringDocuments as W,useSchema as G,Preview as K,useFormValue as Z,definePlugin as J}from"sanity";import{ThLargeIcon as ee,ThListIcon as te,SortIcon as ne,SelectIcon as ie,CloseIcon as ae,AddCircleIcon as le,SearchIcon as oe,PlugIcon as re,ClipboardIcon as se,DownloadIcon as de,ErrorOutlineIcon as ce,ChevronDownIcon as ue,AddIcon as pe,WarningOutlineIcon as he,EditIcon as ge,ArrowUpIcon as me,ArrowDownIcon as ye,TrashIcon as fe,ComposeIcon as ve,Icon as be,UploadIcon as xe,WarningFilledIcon as Ce,CheckmarkCircleIcon as we,ChevronUpIcon as Ie,ImageIcon as Te}from"@sanity/icons";import{jsx as ke,jsxs as _e,Fragment as Se}from"react/jsx-runtime";import{Inline as Re,Button as Ee,MenuButton as ze,Menu as Ae,MenuItem as Oe,MenuDivider as De,Box as qe,Flex as je,Label as Le,Text as Fe,TextInput as Ue,studioTheme as Pe,Card as Me,MenuGroup as Ne,useMediaIndex as Ve,Tooltip as Qe,Switch as Be,Popover as Xe,Stack as He,Dialog as Ye,TextArea as $e,TabList as We,Tab as Ge,TabPanel as Ke,Container as Ze,Spinner as Je,Checkbox as et,Grid as tt,useToast as nt,ThemeProvider as it,ToastProvider as at,useLayer as lt,PortalProvider as ot,Portal as rt}from"@sanity/ui";import{useRef as st,useEffect as dt,createContext as ct,useContext as ut,useState as pt,forwardRef as ht,useCallback as gt,memo as mt,Component as yt}from"react";import ft from"is-hotkey";import vt from"groq";import{useSelector as bt,useDispatch as xt,Provider as Ct}from"react-redux";import{createAction as wt,createSlice as It,createSelector as Tt,combineReducers as kt,configureStore as _t}from"@reduxjs/toolkit";import{nanoid as St}from"nanoid";import{ofType as Rt,combineEpics as Et,createEpicMiddleware as zt}from"redux-observable";import{iif as At,throwError as Ot,of as Dt,from as qt,empty as jt,Subject as Lt,Observable as Ft,merge as Ut}from"rxjs";import{delay as Pt,mergeMap as Mt,filter as Nt,withLatestFrom as Vt,catchError as Qt,switchMap as Bt,bufferTime as Xt,debounceTime as Ht,first as Yt,map as $t,takeUntil as Wt}from"rxjs/operators";import{hues as Gt,white as Kt,black as Zt}from"@sanity/color";import Jt,{css as en,createGlobalStyle as tn}from"styled-components";import nn from"pluralize";import{useNProgress as an}from"@tanem/react-nprogress";import ln,{components as on}from"react-select";import{Virtuoso as rn,VirtuosoGrid as sn,GroupedVirtuoso as dn}from"react-virtuoso";import{yupResolver as cn}from"@hookform/resolvers/yup";import{Controller as un,useForm as pn}from"react-hook-form";import*as hn from"yup";import gn from"date-fns/format";import mn from"filesize";import yn from"copy-to-clipboard";import{useIntentLink as fn}from"sanity/router";import{FileIcon as vn,defaultStyles as bn}from"react-file-icon";import xn from"react-select/creatable";import Cn from"date-fns/formatRelative";import{useDropzone as wn}from"react-dropzone";const In=(e,t)=>{const n=st(!1);function i(i){ft(e,i)&&(n.current=!0,t&&t())}const a=()=>{n.current=!1};return dt((()=>(window.addEventListener("keydown",i),window.addEventListener("keyup",a),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",a)})),[]),n},Tn={type:"divider"},kn={altText:{assetTypes:["file","image"],field:"altText",name:"altText",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Alt text",type:"string",value:""},description:{assetTypes:["file","image"],field:"description",name:"description",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Description",type:"string",value:""},fileName:{assetTypes:["file","image"],field:"originalFilename",name:"filename",operatorType:"includes",operatorTypes:["includes","doesNotInclude"],title:"File name",type:"string",value:""},height:{assetTypes:["image"],field:"metadata.dimensions.height",name:"height",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"Height",type:"number",value:400},inCurrentDocument:{assetTypes:["file","image"],name:"inCurrentDocument",operatorType:"is",options:[{name:"true",title:"True",value:vt(t||(t=H(["_id in $documentAssetIds"])))},{name:"false",title:"False",value:vt(n||(n=H(["!(_id in $documentAssetIds)"])))}],selectOnly:!0,title:"In use in current document",type:"select",value:"true"},inUse:{assetTypes:["file","image"],name:"inUse",operatorType:"is",options:[{name:"true",title:"True",value:vt(i||(i=H(["count(*[references(^._id)]) > 0"])))},{name:"false",title:"False",value:vt(a||(a=H(["count(*[references(^._id)]) == 0"])))}],title:"In use",type:"select",value:"true"},isOpaque:{assetTypes:["image"],field:"metadata.isOpaque",name:"isOpaque",operatorType:"equalTo",options:[{name:"true",title:"True",value:"false"},{name:"false",title:"False",value:"true"}],title:"Has transparency",type:"select",value:"true"},orientation:{assetTypes:["image"],name:"orientation",operatorType:"is",operatorTypes:["is","isNot"],options:[{name:"portrait",title:"Portrait",value:"metadata.dimensions.aspectRatio < 1"},{name:"landscape",title:"Landscape",value:"metadata.dimensions.aspectRatio > 1"},{name:"square",title:"Square",value:"metadata.dimensions.aspectRatio == 1"}],title:"Orientation",type:"select",value:"portrait"},size:{assetTypes:["file","image"],field:"size",modifier:"kb",modifiers:[{name:"kb",title:"KB",fieldModifier:e=>"round(".concat(e," / 1000)")},{name:"mb",title:"MB",fieldModifier:e=>"round(".concat(e," / 1000000)")}],name:"size",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"File size",type:"number",value:0},tag:{assetTypes:["file","image"],field:"opt.media.tags",name:"tag",operatorType:"references",operatorTypes:["references","doesNotReference",null,"empty","notEmpty"],title:"Tags",type:"searchable"},title:{assetTypes:["file","image"],field:"title",name:"title",operatorType:"empty",operatorTypes:["empty","notEmpty",null,"includes","doesNotInclude"],title:"Title",type:"string",value:""},type:{assetTypes:["file","image"],name:"type",operatorType:"is",operatorTypes:["is","isNot"],options:[{name:"image",title:"Image",value:'mimeType match "image*"'},{name:"video",title:"Video",value:'mimeType match "video*"'},{name:"audio",title:"Audio",value:'mimeType match "audio*"'},{name:"pdf",title:"PDF",value:'mimeType == "application/pdf"'}],title:"File type",type:"select",value:"image"},width:{assetTypes:["image"],field:"metadata.dimensions.width",name:"width",operatorType:"greaterThan",operatorTypes:["greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo",null,"equalTo"],title:"Width",type:"number",value:400}},_n={doesNotInclude:{fn:(e,t)=>e?"!(".concat(t," match '*").concat(e,"*')"):void 0,label:"does not include"},doesNotReference:{fn:(e,t)=>e?"!references('".concat(e,"')"):void 0,label:"does not include"},empty:{fn:(e,t)=>"!defined(".concat(t,")"),hideInput:!0,label:"is empty"},equalTo:{fn:(e,t)=>e?"".concat(t," == ").concat(e):void 0,label:"is equal to"},greaterThan:{fn:(e,t)=>e?"".concat(t," > ").concat(e):void 0,label:"is greater than"},greaterThanOrEqualTo:{fn:(e,t)=>e?"".concat(t," >= ").concat(e):void 0,label:"is greater than or equal to"},includes:{fn:(e,t)=>e?"".concat(t," match '*").concat(e,"*'"):void 0,label:"includes"},is:{fn:(e,t)=>"".concat(e),label:"is"},isNot:{fn:(e,t)=>"!(".concat(e,")"),label:"is not"},lessThan:{fn:(e,t)=>e?"".concat(t," < ").concat(e):void 0,label:"is less than"},lessThanOrEqualTo:{fn:(e,t)=>e?"".concat(t," <= ").concat(e):void 0,label:"is less than or equal to"},notEmpty:{fn:(e,t)=>"defined(".concat(t,")"),hideInput:!0,label:"is not empty"},references:{fn:(e,t)=>e?"references('".concat(e,"')"):void 0,label:"includes"}},Sn=[{direction:"desc",field:"_createdAt"},{direction:"asc",field:"_createdAt"},null,{direction:"desc",field:"_updatedAt"},{direction:"asc",field:"_updatedAt"},null,{direction:"asc",field:"originalFilename"},{direction:"desc",field:"originalFilename"},null,{direction:"desc",field:"size"},{direction:"asc",field:"size"}],Rn=[kn.tag,Tn,kn.inUse,kn.inCurrentDocument,Tn,kn.title,kn.altText,kn.description,Tn,kn.isOpaque,Tn,kn.fileName,kn.size,kn.type,Tn,kn.orientation,kn.width,kn.height],En="3rem 100px auto 1.5rem",zn="3rem 100px auto 5.5rem 5.5rem 3.5rem 8.5rem 2rem",An=ct(void 0),On=e=>{const{children:t,onSelect:n}=e,i={onSelect:n};return ke(An.Provider,{value:i,children:t})},Dn=()=>{const e=ut(An);if(void 0===e)throw new Error("useAssetSourceActions must be used within an AssetSourceDispatchProvider");return e},qn=()=>Y({apiVersion:"2022-10-01"}),jn={_createdAt:{asc:"Last created: Oldest first",desc:"Last created: Newest first"},_updatedAt:{asc:"Last updated: Oldest first",desc:"Last updated: Newest first"},mimeType:{asc:"MIME type: A to Z",desc:"MIME type: Z to A"},originalFilename:{asc:"File name: A to Z",desc:"File name: Z to A"},size:{asc:"File size: Smallest first",desc:"File size: Largest first"}},Ln=(e,t)=>jn[e][t],Fn=e=>function(t){return At((()=>!!e),t.pipe(Pt(3e3),Mt((e=>Math.random()>.5?Ot({message:"Test error",statusCode:500}):Dt(e)))),t)},Un=e=>{let{assetTypes:t,searchFacets:n,searchQuery:i}=e;const a=t.map((e=>"sanity.".concat(e,"Asset"))),r=vt(l||(l=H(["\n _type in ",' && !(_id in path("drafts.**"))\n '])),JSON.stringify(a)),s=n.reduce(((e,t)=>{var n;if("number"===t.type){const{field:n,modifier:i,modifiers:a,operatorType:l,value:o}=t,r=_n[l],s=null==a?void 0:a.find((e=>e.name===i)),d=(null==s?void 0:s.fieldModifier)?s.fieldModifier(n):n,c=r.fn(o,d);c&&e.push(c)}if("searchable"===t.type){const{field:n,operatorType:i,value:a}=t,l=_n[i].fn(null==a?void 0:a.value,n);l&&e.push(l)}if("select"===t.type){const{field:i,operatorType:a,options:l,value:o}=t,r=_n[a],s=null==(n=null==l?void 0:l.find((e=>e.name===o)))?void 0:n.value,d=r.fn(s,i);d&&e.push(d)}if("string"===t.type){const{field:n,operatorType:i,value:a}=t,l=_n[i].fn(a,n);l&&e.push(l)}return e}),[]);return[r,...i?[vt(o||(o=H(["[_id, altText, assetId, description, originalFilename, title, url] match '*","*'"])),i.trim())]:[],...s].join(" && ")},Pn=(e,t)=>function(n){return n.pipe(Mt((()=>qt(e.fetch(vt(r||(r=H(['count(*[_type == "','" && name.current == $name])'])),"media.tag"),{name:t})))),Mt((e=>e>0?Ot({message:"Tag already exists",statusCode:409}):Dt(!0))))},Mn=e=>e.reduce(((e,t)=>{var n;const i=null==t?void 0:t.tag;return i&&e.push({label:null==(n=null==i?void 0:i.name)?void 0:n.current,value:null==i?void 0:i._id}),e}),[]),Nn={tagsAddComplete:wt("actions/tagsAddComplete",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsAddError:wt("actions/tagsAddError",(function(e){let{assets:t,error:n,tag:i}=e;return{payload:{assets:t,error:n,tag:i}}})),tagsAddRequest:wt("actions/tagsAddRequest",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsRemoveComplete:wt("actions/tagsRemoveComplete",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}})),tagsRemoveError:wt("actions/tagsRemoveError",(function(e){let{assets:t,error:n,tag:i}=e;return{payload:{assets:t,error:n,tag:i}}})),tagsRemoveRequest:wt("actions/tagsRemoveRequest",(function(e){let{assets:t,tag:n}=e;return{payload:{assets:t,tag:n}}}))},Vn={showTagCreate:wt("dialog/showTagCreate"),showTagEdit:wt("dialog/showTagEdit",(function(e){let{tagId:t}=e;return{payload:{tagId:t}}}))},Qn=It({name:"tags",initialState:{allIds:[],byIds:{},creating:!1,creatingError:void 0,fetchCount:-1,fetching:!1,fetchingError:void 0,panelVisible:!0},extraReducers:e=>{e.addCase(Vn.showTagCreate,(e=>{delete e.creatingError})).addCase(Vn.showTagEdit,((e,t)=>{const{tagId:n}=t.payload;delete e.byIds[n].error})).addMatcher((e=>[Nn.tagsAddComplete.type,Nn.tagsAddError.type,Nn.tagsRemoveComplete.type,Nn.tagsRemoveError.type].includes(e.type)),((e,t)=>{const{tag:n}=t.payload;e.byIds[n._id].updating=!1})).addMatcher((e=>[Nn.tagsAddRequest.type,Nn.tagsRemoveRequest.type].includes(e.type)),((e,t)=>{const{tag:n}=t.payload;e.byIds[n._id].updating=!0}))},reducers:{createComplete(e,t){const{tag:n}=t.payload;e.creating=!1,e.allIds.includes(n._id)||e.allIds.push(n._id),e.byIds[n._id]={_type:"tag",picked:!1,tag:n,updating:!1}},createError(e,t){e.creating=!1,e.creatingError=t.payload.error},createRequest(e,t){e.creating=!0,delete e.creatingError},deleteComplete(e,t){const{tagId:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),delete e.byIds[n]},deleteError(e,t){const{error:n,tag:i}=t.payload,a=null==i?void 0:i._id;e.byIds[a].error=n,e.byIds[a].updating=!1},deleteRequest(e,t){var n,i;const a=null==(i=null==(n=t.payload)?void 0:n.tag)?void 0:i._id;e.byIds[a].picked=!1,e.byIds[a].updating=!0,Object.keys(e.byIds).forEach((t=>{delete e.byIds[t].error}))},fetchComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.allIds.push(t._id),e.byIds[t._id]={_type:"tag",picked:!1,tag:t,updating:!1}})),e.fetching=!1,e.fetchCount=n.length||0,delete e.fetchingError},fetchError(e,t){const{error:n}=t.payload;e.fetching=!1,e.fetchingError=n},fetchRequest:{reducer:(e,t)=>{e.fetching=!0,delete e.fetchingError},prepare:()=>({payload:{query:vt(s||(s=H(['\n {\n "items": *[\n _type == "','"\n && !(_id in path("drafts.**"))\n ] {\n _createdAt,\n _updatedAt,\n _id,\n _rev,\n _type,\n name\n } | order(name.current asc),\n }\n '])),"media.tag")}})},listenerCreateQueue(e,t){},listenerCreateQueueComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.byIds[t._id]={_type:"tag",picked:!1,tag:t,updating:!1},e.allIds.includes(t._id)||e.allIds.push(t._id)}))},listenerDeleteQueue(e,t){},listenerDeleteQueueComplete(e,t){const{tagIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]}))},listenerUpdateQueue(e,t){},listenerUpdateQueueComplete(e,t){const{tags:n}=t.payload;null==n||n.forEach((t=>{e.byIds[t._id]&&(e.byIds[t._id].tag=t)}))},panelVisibleSet(e,t){const{panelVisible:n}=t.payload;e.panelVisible=n},sort(e){e.allIds.sort(((t,n)=>{const i=e.byIds[t].tag.name.current,a=e.byIds[n].tag.name.current;return i<a?-1:i>a?1:0}))},updateComplete(e,t){const{tag:n}=t.payload;e.byIds[n._id].tag=n,e.byIds[n._id].updating=!1},updateError(e,t){const{error:n,tag:i}=t.payload,a=null==i?void 0:i._id;e.byIds[a].error=n,e.byIds[a].updating=!1},updateRequest(e,t){const{tag:n}=t.payload;e.byIds[null==n?void 0:n._id].updating=!0}}}),Bn=e=>e.tags.byIds,Xn=Tt([Bn,e=>e.tags.allIds],((e,t)=>t.map((t=>e[t])))),Hn=Tt([Bn,(e,t)=>t],((e,t)=>e[t])),Yn=Qn.actions;var $n=Qn.reducer;const Wn=It({name:"search",initialState:{facets:[],query:""},reducers:{facetsAdd(e,t){e.facets.push(t.payload.facet)},facetsClear(e){e.facets=[]},facetsRemove(e,t){e.facets=e.facets.filter((e=>e.name!==t.payload.facetName))},facetsUpdate(e,t){const{modifier:n,name:i,operatorType:a,value:l}=t.payload;e.facets.forEach(((t,o)=>{t.name===i&&("number"===t.type&&n&&(t.modifier=n),a&&(t.operatorType=a),void 0!==l&&(e.facets[o].value=l))}))},querySet(e,t){var n;e.query=null==(n=t.payload)?void 0:n.searchQuery}}}),Gn=Tt((e=>e.search.facets),(e=>!!(null==e?void 0:e.find((e=>"tag"===e.name))))),Kn=Tt([e=>e.tags.byIds,e=>e.search.facets,(e,t)=>t],((e,t,n)=>{var i,a,l;const o=null==t?void 0:t.find((e=>"tag"===e.name));if("searchable"===(null==o?void 0:o.type)){const t=null==(i=o.value)?void 0:i.value;if(t)return(null==(l=null==(a=e[t])?void 0:a.tag)?void 0:l._id)===n&&"references"===(null==o?void 0:o.operatorType)}return!1})),Zn=Wn.actions;var Jn=Wn.reducer;const ei={uploadComplete:wt("uploads/uploadComplete",(function(e){let{asset:t}=e;return{payload:{asset:t}}}))},ti=Sn[0],ni={allIds:[],assetTypes:[],byIds:{},fetchCount:-1,fetching:!1,fetchingError:void 0,lastPicked:void 0,order:{direction:ti.direction,field:ti.field,title:Ln(ti.field,ti.direction)},pageIndex:0,pageSize:50,view:"grid"},ii=It({name:"assets",initialState:ni,extraReducers:e=>{e.addCase(ei.uploadComplete,((e,t)=>{const{asset:n}=t.payload;e.byIds[n._id]={_type:"asset",asset:n,picked:!1,updating:!1}})).addCase(Nn.tagsAddComplete,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsAddError,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsAddRequest,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!0}))})).addCase(Nn.tagsRemoveComplete,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsRemoveError,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!1}))})).addCase(Nn.tagsRemoveRequest,((e,t)=>{const{assets:n}=t.payload;n.forEach((t=>{e.byIds[t.asset._id].updating=!0}))}))},reducers:{clear(e){e.allIds=[]},deleteComplete(e,t){const{assetIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]})),e.pageIndex=Math.floor(e.allIds.length/e.pageSize)-1},deleteError(e,t){var n,i,a,l;const{assetIds:o,error:r}=t.payload,s=null==(l=null==(a=null==(i=null==(n=null==r?void 0:r.response)?void 0:n.body)?void 0:i.error)?void 0:a.items)?void 0:l.map((e=>e.error));null==o||o.forEach((t=>{e.byIds[t].updating=!1})),null==s||s.forEach((t=>{e.byIds[t.id].error=t.description}))},deleteRequest(e,t){const{assets:n}=t.payload;n.forEach((t=>{e.byIds[null==t?void 0:t._id].updating=!0})),Object.keys(e.byIds).forEach((t=>{delete e.byIds[t].error}))},fetchComplete(e,t){var n;const i=(null==(n=t.payload)?void 0:n.assets)||[];i&&i.forEach((t=>{e.allIds.includes(t._id)||e.allIds.push(t._id),e.byIds[t._id]={_type:"asset",asset:t,picked:!1,updating:!1}})),e.fetching=!1,e.fetchCount=i.length||0,delete e.fetchingError},fetchError(e,t){const n=t.payload;e.fetching=!1,e.fetchingError=n},fetchRequest:{reducer:(e,t)=>{e.fetching=!0,delete e.fetchingError},prepare:e=>{let{params:t={},queryFilter:n,selector:i="",sort:a=vt(c||(c=H(["order(_updatedAt desc)"])))}=e;const l=a||i?"|":"";return{payload:{params:t,query:vt(u||(u=H(['\n {\n "items": *[',"] {\n _id,\n _type,\n _createdAt,\n _updatedAt,\n altText,\n description,\n extension,\n metadata {\n dimensions,\n exif,\n isOpaque,\n },\n mimeType,\n opt {\n media\n },\n originalFilename,\n size,\n title,\n url\n } "," "," ",",\n }\n "])),n,l,a,i)}}}},insertUploads(e,t){const{results:n}=t.payload;Object.entries(n).forEach((t=>{let[n,i]=t;i&&!e.allIds.includes(n)&&e.allIds.push(i)}))},listenerCreateQueue(e,t){},listenerCreateQueueComplete(e,t){const{assets:n}=t.payload;null==n||n.forEach((t=>{var n;(null==(n=e.byIds[null==t?void 0:t._id])?void 0:n.asset)&&(e.byIds[t._id].asset=t)}))},listenerDeleteQueue(e,t){},listenerDeleteQueueComplete(e,t){const{assetIds:n}=t.payload;null==n||n.forEach((t=>{const n=e.allIds.indexOf(t);n>=0&&e.allIds.splice(n,1),delete e.byIds[t]}))},listenerUpdateQueue(e,t){},listenerUpdateQueueComplete(e,t){const{assets:n}=t.payload;null==n||n.forEach((t=>{var n;(null==(n=e.byIds[null==t?void 0:t._id])?void 0:n.asset)&&(e.byIds[t._id].asset=t)}))},loadNextPage(){},loadPageIndex(e,t){e.pageIndex=t.payload.pageIndex},orderSet(e,t){var n;e.order=null==(n=t.payload)?void 0:n.order,e.pageIndex=0},pick(e,t){const{assetId:n,picked:i}=t.payload;e.byIds[n].picked=i,e.lastPicked=i?n:void 0},pickAll(e){e.allIds.forEach((t=>{e.byIds[t].picked=!0}))},pickClear(e){e.lastPicked=void 0,Object.values(e.byIds).forEach((t=>{e.byIds[t.asset._id].picked=!1}))},pickRange(e,t){const n=e.allIds.findIndex((e=>e===t.payload.startId)),i=e.allIds.findIndex((e=>e===t.payload.endId)),a=[n,i].sort(((e,t)=>e-t));e.allIds.slice(a[0],a[1]+1).forEach((t=>{e.byIds[t].picked=!0})),e.lastPicked=e.allIds[i]},sort(e){e.allIds.sort(((t,n)=>{const i=e.byIds[t].asset[e.order.field],a=e.byIds[n].asset[e.order.field];return i<a?"asc"===e.order.direction?-1:1:i>a?"asc"===e.order.direction?1:-1:0}))},updateComplete(e,t){const{asset:n}=t.payload;e.byIds[n._id].updating=!1,e.byIds[n._id].asset=n},updateError(e,t){const{asset:n,error:i}=t.payload,a=null==n?void 0:n._id;e.byIds[a].error=i.message,e.byIds[a].updating=!1},updateRequest(e,t){var n,i;const a=null==(i=null==(n=t.payload)?void 0:n.asset)?void 0:i._id;e.byIds[a].updating=!0},viewSet(e,t){var n;e.view=null==(n=t.payload)?void 0:n.view}}}),ai=Tt([e=>e.assets.byIds,(e,t)=>t],((e,t)=>e[t])),li=Tt([e=>e.assets.byIds,e=>e.assets.allIds],((e,t)=>t.map((t=>e[t])))),oi=Tt([li],(e=>e.length)),ri=Tt([li],(e=>e.filter((e=>null==e?void 0:e.picked)))),si=Tt([ri],(e=>e.length)),di=ii.actions;var ci,ui,pi=ii.reducer;const hi=en(m||(m=H(["\n ::-webkit-scrollbar {\n width: 14px;\n }\n\n ::-webkit-scrollbar-thumb {\n border-radius: 10px;\n border: 4px solid rgba(0, 0, 0, 0);\n background: ",";\n background-clip: padding-box;\n\n &:hover {\n background: ",";\n background-clip: padding-box;\n }\n }\n"])),null==(ci=Gt.gray)?void 0:ci[800].hex,null==(ui=Gt.gray)?void 0:ui[400].hex),gi=tn(y||(y=H(["\n .media__custom-scrollbar {\n ",'\n }\n\n // @sanity/ui overrides\n\n // Custom scrollbar on Box (used in Dialogs)\n div[data-ui="Box"] {\n ','\n }\n\n // Dialog background color\n div[data-ui="Dialog"] {\n background-color: rgba(15, 17, 18, 0.9);\n }\n\n'])),hi,hi),mi=bt,yi=It({name:"dialog",initialState:{items:[]},extraReducers:e=>{e.addCase(Vn.showTagCreate,(e=>{e.items.push({id:"tagCreate",type:"tagCreate"})})),e.addCase(Vn.showTagEdit,((e,t)=>{const{tagId:n}=t.payload;e.items.push({id:n,tagId:n,type:"tagEdit"})}))},reducers:{clear(e){e.items=[]},inlineTagCreate(e,t){const{assetId:n,tag:i}=t.payload;e.items.forEach((e=>{"assetEdit"===e.type&&e.assetId===n&&(e.lastCreatedTag={label:i.name.current,value:i._id})}))},inlineTagRemove(e,t){const{tagIds:n}=t.payload;e.items.forEach((e=>{"assetEdit"===e.type&&(e.lastRemovedTagIds=n)}))},remove(e,t){var n;const i=null==(n=t.payload)?void 0:n.id;e.items=e.items.filter((e=>e.id!==i))},showConfirmAssetsTagAdd(e,t){const{assetsPicked:n,closeDialogId:i,tag:a}=t.payload,l="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:Nn.tagsAddRequest({assets:n,tag:a}),confirmText:"Yes, add tag to ".concat(l),title:"Add tag ".concat(a.name.current," to ").concat(l,"?"),id:"confirm",headerTitle:"Confirm tag addition",tone:"primary",type:"confirm"})},showConfirmAssetsTagRemove(e,t){const{assetsPicked:n,closeDialogId:i,tag:a}=t.payload,l="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:Nn.tagsRemoveRequest({assets:n,tag:a}),confirmText:"Yes, remove tag from ".concat(l),headerTitle:"Confirm tag removal",id:"confirm",title:"Remove tag ".concat(a.name.current," from ").concat(l,"?"),tone:"critical",type:"confirm"})},showConfirmDeleteAssets(e,t){const{assets:n,closeDialogId:i}=t.payload,a="".concat(n.length," ").concat(nn("asset",n.length));e.items.push({closeDialogId:i,confirmCallbackAction:di.deleteRequest({assets:n.map((e=>e.asset))}),confirmText:"Yes, delete ".concat(a),description:"This operation cannot be reversed. Are you sure you want to continue?",title:"Permanently delete ".concat(a,"?"),id:"confirm",headerTitle:"Confirm deletion",tone:"critical",type:"confirm"})},showConfirmDeleteTag(e,t){const{closeDialogId:n,tag:i}=t.payload;e.items.push({closeDialogId:n,confirmCallbackAction:Yn.deleteRequest({tag:i}),confirmText:"Yes, delete ".concat("tag"),description:"This operation cannot be reversed. Are you sure you want to continue?",title:"Permanently delete ".concat("tag","?"),id:"confirm",headerTitle:"Confirm deletion",tone:"critical",type:"confirm"})},showAssetEdit(e,t){const{assetId:n}=t.payload;e.items.push({assetId:n,id:n,type:"assetEdit"})},showSearchFacets(e){e.items.push({id:"searchFacets",type:"searchFacets"})},showTags(e){e.items.push({id:"tags",type:"tags"})}}}),fi=yi.actions;var vi=yi.reducer;const bi=()=>{const e=xt(),t=mi((e=>e.assets.view));return _e(Re,{space:0,style:{whiteSpace:"nowrap"},children:[ke(Ee,{fontSize:1,icon:ee,mode:"grid"===t?"default":"ghost",onClick:()=>e(di.viewSet({view:"grid"})),style:{borderBottomRightRadius:0,borderTopRightRadius:0}}),ke(Ee,{fontSize:1,icon:te,mode:"table"===t?"default":"ghost",onClick:()=>e(di.viewSet({view:"table"})),style:{borderBottomLeftRadius:0,borderTopLeftRadius:0}})]})},xi=()=>{var e;const t=xt(),n=mi((e=>e.assets.order));return ke(ze,{button:ke(Ee,{fontSize:1,icon:ne,iconRight:ie,mode:"ghost",padding:3,text:Ln(n.field,n.direction)}),id:"order",menu:ke(Ae,{children:null==(e=Sn)?void 0:e.map(((e,i)=>e?ke(Oe,{disabled:n.field===e.field&&n.direction===e.direction,fontSize:1,onClick:()=>t(di.orderSet({order:{direction:e.direction,field:e.field}})),padding:2,text:Ln(e.field,e.direction)},i):ke(De,{},i)))})})},Ci=e=>{const{loading:t}=e,{animationDuration:n,isFinished:i,progress:a}=an({animationDuration:300,isAnimating:t});return ke(qe,{style:{opacity:i?0:1,transition:"opacity ".concat(n,"ms linear")},children:ke(qe,{style:{height:"1px",background:"rgba(255, 255, 255, 0.5)",position:"absolute",left:0,top:0,transition:"width ".concat(n,"ms linear"),width:"".concat(100*a,"%")}})})},wi=Jt(qe)(f||(f=H(["\n background: rgba(255, 255, 255, 0.05);\n border-radius: ","px;\n"])),(e=>e.theme.sanity.radius[2])),Ii=e=>{const{children:t,facet:n}=e,i=xt();return ke(wi,{padding:[2,2,1],children:_e(je,{align:["flex-start","flex-start","center"],direction:["column","column","row"],children:[ke(qe,{paddingBottom:[3,3,0],paddingLeft:1,paddingRight:2,paddingTop:[1,1,0],children:ke(Le,{size:0,style:{whiteSpace:"nowrap"},children:n.title})}),_e(je,{align:"center",children:[t,ke(qe,{marginLeft:1,paddingX:2,children:ke(Fe,{muted:!0,size:0,children:ke(ae,{onClick:()=>{i(Zn.facetsRemove({facetName:n.name}))}})})})]})]})})},Ti=t=>{const{onValueChange:n,value:i}=t,a=V(t,e);return ke(Ue,B(B({},a),{},{onChange:e=>{const t=e.target.value;(""===t||/^[0-9\b]+$/.test(t))&&n(parseInt(t,10)||"")},value:null!=i?i:""}))},ki=e=>{var t;const{facet:n}=e,i=xt(),a=null==n?void 0:n.modifiers,l=(null==n?void 0:n.modifier)?null==a?void 0:a.find((e=>e.name===(null==n?void 0:n.modifier))):null==a?void 0:a[0],o=null!=(t=n.operatorType)?t:"greaterThan";return _e(Ii,{facet:n,children:[(null==n?void 0:n.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[o].label}),id:"operators",menu:ke(Ae,{children:n.operatorTypes.map(((e,t)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},t)))})}),ke(qe,{marginX:1,style:{maxWidth:"50px"},children:ke(Ti,{fontSize:1,onValueChange:e=>{i(Zn.facetsUpdate({name:n.name,value:e}))},padding:2,radius:2,width:2,value:null==n?void 0:n.value})}),a&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:null==l?void 0:l.title}),id:"modifier",menu:ke(Ae,{children:a.map((e=>ke(Oe,{disabled:e.name===n.modifier,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,modifier:e.name}))})(e),padding:2,text:e.title},e.name)))})})]})},_i=e=>{var t;const{facet:n}=e,i=xt(),a=null==n?void 0:n.options,l=null==a?void 0:a.find((e=>e.name===(null==n?void 0:n.value))),o=null!=(t=null==n?void 0:n.operatorType)?t:"is";return _e(Ii,{facet:n,children:[(null==n?void 0:n.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,style:{marginRight:"4px"},text:_n[o].label}),id:"operators",menu:ke(Ae,{children:n.operatorTypes.map(((e,t)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{i(Zn.facetsUpdate({name:n.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},t)))})}),ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:null==l?void 0:l.title}),id:"list",menu:ke(Ae,{children:null==a?void 0:a.map(((e,t)=>ke(Oe,{disabled:e.name===(null==l?void 0:l.name),fontSize:1,onClick:()=>{return e=a[t],void i(Zn.facetsUpdate({name:n.name,value:e.name}));var e},padding:2,text:e.title},e.name)))})})]})},Si=e=>{const{facet:t}=e,n=xt(),i=t.operatorType;return _e(Ii,{facet:t,children:[(null==t?void 0:t.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[i].label}),id:"operators",menu:ke(Ae,{children:t.operatorTypes.map(((e,a)=>e?ke(Oe,{disabled:e===i,fontSize:1,onClick:()=>(e=>{n(Zn.facetsUpdate({name:t.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},a)))})}),!_n[i].hideInput&&ke(qe,{marginLeft:1,style:{maxWidth:"125px"},children:ke(Ue,{fontSize:1,onChange:e=>{n(Zn.facetsUpdate({name:t.name,value:e.target.value}))},padding:2,radius:2,width:2,value:null==t?void 0:t.value})})]})};var Ri,Ei,zi,Ai,Oi,Di,qi,ji,Li,Fi,Ui,Pi,Mi,Ni,Vi;const Qi=null==(Oi=null==(Ai=null==(zi=null==(Ei=null==(Ri=Pe)?void 0:Ri.color)?void 0:Ei.dark)?void 0:zi.primary)?void 0:Ai.spot)?void 0:Oi.blue,Bi=null==(Fi=null==(Li=null==(ji=null==(qi=null==(Di=Pe)?void 0:Di.color)?void 0:qi.dark)?void 0:ji.default)?void 0:Li.base)?void 0:Fi.bg,Xi=null==(Ui=Pe)?void 0:Ui.radius,Hi=null==(Pi=Pe)?void 0:Pi.space,Yi=null==(Vi=null==(Ni=null==(Mi=Pe)?void 0:Mi.fonts)?void 0:Ni.text)?void 0:Vi.sizes,$i={control:(e,t)=>{let{isDisabled:n,isFocused:i}=t,a="inset 0 0 0 1px ".concat(Gt.gray[900].hex);return i&&(a="inset 0 0 0 1px ".concat(Gt.gray[900].hex,", 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important")),B(B({},e),{},{backgroundColor:Bi,color:Kt.hex,border:"none",borderRadius:Xi[2],boxShadow:a,fontSize:Yi[1].fontSize,minHeight:"25px",opacity:n?.5:"inherit",outline:"none",transition:"none","&:hover":{boxShadow:"inset 0 0 0 1px ".concat(Pe.color.dark.default.input.default.hovered.border)}})},input:e=>B(B({},e),{},{color:Kt.hex,fontFamily:Pe.fonts.text.family,marginLeft:Hi[2]}),menuList:e=>B(B({},e),{},{padding:0}),noOptionsMessage:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,fontSize:Yi[1].fontSize,lineHeight:"1em"}),option:(e,t)=>{let{isFocused:n}=t;return B(B({},e),{},{backgroundColor:n?Qi:"transparent",borderRadius:Xi[2],color:n?Zt.hex:"inherit",fontSize:Yi[1].fontSize,lineHeight:"1em",padding:"4px 6px","&:hover":{backgroundColor:Qi,color:Zt.hex}})},placeholder:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,marginLeft:Hi[2],paddingBottom:"2px"}),singleValue:e=>B(B({},e),{},{color:Kt.hex,lineHeight:"1em",paddingBottom:"1px"}),valueContainer:e=>B(B({},e),{},{margin:0,padding:0})},Wi=e=>ke(qe,{padding:1,children:ke(on.Option,B(B({},e),{},{children:ke(qe,{paddingY:1,children:ke(Fe,{size:1,style:{color:"inherit"},textOverflow:"ellipsis",children:e.children})})}))}),Gi={ClearIndicator:e=>ke(on.ClearIndicator,B(B({},e),{},{children:ke(qe,{paddingRight:1,style:{transform:"scale(0.85)"},children:ke(Fe,{muted:!0,size:0,children:ke(ae,{})})})})),DropdownIndicator:null,IndicatorSeparator:null,Menu:e=>ke(on.Menu,B(B({},e),{},{children:ke(Me,{radius:1,shadow:2,children:e.children})})),MenuList:e=>{const{children:t}=e;if(Array.isArray(t)){const e=t.length>5?165:33*t.length;return ke(rn,{className:"media__custom-scrollbar",itemContent:e=>{const n=t[e];return ke(Wi,B({},n.props))},style:{height:e},totalCount:t.length})}return ke(on.MenuList,B(B({},e),{},{children:t}))},NoOptionsMessage:e=>ke(on.NoOptionsMessage,B(B({},e),{},{children:e.children})),Option:Wi,SingleValue:e=>ke(on.SingleValue,B(B({},e),{},{children:ke(qe,{paddingLeft:2,children:ke(Fe,{size:1,style:{color:"inherit",lineHeight:"2em"},textOverflow:"ellipsis",children:e.children})})}))},Ki=e=>{const{facet:t}=e,n=xt(),i=mi((e=>Xn(e))),a=mi((e=>e.tags.fetching)),l=Mn(i),o=t.operatorType;return _e(Ii,{facet:t,children:[(null==t?void 0:t.operatorTypes)&&ke(ze,{button:ke(Ee,{fontSize:1,iconRight:ie,padding:2,text:_n[o].label}),id:"operators",menu:ke(Ae,{children:t.operatorTypes.map(((e,i)=>e?ke(Oe,{disabled:e===o,fontSize:1,onClick:()=>(e=>{n(Zn.facetsUpdate({name:t.name,operatorType:e}))})(e),padding:2,text:_n[e].label},e):ke(De,{},i)))})}),!_n[o].hideInput&&ke(qe,{marginX:1,style:{width:"160px"},children:ke(ln,{components:Gi,instanceId:"facet-searchable",isClearable:!0,isDisabled:a,isSearchable:!0,name:"tags",noOptionsMessage:()=>"No tags",onChange:e=>{return i=e,void n(Zn.facetsUpdate({name:t.name,value:i}));var i},options:l,placeholder:a?"Loading...":"Select...",styles:$i,value:null==t?void 0:t.value})})]})},Zi=Jt(je)(v||(v=H(["\n > * {\n margin-bottom: ","px;\n }\n"])),(e=>e.theme.sanity.space[2])),Ji=e=>{const{layout:t="inline"}=e,n=mi((e=>e.search.facets)),i=n.map((e=>"number"===e.type?ke(ki,{facet:e},e.name):"searchable"===e.type?ke(Ki,{facet:e},e.name):"select"===e.type?ke(_i,{facet:e},e.name):"string"===e.type?ke(Si,{facet:e},e.name):null));if("inline"===t)return 0===n.length?null:ke(qe,{marginBottom:2,children:ke(Re,{space:2,children:i})});if("stack"===t)return ke(Zi,{align:"flex-start",direction:"column",children:i});throw Error("Invalid layout")},ea=()=>{const e=xt(),t=mi((e=>e.assets.assetTypes)),n=mi((e=>e.search.facets)),i=!mi((e=>e.selected.document)),a=Rn.filter((e=>{if("group"===e.type||"divider"===e.type)return!0;if(i)return!(null==e?void 0:e.selectOnly);return e.assetTypes.filter((e=>t.includes(e))).length>0})).filter(((e,t,n)=>{const i=n[t-1];return("divider"!==e.type||0!==t&&t!==n.length-1)&&("divider"!==e.type||"divider"!==(null==i?void 0:i.type))})),l=a.filter((e=>e)).length-n.length>0,o=function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ke(Se,{children:null==t?void 0:t.map(((t,a)=>{if("divider"===t.type)return ke(De,{},a);if("group"===t.type)return ke(Ne,{text:t.title,title:t.title,children:o(t.facets,i+1)},"group-".concat(i,"-").concat(a));if(t){const i=!!n.find((e=>e.name===t.name));return ke(Oe,{disabled:i,fontSize:1,onClick:()=>e(Zn.facetsAdd({facet:t})),padding:2,text:t.title},t.name)}return null}))})};return _e(je,{children:[ke(ze,{button:ke(Ee,{disabled:!l,fontSize:1,icon:le,mode:"bleed",text:"Add filter",tone:"primary"}),id:"facets",menu:ke(Ae,{children:o(a)}),placement:"right-start",portal:!0}),n.length>0&&ke(Ee,{fontSize:1,mode:"bleed",onClick:()=>e(Zn.facetsClear()),text:"Clear"})]})},ta=()=>_e("svg",{"data-sanity-icon":"media__tag",fill:"currentColor",height:"1em",stroke:"currentColor",strokeWidth:"0",viewBox:"0 0 512 512",width:"1em",children:[ke("path",{d:"M435.25 48h-122.9a14.46 14.46 0 00-10.2 4.2L56.45 297.9a28.85 28.85 0 000 40.7l117 117a28.85 28.85 0 0040.7 0L459.75 210a14.46 14.46 0 004.2-10.2v-123a28.66 28.66 0 00-28.7-28.8z",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32"}),ke("path",{d:"M384 160a32 32 0 1132-32 32 32 0 01-32 32z"})]}),na=()=>{const e=mi((e=>e.search.query)),t=xt();return _e(qe,{style:{position:"relative"},children:[ke(Ue,{fontSize:1,icon:oe,onChange:e=>{t(Zn.querySet({searchQuery:e.currentTarget.value}))},placeholder:"Search",radius:2,value:e}),e.length>0&&ke(je,{align:"center",justify:"center",onClick:()=>{t(Zn.querySet({searchQuery:""}))},style:{cursor:"pointer",height:"100%",opacity:.75,position:"absolute",right:0,top:0,width:"2em",zIndex:1},children:ke(ae,{})})]})},ia=()=>{var e;const t=xt(),n=mi((e=>e.assets.fetching)),i=mi((e=>e.assets.pageIndex)),a=mi((e=>e.search.facets)),l=mi((e=>e.tags.panelVisible)),o=Ve();return _e(qe,{paddingY:2,style:{borderBottom:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),zIndex:2},children:[ke(qe,{marginBottom:2,children:ke(je,{align:"flex-start",direction:["column","column","column","column","row"],justify:"space-between",children:_e(je,{flex:1,style:{alignItems:"flex-start",flex:1,height:"100%",justifyContent:o<2?"space-between":"flex-start",position:"relative",width:"100%"},children:[ke(qe,{marginX:2,style:{minWidth:"200px"},children:ke(na,{})}),_e(qe,{display:["none","none","block"],children:[ke(Ji,{}),ke(ea,{})]}),ke(qe,{display:["block","block","none"],marginX:2,children:_e(Re,{space:2,style:{whiteSpace:"nowrap"},children:[ke(Ee,{fontSize:1,mode:"ghost",onClick:()=>{t(fi.showSearchFacets())},text:"Filters".concat(a.length>0?" (".concat(a.length,")"):""),tone:"primary"}),ke(Ee,{fontSize:1,mode:"ghost",onClick:()=>{t(fi.showTags())},text:"Tags",tone:"primary"})]})})]})})}),ke(qe,{children:_e(je,{align:"center",justify:["space-between"],children:[ke(qe,{marginX:2,children:ke(bi,{})}),_e(je,{marginX:2,children:[ke(xi,{}),ke(qe,{display:["none","none","block"],marginLeft:2,children:ke(Ee,{fontSize:1,icon:ke(qe,{style:{transform:"scale(0.75)"},children:ke(ta,{})}),onClick:()=>{t(Yn.panelVisibleSet({panelVisible:!l}))},mode:l?"default":"ghost",text:l?"Tags":""})})]})]})}),ke(Ci,{loading:n},i)]})},aa=It({name:"debug",initialState:{badConnection:!1,enabled:!1},reducers:{setBadConnection(e,t){e.badConnection=t.payload},toggleEnabled(e){e.enabled=!e.enabled}}}),la=aa.actions;var oa=aa.reducer;const ra=()=>{const e=xt(),t=mi((e=>e.debug.badConnection)),n=mi((e=>e.debug.enabled));return In("alt+ctrl+shift+/",(()=>{e(la.toggleEnabled())})),n?ke(qe,{padding:4,style:{bottom:0,left:0,pointerEvents:"none",position:"fixed",width:"100%"},children:_e(je,{align:"center",children:[ke(qe,{marginRight:3,children:ke(Fe,{muted:!0,size:1,children:ke(re,{})})}),ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:t?"Bad connection: +3000ms & 50% chance to fail":"No connection throttling"})}),fallbackPlacements:["right","left"],placement:"bottom",children:ke(Be,{checked:t,onChange:t=>{const n=t.target.checked;e(la.setBadConnection(n))},style:{pointerEvents:"auto"}})})]})}):null},sa=(e,t)=>{const n="undefined"!=typeof window&&window.devicePixelRatio?Math.round(window.devicePixelRatio):1,i=(null==t?void 0:t.height)?(null==t?void 0:t.height)*Math.max(1,n):void 0,a=t.width*Math.max(1,n),l=new URLSearchParams;return l.append("fit","max"),l.append("w",a.toString()),i&&l.append("h",i.toString()),"".concat(e.url,"?").concat(l.toString())},da=e=>Object.keys(e).reduce(((t,n)=>{const i=e[n];return"object"==typeof i&&null!==i&&i.constructor!==Array?t[n]=da(i):""===i||void 0===i||0===(null==i?void 0:i.length)?t[n]=null:t[n]="string"==typeof i&&i?e[n].trim():e[n],t}),{}),ca=e=>"sanity.fileAsset"===e._type,ua=e=>"sanity.imageAsset"===e._type,pa=e=>"".concat(e.metadata.dimensions.width,"x").concat(e.metadata.dimensions.height,"px"),ha=e=>{const{disabled:t,url:n}=e,i=st(),[a,l]=pt(!1);return dt((()=>()=>{i.current&&clearTimeout(i.current)}),[]),ke(Xe,{content:ke(Fe,{muted:!0,size:1,children:"Copied!"}),open:a,padding:2,placement:"top",radius:1,children:ke(Ee,{disabled:t,fontSize:1,icon:se,mode:"ghost",onClick:()=>{i.current&&clearTimeout(i.current),l(!0),yn(n),i.current=setTimeout((()=>{l(!1)}),1250)},text:"Copy URL"})})},ga=e=>{let{label:t,value:n}=e;return _e(je,{justify:"space-between",children:[ke(Fe,{size:1,style:{opacity:.8,width:"40%"},textOverflow:"ellipsis",children:t}),ke(Fe,{size:1,style:{opacity:.4,textAlign:"right",width:"60%"},textOverflow:"ellipsis",children:n})]})},ma=e=>{var t;const{asset:n,item:i}=e,a=null==(t=null==n?void 0:n.metadata)?void 0:t.exif;return _e(qe,{marginTop:3,children:[ke(qe,{children:_e(He,{space:3,children:[ke(ga,{label:"Size",value:mn(null==n?void 0:n.size,{base:10,round:0})}),ke(ga,{label:"MIME type",value:null==n?void 0:n.mimeType}),ke(ga,{label:"Extension",value:(null==n?void 0:n.extension).toUpperCase()}),ua(n)&&ke(ga,{label:"Dimensions",value:pa(n)})]})}),a&&_e(Se,{children:[ke(qe,{marginY:4,style:{background:"#222",height:"1px",width:"100%"}}),ke(qe,{children:_e(He,{space:3,children:[a.ISO&&ke(ga,{label:"ISO",value:a.ISO}),a.FNumber&&ke(ga,{label:"Aperture",value:"ƒ/".concat(a.FNumber)}),a.FocalLength&&ke(ga,{label:"Focal length",value:"".concat(a.FocalLength,"mm")}),a.ExposureTime&&ke(ga,{label:"Exposure time",value:"1/".concat(1/a.ExposureTime)}),a.DateTimeOriginal&&ke(ga,{label:"Original date",value:gn(new Date(a.DateTimeOriginal),"PPp")})]})})]}),ke(qe,{marginTop:5,children:_e(Re,{space:2,children:[ke(Ee,{disabled:!i||(null==i?void 0:i.updating),fontSize:1,icon:de,mode:"ghost",onClick:()=>{window.location.href="".concat(n.url,"?dl=").concat(n.originalFilename)},text:"Download"}),ke(ha,{disabled:!i||(null==i?void 0:i.updating),url:n.url})]})})]})},ya=e=>ke(Ye,B(B({},e),{},{style:{position:"fixed"}})),fa=e=>{const{assetId:t}=e,n=$();return ke(W,{documentStore:n,id:t,children:e=>{let{isLoading:t,referringDocuments:n}=e;return ke(va,{isLoading:t,referringDocuments:n})}})},va=e=>{const{isLoading:t,referringDocuments:n}=e,i=G(),a=n.reduce(((e,t)=>t._id.startsWith("drafts.")?e.concat(t._id.slice(7)):e),[]),l=n.filter((e=>!a.includes(e._id)));return t?ke(Fe,{size:1,children:"Loading..."}):0===l.length?ke(Fe,{size:1,children:"No documents are referencing this asset"}):ke(Me,{flex:1,marginBottom:2,padding:2,radius:2,shadow:1,children:ke(He,{space:2,children:null==l?void 0:l.map((e=>ke(ba,{doc:e,schemaType:i.get(e._type)},e._id)))})})},ba=e=>{const{doc:t,schemaType:n}=e,{onClick:i}=fn({intent:"edit",params:{id:t._id}});return n?ke(Ee,{mode:"bleed",onClick:i,padding:2,style:{width:"100%"},children:ke(K,{layout:"default",schemaType:n,value:t})},t._id):ke(qe,{padding:2,children:_e(Fe,{size:1,children:["A document of the unknown type ",ke("em",{children:t._type})]})})},xa=Jt(qe)(b||(b=H(["\n text {\n font-family: "," !important;\n font-size: 8px !important;\n font-weight: 500 !important;\n }\n"])),(e=>e.theme.sanity.fonts.text.family)),Ca=e=>{const{extension:t,onClick:n,width:i}=e;return ke(je,{align:"center",justify:"center",onClick:n,style:{height:"100%"},children:ke(xa,{style:{width:i},children:ke(vn,t?B({extension:t},bn[t]):{})})})},wa=e=>{const{asset:t}=e;return 0===t.mimeType.search("audio")?ke(je,{align:"center",justify:"center",style:{height:"100%"},children:ke("audio",{controls:!0,src:t.url,style:{width:"100%"}})}):0===t.mimeType.search("video")?ke("video",{controls:!0,src:t.url,style:{height:"100%",width:"100%"}}):ke(Ca,{extension:t.extension,width:"50%"})},Ia=Jt(ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}})),Ta=e=>{const{description:t,error:n,label:i,name:a}=e;return _e(Se,{children:[ke(qe,{marginY:3,children:_e(Re,{space:2,children:[ke(Fe,{as:"label",htmlFor:a,size:1,weight:"semibold",children:i}),n&&ke(Fe,{size:1,children:ke(Qe,{content:ke(qe,{padding:2,children:_e(Fe,{muted:!0,size:1,children:[ke(Ia,{style:{marginRight:"0.1em"}}),n.message]})}),fallbackPlacements:["top","left"],placement:"right",portal:!0,children:ke(Ia,{})})})]})}),t&&ke(qe,{marginY:3,children:ke(Fe,{htmlFor:a,muted:!0,size:1,children:t})})]})},ka=ht(((e,t)=>{const{description:n,disabled:i,error:a,extension:l,label:o,name:r,placeholder:s,value:d}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:o,name:r}),_e(je,{children:[ke(qe,{style:{flexGrow:1},children:ke(Ue,{autoComplete:"off",autoFocus:!0,defaultValue:d,disabled:i,id:r,name:r,placeholder:s,ref:t})}),ke(qe,{style:{width:"70px"},children:ke(Ue,{defaultValue:".".concat(l),disabled:!0})})]})]})}));var _a,Sa,Ra,Ea,za,Aa,Oa,Da,qa,ja,La,Fa;const Ua=null==(za=null==(Ea=null==(Ra=null==(Sa=null==(_a=Pe)?void 0:_a.color)?void 0:Sa.dark)?void 0:Ra.primary)?void 0:Ea.spot)?void 0:za.blue,Pa=null==(ja=null==(qa=null==(Da=null==(Oa=null==(Aa=Pe)?void 0:Aa.color)?void 0:Oa.dark)?void 0:Da.primary)?void 0:qa.spot)?void 0:ja.gray,Ma=null==(La=Pe)?void 0:La.radius,Na=null==(Fa=Pe)?void 0:Fa.space,Va={control:(e,t)=>{let{isDisabled:n,isFocused:i}=t,a="inset 0 0 0 1px ".concat(Gt.gray[900].hex);return i&&(a="inset 0 0 0 1px ".concat(Gt.gray[900].hex,", 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color) !important")),B(B({},e),{},{background:n?Pe.color.dark.default.input.default.disabled.bg:"transparent",color:Kt.hex,border:"none",borderRadius:Ma[1],boxShadow:a,minHeight:"35px",outline:"none",transition:"none","&:hover":{boxShadow:"inset 0 0 0 1px ".concat(Pe.color.dark.default.input.default.hovered.border)}})},indicatorsContainer:(e,t)=>{let{isDisabled:n}=t;return B(B({},e),{},{opacity:n?.25:1})},input:e=>B(B({},e),{},{color:Kt.hex,fontFamily:Pe.fonts.text.family,marginLeft:Na[2]}),menuList:e=>B({},e),multiValue:(e,t)=>{let{isDisabled:n}=t;return B(B({},e),{},{backgroundColor:Pa,borderRadius:Ma[2],opacity:n?.5:1})},multiValueRemove:e=>B(B({},e),{},{paddingLeft:0,"&:hover":{background:"transparent",color:"inherit"}}),noOptionsMessage:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,lineHeight:"1em"}),option:(e,t)=>{let{isFocused:n}=t;return B(B({},e),{},{backgroundColor:n?Ua:"transparent",borderRadius:Ma[2],color:n?Zt.hex:"inherit",fontFamily:Pe.fonts.text.family,padding:"4px 8px","&:hover":{backgroundColor:Ua,color:Zt.hex}})},placeholder:e=>B(B({},e),{},{fontFamily:Pe.fonts.text.family,marginLeft:Na[2]}),valueContainer:e=>B(B({},e),{},{marginBottom:Na[0],marginLeft:Na[1],marginTop:Na[0],padding:0})},Qa=e=>ke(qe,{paddingX:1,paddingY:1,children:ke(on.Option,B(B({},e),{},{children:_e(je,{align:"center",children:[e.data.__isNew__&&ke(pe,{style:{marginRight:"3px"}}),e.children]})}))}),Ba={DropdownIndicator:e=>ke(on.DropdownIndicator,B(B({},e),{},{children:ke(qe,{paddingX:2,children:ke(Fe,{size:1,children:ke(ue,{})})})})),IndicatorSeparator:null,Menu:e=>ke(on.Menu,B(B({},e),{},{children:ke(Me,{radius:1,shadow:2,children:e.children})})),MenuList:e=>{const{children:t}=e;if(Array.isArray(t)){const e=t.length>5?185:37*t.length;return ke(rn,{className:"media__custom-scrollbar",itemContent:e=>{const n=t[e];return ke(Qa,B({},n.props))},style:{height:e},totalCount:t.length})}return ke(on.MenuList,B(B({},e),{},{children:t}))},MultiValueLabel:e=>ke(qe,{paddingLeft:1,paddingRight:0,paddingY:1,children:ke(Fe,{size:2,weight:"medium",children:ke(on.MultiValueLabel,B({},e))})}),MultiValueRemove:e=>ke(on.MultiValueRemove,B(B({},e),{},{children:ke(ae,{color:"#1f2123"})})),Option:Qa},Xa=e=>{const{control:t,description:n,disabled:i,error:a,label:l,name:o,onCreateTag:r,options:s,placeholder:d,value:c}=e,u=mi((e=>e.tags.creating)),p=mi((e=>e.tags.fetching));return _e(qe,{style:{zIndex:2},children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke(un,{control:t,defaultValue:c,name:o,render:e=>{let{onBlur:t,onChange:n,value:a}=e;return ke(xn,{components:Ba,instanceId:"tags",isClearable:!1,isDisabled:u||i||p,isLoading:u,isMulti:!0,name:o,noOptionsMessage:()=>"No tags",onBlur:t,onChange:n,onCreateOption:r,options:s,placeholder:p?"Loading...":d,styles:Va,value:a})}})]})},Ha=ht(((e,t)=>{const{description:n,disabled:i,error:a,label:l,name:o,placeholder:r,value:s}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke(Ue,{autoComplete:"off",autoFocus:!0,defaultValue:s,disabled:i,id:o,name:o,placeholder:r,ref:t})]})})),Ya=ht(((e,t)=>{const{description:n,disabled:i,error:a,label:l,name:o,placeholder:r,rows:s,value:d}=e;return _e(qe,{children:[ke(Ta,{description:n,error:a,label:l,name:o}),ke($e,{autoComplete:"off",defaultValue:d,disabled:i,id:o,name:o,placeholder:r,ref:t,rows:s})]})})),$a=e=>{const{disabled:t,isValid:n,lastUpdated:i,onClick:a}=e;let l;return l=n?i?_e(Se,{children:["Last updated",ke("br",{})," ",gn(new Date(i),"PPp")]}):"No unpublished changes":"There are validation errors that need to be fixed before this document can be published",ke(Qe,{content:ke(qe,{padding:3,style:{maxWidth:"185px"},children:ke(Fe,{muted:!0,size:1,children:l})}),disabled:"ontouchstart"in window,placement:"top",children:ke(qe,{children:ke(Ee,{disabled:t,fontSize:1,onClick:a,text:"Save and close",tone:"primary"})})})},Wa=Jt.img(x||(x=H(["\n --checkerboard-color: ",";\n\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n\n ","\n"])),Gt.gray[900].hex,(e=>e.showCheckerboard&&en(C||(C=H(["\n background-image: linear-gradient(45deg, var(--checkerboard-color) 25%, transparent 25%),\n linear-gradient(-45deg, var(--checkerboard-color) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--checkerboard-color) 75%),\n linear-gradient(-45deg, transparent 75%, var(--checkerboard-color) 75%);\n background-size: 20px 20px;\n background-position: 0 0, 0 10px, 10px -10px, -10px 0;\n "]))))),Ga=hn.object().shape({originalFilename:hn.string().required("Filename cannot be empty")}),Ka=e=>{var t,n;const i=null==(t=null==e?void 0:e.originalFilename)?void 0:t.toLowerCase().lastIndexOf(".".concat(e.extension));return null==(n=null==e?void 0:e.originalFilename)?void 0:n.slice(0,i)},Za=e=>{var t,n,i;const{children:a,dialog:{assetId:l,id:o,lastCreatedTag:r,lastRemovedTagIds:s}}=e,d=qn(),c=xt(),u=mi((e=>ai(e,String(l)))),p=mi(Xn),h=st(!1),[g,m]=pt(null==u?void 0:u.asset),[y,f]=pt("details"),v=u?null==u?void 0:u.asset:g,b=Mn(p),x=mi((C=v,e=>{var t,n,i;const a=null==(i=null==(n=null==(t=null==C?void 0:C.opt)?void 0:t.media)?void 0:n.tags)?void 0:i.reduce(((t,n)=>{const i=e.tags.byIds[n._ref];return(null==i?void 0:i.tag)&&t.push(i),t}),[]);return a&&(null==a?void 0:a.length)>0?Mn(a):null}));var C;const I=e=>({altText:(null==e?void 0:e.altText)||"",description:(null==e?void 0:e.description)||"",originalFilename:e?Ka(e):void 0,opt:{media:{tags:x}},title:(null==e?void 0:e.title)||""}),T=null==x?void 0:x.map((e=>e.label)).join(","),{control:k,formState:{errors:_,isDirty:S,isValid:R},getValues:E,handleSubmit:z,register:A,reset:O,setValue:D}=pn({defaultValues:I(null==u?void 0:u.asset),mode:"onChange",resolver:cn(Ga)}),q=!u||(null==u?void 0:u.updating),j=()=>{(null==u?void 0:u.asset)&&c(fi.showConfirmDeleteAssets({assets:[u],closeDialogId:null==u?void 0:u.asset._id}))},L=e=>{const{result:t,transition:n}=e;t&&"update"===n&&(m(t),O(I(t)))},F=async e=>{var t;if(!(null==u?void 0:u.asset))return;const n=da(e);c(di.updateRequest({asset:null==u?void 0:u.asset,closeDialogId:null==u?void 0:u.asset._id,formData:B(B({},n),{},{opt:{media:B(B({},n.opt.media),{},{tags:(null==(t=n.opt.media.tags)?void 0:t.map((e=>({_ref:e.value,_type:"reference",_weak:!0}))))||null})},originalFilename:"".concat(n.originalFilename,".").concat(null==u?void 0:u.asset.extension)})}))};dt((()=>{if(!(null==u?void 0:u.asset))return;const e=d.listen(vt(w||(w=H(["*[_id == $id]"]))),{id:null==u?void 0:u.asset._id}).subscribe(L);return()=>{null==e||e.unsubscribe()}}),[]),dt((()=>{h.current&&O({opt:{media:{tags:x}}},{errors:!0,dirtyFields:!0,isDirty:!0}),h.current=!0}),[T]),dt((()=>{if(r){const e=(E("opt.media.tags")||[]).concat([r]);D("opt.media.tags",e,{shouldDirty:!0})}}),[r]),dt((()=>{if(s){const e=(E("opt.media.tags")||[]).filter((e=>!s.includes(e.value)));D("opt.media.tags",e,{shouldDirty:!0})}}),[s]);return v?_e(ya,{footer:ke((()=>ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{disabled:q,fontSize:1,mode:"bleed",onClick:j,text:"Delete",tone:"critical"}),ke($a,{disabled:q||!S||!R,isValid:R,lastUpdated:v._updatedAt,onClick:z(F)})]})})),{}),header:"Asset details",id:o,onClose:()=>{c(fi.remove({id:o}))},width:3,children:[_e(je,{direction:["column-reverse","column-reverse","row-reverse"],children:[_e(qe,{flex:1,marginTop:[5,5,0],padding:4,children:[_e(We,{space:2,children:[ke(Ge,{"aria-controls":"details-panel",disabled:q,id:"details-tab",label:"Details",onClick:()=>f("details"),selected:"details"===y,size:2}),ke(Ge,{"aria-controls":"references-panel",disabled:q,id:"references-tab",label:"References",onClick:()=>f("references"),selected:"references"===y,size:2})]}),_e(qe,{as:"form",marginTop:4,onSubmit:z(F),children:[!u&&ke(Me,{marginBottom:3,padding:3,radius:2,shadow:1,tone:"critical",children:ke(Fe,{size:1,children:"This file cannot be found – it may have been deleted."})}),ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ke,{"aria-labelledby":"details",hidden:"details"!==y,id:"details-panel",children:_e(He,{space:3,children:[ke(Xa,{control:k,disabled:q,error:null==(n=null==(t=null==_?void 0:_.opt)?void 0:t.media)?void 0:n.tags,label:"Tags",name:"opt.media.tags",onCreateTag:e=>{c(Yn.createRequest({assetId:null==v?void 0:v._id,name:e}))},options:b,placeholder:"Select or create...",value:x}),ke(ka,{disabled:q,error:null==_?void 0:_.originalFilename,extension:(null==v?void 0:v.extension)||"",label:"Filename",name:"originalFilename",ref:A,value:Ka(v)}),ke(Ha,{disabled:q,error:null==_?void 0:_.title,label:"Title",name:"title",ref:A,value:null==v?void 0:v.title}),ke(Ha,{disabled:q,error:null==_?void 0:_.altText,label:"Alt Text",name:"altText",ref:A,value:null==v?void 0:v.altText}),ke(Ya,{disabled:q,error:null==_?void 0:_.description,label:"Description",name:"description",ref:A,rows:3,value:null==v?void 0:v.description})]})}),ke(Ke,{"aria-labelledby":"references",hidden:"references"!==y,id:"references-panel",children:ke(qe,{marginTop:5,children:(null==u?void 0:u.asset)&&ke(fa,{assetId:null==u?void 0:u.asset._id})})})]})]}),_e(qe,{flex:1,padding:4,children:[_e(qe,{style:{aspectRatio:"1"},children:[ca(v)&&ke(wa,{asset:v}),ua(v)&&ke(Wa,{draggable:!1,showCheckerboard:!(null==(i=null==v?void 0:v.metadata)?void 0:i.isOpaque),src:sa(v,{height:600,width:600})})]}),v&&ke(qe,{marginTop:4,children:ke(ma,{asset:v,item:u})})]})]}),a]}):null},Ja=e=>{const{children:t,dialog:n}=e,i=xt(),a=()=>{i(fi.remove({id:null==n?void 0:n.id}))},l=()=>{(null==n?void 0:n.closeDialogId)&&i(fi.remove({id:null==n?void 0:n.closeDialogId})),(null==n?void 0:n.confirmCallbackAction)&&i(n.confirmCallbackAction),a()},o=()=>_e(je,{align:"center",children:[ke(qe,{paddingX:1,children:ke(he,{})}),ke(qe,{marginLeft:2,children:null==n?void 0:n.headerTitle})]});return _e(ya,{footer:ke((()=>ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{fontSize:1,mode:"bleed",onClick:a,text:"Cancel"}),ke(Ee,{fontSize:1,onClick:l,text:null==n?void 0:n.confirmText,tone:null==n?void 0:n.tone})]})})),{}),header:ke(o,{}),id:"confirm",onClose:a,width:1,children:[ke(qe,{paddingX:4,paddingY:4,children:_e(He,{space:3,children:[(null==n?void 0:n.title)&&ke(Fe,{size:1,children:n.title}),(null==n?void 0:n.description)&&ke(Fe,{muted:!0,size:1,children:ke("em",{children:n.description})})]})}),t]})},el=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=gt((()=>{i(fi.clear())}),[]);return _e(ya,{header:"Filters",id:n,onClose:a,width:1,children:[_e(qe,{padding:3,children:[ke(Ji,{layout:"stack"}),ke(ea,{})]}),t]})},tl=hn.object().shape({name:hn.string().required("Name cannot be empty")}),nl=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=mi((e=>e.tags.creating)),l=mi((e=>e.tags.creatingError)),{formState:{errors:o,isDirty:r,isValid:s},handleSubmit:d,register:c,setError:u}=pn({defaultValues:{name:""},mode:"onChange",resolver:cn(tl)}),p=a,h=async e=>{const t=da(e);i(Yn.createRequest({name:t.name}))};dt((()=>{l&&u("name",{message:null==l?void 0:l.message})}),[l]);return _e(ya,{footer:ke((()=>ke(qe,{padding:3,children:ke(je,{justify:"flex-end",children:ke($a,{disabled:p||!r||!s,isValid:s,onClick:d(h)})})})),{}),header:"Create Tag",id:n,onClose:()=>{i(fi.clear())},width:1,children:[_e(qe,{as:"form",padding:4,onSubmit:d(h),children:[ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ha,{disabled:p,error:null==o?void 0:o.name,label:"Name",name:"name",ref:c})]}),t]})},il=hn.object().shape({name:hn.string().required("Name cannot be empty")}),al=e=>{const{children:t,dialog:{id:n,tagId:i}}=e,a=qn(),l=xt(),o=mi((e=>Hn(e,String(i)))),[r,s]=pt(null==o?void 0:o.tag),d=o?null==o?void 0:o.tag:r,c=e=>{var t;return{name:(null==(t=null==e?void 0:e.name)?void 0:t.current)||""}},{formState:{errors:u,isDirty:p,isValid:h},handleSubmit:g,register:m,reset:y,setError:f}=pn({defaultValues:c(null==o?void 0:o.tag),mode:"onChange",resolver:cn(il)}),v=!o||(null==o?void 0:o.updating),b=async e=>{var t;if(!(null==o?void 0:o.tag))return;const n=da(e);l(Yn.updateRequest({closeDialogId:null==(t=null==o?void 0:o.tag)?void 0:t._id,formData:{name:{_type:"slug",current:n.name}},tag:null==o?void 0:o.tag}))},x=()=>{var e;(null==o?void 0:o.tag)&&l(fi.showConfirmDeleteTag({closeDialogId:null==(e=null==o?void 0:o.tag)?void 0:e._id,tag:null==o?void 0:o.tag}))},C=e=>{const{result:t,transition:n}=e;t&&"update"===n&&(s(t),y(c(t)))};dt((()=>{var e;(null==o?void 0:o.error)&&f("name",{message:null==(e=o.error)?void 0:e.message})}),[null==o?void 0:o.error]),dt((()=>{if(!(null==o?void 0:o.tag))return;const e=a.listen(vt(I||(I=H(["*[_id == $id]"]))),{id:null==o?void 0:o.tag._id}).subscribe(C);return()=>{null==e||e.unsubscribe()}}),[]);const w=()=>{var e;return ke(qe,{padding:3,children:_e(je,{justify:"space-between",children:[ke(Ee,{disabled:v,fontSize:1,mode:"bleed",onClick:x,text:"Delete",tone:"critical"}),ke($a,{disabled:v||!p||!h,isValid:h,lastUpdated:null==(e=null==o?void 0:o.tag)?void 0:e._updatedAt,onClick:g(b)})]})})};return d?_e(ya,{footer:ke(w,{}),header:"Edit Tag",id:n,onClose:()=>{l(fi.remove({id:n}))},width:1,children:[_e(qe,{as:"form",padding:4,onSubmit:g(b),children:[!o&&ke(Me,{marginBottom:3,padding:3,radius:2,shadow:1,tone:"critical",children:ke(Fe,{size:1,children:"This tag cannot be found – it may have been deleted."})}),ke("button",{style:{display:"none"},tabIndex:-1,type:"submit"}),ke(Ha,{disabled:v,error:null==u?void 0:u.name,label:"Name",name:"name",ref:m})]}),t]}):null},ll=Jt(je)(T||(T=H(["\n height: ","px;\n"])),32),ol=Jt(je)(k||(k=H(["\n @media (pointer: fine) {\n visibility: hidden;\n }\n\n @media (hover: hover) and (pointer: fine) {\n ",":hover & {\n visibility: visible;\n }\n }\n"])),ll),rl=e=>{const{disabled:t,icon:n,onClick:i,tone:a,tooltip:l}=e;return ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{muted:!0,size:1,children:l})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{disabled:t,fontSize:1,icon:n,mode:"bleed",onClick:i,padding:2,tone:a})})},sl=e=>{var t,n;const{actions:i,tag:a}=e,l=xt(),o=mi(ri),r=mi(Gn),s=mi((e=>{var t;return Kn(e,null==(t=null==a?void 0:a.tag)?void 0:t._id)}));return _e(ll,{align:"center",flex:1,justify:"space-between",paddingLeft:3,children:[ke(qe,{flex:1,children:ke(Fe,{size:1,style:{color:(null==a?void 0:a.updating)?Gt.gray[800].hex:Gt.gray[500].hex,userSelect:"none"},textOverflow:"ellipsis",children:null==(n=null==(t=null==a?void 0:a.tag)?void 0:t.name)?void 0:n.current})}),_e(ol,{align:"center",style:{flexShrink:0},children:[(null==i?void 0:i.includes("search"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(s?ae:oe,{}),onClick:s?()=>{l(Zn.facetsRemove({facetName:"tag"}))}:()=>{var e,t,n;const i=B(B({},kn.tag),{},{value:{label:null==(t=null==(e=null==a?void 0:a.tag)?void 0:e.name)?void 0:t.current,value:null==(n=null==a?void 0:a.tag)?void 0:n._id}});l(r?Zn.facetsUpdate({name:"tag",operatorType:"references",value:i.value}):Zn.facetsAdd({facet:i}))},tooltip:s?"Remove filter":"Filter by tag"}),(null==i?void 0:i.includes("edit"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(ge,{}),onClick:()=>{var e;l(Vn.showTagEdit({tagId:null==(e=null==a?void 0:a.tag)?void 0:e._id}))},tone:"primary",tooltip:"Edit tag"}),(null==i?void 0:i.includes("applyAll"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(me,{}),onClick:()=>{l(fi.showConfirmAssetsTagAdd({assetsPicked:o,tag:a.tag}))},tone:"primary",tooltip:"Add tag to selected assets"}),(null==i?void 0:i.includes("removeAll"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(ye,{}),onClick:()=>{l(fi.showConfirmAssetsTagRemove({assetsPicked:o,tag:a.tag}))},tone:"critical",tooltip:"Remove tag from selected assets"}),(null==i?void 0:i.includes("delete"))&&ke(rl,{disabled:null==a?void 0:a.updating,icon:ke(fe,{}),onClick:()=>{l(fi.showConfirmDeleteTag({tag:a.tag}))},tone:"critical",tooltip:"Delete tag"})]})]})},dl=mt((e=>{let{isScrolling:t,item:n}=e;var i;return"string"==typeof n?ke(je,{align:"center",justify:"space-between",paddingX:3,style:{height:"".concat(32,"px")},children:ke(Le,{size:0,children:n})},n):ke(sl,{actions:t?void 0:n.actions,tag:n},null==(i=n.tag)?void 0:i._id)})),cl=()=>{const e=mi(ri),t=mi(Xn),[n,i]=pt(!1),a=null==e?void 0:e.reduce(((e,t)=>{var n,i,a,l;const o=(null==(l=null==(a=null==(i=null==(n=null==t?void 0:t.asset)?void 0:n.opt)?void 0:i.media)?void 0:a.tags)?void 0:l.map((e=>e._ref)))||[];return e=e.concat(o)}),[]),l=[...new Set(a)],o=l.reduce(((t,n)=>{const i=e.every((e=>{var t,i,a,l;return(null!=(l=null==(a=null==(i=null==(t=e.asset.opt)?void 0:t.media)?void 0:i.tags)?void 0:a.findIndex((e=>e._ref===n)))?l:-1)>=0}));return i?t.appliedToAll.push(n):t.appliedToSome.push(n),t}),{appliedToAll:[],appliedToSome:[]}),r=t.filter((e=>o.appliedToAll.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["delete","edit","removeAll","search"]}))),s=t.filter((e=>o.appliedToSome.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["applyAll","delete","edit","removeAll","search"]}))),d=t.filter((e=>!l.includes(e.tag._id))).map((e=>B(B({},e),{},{actions:["applyAll","delete","edit","search"]})));let c=[];return 0===e.length?c=t.map((e=>B(B({},e),{},{actions:["delete","edit","search"]}))):((null==r?void 0:r.length)>0&&(c=[...c,1===e.length?"Used":"Used by all",...r]),(null==s?void 0:s.length)>0&&(c=[...c,"Used by some",...s]),(null==d?void 0:d.length)>0&&(c=[...c,"Unused",...d])),ke(rn,{className:"media__custom-scrollbar",computeItemKey:e=>{const t=c[e];return"string"==typeof t?t:t.tag._id},isScrolling:i,itemContent:e=>ke(dl,{isScrolling:n,item:c[e]}),style:{flex:1,overflowX:"hidden"},totalCount:c.length})},ul=e=>{var t,n;const{allowCreate:i,light:a,title:l}=e,o=xt(),r=mi((e=>e.tags.creating)),s=mi((e=>e.tags.fetching));return ke(Se,{children:_e(je,{align:"center",justify:"space-between",paddingLeft:3,style:{background:a?null==(t=Gt.gray)?void 0:t[900].hex:Zt.hex,borderBottom:"1px solid ".concat(null==(n=Gt.gray)?void 0:n[900].hex),height:"".concat(32,"px")},children:[_e(Re,{space:2,children:[ke(Le,{size:0,children:l}),s&&ke(Le,{size:0,style:{opacity:.3},children:"Loading..."})]}),i&&ke(qe,{marginRight:1,children:ke(Ee,{disabled:r,fontSize:1,icon:ve,mode:"bleed",onClick:()=>{o(Vn.showTagCreate())},style:{background:"transparent",boxShadow:"none"}})})]})})},pl=()=>{const e=mi(si),t=mi(Xn),n=mi((e=>e.tags.fetching)),i=-1!==mi((e=>e.tags.fetchCount)),a=!n&&(null==t?void 0:t.length)>0,l=!!(e>0);return _e(je,{direction:"column",flex:1,style:{background:Zt.hex,height:"100%"},children:[ke(ul,{allowCreate:!0,light:l,title:l?"Tags (in selection)":"Tags"}),i&&!a&&ke(qe,{padding:3,children:ke(Fe,{size:1,style:{color:Gt.gray[700].hex},children:ke("em",{children:"No tags"})})}),a&&ke(cl,{})]})},hl=e=>{const{children:t,dialog:{id:n}}=e,i=xt(),a=gt((()=>{i(fi.clear())}),[]);return _e(ya,{header:"All Tags",id:n,onClose:a,width:1,children:[ke(qe,{style:{height:"100%",minHeight:"420px"},children:ke(pl,{})}),t]})},gl=()=>{const e=mi((e=>e.dialog.items)),t=(e,n)=>{if(0===e.length||n>=e.length)return null;const i=e[n],a=t(e,n+1);return"assetEdit"===i.type?ke(Za,{dialog:i,children:a},n):"confirm"===i.type?ke(Ja,{dialog:i,children:a},n):"searchFacets"===i.type?ke(el,{dialog:i,children:a},n):"tagCreate"===i.type?ke(nl,{dialog:i,children:a},n):"tagEdit"===i.type?ke(al,{dialog:i,children:a},n):"tags"===i.type?ke(hl,{dialog:i,children:a},n):null};return t(e,0)},ml=ct(void 0),yl=e=>{const{children:t,open:n}=e,i={open:n};return ke(ml.Provider,{value:i,children:t})},fl=e=>{const{onClose:t}=e,{open:n}=(()=>{const e=ut(ml);if(void 0===e)throw new Error("useDropzoneActions must be used within an DropzoneDispatchProvider");return e})(),{onSelect:i}=Dn(),a=mi((e=>e.assets.assetTypes)),l=mi((e=>e.selected.document));return ke(qe,{paddingY:2,children:_e(je,{align:"center",justify:"space-between",children:[ke(qe,{flex:1,marginX:3,children:_e(Re,{style:{whiteSpace:"nowrap"},children:[ke(Fe,{textOverflow:"ellipsis",weight:"semibold",children:ke("span",{children:i?"Insert ".concat(a.join(" or ")):"Browse Assets"})}),l&&ke(qe,{display:["none","none","block"],children:_e(Fe,{children:[ke("span",{style:{margin:"0 0.5em"},children:ke(be,{symbol:"arrow-right"})}),ke("span",{style:{textTransform:"capitalize"},children:l._type})]})})]})}),_e(je,{marginX:2,children:[ke(Ee,{fontSize:1,icon:xe,mode:"bleed",onClick:n,text:"Upload ".concat(1===a.length?nn(a[0]):"assets"),tone:"primary"}),t&&ke(qe,{style:{flexShrink:0},children:ke(Ee,{disabled:!t,icon:ae,mode:"bleed",onClick:t,radius:2})})]})]})})},vl=Tt([e=>e.assets.allIds,e=>e.uploads.allIds],((e,t)=>{const n=e.map((e=>({id:e,type:"asset"})));return[...t.map((e=>({id:e,type:"upload"}))),...n]})),bl=Jt(je)(_||(_=H(["\n box-sizing: border-box;\n height: 100%;\n overflow: hidden;\n padding: 2px;\n position: relative;\n width: 100%;\n"]))),xl=Jt(je)(S||(S=H(["\n border: 1px solid transparent;\n height: 100%;\n pointer-events: ",";\n position: relative;\n transition: all 300ms;\n user-select: none;\n width: 100%;\n\n border: ",";\n\n ","\n"])),(e=>e.updating?"none":"auto"),(e=>e.picked?"1px solid ".concat(e.theme.sanity.color.spot.orange," !important"):"1px solid inherit"),(e=>!e.updating&&en(R||(R=H(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n border: 1px solid ",";\n }\n }\n "])),Gt.gray[500].hex))),Cl=Jt(je)(E||(E=H(["\n cursor: ",";\n height: ","px;\n transition: all 300ms;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),(e=>e.selected?"default":"pointer"),32,Gt.gray[950].hex),wl=Jt(Ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}}));var Il=mt((e=>{var t,n;const{id:i,selected:a}=e,l=In("shift"),o=xt(),r=mi((e=>e.assets.lastPicked)),s=mi((e=>ai(e,i))),d=null==s?void 0:s.asset,c=null==s?void 0:s.error,u=null==(n=null==(t=null==s?void 0:s.asset)?void 0:t.metadata)?void 0:n.isOpaque,p=null==s?void 0:s.picked,h=null==s?void 0:s.updating,{onSelect:g}=Dn();if(!d)return null;const m=h?.5:1,y=a||h?.25:1;return ke(bl,{children:_e(xl,{direction:"column",picked:p,updating:s.updating,children:[_e(qe,{flex:1,style:{cursor:a?"default":"pointer",position:"relative"},children:[_e("div",{onClick:e=>{e.stopPropagation(),g?g([{kind:"assetDocumentId",value:d._id}]):l.current?o(p?di.pick({assetId:d._id,picked:!p}):di.pickRange({startId:r||d._id,endId:d._id})):o(fi.showAssetEdit({assetId:d._id}))},style:{height:"100%",opacity:y},children:[ca(d)&&ke(Ca,{extension:d.extension,width:"80px"}),ua(d)&&ke(Wa,{draggable:!1,showCheckerboard:!u,src:sa(d,{height:250,width:250}),style:{draggable:!1,transition:"opacity 1000ms"}})]}),a&&!h&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,opacity:m,position:"absolute",top:0,width:"100%"},children:ke(Fe,{size:2,children:ke(we,{})})}),h&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Je,{})})]}),_e(Cl,{align:"center",onClick:e=>{e.stopPropagation(),g?o(fi.showAssetEdit({assetId:d._id})):l.current&&!p?o(di.pickRange({startId:r||d._id,endId:d._id})):o(di.pick({assetId:d._id,picked:!p}))},paddingX:1,style:{opacity:m},children:[g?ke(ge,{style:{flexShrink:0,opacity:.5}}):ke(et,{checked:p,readOnly:!0,style:{flexShrink:0,pointerEvents:"none",transform:"scale(0.8)"}}),ke(qe,{marginLeft:2,children:ke(Fe,{muted:!0,size:0,textOverflow:"ellipsis",children:d.originalFilename})})]}),c&&ke(qe,{padding:3,style:{position:"absolute",right:0,top:0},children:ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{size:1,children:c})}),placement:"left",portal:!0,children:ke(Fe,{size:1,children:ke(wl,{color:"critical"})})})})]})})}));const Tl=async e=>{const t=await(e=>new Promise((t=>{const n=window.URL.createObjectURL(e),i=new Image;i.onload=()=>{window.URL.revokeObjectURL(n),t(i)},i.src=n})))(e),n=await(i=t,new Promise((e=>{const t=i.width/i.height,n=document.createElement("canvas");n.width=180,n.height=Math.max(180/t,1);try{const a=n.getContext("2d");null==a||a.drawImage(i,0,0,180,180/t),n.toBlob(e,"image/jpeg")}catch(e){console.warn("Unable to generate preview image:",e)}})));var i;if(!n)throw Error("Unable to generate file Blob");return window.URL.createObjectURL(n)};function kl(e,t){const n=e.indexOf(t);return n>-1&&e.splice(n,1),e}const _l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;const t=[],n=[],i=new Lt;function a(o){return new Ft((r=>{if(t.length>=e)return l(o).pipe(Mt(a)).subscribe(r);const s=o.subscribe(r);return t.push(s),()=>{for(kl(t,s),kl(n,o),s.unsubscribe();n.length>0&&t.length<e;)i.next(n.shift())}}))}function l(e){return n.push(e),i.asObservable().pipe(Yt((t=>t===e)))}return a},Sl=e=>Array.prototype.map.call(new Uint8Array(e),(e=>"00".concat(e.toString(16)).slice(-2))).join(""),Rl=e=>window.crypto&&window.crypto.subtle&&window.FileReader?(e=>new Ft((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(Mt((e=>window.crypto.subtle.digest("SHA-1",e))),$t(Sl)):Ot({message:"Unable to generate hash: uploads are only allowed in secure contexts",statusCode:500}),El=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const n=_l(t);return function(){return qt(n(e(...arguments)))}}(((e,t,n,i)=>Dt(null).pipe(Mt((()=>((e,t,n)=>e.observable.fetch("*[_type == $documentType && sha1hash == $hash][0]",{documentType:t,hash:n}))(e,"sanity.".concat(t,"Asset"),i))),Mt((e=>e?Ot({message:"Asset already exists",statusCode:409}):Dt(null))),Mt((()=>e.observable.assets.upload(t,n,{extract:["blurhash","exif","location","lqip","palette"],preserveFilename:!0}).pipe($t((e=>"response"===e.type?{asset:e.body.document,id:e.body.document._id,type:"complete"}:e)))))))),zl=It({name:"uploads",initialState:{allIds:[],byIds:{}},extraReducers:e=>{e.addCase(ei.uploadComplete,((e,t)=>{const{asset:n}=t.payload;e.byIds[n.sha1hash]&&(e.byIds[n.sha1hash].status="complete")}))},reducers:{checkRequest(e,t){},checkComplete(e,t){const{results:n}=t.payload;Object.keys(n).forEach((t=>{const n=e.allIds.indexOf(t);if(n>=0&&e.allIds.splice(n,1),e.byIds[t]){const n=e.byIds[t].objectUrl;n&&window.URL.revokeObjectURL(n),delete e.byIds[t]}}))},previewReady(e,t){const{blobUrl:n,hash:i}=t.payload;e.byIds[i]&&(e.byIds[i].objectUrl=n)},uploadCancel(e,t){const{hash:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),e.byIds[n]&&delete e.byIds[n]},uploadError(e,t){const{hash:n}=t.payload,i=e.allIds.indexOf(n);i>=0&&e.allIds.splice(i,1),delete e.byIds[n]},uploadRequest(e,t){},uploadProgress(e,t){const{event:n,uploadHash:i}=t.payload;e.byIds[i].percent=n.percent,e.byIds[i].status="uploading"},uploadStart(e,t){const{uploadItem:n}=t.payload;e.allIds.includes(n.hash)||e.allIds.push(n.hash),e.byIds[n.hash]=n}}}),Al=Tt([e=>e.uploads.byIds,(e,t)=>t],((e,t)=>e[t]));Tt([e=>e.uploads.byIds,e=>e.uploads.allIds],((e,t)=>t.map((t=>e[t]))));const Ol=zl.actions;var Dl=zl.reducer;const ql=Jt(je)(A||(A=H(["\n box-sizing: border-box;\n height: 100%;\n overflow: hidden;\n padding: 2px;\n position: relative;\n width: 100%;\n"]))),jl=e=>{const{id:t}=e,n=xt(),i=mi((e=>Al(e,t)));if(!i)return null;const a=mn(i.size,{base:10,round:0}),l=Math.round(i.percent||0),o="complete"===i.status,r="uploading"===i.status,s="queued"===i.status;let d;o&&(d="Verifying"),r&&(d="".concat(l,"%")),s&&(d="Queued");return ke(ql,{children:_e(je,{direction:"column",flex:1,style:{background:Gt.gray[950].hex,border:"1px solid transparent",height:"100%",position:"relative"},children:[ke("div",{style:{background:Gt.gray[600].hex,bottom:0,height:"1px",left:0,position:"absolute",width:"100%",transform:"scaleX(".concat(.01*l,")"),transformOrigin:"bottom left",transition:"all 1000ms ease-out"}}),_e(qe,{flex:1,style:{position:"relative"},children:["image"===i.assetType&&(null==i?void 0:i.objectUrl)&&ke(Wa,{draggable:!1,src:i.objectUrl,style:{opacity:.4}}),"file"===i.assetType&&ke("div",{style:{height:"100%",opacity:.1},children:ke(Ca,{width:"80px"})}),!o&&100!==l&&ke(je,{align:"center",direction:"column",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:"Cancel"})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{fontSize:4,icon:ae,mode:"bleed",onClick:()=>{n(Ol.uploadCancel({hash:i.hash}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical"})})})]}),_e(je,{align:"center",justify:"space-between",paddingX:2,style:{height:"".concat(32,"px")},children:[ke(qe,{flex:1,marginRight:1,children:_e(Fe,{size:0,textOverflow:"ellipsis",children:[i.name," (",a,")"]})}),ke(Fe,{size:0,style:{flexShrink:0},weight:"semibold",children:d})]})]})})},Ll=mt((e=>{let{item:t,selected:n}=e;return"asset"===(null==t?void 0:t.type)?ke(Il,{id:t.id,selected:n}):"upload"===(null==t?void 0:t.type)?ke(jl,{id:t.id}):null})),Fl=Jt.div(O||(O=H(["\n height: ","px;\n width: ","px;\n"])),220,240),Ul=Jt.div(D||(D=H(["\n display: grid;\n grid-template-columns: repeat(auto-fill, ","px);\n justify-content: center;\n margin: 0 auto;\n"])),240),Pl=e=>{const{items:t,onLoadMore:n}=e,i=mi((e=>e.selected.assets)),a=i&&i.map((e=>e._id))||[],l=null==t?void 0:t.length;return 0===l?null:ke(sn,{className:"media__custom-scrollbar",computeItemKey:e=>{const n=t[e];return null==n?void 0:n.id},components:{Item:Fl,List:Ul},endReached:n,itemContent:e=>{const n=t[e],i=a.includes(null==n?void 0:n.id);return ke(Ll,{item:n,selected:i})},overscan:48,style:{overflowX:"hidden"},totalCount:l})},Ml=e=>{const{field:t,title:n}=e,i=xt(),a=mi((e=>e.assets.order)),l=a.field===t;return ke(Le,{muted:!t,size:0,children:_e(qe,{onClick:t?()=>{if(t&&n)if(l){const e="asc"===a.direction?"desc":"asc";i(di.orderSet({order:{field:t,direction:e}}))}else i(di.orderSet({order:{field:t,direction:"asc"}}))}:void 0,style:{cursor:t?"pointer":"default",display:"inline",whiteSpace:"nowrap"},children:[ke("span",{style:{marginRight:"0.4em"},children:n}),l&&"asc"===(null==a?void 0:a.direction)&&ke(Ie,{}),l&&"desc"===(null==a?void 0:a.direction)&&ke(ue,{})]})})};var Nl;const Vl=Jt(je)(q||(q=H(["\n cursor: pointer;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),null==(Nl=Gt.gray)?void 0:Nl[900].hex),Ql=()=>{var e;const t=xt(),n=mi((e=>e.assets.fetching)),i=mi(oi),a=mi(si),l=Ve(),{onSelect:o}=Dn(),r=a===i;return _e(tt,{style:{alignItems:"center",background:Zt.hex,borderBottom:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),gridColumnGap:l<3?0:"16px",gridTemplateColumns:zn,height:l<3?0:"".concat(32,"px"),letterSpacing:"0.025em",position:"sticky",textTransform:"uppercase",top:0,visibility:l<3?"hidden":"visible",width:"100%",zIndex:1},children:[o?ke(Ml,{}):ke(Vl,{align:"center",justify:"center",onClick:e=>{e.stopPropagation(),t(r?di.pickClear():di.pickAll())},style:{height:"100%",position:"relative"},children:ke(et,{checked:!n&&r,readOnly:!0,style:{pointerEvents:"none",transform:"scale(0.8)"}})}),ke(Ml,{}),ke(Ml,{field:"originalFilename",title:"Filename"}),ke(Ml,{title:"Resolution"}),ke(Ml,{field:"mimeType",title:"MIME type"}),ke(Ml,{field:"size",title:"Size"}),ke(Ml,{field:"_updatedAt",title:"Last updated"}),ke(Ml,{})]})};var Bl;const Xl=Jt(tt)(j||(j=H(["\n align-items: center;\n cursor: ",";\n height: 100%;\n pointer-events: ",";\n user-select: none;\n white-space: nowrap;\n\n ","\n"])),(e=>e.selected?"default":"pointer"),(e=>e.updating?"none":"auto"),(e=>{var t;return!e.updating&&en(L||(L=H(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n "])),null==(t=Gt.gray)?void 0:t[950].hex)})),Hl=Jt(je)(F||(F=H(["\n cursor: pointer;\n\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ",";\n }\n }\n"])),null==(Bl=Gt.gray)?void 0:Bl[900].hex),Yl=Jt(Ce)((e=>{let{theme:t}=e;return{color:t.sanity.color.spot.red}}));var $l=mt((e=>{var t,n;const{id:i,selected:a}=e,l=In("shift"),o=xt(),r=mi((e=>e.assets.lastPicked)),s=mi((e=>ai(e,i))),d=Ve(),c=null==s?void 0:s.asset,u=null==s?void 0:s.error,p=null==(n=null==(t=null==s?void 0:s.asset)?void 0:t.metadata)?void 0:n.isOpaque,h=null==s?void 0:s.picked,g=null==s?void 0:s.updating,{onSelect:m}=Dn();if(!c)return null;const y=g?.5:1,f=a||g?.1:1;return _e(Xl,{onClick:a?void 0:e=>{e.stopPropagation(),m?m([{kind:"assetDocumentId",value:c._id}]):l.current?o(h?di.pick({assetId:c._id,picked:!h}):di.pickRange({startId:r||c._id,endId:c._id})):o(fi.showAssetEdit({assetId:c._id}))},selected:a,style:{gridColumnGap:d<3?0:"16px",gridRowGap:0,gridTemplateColumns:d<3?En:zn,gridTemplateRows:d<3?"auto":"1fr"},updating:s.updating,children:[ke(Hl,{onClick:e=>{e.stopPropagation(),m?o(fi.showAssetEdit({assetId:c._id})):l.current&&!h?o(di.pickRange({startId:r||c._id,endId:c._id})):o(di.pick({assetId:c._id,picked:!h}))},style:{alignItems:"center",gridColumn:1,gridRowStart:1,gridRowEnd:"span 5",height:"100%",justifyContent:"center",opacity:y,position:"relative"},children:m?ke(ge,{style:{flexShrink:0,opacity:.5}}):ke(et,{checked:h,readOnly:!0,style:{pointerEvents:"none",transform:"scale(0.8)"}})}),ke(qe,{style:{gridColumn:2,gridRowStart:1,gridRowEnd:"span 5",height:"90px",width:"100px"},children:_e(je,{align:"center",justify:"center",style:{height:"100%",position:"relative"},children:[_e(qe,{style:{height:"100%",opacity:f,position:"relative"},children:[ca(c)&&ke(Ca,{extension:c.extension,width:"40px"}),ua(c)&&ke(Wa,{draggable:!1,showCheckerboard:!p,src:sa(c,{height:100,width:100})})]}),g&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Je,{})}),a&&!g&&ke(je,{align:"center",justify:"center",style:{height:"100%",left:0,position:"absolute",top:0,width:"100%"},children:ke(Fe,{size:2,children:ke(we,{})})})]})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:3,gridRow:d<3?2:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:c.originalFilename})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:d<3?3:4,gridRow:d<3?3:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:ua(c)&&pa(c)})}),ke(qe,{style:{display:d<3?"none":"block",gridColumn:5,gridRow:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:c.mimeType})}),ke(qe,{style:{display:d<3?"none":"block",gridColumn:6,gridRow:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:mn(c.size,{base:10,round:0})})}),ke(qe,{marginLeft:d<3?3:0,style:{gridColumn:d<3?3:7,gridRow:d<3?4:"auto",opacity:y},children:ke(Fe,{muted:!0,size:1,style:{lineHeight:"2em"},textOverflow:"ellipsis",children:Cn(new Date(c._updatedAt),new Date)})}),ke(je,{align:"center",justify:"center",style:{gridColumn:d<3?4:8,gridRowStart:"1",gridRowEnd:d<3?"span 5":"auto",opacity:y},children:u&&ke(qe,{padding:2,children:ke(Qe,{content:ke(Ze,{padding:2,width:0,children:ke(Fe,{size:1,children:u})}),placement:"left",portal:!0,children:ke(Fe,{size:1,children:ke(Yl,{color:"critical"})})})})})]})}));const Wl=e=>{const{id:t}=e,n=xt(),i=mi((e=>Al(e,t))),a=Ve();if(!i)return null;const l=mn(i.size,{base:10,round:0}),o=Math.round(i.percent||0),r="complete"===i.status,s="uploading"===i.status,d="queued"===i.status;let c;r&&(c="Verifying"),s&&(c="".concat(o,"%")),d&&(c="Queued");return _e(tt,{style:{alignItems:"center",background:Gt.gray[950].hex,gridColumnGap:a<3?0:"16px",gridRowGap:0,gridTemplateColumns:a<3?En:zn,gridTemplateRows:a<3?"auto":"1fr",height:"100%",position:"relative"},children:[ke("div",{style:{background:Gt.gray[600].hex,bottom:0,height:"1px",left:0,position:"absolute",width:"100%",transform:"scaleX(".concat(.01*o,")"),transformOrigin:"bottom left",transition:"all 1000ms ease-out"}}),ke(qe,{style:{gridColumn:2,gridRowStart:a<3?1:"auto",gridRowEnd:a<3?"span 4":"auto",height:"90px",width:"100px"},children:_e(qe,{style:{height:"100%",position:"relative"},children:["image"===i.assetType&&(null==i?void 0:i.objectUrl)&&ke(Wa,{draggable:!1,src:i.objectUrl,style:{opacity:.25}}),"file"===i.assetType&&ke("div",{style:{height:"100%",opacity:.1},children:ke(Ca,{width:"40px"})}),!r&&100!==o&&ke(je,{align:"center",justify:"center",style:{position:"absolute",height:"100%",left:0,top:0,width:"100%"},children:ke(Qe,{content:ke(qe,{padding:2,children:ke(Fe,{muted:!0,size:1,children:"Cancel"})}),disabled:"ontouchstart"in window,placement:"top",children:ke(Ee,{fontSize:3,icon:ae,mode:"bleed",onClick:()=>{n(Ol.uploadCancel({hash:i.hash}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical"})})})]})}),ke(qe,{style:{gridColumn:a<3?3:"3/8",gridRow:a<3?"2/4":"auto",marginLeft:a<3?3:0},children:_e(He,{space:3,children:[_e(Fe,{muted:!0,size:1,textOverflow:"ellipsis",children:[i.name," (",l,")"]}),ke(Fe,{size:1,textOverflow:"ellipsis",weight:"semibold",children:c})]})})]})},Gl=mt((e=>{let{item:t,selected:n}=e;return"asset"===(null==t?void 0:t.type)?ke(qe,{style:{height:"100px"},children:ke($l,{id:t.id,selected:n})}):"upload"===(null==t?void 0:t.type)?ke(qe,{style:{height:"100px"},children:ke(Wl,{id:t.id})}):null})),Kl=e=>{const{items:t,onLoadMore:n}=e,i=mi((e=>e.selected.assets)),a=i&&i.map((e=>e._id))||[],l=null==t?void 0:t.length;return 0===l?null:ke(dn,{className:"media__custom-scrollbar",computeItemKey:e=>{const n=t[e];return(null==n?void 0:n.id)||e},endReached:n,groupCounts:Array(1).fill(l),groupContent:()=>ke(Ql,{}),itemContent:e=>{const n=t[e],i=a.includes(null==n?void 0:n.id);return ke(Gl,{item:n,selected:i})},style:{overflowX:"hidden"}})},Zl=()=>{const e=xt(),t=mi((e=>e.assets.fetchCount)),n=mi((e=>e.assets.fetching)),i=mi((e=>e.tags.panelVisible)),a=mi((e=>e.assets.view)),l=mi(vl),o=(()=>{var e,t;const n=null==(t=null==(e=Pe)?void 0:e.container)?void 0:t.map((e=>window.matchMedia("(max-width: ".concat(e,"px)")))),i=()=>n.findIndex((e=>e.matches)),[a,l]=pt(i());return dt((()=>{const e=()=>{l(i)};return n.forEach((t=>{try{t.addEventListener("change",e)}catch(n){try{t.addListener(e)}catch(e){}}})),()=>{try{n.forEach((t=>t.removeEventListener("change",e)))}catch(t){try{n.forEach((t=>t.removeListener(e)))}catch(e){}}}}),[]),a})(),r=t>=0,s=l.length>0,d=()=>{n||e(di.loadNextPage())};dt((()=>{o<=1&&i&&e(Yn.panelVisibleSet({panelVisible:!1}))}),[o]);return ke(qe,{flex:1,style:{width:"100%"},children:!s&&r&&!n?ke(qe,{padding:4,children:ke(Fe,{size:1,weight:"semibold",children:"No results for the current query"})}):_e(Se,{children:["grid"===a&&ke(Pl,{items:l,onLoadMore:d}),"table"===a&&ke(Kl,{items:l,onLoadMore:d})]})})},Jl=()=>{const e=mi((e=>e.notifications.items)),t=nt();return dt((()=>{if(e.length>0){const n=e[e.length-1];t.push({closable:!0,status:n.status,title:n.title})}}),[e.length]),null},eo=()=>{var e,t;const n=xt(),i=mi(ri);return 0===i.length?null:ke(je,{align:"center",justify:"flex-start",style:{background:null==(e=Gt.gray)?void 0:e[900].hex,borderBottom:"1px solid ".concat(null==(t=Gt.gray)?void 0:t[900].hex),height:"".concat(32,"px"),position:"relative",width:"100%"},children:_e(je,{align:"center",paddingX:3,children:[ke(qe,{paddingRight:2,children:_e(Le,{size:0,style:{color:"inherit"},children:[i.length," ",nn("asset",i.length)," selected"]})}),ke(Ee,{mode:"bleed",onClick:()=>{n(di.pickClear())},padding:2,style:{background:"none",boxShadow:"none"},tone:"default",children:ke(Le,{size:0,children:"Deselect"})}),ke(Ee,{mode:"bleed",onClick:()=>{n(fi.showConfirmDeleteAssets({assets:i}))},padding:2,style:{background:"none",boxShadow:"none"},tone:"critical",children:ke(Le,{size:0,children:"Delete"})})]})})};var to=It({name:"selected",initialState:{assets:[],document:void 0,documentAssetIds:[]},reducers:{}}).reducer;const no=It({name:"notifications",initialState:{items:[]},reducers:{add(e,t){const{asset:n,status:i,title:a}=t.payload;e.items.push({asset:n,status:i,title:a})}}}),io=no.actions;var ao=no.reducer;const lo=Et(((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.deleteRequest.match),Mt((e=>{const{assets:t}=e.payload,n=t.map((e=>e._id));return Dt(t).pipe(Mt((()=>i.observable.delete({query:vt(p||(p=H(["*[_id in ","]"])),JSON.stringify(n))}))),Mt((()=>Dt(di.deleteComplete({assetIds:n})))),Qt((e=>Dt(di.deleteError({assetIds:n,error:e})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.fetchRequest.match),Vt(t),Bt((e=>{let[t,n]=e;var a,l;const o=null==(a=t.payload)?void 0:a.params,r=null==(l=t.payload)?void 0:l.query;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(r,o))),Mt((e=>{const{items:t}=e;return Dt(di.fetchComplete({assets:t}))})),Qt((e=>Dt(di.fetchError({message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500})))))})))}),((e,t)=>e.pipe(Nt(di.deleteComplete.match),Vt(t),Bt((e=>{let[t,n]=e;if(0===n.assets.allIds.length){const e=Math.floor(n.assets.allIds.length/n.assets.pageSize);return Dt(di.loadPageIndex({pageIndex:e}))}return jt()})))),((e,t)=>e.pipe(Nt(di.loadNextPage.match),Vt(t),Bt((e=>{let[t,n]=e;return Dt(di.loadPageIndex({pageIndex:n.assets.pageIndex+1}))})))),((e,t)=>e.pipe(Nt(di.loadPageIndex.match),Vt(t),Bt((e=>{let[t,n]=e;var i,a,l,o,r,s;const d=n.assets.pageSize,c=t.payload.pageIndex*d,u=c+d,p=null==(i=null==n?void 0:n.selected.document)?void 0:i._id,m=null==(a=null==n?void 0:n.selected)?void 0:a.documentAssetIds,y=Un({assetTypes:n.assets.assetTypes,searchFacets:n.search.facets,searchQuery:n.search.query}),f=B(B({},p?{documentId:p}:{}),{},{documentAssetIds:m});return Dt(di.fetchRequest({params:f,queryFilter:y,selector:vt(h||(h=H(["[","...","]"])),c,u),sort:vt(g||(g=H(["order("," ",")"])),null==(o=null==(l=n.assets)?void 0:l.order)?void 0:o.field,null==(s=null==(r=n.assets)?void 0:r.order)?void 0:s.direction)}))})))),(e=>e.pipe(Nt(di.listenerCreateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.asset));return Dt(di.listenerCreateQueueComplete({assets:t}))})))),(e=>e.pipe(Nt(di.listenerDeleteQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.assetId));return Dt(di.listenerDeleteQueueComplete({assetIds:t}))})))),(e=>e.pipe(Nt(di.listenerUpdateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.asset));return Dt(di.listenerUpdateQueueComplete({assets:t}))})))),(e=>e.pipe(Nt(di.orderSet.match),Mt((()=>Dt(di.clear(),di.loadPageIndex({pageIndex:0})))))),(e=>e.pipe(Rt(Zn.facetsAdd.type,Zn.facetsClear.type,Zn.facetsRemove.type,Zn.facetsUpdate.type,Zn.querySet.type),Ht(400),Mt((()=>Dt(di.clear(),di.loadPageIndex({pageIndex:0})))))),(e=>e.pipe(Rt(di.insertUploads.type,di.listenerUpdateQueueComplete.type,di.updateComplete.type),Mt((()=>Dt(di.sort()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Nn.tagsAddRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a,tag:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>{const e=ri(n),t=null==e?void 0:e.filter((e=>t=>{var n,i,a,l,o;return(null!=(o=null==(l=null==(a=null==(i=null==(n=null==t?void 0:t.asset)?void 0:n.opt)?void 0:i.media)?void 0:a.tags)?void 0:l.findIndex((t=>t._ref===(null==e?void 0:e._id))))?o:-1)<0})(l)),a=t.reduce(((e,t)=>{var n;return e.patch(null==(n=null==t?void 0:t.asset)?void 0:n._id,(e=>{let{tag:t}=e;return e=>e.setIfMissing({opt:{}}).setIfMissing({"opt.media":{}}).setIfMissing({"opt.media.tags":[]}).append("opt.media.tags",[{_key:St(),_ref:null==t?void 0:t._id,_type:"reference",_weak:!0}])})({tag:l}))}),i.transaction());return qt(a.commit())})),Mt((()=>Dt(Nn.tagsAddComplete({assets:a,tag:l})))),Qt((e=>Dt(Nn.tagsAddError({assets:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:l})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Nn.tagsRemoveRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a,tag:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>{const e=ri(n).reduce(((e,t)=>{var n;return e.patch(null==(n=null==t?void 0:t.asset)?void 0:n._id,(e=>{let{asset:t,tag:n}=e;return e=>{var i;return e.ifRevisionId(null==(i=null==t?void 0:t.asset)?void 0:i._rev).unset(['opt.media.tags[_ref == "'.concat(n._id,'"]')])}})({asset:t,tag:l}))}),i.transaction());return qt(e.commit())})),Mt((()=>Dt(Nn.tagsRemoveComplete({assets:a,tag:l})))),Qt((e=>Dt(Nn.tagsRemoveError({assets:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:l})))))})))}),(e=>e.pipe(Rt(di.orderSet.type,di.viewSet.type,Zn.facetsAdd.type,Zn.facetsClear.type,Zn.facetsRemove.type,Zn.facetsUpdate.type,Zn.querySet.type),Mt((()=>Dt(di.pickClear()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(di.updateRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{asset:a,closeDialogId:l,formData:o}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>qt(i.patch(a._id).setIfMissing({opt:{}}).setIfMissing({"opt.media":{}}).set(o).commit()))),Mt((e=>Dt(di.updateComplete({asset:e,closeDialogId:l})))),Qt((e=>Dt(di.updateError({asset:a,error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500}})))))})))}),(e=>e.pipe(Rt(di.deleteComplete.type,di.updateComplete.type,Yn.deleteComplete.type,Yn.updateComplete.type),Nt((e=>{var t;return!!(null==(t=null==e?void 0:e.payload)?void 0:t.closeDialogId)})),Mt((e=>{var t;const n=null==(t=null==e?void 0:e.payload)?void 0:t.closeDialogId;return n?Dt(yi.actions.remove({id:n})):jt()})))),(e=>e.pipe(Nt(Yn.createComplete.match),Mt((e=>{const{assetId:t,tag:n}=null==e?void 0:e.payload;return t?Dt(yi.actions.inlineTagCreate({tag:n,assetId:t})):n._id?Dt(yi.actions.remove({id:"tagCreate"})):jt()})))),(e=>e.pipe(Nt(Yn.listenerDeleteQueueComplete.match),Mt((e=>{const{tagIds:t}=null==e?void 0:e.payload;return Dt(yi.actions.inlineTagRemove({tagIds:t}))})))),(e=>e.pipe(Nt(di.deleteError.match),Mt((e=>{const{assetIds:t}=e.payload,n=t.length;return Dt(no.actions.add({status:"error",title:"Unable to delete ".concat(n," ").concat(nn("asset",n),". Please review any asset errors and try again.")}))})))),(e=>e.pipe(Nt(di.deleteComplete.match),Mt((e=>{const{assetIds:t}=e.payload,n=t.length;return Dt(no.actions.add({status:"info",title:"".concat(n," ").concat(nn("asset",n)," deleted")}))})))),(e=>e.pipe(Nt(Nn.tagsAddComplete.match),Mt((e=>{var t,n;const i=null==(n=null==(t=null==e?void 0:e.payload)?void 0:t.assets)?void 0:n.length;return Dt(no.actions.add({status:"info",title:"Tag added to ".concat(i," ").concat(nn("asset",i))}))})))),(e=>e.pipe(Nt(Nn.tagsRemoveComplete.match),Mt((e=>{var t,n;const i=null==(n=null==(t=null==e?void 0:e.payload)?void 0:t.assets)?void 0:n.length;return Dt(no.actions.add({status:"info",title:"Tag removed from ".concat(i," ").concat(nn("asset",i))}))})))),(e=>e.pipe(Nt(di.updateComplete.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=e.length;return Dt(no.actions.add({status:"info",title:"".concat(t," ").concat(nn("asset",t)," updated")}))})))),(e=>e.pipe(Rt(di.fetchError.type,di.updateError.type,Yn.createError.type,Yn.deleteError.type,Yn.fetchError.type,Yn.updateError.type,Ol.uploadError.type),Mt((e=>{var t;const n=null==(t=e.payload)?void 0:t.error;return Dt(no.actions.add({status:"error",title:"An error occured: ".concat(n.message)}))})))),(e=>e.pipe(Nt(Yn.createComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag created"})))))),(e=>e.pipe(Nt(Yn.deleteComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag deleted"})))))),(e=>e.pipe(Nt(Yn.updateComplete.match),Mt((()=>Dt(no.actions.add({status:"info",title:"Tag updated"})))))),((e,t)=>e.pipe(Nt(Yn.updateComplete.match),Vt(t),Mt((e=>{let[t,n]=e;var i,a,l,o,r;const{tag:s}=t.payload,d=null==(i=n.search.facets)?void 0:i.find((e=>"tag"===e.name)),c=n.tags.byIds[s._id];return"searchable"===(null==d?void 0:d.type)&&(null==(a=d.value)?void 0:a.value)===s._id?Dt(Wn.actions.facetsUpdate({name:"tag",value:{label:null==(o=null==(l=null==c?void 0:c.tag)?void 0:l.name)?void 0:o.current,value:null==(r=null==c?void 0:c.tag)?void 0:r._id}})):jt()})))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.createRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assetId:a,name:l}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Pn(i,l),Mt((()=>i.observable.create({_type:"media.tag",name:{_type:"slug",current:l}}))),Mt((e=>Dt(Qn.actions.createComplete({assetId:a,tag:e})))),Qt((e=>Dt(Qn.actions.createError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},name:l})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.deleteRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{tag:a}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(vt(d||(d=H(['*[\n _type in ["sanity.fileAsset", "sanity.imageAsset"]\n && references(*[_type == "media.tag" && name.current == $tagName]._id)\n ] {\n _id,\n _rev,\n opt\n }']))),{tagName:a.name.current}))),Mt((e=>{const t=e.map((e=>({id:e._id,patch:{ifRevisionID:e._rev,unset:['opt.media.tags[_ref == "'.concat(a._id,'"]')]}}))).reduce(((e,t)=>e.patch(t.id,t.patch)),i.transaction());return t.delete(a._id),qt(t.commit())})),Mt((()=>Dt(Qn.actions.deleteComplete({tagId:a._id})))),Qt((e=>Dt(Qn.actions.deleteError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:a})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.fetchRequest.match),Vt(t),Bt((e=>{let[t,n]=e;const{query:a}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Mt((()=>i.observable.fetch(a))),Mt((e=>{const{items:t}=e;return Dt(Qn.actions.fetchComplete({tags:t}))})),Qt((e=>Dt(Qn.actions.fetchError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500}})))))})))}),(e=>e.pipe(Nt(Qn.actions.listenerCreateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tag));return Dt(Qn.actions.listenerCreateQueueComplete({tags:t}))})))),(e=>e.pipe(Nt(Qn.actions.listenerDeleteQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tagId));return Dt(Qn.actions.listenerDeleteQueueComplete({tagIds:t}))})))),(e=>e.pipe(Nt(Qn.actions.listenerUpdateQueue.match),Xt(2e3),Nt((e=>e.length>0)),Mt((e=>{const t=null==e?void 0:e.map((e=>e.payload.tag));return Dt(Qn.actions.listenerUpdateQueueComplete({tags:t}))})))),(e=>e.pipe(Rt(Qn.actions.listenerCreateQueueComplete.type,Qn.actions.listenerUpdateQueueComplete.type),Xt(1e3),Nt((e=>e.length>0)),Mt((()=>Dt(Qn.actions.sort()))))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Qn.actions.updateRequest.match),Vt(t),Mt((e=>{let[t,n]=e;var a;const{closeDialogId:l,formData:o,tag:r}=t.payload;return Dt(t).pipe(Fn(n.debug.badConnection),Pn(i,null==(a=null==o?void 0:o.name)?void 0:a.current),Mt((()=>qt(i.patch(r._id).set({name:{_type:"slug",current:null==o?void 0:o.name.current}}).commit()))),Mt((e=>Dt(Qn.actions.updateComplete({closeDialogId:l,tag:e})))),Qt((e=>Dt(Qn.actions.updateError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},tag:r})))))})))}),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Ol.uploadStart.match),Mt((t=>{const{file:n,uploadItem:a}=t.payload;return Ut(Dt(null).pipe(Mt((()=>(e=>Dt(null).pipe(Mt((()=>qt(Tl(e))))))(n))),Mt((e=>Dt(Ol.previewReady({blobUrl:e,hash:a.hash}))))),Dt(null).pipe(Mt((()=>El(i,a.assetType,n,a.hash))),Wt(e.pipe(Nt(Ol.uploadCancel.match),Nt((e=>e.payload.hash===a.hash)))),Mt((e=>"complete"===(null==e?void 0:e.type)?Dt(ei.uploadComplete({asset:e.asset})):"progress"===(null==e?void 0:e.type)&&"upload"===(null==e?void 0:e.stage)?Dt(Ol.uploadProgress({event:e,uploadHash:a.hash})):jt())),Qt((e=>Dt(Ol.uploadError({error:{message:(null==e?void 0:e.message)||"Internal error",statusCode:(null==e?void 0:e.statusCode)||500},hash:a.hash}))))))})))}),((e,t)=>e.pipe(Nt(Ol.uploadRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{file:i,forceAsAssetType:a}=t.payload;return Dt(t).pipe(Mt((()=>Rl(i))),Nt((e=>!!!n.uploads.byIds[e])),Mt((e=>{const t={_type:"upload",assetType:a||(i.type.indexOf("image")>=0?"image":"file"),hash:e,name:i.name,size:i.size,status:"queued"};return Dt(Ol.uploadStart({file:i,uploadItem:t}))})))})))),((e,t,n)=>{let{client:i}=n;return e.pipe(Nt(Ol.checkRequest.match),Vt(t),Mt((e=>{let[t,n]=e;const{assets:a}=t.payload,l=a.map((e=>e._id)),o=Un({assetTypes:n.assets.assetTypes,searchFacets:n.search.facets,searchQuery:n.search.query}),r=vt(z||(z=H(["\n *["," && _id in $documentIds].sha1hash\n "])),o);return Dt(t).pipe(Pt(1e3),Mt((()=>i.observable.fetch(r,{documentIds:l}))),Mt((e=>{const t=a.reduce(((t,n)=>(t[n.sha1hash]=e.includes(n.sha1hash)?n._id:null,t)),{});return Dt(Ol.checkComplete({results:t}),di.insertUploads({results:t}))})))})))}),(e=>e.pipe(Nt(ei.uploadComplete.match),Mt((e=>Dt(Ol.checkRequest({assets:[e.payload.asset]}))))))),oo=kt({assets:pi,debug:oa,dialog:vi,notifications:ao,search:Jn,selected:to,tags:$n,uploads:Dl}),ro=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),so=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];var n,i;return Array.isArray(e)&&e.forEach((e=>{so(e,t)})),ro(e)&&("reference"===(null==(n=null==e?void 0:e.asset)?void 0:n._type)&&(null==(i=null==e?void 0:e.asset)?void 0:i._ref)&&t.push(e.asset._ref),Object.values(e).forEach((e=>{so(e,t)}))),t},co=e=>{const t=so(e);return[...new Set(t.sort())]};class uo extends yt{constructor(e){super(e);const t=zt({dependencies:{client:e.client}});this.store=_t({reducer:oo,middleware:e=>e({serializableCheck:!1,thunk:!1}).prepend(t),devTools:!0,preloadedState:{assets:B(B({},ni),{},{assetTypes:(null==e?void 0:e.assetType)?[e.assetType]:["file","image"]}),selected:{assets:e.selectedAssets||[],document:e.document,documentAssetIds:e.document?co(e.document):[]}}}),t.run(lo)}render(){return ke(Ct,{store:this.store,children:this.props.children})}}const po=()=>{var e;return mi((e=>e.tags.panelVisible))?ke(qe,{style:{position:"relative",width:250},children:ke(qe,{className:"media__custom-scrollbar",style:{borderLeft:"1px solid ".concat(null==(e=Gt.gray)?void 0:e[900].hex),height:"100%",overflowX:"hidden",overflowY:"auto",position:"absolute",right:0,top:0,width:"100%"},children:ke(pl,{})})}):null},ho=Jt.div(U||(U=H(["\n color: white;\n height: 100%;\n min-height: 100%;\n right: 0;\n top: 0;\n width: 100%;\n\n &:focus {\n outline: none;\n }\n"]))),go=Jt.div(P||(P=H(["\n align-items: center;\n background: rgba(0, 0, 0, 0.75);\n display: flex;\n height: 100%;\n justify-content: center;\n position: absolute;\n right: 0;\n top: 0;\n width: 100%;\n z-index: 3;\n"])));const mo=e=>{const{children:t}=e,{onSelect:n}=Dn(),i=xt(),a=mi((e=>e.assets.assetTypes)),l=1===a.length&&"image"===a[0],{getRootProps:o,getInputProps:r,isDragActive:s,open:d}=wn({accept:l?"image/*":"",getFilesFromEvent:async e=>{var t;let n;if("drop"===e.type&&"dataTransfer"in e&&(n=null==(t=null==e?void 0:e.dataTransfer)?void 0:t.files),"change"===e.type){const t=null==e?void 0:e.target;(null==t?void 0:t.files)&&(n=t.files)}if(!n)return[];const a=await async function(e){const t=Array.from(e),n=[];for(const e of t)try{await e.slice(0,1).arrayBuffer(),n.push(e)}catch(e){}return n}(n);return(null==n?void 0:n.length)!==a.length&&i(io.add({status:"error",title:"Unable to upload some items (folders and packages aren't supported)"})),a},noClick:!0,noDrag:!!n,onDrop:async e=>{e.forEach((e=>i(Ol.uploadRequest({file:e,forceAsAssetType:1===a.length?a[0]:void 0}))))}});return ke(yl,{open:d,children:_e(ho,B(B({},o()),{},{children:[ke("input",B({},r())),s&&ke(go,{children:ke(je,{direction:"column",justify:"center",style:{color:Kt.hex},children:ke(Fe,{size:3,style:{color:"inherit"},children:"Drop files to upload"})})}),t]}))})},yo=e=>{let{onClose:t}=e;const n=qn(),i=xt(),a=e=>{const{documentId:t,result:n,transition:a}=e;"appear"===a&&i(di.listenerCreateQueue({asset:n})),"disappear"===a&&i(di.listenerDeleteQueue({assetId:t})),"update"===a&&i(di.listenerUpdateQueue({asset:n}))},l=e=>{const{documentId:t,result:n,transition:a}=e;"appear"===a&&i(Yn.listenerCreateQueue({tag:n})),"disappear"===a&&i(Yn.listenerDeleteQueue({tagId:t})),"update"===a&&i(Yn.listenerUpdateQueue({tag:n}))};return dt((()=>{i(di.loadPageIndex({pageIndex:0})),i(Yn.fetchRequest());const e=n.listen(vt(M||(M=H(['*[_type in ["sanity.fileAsset", "sanity.imageAsset"] && !(_id in path("drafts.**"))]'])))).subscribe(a),t=n.listen(vt(N||(N=H(['*[_type == "','" && !(_id in path("drafts.**"))]'])),"media.tag")).subscribe(l);return()=>{null==e||e.unsubscribe(),null==t||t.unsubscribe()}}),[]),_e(mo,{children:[ke(gl,{}),ke(Jl,{}),ke(Me,{display:"flex",height:"fill",children:_e(je,{direction:"column",flex:1,children:[ke(fl,{onClose:t}),ke(ia,{}),_e(je,{flex:1,children:[_e(je,{align:"flex-end",direction:"column",flex:1,style:{position:"relative"},children:[ke(eo,{}),ke(Zl,{})]}),ke(po,{})]}),ke(ra,{})]})})]})},fo=e=>{const t=qn();return ke(uo,{assetType:null==e?void 0:e.assetType,client:t,document:null==e?void 0:e.document,selectedAssets:null==e?void 0:e.selectedAssets,children:ke(it,{scheme:"dark",theme:Pe,children:ke(at,{children:_e(On,{onSelect:null==e?void 0:e.onSelect,children:[ke(gi,{}),ke(yo,{onClose:null==e?void 0:e.onClose})]})})})})},vo=()=>{const[e]=pt((()=>document.createElement("div")));return dt((()=>(e.classList.add("media-portal"),document.body.appendChild(e),()=>{document.body.removeChild(e)})),[]),e};var bo={title:"Media Tag",icon:ta,name:"media.tag",type:"document",fields:[{title:"Name",name:"name",type:"slug"}],preview:{select:{name:"name"},prepare(e){const{name:t}=e;return{media:ta,title:null==t?void 0:t.current}}}};const xo={icon:Te,name:"media",title:"Media"},Co=B(B({},xo),{},{component:e=>{const{onClose:t}=e,n=vo(),i=Z([]);In("escape",t);const a=e=>{e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()},{zIndex:l}=lt();return ke(ot,{element:n,children:ke(rt,{children:ke(qe,{onDragEnter:a,onDragLeave:a,onDragOver:a,onDrop:a,onMouseUp:a,style:{bottom:0,height:"auto",left:0,position:"fixed",top:0,width:"100%",zIndex:l},children:ke(fo,B({document:i},e))})})})}}),wo=B(B({},xo),{},{component:()=>ke(je,{direction:"column",height:"fill",flex:1,children:ke(fo,{})})}),Io=J({name:"media",form:{file:{assetSources:e=>[...e,Co]},image:{assetSources:e=>[...e,Co]}},schema:{types:[bo]},tools:e=>[...e,wo]});export{Io as media,Co as mediaAssetSource};
2
2
  //# sourceMappingURL=index.esm.js.map