sanity-plugin-mux-input 2.0.0-v3-studio.21 → 2.0.0

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.
Files changed (26) hide show
  1. package/README.md +14 -19
  2. package/lib/_chunks/{Input-3c1cbd98.js → Input-2ba004d3.js} +2 -2
  3. package/lib/_chunks/{Input-3c1cbd98.js.map → Input-2ba004d3.js.map} +1 -1
  4. package/lib/_chunks/{Input-0b484b20.esm.js → Input-af5a0a66.esm.js} +2 -2
  5. package/lib/_chunks/{Input-0b484b20.esm.js.map → Input-af5a0a66.esm.js.map} +1 -1
  6. package/lib/_chunks/{Preview-b41abb07.js → Preview-3195237b.js} +2 -2
  7. package/lib/_chunks/{Preview-b41abb07.js.map → Preview-3195237b.js.map} +1 -1
  8. package/lib/_chunks/{Preview-e552ce93.esm.js → Preview-bb256342.esm.js} +2 -2
  9. package/lib/_chunks/{Preview-e552ce93.esm.js.map → Preview-bb256342.esm.js.map} +1 -1
  10. package/lib/_chunks/VideoSource.styled-1b994d90.js +2 -0
  11. package/lib/_chunks/VideoSource.styled-1b994d90.js.map +1 -0
  12. package/lib/_chunks/VideoSource.styled-f92259cd.esm.js +2 -0
  13. package/lib/_chunks/VideoSource.styled-f92259cd.esm.js.map +1 -0
  14. package/lib/_chunks/{index-6319c19e.esm.js → index-3d8d7583.esm.js} +2 -2
  15. package/lib/_chunks/{index-6319c19e.esm.js.map → index-3d8d7583.esm.js.map} +1 -1
  16. package/lib/_chunks/{index-a8ca4222.js → index-efe6ce48.js} +2 -2
  17. package/lib/_chunks/{index-a8ca4222.js.map → index-efe6ce48.js.map} +1 -1
  18. package/lib/index.esm.js +1 -1
  19. package/lib/index.js +1 -1
  20. package/package.json +4 -4
  21. package/src/util/generateJwt.ts +1 -17
  22. package/v2-incompatible.js +1 -1
  23. package/lib/_chunks/VideoSource.styled-243df6cd.esm.js +0 -2
  24. package/lib/_chunks/VideoSource.styled-243df6cd.esm.js.map +0 -1
  25. package/lib/_chunks/VideoSource.styled-537ca588.js +0 -2
  26. package/lib/_chunks/VideoSource.styled-537ca588.js.map +0 -1
