import{eK as I,jj as _,jk as z,iu as S,jl as x,jm as $,jn as F,jo as K,jp as k,jq as U,jr as A,i4 as B,eI as E,al as J,js as T}from"./index.6c049565.js";import{i as V}from"./multiOriginJSONSupportUtils.38b69b9c.js";function g(e){return y[q(e)]||G}function q(e){return e instanceof Blob?e.type:D(e.url)}function D(e){const t=I(e);return d[t]||w}const y={},w="text/plain",G=y[w],d={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpg",bmp:"image/bmp",gif:"image/gif",json:"application/json",txt:"text/plain",xml:"application/xml",svg:"image/svg+xml",zip:"application/zip",pbf:"application/vnd.mapbox-vector-tile",gz:"application/gzip","bin.gz":"application/octet-stream"};for(const e in d)y[d[e]]=e;function ee(e){var o;const t=(o=e==null?void 0:e.origins)!=null?o:[void 0];return(s,n)=>{const i=L(e,s,n);for(const a of t){const r=_(s,a,n);for(const c in i)r[c]=i[c]}}}function L(e,t,o){var s;if((e==null?void 0:e.type)==="resource")return C(e,t,o);switch((s=e==null?void 0:e.type)!=null?s:"other"){case"other":return{read:!0,write:!0};case"url":{const{read:n,write:i}=T;return{read:n,write:i}}}}function C(e,t,o){const s=z(t,o);return{type:String,read:(n,i,a)=>{const r=S(n,i,a);return s.type===String?r:typeof s.type=="function"?new s.type({url:r}):void 0},write:{writer(n,i,a,r){if(!r||!r.resources)return typeof n=="string"?void(i[a]=x(n,r)):void(i[a]=n.write({},r));const c=W(n),p=x(c,{...r,verifyItemRelativeUrls:r&&r.verifyItemRelativeUrls?{writtenUrls:r.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},$.NO),l=s.type!==String&&(!V(this)||r&&r.origin&&this.originIdOf(o)>F(r.origin)),u={object:this,propertyName:o,value:n,targetUrl:p,dest:i,targetPropertyName:a,context:r,params:e};r&&r.portalItem&&p&&!K(p)?l?H(u):M(u):r&&r.portalItem&&(p==null||k(p)!=null||U(p)||l)?b(u):i[a]=p}}}}function b(e){var v,h,j;const{targetUrl:t,params:o,value:s,context:n,dest:i,targetPropertyName:a}=e;if(!n.portalItem)return;const r=A(t),c=(v=r==null?void 0:r.filename)!=null?v:B(),p=(h=o==null?void 0:o.prefix)!=null?h:r==null?void 0:r.prefix,l=N(s,t,n),u=E(p,c),m=`${u}.${g(l)}`,f=n.portalItem.resourceFromPath(m);U(t)&&n.resources&&n.resources.pendingOperations.push(Q(t).then(R=>{f.path=`${u}.${g(R)}`,i[a]=f.itemRelativeUrl}).catch(()=>{}));const O=(j=o==null?void 0:o.compress)!=null?j:!1;n.resources&&P({...e,resource:f,content:l,compress:O,updates:n.resources.toAdd}),i[a]=f.itemRelativeUrl}function H(e){var m;const{context:t,targetUrl:o,params:s,value:n,dest:i,targetPropertyName:a}=e;if(!t.portalItem)return;const r=t.portalItem.resourceFromPath(o),c=N(n,o,t),p=g(c),l=I(r.path),u=(m=s==null?void 0:s.compress)!=null?m:!1;p===l?(t.resources&&P({...e,resource:r,content:c,compress:u,updates:t.resources.toUpdate}),i[a]=o):b(e)}function M({context:e,targetUrl:t,dest:o,targetPropertyName:s}){e.portalItem&&e.resources&&(e.resources.toKeep.push({resource:e.portalItem.resourceFromPath(t),compress:!1}),o[s]=t)}function P({object:e,propertyName:t,updates:o,resource:s,content:n,compress:i}){o.push({resource:s,content:n,compress:i,finish:a=>{X(e,t,a)}})}function N(e,t,o){return typeof e=="string"?{url:t}:new Blob([JSON.stringify(e.toJSON(o))],{type:"application/json"})}async function Q(e){const t=(await J(()=>import("./index.6c049565.js").then(function(s){return s.l1}),["assets/index.6c049565.js","assets/index.cf071e35.css"])).default,{data:o}=await t(e,{responseType:"blob"});return o}function W(e){return e==null?null:typeof e=="string"?e:e.url}function X(e,t,o){typeof e[t]=="string"?e[t]=o.url:e[t].url=o.url}export{ee as g};