Files
ADHA_mobile_project/assets/persistable-bf2854d4.js
T
2024-02-28 17:06:42 +05:00

2 lines
3.4 KiB
JavaScript

import{dA as N,dB as x,dC as P,dD as v,dE as A,dF as b,dG as S,dH as R,dI as U,dJ as O,s as F,dK as J,aA as K,aF as C,dL as y,dM as G,aG as H,dN as z}from"./index-b5c8f851.js";import{i as B}from"./multiOriginJSONSupportUtils-c978f4c3.js";function q(e){const o=(e==null?void 0:e.origins)??[void 0];return(r,n)=>{const s=D(e,r,n);for(const a of o){const i=N(r,a,n);for(const t in s)i[t]=s[t]}}}function D(e,o,r){if((e==null?void 0:e.type)==="resource")return E(e,o,r);switch((e==null?void 0:e.type)??"other"){case"other":return{read:!0,write:!0};case"url":{const{read:n,write:s}=z;return{read:n,write:s}}}}function E(e,o,r){const n=x(o,r);return{type:String,read:(s,a,i)=>{const t=P(s,a,i);return n.type===String?t:typeof n.type=="function"?new n.type({url:t}):void 0},write:{writer(s,a,i,t){if(!(t!=null&&t.resources))return typeof s=="string"?void(a[i]=v(s,t)):void(a[i]=s.write({},t));const c=V(s),d=v(c,{...t,verifyItemRelativeUrls:t!=null&&t.verifyItemRelativeUrls?{writtenUrls:t.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},A.NO),l=n.type!==String&&(!B(this)||(t==null?void 0:t.origin)&&this.originIdOf(r)>b(t.origin)),p={object:this,propertyName:r,value:s,targetUrl:d,dest:a,targetPropertyName:i,context:t,params:e};t!=null&&t.portalItem&&d&&!S(d)?l&&(e!=null&&e.contentAddressed)?g(p):l?L(p):M(p):t!=null&&t.portalItem&&(d==null||R(d)!=null||U(d)||l)?g(p):a[i]=d}}}}function g(e){var h;const{targetUrl:o,params:r,value:n,context:s,dest:a,targetPropertyName:i}=e;if(!s.portalItem)return;const t=O(o),c=I(n,o,s);if(r!=null&&r.contentAddressed&&c.type!=="json")return void((h=s.messages)==null?void 0:h.push(new F("persistable:contentAddressingUnsupported",`Property "${i}" is trying to serializing a resource with content of type ${c.type} with content addressing. Content addressing is only supported for json resources.`,{content:c})));const d=r!=null&&r.contentAddressed&&c.type==="json"?J(c.jsonString):(t==null?void 0:t.filename)??K(),l=C((r==null?void 0:r.prefix)??(t==null?void 0:t.prefix),d),p=`${l}.${y(c)}`;if(r!=null&&r.contentAddressed&&s.resources&&c.type==="json"){const m=s.resources.toKeep.find(f=>f.resource.path===p)??s.resources.toAdd.find(f=>f.resource.path===p);if(m)return void(a[i]=m.resource.itemRelativeUrl)}const u=s.portalItem.resourceFromPath(p);U(o)&&s.resources&&s.resources.pendingOperations.push(G(o).then(m=>{u.path=`${l}.${y({type:"blob",blob:m})}`,a[i]=u.itemRelativeUrl}).catch(()=>{}));const j=(r==null?void 0:r.compress)??!1;s.resources&&w({...e,resource:u,content:c,compress:j,updates:s.resources.toAdd}),a[i]=u.itemRelativeUrl}function L(e){const{context:o,targetUrl:r,params:n,value:s,dest:a,targetPropertyName:i}=e;if(!o.portalItem)return;const t=o.portalItem.resourceFromPath(r),c=I(s,r,o),d=y(c),l=H(t.path),p=(n==null?void 0:n.compress)??!1;d===l?(o.resources&&w({...e,resource:t,content:c,compress:p,updates:o.resources.toUpdate}),a[i]=r):g(e)}function M({context:e,targetUrl:o,dest:r,targetPropertyName:n}){e.portalItem&&e.resources&&(e.resources.toKeep.push({resource:e.portalItem.resourceFromPath(o),compress:!1}),r[n]=o)}function w({object:e,propertyName:o,updates:r,resource:n,content:s,compress:a}){r.push({resource:n,content:s,compress:a,finish:i=>{Y(e,o,i)}})}function I(e,o,r){return typeof e=="string"?{type:"url",url:o}:{type:"json",jsonString:JSON.stringify(e.toJSON(r))}}function V(e){return e==null?null:typeof e=="string"?e:e.url}function Y(e,o,r){typeof e[o]=="string"?e[o]=r.url:e[o].url=r.url}export{q as j};