@@ -1,2 +1,2 @@
1
- const e=["icon","id","accept","capture","fontSize","multiple","onSelect","padding","space","textAlign","text","disabled"],t=["onSelect"];var n,r,i,o,a,s,l,d,c,u,p,h,g,f,m,y,v,b,w;function x(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function S(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{jsxs as O,jsx as P,Fragment as D}from"react/jsx-runtime";import E,{useState as I,useMemo as T,memo as _,useRef as j,useLayoutEffect as M,useCallback as K,useId as z,useEffect as L,isValidElement as R,createElement as A,forwardRef as F,Component as G,useReducer as q}from"react";import{u as V,V as H,A as B,T as Y,C as Z,g as N,a as W,b as X,c as $,_ as J,d as Q}from"./VideoSource.styled-243df6cd.esm.js";import{useProjectId as ee,useDataset as te,useDocumentValues as ne,PatchEvent as re,setIfMissing as ie,set as oe,unset as ae,LinearProgress as se}from"sanity";import le from"swr";import{m as de,c as ce,I as ue}from"./index-6319c19e.esm.js";import{Observable as pe,defer as he,concat as ge,of as fe,throwError as me,from as ye,Subject as ve}from"rxjs";import{switchMap as be,mergeMap as we,catchError as xe,mergeMapTo as Se,takeUntil as ke,tap as Ce}from"rxjs/operators";import{uuid as Ue}from"@sanity/uuid";import*as Oe from"@mux/upchunk";import{Card as Pe,Box as De,Flex as Ee,Spinner as Ie,Text as Te,Button as _e,useClickOutside as je,MenuButton as Me,Menu as Ke,MenuItem as ze,useToast as Le,Dialog as Re,Grid as Ae,Stack as Fe,Checkbox as Ge,Code as qe,Inline as Ve,Tooltip as He,Popover as Be,Label as Ye,MenuDivider as Ze,rem as Ne,TextInput as We,Heading as Xe}from"@sanity/ui";import{DownloadIcon as $e,EllipsisVerticalIcon as Je,TrashIcon as Qe,LockIcon as et,EditIcon as tt,UploadIcon as nt,SearchIcon as rt,PlugIcon as it,ResetIcon as ot,DocumentVideoIcon as at}from"@sanity/icons";import{animate as st}from"motion";import lt,{css as dt}from"styled-components";import{getDevicePixelRatio as ct}from"use-device-pixel-ratio";import{generatePlayerInitTime as ut,initialize as pt}from"@mux/playback-core";import{MediaControlBar as ht,MediaPosterImage as gt,MediaController as ft,MediaLoadingIndicator as mt,MediaPlayButton as yt,MediaMuteButton as vt,MediaTimeDisplay as bt,MediaTimeRange as wt,MediaDurationDisplay as xt,MediaFullscreenButton as St}from"media-chrome/dist/react";import{isValidElementType as kt}from"react-is";import{clear as Ct,preload as Ut}from"suspend-react";import"use-error-boundary";import"scroll-into-view-if-needed";const Ot=["token","secretKey","enableSignedUrls","signingKeyId","signingKeyPrivate"];function Pt(e,t,n){return new pe((r=>{const i=Oe.createUpload({endpoint:t,file:n,dynamicChunkSize:!0});return i.on("success",(()=>{r.next({type:"success",id:e}),r.complete()})),i.on("error",(e=>r.error(new Error(e.detail.message)))),i.on("progress",(e=>r.next({type:"progress",percent:e.detail}))),i.on("offline",(()=>{i.pause(),r.next({type:"pause",id:e})})),i.on("online",(()=>{i.resume(),r.next({type:"resume",id:e})})),()=>i.abort()}))}function Dt(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/assets/".concat(n,"/").concat(t),withCredentials:!0,method:"DELETE"})}function Et(e,t,n,r,i,o){const a={_id:"secrets.mux",_type:"mux.apiKey",token:t,secretKey:n,enableSignedUrls:r,signingKeyId:i,signingKeyPrivate:o};return e.createOrReplace(a)}function It(e){const{dataset:t}=e.config();return he((()=>e.observable.request({url:"/addons/mux/secrets/".concat(t,"/test"),withCredentials:!0,method:"GET"})))}function Tt(e,t){return e.observable.request({url:"/addons/mux/uploads/".concat(e.clientConfig.dataset,"/").concat(t),withCredentials:!0,method:"DELETE"})}async function _t(e,t){let n,r;try{n=await function(e,t){let n,r,i,o=0;return new Promise(((a,s)=>{n=setInterval((async()=>{try{i=await function(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/uploads/".concat(n,"/").concat(t),withCredentials:!0,method:"GET"})}(e,t)}catch(e){return void s(e)}r=i&&i.data&&i.data.asset_id,r&&(clearInterval(n),a(i)),o>10&&(clearInterval(n),s(new Error("Upload did not finish"))),o++}),2e3)}))}(e,t)}catch(e){return Promise.reject(e)}try{r=await function(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/assets/".concat(n,"/data/").concat(t),withCredentials:!0,method:"GET"})}(e,n.data.asset_id)}catch(e){return Promise.reject(e)}const i={_id:t,_type:"mux.videoAsset",status:r.data.status,data:r.data,assetId:r.data.id,playbackId:r.data.playback_ids[0].id,uploadId:n.data.id};return e.createOrReplace(i).then((()=>i))}function jt(e){if("undefined"!=typeof window&&e instanceof window.File){const t=function(e,t){if("undefined"==typeof window||!(t instanceof window.File))return e;return{name:!1===e.preserveFilename?void 0:t.name,type:t.type}}({},e);return fe(t)}return me(new Error("Invalid file"))}function Mt(e){const t=new Error("Invalid URL");if("string"!=typeof e)return me(t);let n;try{n=new URL(e)}catch(e){return me(t)}return n&&!n.protocol.match(/http:|https:/)?me(t):fe(e)}function Kt(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t&&t.length>0?Promise.resolve(t):function(e){return Promise.all(e.map((e=>{if("file"===e.kind&&e.webkitGetAsEntry){let t;try{t=e.webkitGetAsEntry()}catch(t){return[e.getAsFile()]}return t?t.isDirectory?zt(t):[e.getAsFile()]:[]}if("file"===e.kind){const t=e.getAsFile();return Promise.resolve(t?[t]:[])}return new Promise((t=>e.getAsString(t))).then((t=>t?[new File([t],"unknown.txt",{type:e.type})]:[]))})))}(n).then((e=>e.flat()))}function zt(e){if(function(e){return e.isFile}(e))return new Promise((t=>e.file(t))).then((e=>[e]));if(function(e){return e.isDirectory}(e)){const t=e.createReader();return new Promise((e=>t.readEntries(e))).then((e=>e.filter((e=>!e.name.startsWith("."))))).then((e=>Promise.all(e.map(zt)).then((e=>e.flat()))))}return Promise.resolve([])}function Lt(e){const{asset:t}=e,n=z(),[r,i]=I(),[o,a]=I(!1),[s,l]=I(null),d=K((()=>i("confirm-delete")),[]),c=K((()=>{i(!1),a(!0)}),[i]),u=K((()=>{i(!1),a(!1)}),[i]);return L((()=>{o&&r&&a(!1)}),[r,o]),je(K((()=>a(!1)),[]),[s]),O(D,{children:[P(Me,{id:"".concat(n,"-asset-menu"),button:P(_e,{icon:Je,mode:"ghost",onClick:c,padding:2}),menu:P(Ke,{ref:l,children:P(ze,{tone:"critical",icon:Qe,text:"Delete",onClick:d})}),portal:!0,placement:"right"}),"confirm-delete"===r&&P(Rt,{asset:t,onClose:u})]})}function Rt(e){const{asset:t,onClose:n}=e,r=V(),{push:i}=Le(),[o,a]=I(!1),[s,l]=I(!1),d=z(),c=200*ct({maxDpr:2}),u=K((async()=>{var e,o,l;a(!0);try{(null==t?void 0:t._id)&&await r.delete(t._id),s&&(null==t?void 0:t.assetId)&&await Dt(r,t.assetId),null==(l=null==(o=null==(e=document.querySelector('[data-id="'.concat(t._id,'"]')))?void 0:e.parentElement)?void 0:o.setAttribute)||l.call(o,"hidden","true")}catch(e){console.error("Failed during delete",e),i({closable:!0,description:null==e?void 0:e.message,duration:5e3,title:"Uncaught error",status:"error"})}finally{a(!1),n()}}),[t._id,t.assetId,r,s,n,i]);return P(Re,{onClose:n,id:"".concat(d,"-confirm-delete"),header:"Delete video",footer:O(Ae,{padding:2,gap:2,columns:2,children:[P(_e,{mode:"bleed",text:"Cancel",onClick:n}),P(_e,{text:"Delete",tone:"critical",icon:Qe,onClick:u,loading:o})]}),width:1,children:P(Fe,{paddingX:0,paddingY:0,space:1,children:P(Pe,{paddingX:[2,3,4],paddingY:[3,3,3,4],children:O(Ae,{columns:3,gap:3,children:[P(Ee,{style:{gridColumn:"span 2"},align:"center",children:P(De,{padding:4,children:O(Fe,{space:4,children:[O(Ee,{align:"center",as:"label",children:[P(Ge,{checked:s,onChange:()=>l((e=>!e))}),P(Te,{style:{margin:"0 10px"},children:"Delete asset on Mux"})]}),O(Ee,{align:"center",as:"label",children:[P(Ge,{disabled:!0,checked:!0}),P(Te,{style:{margin:"0 10px"},children:"Delete video from dataset"})]})]})})}),P(H,{asset:t,width:c,showTip:!0})]})})})})}function At(e){let{assets:t,isLoading:n,isLastPage:r,onSelect:i,onLoadMore:o}=e;const a=K((e=>i(e.currentTarget.dataset.id)),[i]),s=K((e=>{"Enter"===e.key&&i(e.currentTarget.dataset.id)}),[i]),l=200*ct({maxDpr:2});return O(D,{children:[O(De,{padding:4,children:[P(Y,{gap:2,children:t.map((e=>P(Ft,{asset:e,onClick:a,onKeyPress:s,width:l},e._id)))}),n&&0===t.length&&P(Ee,{justify:"center",children:P(Ie,{muted:!0})}),!n&&0===t.length&&P(Te,{align:"center",muted:!0,children:"No videos"})]}),t.length>0&&!r&&P(Z,{tone:"default",padding:4,children:P(Ee,{direction:"column",children:P(_e,{type:"button",icon:$e,loading:n,onClick:o,text:"Load more",tone:"primary"})})})]})}const Ft=_((e=>{let{asset:t,onClick:n,onKeyPress:r,width:i}=e;const[o,a]=I(null),s=j(null);return M((()=>{s.current&&null!==o&&st(s.current,o?{opacity:1}:{opacity:0})}),[o]),O(De,{height:"fill",style:{position:"relative"},children:[O(Pe,{as:"button","data-id":t._id,onClick:n,onKeyPress:r,tabIndex:0,radius:2,padding:1,style:{lineHeight:0,position:"relative"},__unstable_focusRing:!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[P(H,{asset:t,width:i,showTip:!0}),(null==t?void 0:t.playbackId)&&P(Gt,{tone:"transparent",ref:s,margin:1,radius:1,children:null!==o&&P(B,{asset:t,width:i})})]}),P(qt,{children:P(Lt,{asset:t})})]})})),Gt=lt(Pe)(n||(n=S(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n will-change: opacity;\n background: transparent;\n background-color: hsl(0deg 0% 0% / 33%);\n opacity: 0;\n pointer-events: none;\n"]))),qt=lt.div(r||(r=S(["\n box-sizing: border-box;\n position: absolute;\n z-index: 300;\n opacity: 0;\n top: 7px;\n right: 7px;\n\n button:hover + &,\n button:focus-visible + &,\n &:hover,\n &:focus-visible {\n opacity: 1;\n }\n"])));function Vt(e){let{asset:t,onChange:n,setDialogState:r}=e;const i=V(),o=j(0),[a,s]=I(!1),[l,d]=I(!1),[c,u]=I([]),p=K((e=>{const t=200*e,n=t+200;return d(!0),i.fetch(function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return'*[_type == "mux.videoAsset"] | order(_updatedAt desc) ['.concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,"...").concat(e,"]")}(t,n)).then((e=>{s(e.length<200),u((t=>t.concat(e)))})).finally((()=>d(!1)))}),[i]),h=K((e=>{const t=c.find((t=>t._id===e));if(!t)throw new TypeError("Failed to find video asset with id: ".concat(e));n(re.from([ie({asset:{}}),oe({_type:"reference",_weak:!0,_ref:t._id},["asset"])])),r(!1)}),[c,n,r]),g=K((()=>{p(++o.current)}),[p]);return L((()=>{p(o.current)}),[p]),P(At,{onSelect:h,assets:c,isLastPage:a,isLoading:l,onLoadMore:g})}function Ht(e){let{setDialogState:t,asset:n,onChange:r}=e;const i="InputBrowser".concat(z()),o=K((()=>t(!1)),[t]);return P(Re,{scheme:"dark",__unstable_autoFocus:!0,header:"Select video",id:i,onClose:o,width:2,children:P(Vt,{asset:n,onChange:r,setDialogState:t})})}function Bt(e){let{asset:t,getCurrentTime:n,setDialogState:r}=e;const i=V(),o="EditThumbnailDialog".concat(z()),a=T((()=>n()),[n]),s=T((()=>C(C({},t),{},{thumbTime:a})),[t,a]),[l,d]=I(!1),[c,u]=I(null),p=K((()=>{d(!0),i.patch(t._id).set({thumbTime:a}).commit({returnDocuments:!1}).then((()=>{r(!1)})).catch(u).finally((()=>{d(!1)}))}),[i,t._id,a,r]),h=300*ct({maxDpr:2});if(c)throw c;return P(Re,{id:o,header:"Edit thumbnail",onClose:()=>r(!1),footer:P(Fe,{padding:3,children:P(_e,{mode:"ghost",tone:"primary",loading:l,onClick:p,text:"Set new thumbnail"},"thumbnail")}),children:O(Fe,{space:3,padding:3,children:[O(Fe,{space:2,children:[P(Te,{size:1,weight:"semibold",children:"Current:"}),P(H,{asset:t,width:h})]}),O(Fe,{space:2,children:[P(Te,{size:1,weight:"semibold",children:"New:"}),P(H,{asset:s,width:h})]})]})})}const Yt=lt(Pe)(i||(i=S(["\n position: relative;\n min-height: 150px;\n aspect-ratio: 16 / 9;\n overflow: hidden;\n border-radius: 1px;\n media-airplay-button[media-airplay-unavailable] {\n display: none;\n }\n media-volume-range[media-volume-unavailable] {\n display: none;\n }\n media-pip-button[media-pip-unavailable] {\n display: none;\n }\n media-controller {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n --media-range-track-background-color: rgba(255, 255, 255, 0.5);\n --media-range-track-border-radius: 3px;\n width: 100%;\n height: 100%;\n background-color: transparent;\n }\n media-control-bar {\n --media-button-icon-width: 18px;\n --media-preview-time-margin: 0px;\n }\n media-control-bar:not([slot]) :is([role='button'], [role='switch'], button) {\n height: 44px;\n }\n .size-extra-small media-control-bar [role='button'],\n .size-extra-small media-control-bar [role='switch'] {\n height: auto;\n padding: 4.4% 3.2%;\n }\n .mxp-spacer {\n flex-grow: 1;\n height: 100%;\n background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));\n }\n media-controller::part(vertical-layer) {\n transition: background-color 1s;\n }\n media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer) {\n background-color: rgba(0, 0, 0, 0.6);\n transition: background-color 0.25s;\n }\n .mxp-center-controls {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n .mxp-center-controls media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n .mxp-center-controls media-seek-backward-button,\n .mxp-center-controls media-seek-forward-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n margin: 0 10%;\n width: min(7%, 70px);\n }\n media-loading-indicator {\n --media-loading-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n position: absolute;\n width: min(15%, 150px);\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n /* Intentionally don't target the div for transition but the children\n of the div. Prevents messing with media-chrome's autohide feature. */\n media-loading-indicator + div * {\n transition: opacity 0.15s;\n opacity: 1;\n }\n media-loading-indicator[media-loading]:not([media-paused]) ~ div > * {\n opacity: 0;\n transition-delay: 400ms;\n }\n media-volume-range {\n width: min(100%, 100px);\n }\n media-time-display {\n white-space: nowrap;\n }\n :is(media-time-display, media-text-display, media-playback-rate-button) {\n color: inherit;\n }\n media-controller:fullscreen media-control-bar[slot='top-chrome'] {\n /* Hide menus and buttons that trigger modals when in full-screen */\n display: none;\n }\n video {\n background: transparent;\n }\n media-controller:not(:fullscreen) video {\n aspect-ratio: 16 / 9;\n }\n media-controller:not(:-webkit-full-screen) video {\n aspect-ratio: 16 / 9;\n }\n"]))),Zt=lt.div(o||(o=S(["\n && {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n }\n"]))),Nt=lt(ht)(a||(a=S(["\n justify-content: flex-end;\n button {\n height: auto;\n }\n"])));function Wt(e){let{asset:t}=e;const n=V(),r=j(null),i=T((()=>$({client:n,asset:t,width:1920,height:1080})),[n,t]);return L((()=>{var e;if(r.current){const t=document.createElement("style");t.innerHTML="img { object-fit: contain; }",(null==(e=r.current)?void 0:e.shadowRoot)&&r.current.shadowRoot.appendChild(t)}}),[]),P(gt,{ref:r,slot:"poster",src:i})}function Xt(e){let{asset:t}=e;const n=V(),[r]=I((()=>function(e){let{asset:t,client:n}=e;const r=N(t),i=new URLSearchParams;if("signed"===W(t)){const e=X(n,r,"s");i.set("token",e)}return"https://image.mux.com/".concat(r,"/storyboard.vtt?").concat(i)}({asset:t,client:n})));return P("track",{label:"thumbnails",default:!0,kind:"metadata",src:r})}const $t=lt(Pe)(s||(s=S(["\n min-height: 82px;\n box-sizing: border-box;\n"]))),Jt=lt(Ee)(l||(l=S(["\n text-overflow: ellipsis;\n overflow: hidden;\n"]))),Qt=lt(Fe)(d||(d=S(["\n position: relative;\n width: 60%;\n"]))),en=lt(qe)(c||(c=S(["\n position: relative;\n width: 100%;\n\n code {\n overflow: hidden;\n text-overflow: ellipsis;\n position: relative;\n max-width: 200px;\n }\n"]))),tn=e=>{let{progress:t=100,onCancel:n,filename:r,text:i="Uploading"}=e;return P($t,{tone:"primary",padding:4,border:!0,height:"fill",children:O(Jt,{align:"center",justify:"space-between",height:"fill",direction:"row",gap:2,children:[O(Qt,{children:[P(Ee,{justify:"center",gap:[3,3,2,2],direction:["column","column","row"],children:P(Te,{size:1,children:O(Ve,{space:2,children:[i,P(en,{size:1,children:r||"..."})]})})}),P(Pe,{marginTop:3,radius:5,shadow:1,children:P(se,{value:t})})]}),n?P(_e,{fontSize:2,text:"Cancel upload",mode:"ghost",tone:"critical",onClick:n}):null]})})},nn=e=>{let{asset:t,buttons:n,readOnly:r,onChange:i,dialogState:o,setDialogState:a}=e;var s,l,d,c;const u=V(),p=T((()=>"preparing"===(null==t?void 0:t.status)?"Preparing the video":"waiting_for_upload"===(null==t?void 0:t.status)?"Waiting for upload to start":"waiting"===(null==t?void 0:t.status)?"Processing upload":"ready"!==(null==t?void 0:t.status)&&void 0!==(null==t?void 0:t.status)),[t]),h=T((()=>{var e,n,r,i;return"preparing"===(null==(n=null==(e=null==t?void 0:t.data)?void 0:e.static_renditions)?void 0:n.status)||(null==(i=null==(r=null==t?void 0:t.data)?void 0:r.static_renditions)||i.status,!1)}),[null==(l=null==(s=null==t?void 0:t.data)?void 0:s.static_renditions)?void 0:l.status]),g=T((()=>t.playbackId&&function(e){let{asset:t,client:n}=e;const r=N(t),i=new URLSearchParams;if("signed"===W(t)){const e=X(n,r,"v");i.set("token",e)}return"https://stream.mux.com/".concat(r,".m3u8?").concat(i)}({client:u,asset:t})),[t,u]),[f,m]=I(null),y=K((e=>m(e.currentTarget.error)),[]),v=j(null),b=j(null),w=j(null),x=K((()=>{var e,t;return null!=(t=null==(e=w.current)?void 0:e.currentTime)?t:0}),[w]),S=((e,t)=>{const n=V();return K((()=>{e&&(t(re.from(ae())),e.assetId&&Dt(n,e.assetId),e._id&&n.delete(e._id))}),[e,n,t])})(t,i);L((()=>{var e,t;const n=document.createElement("style");n.innerHTML="button svg { vertical-align: middle; }",(null==(e=v.current)?void 0:e.shadowRoot)&&v.current.shadowRoot.appendChild(n),(null==(t=null==b?void 0:b.current)?void 0:t.shadowRoot)&&b.current.shadowRoot.appendChild(n.cloneNode(!0))}),[]);const[k]=I((()=>ut())),C=j(void 0);if(L((()=>{if(p||!g)return;const e=pt({src:g,playerInitTime:k,playerSoftwareName:"sanity-plugin-mux-input",playerSoftwareVersion:"dev-preview"},w.current,C.current);C.current=e}),[g,p,k]),L((()=>{var e,n,r;if("errored"===(null==t?void 0:t.status))throw S(),new Error(null==(r=null==(n=null==(e=t.data)?void 0:e.errors)?void 0:n.messages)?void 0:r.join(" "))}),[null==(c=null==(d=t.data)?void 0:d.errors)?void 0:c.messages,null==t?void 0:t.status,S]),f)throw f;return t&&t.status?p?P(tn,{progress:100,filename:null==t?void 0:t.filename,text:!0!==p&&p||"Waiting for Mux to complete the file",onCancel:r?void 0:()=>S()}):O(D,{children:[O(Yt,{shadow:1,tone:"transparent",scheme:"dark",children:[O(ft,{children:[P("video",{playsInline:!0,ref:w,onError:y,slot:"media",preload:"metadata",crossOrigin:"anonomous",children:P(Xt,{asset:t})}),P(Wt,{asset:t}),P(mt,{slot:"centered-chrome",noAutoHide:!0}),P(Zt,{slot:"centered-chrome",children:P(yt,{})}),n&&P(Nt,{slot:"top-chrome",children:n}),O(ht,{children:[P(vt,{}),P(bt,{}),P(wt,{}),P(xt,{}),P(St,{})]})]}),h&&P(Pe,{padding:2,radius:1,style:{background:"var(--card-fg-color)",position:"absolute",top:"0.5em",left:"0.5em"},children:P(Te,{size:1,style:{color:"var(--card-bg-color)"},children:"MUX is preparing static renditions, please stand by"})})]}),"edit-thumbnail"===o&&P(Bt,{asset:t,getCurrentTime:x,setDialogState:a})]}):null};function rn(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function on(e){const{base:t,border:n,focusRing:r}=e,i=r.offset+r.width,o=0-r.offset,a=t?t.bg:"var(--card-bg-color)";return[o>0&&"inset 0 0 0 ".concat(o,"px var(--card-focus-ring-color)"),n&&rn(n),o<0&&"0 0 0 ".concat(0-o,"px ").concat(a),i>0&&"0 0 0 ".concat(i,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}const an=lt(ze)((e=>{let{theme:t}=e;const{focusRing:n}=t.sanity,r=t.sanity.color.base;return dt(u||(u=S(["\n position: relative;\n\n &:not([data-disabled='true']) {\n &:focus-within {\n box-shadow: ",";\n }\n }\n\n & input {\n overflow: hidden;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n min-width: 0;\n display: block;\n appearance: none;\n padding: 0;\n margin: 0;\n border: 0;\n opacity: 0;\n }\n "])),on({base:r,border:{width:1,color:"var(--card-border-color)"},focusRing:n}))})),sn=E.forwardRef((function(t,n){const{icon:r,id:i,accept:o,capture:a,fontSize:s,multiple:l,onSelect:d,padding:c=3,space:u=3,textAlign:p,text:h,disabled:g}=t,f=x(t,e),m=z(),y=i||m,v=E.useCallback((e=>{d&&e.target.files&&d(Array.from(e.target.files))}),[d]),b=O(Ee,{align:"center",justify:"flex-start",padding:c,children:[r&&P(De,{marginRight:h?u:void 0,children:O(Te,{size:s,children:[R(r)&&r,kt(r)&&A(r)]})}),h&&P(Te,{align:p,size:s,textOverflow:"ellipsis",children:h})]});return O(an,C(C({},f),{},{htmlFor:y,padding:0,fontSize:2,disabled:g,ref:n,children:[b,P("input",{"data-testid":"file-button-input",accept:o,capture:a,id:y,multiple:l,onChange:v,type:"file",value:"",disabled:g})]}))})),ln=lt(Pe)(p||(p=S(["\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0.6;\n mix-blend-mode: screen;\n background: transparent;\n"]))),dn=lt(_e)(h||(h=S(["\n background: transparent;\n color: white;\n"])));var cn=_((function(e){const{asset:t,readOnly:n,dialogState:r,setDialogState:i,onChange:o,onUpload:a}=e,[s,l]=I(!1),[d,c]=I(null),u=T((()=>"signed"===W(t)),[t]),p=K((()=>o(re.from(ae([])))),[o]);return L((()=>{s&&r&&l(!1)}),[r,s]),je(K((()=>l(!1)),[]),[d]),O(Ve,{space:1,padding:2,children:[u&&P(He,{content:P(De,{padding:2,children:P(Te,{muted:!0,size:1,children:"Signed playback policy"})}),placement:"right",portal:!0,children:P(ln,{radius:2,margin:2,scheme:"dark",tone:"positive",children:P(dn,{icon:et,mode:"bleed",tone:"positive"})})}),!n&&P(_e,{icon:tt,mode:"ghost",onClick:()=>i("edit-thumbnail")}),P(Be,{content:O(Ke,{ref:c,children:[P(De,{padding:2,children:P(Ye,{muted:!0,size:1,children:"Replace"})}),P(sn,{accept:"video/*",icon:nt,mode:"bleed",onSelect:a,text:"Upload",disabled:n,fontSize:2}),P(ze,{icon:rt,text:"Browse",onClick:()=>i("select-video")}),P(Ze,{}),P(ze,{icon:it,text:"Configure API",onClick:()=>i("secrets")}),P(Ze,{}),P(ze,{tone:"critical",icon:ot,text:"Clear field",onClick:p,disabled:n})]}),portal:!0,open:s,children:P(_e,{icon:Je,mode:"ghost",onClick:()=>{i(!1),l(!0)}})})]})}));const un=lt(Pe)((e=>{const t={width:e.$border?1:0,color:"var(--card-border-color)"};return dt(g||(g=S(["\n --card-focus-box-shadow: ",";\n\n border-radius: ",";\n outline: none;\n box-shadow: var(--card-focus-box-shadow);\n\n &:focus {\n --card-focus-box-shadow: ",";\n }\n "])),rn(t),Ne(e.theme.sanity.radius[1]),on({base:e.theme.sanity.color.base,border:t,focusRing:e.theme.sanity.focusRing}))}));const pn=F(((e,t)=>{let{children:n,tone:r,onPaste:i,onDrop:o,onDragEnter:a,onDragLeave:s,onDragOver:l}=e;const d=j(!1),c=j(null),u=K((e=>{17!=e.keyCode&&91!=e.keyCode||(d.current=!0);d.current&&86==e.keyCode&&c.current.focus()}),[]),p=K((e=>{17!=e.keyCode&&91!=e.keyCode||(d.current=!1)}),[]);return O(un,{tone:r,height:"fill",ref:t,padding:0,radius:2,shadow:0,tabIndex:0,onKeyDown:u,onKeyUp:p,onPaste:i,onDrop:o,onDragEnter:a,onDragLeave:s,onDragOver:l,children:[P(hn,{ref:c,onPaste:i}),n]})})),hn=lt.input.attrs({type:"text"})(f||(f=S(["\n position: absolute;\n border: 0;\n color: white;\n opacity: 0;\n\n &:focus {\n outline: none;\n }\n"]))),gn=lt.input(m||(m=S(["\n overflow: hidden;\n width: 0.1px;\n height: 0.1px;\n opacity: 0;\n position: absolute;\n z-index: -1;\n"]))),fn=lt.label(y||(y=S(["\n position: relative;\n"]))),mn=e=>{let{onSelect:n}=e,r=x(e,t);const i="FileSelect".concat(z()),o=j(null),a=K((e=>{n&&n(e.target.files)}),[n]),s=K((()=>{var e;return null==(e=o.current)?void 0:e.click()}),[]);return O(fn,{htmlFor:i,children:[P(gn,{accept:"video/*",ref:o,tabIndex:0,type:"file",id:i,onChange:a,value:""}),P(_e,C({onClick:s,mode:"default",tone:"primary",style:{width:"100%"}},r))]})},yn=lt(Pe)(v||(v=S(["\n && {\n border-style: dashed;\n }\n"]))),vn=lt(De)(b||(b=S(["\n position: absolute;\n top: 0;\n right: 0;\n"])));function bn(e){const{setDialogState:t,readOnly:n,onSelect:r,hovering:i,needsSetup:o}=e,a=K((()=>t("select-video")),[t]),s=K((()=>t("secrets")),[t]);return P(De,{style:{padding:1,position:"relative"},height:"stretch",children:O(yn,{sizing:"border",height:"fill",tone:n?"transparent":"inherit",border:!0,padding:3,style:i?{borderColor:"transparent"}:void 0,children:[P(vn,{padding:3,children:P(_e,{padding:3,radius:3,tone:o?"critical":void 0,onClick:s,icon:it,mode:"bleed"})}),O(Ee,{align:"center",justify:"space-between",gap:4,direction:["column","column","row"],paddingY:[2,2,0],sizing:"border",height:"fill",children:[O(Ee,{align:"center",justify:"center",gap:2,flex:1,children:[P(Ee,{justify:"center",children:P(Te,{muted:!0,children:P(at,{})})}),P(Ee,{justify:"center",children:P(Te,{size:1,muted:!0,children:"Drag video or paste URL here"})})]}),O(Ve,{space:2,children:[P(mn,{mode:"ghost",tone:"default",icon:nt,text:"Upload",onSelect:r}),P(_e,{mode:"ghost",icon:rt,text:"Select",onClick:a})]})]})]})})}class wn extends G{constructor(){super(...arguments),this.state={isDraggingOver:!1,invalidPaste:!1,invalidFile:!1,uploadProgress:null,fileInfo:null,uuid:null,error:null,url:null},this.dragEnteredEls=[],this.ctrlDown=!1,this.upload=null,this.container=E.createRef(),this.handleProgress=e=>{this.setState({uploadProgress:e.percent})},this.onUpload=e=>{this.setState({uploadProgress:0,fileInfo:null,uuid:null}),this.upload=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return jt(n).pipe(be((i=>ge(fe({type:"file",file:i}),It(t).pipe(be((i=>{if(!i||!i.status)return me(new Error("Invalid credentials"));const o=Ue(),{enableSignedUrls:a}=r,s={mp4_support:e.mp4_support,playback_policy:[a?"signed":"public"]};return ge(fe({type:"uuid",uuid:o}),he((()=>t.observable.request({url:"/addons/mux/uploads/".concat(t.clientConfig.dataset),withCredentials:!0,method:"POST",headers:{"MUX-Proxy-UUID":o,"Content-Type":"application/json"},body:s}))).pipe(we((e=>Pt(o,e.upload.url,n).pipe(we((e=>"success"!==e.type?fe(e):ye(_t(t,o)).pipe(we((t=>fe(C(C({},e),{},{asset:t}))))))),xe((e=>Tt(t,o).pipe(Se(me(e))))))))))})))))))}(this.props.config,this.props.client,e[0],{enableSignedUrls:this.props.secrets.enableSignedUrls}).pipe(ke(this.onCancelUploadButtonClick$.pipe(Ce((()=>{this.state.uuid&&this.props.client.delete(this.state.uuid)}))))).subscribe({complete:()=>{this.setState({error:null,uploadProgress:null,uuid:null})},next:e=>{this.handleUploadEvent(e)},error:e=>{this.setState({error:e,uploadProgress:null,uuid:null})}})},this.handleUploadEvent=e=>{switch(e.type){case"success":return this.handleUploadSuccess(e.asset);case"progress":return this.handleProgress(e);case"file":return this.setState({fileInfo:e.file});case"uuid":return this.setState({uuid:e.uuid});case"url":return this.setState({url:e.url,uploadProgress:100});default:return null}},this.handleUploadSuccess=e=>{this.setState({uploadProgress:100}),this.props.onChange(re.from([ie({asset:{}}),oe({_type:"reference",_weak:!0,_ref:e._id},["asset"])]))},this.handlePaste=e=>{const t=(e.clipboardData||window.clipboardData).getData("text"),n={enableSignedUrls:this.props.secrets.enableSignedUrls};this.upload=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Mt(n).pipe(be((n=>ge(fe({type:"url",url:n}),It(t).pipe(be((i=>{if(!i||!i.status)return me(new Error("Invalid credentials"));const o=Ue(),{enableSignedUrls:a}=r,s={input:n,playback_policy:[a?"signed":"public"],mp4_support:e.mp4_support},l={muxBody:JSON.stringify(s),filename:n.split("/").slice(-1)[0]},d=t.clientConfig.dataset;return he((()=>t.observable.request({url:"/addons/mux/assets/".concat(d),withCredentials:!0,method:"POST",headers:{"MUX-Proxy-UUID":o,"Content-Type":"application/json"},query:l}))).pipe(we((e=>{const t=e&&e.results&&e.results[0]&&e.results[0].document||null;return t?fe({type:"success",id:o,asset:t}):me(new Error("No asset document returned"))})))})))))))}(this.props.config,this.props.client,t,n).subscribe({complete:()=>{this.setState({error:null,uploadProgress:null,url:null})},next:e=>{this.handleUploadEvent(e)},error:e=>{let t;e.message.toLowerCase().match("invalid url")||(t=e),this.setState({invalidPaste:!0,error:t},(()=>{setTimeout((()=>{this.setState({invalidPaste:!1,uploadProgress:null})}),2e3)}))}})},this.handleDrop=e=>{this.setState({isDraggingOver:!1}),e.preventDefault(),e.stopPropagation(),Kt(e.nativeEvent.dataTransfer).then((e=>{e&&this.onUpload(e)}))},this.handleDragOver=e=>{e.preventDefault(),e.stopPropagation()},this.handleDragEnter=e=>{var t,n;e.stopPropagation(),this.dragEnteredEls.push(e.target),this.setState({isDraggingOver:!0});const r=null==(n=null==(t=e.dataTransfer.items)?void 0:t[0])?void 0:n.type;this.setState({invalidFile:!r.startsWith("video/")})},this.handleDragLeave=e=>{e.stopPropagation();const t=this.dragEnteredEls.indexOf(e.target);t>-1&&this.dragEnteredEls.splice(t,1),0===this.dragEnteredEls.length&&this.setState({isDraggingOver:!1})}}componentWillUnmount(){this.unSubscribeToUpload()}componentDidMount(){const e=new ve;this.onCancelUploadButtonClick$=e.asObservable(),this.handleCancelUploadButtonClick=t=>e.next(t)}unSubscribeToUpload(){this.upload&&!this.upload.closed&&this.upload.unsubscribe()}render(){var e;if(null!==this.state.uploadProgress)return P(tn,{onCancel:this.handleCancelUploadButtonClick,progress:this.state.uploadProgress,filename:(null==(e=this.state.fileInfo)?void 0:e.name)||this.state.url});if(this.state.error)throw this.state.error;return O(D,{children:[P(pn,{tone:this.state.isDraggingOver&&(this.state.invalidPaste||this.state.invalidFile)?"critical":this.state.isDraggingOver?"positive":void 0,onDrop:this.handleDrop,onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave,onDragEnter:this.handleDragEnter,onPaste:this.handlePaste,ref:this.container,children:this.props.asset?P(nn,{readOnly:this.props.readOnly,asset:this.props.asset,onChange:this.props.onChange,dialogState:this.props.dialogState,setDialogState:this.props.setDialogState,buttons:P(cn,{asset:this.props.asset,dialogState:this.props.dialogState,setDialogState:this.props.setDialogState,onChange:this.props.onChange,onUpload:this.onUpload,readOnly:this.props.readOnly})}):P(bn,{hovering:this.state.isDraggingOver,onSelect:this.onUpload,readOnly:this.props.readOnly,setDialogState:this.props.setDialogState,needsSetup:this.props.needsSetup})}),"select-video"===this.props.dialogState&&P(Ht,{asset:this.props.asset,onChange:this.props.onChange,setDialogState:this.props.setDialogState})]})}}const xn=(e,t)=>K((async n=>{let{token:r,secretKey:i,enableSignedUrls:o}=n,{signingKeyId:a,signingKeyPrivate:s}=t;try{await Et(e,r,i,o,a,s);const t=await function(e){const{dataset:t}=e.config();return e.request({url:"/addons/mux/secrets/".concat(t,"/test"),withCredentials:!0,method:"GET"})}(e);if(!(null==t?void 0:t.status)&&r&&i)throw new Error("Invalid secrets")}catch(e){throw console.error("Error while trying to save secrets:",e),e}if(o){const t=await async function(e,t,n){if(!t||!n)return!1;const{dataset:r}=e.config();try{const n=await e.request({url:"/addons/mux/signing-keys/".concat(r,"/").concat(t),withCredentials:!0,method:"GET"});return!(!n.data||!n.data.id)}catch(e){return console.error("Error fetching signingKeyId",t,"assuming it is not valid"),!1}}(e,a,s);if(!t)try{const{data:t}=await function(e){const{dataset:t}=e.config();return e.request({url:"/addons/mux/signing-keys/".concat(t),withCredentials:!0,method:"POST"})}(e);a=t.id,s=t.private_key,await Et(e,r,i,o,a,s)}catch(e){throw console.log("Error while creating and saving signing key:",null==e?void 0:e.message),e}}return{token:r,secretKey:i,enableSignedUrls:o,signingKeyId:a,signingKeyPrivate:s}}),[e,t]);function Sn(e){let{token:t,secretKey:n,enableSignedUrls:r}=e;return{submitting:!1,error:null,token:null!=t?t:"",secretKey:null!=n?n:"",enableSignedUrls:null!=r&&r}}function kn(e,t){switch(null==t?void 0:t.type){case"submit":return C(C({},e),{},{submitting:!0,error:null});case"error":return C(C({},e),{},{submitting:!1,error:t.payload});case"reset":return Sn(t.payload);case"change":return C(C({},e),{},{[t.payload.name]:t.payload.value});default:throw new Error("Unknown action type: ".concat(null==t?void 0:t.type))}}const Cn=["title","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"];function Un(e){let{height:t=26}=e;const n=z(),[r,i,o,a,s,l,d,c,u,p,h,g,f,m,y,v,b,w,x]=T((()=>Cn.map((e=>"".concat(n,"-").concat(e)))),[n]);return O("svg",{"aria-labelledby":r,role:"img",xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",viewBox:"92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",style:{height:"".concat(t,"px")},children:[P("title",{id:r,children:"Mux Logo"}),O("defs",{children:[O("linearGradient",{id:a,spreadMethod:"pad",gradientTransform:"matrix(528.38055 0 0 -528.38055 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:s,spreadMethod:"pad",gradientTransform:"matrix(523.66766 0 0 -523.66766 67.897 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:c,spreadMethod:"pad",gradientTransform:"rotate(180 296.075 79.75) scale(524.84045)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:p,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:h,spreadMethod:"pad",gradientTransform:"matrix(523.08514 0 0 -523.08514 67.897 224.446)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:g,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 94.553)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:f,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:m,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 94.554)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:b,spreadMethod:"pad",gradientTransform:"matrix(521.97632 0 0 -521.97632 69.067 191.973)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:w,spreadMethod:"pad",gradientTransform:"matrix(523.09039 0 0 -523.09039 67.312 191.973)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:x,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),P("clipPath",{id:i,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:o,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M423.64 242h164.999V77H423.64Z"})}),P("clipPath",{id:l,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:d,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M311.3 242h93.031V77H311.3Z"})}),P("clipPath",{id:u,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M198.96 242h35.106V77H198.96Z"})}),P("clipPath",{id:y,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:v,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M69.067 242H169.12V141.947H69.067Z"})})]}),P("g",{clipPath:"url(#".concat(i,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(o,")"),children:P("path",{style:{fill:"url(#".concat(a,")"),stroke:"none"},d:"M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"})})}),P("path",{style:{fill:"url(#".concat(s,")"),stroke:"none"},d:"M558.674 236.858 428.781 106.966c-6.855-6.855-6.855-17.969 0-24.825 6.855-6.854 17.969-6.854 24.823 0l129.894 129.894c6.854 6.855 6.854 17.968 0 24.823A17.498 17.498 0 0 1 571.086 242a17.495 17.495 0 0 1-12.412-5.142",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),O("g",{clipPath:"url(#".concat(l,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:[P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(d,")"),children:P("path",{style:{fill:"url(#".concat(c,")"),stroke:"none"},d:"M328.853 112.107c22.297 0 40.372 18.075 40.372 40.372v71.315c0 10.054 7.505 18.206 17.554 18.206 10.048 0 17.552-8.152 17.552-18.206v-71.315c0-41.686-33.793-75.479-75.478-75.479-9.694 0-17.553 7.859-17.553 17.554 0 9.694 7.859 17.553 17.553 17.553"})}),P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(u,")"),children:P("path",{style:{fill:"url(#".concat(p,")"),stroke:"none"},d:"M216.513 242c-10.049 0-17.553-8.152-17.553-18.206V95.206c0-10.054 7.504-18.206 17.553-18.206 10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.054-7.505 18.206-17.553 18.206"})})]}),P("path",{style:{fill:"url(#".concat(h,")"),stroke:"none"},d:"M369.225 224.447c0-9.694 7.859-17.553 17.553-17.553 9.695 0 17.553 7.859 17.553 17.553s-7.858 17.552-17.553 17.552c-9.694 0-17.553-7.858-17.553-17.552",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(g,")"),stroke:"none"},d:"M553.532 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.552-17.554 17.552-9.694 0-17.553-7.858-17.553-17.552",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(f,")"),stroke:"none"},d:"M69.067 223.794V95.206C69.067 85.152 76.571 77 86.62 77c10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.055-7.505 18.205-17.553 18.205-10.049 0-17.553-8.15-17.553-18.205",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(m,")"),stroke:"none"},d:"M198.96 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.553-17.554 17.553-9.694 0-17.553-7.859-17.553-17.553",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("g",{clipPath:"url(#".concat(y,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(v,")"),children:P("path",{style:{fill:"url(#".concat(b,")"),stroke:"none"},d:"M139.155 147.088c6.855-6.855 17.969-6.855 24.824 0s6.855 17.969 0 24.824l-64.947 64.946c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"})})}),P("path",{style:{fill:"url(#".concat(w,")"),stroke:"none"},d:"m204.101 236.858-64.947-64.946c-6.854-6.855-6.854-17.969 0-24.824 6.856-6.855 17.97-6.855 24.824 0l64.947 64.947c6.855 6.855 6.855 17.968 0 24.823A17.495 17.495 0 0 1 216.513 242a17.498 17.498 0 0 1-12.412-5.142",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(x,")"),stroke:"none"},d:"M253.374 223.794v-71.315c0-41.685 33.793-75.479 75.479-75.479 9.695 0 17.553 7.859 17.553 17.554 0 9.694-7.858 17.553-17.553 17.553-22.297 0-40.372 18.075-40.372 40.372v71.315c0 10.055-7.505 18.205-17.554 18.205s-17.553-8.15-17.553-18.205",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"})]})}const On=lt.span(w||(w=S(["\n display: inline-block;\n height: 0.8em;\n margin-right: 1em;\n transform: translate(0.3em, -0.2em);\n"]))),Pn=()=>O(D,{children:[P(On,{children:P(Un,{height:13})}),"API Credentials"]});var Dn=_((function(e){const{children:t,title:n,description:r,inputId:i}=e;return O(Fe,{space:1,children:[P(Ee,{align:"flex-end",children:P(De,{flex:1,paddingY:2,children:P(Fe,{space:2,children:O(Ee,{children:[P(Te,{as:"label",htmlFor:i,weight:"semibold",size:1,children:n||P("em",{children:"Untitled"})}),r&&P(Te,{muted:!0,size:1,children:r})]})})})}),P("div",{children:t})]})}));const En=["token","secretKey","enableSignedUrls"];var In=_((function(e){let{secrets:t,setDialogState:n}=e;var r,i;const o=V(),[a,s]=(e=>q(kn,e,Sn))(t),l=T((()=>t.token&&t.secretKey),[t]),d=K((()=>n(!1)),[n]),c=T((()=>t.token!==a.token||t.secretKey!==a.secretKey||t.enableSignedUrls!==a.enableSignedUrls),[t,a]),u="ConfigureApi".concat(z()),[p,h,g]=T((()=>En.map((e=>"".concat(u,"-").concat(e)))),[u]),f=j(null),m=xn(o,t),y=j(!1),v=K((e=>{if(e.preventDefault(),!y.current&&e.currentTarget.reportValidity()){y.current=!0,s({type:"submit"});const{token:e,secretKey:t,enableSignedUrls:r}=a;m({token:e,secretKey:t,enableSignedUrls:r}).then((e=>{const{projectId:t,dataset:r}=o.config();Ct([ce,J,t,r]),Ut((()=>Promise.resolve(e)),[ce,J,t,r]),n(!1)})).catch((e=>s({type:"error",payload:e.message}))).finally((()=>{y.current=!1}))}}),[o,s,m,n,a]),b=K((e=>{s({type:"change",payload:{name:"token",value:e.currentTarget.value}})}),[s]),w=K((e=>{s({type:"change",payload:{name:"secretKey",value:e.currentTarget.value}})}),[s]),x=K((e=>{s({type:"change",payload:{name:"enableSignedUrls",value:e.currentTarget.checked}})}),[s]);return L((()=>{f.current&&f.current.focus()}),[f]),P(Re,{id:u,onClose:d,header:P(Pn,{}),width:0,children:P(De,{padding:4,style:{position:"relative"},children:P("form",{onSubmit:v,noValidate:!0,children:O(Fe,{space:4,children:[!l&&P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"primary",children:O(Fe,{space:3,children:[O(Te,{size:1,children:["To set up a new access token, go to your"," ",P("a",{href:"https://dashboard.mux.com/settings/access-tokens",target:"_blank",rel:"noreferrer noopener",children:"account on mux.com"}),"."]}),O(Te,{size:1,children:["The access token needs permissions: ",P("strong",{children:"Mux Video "}),"(Full Access) and ",P("strong",{children:"Mux Data"})," (Read)",P("br",{}),"The credentials will be stored safely in a hidden document only available to editors."]})]})}),P(Dn,{title:"Access Token",inputId:p,children:P(We,{id:p,ref:f,onChange:b,type:"text",value:null!=(r=a.token)?r:"",required:!!a.secretKey||a.enableSignedUrls})}),P(Dn,{title:"Secret Key",inputId:h,children:P(We,{id:h,onChange:w,type:"text",value:null!=(i=a.secretKey)?i:"",required:!!a.token||a.enableSignedUrls})}),O(Fe,{space:4,children:[O(Ee,{align:"center",children:[P(Ge,{id:g,onChange:x,checked:a.enableSignedUrls,style:{display:"block"}}),P(De,{flex:1,paddingLeft:3,children:P(Te,{children:P("label",{htmlFor:g,children:"Enable Signed Urls"})})})]}),t.signingKeyId&&a.enableSignedUrls?P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"caution",children:O(Fe,{space:3,children:[P(Te,{size:1,children:"The signing key ID that Sanity will use is:"}),P(qe,{size:1,children:t.signingKeyId}),O(Te,{size:1,children:["This key is only used for previewing content in the Sanity UI.",P("br",{}),"You should generate a different key to use in your application server."]})]})}):null]}),O(Ve,{space:2,children:[P(_e,{text:"Save",disabled:!c,loading:a.submitting,tone:"primary",mode:"default",type:"submit"}),P(_e,{disabled:a.submitting,text:"Cancel",mode:"bleed",onClick:d})]}),a.error&&P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"critical",children:P(Te,{children:a.error})})]})})})})}));function Tn(e){const{setDialogState:t}=e,n=K((()=>t("secrets")),[t]);return P(D,{children:P("div",{style:{padding:2},children:P(Pe,{display:"flex",sizing:"border",style:{aspectRatio:"16/9",width:"100%",boxShadow:"var(--card-bg-color) 0 0 0 2px"},paddingX:[2,3,4,4],radius:1,tone:"transparent",children:P(Ee,{justify:"flex-start",align:"center",children:O(Ae,{columns:1,gap:[2,3,4,4],children:[P(Ve,{paddingY:1,children:P("div",{style:{height:"32px"},children:P(Un,{})})}),P(Ve,{paddingY:1,children:P(Xe,{size:[0,1,2,2],children:"Upload and preview videos directly from your studio."})}),P(Ve,{paddingY:1,children:P(_e,{mode:"ghost",icon:it,text:"Configure API",onClick:n})})]})})})})})}var _n=_((e=>{var t;const n=V(),r=(()=>{const{error:e,isLoading:t,value:n}=ne(de,Ot);return{error:e,isLoading:t,value:T((()=>{const e=Boolean(n),t={token:(null==n?void 0:n.token)||null,secretKey:(null==n?void 0:n.secretKey)||null,enableSignedUrls:(null==n?void 0:n.enableSignedUrls)||!1,signingKeyId:(null==n?void 0:n.signingKeyId)||null,signingKeyPrivate:(null==n?void 0:n.signingKeyPrivate)||null};return{isInitialSetup:!e,needsSetup:!(null==t?void 0:t.token)||!(null==t?void 0:t.secretKey),secrets:t}}),[n])}})(),i=Q(null==(t=e.value)?void 0:t.asset),o=(e=>{var t,n;const r=V(),i=ee(),o=te(),a=T((()=>{var t,n;return!!(null==e?void 0:e.assetId)&&("preparing"===(null==e?void 0:e.status)||"preparing"===(null==(n=null==(t=null==e?void 0:e.data)?void 0:t.static_renditions)?void 0:n.status))}),[null==e?void 0:e.assetId,null==(n=null==(t=null==e?void 0:e.data)?void 0:t.static_renditions)?void 0:n.status,null==e?void 0:e.status]);return le(a?"/".concat(i,"/addons/mux/assets/").concat(o,"/data/").concat(null==e?void 0:e.assetId):null,(async()=>{const{data:t}=await r.request({url:"/addons/mux/assets/".concat(o,"/data/").concat(e.assetId),withCredentials:!0,method:"GET"});r.patch(e._id).set({status:t.status,data:t}).commit({returnDocuments:!1})}),{refreshInterval:2e3,refreshWhenHidden:!0,dedupingInterval:1e3})})(e.readOnly?void 0:(null==i?void 0:i.value)||void 0),[a,s]=I(!1),l=r.error||i.error||o.error;if(l)throw l;const d=r.isLoading||i.isLoading;return P(D,{children:d?P(ue,{}):O(D,{children:[r.value.needsSetup&&!i.value?P(Tn,{setDialogState:s}):P(wn,C(C({},e),{},{config:e.config,onChange:e.onChange,client:n,secrets:r.value.secrets,asset:i.value,dialogState:a,setDialogState:s,needsSetup:r.value.needsSetup})),"secrets"===a&&P(In,{setDialogState:s,secrets:r.value.secrets})]})})}));export{_n as default};
2
- //# sourceMappingURL=Input-0b484b20.esm.js.map
1
+ const e=["icon","id","accept","capture","fontSize","multiple","onSelect","padding","space","textAlign","text","disabled"],t=["onSelect"];var n,r,i,o,a,s,l,d,c,u,p,h,g,f,m,y,v,b,w;function x(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function S(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{jsxs as O,jsx as P,Fragment as D}from"react/jsx-runtime";import E,{useState as I,useMemo as T,memo as _,useRef as j,useLayoutEffect as M,useCallback as K,useId as z,useEffect as L,isValidElement as R,createElement as A,forwardRef as F,Component as G,useReducer as q}from"react";import{u as V,V as H,A as B,T as Y,C as Z,g as N,a as W,b as X,c as $,_ as J,d as Q}from"./VideoSource.styled-f92259cd.esm.js";import{useProjectId as ee,useDataset as te,useDocumentValues as ne,PatchEvent as re,setIfMissing as ie,set as oe,unset as ae,LinearProgress as se}from"sanity";import le from"swr";import{m as de,c as ce,I as ue}from"./index-3d8d7583.esm.js";import{Observable as pe,defer as he,concat as ge,of as fe,throwError as me,from as ye,Subject as ve}from"rxjs";import{switchMap as be,mergeMap as we,catchError as xe,mergeMapTo as Se,takeUntil as ke,tap as Ce}from"rxjs/operators";import{uuid as Ue}from"@sanity/uuid";import*as Oe from"@mux/upchunk";import{Card as Pe,Box as De,Flex as Ee,Spinner as Ie,Text as Te,Button as _e,useClickOutside as je,MenuButton as Me,Menu as Ke,MenuItem as ze,useToast as Le,Dialog as Re,Grid as Ae,Stack as Fe,Checkbox as Ge,Code as qe,Inline as Ve,Tooltip as He,Popover as Be,Label as Ye,MenuDivider as Ze,rem as Ne,TextInput as We,Heading as Xe}from"@sanity/ui";import{DownloadIcon as $e,EllipsisVerticalIcon as Je,TrashIcon as Qe,LockIcon as et,EditIcon as tt,UploadIcon as nt,SearchIcon as rt,PlugIcon as it,ResetIcon as ot,DocumentVideoIcon as at}from"@sanity/icons";import{animate as st}from"motion";import lt,{css as dt}from"styled-components";import{getDevicePixelRatio as ct}from"use-device-pixel-ratio";import{generatePlayerInitTime as ut,initialize as pt}from"@mux/playback-core";import{MediaControlBar as ht,MediaPosterImage as gt,MediaController as ft,MediaLoadingIndicator as mt,MediaPlayButton as yt,MediaMuteButton as vt,MediaTimeDisplay as bt,MediaTimeRange as wt,MediaDurationDisplay as xt,MediaFullscreenButton as St}from"media-chrome/dist/react";import{isValidElementType as kt}from"react-is";import{clear as Ct,preload as Ut}from"suspend-react";import"use-error-boundary";import"scroll-into-view-if-needed";const Ot=["token","secretKey","enableSignedUrls","signingKeyId","signingKeyPrivate"];function Pt(e,t,n){return new pe((r=>{const i=Oe.createUpload({endpoint:t,file:n,dynamicChunkSize:!0});return i.on("success",(()=>{r.next({type:"success",id:e}),r.complete()})),i.on("error",(e=>r.error(new Error(e.detail.message)))),i.on("progress",(e=>r.next({type:"progress",percent:e.detail}))),i.on("offline",(()=>{i.pause(),r.next({type:"pause",id:e})})),i.on("online",(()=>{i.resume(),r.next({type:"resume",id:e})})),()=>i.abort()}))}function Dt(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/assets/".concat(n,"/").concat(t),withCredentials:!0,method:"DELETE"})}function Et(e,t,n,r,i,o){const a={_id:"secrets.mux",_type:"mux.apiKey",token:t,secretKey:n,enableSignedUrls:r,signingKeyId:i,signingKeyPrivate:o};return e.createOrReplace(a)}function It(e){const{dataset:t}=e.config();return he((()=>e.observable.request({url:"/addons/mux/secrets/".concat(t,"/test"),withCredentials:!0,method:"GET"})))}function Tt(e,t){return e.observable.request({url:"/addons/mux/uploads/".concat(e.clientConfig.dataset,"/").concat(t),withCredentials:!0,method:"DELETE"})}async function _t(e,t){let n,r;try{n=await function(e,t){let n,r,i,o=0;return new Promise(((a,s)=>{n=setInterval((async()=>{try{i=await function(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/uploads/".concat(n,"/").concat(t),withCredentials:!0,method:"GET"})}(e,t)}catch(e){return void s(e)}r=i&&i.data&&i.data.asset_id,r&&(clearInterval(n),a(i)),o>10&&(clearInterval(n),s(new Error("Upload did not finish"))),o++}),2e3)}))}(e,t)}catch(e){return Promise.reject(e)}try{r=await function(e,t){const{dataset:n}=e.config();return e.request({url:"/addons/mux/assets/".concat(n,"/data/").concat(t),withCredentials:!0,method:"GET"})}(e,n.data.asset_id)}catch(e){return Promise.reject(e)}const i={_id:t,_type:"mux.videoAsset",status:r.data.status,data:r.data,assetId:r.data.id,playbackId:r.data.playback_ids[0].id,uploadId:n.data.id};return e.createOrReplace(i).then((()=>i))}function jt(e){if("undefined"!=typeof window&&e instanceof window.File){const t=function(e,t){if("undefined"==typeof window||!(t instanceof window.File))return e;return{name:!1===e.preserveFilename?void 0:t.name,type:t.type}}({},e);return fe(t)}return me(new Error("Invalid file"))}function Mt(e){const t=new Error("Invalid URL");if("string"!=typeof e)return me(t);let n;try{n=new URL(e)}catch(e){return me(t)}return n&&!n.protocol.match(/http:|https:/)?me(t):fe(e)}function Kt(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t&&t.length>0?Promise.resolve(t):function(e){return Promise.all(e.map((e=>{if("file"===e.kind&&e.webkitGetAsEntry){let t;try{t=e.webkitGetAsEntry()}catch(t){return[e.getAsFile()]}return t?t.isDirectory?zt(t):[e.getAsFile()]:[]}if("file"===e.kind){const t=e.getAsFile();return Promise.resolve(t?[t]:[])}return new Promise((t=>e.getAsString(t))).then((t=>t?[new File([t],"unknown.txt",{type:e.type})]:[]))})))}(n).then((e=>e.flat()))}function zt(e){if(function(e){return e.isFile}(e))return new Promise((t=>e.file(t))).then((e=>[e]));if(function(e){return e.isDirectory}(e)){const t=e.createReader();return new Promise((e=>t.readEntries(e))).then((e=>e.filter((e=>!e.name.startsWith("."))))).then((e=>Promise.all(e.map(zt)).then((e=>e.flat()))))}return Promise.resolve([])}function Lt(e){const{asset:t}=e,n=z(),[r,i]=I(),[o,a]=I(!1),[s,l]=I(null),d=K((()=>i("confirm-delete")),[]),c=K((()=>{i(!1),a(!0)}),[i]),u=K((()=>{i(!1),a(!1)}),[i]);return L((()=>{o&&r&&a(!1)}),[r,o]),je(K((()=>a(!1)),[]),[s]),O(D,{children:[P(Me,{id:"".concat(n,"-asset-menu"),button:P(_e,{icon:Je,mode:"ghost",onClick:c,padding:2}),menu:P(Ke,{ref:l,children:P(ze,{tone:"critical",icon:Qe,text:"Delete",onClick:d})}),portal:!0,placement:"right"}),"confirm-delete"===r&&P(Rt,{asset:t,onClose:u})]})}function Rt(e){const{asset:t,onClose:n}=e,r=V(),{push:i}=Le(),[o,a]=I(!1),[s,l]=I(!1),d=z(),c=200*ct({maxDpr:2}),u=K((async()=>{var e,o,l;a(!0);try{(null==t?void 0:t._id)&&await r.delete(t._id),s&&(null==t?void 0:t.assetId)&&await Dt(r,t.assetId),null==(l=null==(o=null==(e=document.querySelector('[data-id="'.concat(t._id,'"]')))?void 0:e.parentElement)?void 0:o.setAttribute)||l.call(o,"hidden","true")}catch(e){console.error("Failed during delete",e),i({closable:!0,description:null==e?void 0:e.message,duration:5e3,title:"Uncaught error",status:"error"})}finally{a(!1),n()}}),[t._id,t.assetId,r,s,n,i]);return P(Re,{onClose:n,id:"".concat(d,"-confirm-delete"),header:"Delete video",footer:O(Ae,{padding:2,gap:2,columns:2,children:[P(_e,{mode:"bleed",text:"Cancel",onClick:n}),P(_e,{text:"Delete",tone:"critical",icon:Qe,onClick:u,loading:o})]}),width:1,children:P(Fe,{paddingX:0,paddingY:0,space:1,children:P(Pe,{paddingX:[2,3,4],paddingY:[3,3,3,4],children:O(Ae,{columns:3,gap:3,children:[P(Ee,{style:{gridColumn:"span 2"},align:"center",children:P(De,{padding:4,children:O(Fe,{space:4,children:[O(Ee,{align:"center",as:"label",children:[P(Ge,{checked:s,onChange:()=>l((e=>!e))}),P(Te,{style:{margin:"0 10px"},children:"Delete asset on Mux"})]}),O(Ee,{align:"center",as:"label",children:[P(Ge,{disabled:!0,checked:!0}),P(Te,{style:{margin:"0 10px"},children:"Delete video from dataset"})]})]})})}),P(H,{asset:t,width:c,showTip:!0})]})})})})}function At(e){let{assets:t,isLoading:n,isLastPage:r,onSelect:i,onLoadMore:o}=e;const a=K((e=>i(e.currentTarget.dataset.id)),[i]),s=K((e=>{"Enter"===e.key&&i(e.currentTarget.dataset.id)}),[i]),l=200*ct({maxDpr:2});return O(D,{children:[O(De,{padding:4,children:[P(Y,{gap:2,children:t.map((e=>P(Ft,{asset:e,onClick:a,onKeyPress:s,width:l},e._id)))}),n&&0===t.length&&P(Ee,{justify:"center",children:P(Ie,{muted:!0})}),!n&&0===t.length&&P(Te,{align:"center",muted:!0,children:"No videos"})]}),t.length>0&&!r&&P(Z,{tone:"default",padding:4,children:P(Ee,{direction:"column",children:P(_e,{type:"button",icon:$e,loading:n,onClick:o,text:"Load more",tone:"primary"})})})]})}const Ft=_((e=>{let{asset:t,onClick:n,onKeyPress:r,width:i}=e;const[o,a]=I(null),s=j(null);return M((()=>{s.current&&null!==o&&st(s.current,o?{opacity:1}:{opacity:0})}),[o]),O(De,{height:"fill",style:{position:"relative"},children:[O(Pe,{as:"button","data-id":t._id,onClick:n,onKeyPress:r,tabIndex:0,radius:2,padding:1,style:{lineHeight:0,position:"relative"},__unstable_focusRing:!0,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[P(H,{asset:t,width:i,showTip:!0}),(null==t?void 0:t.playbackId)&&P(Gt,{tone:"transparent",ref:s,margin:1,radius:1,children:null!==o&&P(B,{asset:t,width:i})})]}),P(qt,{children:P(Lt,{asset:t})})]})})),Gt=lt(Pe)(n||(n=S(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n will-change: opacity;\n background: transparent;\n background-color: hsl(0deg 0% 0% / 33%);\n opacity: 0;\n pointer-events: none;\n"]))),qt=lt.div(r||(r=S(["\n box-sizing: border-box;\n position: absolute;\n z-index: 300;\n opacity: 0;\n top: 7px;\n right: 7px;\n\n button:hover + &,\n button:focus-visible + &,\n &:hover,\n &:focus-visible {\n opacity: 1;\n }\n"])));function Vt(e){let{asset:t,onChange:n,setDialogState:r}=e;const i=V(),o=j(0),[a,s]=I(!1),[l,d]=I(!1),[c,u]=I([]),p=K((e=>{const t=200*e,n=t+200;return d(!0),i.fetch(function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return'*[_type == "mux.videoAsset"] | order(_updatedAt desc) ['.concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,"...").concat(e,"]")}(t,n)).then((e=>{s(e.length<200),u((t=>t.concat(e)))})).finally((()=>d(!1)))}),[i]),h=K((e=>{const t=c.find((t=>t._id===e));if(!t)throw new TypeError("Failed to find video asset with id: ".concat(e));n(re.from([ie({asset:{}}),oe({_type:"reference",_weak:!0,_ref:t._id},["asset"])])),r(!1)}),[c,n,r]),g=K((()=>{p(++o.current)}),[p]);return L((()=>{p(o.current)}),[p]),P(At,{onSelect:h,assets:c,isLastPage:a,isLoading:l,onLoadMore:g})}function Ht(e){let{setDialogState:t,asset:n,onChange:r}=e;const i="InputBrowser".concat(z()),o=K((()=>t(!1)),[t]);return P(Re,{scheme:"dark",__unstable_autoFocus:!0,header:"Select video",id:i,onClose:o,width:2,children:P(Vt,{asset:n,onChange:r,setDialogState:t})})}function Bt(e){let{asset:t,getCurrentTime:n,setDialogState:r}=e;const i=V(),o="EditThumbnailDialog".concat(z()),a=T((()=>n()),[n]),s=T((()=>C(C({},t),{},{thumbTime:a})),[t,a]),[l,d]=I(!1),[c,u]=I(null),p=K((()=>{d(!0),i.patch(t._id).set({thumbTime:a}).commit({returnDocuments:!1}).then((()=>{r(!1)})).catch(u).finally((()=>{d(!1)}))}),[i,t._id,a,r]),h=300*ct({maxDpr:2});if(c)throw c;return P(Re,{id:o,header:"Edit thumbnail",onClose:()=>r(!1),footer:P(Fe,{padding:3,children:P(_e,{mode:"ghost",tone:"primary",loading:l,onClick:p,text:"Set new thumbnail"},"thumbnail")}),children:O(Fe,{space:3,padding:3,children:[O(Fe,{space:2,children:[P(Te,{size:1,weight:"semibold",children:"Current:"}),P(H,{asset:t,width:h})]}),O(Fe,{space:2,children:[P(Te,{size:1,weight:"semibold",children:"New:"}),P(H,{asset:s,width:h})]})]})})}const Yt=lt(Pe)(i||(i=S(["\n position: relative;\n min-height: 150px;\n aspect-ratio: 16 / 9;\n overflow: hidden;\n border-radius: 1px;\n media-airplay-button[media-airplay-unavailable] {\n display: none;\n }\n media-volume-range[media-volume-unavailable] {\n display: none;\n }\n media-pip-button[media-pip-unavailable] {\n display: none;\n }\n media-controller {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n --media-range-track-background-color: rgba(255, 255, 255, 0.5);\n --media-range-track-border-radius: 3px;\n width: 100%;\n height: 100%;\n background-color: transparent;\n }\n media-control-bar {\n --media-button-icon-width: 18px;\n --media-preview-time-margin: 0px;\n }\n media-control-bar:not([slot]) :is([role='button'], [role='switch'], button) {\n height: 44px;\n }\n .size-extra-small media-control-bar [role='button'],\n .size-extra-small media-control-bar [role='switch'] {\n height: auto;\n padding: 4.4% 3.2%;\n }\n .mxp-spacer {\n flex-grow: 1;\n height: 100%;\n background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));\n }\n media-controller::part(vertical-layer) {\n transition: background-color 1s;\n }\n media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer) {\n background-color: rgba(0, 0, 0, 0.6);\n transition: background-color 0.25s;\n }\n .mxp-center-controls {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n .mxp-center-controls media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n .mxp-center-controls media-seek-backward-button,\n .mxp-center-controls media-seek-forward-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n margin: 0 10%;\n width: min(7%, 70px);\n }\n media-loading-indicator {\n --media-loading-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n position: absolute;\n width: min(15%, 150px);\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n /* Intentionally don't target the div for transition but the children\n of the div. Prevents messing with media-chrome's autohide feature. */\n media-loading-indicator + div * {\n transition: opacity 0.15s;\n opacity: 1;\n }\n media-loading-indicator[media-loading]:not([media-paused]) ~ div > * {\n opacity: 0;\n transition-delay: 400ms;\n }\n media-volume-range {\n width: min(100%, 100px);\n }\n media-time-display {\n white-space: nowrap;\n }\n :is(media-time-display, media-text-display, media-playback-rate-button) {\n color: inherit;\n }\n media-controller:fullscreen media-control-bar[slot='top-chrome'] {\n /* Hide menus and buttons that trigger modals when in full-screen */\n display: none;\n }\n video {\n background: transparent;\n }\n media-controller:not(:fullscreen) video {\n aspect-ratio: 16 / 9;\n }\n media-controller:not(:-webkit-full-screen) video {\n aspect-ratio: 16 / 9;\n }\n"]))),Zt=lt.div(o||(o=S(["\n && {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n }\n"]))),Nt=lt(ht)(a||(a=S(["\n justify-content: flex-end;\n button {\n height: auto;\n }\n"])));function Wt(e){let{asset:t}=e;const n=V(),r=j(null),i=T((()=>$({client:n,asset:t,width:1920,height:1080})),[n,t]);return L((()=>{var e;if(r.current){const t=document.createElement("style");t.innerHTML="img { object-fit: contain; }",(null==(e=r.current)?void 0:e.shadowRoot)&&r.current.shadowRoot.appendChild(t)}}),[]),P(gt,{ref:r,slot:"poster",src:i})}function Xt(e){let{asset:t}=e;const n=V(),[r]=I((()=>function(e){let{asset:t,client:n}=e;const r=N(t),i=new URLSearchParams;if("signed"===W(t)){const e=X(n,r,"s");i.set("token",e)}return"https://image.mux.com/".concat(r,"/storyboard.vtt?").concat(i)}({asset:t,client:n})));return P("track",{label:"thumbnails",default:!0,kind:"metadata",src:r})}const $t=lt(Pe)(s||(s=S(["\n min-height: 82px;\n box-sizing: border-box;\n"]))),Jt=lt(Ee)(l||(l=S(["\n text-overflow: ellipsis;\n overflow: hidden;\n"]))),Qt=lt(Fe)(d||(d=S(["\n position: relative;\n width: 60%;\n"]))),en=lt(qe)(c||(c=S(["\n position: relative;\n width: 100%;\n\n code {\n overflow: hidden;\n text-overflow: ellipsis;\n position: relative;\n max-width: 200px;\n }\n"]))),tn=e=>{let{progress:t=100,onCancel:n,filename:r,text:i="Uploading"}=e;return P($t,{tone:"primary",padding:4,border:!0,height:"fill",children:O(Jt,{align:"center",justify:"space-between",height:"fill",direction:"row",gap:2,children:[O(Qt,{children:[P(Ee,{justify:"center",gap:[3,3,2,2],direction:["column","column","row"],children:P(Te,{size:1,children:O(Ve,{space:2,children:[i,P(en,{size:1,children:r||"..."})]})})}),P(Pe,{marginTop:3,radius:5,shadow:1,children:P(se,{value:t})})]}),n?P(_e,{fontSize:2,text:"Cancel upload",mode:"ghost",tone:"critical",onClick:n}):null]})})},nn=e=>{let{asset:t,buttons:n,readOnly:r,onChange:i,dialogState:o,setDialogState:a}=e;var s,l,d,c;const u=V(),p=T((()=>"preparing"===(null==t?void 0:t.status)?"Preparing the video":"waiting_for_upload"===(null==t?void 0:t.status)?"Waiting for upload to start":"waiting"===(null==t?void 0:t.status)?"Processing upload":"ready"!==(null==t?void 0:t.status)&&void 0!==(null==t?void 0:t.status)),[t]),h=T((()=>{var e,n,r,i;return"preparing"===(null==(n=null==(e=null==t?void 0:t.data)?void 0:e.static_renditions)?void 0:n.status)||(null==(i=null==(r=null==t?void 0:t.data)?void 0:r.static_renditions)||i.status,!1)}),[null==(l=null==(s=null==t?void 0:t.data)?void 0:s.static_renditions)?void 0:l.status]),g=T((()=>t.playbackId&&function(e){let{asset:t,client:n}=e;const r=N(t),i=new URLSearchParams;if("signed"===W(t)){const e=X(n,r,"v");i.set("token",e)}return"https://stream.mux.com/".concat(r,".m3u8?").concat(i)}({client:u,asset:t})),[t,u]),[f,m]=I(null),y=K((e=>m(e.currentTarget.error)),[]),v=j(null),b=j(null),w=j(null),x=K((()=>{var e,t;return null!=(t=null==(e=w.current)?void 0:e.currentTime)?t:0}),[w]),S=((e,t)=>{const n=V();return K((()=>{e&&(t(re.from(ae())),e.assetId&&Dt(n,e.assetId),e._id&&n.delete(e._id))}),[e,n,t])})(t,i);L((()=>{var e,t;const n=document.createElement("style");n.innerHTML="button svg { vertical-align: middle; }",(null==(e=v.current)?void 0:e.shadowRoot)&&v.current.shadowRoot.appendChild(n),(null==(t=null==b?void 0:b.current)?void 0:t.shadowRoot)&&b.current.shadowRoot.appendChild(n.cloneNode(!0))}),[]);const[k]=I((()=>ut())),C=j(void 0);if(L((()=>{if(p||!g)return;const e=pt({src:g,playerInitTime:k,playerSoftwareName:"sanity-plugin-mux-input",playerSoftwareVersion:"dev-preview"},w.current,C.current);C.current=e}),[g,p,k]),L((()=>{var e,n,r;if("errored"===(null==t?void 0:t.status))throw S(),new Error(null==(r=null==(n=null==(e=t.data)?void 0:e.errors)?void 0:n.messages)?void 0:r.join(" "))}),[null==(c=null==(d=t.data)?void 0:d.errors)?void 0:c.messages,null==t?void 0:t.status,S]),f)throw f;return t&&t.status?p?P(tn,{progress:100,filename:null==t?void 0:t.filename,text:!0!==p&&p||"Waiting for Mux to complete the file",onCancel:r?void 0:()=>S()}):O(D,{children:[O(Yt,{shadow:1,tone:"transparent",scheme:"dark",children:[O(ft,{children:[P("video",{playsInline:!0,ref:w,onError:y,slot:"media",preload:"metadata",crossOrigin:"anonomous",children:P(Xt,{asset:t})}),P(Wt,{asset:t}),P(mt,{slot:"centered-chrome",noAutoHide:!0}),P(Zt,{slot:"centered-chrome",children:P(yt,{})}),n&&P(Nt,{slot:"top-chrome",children:n}),O(ht,{children:[P(vt,{}),P(bt,{}),P(wt,{}),P(xt,{}),P(St,{})]})]}),h&&P(Pe,{padding:2,radius:1,style:{background:"var(--card-fg-color)",position:"absolute",top:"0.5em",left:"0.5em"},children:P(Te,{size:1,style:{color:"var(--card-bg-color)"},children:"MUX is preparing static renditions, please stand by"})})]}),"edit-thumbnail"===o&&P(Bt,{asset:t,getCurrentTime:x,setDialogState:a})]}):null};function rn(e){return"inset 0 0 0 ".concat(e.width,"px ").concat(e.color)}function on(e){const{base:t,border:n,focusRing:r}=e,i=r.offset+r.width,o=0-r.offset,a=t?t.bg:"var(--card-bg-color)";return[o>0&&"inset 0 0 0 ".concat(o,"px var(--card-focus-ring-color)"),n&&rn(n),o<0&&"0 0 0 ".concat(0-o,"px ").concat(a),i>0&&"0 0 0 ".concat(i,"px var(--card-focus-ring-color)")].filter(Boolean).join(",")}const an=lt(ze)((e=>{let{theme:t}=e;const{focusRing:n}=t.sanity,r=t.sanity.color.base;return dt(u||(u=S(["\n position: relative;\n\n &:not([data-disabled='true']) {\n &:focus-within {\n box-shadow: ",";\n }\n }\n\n & input {\n overflow: hidden;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n min-width: 0;\n display: block;\n appearance: none;\n padding: 0;\n margin: 0;\n border: 0;\n opacity: 0;\n }\n "])),on({base:r,border:{width:1,color:"var(--card-border-color)"},focusRing:n}))})),sn=E.forwardRef((function(t,n){const{icon:r,id:i,accept:o,capture:a,fontSize:s,multiple:l,onSelect:d,padding:c=3,space:u=3,textAlign:p,text:h,disabled:g}=t,f=x(t,e),m=z(),y=i||m,v=E.useCallback((e=>{d&&e.target.files&&d(Array.from(e.target.files))}),[d]),b=O(Ee,{align:"center",justify:"flex-start",padding:c,children:[r&&P(De,{marginRight:h?u:void 0,children:O(Te,{size:s,children:[R(r)&&r,kt(r)&&A(r)]})}),h&&P(Te,{align:p,size:s,textOverflow:"ellipsis",children:h})]});return O(an,C(C({},f),{},{htmlFor:y,padding:0,fontSize:2,disabled:g,ref:n,children:[b,P("input",{"data-testid":"file-button-input",accept:o,capture:a,id:y,multiple:l,onChange:v,type:"file",value:"",disabled:g})]}))})),ln=lt(Pe)(p||(p=S(["\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0.6;\n mix-blend-mode: screen;\n background: transparent;\n"]))),dn=lt(_e)(h||(h=S(["\n background: transparent;\n color: white;\n"])));var cn=_((function(e){const{asset:t,readOnly:n,dialogState:r,setDialogState:i,onChange:o,onUpload:a}=e,[s,l]=I(!1),[d,c]=I(null),u=T((()=>"signed"===W(t)),[t]),p=K((()=>o(re.from(ae([])))),[o]);return L((()=>{s&&r&&l(!1)}),[r,s]),je(K((()=>l(!1)),[]),[d]),O(Ve,{space:1,padding:2,children:[u&&P(He,{content:P(De,{padding:2,children:P(Te,{muted:!0,size:1,children:"Signed playback policy"})}),placement:"right",portal:!0,children:P(ln,{radius:2,margin:2,scheme:"dark",tone:"positive",children:P(dn,{icon:et,mode:"bleed",tone:"positive"})})}),!n&&P(_e,{icon:tt,mode:"ghost",onClick:()=>i("edit-thumbnail")}),P(Be,{content:O(Ke,{ref:c,children:[P(De,{padding:2,children:P(Ye,{muted:!0,size:1,children:"Replace"})}),P(sn,{accept:"video/*",icon:nt,mode:"bleed",onSelect:a,text:"Upload",disabled:n,fontSize:2}),P(ze,{icon:rt,text:"Browse",onClick:()=>i("select-video")}),P(Ze,{}),P(ze,{icon:it,text:"Configure API",onClick:()=>i("secrets")}),P(Ze,{}),P(ze,{tone:"critical",icon:ot,text:"Clear field",onClick:p,disabled:n})]}),portal:!0,open:s,children:P(_e,{icon:Je,mode:"ghost",onClick:()=>{i(!1),l(!0)}})})]})}));const un=lt(Pe)((e=>{const t={width:e.$border?1:0,color:"var(--card-border-color)"};return dt(g||(g=S(["\n --card-focus-box-shadow: ",";\n\n border-radius: ",";\n outline: none;\n box-shadow: var(--card-focus-box-shadow);\n\n &:focus {\n --card-focus-box-shadow: ",";\n }\n "])),rn(t),Ne(e.theme.sanity.radius[1]),on({base:e.theme.sanity.color.base,border:t,focusRing:e.theme.sanity.focusRing}))}));const pn=F(((e,t)=>{let{children:n,tone:r,onPaste:i,onDrop:o,onDragEnter:a,onDragLeave:s,onDragOver:l}=e;const d=j(!1),c=j(null),u=K((e=>{17!=e.keyCode&&91!=e.keyCode||(d.current=!0);d.current&&86==e.keyCode&&c.current.focus()}),[]),p=K((e=>{17!=e.keyCode&&91!=e.keyCode||(d.current=!1)}),[]);return O(un,{tone:r,height:"fill",ref:t,padding:0,radius:2,shadow:0,tabIndex:0,onKeyDown:u,onKeyUp:p,onPaste:i,onDrop:o,onDragEnter:a,onDragLeave:s,onDragOver:l,children:[P(hn,{ref:c,onPaste:i}),n]})})),hn=lt.input.attrs({type:"text"})(f||(f=S(["\n position: absolute;\n border: 0;\n color: white;\n opacity: 0;\n\n &:focus {\n outline: none;\n }\n"]))),gn=lt.input(m||(m=S(["\n overflow: hidden;\n width: 0.1px;\n height: 0.1px;\n opacity: 0;\n position: absolute;\n z-index: -1;\n"]))),fn=lt.label(y||(y=S(["\n position: relative;\n"]))),mn=e=>{let{onSelect:n}=e,r=x(e,t);const i="FileSelect".concat(z()),o=j(null),a=K((e=>{n&&n(e.target.files)}),[n]),s=K((()=>{var e;return null==(e=o.current)?void 0:e.click()}),[]);return O(fn,{htmlFor:i,children:[P(gn,{accept:"video/*",ref:o,tabIndex:0,type:"file",id:i,onChange:a,value:""}),P(_e,C({onClick:s,mode:"default",tone:"primary",style:{width:"100%"}},r))]})},yn=lt(Pe)(v||(v=S(["\n && {\n border-style: dashed;\n }\n"]))),vn=lt(De)(b||(b=S(["\n position: absolute;\n top: 0;\n right: 0;\n"])));function bn(e){const{setDialogState:t,readOnly:n,onSelect:r,hovering:i,needsSetup:o}=e,a=K((()=>t("select-video")),[t]),s=K((()=>t("secrets")),[t]);return P(De,{style:{padding:1,position:"relative"},height:"stretch",children:O(yn,{sizing:"border",height:"fill",tone:n?"transparent":"inherit",border:!0,padding:3,style:i?{borderColor:"transparent"}:void 0,children:[P(vn,{padding:3,children:P(_e,{padding:3,radius:3,tone:o?"critical":void 0,onClick:s,icon:it,mode:"bleed"})}),O(Ee,{align:"center",justify:"space-between",gap:4,direction:["column","column","row"],paddingY:[2,2,0],sizing:"border",height:"fill",children:[O(Ee,{align:"center",justify:"center",gap:2,flex:1,children:[P(Ee,{justify:"center",children:P(Te,{muted:!0,children:P(at,{})})}),P(Ee,{justify:"center",children:P(Te,{size:1,muted:!0,children:"Drag video or paste URL here"})})]}),O(Ve,{space:2,children:[P(mn,{mode:"ghost",tone:"default",icon:nt,text:"Upload",onSelect:r}),P(_e,{mode:"ghost",icon:rt,text:"Select",onClick:a})]})]})]})})}class wn extends G{constructor(){super(...arguments),this.state={isDraggingOver:!1,invalidPaste:!1,invalidFile:!1,uploadProgress:null,fileInfo:null,uuid:null,error:null,url:null},this.dragEnteredEls=[],this.ctrlDown=!1,this.upload=null,this.container=E.createRef(),this.handleProgress=e=>{this.setState({uploadProgress:e.percent})},this.onUpload=e=>{this.setState({uploadProgress:0,fileInfo:null,uuid:null}),this.upload=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return jt(n).pipe(be((i=>ge(fe({type:"file",file:i}),It(t).pipe(be((i=>{if(!i||!i.status)return me(new Error("Invalid credentials"));const o=Ue(),{enableSignedUrls:a}=r,s={mp4_support:e.mp4_support,playback_policy:[a?"signed":"public"]};return ge(fe({type:"uuid",uuid:o}),he((()=>t.observable.request({url:"/addons/mux/uploads/".concat(t.clientConfig.dataset),withCredentials:!0,method:"POST",headers:{"MUX-Proxy-UUID":o,"Content-Type":"application/json"},body:s}))).pipe(we((e=>Pt(o,e.upload.url,n).pipe(we((e=>"success"!==e.type?fe(e):ye(_t(t,o)).pipe(we((t=>fe(C(C({},e),{},{asset:t}))))))),xe((e=>Tt(t,o).pipe(Se(me(e))))))))))})))))))}(this.props.config,this.props.client,e[0],{enableSignedUrls:this.props.secrets.enableSignedUrls}).pipe(ke(this.onCancelUploadButtonClick$.pipe(Ce((()=>{this.state.uuid&&this.props.client.delete(this.state.uuid)}))))).subscribe({complete:()=>{this.setState({error:null,uploadProgress:null,uuid:null})},next:e=>{this.handleUploadEvent(e)},error:e=>{this.setState({error:e,uploadProgress:null,uuid:null})}})},this.handleUploadEvent=e=>{switch(e.type){case"success":return this.handleUploadSuccess(e.asset);case"progress":return this.handleProgress(e);case"file":return this.setState({fileInfo:e.file});case"uuid":return this.setState({uuid:e.uuid});case"url":return this.setState({url:e.url,uploadProgress:100});default:return null}},this.handleUploadSuccess=e=>{this.setState({uploadProgress:100}),this.props.onChange(re.from([ie({asset:{}}),oe({_type:"reference",_weak:!0,_ref:e._id},["asset"])]))},this.handlePaste=e=>{const t=(e.clipboardData||window.clipboardData).getData("text"),n={enableSignedUrls:this.props.secrets.enableSignedUrls};this.upload=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Mt(n).pipe(be((n=>ge(fe({type:"url",url:n}),It(t).pipe(be((i=>{if(!i||!i.status)return me(new Error("Invalid credentials"));const o=Ue(),{enableSignedUrls:a}=r,s={input:n,playback_policy:[a?"signed":"public"],mp4_support:e.mp4_support},l={muxBody:JSON.stringify(s),filename:n.split("/").slice(-1)[0]},d=t.clientConfig.dataset;return he((()=>t.observable.request({url:"/addons/mux/assets/".concat(d),withCredentials:!0,method:"POST",headers:{"MUX-Proxy-UUID":o,"Content-Type":"application/json"},query:l}))).pipe(we((e=>{const t=e&&e.results&&e.results[0]&&e.results[0].document||null;return t?fe({type:"success",id:o,asset:t}):me(new Error("No asset document returned"))})))})))))))}(this.props.config,this.props.client,t,n).subscribe({complete:()=>{this.setState({error:null,uploadProgress:null,url:null})},next:e=>{this.handleUploadEvent(e)},error:e=>{let t;e.message.toLowerCase().match("invalid url")||(t=e),this.setState({invalidPaste:!0,error:t},(()=>{setTimeout((()=>{this.setState({invalidPaste:!1,uploadProgress:null})}),2e3)}))}})},this.handleDrop=e=>{this.setState({isDraggingOver:!1}),e.preventDefault(),e.stopPropagation(),Kt(e.nativeEvent.dataTransfer).then((e=>{e&&this.onUpload(e)}))},this.handleDragOver=e=>{e.preventDefault(),e.stopPropagation()},this.handleDragEnter=e=>{var t,n;e.stopPropagation(),this.dragEnteredEls.push(e.target),this.setState({isDraggingOver:!0});const r=null==(n=null==(t=e.dataTransfer.items)?void 0:t[0])?void 0:n.type;this.setState({invalidFile:!r.startsWith("video/")})},this.handleDragLeave=e=>{e.stopPropagation();const t=this.dragEnteredEls.indexOf(e.target);t>-1&&this.dragEnteredEls.splice(t,1),0===this.dragEnteredEls.length&&this.setState({isDraggingOver:!1})}}componentWillUnmount(){this.unSubscribeToUpload()}componentDidMount(){const e=new ve;this.onCancelUploadButtonClick$=e.asObservable(),this.handleCancelUploadButtonClick=t=>e.next(t)}unSubscribeToUpload(){this.upload&&!this.upload.closed&&this.upload.unsubscribe()}render(){var e;if(null!==this.state.uploadProgress)return P(tn,{onCancel:this.handleCancelUploadButtonClick,progress:this.state.uploadProgress,filename:(null==(e=this.state.fileInfo)?void 0:e.name)||this.state.url});if(this.state.error)throw this.state.error;return O(D,{children:[P(pn,{tone:this.state.isDraggingOver&&(this.state.invalidPaste||this.state.invalidFile)?"critical":this.state.isDraggingOver?"positive":void 0,onDrop:this.handleDrop,onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave,onDragEnter:this.handleDragEnter,onPaste:this.handlePaste,ref:this.container,children:this.props.asset?P(nn,{readOnly:this.props.readOnly,asset:this.props.asset,onChange:this.props.onChange,dialogState:this.props.dialogState,setDialogState:this.props.setDialogState,buttons:P(cn,{asset:this.props.asset,dialogState:this.props.dialogState,setDialogState:this.props.setDialogState,onChange:this.props.onChange,onUpload:this.onUpload,readOnly:this.props.readOnly})}):P(bn,{hovering:this.state.isDraggingOver,onSelect:this.onUpload,readOnly:this.props.readOnly,setDialogState:this.props.setDialogState,needsSetup:this.props.needsSetup})}),"select-video"===this.props.dialogState&&P(Ht,{asset:this.props.asset,onChange:this.props.onChange,setDialogState:this.props.setDialogState})]})}}const xn=(e,t)=>K((async n=>{let{token:r,secretKey:i,enableSignedUrls:o}=n,{signingKeyId:a,signingKeyPrivate:s}=t;try{await Et(e,r,i,o,a,s);const t=await function(e){const{dataset:t}=e.config();return e.request({url:"/addons/mux/secrets/".concat(t,"/test"),withCredentials:!0,method:"GET"})}(e);if(!(null==t?void 0:t.status)&&r&&i)throw new Error("Invalid secrets")}catch(e){throw console.error("Error while trying to save secrets:",e),e}if(o){const t=await async function(e,t,n){if(!t||!n)return!1;const{dataset:r}=e.config();try{const n=await e.request({url:"/addons/mux/signing-keys/".concat(r,"/").concat(t),withCredentials:!0,method:"GET"});return!(!n.data||!n.data.id)}catch(e){return console.error("Error fetching signingKeyId",t,"assuming it is not valid"),!1}}(e,a,s);if(!t)try{const{data:t}=await function(e){const{dataset:t}=e.config();return e.request({url:"/addons/mux/signing-keys/".concat(t),withCredentials:!0,method:"POST"})}(e);a=t.id,s=t.private_key,await Et(e,r,i,o,a,s)}catch(e){throw console.log("Error while creating and saving signing key:",null==e?void 0:e.message),e}}return{token:r,secretKey:i,enableSignedUrls:o,signingKeyId:a,signingKeyPrivate:s}}),[e,t]);function Sn(e){let{token:t,secretKey:n,enableSignedUrls:r}=e;return{submitting:!1,error:null,token:null!=t?t:"",secretKey:null!=n?n:"",enableSignedUrls:null!=r&&r}}function kn(e,t){switch(null==t?void 0:t.type){case"submit":return C(C({},e),{},{submitting:!0,error:null});case"error":return C(C({},e),{},{submitting:!1,error:t.payload});case"reset":return Sn(t.payload);case"change":return C(C({},e),{},{[t.payload.name]:t.payload.value});default:throw new Error("Unknown action type: ".concat(null==t?void 0:t.type))}}const Cn=["title","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"];function Un(e){let{height:t=26}=e;const n=z(),[r,i,o,a,s,l,d,c,u,p,h,g,f,m,y,v,b,w,x]=T((()=>Cn.map((e=>"".concat(n,"-").concat(e)))),[n]);return O("svg",{"aria-labelledby":r,role:"img",xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",viewBox:"92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",style:{height:"".concat(t,"px")},children:[P("title",{id:r,children:"Mux Logo"}),O("defs",{children:[O("linearGradient",{id:a,spreadMethod:"pad",gradientTransform:"matrix(528.38055 0 0 -528.38055 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:s,spreadMethod:"pad",gradientTransform:"matrix(523.66766 0 0 -523.66766 67.897 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:c,spreadMethod:"pad",gradientTransform:"rotate(180 296.075 79.75) scale(524.84045)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:p,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:h,spreadMethod:"pad",gradientTransform:"matrix(523.08514 0 0 -523.08514 67.897 224.446)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:g,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 94.553)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:f,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:m,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 94.554)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:b,spreadMethod:"pad",gradientTransform:"matrix(521.97632 0 0 -521.97632 69.067 191.973)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:w,spreadMethod:"pad",gradientTransform:"matrix(523.09039 0 0 -523.09039 67.312 191.973)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),O("linearGradient",{id:x,spreadMethod:"pad",gradientTransform:"matrix(524.84045 0 0 -524.84045 63.801 159.5)",gradientUnits:"userSpaceOnUse",y2:0,x2:1,y1:0,x1:0,children:[P("stop",{offset:0,style:{stopOpacity:1,stopColor:"#ff4e00"}}),P("stop",{offset:1,style:{stopOpacity:1,stopColor:"#ff1791"}})]}),P("clipPath",{id:i,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:o,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M423.64 242h164.999V77H423.64Z"})}),P("clipPath",{id:l,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:d,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M311.3 242h93.031V77H311.3Z"})}),P("clipPath",{id:u,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M198.96 242h35.106V77H198.96Z"})}),P("clipPath",{id:y,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M0 319h657.706V0H0Z"})}),P("clipPath",{id:v,clipPathUnits:"userSpaceOnUse",children:P("path",{d:"M69.067 242H169.12V141.947H69.067Z"})})]}),P("g",{clipPath:"url(#".concat(i,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(o,")"),children:P("path",{style:{fill:"url(#".concat(a,")"),stroke:"none"},d:"M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"})})}),P("path",{style:{fill:"url(#".concat(s,")"),stroke:"none"},d:"M558.674 236.858 428.781 106.966c-6.855-6.855-6.855-17.969 0-24.825 6.855-6.854 17.969-6.854 24.823 0l129.894 129.894c6.854 6.855 6.854 17.968 0 24.823A17.498 17.498 0 0 1 571.086 242a17.495 17.495 0 0 1-12.412-5.142",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),O("g",{clipPath:"url(#".concat(l,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:[P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(d,")"),children:P("path",{style:{fill:"url(#".concat(c,")"),stroke:"none"},d:"M328.853 112.107c22.297 0 40.372 18.075 40.372 40.372v71.315c0 10.054 7.505 18.206 17.554 18.206 10.048 0 17.552-8.152 17.552-18.206v-71.315c0-41.686-33.793-75.479-75.478-75.479-9.694 0-17.553 7.859-17.553 17.554 0 9.694 7.859 17.553 17.553 17.553"})}),P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(u,")"),children:P("path",{style:{fill:"url(#".concat(p,")"),stroke:"none"},d:"M216.513 242c-10.049 0-17.553-8.152-17.553-18.206V95.206c0-10.054 7.504-18.206 17.553-18.206 10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.054-7.505 18.206-17.553 18.206"})})]}),P("path",{style:{fill:"url(#".concat(h,")"),stroke:"none"},d:"M369.225 224.447c0-9.694 7.859-17.553 17.553-17.553 9.695 0 17.553 7.859 17.553 17.553s-7.858 17.552-17.553 17.552c-9.694 0-17.553-7.858-17.553-17.552",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(g,")"),stroke:"none"},d:"M553.532 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.552-17.554 17.552-9.694 0-17.553-7.858-17.553-17.552",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(f,")"),stroke:"none"},d:"M69.067 223.794V95.206C69.067 85.152 76.571 77 86.62 77c10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.055-7.505 18.205-17.553 18.205-10.049 0-17.553-8.15-17.553-18.205",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(m,")"),stroke:"none"},d:"M198.96 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.553-17.554 17.553-9.694 0-17.553-7.859-17.553-17.553",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("g",{clipPath:"url(#".concat(y,")"),transform:"matrix(1.33333 0 0 -1.33333 0 425.333)",children:P("g",{style:{opacity:.69999701},clipPath:"url(#".concat(v,")"),children:P("path",{style:{fill:"url(#".concat(b,")"),stroke:"none"},d:"M139.155 147.088c6.855-6.855 17.969-6.855 24.824 0s6.855 17.969 0 24.824l-64.947 64.946c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"})})}),P("path",{style:{fill:"url(#".concat(w,")"),stroke:"none"},d:"m204.101 236.858-64.947-64.946c-6.854-6.855-6.854-17.969 0-24.824 6.856-6.855 17.97-6.855 24.824 0l64.947 64.947c6.855 6.855 6.855 17.968 0 24.823A17.495 17.495 0 0 1 216.513 242a17.498 17.498 0 0 1-12.412-5.142",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"}),P("path",{style:{fill:"url(#".concat(x,")"),stroke:"none"},d:"M253.374 223.794v-71.315c0-41.685 33.793-75.479 75.479-75.479 9.695 0 17.553 7.859 17.553 17.554 0 9.694-7.858 17.553-17.553 17.553-22.297 0-40.372 18.075-40.372 40.372v71.315c0 10.055-7.505 18.205-17.554 18.205s-17.553-8.15-17.553-18.205",transform:"matrix(1.33333 0 0 -1.33333 0 425.333)"})]})}const On=lt.span(w||(w=S(["\n display: inline-block;\n height: 0.8em;\n margin-right: 1em;\n transform: translate(0.3em, -0.2em);\n"]))),Pn=()=>O(D,{children:[P(On,{children:P(Un,{height:13})}),"API Credentials"]});var Dn=_((function(e){const{children:t,title:n,description:r,inputId:i}=e;return O(Fe,{space:1,children:[P(Ee,{align:"flex-end",children:P(De,{flex:1,paddingY:2,children:P(Fe,{space:2,children:O(Ee,{children:[P(Te,{as:"label",htmlFor:i,weight:"semibold",size:1,children:n||P("em",{children:"Untitled"})}),r&&P(Te,{muted:!0,size:1,children:r})]})})})}),P("div",{children:t})]})}));const En=["token","secretKey","enableSignedUrls"];var In=_((function(e){let{secrets:t,setDialogState:n}=e;var r,i;const o=V(),[a,s]=(e=>q(kn,e,Sn))(t),l=T((()=>t.token&&t.secretKey),[t]),d=K((()=>n(!1)),[n]),c=T((()=>t.token!==a.token||t.secretKey!==a.secretKey||t.enableSignedUrls!==a.enableSignedUrls),[t,a]),u="ConfigureApi".concat(z()),[p,h,g]=T((()=>En.map((e=>"".concat(u,"-").concat(e)))),[u]),f=j(null),m=xn(o,t),y=j(!1),v=K((e=>{if(e.preventDefault(),!y.current&&e.currentTarget.reportValidity()){y.current=!0,s({type:"submit"});const{token:e,secretKey:t,enableSignedUrls:r}=a;m({token:e,secretKey:t,enableSignedUrls:r}).then((e=>{const{projectId:t,dataset:r}=o.config();Ct([ce,J,t,r]),Ut((()=>Promise.resolve(e)),[ce,J,t,r]),n(!1)})).catch((e=>s({type:"error",payload:e.message}))).finally((()=>{y.current=!1}))}}),[o,s,m,n,a]),b=K((e=>{s({type:"change",payload:{name:"token",value:e.currentTarget.value}})}),[s]),w=K((e=>{s({type:"change",payload:{name:"secretKey",value:e.currentTarget.value}})}),[s]),x=K((e=>{s({type:"change",payload:{name:"enableSignedUrls",value:e.currentTarget.checked}})}),[s]);return L((()=>{f.current&&f.current.focus()}),[f]),P(Re,{id:u,onClose:d,header:P(Pn,{}),width:0,children:P(De,{padding:4,style:{position:"relative"},children:P("form",{onSubmit:v,noValidate:!0,children:O(Fe,{space:4,children:[!l&&P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"primary",children:O(Fe,{space:3,children:[O(Te,{size:1,children:["To set up a new access token, go to your"," ",P("a",{href:"https://dashboard.mux.com/settings/access-tokens",target:"_blank",rel:"noreferrer noopener",children:"account on mux.com"}),"."]}),O(Te,{size:1,children:["The access token needs permissions: ",P("strong",{children:"Mux Video "}),"(Full Access) and ",P("strong",{children:"Mux Data"})," (Read)",P("br",{}),"The credentials will be stored safely in a hidden document only available to editors."]})]})}),P(Dn,{title:"Access Token",inputId:p,children:P(We,{id:p,ref:f,onChange:b,type:"text",value:null!=(r=a.token)?r:"",required:!!a.secretKey||a.enableSignedUrls})}),P(Dn,{title:"Secret Key",inputId:h,children:P(We,{id:h,onChange:w,type:"text",value:null!=(i=a.secretKey)?i:"",required:!!a.token||a.enableSignedUrls})}),O(Fe,{space:4,children:[O(Ee,{align:"center",children:[P(Ge,{id:g,onChange:x,checked:a.enableSignedUrls,style:{display:"block"}}),P(De,{flex:1,paddingLeft:3,children:P(Te,{children:P("label",{htmlFor:g,children:"Enable Signed Urls"})})})]}),t.signingKeyId&&a.enableSignedUrls?P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"caution",children:O(Fe,{space:3,children:[P(Te,{size:1,children:"The signing key ID that Sanity will use is:"}),P(qe,{size:1,children:t.signingKeyId}),O(Te,{size:1,children:["This key is only used for previewing content in the Sanity UI.",P("br",{}),"You should generate a different key to use in your application server."]})]})}):null]}),O(Ve,{space:2,children:[P(_e,{text:"Save",disabled:!c,loading:a.submitting,tone:"primary",mode:"default",type:"submit"}),P(_e,{disabled:a.submitting,text:"Cancel",mode:"bleed",onClick:d})]}),a.error&&P(Pe,{padding:[3,3,3],radius:2,shadow:1,tone:"critical",children:P(Te,{children:a.error})})]})})})})}));function Tn(e){const{setDialogState:t}=e,n=K((()=>t("secrets")),[t]);return P(D,{children:P("div",{style:{padding:2},children:P(Pe,{display:"flex",sizing:"border",style:{aspectRatio:"16/9",width:"100%",boxShadow:"var(--card-bg-color) 0 0 0 2px"},paddingX:[2,3,4,4],radius:1,tone:"transparent",children:P(Ee,{justify:"flex-start",align:"center",children:O(Ae,{columns:1,gap:[2,3,4,4],children:[P(Ve,{paddingY:1,children:P("div",{style:{height:"32px"},children:P(Un,{})})}),P(Ve,{paddingY:1,children:P(Xe,{size:[0,1,2,2],children:"Upload and preview videos directly from your studio."})}),P(Ve,{paddingY:1,children:P(_e,{mode:"ghost",icon:it,text:"Configure API",onClick:n})})]})})})})})}var _n=_((e=>{var t;const n=V(),r=(()=>{const{error:e,isLoading:t,value:n}=ne(de,Ot);return{error:e,isLoading:t,value:T((()=>{const e=Boolean(n),t={token:(null==n?void 0:n.token)||null,secretKey:(null==n?void 0:n.secretKey)||null,enableSignedUrls:(null==n?void 0:n.enableSignedUrls)||!1,signingKeyId:(null==n?void 0:n.signingKeyId)||null,signingKeyPrivate:(null==n?void 0:n.signingKeyPrivate)||null};return{isInitialSetup:!e,needsSetup:!(null==t?void 0:t.token)||!(null==t?void 0:t.secretKey),secrets:t}}),[n])}})(),i=Q(null==(t=e.value)?void 0:t.asset),o=(e=>{var t,n;const r=V(),i=ee(),o=te(),a=T((()=>{var t,n;return!!(null==e?void 0:e.assetId)&&("preparing"===(null==e?void 0:e.status)||"preparing"===(null==(n=null==(t=null==e?void 0:e.data)?void 0:t.static_renditions)?void 0:n.status))}),[null==e?void 0:e.assetId,null==(n=null==(t=null==e?void 0:e.data)?void 0:t.static_renditions)?void 0:n.status,null==e?void 0:e.status]);return le(a?"/".concat(i,"/addons/mux/assets/").concat(o,"/data/").concat(null==e?void 0:e.assetId):null,(async()=>{const{data:t}=await r.request({url:"/addons/mux/assets/".concat(o,"/data/").concat(e.assetId),withCredentials:!0,method:"GET"});r.patch(e._id).set({status:t.status,data:t}).commit({returnDocuments:!1})}),{refreshInterval:2e3,refreshWhenHidden:!0,dedupingInterval:1e3})})(e.readOnly?void 0:(null==i?void 0:i.value)||void 0),[a,s]=I(!1),l=r.error||i.error||o.error;if(l)throw l;const d=r.isLoading||i.isLoading;return P(D,{children:d?P(ue,{}):O(D,{children:[r.value.needsSetup&&!i.value?P(Tn,{setDialogState:s}):P(wn,C(C({},e),{},{config:e.config,onChange:e.onChange,client:n,secrets:r.value.secrets,asset:i.value,dialogState:a,setDialogState:s,needsSetup:r.value.needsSetup})),"secrets"===a&&P(In,{setDialogState:s,secrets:r.value.secrets})]})})}));export{_n as default};
2
+ //# sourceMappingURL=Input-af5a0a66.esm.js.map