@coasys/ad4m-connect 0.13.0-test-3 → 0.13.0-test-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +3 -7
- package/dist/core.js +127 -1759
- package/dist/index.js +299 -1931
- package/dist/services/hostIndex.d.ts +2 -2
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +1 -1
- package/dist/web.js +264 -1884
- package/package.json +21 -19
package/dist/core.js
CHANGED
|
@@ -1,1779 +1,147 @@
|
|
|
1
|
-
var fe=(r,e,t)=>new Promise((n,i)=>{var a=c=>{try{s(t.next(c))}catch(u){i(u)}},o=c=>{try{s(t.throw(c))}catch(u){i(u)}},s=c=>c.done?n(c.value):Promise.resolve(c.value).then(a,o);s((t=t.apply(r,e)).next())});var cc=function(r,e){return cc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},cc(r,e)};function Ae(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");cc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var T=function(){return T=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},T.apply(this,arguments)};function zt(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function $t(r,e,t,n){function i(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(l){try{u(n.next(l))}catch(d){o(d)}}function c(l){try{u(n.throw(l))}catch(d){o(d)}}function u(l){l.done?a(l.value):i(l.value).then(s,c)}u((n=n.apply(r,e||[])).next())})}function Ft(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(l){return c([u,l])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(t=0)),t;)try{if(n=1,i&&(a=u[0]&2?i.return:u[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,u[1])).done)return a;switch(i=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){t.label=u[1];break}if(u[0]===6&&t.label<a[1]){t.label=a[1],a=u;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(u);break}a[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(l){u=[6,l],i=0}finally{n=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Ir(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return r.concat(a||Array.prototype.slice.call(e))}var uc="Invariant Violation",Dl=Object.setPrototypeOf,dm=Dl===void 0?function(r,e){return r.__proto__=e,r}:Dl,X=function(r){Ae(e,r);function e(t){t===void 0&&(t=uc);var n=r.call(this,typeof t=="number"?uc+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return n.framesToPop=1,n.name=uc,dm(n,e.prototype),n}return e}(Error);function $(r,e){if(!r)throw new X(e)}var yo=["debug","log","warn","error","silent"],lc=yo.indexOf("log");function go(r){return function(){if(yo.indexOf(r)>=lc){var e=console[r]||console.log;return e.apply(console,arguments)}}}(function(r){r.debug=go("debug"),r.log=go("log"),r.warn=go("warn"),r.error=go("error")})($||($={}));function Ll(r){var e=yo[lc];return lc=Math.max(0,yo.indexOf(r)),e}function Be(r){try{return r()}catch{}}var vo=Be(function(){return globalThis})||Be(function(){return window})||Be(function(){return self})||Be(function(){return global})||Be(function(){return Be.constructor("return this")()});var $l="__",Fl=[$l,$l].join("DEV");function hm(){try{return Boolean(__DEV__)}catch{return Object.defineProperty(vo,Fl,{value:Be(function(){return"production"})!=="production",enumerable:!1,configurable:!0,writable:!0}),vo[Fl]}}var sn=hm();function Tr(r){try{return r()}catch{}}var fc=Tr(function(){return globalThis})||Tr(function(){return window})||Tr(function(){return self})||Tr(function(){return global})||Tr(function(){return Tr.constructor("return this")()}),pc=!1;function mm(){fc&&!Tr(function(){return"production"})&&!Tr(function(){return process})&&(Object.defineProperty(fc,"process",{value:{env:{NODE_ENV:"production"}},configurable:!0,enumerable:!1,writable:!0}),pc=!0)}mm();function dc(){pc&&(delete fc.process,pc=!1)}var m_=typeof Symbol=="function"&&Symbol.iterator!=null?Symbol.iterator:"@@iterator",g_=typeof Symbol=="function"&&Symbol.asyncIterator!=null?Symbol.asyncIterator:"@@asyncIterator",Ml=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";var De=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function hc(r,e){var t=Boolean(r);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var gm=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,Hi=gm;function bo(r){var e=r.prototype.toJSON;typeof e=="function"||hc(0),r.prototype.inspect=e,Hi&&(r.prototype[Hi]=e)}var Ul=function(){function r(t,n,i){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=i}var e=r.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},r}();bo(Ul);var jl=function(){function r(t,n,i,a,o,s,c){this.kind=t,this.start=n,this.end=i,this.line=a,this.column=o,this.value=c,this.prev=s,this.next=null}var e=r.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},r}();bo(jl);function mc(r){return r!=null&&typeof r.kind=="string"}function wo(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?wo=function(t){return typeof t}:wo=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wo(r)}var ym=10,ql=2;function Wi(r){return So(r,[])}function So(r,e){switch(wo(r)){case"string":return JSON.stringify(r);case"function":return r.name?"[function ".concat(r.name,"]"):"[function]";case"object":return r===null?"null":vm(r,e);default:return String(r)}}function vm(r,e){if(e.indexOf(r)!==-1)return"[Circular]";var t=[].concat(e,[r]),n=Sm(r);if(n!==void 0){var i=n.call(r);if(i!==r)return typeof i=="string"?i:So(i,t)}else if(Array.isArray(r))return wm(r,t);return bm(r,t)}function bm(r,e){var t=Object.keys(r);if(t.length===0)return"{}";if(e.length>ql)return"["+_m(r)+"]";var n=t.map(function(i){var a=So(r[i],e);return i+": "+a});return"{ "+n.join(", ")+" }"}function wm(r,e){if(r.length===0)return"[]";if(e.length>ql)return"[Array]";for(var t=Math.min(ym,r.length),n=r.length-t,i=[],a=0;a<t;++a)i.push(So(r[a],e));return n===1?i.push("... 1 more item"):n>1&&i.push("... ".concat(n," more items")),"["+i.join(", ")+"]"}function Sm(r){var e=r[String(Hi)];if(typeof e=="function")return e;if(typeof r.inspect=="function")return r.inspect}function _m(r){var e=Object.prototype.toString.call(r).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof r.constructor=="function"){var t=r.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function Gi(r,e){var t=Boolean(r);if(!t)throw new Error(e)}function Bl(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function Em(r,e,t){return e&&Bl(r.prototype,e),t&&Bl(r,t),r}var _o=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||Gi(0,"Body must be a string. Received: ".concat(Wi(e),".")),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||Gi(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Gi(0,"column in locationOffset is 1-indexed and must be positive.")}return Em(r,[{key:Ml,get:function(){return"Source"}}]),r}();function Vl(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=r.indexOf(`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`),
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`,
|
|
20
|
-
`)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`)!==-1}function Ql(r){return r!=null&&r.some(km)}function Ki(r){return r.kind===De.FIELD||r.kind===De.FRAGMENT_SPREAD||r.kind===De.INLINE_FRAGMENT}function zl(){return typeof _o=="function"?dc():dc()}function Fm(){__DEV__?$(typeof sn=="boolean",sn):$(typeof sn=="boolean",39)}zl();Fm();function cr(r,e){var t=r.directives;return!t||!t.length?!0:Hl(t).every(function(n){var i=n.directive,a=n.ifArgument,o=!1;return a.value.kind==="Variable"?(o=e&&e[a.value.name.value],__DEV__?$(o!==void 0,"Invalid variable referenced in @".concat(i.name.value," directive.")):$(o!==void 0,40)):o=a.value.value,i.name.value==="skip"?!o:o})}function ni(r,e,t){var n=new Set(r),i=n.size;return Ye(e,{Directive:function(a){if(n.delete(a.name.value)&&(!t||!n.size))return cn}}),t?!n.size:n.size<i}function yc(r){return r&&ni(["client","export"],r,!0)}function Mm(r){var e=r.name.value;return e==="skip"||e==="include"}function Hl(r){var e=[];return r&&r.length&&r.forEach(function(t){if(!!Mm(t)){var n=t.arguments,i=t.name.value;__DEV__?$(n&&n.length===1,"Incorrect number of arguments for the @".concat(i," directive.")):$(n&&n.length===1,41);var a=n[0];__DEV__?$(a.name&&a.name.value==="if","Invalid argument for the @".concat(i," directive.")):$(a.name&&a.name.value==="if",42);var o=a.value;__DEV__?$(o&&(o.kind==="Variable"||o.kind==="BooleanValue"),"Argument for the @".concat(i," directive must be a variable or a boolean value.")):$(o&&(o.kind==="Variable"||o.kind==="BooleanValue"),43),e.push({directive:t,ifArgument:a})}}),e}function vc(r,e){var t=e,n=[];r.definitions.forEach(function(a){if(a.kind==="OperationDefinition")throw __DEV__?new X("Found a ".concat(a.operation," operation").concat(a.name?" named '".concat(a.name.value,"'"):"",". ")+"No operations are allowed when using a fragment as a query. Only fragments are allowed."):new X(44);a.kind==="FragmentDefinition"&&n.push(a)}),typeof t>"u"&&(__DEV__?$(n.length===1,"Found ".concat(n.length," fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")):$(n.length===1,45),t=n[0].name.value);var i=T(T({},r),{definitions:Ir([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:t}}]}}],r.definitions,!0)});return i}function un(r){r===void 0&&(r=[]);var e={};return r.forEach(function(t){e[t.name.value]=t}),e}function ln(r,e){switch(r.kind){case"InlineFragment":return r;case"FragmentSpread":{var t=r.name.value;if(typeof e=="function")return e(t);var n=e&&e[t];return __DEV__?$(n,"No fragment named ".concat(t)):$(n,46),n||null}default:return null}}function le(r){return r!==null&&typeof r=="object"}function Ht(r){return{__ref:String(r)}}function se(r){return Boolean(r&&typeof r=="object"&&typeof r.__ref=="string")}function bc(r){return le(r)&&r.kind==="Document"&&Array.isArray(r.definitions)}function Um(r){return r.kind==="StringValue"}function jm(r){return r.kind==="BooleanValue"}function qm(r){return r.kind==="IntValue"}function Bm(r){return r.kind==="FloatValue"}function Vm(r){return r.kind==="Variable"}function Qm(r){return r.kind==="ObjectValue"}function zm(r){return r.kind==="ListValue"}function Hm(r){return r.kind==="EnumValue"}function Wm(r){return r.kind==="NullValue"}function kr(r,e,t,n){if(qm(t)||Bm(t))r[e.value]=Number(t.value);else if(jm(t)||Um(t))r[e.value]=t.value;else if(Qm(t)){var i={};t.fields.map(function(o){return kr(i,o.name,o.value,n)}),r[e.value]=i}else if(Vm(t)){var a=(n||{})[t.name.value];r[e.value]=a}else if(zm(t))r[e.value]=t.values.map(function(o){var s={};return kr(s,e,o,n),s[e.value]});else if(Hm(t))r[e.value]=t.value;else if(Wm(t))r[e.value]=null;else throw __DEV__?new X('The inline argument "'.concat(e.value,'" of kind "').concat(t.kind,'"')+"is not supported. Use variables instead of inline arguments to overcome this limitation."):new X(55)}function wc(r,e){var t=null;r.directives&&(t={},r.directives.forEach(function(i){t[i.name.value]={},i.arguments&&i.arguments.forEach(function(a){var o=a.name,s=a.value;return kr(t[i.name.value],o,s,e)})}));var n=null;return r.arguments&&r.arguments.length&&(n={},r.arguments.forEach(function(i){var a=i.name,o=i.value;return kr(n,a,o,e)})),Zi(r.name.value,n,t)}var Gm=["connection","include","skip","client","rest","export"],Zi=Object.assign(function(r,e,t){if(e&&t&&t.connection&&t.connection.key)if(t.connection.filter&&t.connection.filter.length>0){var n=t.connection.filter?t.connection.filter:[];n.sort();var i={};return n.forEach(function(s){i[s]=e[s]}),"".concat(t.connection.key,"(").concat(Ji(i),")")}else return t.connection.key;var a=r;if(e){var o=Ji(e);a+="(".concat(o,")")}return t&&Object.keys(t).forEach(function(s){Gm.indexOf(s)===-1&&(t[s]&&Object.keys(t[s]).length?a+="@".concat(s,"(").concat(Ji(t[s]),")"):a+="@".concat(s))}),a},{setStringify:function(r){var e=Ji;return Ji=r,e}}),Ji=function(e){return JSON.stringify(e,Km)};function Km(r,e){return le(e)&&!Array.isArray(e)&&(e=Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})),e}function ur(r,e){if(r.arguments&&r.arguments.length){var t={};return r.arguments.forEach(function(n){var i=n.name,a=n.value;return kr(t,i,a,e)}),t}return null}function Tt(r){return r.alias?r.alias.value:r.name.value}function Yi(r,e,t){if(typeof r.__typename=="string")return r.__typename;for(var n=0,i=e.selections;n<i.length;n++){var a=i[n];if(vt(a)){if(a.name.value==="__typename")return r[Tt(a)]}else{var o=Yi(r,ln(a,t).selectionSet,t);if(typeof o=="string")return o}}}function vt(r){return r.kind==="Field"}function Sc(r){return r.kind==="InlineFragment"}function ii(r){__DEV__?$(r&&r.kind==="Document",'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):$(r&&r.kind==="Document",47);var e=r.definitions.filter(function(t){return t.kind!=="FragmentDefinition"}).map(function(t){if(t.kind!=="OperationDefinition")throw __DEV__?new X('Schema type definitions not allowed in queries. Found: "'.concat(t.kind,'"')):new X(48);return t});return __DEV__?$(e.length<=1,"Ambiguous GraphQL document: contains ".concat(e.length," operations")):$(e.length<=1,49),r}function Wt(r){return ii(r),r.definitions.filter(function(e){return e.kind==="OperationDefinition"})[0]}function ai(r){return r.definitions.filter(function(e){return e.kind==="OperationDefinition"&&!!e.name}).map(function(e){return e.name.value})[0]||null}function fn(r){return r.definitions.filter(function(e){return e.kind==="FragmentDefinition"})}function Xi(r){var e=Wt(r);return __DEV__?$(e&&e.operation==="query","Must contain a query definition."):$(e&&e.operation==="query",50),e}function _c(r){__DEV__?$(r.kind==="Document",'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):$(r.kind==="Document",51),__DEV__?$(r.definitions.length<=1,"Fragment must have exactly one definition."):$(r.definitions.length<=1,52);var e=r.definitions[0];return __DEV__?$(e.kind==="FragmentDefinition","Must be a fragment definition."):$(e.kind==="FragmentDefinition",53),e}function pn(r){ii(r);for(var e,t=0,n=r.definitions;t<n.length;t++){var i=n[t];if(i.kind==="OperationDefinition"){var a=i.operation;if(a==="query"||a==="mutation"||a==="subscription")return i}i.kind==="FragmentDefinition"&&!e&&(e=i)}if(e)return e;throw __DEV__?new X("Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment."):new X(54)}function dn(r){var e=Object.create(null),t=r&&r.variableDefinitions;return t&&t.length&&t.forEach(function(n){n.defaultValue&&kr(e,n.variable.name,n.defaultValue)}),e}var ve=Array.isArray;function Fe(r){return Array.isArray(r)&&r.length>0}var Wl={kind:De.FIELD,name:{kind:De.NAME,value:"__typename"}};function Kl(r,e){return!r||r.selectionSet.selections.every(function(t){return t.kind===De.FRAGMENT_SPREAD&&Kl(e[t.name.value],e)})}function Jm(r){return Kl(Wt(r)||_c(r),un(fn(r)))?null:r}function Zm(r){var e=new Set,t=[];return r.forEach(function(n){n.name?e.add(n.name):n.test&&t.push(n.test)}),function(n){return e.has(n.name.value)||t.some(function(i){return i(n)})}}function Gl(r){var e=new Map;return function(n){n===void 0&&(n=r);var i=e.get(n);return i||e.set(n,i={variables:new Set,fragmentSpreads:new Set}),i}}function Ec(r,e){for(var t=Gl(""),n=Gl(""),i=function(w){for(var y=0,b=void 0;y<w.length&&(b=w[y]);++y)if(!ve(b)){if(b.kind===De.OPERATION_DEFINITION)return t(b.name&&b.name.value);if(b.kind===De.FRAGMENT_DEFINITION)return n(b.name.value)}return __DEV__&&$.error("Could not find operation or fragment"),null},a=0,o=e.definitions.length-1;o>=0;--o)e.definitions[o].kind===De.OPERATION_DEFINITION&&++a;var s=Zm(r),c=r.some(function(w){return w.remove}),u=function(w){return c&&w&&w.some(s)},l=new Map,d=!1,p={enter:function(w){if(u(w.directives))return d=!0,null}},f=Ye(e,{Field:p,InlineFragment:p,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(w,y,b,I,A){var E=i(A);E&&E.variables.add(w.name.value)}},FragmentSpread:{enter:function(w,y,b,I,A){if(u(w.directives))return d=!0,null;var E=i(A);E&&E.fragmentSpreads.add(w.name.value)}},FragmentDefinition:{enter:function(w,y,b,I){l.set(JSON.stringify(I),w)},leave:function(w,y,b,I){var A=l.get(JSON.stringify(I));if(w===A)return w;if(a>0&&w.selectionSet.selections.every(function(E){return E.kind===De.FIELD&&E.name.value==="__typename"}))return n(w.name.value).removed=!0,d=!0,null}},Directive:{leave:function(w){if(s(w))return d=!0,null}}});if(!d)return e;var h=function(w){return w.transitiveVars||(w.transitiveVars=new Set(w.variables),w.removed||w.fragmentSpreads.forEach(function(y){h(n(y)).transitiveVars.forEach(function(b){w.transitiveVars.add(b)})})),w},m=new Set;f.definitions.forEach(function(w){w.kind===De.OPERATION_DEFINITION?h(t(w.name&&w.name.value)).fragmentSpreads.forEach(function(y){m.add(y)}):w.kind===De.FRAGMENT_DEFINITION&&a===0&&!n(w.name.value).removed&&m.add(w.name.value)}),m.forEach(function(w){h(n(w)).fragmentSpreads.forEach(function(y){m.add(y)})});var g=function(w){return!!(!m.has(w)||n(w).removed)},_={enter:function(w){if(g(w.name.value))return null}};return Jm(Ye(f,{FragmentSpread:_,FragmentDefinition:_,OperationDefinition:{leave:function(w){if(w.variableDefinitions){var y=h(t(w.name&&w.name.value)).transitiveVars;if(y.size<w.variableDefinitions.length)return T(T({},w),{variableDefinitions:w.variableDefinitions.filter(function(b){return y.has(b.variable.name.value)})})}}}}))}var hn=Object.assign(function(r){return Ye(r,{SelectionSet:{enter:function(e,t,n){if(!(n&&n.kind===De.OPERATION_DEFINITION)){var i=e.selections;if(!!i){var a=i.some(function(s){return vt(s)&&(s.name.value==="__typename"||s.name.value.lastIndexOf("__",0)===0)});if(!a){var o=n;if(!(vt(o)&&o.directives&&o.directives.some(function(s){return s.name.value==="export"})))return T(T({},e),{selections:Ir(Ir([],i,!0),[Wl],!1)})}}}}}})},{added:function(r){return r===Wl}}),Ym={test:function(r){var e=r.name.value==="connection";return e&&(!r.arguments||!r.arguments.some(function(t){return t.name.value==="key"}))&&__DEV__&&$.warn("Removing an @connection directive even though it does not have a key. You may want to use the key parameter to specify a store key."),e}};function xc(r){return Ec([Ym],ii(r))}function Ic(r){var e=pn(r),t=e.operation;if(t==="query")return r;var n=Ye(r,{OperationDefinition:{enter:function(i){return T(T({},i),{operation:"query"})}}});return n}function Tc(r){ii(r);var e=Ec([{test:function(t){return t.name.value==="client"},remove:!0}],r);return e}var Xm=Object.prototype.hasOwnProperty;function kc(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return ea(r)}function ea(r){var e=r[0]||{},t=r.length;if(t>1)for(var n=new ut,i=1;i<t;++i)e=n.merge(e,r[i]);return e}var eg=function(r,e,t){return this.merge(r[t],e[t])},ut=function(){function r(e){e===void 0&&(e=eg),this.reconciler=e,this.isObject=le,this.pastCopies=new Set}return r.prototype.merge=function(e,t){for(var n=this,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];return le(t)&&le(e)?(Object.keys(t).forEach(function(o){if(Xm.call(e,o)){var s=e[o];if(t[o]!==s){var c=n.reconciler.apply(n,Ir([e,t,o],i,!1));c!==s&&(e=n.shallowCopyForMerge(e),e[o]=c)}}else e=n.shallowCopyForMerge(e),e[o]=t[o]}),e):t},r.prototype.shallowCopyForMerge=function(e){return le(e)&&(this.pastCopies.has(e)||(Array.isArray(e)?e=e.slice(0):e=T({__proto__:Object.getPrototypeOf(e)},e),this.pastCopies.add(e))),e},r}();function tg(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=rg(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
24
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rg(r,e){if(!!r){if(typeof r=="string")return Jl(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jl(r,e)}}function Jl(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Zl(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function Rc(r,e,t){return e&&Zl(r.prototype,e),t&&Zl(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}var Pc=function(){return typeof Symbol=="function"},Nc=function(r){return Pc()&&Boolean(Symbol[r])},Dc=function(r){return Nc(r)?Symbol[r]:"@@"+r};Pc()&&!Nc("observable")&&(Symbol.observable=Symbol("observable"));var ng=Dc("iterator"),Oc=Dc("observable"),Yl=Dc("species");function Io(r,e){var t=r[e];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function ta(r){var e=r.constructor;return e!==void 0&&(e=e[Yl],e===null&&(e=void 0)),e!==void 0?e:ae}function ig(r){return r instanceof ae}function oi(r){oi.log?oi.log(r):setTimeout(function(){throw r})}function xo(r){Promise.resolve().then(function(){try{r()}catch(e){oi(e)}})}function Xl(r){var e=r._cleanup;if(e!==void 0&&(r._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{var t=Io(e,"unsubscribe");t&&t.call(e)}}catch(n){oi(n)}}function Cc(r){r._observer=void 0,r._queue=void 0,r._state="closed"}function ag(r){var e=r._queue;if(!!e){r._queue=void 0,r._state="ready";for(var t=0;t<e.length&&(ef(r,e[t].type,e[t].value),r._state!=="closed");++t);}}function ef(r,e,t){r._state="running";var n=r._observer;try{var i=Io(n,e);switch(e){case"next":i&&i.call(n,t);break;case"error":if(Cc(r),i)i.call(n,t);else throw t;break;case"complete":Cc(r),i&&i.call(n);break}}catch(a){oi(a)}r._state==="closed"?Xl(r):r._state==="running"&&(r._state="ready")}function Ac(r,e,t){if(r._state!=="closed"){if(r._state==="buffering"){r._queue.push({type:e,value:t});return}if(r._state!=="ready"){r._state="buffering",r._queue=[{type:e,value:t}],xo(function(){return ag(r)});return}ef(r,e,t)}}var og=function(){function r(t,n){this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var i=new sg(this);try{this._cleanup=n.call(void 0,i)}catch(a){i.error(a)}this._state==="initializing"&&(this._state="ready")}var e=r.prototype;return e.unsubscribe=function(){this._state!=="closed"&&(Cc(this),Xl(this))},Rc(r,[{key:"closed",get:function(){return this._state==="closed"}}]),r}(),sg=function(){function r(t){this._subscription=t}var e=r.prototype;return e.next=function(n){Ac(this._subscription,"next",n)},e.error=function(n){Ac(this._subscription,"error",n)},e.complete=function(){Ac(this._subscription,"complete")},Rc(r,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),r}(),ae=function(){function r(t){if(!(this instanceof r))throw new TypeError("Observable cannot be called as a function");if(typeof t!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=t}var e=r.prototype;return e.subscribe=function(n){return(typeof n!="object"||n===null)&&(n={next:n,error:arguments[1],complete:arguments[2]}),new og(n,this._subscriber)},e.forEach=function(n){var i=this;return new Promise(function(a,o){if(typeof n!="function"){o(new TypeError(n+" is not a function"));return}function s(){c.unsubscribe(),a()}var c=i.subscribe({next:function(u){try{n(u,s)}catch(l){o(l),c.unsubscribe()}},error:o,complete:a})})},e.map=function(n){var i=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var a=ta(this);return new a(function(o){return i.subscribe({next:function(s){try{s=n(s)}catch(c){return o.error(c)}o.next(s)},error:function(s){o.error(s)},complete:function(){o.complete()}})})},e.filter=function(n){var i=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var a=ta(this);return new a(function(o){return i.subscribe({next:function(s){try{if(!n(s))return}catch(c){return o.error(c)}o.next(s)},error:function(s){o.error(s)},complete:function(){o.complete()}})})},e.reduce=function(n){var i=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var a=ta(this),o=arguments.length>1,s=!1,c=arguments[1],u=c;return new a(function(l){return i.subscribe({next:function(d){var p=!s;if(s=!0,!p||o)try{u=n(u,d)}catch(f){return l.error(f)}else u=d},error:function(d){l.error(d)},complete:function(){if(!s&&!o)return l.error(new TypeError("Cannot reduce an empty sequence"));l.next(u),l.complete()}})})},e.concat=function(){for(var n=this,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=ta(this);return new s(function(c){var u,l=0;function d(p){u=p.subscribe({next:function(f){c.next(f)},error:function(f){c.error(f)},complete:function(){l===a.length?(u=void 0,c.complete()):d(s.from(a[l++]))}})}return d(n),function(){u&&(u.unsubscribe(),u=void 0)}})},e.flatMap=function(n){var i=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var a=ta(this);return new a(function(o){var s=[],c=i.subscribe({next:function(l){if(n)try{l=n(l)}catch(p){return o.error(p)}var d=a.from(l).subscribe({next:function(p){o.next(p)},error:function(p){o.error(p)},complete:function(){var p=s.indexOf(d);p>=0&&s.splice(p,1),u()}});s.push(d)},error:function(l){o.error(l)},complete:function(){u()}});function u(){c.closed&&s.length===0&&o.complete()}return function(){s.forEach(function(l){return l.unsubscribe()}),c.unsubscribe()}})},e[Oc]=function(){return this},r.from=function(n){var i=typeof this=="function"?this:r;if(n==null)throw new TypeError(n+" is not an object");var a=Io(n,Oc);if(a){var o=a.call(n);if(Object(o)!==o)throw new TypeError(o+" is not an object");return ig(o)&&o.constructor===i?o:new i(function(s){return o.subscribe(s)})}if(Nc("iterator")&&(a=Io(n,ng),a))return new i(function(s){xo(function(){if(!s.closed){for(var c=tg(a.call(n)),u;!(u=c()).done;){var l=u.value;if(s.next(l),s.closed)return}s.complete()}})});if(Array.isArray(n))return new i(function(s){xo(function(){if(!s.closed){for(var c=0;c<n.length;++c)if(s.next(n[c]),s.closed)return;s.complete()}})});throw new TypeError(n+" is not observable")},r.of=function(){for(var n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];var o=typeof this=="function"?this:r;return new o(function(s){xo(function(){if(!s.closed){for(var c=0;c<i.length;++c)if(s.next(i[c]),s.closed)return;s.complete()}})})},Rc(r,null,[{key:Yl,get:function(){return this}}]),r}();Pc()&&Object.defineProperty(ae,Symbol("extensions"),{value:{symbol:Oc,hostReportError:oi},configurable:!0});function Lc(r){var e,t=r.Symbol;if(typeof t=="function")if(t.observable)e=t.observable;else{typeof t.for=="function"?e=t.for("https://github.com/benlesh/symbol-observable"):e=t("https://github.com/benlesh/symbol-observable");try{t.observable=e}catch{}}else e="@@observable";return e}var si;typeof self<"u"?si=self:typeof window<"u"?si=window:typeof global<"u"?si=global:typeof module<"u"?si=module:si=Function("return this")();var V0=Lc(si);var tf=ae.prototype,rf="@@observable";tf[rf]||(tf[rf]=function(){return this});var cg=Object.prototype.toString;function To(r){return $c(r)}function $c(r,e){switch(cg.call(r)){case"[object Array]":{if(e=e||new Map,e.has(r))return e.get(r);var t=r.slice(0);return e.set(r,t),t.forEach(function(i,a){t[a]=$c(i,e)}),t}case"[object Object]":{if(e=e||new Map,e.has(r))return e.get(r);var n=Object.create(Object.getPrototypeOf(r));return e.set(r,n),Object.keys(r).forEach(function(i){n[i]=$c(r[i],e)}),n}default:return r}}function ug(r){var e=new Set([r]);return e.forEach(function(t){le(t)&&lg(t)===t&&Object.getOwnPropertyNames(t).forEach(function(n){le(t[n])&&e.add(t[n])})}),r}function lg(r){if(__DEV__&&!Object.isFrozen(r))try{Object.freeze(r)}catch(e){if(e instanceof TypeError)return null;throw e}return r}function ra(r){return __DEV__&&ug(r),r}function mn(r,e,t){var n=[];r.forEach(function(i){return i[e]&&n.push(i)}),n.forEach(function(i){return i[e](t)})}function ko(r,e,t){return new ae(function(n){var i=n.next,a=n.error,o=n.complete,s=0,c=!1,u={then:function(f){return new Promise(function(h){return h(f())})}};function l(f,h){return f?function(m){++s;var g=function(){return f(m)};u=u.then(g,g).then(function(_){--s,i&&i.call(n,_),c&&d.complete()},function(_){throw--s,_}).catch(function(_){a&&a.call(n,_)})}:function(m){return h&&h.call(n,m)}}var d={next:l(e,i),error:l(t,a),complete:function(){c=!0,s||o&&o.call(n)}},p=r.subscribe(d);return function(){return p.unsubscribe()}})}var kt=typeof WeakMap=="function"&&Be(function(){return navigator.product})!=="ReactNative",nf=typeof WeakSet=="function",Fc=typeof Symbol=="function"&&typeof Symbol.for=="function",Ar=Fc&&Symbol.asyncIterator,r1=typeof Be(function(){return window.document.createElement})=="function",n1=Be(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1;function Ao(r){function e(t){Object.defineProperty(r,t,{value:ae})}return Fc&&Symbol.species&&e(Symbol.species),e("@@species"),r}function af(r){return r&&typeof r.then=="function"}var ci=function(r){Ae(e,r);function e(t){var n=r.call(this,function(i){return n.addObserver(i),function(){return n.removeObserver(i)}})||this;return n.observers=new Set,n.promise=new Promise(function(i,a){n.resolve=i,n.reject=a}),n.handlers={next:function(i){n.sub!==null&&(n.latest=["next",i],n.notify("next",i),mn(n.observers,"next",i))},error:function(i){var a=n.sub;a!==null&&(a&&setTimeout(function(){return a.unsubscribe()}),n.sub=null,n.latest=["error",i],n.reject(i),n.notify("error",i),mn(n.observers,"error",i))},complete:function(){var i=n,a=i.sub,o=i.sources,s=o===void 0?[]:o;if(a!==null){var c=s.shift();c?af(c)?c.then(function(u){return n.sub=u.subscribe(n.handlers)}):n.sub=c.subscribe(n.handlers):(a&&setTimeout(function(){return a.unsubscribe()}),n.sub=null,n.latest&&n.latest[0]==="next"?n.resolve(n.latest[1]):n.resolve(),n.notify("complete"),mn(n.observers,"complete"))}}},n.nextResultListeners=new Set,n.cancel=function(i){n.reject(i),n.sources=[],n.handlers.complete()},n.promise.catch(function(i){}),typeof t=="function"&&(t=[new ae(t)]),af(t)?t.then(function(i){return n.start(i)},n.handlers.error):n.start(t),n}return e.prototype.start=function(t){this.sub===void 0&&(this.sources=Array.from(t),this.handlers.complete())},e.prototype.deliverLastMessage=function(t){if(this.latest){var n=this.latest[0],i=t[n];i&&i.call(t,this.latest[1]),this.sub===null&&n==="next"&&t.complete&&t.complete()}},e.prototype.addObserver=function(t){this.observers.has(t)||(this.deliverLastMessage(t),this.observers.add(t))},e.prototype.removeObserver=function(t){this.observers.delete(t)&&this.observers.size<1&&this.handlers.complete()},e.prototype.notify=function(t,n){var i=this.nextResultListeners;i.size&&(this.nextResultListeners=new Set,i.forEach(function(a){return a(t,n)}))},e.prototype.beforeNext=function(t){var n=!1;this.nextResultListeners.add(function(i,a){n||(n=!0,t(i,a))})},e}(ae);Ao(ci);function Or(r){return"incremental"in r}function fg(r){return"hasNext"in r&&"data"in r}function of(r){return Or(r)||fg(r)}function Oo(r,e){var t=r,n=new ut;return Or(e)&&Fe(e.incremental)&&e.incremental.forEach(function(i){for(var a=i.data,o=i.path,s=o.length-1;s>=0;--s){var c=o[s],u=!isNaN(+c),l=u?[]:{};l[c]=a,a=l}t=n.merge(t,a)}),t}function ui(r){var e=Co(r);return Fe(e)}function Co(r){var e=Fe(r.errors)?r.errors.slice(0):[];return Or(r)&&Fe(r.incremental)&&r.incremental.forEach(function(t){t.errors&&e.push.apply(e,t.errors)}),e}function Cr(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Object.create(null);return r.forEach(function(n){!n||Object.keys(n).forEach(function(i){var a=n[i];a!==void 0&&(t[i]=a)})}),t}var sf=new Map;function na(r){var e=sf.get(r)||1;return sf.set(r,e+1),"".concat(r,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function cf(r){var e=na("stringifyForDisplay");return JSON.stringify(r,function(t,n){return n===void 0?e:n}).split(JSON.stringify(e)).join("<undefined>")}function ia(r,e){return Cr(r,e,e.variables&&{variables:T(T({},r&&r.variables),e.variables)})}function Ro(r){return new ae(function(e){e.error(r)})}var aa=function(r,e,t){var n=new Error(t);throw n.name="ServerError",n.response=r,n.statusCode=r.status,n.result=e,n};function Mc(r){for(var e=["query","operationName","variables","extensions","context"],t=0,n=Object.keys(r);t<n.length;t++){var i=n[t];if(e.indexOf(i)<0)throw __DEV__?new X("illegal argument: ".concat(i)):new X(27)}return r}function Uc(r,e){var t=T({},r),n=function(a){typeof a=="function"?t=T(T({},t),a(t)):t=T(T({},t),a)},i=function(){return T({},t)};return Object.defineProperty(e,"setContext",{enumerable:!1,value:n}),Object.defineProperty(e,"getContext",{enumerable:!1,value:i}),e}function jc(r){var e={variables:r.variables||{},extensions:r.extensions||{},operationName:r.operationName,query:r.query};return e.operationName||(e.operationName=typeof e.query!="string"?ai(e.query)||void 0:""),e}function uf(r,e){return e?e(r):ae.of()}function oa(r){return typeof r=="function"?new At(r):r}function Po(r){return r.request.length<=1}var pg=function(r){Ae(e,r);function e(t,n){var i=r.call(this,t)||this;return i.link=n,i}return e}(Error),At=function(){function r(e){e&&(this.request=e)}return r.empty=function(){return new r(function(){return ae.of()})},r.from=function(e){return e.length===0?r.empty():e.map(oa).reduce(function(t,n){return t.concat(n)})},r.split=function(e,t,n){var i=oa(t),a=oa(n||new r(uf));return Po(i)&&Po(a)?new r(function(o){return e(o)?i.request(o)||ae.of():a.request(o)||ae.of()}):new r(function(o,s){return e(o)?i.request(o,s)||ae.of():a.request(o,s)||ae.of()})},r.execute=function(e,t){return e.request(Uc(t.context,jc(Mc(t))))||ae.of()},r.concat=function(e,t){var n=oa(e);if(Po(n))return __DEV__&&$.warn(new pg("You are calling concat on a terminating link, which will have no effect",n)),n;var i=oa(t);return Po(i)?new r(function(a){return n.request(a,function(o){return i.request(o)||ae.of()})||ae.of()}):new r(function(a,o){return n.request(a,function(s){return i.request(s,o)||ae.of()})||ae.of()})},r.prototype.split=function(e,t,n){return this.concat(r.split(e,t,n||new r(uf)))},r.prototype.concat=function(e){return r.concat(this,e)},r.prototype.request=function(e,t){throw __DEV__?new X("request is not implemented"):new X(22)},r.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},r.prototype.setOnError=function(e){return this.onError=e,this},r}();var li=At.execute;var lf="3.7.10";function ff(r){return!!r.body}function pf(r){return!!r.getReader}function df(r){return!!(Ar&&r[Symbol.asyncIterator])}function hf(r){return!!r.stream}function mf(r){return!!r.arrayBuffer}function gf(r){return!!r.pipe}function qc(r){var e,t=r[Symbol.asyncIterator]();return e={next:function(){return t.next()}},e[Symbol.asyncIterator]=function(){return this},e}function Bc(r){var e=null,t=null,n=!1,i=[],a=[];function o(d){if(!t){if(a.length){var p=a.shift();if(Array.isArray(p)&&p[0])return p[0]({value:d,done:!1})}i.push(d)}}function s(d){t=d;var p=a.slice();p.forEach(function(f){f[1](d)}),!e||e()}function c(){n=!0;var d=a.slice();d.forEach(function(p){p[0]({value:void 0,done:!0})}),!e||e()}e=function(){e=null,r.removeListener("data",o),r.removeListener("error",s),r.removeListener("end",c),r.removeListener("finish",c),r.removeListener("close",c)},r.on("data",o),r.on("error",s),r.on("end",c),r.on("finish",c),r.on("close",c);function u(){return new Promise(function(d,p){if(t)return p(t);if(i.length)return d({value:i.shift(),done:!1});if(n)return d({value:void 0,done:!0});a.push([d,p])})}var l={next:function(){return u()}};return Ar&&(l[Symbol.asyncIterator]=function(){return this}),l}function Vc(r){var e=!1,t={next:function(){return e?Promise.resolve({value:void 0,done:!0}):(e=!0,new Promise(function(n,i){r.then(function(a){n({value:a,done:!1})}).catch(i)}))}};return Ar&&(t[Symbol.asyncIterator]=function(){return this}),t}function No(r){var e={next:function(){return r.read()}};return Ar&&(e[Symbol.asyncIterator]=function(){return this}),e}function yf(r){var e=r;if(ff(r)&&(e=r.body),df(e))return qc(e);if(pf(e))return No(e.getReader());if(hf(e))return No(e.stream().getReader());if(mf(e))return Vc(e.arrayBuffer());if(gf(e))return Bc(e);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var vf=Object.prototype.hasOwnProperty;function bf(r,e){var t,n,i;return $t(this,void 0,void 0,function(){var a,o,s,c,u,l,d,p,f,h,m,g,_,w,y,b,I,A,E,R;return Ft(this,function(L){switch(L.label){case 0:if(TextDecoder===void 0)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");a=new TextDecoder("utf-8"),o=(t=r.headers)===null||t===void 0?void 0:t.get("content-type"),s="boundary=",c=o?.includes(s)?o?.substring(o?.indexOf(s)+s.length).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",u="--".concat(c),l="",d=yf(r),p=!0,L.label=1;case 1:return p?[4,d.next()]:[3,3];case 2:for(f=L.sent(),h=f.value,m=f.done,g=typeof h=="string"?h:a.decode(h),p=!m,l+=g,_=l.indexOf(u);_>-1;){if(w=void 0,R=[l.slice(0,_),l.slice(_+u.length)],w=R[0],l=R[1],w.trim()){if(y=w.indexOf(`\r
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
`):new X(23)};var Tf=function(){if(typeof AbortController>"u")return{controller:!1,signal:!1};var r=new AbortController,e=r.signal;return{controller:r,signal:e}};var kf=function(r,e){var t=r.getContext(),n=t.uri;return n||(typeof e=="function"?e(r):e||"/graphql")};function Af(r,e){var t=[],n=function(d,p){t.push("".concat(d,"=").concat(encodeURIComponent(p)))};if("query"in e&&n("query",e.query),e.operationName&&n("operationName",e.operationName),e.variables){var i=void 0;try{i=sa(e.variables,"Variables map")}catch(d){return{parseError:d}}n("variables",i)}if(e.extensions){var a=void 0;try{a=sa(e.extensions,"Extensions map")}catch(d){return{parseError:d}}n("extensions",a)}var o="",s=r,c=r.indexOf("#");c!==-1&&(o=r.substr(c),s=r.substr(0,c));var u=s.indexOf("?")===-1?"?":"&",l=s+u+t.join("&")+o;return{newURI:l}}var Of=Be(function(){return fetch}),Cf=function(r){r===void 0&&(r={});var e=r.uri,t=e===void 0?"/graphql":e,n=r.fetch,i=r.print,a=i===void 0?Ef:i,o=r.includeExtensions,s=r.preserveHeaderCase,c=r.useGETForQueries,u=r.includeUnusedVariables,l=u===void 0?!1:u,d=zt(r,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);__DEV__&&If(n||Of);var p={http:{includeExtensions:o,preserveHeaderCase:s},options:d.fetchOptions,credentials:d.credentials,headers:d.headers};return new At(function(f){var h=kf(f,t),m=f.getContext(),g={};if(m.clientAwareness){var _=m.clientAwareness,w=_.name,y=_.version;w&&(g["apollographql-client-name"]=w),y&&(g["apollographql-client-version"]=y)}var b=T(T({},g),m.headers),I={http:m.http,options:m.fetchOptions,credentials:m.credentials,headers:b},A=xf(f,a,_f,p,I),E=A.options,R=A.body;if(R.variables&&!l){var L=new Set(Object.keys(R.variables));Ye(f.query,{Variable:function(ue,Vt,ie){ie&&ie.kind!=="VariableDefinition"&&L.delete(ue.name.value)}}),L.size&&(R.variables=T({},R.variables),L.forEach(function(ue){delete R.variables[ue]}))}var N;if(!E.signal){var F=Tf(),_e=F.controller,Ee=F.signal;N=_e,N&&(E.signal=Ee)}var O=function(ue){return ue.kind==="OperationDefinition"&&ue.operation==="mutation"};if(c&&!f.query.definitions.some(O)&&(E.method="GET"),ni(["defer"],f.query)&&(E.headers=E.headers||{},E.headers.accept="multipart/mixed; deferSpec=20220824, application/json"),E.method==="GET"){var ge=Af(h,R),ye=ge.newURI,ne=ge.parseError;if(ne)return Ro(ne);h=ye}else try{E.body=sa(R,"Payload")}catch(ue){return Ro(ue)}return new ae(function(ue){var Vt=n||Be(function(){return fetch})||Of;return Vt(h,E).then(function(ie){var Qt;f.setContext({response:ie});var xr=(Qt=ie.headers)===null||Qt===void 0?void 0:Qt.get("content-type");return xr!==null&&/^multipart\/mixed/i.test(xr)?bf(ie,ue):Sf(ie,f,ue)}).catch(function(ie){return Do(ie,ue)}),function(){N&&N.abort()}})})};var Qc=function(r){Ae(e,r);function e(t){t===void 0&&(t={});var n=r.call(this,Cf(t).request)||this;return n.options=t,n}return e}(At);var{toString:Rf,hasOwnProperty:bg}=Object.prototype,Pf=Function.prototype.toString,zc=new Map;function xe(r,e){try{return Hc(r,e)}finally{zc.clear()}}function Hc(r,e){if(r===e)return!0;let t=Rf.call(r),n=Rf.call(e);if(t!==n)return!1;switch(t){case"[object Array]":if(r.length!==e.length)return!1;case"[object Object]":{if(Df(r,e))return!0;let i=Nf(r),a=Nf(e),o=i.length;if(o!==a.length)return!1;for(let s=0;s<o;++s)if(!bg.call(e,i[s]))return!1;for(let s=0;s<o;++s){let c=i[s];if(!Hc(r[c],e[c]))return!1}return!0}case"[object Error]":return r.name===e.name&&r.message===e.message;case"[object Number]":if(r!==r)return e!==e;case"[object Boolean]":case"[object Date]":return+r==+e;case"[object RegExp]":case"[object String]":return r==`${e}`;case"[object Map]":case"[object Set]":{if(r.size!==e.size)return!1;if(Df(r,e))return!0;let i=r.entries(),a=t==="[object Map]";for(;;){let o=i.next();if(o.done)break;let[s,c]=o.value;if(!e.has(s)||a&&!Hc(c,e.get(s)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":r=new Uint8Array(r),e=new Uint8Array(e);case"[object DataView]":{let i=r.byteLength;if(i===e.byteLength)for(;i--&&r[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{let i=Pf.call(r);return i!==Pf.call(e)?!1:!_g(i,Sg)}}return!1}function Nf(r){return Object.keys(r).filter(wg,r)}function wg(r){return this[r]!==void 0}var Sg="{ [native code] }";function _g(r,e){let t=r.length-e.length;return t>=0&&r.indexOf(e,t)===t}function Df(r,e){let t=zc.get(r);if(t){if(t.has(e))return!0}else zc.set(r,t=new Set);return t.add(e),!1}var Eg=function(){return Object.create(null)},Lf=Array.prototype,xg=Lf.forEach,Ig=Lf.slice,Gt=function(){function r(e,t){e===void 0&&(e=!0),t===void 0&&(t=Eg),this.weakness=e,this.makeData=t}return r.prototype.lookup=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.lookupArray(e)},r.prototype.lookupArray=function(e){var t=this;return xg.call(e,function(n){return t=t.getChildTrie(n)}),t.data||(t.data=this.makeData(Ig.call(e)))},r.prototype.getChildTrie=function(e){var t=this.weakness&&Tg(e)?this.weak||(this.weak=new WeakMap):this.strong||(this.strong=new Map),n=t.get(e);return n||t.set(e,n=new r(this.weakness,this.makeData)),n},r}();function Tg(r){switch(typeof r){case"object":if(r===null)break;case"function":return!0}return!1}var Ge=null,$f={},kg=1,Ag=()=>class{constructor(){this.id=["slot",kg++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=Ge;e;e=e.parent)if(this.id in e.slots){let t=e.slots[this.id];if(t===$f)break;return e!==Ge&&(Ge.slots[this.id]=t),!0}return Ge&&(Ge.slots[this.id]=$f),!1}getValue(){if(this.hasValue())return Ge.slots[this.id]}withValue(e,t,n,i){let a={__proto__:null,[this.id]:e},o=Ge;Ge={parent:o,slots:a};try{return t.apply(i,n)}finally{Ge=o}}static bind(e){let t=Ge;return function(){let n=Ge;try{return Ge=t,e.apply(this,arguments)}finally{Ge=n}}}static noContext(e,t,n){if(Ge){let i=Ge;try{return Ge=null,e.apply(n,t)}finally{Ge=i}}else return e.apply(n,t)}};function Ff(r){try{return r()}catch{}}var Wc="@wry/context:Slot",Og=Ff(()=>globalThis)||Ff(()=>global)||Object.create(null),Mf=Og,fi=Mf[Wc]||Array[Wc]||function(r){try{Object.defineProperty(Mf,Wc,{value:r,enumerable:!1,writable:!1,configurable:!0})}finally{return r}}(Ag());var{bind:Cg,noContext:Rg}=fi;function Pg(){}var Ng=function(){function r(e,t){e===void 0&&(e=1/0),t===void 0&&(t=Pg),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return r.prototype.has=function(e){return this.map.has(e)},r.prototype.get=function(e){var t=this.getNode(e);return t&&t.value},r.prototype.getNode=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,i=t.newer;i&&(i.older=n),n&&(n.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t},r.prototype.set=function(e,t){var n=this.getNode(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},r.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},r.prototype.delete=function(e){var t=this.map.get(e);return t?(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0):!1},r}(),$o=new fi,Gc,Dg=Object.prototype.hasOwnProperty,Jc=(Gc=Array.from,Gc===void 0?function(r){var e=[];return r.forEach(function(t){return e.push(t)}),e}:Gc);function Lo(r){var e=r.unsubscribe;typeof e=="function"&&(r.unsubscribe=void 0,e())}var ca=[],Lg=100;function pi(r,e){if(!r)throw new Error(e||"assertion failure")}function $g(r,e){var t=r.length;return t>0&&t===e.length&&r[t-1]===e[t-1]}function jf(r){switch(r.length){case 0:throw new Error("unknown value");case 1:return r[0];case 2:throw r[1]}}function Fg(r){return r.slice(0)}var Mg=function(){function r(e){this.fn=e,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++r.count}return r.prototype.peek=function(){if(this.value.length===1&&!Rr(this))return Uf(this),this.value[0]},r.prototype.recompute=function(e){return pi(!this.recomputing,"already recomputing"),Uf(this),Rr(this)?Ug(this,e):jf(this.value)},r.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,qf(this),Lo(this))},r.prototype.dispose=function(){var e=this;this.setDirty(),Hf(this),Zc(this,function(t,n){t.setDirty(),Wf(t,e)})},r.prototype.forget=function(){this.dispose()},r.prototype.dependOn=function(e){e.add(this),this.deps||(this.deps=ca.pop()||new Set),this.deps.add(e)},r.prototype.forgetDeps=function(){var e=this;this.deps&&(Jc(this.deps).forEach(function(t){return t.delete(e)}),this.deps.clear(),ca.push(this.deps),this.deps=null)},r.count=0,r}();function Uf(r){var e=$o.getValue();if(e)return r.parents.add(e),e.childValues.has(r)||e.childValues.set(r,[]),Rr(r)?Vf(e,r):Qf(e,r),e}function Ug(r,e){return Hf(r),$o.withValue(r,jg,[r,e]),Bg(r,e)&&qg(r),jf(r.value)}function jg(r,e){r.recomputing=!0,r.value.length=0;try{r.value[0]=r.fn.apply(null,e)}catch(t){r.value[1]=t}r.recomputing=!1}function Rr(r){return r.dirty||!!(r.dirtyChildren&&r.dirtyChildren.size)}function qg(r){r.dirty=!1,!Rr(r)&&Bf(r)}function qf(r){Zc(r,Vf)}function Bf(r){Zc(r,Qf)}function Zc(r,e){var t=r.parents.size;if(t)for(var n=Jc(r.parents),i=0;i<t;++i)e(n[i],r)}function Vf(r,e){pi(r.childValues.has(e)),pi(Rr(e));var t=!Rr(r);if(!r.dirtyChildren)r.dirtyChildren=ca.pop()||new Set;else if(r.dirtyChildren.has(e))return;r.dirtyChildren.add(e),t&&qf(r)}function Qf(r,e){pi(r.childValues.has(e)),pi(!Rr(e));var t=r.childValues.get(e);t.length===0?r.childValues.set(e,Fg(e.value)):$g(t,e.value)||r.setDirty(),zf(r,e),!Rr(r)&&Bf(r)}function zf(r,e){var t=r.dirtyChildren;t&&(t.delete(e),t.size===0&&(ca.length<Lg&&ca.push(t),r.dirtyChildren=null))}function Hf(r){r.childValues.size>0&&r.childValues.forEach(function(e,t){Wf(r,t)}),r.forgetDeps(),pi(r.dirtyChildren===null)}function Wf(r,e){e.parents.delete(r),r.childValues.delete(e),zf(r,e)}function Bg(r,e){if(typeof r.subscribe=="function")try{Lo(r),r.unsubscribe=r.subscribe.apply(null,e)}catch{return r.setDirty(),!1}return!0}var Vg={setDirty:!0,dispose:!0,forget:!0};function Fo(r){var e=new Map,t=r&&r.subscribe;function n(i){var a=$o.getValue();if(a){var o=e.get(i);o||e.set(i,o=new Set),a.dependOn(o),typeof t=="function"&&(Lo(o),o.unsubscribe=t(i))}}return n.dirty=function(a,o){var s=e.get(a);if(s){var c=o&&Dg.call(Vg,o)?o:"setDirty";Jc(s).forEach(function(u){return u[c]()}),e.delete(a),Lo(s)}},n}function Gf(){var r=new Gt(typeof WeakMap=="function");return function(){return r.lookupArray(arguments)}}var Mx=Gf(),Kc=new Set;function gn(r,e){e===void 0&&(e=Object.create(null));var t=new Ng(e.max||Math.pow(2,16),function(u){return u.dispose()}),n=e.keyArgs,i=e.makeCacheKey||Gf(),a=function(){var u=i.apply(null,n?n.apply(null,arguments):arguments);if(u===void 0)return r.apply(null,arguments);var l=t.get(u);l||(t.set(u,l=new Mg(r)),l.subscribe=e.subscribe,l.forget=function(){return t.delete(u)});var d=l.recompute(Array.prototype.slice.call(arguments));return t.set(u,l),Kc.add(t),$o.hasValue()||(Kc.forEach(function(p){return p.clean()}),Kc.clear()),d};Object.defineProperty(a,"size",{get:function(){return t.map.size},configurable:!1,enumerable:!1});function o(u){var l=t.get(u);l&&l.setDirty()}a.dirtyKey=o,a.dirty=function(){o(i.apply(null,arguments))};function s(u){var l=t.get(u);if(l)return l.peek()}a.peekKey=s,a.peek=function(){return s(i.apply(null,arguments))};function c(u){return t.delete(u)}return a.forgetKey=c,a.forget=function(){return c(i.apply(null,arguments))},a.makeCacheKey=i,a.getKey=n?function(){return i.apply(null,n.apply(null,arguments))}:i,Object.freeze(a)}var Yc=function(){function r(){this.getFragmentDoc=gn(vc)}return r.prototype.batch=function(e){var t=this,n=typeof e.optimistic=="string"?e.optimistic:e.optimistic===!1?null:void 0,i;return this.performTransaction(function(){return i=e.update(t)},n),i},r.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},r.prototype.transformDocument=function(e){return e},r.prototype.transformForLink=function(e){return e},r.prototype.identify=function(e){},r.prototype.gc=function(){return[]},r.prototype.modify=function(e){return!1},r.prototype.readQuery=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(T(T({},e),{rootId:e.id||"ROOT_QUERY",optimistic:t}))},r.prototype.readFragment=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(T(T({},e),{query:this.getFragmentDoc(e.fragment,e.fragmentName),rootId:e.id,optimistic:t}))},r.prototype.writeQuery=function(e){var t=e.id,n=e.data,i=zt(e,["id","data"]);return this.write(Object.assign(i,{dataId:t||"ROOT_QUERY",result:n}))},r.prototype.writeFragment=function(e){var t=e.id,n=e.data,i=e.fragment,a=e.fragmentName,o=zt(e,["id","data","fragment","fragmentName"]);return this.write(Object.assign(o,{query:this.getFragmentDoc(i,a),dataId:t,result:n}))},r.prototype.updateQuery=function(e,t){return this.batch({update:function(n){var i=n.readQuery(e),a=t(i);return a==null?i:(n.writeQuery(T(T({},e),{data:a})),a)}})},r.prototype.updateFragment=function(e,t){return this.batch({update:function(n){var i=n.readFragment(e),a=t(i);return a==null?i:(n.writeFragment(T(T({},e),{data:a})),a)}})},r}();var ua=function(r){Ae(e,r);function e(t,n,i,a){var o,s=r.call(this,t)||this;if(s.message=t,s.path=n,s.query=i,s.variables=a,Array.isArray(s.path)){s.missing=s.message;for(var c=s.path.length-1;c>=0;--c)s.missing=(o={},o[s.path[c]]=s.missing,o)}else s.missing=s.path;return s.__proto__=e.prototype,s}return e}(Error);var Oe=Object.prototype.hasOwnProperty;function la(r){return r==null}function Uo(r,e){var t=r.__typename,n=r.id,i=r._id;if(typeof t=="string"&&(e&&(e.keyObject=la(n)?la(i)?void 0:{_id:i}:{id:n}),la(n)&&!la(i)&&(n=i),!la(n)))return"".concat(t,":").concat(typeof n=="number"||typeof n=="string"?n:JSON.stringify(n))}var Kf={dataIdFromObject:Uo,addTypename:!0,resultCaching:!0,canonizeResults:!1};function Jf(r){return Cr(Kf,r)}function jo(r){var e=r.canonizeResults;return e===void 0?Kf.canonizeResults:e}function Zf(r,e){return se(e)?r.get(e.__ref,"__typename"):e&&e.__typename}var Xc=/^[_a-z][_0-9a-z]*/i;function jt(r){var e=r.match(Xc);return e?e[0]:r}function Mo(r,e,t){return le(e)?ve(e)?e.every(function(n){return Mo(r,n,t)}):r.selections.every(function(n){if(vt(n)&&cr(n,t)){var i=Tt(n);return Oe.call(e,i)&&(!n.selectionSet||Mo(n.selectionSet,e[i],t))}return!0}):!1}function Pr(r){return le(r)&&!se(r)&&!ve(r)}function Yf(){return new ut}function qo(r,e){var t=un(fn(r));return{fragmentMap:t,lookupFragment:function(n){var i=t[n];return!i&&e&&(i=e.lookup(n)),i||null}}}var Bo=Object.create(null),eu=function(){return Bo},Xf=Object.create(null),di=function(){function r(e,t){var n=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(i,a){return ra(se(i)?n.get(i.__ref,a):i&&i[a])},this.canRead=function(i){return se(i)?n.has(i.__ref):typeof i=="object"},this.toReference=function(i,a){if(typeof i=="string")return Ht(i);if(se(i))return i;var o=n.policies.identify(i)[0];if(o){var s=Ht(o);return a&&n.merge(o,i),s}}}return r.prototype.toObject=function(){return T({},this.data)},r.prototype.has=function(e){return this.lookup(e,!0)!==void 0},r.prototype.get=function(e,t){if(this.group.depend(e,t),Oe.call(this.data,e)){var n=this.data[e];if(n&&Oe.call(n,t))return n[t]}if(t==="__typename"&&Oe.call(this.policies.rootTypenamesById,e))return this.policies.rootTypenamesById[e];if(this instanceof Nr)return this.parent.get(e,t)},r.prototype.lookup=function(e,t){if(t&&this.group.depend(e,"__exists"),Oe.call(this.data,e))return this.data[e];if(this instanceof Nr)return this.parent.lookup(e,t);if(this.policies.rootTypenamesById[e])return Object.create(null)},r.prototype.merge=function(e,t){var n=this,i;se(e)&&(e=e.__ref),se(t)&&(t=t.__ref);var a=typeof e=="string"?this.lookup(i=e):e,o=typeof t=="string"?this.lookup(i=t):t;if(!!o){__DEV__?$(typeof i=="string","store.merge expects a string ID"):$(typeof i=="string",1);var s=new ut(zg).merge(a,o);if(this.data[i]=s,s!==a&&(delete this.refs[i],this.group.caching)){var c=Object.create(null);a||(c.__exists=1),Object.keys(o).forEach(function(u){if(!a||a[u]!==s[u]){c[u]=1;var l=jt(u);l!==u&&!n.policies.hasKeyArgs(s.__typename,l)&&(c[l]=1),s[u]===void 0&&!(n instanceof Nr)&&delete s[u]}}),c.__typename&&!(a&&a.__typename)&&this.policies.rootTypenamesById[i]===s.__typename&&delete c.__typename,Object.keys(c).forEach(function(u){return n.group.dirty(i,u)})}}},r.prototype.modify=function(e,t){var n=this,i=this.lookup(e);if(i){var a=Object.create(null),o=!1,s=!0,c={DELETE:Bo,INVALIDATE:Xf,isReference:se,toReference:this.toReference,canRead:this.canRead,readField:function(u,l){return n.policies.readField(typeof u=="string"?{fieldName:u,from:l||Ht(e)}:u,{store:n})}};if(Object.keys(i).forEach(function(u){var l=jt(u),d=i[u];if(d!==void 0){var p=typeof t=="function"?t:t[u]||t[l];if(p){var f=p===eu?Bo:p(ra(d),T(T({},c),{fieldName:l,storeFieldName:u,storage:n.getStorage(e,u)}));f===Xf?n.group.dirty(e,u):(f===Bo&&(f=void 0),f!==d&&(a[u]=f,o=!0,d=f))}d!==void 0&&(s=!1)}}),o)return this.merge(e,a),s&&(this instanceof Nr?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},r.prototype.delete=function(e,t,n){var i,a=this.lookup(e);if(a){var o=this.getFieldValue(a,"__typename"),s=t&&n?this.policies.getStoreFieldName({typename:o,fieldName:t,args:n}):t;return this.modify(e,s?(i={},i[s]=eu,i):eu)}return!1},r.prototype.evict=function(e,t){var n=!1;return e.id&&(Oe.call(this.data,e.id)&&(n=this.delete(e.id,e.fieldName,e.args)),this instanceof Nr&&this!==t&&(n=this.parent.evict(e,t)||n),(e.fieldName||n)&&this.group.dirty(e.id,e.fieldName||"__exists")),n},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var e=this,t=this.toObject(),n=[];return this.getRootIdSet().forEach(function(i){Oe.call(e.policies.rootTypenamesById,i)||n.push(i)}),n.length&&(t.__META={extraRootIds:n.sort()}),t},r.prototype.replace=function(e){var t=this;if(Object.keys(this.data).forEach(function(a){e&&Oe.call(e,a)||t.delete(a)}),e){var n=e.__META,i=zt(e,["__META"]);Object.keys(i).forEach(function(a){t.merge(a,i[a])}),n&&n.extraRootIds.forEach(this.retain,this)}},r.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},r.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},r.prototype.getRootIdSet=function(e){return e===void 0&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Nr?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},r.prototype.gc=function(){var e=this,t=this.getRootIdSet(),n=this.toObject();t.forEach(function(o){Oe.call(n,o)&&(Object.keys(e.findChildRefIds(o)).forEach(t.add,t),delete n[o])});var i=Object.keys(n);if(i.length){for(var a=this;a instanceof Nr;)a=a.parent;i.forEach(function(o){return a.delete(o)})}return i},r.prototype.findChildRefIds=function(e){if(!Oe.call(this.refs,e)){var t=this.refs[e]=Object.create(null),n=this.data[e];if(!n)return t;var i=new Set([n]);i.forEach(function(a){se(a)&&(t[a.__ref]=!0),le(a)&&Object.keys(a).forEach(function(o){var s=a[o];le(s)&&i.add(s)})})}return this.refs[e]},r.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},r}();var ep=function(){function r(e,t){t===void 0&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return r.prototype.resetCaching=function(){this.d=this.caching?Fo():null,this.keyMaker=new Gt(kt)},r.prototype.depend=function(e,t){if(this.d){this.d(tu(e,t));var n=jt(t);n!==t&&this.d(tu(e,n)),this.parent&&this.parent.depend(e,t)}},r.prototype.dirty=function(e,t){this.d&&this.d.dirty(tu(e,t),t==="__exists"?"forget":"setDirty")},r}();function tu(r,e){return e+"#"+r}function ru(r,e){yn(r)&&r.group.depend(e,"__exists")}(function(r){var e=function(t){Ae(n,t);function n(i){var a=i.policies,o=i.resultCaching,s=o===void 0?!0:o,c=i.seed,u=t.call(this,a,new ep(s))||this;return u.stump=new Qg(u),u.storageTrie=new Gt(kt),c&&u.replace(c),u}return n.prototype.addLayer=function(i,a){return this.stump.addLayer(i,a)},n.prototype.removeLayer=function(){return this},n.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},n}(r);r.Root=e})(di||(di={}));var Nr=function(r){Ae(e,r);function e(t,n,i,a){var o=r.call(this,n.policies,a)||this;return o.id=t,o.parent=n,o.replay=i,o.group=a,i(o),o}return e.prototype.addLayer=function(t,n){return new e(t,this,n,this.group)},e.prototype.removeLayer=function(t){var n=this,i=this.parent.removeLayer(t);return t===this.id?(this.group.caching&&Object.keys(this.data).forEach(function(a){var o=n.data[a],s=i.lookup(a);s?o?o!==s&&Object.keys(o).forEach(function(c){xe(o[c],s[c])||n.group.dirty(a,c)}):(n.group.dirty(a,"__exists"),Object.keys(s).forEach(function(c){n.group.dirty(a,c)})):n.delete(a)}),i):i===this.parent?this:i.addLayer(this.id,this.replay)},e.prototype.toObject=function(){return T(T({},this.parent.toObject()),this.data)},e.prototype.findChildRefIds=function(t){var n=this.parent.findChildRefIds(t);return Oe.call(this.data,t)?T(T({},n),r.prototype.findChildRefIds.call(this,t)):n},e.prototype.getStorage=function(){for(var t=this.parent;t.parent;)t=t.parent;return t.getStorage.apply(t,arguments)},e}(di),Qg=function(r){Ae(e,r);function e(t){return r.call(this,"EntityStore.Stump",t,function(){},new ep(t.group.caching,t.group))||this}return e.prototype.removeLayer=function(){return this},e.prototype.merge=function(){return this.parent.merge.apply(this.parent,arguments)},e}(Nr);function zg(r,e,t){var n=r[t],i=e[t];return xe(n,i)?n:i}function yn(r){return!!(r instanceof di&&r.group.caching)}function Hg(r){return le(r)?ve(r)?r.slice(0):T({__proto__:Object.getPrototypeOf(r)},r):r}var Vo=function(){function r(){this.known=new(nf?WeakSet:Set),this.pool=new Gt(kt),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return r.prototype.isKnown=function(e){return le(e)&&this.known.has(e)},r.prototype.pass=function(e){if(le(e)){var t=Hg(e);return this.passes.set(t,e),t}return e},r.prototype.admit=function(e){var t=this;if(le(e)){var n=this.passes.get(e);if(n)return n;var i=Object.getPrototypeOf(e);switch(i){case Array.prototype:{if(this.known.has(e))return e;var a=e.map(this.admit,this),o=this.pool.lookupArray(a);return o.array||(this.known.add(o.array=a),__DEV__&&Object.freeze(a)),o.array}case null:case Object.prototype:{if(this.known.has(e))return e;var s=Object.getPrototypeOf(e),c=[s],u=this.sortedKeys(e);c.push(u.json);var l=c.length;u.sorted.forEach(function(f){c.push(t.admit(e[f]))});var o=this.pool.lookupArray(c);if(!o.object){var d=o.object=Object.create(s);this.known.add(d),u.sorted.forEach(function(f,h){d[f]=c[l+h]}),__DEV__&&Object.freeze(d)}return o.object}}}return e},r.prototype.sortedKeys=function(e){var t=Object.keys(e),n=this.pool.lookupArray(t);if(!n.keys){t.sort();var i=JSON.stringify(t);(n.keys=this.keysByJSON.get(i))||this.keysByJSON.set(i,n.keys={sorted:t,json:i})}return n.keys},r}();var bt=Object.assign(function(r){if(le(r)){nu===void 0&&tp();var e=nu.admit(r),t=iu.get(e);return t===void 0&&iu.set(e,t=JSON.stringify(e)),t}return JSON.stringify(r)},{reset:tp}),nu,iu;function tp(){nu=new Vo,iu=new(kt?WeakMap:Map)}function rp(r){return[r.selectionSet,r.objectOrReference,r.context,r.context.canonizeResults]}var np=function(){function r(e){var t=this;this.knownResults=new(kt?WeakMap:Map),this.config=Cr(e,{addTypename:e.addTypename!==!1,canonizeResults:jo(e)}),this.canon=e.canon||new Vo,this.executeSelectionSet=gn(function(n){var i,a=n.context.canonizeResults,o=rp(n);o[3]=!a;var s=(i=t.executeSelectionSet).peek.apply(i,o);return s?a?T(T({},s),{result:t.canon.admit(s.result)}):s:(ru(n.context.store,n.enclosingRef.__ref),t.execSelectionSetImpl(n))},{max:this.config.resultCacheMaxSize,keyArgs:rp,makeCacheKey:function(n,i,a,o){if(yn(a.store))return a.store.makeCacheKey(n,se(i)?i.__ref:i,a.varString,o)}}),this.executeSubSelectedArray=gn(function(n){return ru(n.context.store,n.enclosingRef.__ref),t.execSubSelectedArrayImpl(n)},{max:this.config.resultCacheMaxSize,makeCacheKey:function(n){var i=n.field,a=n.array,o=n.context;if(yn(o.store))return o.store.makeCacheKey(i,a,o.varString)}})}return r.prototype.resetCanon=function(){this.canon=new Vo},r.prototype.diffQueryAgainstStore=function(e){var t=e.store,n=e.query,i=e.rootId,a=i===void 0?"ROOT_QUERY":i,o=e.variables,s=e.returnPartialData,c=s===void 0?!0:s,u=e.canonizeResults,l=u===void 0?this.config.canonizeResults:u,d=this.config.cache.policies;o=T(T({},dn(Xi(n))),o);var p=Ht(a),f=this.executeSelectionSet({selectionSet:pn(n).selectionSet,objectOrReference:p,enclosingRef:p,context:T({store:t,query:n,policies:d,variables:o,varString:bt(o),canonizeResults:l},qo(n,this.config.fragments))}),h;if(f.missing&&(h=[new ua(Wg(f.missing),f.missing,n,o)],!c))throw h[0];return{result:f.result,complete:!h,missing:h}},r.prototype.isFresh=function(e,t,n,i){if(yn(i.store)&&this.knownResults.get(e)===n){var a=this.executeSelectionSet.peek(n,t,i,this.canon.isKnown(e));if(a&&e===a.result)return!0}return!1},r.prototype.execSelectionSetImpl=function(e){var t=this,n=e.selectionSet,i=e.objectOrReference,a=e.enclosingRef,o=e.context;if(se(i)&&!o.policies.rootTypenamesById[i.__ref]&&!o.store.has(i.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(i.__ref," object")};var s=o.variables,c=o.policies,u=o.store,l=u.getFieldValue(i,"__typename"),d=[],p,f=new ut;this.config.addTypename&&typeof l=="string"&&!c.rootIdsByTypename[l]&&d.push({__typename:l});function h(y,b){var I;return y.missing&&(p=f.merge(p,(I={},I[b]=y.missing,I))),y.result}var m=new Set(n.selections);m.forEach(function(y){var b,I;if(!!cr(y,s))if(vt(y)){var A=c.readField({fieldName:y.name.value,field:y,variables:o.variables,from:i},o),E=Tt(y);A===void 0?hn.added(y)||(p=f.merge(p,(b={},b[E]="Can't find field '".concat(y.name.value,"' on ").concat(se(i)?i.__ref+" object":"object "+JSON.stringify(i,null,2)),b))):ve(A)?A=h(t.executeSubSelectedArray({field:y,array:A,enclosingRef:a,context:o}),E):y.selectionSet?A!=null&&(A=h(t.executeSelectionSet({selectionSet:y.selectionSet,objectOrReference:A,enclosingRef:se(A)?A:a,context:o}),E)):o.canonizeResults&&(A=t.canon.pass(A)),A!==void 0&&d.push((I={},I[E]=A,I))}else{var R=ln(y,o.lookupFragment);if(!R&&y.kind===De.FRAGMENT_SPREAD)throw __DEV__?new X("No fragment named ".concat(y.name.value)):new X(5);R&&c.fragmentMatches(R,l)&&R.selectionSet.selections.forEach(m.add,m)}});var g=ea(d),_={result:g,missing:p},w=o.canonizeResults?this.canon.admit(_):ra(_);return w.result&&this.knownResults.set(w.result,n),w},r.prototype.execSubSelectedArrayImpl=function(e){var t=this,n=e.field,i=e.array,a=e.enclosingRef,o=e.context,s,c=new ut;function u(l,d){var p;return l.missing&&(s=c.merge(s,(p={},p[d]=l.missing,p))),l.result}return n.selectionSet&&(i=i.filter(o.store.canRead)),i=i.map(function(l,d){return l===null?null:ve(l)?u(t.executeSubSelectedArray({field:n,array:l,enclosingRef:a,context:o}),d):n.selectionSet?u(t.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:l,enclosingRef:se(l)?l:a,context:o}),d):(__DEV__&&Gg(o.store,n,l),l)}),{result:o.canonizeResults?this.canon.admit(i):i,missing:s}},r}();function Wg(r){try{JSON.stringify(r,function(e,t){if(typeof t=="string")throw t;return t})}catch(e){return e}}function Gg(r,e,t){if(!e.selectionSet){var n=new Set([t]);n.forEach(function(i){le(i)&&(__DEV__?$(!se(i),"Missing selection set for object of type ".concat(Zf(r,i)," returned for query field ").concat(e.name.value)):$(!se(i),6),Object.values(i).forEach(n.add,n))})}}var hi=new fi,ip=new WeakMap;function fa(r){var e=ip.get(r);return e||ip.set(r,e={vars:new Set,dep:Fo()}),e}function au(r){fa(r).vars.forEach(function(e){return e.forgetCache(r)})}function ap(r){fa(r).vars.forEach(function(e){return e.attachCache(r)})}function Qo(r){var e=new Set,t=new Set,n=function(a){if(arguments.length>0){if(r!==a){r=a,e.forEach(function(c){fa(c).dep.dirty(n),Kg(c)});var o=Array.from(t);t.clear(),o.forEach(function(c){return c(r)})}}else{var s=hi.getValue();s&&(i(s),fa(s).dep(n))}return r};n.onNextChange=function(a){return t.add(a),function(){t.delete(a)}};var i=n.attachCache=function(a){return e.add(a),fa(a).vars.add(n),n};return n.forgetCache=function(a){return e.delete(a)},n}function Kg(r){r.broadcastWatches&&r.broadcastWatches()}var op=Object.create(null);function ou(r){var e=JSON.stringify(r);return op[e]||(op[e]=Object.create(null))}function su(r){var e=ou(r);return e.keyFieldsFn||(e.keyFieldsFn=function(t,n){var i=function(o,s){return n.readField(s,o)},a=n.keyObject=uu(r,function(o){var s=mi(n.storeObject,o,i);return s===void 0&&t!==n.storeObject&&Oe.call(t,o[0])&&(s=mi(t,o,cp)),__DEV__?$(s!==void 0,"Missing field '".concat(o.join("."),"' while extracting keyFields from ").concat(JSON.stringify(t))):$(s!==void 0,2),s});return"".concat(n.typename,":").concat(JSON.stringify(a))})}function cu(r){var e=ou(r);return e.keyArgsFn||(e.keyArgsFn=function(t,n){var i=n.field,a=n.variables,o=n.fieldName,s=uu(r,function(u){var l=u[0],d=l.charAt(0);if(d==="@"){if(i&&Fe(i.directives)){var p=l.slice(1),f=i.directives.find(function(_){return _.name.value===p}),h=f&&ur(f,a);return h&&mi(h,u.slice(1))}return}if(d==="$"){var m=l.slice(1);if(a&&Oe.call(a,m)){var g=u.slice(0);return g[0]=m,mi(a,g)}return}if(t)return mi(t,u)}),c=JSON.stringify(s);return(t||c!=="{}")&&(o+=":"+c),o})}function uu(r,e){var t=new ut;return sp(r).reduce(function(n,i){var a,o=e(i);if(o!==void 0){for(var s=i.length-1;s>=0;--s)o=(a={},a[i[s]]=o,a);n=t.merge(n,o)}return n},Object.create(null))}function sp(r){var e=ou(r);if(!e.paths){var t=e.paths=[],n=[];r.forEach(function(i,a){ve(i)?(sp(i).forEach(function(o){return t.push(n.concat(o))}),n.length=0):(n.push(i),ve(r[a+1])||(t.push(n.slice(0)),n.length=0))})}return e.paths}function cp(r,e){return r[e]}function mi(r,e,t){return t=t||cp,up(e.reduce(function n(i,a){return ve(i)?i.map(function(o){return n(o,a)}):i&&t(i,a)},r))}function up(r){return le(r)?ve(r)?r.map(up):uu(Object.keys(r).sort(),function(e){return mi(r,e)}):r}Zi.setStringify(bt);function lu(r){return r.args!==void 0?r.args:r.field?ur(r.field,r.variables):null}var Jg=function(){},lp=function(r,e){return e.fieldName},fp=function(r,e,t){var n=t.mergeObjects;return n(r,e)},pp=function(r,e){return e},hp=function(){function r(e){this.config=e,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=T({dataIdFromObject:Uo},e),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),e.possibleTypes&&this.addPossibleTypes(e.possibleTypes),e.typePolicies&&this.addTypePolicies(e.typePolicies)}return r.prototype.identify=function(e,t){var n,i=this,a=t&&(t.typename||((n=t.storeObject)===null||n===void 0?void 0:n.__typename))||e.__typename;if(a===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var o=t&&t.storeObject||e,s=T(T({},t),{typename:a,storeObject:o,readField:t&&t.readField||function(){var p=zo(arguments,o);return i.readField(p,{store:i.cache.data,variables:p.variables})}}),c,u=a&&this.getTypePolicy(a),l=u&&u.keyFn||this.config.dataIdFromObject;l;){var d=l(e,s);if(ve(d))l=su(d);else{c=d;break}}return c=c?String(c):void 0,s.keyObject?[c,s.keyObject]:[c]},r.prototype.addTypePolicies=function(e){var t=this;Object.keys(e).forEach(function(n){var i=e[n],a=i.queryType,o=i.mutationType,s=i.subscriptionType,c=zt(i,["queryType","mutationType","subscriptionType"]);a&&t.setRootTypename("Query",n),o&&t.setRootTypename("Mutation",n),s&&t.setRootTypename("Subscription",n),Oe.call(t.toBeAdded,n)?t.toBeAdded[n].push(c):t.toBeAdded[n]=[c]})},r.prototype.updateTypePolicy=function(e,t){var n=this,i=this.getTypePolicy(e),a=t.keyFields,o=t.fields;function s(c,u){c.merge=typeof u=="function"?u:u===!0?fp:u===!1?pp:c.merge}s(i,t.merge),i.keyFn=a===!1?Jg:ve(a)?su(a):typeof a=="function"?a:i.keyFn,o&&Object.keys(o).forEach(function(c){var u=n.getFieldPolicy(e,c,!0),l=o[c];if(typeof l=="function")u.read=l;else{var d=l.keyArgs,p=l.read,f=l.merge;u.keyFn=d===!1?lp:ve(d)?cu(d):typeof d=="function"?d:u.keyFn,typeof p=="function"&&(u.read=p),s(u,f)}u.read&&u.merge&&(u.keyFn=u.keyFn||lp)})},r.prototype.setRootTypename=function(e,t){t===void 0&&(t=e);var n="ROOT_"+e.toUpperCase(),i=this.rootTypenamesById[n];t!==i&&(__DEV__?$(!i||i===e,"Cannot change root ".concat(e," __typename more than once")):$(!i||i===e,3),i&&delete this.rootIdsByTypename[i],this.rootIdsByTypename[t]=n,this.rootTypenamesById[n]=t)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach(function(n){t.getSupertypeSet(n,!0),e[n].forEach(function(i){t.getSupertypeSet(i,!0).add(n);var a=i.match(Xc);(!a||a[0]!==i)&&t.fuzzySubtypes.set(i,new RegExp(i))})})},r.prototype.getTypePolicy=function(e){var t=this;if(!Oe.call(this.typePolicies,e)){var n=this.typePolicies[e]=Object.create(null);n.fields=Object.create(null);var i=this.supertypeMap.get(e);i&&i.size&&i.forEach(function(o){var s=t.getTypePolicy(o),c=s.fields,u=zt(s,["fields"]);Object.assign(n,u),Object.assign(n.fields,c)})}var a=this.toBeAdded[e];return a&&a.length&&a.splice(0).forEach(function(o){t.updateTypePolicy(e,o)}),this.typePolicies[e]},r.prototype.getFieldPolicy=function(e,t,n){if(e){var i=this.getTypePolicy(e).fields;return i[t]||n&&(i[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var n=this.supertypeMap.get(e);return!n&&t&&this.supertypeMap.set(e,n=new Set),n},r.prototype.fragmentMatches=function(e,t,n,i){var a=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var s=this.getSupertypeSet(t,!0),c=[s],u=function(h){var m=a.getSupertypeSet(h,!1);m&&m.size&&c.indexOf(m)<0&&c.push(m)},l=!!(n&&this.fuzzySubtypes.size),d=!1,p=0;p<c.length;++p){var f=c[p];if(f.has(o))return s.has(o)||(d&&__DEV__&&$.warn("Inferring subtype ".concat(t," of supertype ").concat(o)),s.add(o)),!0;f.forEach(u),l&&p===c.length-1&&Mo(e.selectionSet,n,i)&&(l=!1,d=!0,this.fuzzySubtypes.forEach(function(h,m){var g=t.match(h);g&&g[0]===t&&u(m)}))}return!1},r.prototype.hasKeyArgs=function(e,t){var n=this.getFieldPolicy(e,t,!1);return!!(n&&n.keyFn)},r.prototype.getStoreFieldName=function(e){var t=e.typename,n=e.fieldName,i=this.getFieldPolicy(t,n,!1),a,o=i&&i.keyFn;if(o&&t)for(var s={typename:t,fieldName:n,field:e.field||null,variables:e.variables},c=lu(e);o;){var u=o(c,s);if(ve(u))o=cu(u);else{a=u||n;break}}return a===void 0&&(a=e.field?wc(e.field,e.variables):Zi(n,lu(e))),a===!1?n:n===jt(a)?a:n+":"+a},r.prototype.readField=function(e,t){var n=e.from;if(!!n){var i=e.field||e.fieldName;if(!!i){if(e.typename===void 0){var a=t.store.getFieldValue(n,"__typename");a&&(e.typename=a)}var o=this.getStoreFieldName(e),s=jt(o),c=t.store.getFieldValue(n,o),u=this.getFieldPolicy(e.typename,s,!1),l=u&&u.read;if(l){var d=dp(this,n,e,t,t.store.getStorage(se(n)?n.__ref:n,o));return hi.withValue(this.cache,l,[c,d])}return c}}},r.prototype.getReadFunction=function(e,t){var n=this.getFieldPolicy(e,t,!1);return n&&n.read},r.prototype.getMergeFunction=function(e,t,n){var i=this.getFieldPolicy(e,t,!1),a=i&&i.merge;return!a&&n&&(i=this.getTypePolicy(n),a=i&&i.merge),a},r.prototype.runMergeFunction=function(e,t,n,i,a){var o=n.field,s=n.typename,c=n.merge;return c===fp?mp(i.store)(e,t):c===pp?t:(i.overwrite&&(e=void 0),c(e,t,dp(this,void 0,{typename:s,fieldName:o.name.value,field:o,variables:i.variables},i,a||Object.create(null))))},r}();function dp(r,e,t,n,i){var a=r.getStoreFieldName(t),o=jt(a),s=t.variables||n.variables,c=n.store,u=c.toReference,l=c.canRead;return{args:lu(t),field:t.field||null,fieldName:o,storeFieldName:a,variables:s,isReference:se,toReference:u,storage:i,cache:r.cache,canRead:l,readField:function(){return r.readField(zo(arguments,e,s),n)},mergeObjects:mp(n.store)}}function zo(r,e,t){var n=r[0],i=r[1],a=r.length,o;return typeof n=="string"?o={fieldName:n,from:a>1?i:e}:(o=T({},n),Oe.call(o,"from")||(o.from=e)),__DEV__&&o.from===void 0&&__DEV__&&$.warn("Undefined 'from' passed to readField with arguments ".concat(cf(Array.from(r)))),o.variables===void 0&&(o.variables=t),o}function mp(r){return function(t,n){if(ve(t)||ve(n))throw __DEV__?new X("Cannot automatically merge arrays"):new X(4);if(le(t)&&le(n)){var i=r.getFieldValue(t,"__typename"),a=r.getFieldValue(n,"__typename"),o=i&&a&&i!==a;if(o)return n;if(se(t)&&Pr(n))return r.merge(t.__ref,n),t;if(Pr(t)&&se(n))return r.merge(t,n.__ref),n;if(Pr(t)&&Pr(n))return T(T({},t),n)}return n}}function fu(r,e,t){var n="".concat(e).concat(t),i=r.flavors.get(n);return i||r.flavors.set(n,i=r.clientOnly===e&&r.deferred===t?r:T(T({},r),{clientOnly:e,deferred:t})),i}var bp=function(){function r(e,t,n){this.cache=e,this.reader=t,this.fragments=n}return r.prototype.writeToStore=function(e,t){var n=this,i=t.query,a=t.result,o=t.dataId,s=t.variables,c=t.overwrite,u=Wt(i),l=Yf();s=T(T({},dn(u)),s);var d=T(T({store:e,written:Object.create(null),merge:function(f,h){return l.merge(f,h)},variables:s,varString:bt(s)},qo(i,this.fragments)),{overwrite:!!c,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),p=this.processSelectionSet({result:a||Object.create(null),dataId:o,selectionSet:u.selectionSet,mergeTree:{map:new Map},context:d});if(!se(p))throw __DEV__?new X("Could not identify object ".concat(JSON.stringify(a))):new X(7);return d.incomingById.forEach(function(f,h){var m=f.storeObject,g=f.mergeTree,_=f.fieldNodeSet,w=Ht(h);if(g&&g.map.size){var y=n.applyMerges(g,w,m,d);if(se(y))return;m=y}if(__DEV__&&!d.overwrite){var b=Object.create(null);_.forEach(function(E){E.selectionSet&&(b[E.name.value]=!0)});var I=function(E){return b[jt(E)]===!0},A=function(E){var R=g&&g.map.get(E);return Boolean(R&&R.info&&R.info.merge)};Object.keys(m).forEach(function(E){I(E)&&!A(E)&&Zg(w,m,E,d.store)})}e.merge(h,m)}),e.retain(p.__ref),p},r.prototype.processSelectionSet=function(e){var t=this,n=e.dataId,i=e.result,a=e.selectionSet,o=e.context,s=e.mergeTree,c=this.cache.policies,u=Object.create(null),l=n&&c.rootTypenamesById[n]||Yi(i,a,o.fragmentMap)||n&&o.store.get(n,"__typename");typeof l=="string"&&(u.__typename=l);var d=function(){var y=zo(arguments,u,o.variables);if(se(y.from)){var b=o.incomingById.get(y.from.__ref);if(b){var I=c.readField(T(T({},y),{from:b.storeObject}),o);if(I!==void 0)return I}}return c.readField(y,o)},p=new Set;this.flattenFields(a,i,o,l).forEach(function(y,b){var I,A=Tt(b),E=i[A];if(p.add(b),E!==void 0){var R=c.getStoreFieldName({typename:l,fieldName:b.name.value,field:b,variables:y.variables}),L=gp(s,R),N=t.processFieldValue(E,b,b.selectionSet?fu(y,!1,!1):y,L),F=void 0;b.selectionSet&&(se(N)||Pr(N))&&(F=d("__typename",N));var _e=c.getMergeFunction(l,b.name.value,F);_e?L.info={field:b,typename:l,merge:_e}:yp(s,R),u=y.merge(u,(I={},I[R]=N,I))}else __DEV__&&!y.clientOnly&&!y.deferred&&!hn.added(b)&&!c.getReadFunction(l,b.name.value)&&__DEV__&&$.error("Missing field '".concat(Tt(b),"' while writing result ").concat(JSON.stringify(i,null,2)).substring(0,1e3))});try{var f=c.identify(i,{typename:l,selectionSet:a,fragmentMap:o.fragmentMap,storeObject:u,readField:d}),h=f[0],m=f[1];n=n||h,m&&(u=o.merge(u,m))}catch(y){if(!n)throw y}if(typeof n=="string"){var g=Ht(n),_=o.written[n]||(o.written[n]=[]);if(_.indexOf(a)>=0||(_.push(a),this.reader&&this.reader.isFresh(i,g,a,o)))return g;var w=o.incomingById.get(n);return w?(w.storeObject=o.merge(w.storeObject,u),w.mergeTree=pu(w.mergeTree,s),p.forEach(function(y){return w.fieldNodeSet.add(y)})):o.incomingById.set(n,{storeObject:u,mergeTree:Ho(s)?void 0:s,fieldNodeSet:p}),g}return u},r.prototype.processFieldValue=function(e,t,n,i){var a=this;return!t.selectionSet||e===null?__DEV__?To(e):e:ve(e)?e.map(function(o,s){var c=a.processFieldValue(o,t,n,gp(i,s));return yp(i,s),c}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:n,mergeTree:i})},r.prototype.flattenFields=function(e,t,n,i){i===void 0&&(i=Yi(t,e,n.fragmentMap));var a=new Map,o=this.cache.policies,s=new Gt(!1);return function c(u,l){var d=s.lookup(u,l.clientOnly,l.deferred);d.visited||(d.visited=!0,u.selections.forEach(function(p){if(!!cr(p,n.variables)){var f=l.clientOnly,h=l.deferred;if(!(f&&h)&&Fe(p.directives)&&p.directives.forEach(function(_){var w=_.name.value;if(w==="client"&&(f=!0),w==="defer"){var y=ur(_,n.variables);(!y||y.if!==!1)&&(h=!0)}}),vt(p)){var m=a.get(p);m&&(f=f&&m.clientOnly,h=h&&m.deferred),a.set(p,fu(n,f,h))}else{var g=ln(p,n.lookupFragment);if(!g&&p.kind===De.FRAGMENT_SPREAD)throw __DEV__?new X("No fragment named ".concat(p.name.value)):new X(8);g&&o.fragmentMatches(g,i,t,n.variables)&&c(g.selectionSet,fu(n,f,h))}}}))}(e,n),a},r.prototype.applyMerges=function(e,t,n,i,a){var o,s=this;if(e.map.size&&!se(n)){var c=!ve(n)&&(se(t)||Pr(t))?t:void 0,u=n;c&&!a&&(a=[se(c)?c.__ref:c]);var l,d=function(p,f){return ve(p)?typeof f=="number"?p[f]:void 0:i.store.getFieldValue(p,String(f))};e.map.forEach(function(p,f){var h=d(c,f),m=d(u,f);if(m!==void 0){a&&a.push(f);var g=s.applyMerges(p,h,m,i,a);g!==m&&(l=l||new Map,l.set(f,g)),a&&$(a.pop()===f)}}),l&&(n=ve(u)?u.slice(0):T({},u),l.forEach(function(p,f){n[f]=p}))}return e.info?this.cache.policies.runMergeFunction(t,n,e.info,i,a&&(o=i.store).getStorage.apply(o,a)):n},r}();var wp=[];function gp(r,e){var t=r.map;return t.has(e)||t.set(e,wp.pop()||{map:new Map}),t.get(e)}function pu(r,e){if(r===e||!e||Ho(e))return r;if(!r||Ho(r))return e;var t=r.info&&e.info?T(T({},r.info),e.info):r.info||e.info,n=r.map.size&&e.map.size,i=n?new Map:r.map.size?r.map:e.map,a={info:t,map:i};if(n){var o=new Set(e.map.keys());r.map.forEach(function(s,c){a.map.set(c,pu(s,e.map.get(c))),o.delete(c)}),o.forEach(function(s){a.map.set(s,pu(e.map.get(s),r.map.get(s)))})}return a}function Ho(r){return!r||!(r.info||r.map.size)}function yp(r,e){var t=r.map,n=t.get(e);n&&Ho(n)&&(wp.push(n),t.delete(e))}var vp=new Set;function Zg(r,e,t,n){var i=function(d){var p=n.getFieldValue(d,t);return typeof p=="object"&&p},a=i(r);if(!!a){var o=i(e);if(!!o&&!se(a)&&!xe(a,o)&&!Object.keys(a).every(function(d){return n.getFieldValue(o,d)!==void 0})){var s=n.getFieldValue(r,"__typename")||n.getFieldValue(e,"__typename"),c=jt(t),u="".concat(s,".").concat(c);if(!vp.has(u)){vp.add(u);var l=[];!ve(a)&&!ve(o)&&[a,o].forEach(function(d){var p=n.getFieldValue(d,"__typename");typeof p=="string"&&!l.includes(p)&&l.push(p)}),__DEV__&&$.warn("Cache data may be lost when replacing the ".concat(c," field of a ").concat(s,` object.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers
|
|
46
|
-
* Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects
|
|
47
|
-
`))}}}}var Wo=function(r){Ae(e,r);function e(t){t===void 0&&(t={});var n=r.call(this)||this;return n.watches=new Set,n.typenameDocumentCache=new Map,n.makeVar=Qo,n.txCount=0,n.config=Jf(t),n.addTypename=!!n.config.addTypename,n.policies=new hp({cache:n,dataIdFromObject:n.config.dataIdFromObject,possibleTypes:n.config.possibleTypes,typePolicies:n.config.typePolicies}),n.init(),n}return e.prototype.init=function(){var t=this.data=new di.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=t.stump,this.resetResultCache()},e.prototype.resetResultCache=function(t){var n=this,i=this.storeReader,a=this.config.fragments;this.storeWriter=new bp(this,this.storeReader=new np({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:jo(this.config),canon:t?void 0:i&&i.canon,fragments:a}),a),this.maybeBroadcastWatch=gn(function(o,s){return n.broadcastWatch(o,s)},{max:this.config.resultCacheMaxSize,makeCacheKey:function(o){var s=o.optimistic?n.optimisticData:n.data;if(yn(s)){var c=o.optimistic,u=o.id,l=o.variables;return s.makeCacheKey(o.query,o.callback,bt({optimistic:c,id:u,variables:l}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(o){return o.resetCaching()})},e.prototype.restore=function(t){return this.init(),t&&this.data.replace(t),this},e.prototype.extract=function(t){return t===void 0&&(t=!1),(t?this.optimisticData:this.data).extract()},e.prototype.read=function(t){var n=t.returnPartialData,i=n===void 0?!1:n;try{return this.storeReader.diffQueryAgainstStore(T(T({},t),{store:t.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:i})).result||null}catch(a){if(a instanceof ua)return null;throw a}},e.prototype.write=function(t){try{return++this.txCount,this.storeWriter.writeToStore(this.data,t)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.modify=function(t){if(Oe.call(t,"id")&&!t.id)return!1;var n=t.optimistic?this.optimisticData:this.data;try{return++this.txCount,n.modify(t.id||"ROOT_QUERY",t.fields)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore(T(T({},t),{store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",config:this.config}))},e.prototype.watch=function(t){var n=this;return this.watches.size||ap(this),this.watches.add(t),t.immediate&&this.maybeBroadcastWatch(t),function(){n.watches.delete(t)&&!n.watches.size&&au(n),n.maybeBroadcastWatch.forget(t)}},e.prototype.gc=function(t){bt.reset();var n=this.optimisticData.gc();return t&&!this.txCount&&(t.resetResultCache?this.resetResultCache(t.resetResultIdentities):t.resetResultIdentities&&this.storeReader.resetCanon()),n},e.prototype.retain=function(t,n){return(n?this.optimisticData:this.data).retain(t)},e.prototype.release=function(t,n){return(n?this.optimisticData:this.data).release(t)},e.prototype.identify=function(t){if(se(t))return t.__ref;try{return this.policies.identify(t)[0]}catch(n){__DEV__&&$.warn(n)}},e.prototype.evict=function(t){if(!t.id){if(Oe.call(t,"id"))return!1;t=T(T({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t,this.data)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.reset=function(t){var n=this;return this.init(),bt.reset(),t&&t.discardWatches?(this.watches.forEach(function(i){return n.maybeBroadcastWatch.forget(i)}),this.watches.clear(),au(this)):this.broadcastWatches(),Promise.resolve()},e.prototype.removeOptimistic=function(t){var n=this.optimisticData.removeLayer(t);n!==this.optimisticData&&(this.optimisticData=n,this.broadcastWatches())},e.prototype.batch=function(t){var n=this,i=t.update,a=t.optimistic,o=a===void 0?!0:a,s=t.removeOptimistic,c=t.onWatchUpdated,u,l=function(p){var f=n,h=f.data,m=f.optimisticData;++n.txCount,p&&(n.data=n.optimisticData=p);try{return u=i(n)}finally{--n.txCount,n.data=h,n.optimisticData=m}},d=new Set;return c&&!this.txCount&&this.broadcastWatches(T(T({},t),{onWatchUpdated:function(p){return d.add(p),!1}})),typeof o=="string"?this.optimisticData=this.optimisticData.addLayer(o,l):o===!1?l(this.data):l(),typeof s=="string"&&(this.optimisticData=this.optimisticData.removeLayer(s)),c&&d.size?(this.broadcastWatches(T(T({},t),{onWatchUpdated:function(p,f){var h=c.call(this,p,f);return h!==!1&&d.delete(p),h}})),d.size&&d.forEach(function(p){return n.maybeBroadcastWatch.dirty(p)})):this.broadcastWatches(t),u},e.prototype.performTransaction=function(t,n){return this.batch({update:t,optimistic:n||n!==null})},e.prototype.transformDocument=function(t){if(this.addTypename){var n=this.typenameDocumentCache.get(t);return n||(n=hn(t),this.typenameDocumentCache.set(t,n),this.typenameDocumentCache.set(n,n)),n}return t},e.prototype.transformForLink=function(t){var n=this.config.fragments;return n?n.transform(t):t},e.prototype.broadcastWatches=function(t){var n=this;this.txCount||this.watches.forEach(function(i){return n.maybeBroadcastWatch(i,t)})},e.prototype.broadcastWatch=function(t,n){var i=t.lastDiff,a=this.diff(t);n&&(t.optimistic&&typeof n.optimistic=="string"&&(a.fromOptimisticTransaction=!0),n.onWatchUpdated&&n.onWatchUpdated.call(this,t,a,i)===!1)||(!i||!xe(i.result,a.result))&&t.callback(t.lastDiff=a,i)},e}(Yc);function Sp(r){return r.hasOwnProperty("graphQLErrors")}var Yg=function(r){var e="";if(Fe(r.graphQLErrors)||Fe(r.clientErrors)){var t=(r.graphQLErrors||[]).concat(r.clientErrors||[]);t.forEach(function(n){var i=n?n.message:"Error message not found.";e+="".concat(i,`
|
|
48
|
-
`)})}return r.networkError&&(e+="".concat(r.networkError.message,`
|
|
49
|
-
`)),e=e.replace(/\n$/,""),e},lr=function(r){Ae(e,r);function e(t){var n=t.graphQLErrors,i=t.clientErrors,a=t.networkError,o=t.errorMessage,s=t.extraInfo,c=r.call(this,o)||this;return c.name="ApolloError",c.graphQLErrors=n||[],c.clientErrors=i||[],c.networkError=a||null,c.message=o||Yg(c),c.extraInfo=s,c.__proto__=e.prototype,c}return e}(Error);var he;(function(r){r[r.loading=1]="loading",r[r.setVariables=2]="setVariables",r[r.fetchMore=3]="fetchMore",r[r.refetch=4]="refetch",r[r.poll=6]="poll",r[r.ready=7]="ready",r[r.error=8]="error"})(he||(he={}));function Dr(r){return r?r<7:!1}var Xg=Object.assign,ey=Object.hasOwnProperty,Go=function(r){Ae(e,r);function e(t){var n=t.queryManager,i=t.queryInfo,a=t.options,o=r.call(this,function(g){try{var _=g._subscription._observer;_&&!_.error&&(_.error=ty)}catch{}var w=!o.observers.size;o.observers.add(g);var y=o.last;return y&&y.error?g.error&&g.error(y.error):y&&y.result&&g.next&&g.next(y.result),w&&o.reobserve().catch(function(){}),function(){o.observers.delete(g)&&!o.observers.size&&o.tearDownQuery()}})||this;o.observers=new Set,o.subscriptions=new Set,o.queryInfo=i,o.queryManager=n,o.isTornDown=!1;var s=n.defaultOptions.watchQuery,c=s===void 0?{}:s,u=c.fetchPolicy,l=u===void 0?"cache-first":u,d=a.fetchPolicy,p=d===void 0?l:d,f=a.initialFetchPolicy,h=f===void 0?p==="standby"?l:p:f;o.options=T(T({},a),{initialFetchPolicy:h,fetchPolicy:p}),o.queryId=i.queryId||n.generateQueryId();var m=Wt(o.query);return o.queryName=m&&m.name&&m.name.value,o}return Object.defineProperty(e.prototype,"query",{get:function(){return this.queryManager.transform(this.options.query).document},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),e.prototype.result=function(){var t=this;return new Promise(function(n,i){var a={next:function(s){n(s),t.observers.delete(a),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){o.unsubscribe()},0)},error:i},o=t.subscribe(a)})},e.prototype.getCurrentResult=function(t){t===void 0&&(t=!0);var n=this.getLastResult(!0),i=this.queryInfo.networkStatus||n&&n.networkStatus||he.ready,a=T(T({},n),{loading:Dr(i),networkStatus:i}),o=this.options.fetchPolicy,s=o===void 0?"cache-first":o;if(!(s==="network-only"||s==="no-cache"||s==="standby"||this.queryManager.transform(this.options.query).hasForcedResolvers)){var c=this.queryInfo.getDiff();(c.complete||this.options.returnPartialData)&&(a.data=c.result),xe(a.data,{})&&(a.data=void 0),c.complete?(delete a.partial,c.complete&&a.networkStatus===he.loading&&(s==="cache-first"||s==="cache-only")&&(a.networkStatus=he.ready,a.loading=!1)):a.partial=!0,__DEV__&&!c.complete&&!this.options.partialRefetch&&!a.loading&&!a.data&&!a.error&&hu(c.missing)}return t&&this.updateLastResult(a),a},e.prototype.isDifferentFromLastResult=function(t,n){return!this.last||!xe(this.last.result,t)||n&&!xe(this.last.variables,n)},e.prototype.getLast=function(t,n){var i=this.last;if(i&&i[t]&&(!n||xe(i.variables,this.variables)))return i[t]},e.prototype.getLastResult=function(t){return this.getLast("result",t)},e.prototype.getLastError=function(t){return this.getLast("error",t)},e.prototype.resetLastResults=function(){delete this.last,this.isTornDown=!1},e.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},e.prototype.refetch=function(t){var n,i={pollInterval:0},a=this.options.fetchPolicy;if(a==="cache-and-network"?i.fetchPolicy=a:a==="no-cache"?i.fetchPolicy="no-cache":i.fetchPolicy="network-only",__DEV__&&t&&ey.call(t,"variables")){var o=Xi(this.query),s=o.variableDefinitions;(!s||!s.some(function(c){return c.variable.name.value==="variables"}))&&__DEV__&&$.warn("Called refetch(".concat(JSON.stringify(t),") for query ").concat(((n=o.name)===null||n===void 0?void 0:n.value)||JSON.stringify(o),`, which does not declare a $variables variable.
|
|
50
|
-
Did you mean to call refetch(variables) instead of refetch({ variables })?`))}return t&&!xe(this.options.variables,t)&&(i.variables=this.options.variables=T(T({},this.options.variables),t)),this.queryInfo.resetLastWrite(),this.reobserve(i,he.refetch)},e.prototype.fetchMore=function(t){var n=this,i=T(T({},t.query?t:T(T(T(T({},this.options),{query:this.query}),t),{variables:T(T({},this.options.variables),t.variables)})),{fetchPolicy:"no-cache"}),a=this.queryManager.generateQueryId(),o=this.queryInfo,s=o.networkStatus;o.networkStatus=he.fetchMore,i.notifyOnNetworkStatusChange&&this.observe();var c=new Set;return this.queryManager.fetchQuery(a,i,he.fetchMore).then(function(u){return n.queryManager.removeQuery(a),o.networkStatus===he.fetchMore&&(o.networkStatus=s),n.queryManager.cache.batch({update:function(l){var d=t.updateQuery;d?l.updateQuery({query:n.query,variables:n.variables,returnPartialData:!0,optimistic:!1},function(p){return d(p,{fetchMoreResult:u.data,variables:i.variables})}):l.writeQuery({query:i.query,variables:i.variables,data:u.data})},onWatchUpdated:function(l){c.add(l.query)}}),u}).finally(function(){c.has(n.query)||du(n)})},e.prototype.subscribeToMore=function(t){var n=this,i=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables,context:t.context}).subscribe({next:function(a){var o=t.updateQuery;o&&n.updateQuery(function(s,c){var u=c.variables;return o(s,{subscriptionData:a,variables:u})})},error:function(a){if(t.onError){t.onError(a);return}__DEV__&&$.error("Unhandled GraphQL subscription error",a)}});return this.subscriptions.add(i),function(){n.subscriptions.delete(i)&&i.unsubscribe()}},e.prototype.setOptions=function(t){return this.reobserve(t)},e.prototype.setVariables=function(t){return xe(this.variables,t)?this.observers.size?this.result():Promise.resolve():(this.options.variables=t,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:t},he.setVariables):Promise.resolve())},e.prototype.updateQuery=function(t){var n=this.queryManager,i=n.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}).result,a=t(i,{variables:this.variables});a&&(n.cache.writeQuery({query:this.options.query,data:a,variables:this.variables}),n.broadcastQueries())},e.prototype.startPolling=function(t){this.options.pollInterval=t,this.updatePolling()},e.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},e.prototype.applyNextFetchPolicy=function(t,n){if(n.nextFetchPolicy){var i=n.fetchPolicy,a=i===void 0?"cache-first":i,o=n.initialFetchPolicy,s=o===void 0?a:o;a==="standby"||(typeof n.nextFetchPolicy=="function"?n.fetchPolicy=n.nextFetchPolicy(a,{reason:t,options:n,observable:this,initialFetchPolicy:s}):t==="variables-changed"?n.fetchPolicy=s:n.fetchPolicy=n.nextFetchPolicy)}return n.fetchPolicy},e.prototype.fetch=function(t,n){return this.queryManager.setObservableQuery(this),this.queryManager.fetchQueryObservable(this.queryId,t,n)},e.prototype.updatePolling=function(){var t=this;if(!this.queryManager.ssrMode){var n=this,i=n.pollingInfo,a=n.options.pollInterval;if(!a){i&&(clearTimeout(i.timeout),delete this.pollingInfo);return}if(!(i&&i.interval===a)){__DEV__?$(a,"Attempted to start a polling query without a polling interval."):$(a,13);var o=i||(this.pollingInfo={});o.interval=a;var s=function(){t.pollingInfo&&(Dr(t.queryInfo.networkStatus)?c():t.reobserve({fetchPolicy:t.options.initialFetchPolicy==="no-cache"?"no-cache":"network-only"},he.poll).then(c,c))},c=function(){var u=t.pollingInfo;u&&(clearTimeout(u.timeout),u.timeout=setTimeout(s,u.interval))};c()}}},e.prototype.updateLastResult=function(t,n){return n===void 0&&(n=this.variables),this.last=T(T({},this.last),{result:this.queryManager.assumeImmutableResults?t:To(t),variables:n}),Fe(t.errors)||delete this.last.error,this.last},e.prototype.reobserve=function(t,n){var i=this;this.isTornDown=!1;var a=n===he.refetch||n===he.fetchMore||n===he.poll,o=this.options.variables,s=this.options.fetchPolicy,c=Cr(this.options,t||{}),u=a?c:Xg(this.options,c);a||(this.updatePolling(),t&&t.variables&&!xe(t.variables,o)&&u.fetchPolicy!=="standby"&&u.fetchPolicy===s&&(this.applyNextFetchPolicy("variables-changed",u),n===void 0&&(n=he.setVariables)));var l=u.variables&&T({},u.variables),d=this.fetch(u,n),p={next:function(f){i.reportResult(f,l)},error:function(f){i.reportError(f,l)}};return a||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=d,this.observer=p),d.addObserver(p),d.promise},e.prototype.observe=function(){this.reportResult(this.getCurrentResult(!1),this.variables)},e.prototype.reportResult=function(t,n){var i=this.getLastError();(i||this.isDifferentFromLastResult(t,n))&&((i||!t.partial||this.options.returnPartialData)&&this.updateLastResult(t,n),mn(this.observers,"next",t))},e.prototype.reportError=function(t,n){var i=T(T({},this.getLastResult()),{error:t,errors:t.graphQLErrors,networkStatus:he.error,loading:!1});this.updateLastResult(i,n),mn(this.observers,"error",this.last.error=t)},e.prototype.hasObservers=function(){return this.observers.size>0},e.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},e}(ae);Ao(Go);function du(r){var e=r.options,t=e.fetchPolicy,n=e.nextFetchPolicy;return t==="cache-and-network"||t==="network-only"?r.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(){return this.nextFetchPolicy=n,typeof n=="function"?n.apply(this,arguments):t}}):r.reobserve()}function ty(r){__DEV__&&$.error("Unhandled error",r.message,r.stack)}function hu(r){__DEV__&&r&&__DEV__&&$.debug("Missing cache result fields: ".concat(JSON.stringify(r)),r)}var Ko=function(){function r(e){var t=e.cache,n=e.client,i=e.resolvers,a=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,n&&(this.client=n),i&&this.addResolvers(i),a&&this.setFragmentMatcher(a)}return r.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(n){t.resolvers=kc(t.resolvers,n)}):this.resolvers=kc(this.resolvers,e)},r.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},r.prototype.getResolvers=function(){return this.resolvers||{}},r.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,i=e.context,a=e.variables,o=e.onlyRunForcedResolvers,s=o===void 0?!1:o;return $t(this,void 0,void 0,function(){return Ft(this,function(c){return t?[2,this.resolveDocument(t,n.data,i,a,this.fragmentMatcher,s).then(function(u){return T(T({},n),{data:u.result})})]:[2,n]})})},r.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},r.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},r.prototype.clientQuery=function(e){return ni(["client"],e)&&this.resolvers?e:null},r.prototype.serverQuery=function(e){return Tc(e)},r.prototype.prepareContext=function(e){var t=this.cache;return T(T({},e),{cache:t,getCacheKey:function(n){return t.identify(n)}})},r.prototype.addExportedVariables=function(e,t,n){return t===void 0&&(t={}),n===void 0&&(n={}),$t(this,void 0,void 0,function(){return Ft(this,function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then(function(a){return T(T({},t),a.exportedVariables)})]:[2,T({},t)]})})},r.prototype.shouldForceResolvers=function(e){var t=!1;return Ye(e,{Directive:{enter:function(n){if(n.name.value==="client"&&n.arguments&&(t=n.arguments.some(function(i){return i.name.value==="always"&&i.value.kind==="BooleanValue"&&i.value.value===!0}),t))return cn}}}),t},r.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:Ic(e),variables:t,returnPartialData:!0,optimistic:!1}).result},r.prototype.resolveDocument=function(e,t,n,i,a,o){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a=function(){return!0}),o===void 0&&(o=!1),$t(this,void 0,void 0,function(){var s,c,u,l,d,p,f,h,m,g,_;return Ft(this,function(w){return s=pn(e),c=fn(e),u=un(c),l=this.collectSelectionsToResolve(s,u),d=s.operation,p=d?d.charAt(0).toUpperCase()+d.slice(1):"Query",f=this,h=f.cache,m=f.client,g={fragmentMap:u,context:T(T({},n),{cache:h,client:m}),variables:i,fragmentMatcher:a,defaultOperationType:p,exportedVariables:{},selectionsToResolve:l,onlyRunForcedResolvers:o},_=!1,[2,this.resolveSelectionSet(s.selectionSet,_,t,g).then(function(y){return{result:y,exportedVariables:g.exportedVariables}})]})})},r.prototype.resolveSelectionSet=function(e,t,n,i){return $t(this,void 0,void 0,function(){var a,o,s,c,u,l=this;return Ft(this,function(d){return a=i.fragmentMap,o=i.context,s=i.variables,c=[n],u=function(p){return $t(l,void 0,void 0,function(){var f,h;return Ft(this,function(m){return!t&&!i.selectionsToResolve.has(p)?[2]:cr(p,s)?vt(p)?[2,this.resolveField(p,t,n,i).then(function(g){var _;typeof g<"u"&&c.push((_={},_[Tt(p)]=g,_))})]:(Sc(p)?f=p:(f=a[p.name.value],__DEV__?$(f,"No fragment named ".concat(p.name.value)):$(f,11)),f&&f.typeCondition&&(h=f.typeCondition.name.value,i.fragmentMatcher(n,h,o))?[2,this.resolveSelectionSet(f.selectionSet,t,n,i).then(function(g){c.push(g)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(u)).then(function(){return ea(c)})]})})},r.prototype.resolveField=function(e,t,n,i){return $t(this,void 0,void 0,function(){var a,o,s,c,u,l,d,p,f,h=this;return Ft(this,function(m){return n?(a=i.variables,o=e.name.value,s=Tt(e),c=o!==s,u=n[s]||n[o],l=Promise.resolve(u),(!i.onlyRunForcedResolvers||this.shouldForceResolvers(e))&&(d=n.__typename||i.defaultOperationType,p=this.resolvers&&this.resolvers[d],p&&(f=p[c?o:s],f&&(l=Promise.resolve(hi.withValue(this.cache,f,[n,ur(e,a),i.context,{field:e,fragmentMap:i.fragmentMap}]))))),[2,l.then(function(g){var _,w;if(g===void 0&&(g=u),e.directives&&e.directives.forEach(function(b){b.name.value==="export"&&b.arguments&&b.arguments.forEach(function(I){I.name.value==="as"&&I.value.kind==="StringValue"&&(i.exportedVariables[I.value.value]=g)})}),!e.selectionSet||g==null)return g;var y=(w=(_=e.directives)===null||_===void 0?void 0:_.some(function(b){return b.name.value==="client"}))!==null&&w!==void 0?w:!1;if(Array.isArray(g))return h.resolveSubSelectedArray(e,t||y,g,i);if(e.selectionSet)return h.resolveSelectionSet(e.selectionSet,t||y,g,i)})]):[2,null]})})},r.prototype.resolveSubSelectedArray=function(e,t,n,i){var a=this;return Promise.all(n.map(function(o){if(o===null)return null;if(Array.isArray(o))return a.resolveSubSelectedArray(e,t,o,i);if(e.selectionSet)return a.resolveSelectionSet(e.selectionSet,t,o,i)}))},r.prototype.collectSelectionsToResolve=function(e,t){var n=function(o){return!Array.isArray(o)},i=this.selectionsToResolveCache;function a(o){if(!i.has(o)){var s=new Set;i.set(o,s),Ye(o,{Directive:function(c,u,l,d,p){c.name.value==="client"&&p.forEach(function(f){n(f)&&Ki(f)&&s.add(f)})},FragmentSpread:function(c,u,l,d,p){var f=t[c.name.value];__DEV__?$(f,"No fragment named ".concat(c.name.value)):$(f,12);var h=a(f);h.size>0&&(p.forEach(function(m){n(m)&&Ki(m)&&s.add(m)}),s.add(c),h.forEach(function(m){s.add(m)}))}})}return i.get(o)}return a(e)},r}();var gi=new(kt?WeakMap:Map);function mu(r,e){var t=r[e];typeof t=="function"&&(r[e]=function(){return gi.set(r,(gi.get(r)+1)%1e15),t.apply(this,arguments)})}function _p(r){r.notifyTimeout&&(clearTimeout(r.notifyTimeout),r.notifyTimeout=void 0)}var Jo=function(){function r(e,t){t===void 0&&(t=e.generateQueryId()),this.queryId=t,this.listeners=new Set,this.document=null,this.lastRequestId=1,this.subscriptions=new Set,this.stopped=!1,this.dirty=!1,this.observableQuery=null;var n=this.cache=e.cache;gi.has(n)||(gi.set(n,0),mu(n,"evict"),mu(n,"modify"),mu(n,"reset"))}return r.prototype.init=function(e){var t=e.networkStatus||he.loading;return this.variables&&this.networkStatus!==he.loading&&!xe(this.variables,e.variables)&&(t=he.setVariables),xe(e.variables,this.variables)||(this.lastDiff=void 0),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},r.prototype.reset=function(){_p(this),this.dirty=!1},r.prototype.getDiff=function(e){e===void 0&&(e=this.variables);var t=this.getDiffOptions(e);if(this.lastDiff&&xe(t,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables=e);var n=this.observableQuery;if(n&&n.options.fetchPolicy==="no-cache")return{complete:!1};var i=this.cache.diff(t);return this.updateLastDiff(i,t),i},r.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},r.prototype.getDiffOptions=function(e){var t;return e===void 0&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:(t=this.observableQuery)===null||t===void 0?void 0:t.options.canonizeResults}},r.prototype.setDiff=function(e){var t=this,n=this.lastDiff&&this.lastDiff.diff;this.updateLastDiff(e),!this.dirty&&!xe(n&&n.result,e&&e.result)&&(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout(function(){return t.notify()},0)))},r.prototype.setObservableQuery=function(e){var t=this;e!==this.observableQuery&&(this.oqListener&&this.listeners.delete(this.oqListener),this.observableQuery=e,e?(e.queryInfo=this,this.listeners.add(this.oqListener=function(){var n=t.getDiff();n.fromOptimisticTransaction?e.observe():du(e)})):delete this.oqListener)},r.prototype.notify=function(){var e=this;_p(this),this.shouldNotify()&&this.listeners.forEach(function(t){return t(e)}),this.dirty=!1},r.prototype.shouldNotify=function(){if(!this.dirty||!this.listeners.size)return!1;if(Dr(this.networkStatus)&&this.observableQuery){var e=this.observableQuery.options.fetchPolicy;if(e!=="cache-only"&&e!=="cache-and-network")return!1}return!0},r.prototype.stop=function(){if(!this.stopped){this.stopped=!0,this.reset(),this.cancel(),this.cancel=r.prototype.cancel,this.subscriptions.forEach(function(t){return t.unsubscribe()});var e=this.observableQuery;e&&e.stopPolling()}},r.prototype.cancel=function(){},r.prototype.updateWatch=function(e){var t=this;e===void 0&&(e=this.variables);var n=this.observableQuery;if(!(n&&n.options.fetchPolicy==="no-cache")){var i=T(T({},this.getDiffOptions(e)),{watcher:this,callback:function(a){return t.setDiff(a)}});(!this.lastWatch||!xe(i,this.lastWatch))&&(this.cancel(),this.cancel=this.cache.watch(this.lastWatch=i))}},r.prototype.resetLastWrite=function(){this.lastWrite=void 0},r.prototype.shouldWrite=function(e,t){var n=this.lastWrite;return!(n&&n.dmCount===gi.get(this.cache)&&xe(t,n.variables)&&xe(e.data,n.result.data))},r.prototype.markResult=function(e,t,n,i){var a=this,o=new ut,s=Fe(e.errors)?e.errors.slice(0):[];if(this.reset(),"incremental"in e&&Fe(e.incremental)){var c=Oo(this.getDiff().result,e);e.data=c}else if("hasNext"in e&&e.hasNext){var u=this.getDiff();e.data=o.merge(u.result,e.data)}this.graphQLErrors=s,n.fetchPolicy==="no-cache"?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(n.variables)):i!==0&&(Zo(e,n.errorPolicy)?this.cache.performTransaction(function(l){if(a.shouldWrite(e,n.variables))l.writeQuery({query:t,data:e.data,variables:n.variables,overwrite:i===1}),a.lastWrite={result:e,variables:n.variables,dmCount:gi.get(a.cache)};else if(a.lastDiff&&a.lastDiff.diff.complete){e.data=a.lastDiff.diff.result;return}var d=a.getDiffOptions(n.variables),p=l.diff(d);a.stopped||a.updateWatch(n.variables),a.updateLastDiff(p,d),p.complete&&(e.data=p.result)}):this.lastWrite=void 0)},r.prototype.markReady=function(){return this.networkError=null,this.networkStatus=he.ready},r.prototype.markError=function(e){return this.networkStatus=he.error,this.lastWrite=void 0,this.reset(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},r}();function Zo(r,e){e===void 0&&(e="none");var t=e==="ignore"||e==="all",n=!ui(r);return!n&&t&&r.data&&(n=!0),n}var ry=Object.prototype.hasOwnProperty,Ep=function(){function r(e){var t=e.cache,n=e.link,i=e.defaultOptions,a=e.queryDeduplication,o=a===void 0?!1:a,s=e.onBroadcast,c=e.ssrMode,u=c===void 0?!1:c,l=e.clientAwareness,d=l===void 0?{}:l,p=e.localState,f=e.assumeImmutableResults;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new(kt?WeakMap:Map),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Map,this.cache=t,this.link=n,this.defaultOptions=i||Object.create(null),this.queryDeduplication=o,this.clientAwareness=d,this.localState=p||new Ko({cache:t}),this.ssrMode=u,this.assumeImmutableResults=!!f,(this.onBroadcast=s)&&(this.mutationStore=Object.create(null))}return r.prototype.stop=function(){var e=this;this.queries.forEach(function(t,n){e.stopQueryNoBroadcast(n)}),this.cancelPendingFetches(__DEV__?new X("QueryManager stopped while query was in flight"):new X(14))},r.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach(function(t){return t(e)}),this.fetchCancelFns.clear()},r.prototype.mutate=function(e){var t,n,i=e.mutation,a=e.variables,o=e.optimisticResponse,s=e.updateQueries,c=e.refetchQueries,u=c===void 0?[]:c,l=e.awaitRefetchQueries,d=l===void 0?!1:l,p=e.update,f=e.onQueryUpdated,h=e.fetchPolicy,m=h===void 0?((t=this.defaultOptions.mutate)===null||t===void 0?void 0:t.fetchPolicy)||"network-only":h,g=e.errorPolicy,_=g===void 0?((n=this.defaultOptions.mutate)===null||n===void 0?void 0:n.errorPolicy)||"none":g,w=e.keepRootFields,y=e.context;return $t(this,void 0,void 0,function(){var b,I,A,E,R,L;return Ft(this,function(N){switch(N.label){case 0:return __DEV__?$(i,"mutation option is required. You must specify your GraphQL document in the mutation option."):$(i,15),__DEV__?$(m==="network-only"||m==="no-cache","Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write."):$(m==="network-only"||m==="no-cache",16),b=this.generateMutationId(),I=this.transform(i),A=I.document,E=I.hasClientExports,i=this.cache.transformForLink(A),a=this.getVariables(i,a),E?[4,this.localState.addExportedVariables(i,a,y)]:[3,2];case 1:a=N.sent(),N.label=2;case 2:return R=this.mutationStore&&(this.mutationStore[b]={mutation:i,variables:a,loading:!0,error:null}),o&&this.markMutationOptimistic(o,{mutationId:b,document:i,variables:a,fetchPolicy:m,errorPolicy:_,context:y,updateQueries:s,update:p,keepRootFields:w}),this.broadcastQueries(),L=this,[2,new Promise(function(F,_e){return ko(L.getObservableFromLink(i,T(T({},y),{optimisticResponse:o}),a,!1),function(Ee){if(ui(Ee)&&_==="none")throw new lr({graphQLErrors:Co(Ee)});R&&(R.loading=!1,R.error=null);var O=T({},Ee);return typeof u=="function"&&(u=u(O)),_==="ignore"&&ui(O)&&delete O.errors,L.markMutationResult({mutationId:b,result:O,document:i,variables:a,fetchPolicy:m,errorPolicy:_,context:y,update:p,updateQueries:s,awaitRefetchQueries:d,refetchQueries:u,removeOptimistic:o?b:void 0,onQueryUpdated:f,keepRootFields:w})}).subscribe({next:function(Ee){L.broadcastQueries(),(!("hasNext"in Ee)||Ee.hasNext===!1)&&F(Ee)},error:function(Ee){R&&(R.loading=!1,R.error=Ee),o&&L.cache.removeOptimistic(b),L.broadcastQueries(),_e(Ee instanceof lr?Ee:new lr({networkError:Ee}))}})})]}})})},r.prototype.markMutationResult=function(e,t){var n=this;t===void 0&&(t=this.cache);var i=e.result,a=[],o=e.fetchPolicy==="no-cache";if(!o&&Zo(i,e.errorPolicy)){if(Or(i)||a.push({result:i.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),Or(i)&&Fe(i.incremental)){var s=t.diff({id:"ROOT_MUTATION",query:this.transform(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0}),c=void 0;s.result&&(c=Oo(s.result,i)),typeof c<"u"&&(i.data=c,a.push({result:c,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}))}var u=e.updateQueries;u&&this.queries.forEach(function(d,p){var f=d.observableQuery,h=f&&f.queryName;if(!(!h||!ry.call(u,h))){var m=u[h],g=n.queries.get(p),_=g.document,w=g.variables,y=t.diff({query:_,variables:w,returnPartialData:!0,optimistic:!1}),b=y.result,I=y.complete;if(I&&b){var A=m(b,{mutationResult:i,queryName:_&&ai(_)||void 0,queryVariables:w});A&&a.push({result:A,dataId:"ROOT_QUERY",query:_,variables:w})}}})}if(a.length>0||e.refetchQueries||e.update||e.onQueryUpdated||e.removeOptimistic){var l=[];if(this.refetchQueries({updateCache:function(d){o||a.forEach(function(m){return d.write(m)});var p=e.update,f=!of(i)||Or(i)&&!i.hasNext;if(p){if(!o){var h=d.diff({id:"ROOT_MUTATION",query:n.transform(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0});h.complete&&(i=T(T({},i),{data:h.result}),"incremental"in i&&delete i.incremental,"hasNext"in i&&delete i.hasNext)}f&&p(d,i,{context:e.context,variables:e.variables})}!o&&!e.keepRootFields&&f&&d.modify({id:"ROOT_MUTATION",fields:function(m,g){var _=g.fieldName,w=g.DELETE;return _==="__typename"?m:w}})},include:e.refetchQueries,optimistic:!1,removeOptimistic:e.removeOptimistic,onQueryUpdated:e.onQueryUpdated||null}).forEach(function(d){return l.push(d)}),e.awaitRefetchQueries||e.onQueryUpdated)return Promise.all(l).then(function(){return i})}return Promise.resolve(i)},r.prototype.markMutationOptimistic=function(e,t){var n=this,i=typeof e=="function"?e(t.variables):e;return this.cache.recordOptimisticTransaction(function(a){try{n.markMutationResult(T(T({},t),{result:{data:i}}),a)}catch(o){__DEV__&&$.error(o)}},t.mutationId)},r.prototype.fetchQuery=function(e,t,n){return this.fetchQueryObservable(e,t,n).promise},r.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach(function(t,n){e[n]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}}),e},r.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},r.prototype.transform=function(e){var t=this.transformCache;if(!t.has(e)){var n=this.cache.transformDocument(e),i=xc(n),a=this.localState.clientQuery(n),o=i&&this.localState.serverQuery(i),s={document:n,hasClientExports:yc(n),hasForcedResolvers:this.localState.shouldForceResolvers(n),clientQuery:a,serverQuery:o,defaultVars:dn(Wt(n)),asQuery:T(T({},n),{definitions:n.definitions.map(function(u){return u.kind==="OperationDefinition"&&u.operation!=="query"?T(T({},u),{operation:"query"}):u})})},c=function(u){u&&!t.has(u)&&t.set(u,s)};c(e),c(n),c(a),c(o)}return t.get(e)},r.prototype.getVariables=function(e,t){return T(T({},this.transform(e).defaultVars),t)},r.prototype.watchQuery=function(e){e=T(T({},e),{variables:this.getVariables(e.query,e.variables)}),typeof e.notifyOnNetworkStatusChange>"u"&&(e.notifyOnNetworkStatusChange=!1);var t=new Jo(this),n=new Go({queryManager:this,queryInfo:t,options:e});return this.queries.set(n.queryId,t),t.init({document:n.query,observableQuery:n,variables:n.variables}),n},r.prototype.query=function(e,t){var n=this;return t===void 0&&(t=this.generateQueryId()),__DEV__?$(e.query,"query option is required. You must specify your GraphQL document in the query option."):$(e.query,17),__DEV__?$(e.query.kind==="Document",'You must wrap the query string in a "gql" tag.'):$(e.query.kind==="Document",18),__DEV__?$(!e.returnPartialData,"returnPartialData option only supported on watchQuery."):$(!e.returnPartialData,19),__DEV__?$(!e.pollInterval,"pollInterval option only supported on watchQuery."):$(!e.pollInterval,20),this.fetchQuery(t,e).finally(function(){return n.stopQuery(t)})},r.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},r.prototype.generateRequestId=function(){return this.requestIdCounter++},r.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},r.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},r.prototype.clearStore=function(e){return e===void 0&&(e={discardWatches:!0}),this.cancelPendingFetches(__DEV__?new X("Store reset while query was in flight (not completed in link chain)"):new X(21)),this.queries.forEach(function(t){t.observableQuery?t.networkStatus=he.loading:t.stop()}),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},r.prototype.getObservableQueries=function(e){var t=this;e===void 0&&(e="active");var n=new Map,i=new Map,a=new Set;return Array.isArray(e)&&e.forEach(function(o){typeof o=="string"?i.set(o,!1):bc(o)?i.set(t.transform(o).document,!1):le(o)&&o.query&&a.add(o)}),this.queries.forEach(function(o,s){var c=o.observableQuery,u=o.document;if(c){if(e==="all"){n.set(s,c);return}var l=c.queryName,d=c.options.fetchPolicy;if(d==="standby"||e==="active"&&!c.hasObservers())return;(e==="active"||l&&i.has(l)||u&&i.has(u))&&(n.set(s,c),l&&i.set(l,!0),u&&i.set(u,!0))}}),a.size&&a.forEach(function(o){var s=na("legacyOneTimeQuery"),c=t.getQuery(s).init({document:o.query,variables:o.variables}),u=new Go({queryManager:t,queryInfo:c,options:T(T({},o),{fetchPolicy:"network-only"})});$(u.queryId===s),c.setObservableQuery(u),n.set(s,u)}),__DEV__&&i.size&&i.forEach(function(o,s){o||__DEV__&&$.warn("Unknown query ".concat(typeof s=="string"?"named ":"").concat(JSON.stringify(s,null,2)," requested in refetchQueries options.include array"))}),n},r.prototype.reFetchObservableQueries=function(e){var t=this;e===void 0&&(e=!1);var n=[];return this.getObservableQueries(e?"all":"active").forEach(function(i,a){var o=i.options.fetchPolicy;i.resetLastResults(),(e||o!=="standby"&&o!=="cache-only")&&n.push(i.refetch()),t.getQuery(a).setDiff(null)}),this.broadcastQueries(),Promise.all(n)},r.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},r.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,i=e.fetchPolicy,a=e.errorPolicy,o=e.variables,s=e.context,c=s===void 0?{}:s;n=this.transform(n).document,o=this.getVariables(n,o);var u=function(d){return t.getObservableFromLink(n,c,d).map(function(p){if(i!=="no-cache"&&(Zo(p,a)&&t.cache.write({query:n,result:p.data,dataId:"ROOT_SUBSCRIPTION",variables:d}),t.broadcastQueries()),ui(p))throw new lr({graphQLErrors:p.errors});return p})};if(this.transform(n).hasClientExports){var l=this.localState.addExportedVariables(n,o,c).then(u);return new ae(function(d){var p=null;return l.then(function(f){return p=f.subscribe(d)},d.error),function(){return p&&p.unsubscribe()}})}return u(o)},r.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},r.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.queries.has(e)&&(this.getQuery(e).stop(),this.queries.delete(e))},r.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach(function(e){return e.notify()})},r.prototype.getLocalState=function(){return this.localState},r.prototype.getObservableFromLink=function(e,t,n,i){var a=this,o;i===void 0&&(i=(o=t?.queryDeduplication)!==null&&o!==void 0?o:this.queryDeduplication);var s,c=this.transform(e).serverQuery;if(c){var u=this,l=u.inFlightLinkObservables,d=u.link,p={query:c,variables:n,operationName:ai(c)||void 0,context:this.prepareContext(T(T({},t),{forceFetch:!i}))};if(t=p.context,i){var f=l.get(c)||new Map;l.set(c,f);var h=bt(n);if(s=f.get(h),!s){var m=new ci([li(d,p)]);f.set(h,s=m),m.beforeNext(function(){f.delete(h)&&f.size<1&&l.delete(c)})}}else s=new ci([li(d,p)])}else s=new ci([ae.of({data:{}})]),t=this.prepareContext(t);var g=this.transform(e).clientQuery;return g&&(s=ko(s,function(_){return a.localState.runResolvers({document:g,remoteResult:_,context:t,variables:n})})),s},r.prototype.getResultsFromLink=function(e,t,n){var i=e.lastRequestId=this.generateRequestId(),a=this.cache.transformForLink(this.transform(e.document).document);return ko(this.getObservableFromLink(a,n.context,n.variables),function(o){var s=Co(o),c=s.length>0;if(i>=e.lastRequestId){if(c&&n.errorPolicy==="none")throw e.markError(new lr({graphQLErrors:s}));e.markResult(o,a,n,t),e.markReady()}var u={data:o.data,loading:!1,networkStatus:he.ready};return c&&n.errorPolicy!=="ignore"&&(u.errors=s,u.networkStatus=he.error),u},function(o){var s=Sp(o)?o:new lr({networkError:o});throw i>=e.lastRequestId&&e.markError(s),s})},r.prototype.fetchQueryObservable=function(e,t,n){var i=this;n===void 0&&(n=he.loading);var a=this.transform(t.query).document,o=this.getVariables(a,t.variables),s=this.getQuery(e),c=this.defaultOptions.watchQuery,u=t.fetchPolicy,l=u===void 0?c&&c.fetchPolicy||"cache-first":u,d=t.errorPolicy,p=d===void 0?c&&c.errorPolicy||"none":d,f=t.returnPartialData,h=f===void 0?!1:f,m=t.notifyOnNetworkStatusChange,g=m===void 0?!1:m,_=t.context,w=_===void 0?{}:_,y=Object.assign({},t,{query:a,variables:o,fetchPolicy:l,errorPolicy:p,returnPartialData:h,notifyOnNetworkStatusChange:g,context:w}),b=function(E){y.variables=E;var R=i.fetchQueryByPolicy(s,y,n);return y.fetchPolicy!=="standby"&&R.length>0&&s.observableQuery&&s.observableQuery.applyNextFetchPolicy("after-fetch",t),R},I=function(){return i.fetchCancelFns.delete(e)};this.fetchCancelFns.set(e,function(E){I(),setTimeout(function(){return A.cancel(E)})});var A=new ci(this.transform(y.query).hasClientExports?this.localState.addExportedVariables(y.query,y.variables,y.context).then(b):b(y.variables));return A.promise.then(I,I),A},r.prototype.refetchQueries=function(e){var t=this,n=e.updateCache,i=e.include,a=e.optimistic,o=a===void 0?!1:a,s=e.removeOptimistic,c=s===void 0?o?na("refetchQueries"):void 0:s,u=e.onQueryUpdated,l=new Map;i&&this.getObservableQueries(i).forEach(function(p,f){l.set(f,{oq:p,lastDiff:t.getQuery(f).getDiff()})});var d=new Map;return n&&this.cache.batch({update:n,optimistic:o&&c||!1,removeOptimistic:c,onWatchUpdated:function(p,f,h){var m=p.watcher instanceof Jo&&p.watcher.observableQuery;if(m){if(u){l.delete(m.queryId);var g=u(m,f,h);return g===!0&&(g=m.refetch()),g!==!1&&d.set(m,g),g}u!==null&&l.set(m.queryId,{oq:m,lastDiff:h,diff:f})}}}),l.size&&l.forEach(function(p,f){var h=p.oq,m=p.lastDiff,g=p.diff,_;if(u){if(!g){var w=h.queryInfo;w.reset(),g=w.getDiff()}_=u(h,g,m)}(!u||_===!0)&&(_=h.refetch()),_!==!1&&d.set(h,_),f.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(f)}),c&&this.cache.removeOptimistic(c),d},r.prototype.fetchQueryByPolicy=function(e,t,n){var i=this,a=t.query,o=t.variables,s=t.fetchPolicy,c=t.refetchWritePolicy,u=t.errorPolicy,l=t.returnPartialData,d=t.context,p=t.notifyOnNetworkStatusChange,f=e.networkStatus;e.init({document:this.transform(a).document,variables:o,networkStatus:n});var h=function(){return e.getDiff(o)},m=function(b,I){I===void 0&&(I=e.networkStatus||he.loading);var A=b.result;__DEV__&&!l&&!xe(A,{})&&hu(b.missing);var E=function(R){return ae.of(T({data:R,loading:Dr(I),networkStatus:I},b.complete?null:{partial:!0}))};return A&&i.transform(a).hasForcedResolvers?i.localState.runResolvers({document:a,remoteResult:{data:A},context:d,variables:o,onlyRunForcedResolvers:!0}).then(function(R){return E(R.data||void 0)}):u==="none"&&I===he.refetch&&Array.isArray(b.missing)?E(void 0):E(A)},g=s==="no-cache"?0:n===he.refetch&&c!=="merge"?1:2,_=function(){return i.getResultsFromLink(e,g,{variables:o,context:d,fetchPolicy:s,errorPolicy:u})},w=p&&typeof f=="number"&&f!==n&&Dr(n);switch(s){default:case"cache-first":{var y=h();return y.complete?[m(y,e.markReady())]:l||w?[m(y),_()]:[_()]}case"cache-and-network":{var y=h();return y.complete||l||w?[m(y),_()]:[_()]}case"cache-only":return[m(h(),e.markReady())];case"network-only":return w?[m(h()),_()]:[_()];case"no-cache":return w?[m(e.getDiff()),_()]:[_()];case"standby":return[]}},r.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new Jo(this,e)),this.queries.get(e)},r.prototype.prepareContext=function(e){e===void 0&&(e={});var t=this.localState.prepareContext(e);return T(T({},t),{clientAwareness:this.clientAwareness})},r}();var xp=!1;var gu=function(){function r(e){var t=this;this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.uri,i=e.credentials,a=e.headers,o=e.cache,s=e.ssrMode,c=s===void 0?!1:s,u=e.ssrForceFetchDelay,l=u===void 0?0:u,d=e.connectToDevTools,p=d===void 0?typeof window=="object"&&!window.__APOLLO_CLIENT__&&__DEV__:d,f=e.queryDeduplication,h=f===void 0?!0:f,m=e.defaultOptions,g=e.assumeImmutableResults,_=g===void 0?!1:g,w=e.resolvers,y=e.typeDefs,b=e.fragmentMatcher,I=e.name,A=e.version,E=e.link;if(E||(E=n?new Qc({uri:n,credentials:i,headers:a}):At.empty()),!o)throw __DEV__?new X(`To initialize Apollo Client, you must specify a 'cache' property in the options object.
|
|
51
|
-
For more information, please visit: https://go.apollo.dev/c/docs`):new X(9);if(this.link=E,this.cache=o,this.disableNetworkFetches=c||l>0,this.queryDeduplication=h,this.defaultOptions=m||Object.create(null),this.typeDefs=y,l&&setTimeout(function(){return t.disableNetworkFetches=!1},l),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),p&&typeof window=="object"&&(window.__APOLLO_CLIENT__=this),!xp&&p&&__DEV__&&(xp=!0,typeof window<"u"&&window.document&&window.top===window.self&&!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__)){var R=window.navigator,L=R&&R.userAgent,N=void 0;typeof L=="string"&&(L.indexOf("Chrome/")>-1?N="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":L.indexOf("Firefox/")>-1&&(N="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),N&&__DEV__&&$.log("Download the Apollo DevTools for a better development experience: "+N)}this.version=lf,this.localState=new Ko({cache:o,client:this,resolvers:w,fragmentMatcher:b}),this.queryManager=new Ep({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,queryDeduplication:h,ssrMode:c,clientAwareness:{name:I,version:A},localState:this.localState,assumeImmutableResults:_,onBroadcast:p?function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.getQueryStore(),mutations:t.queryManager.mutationStore||{}},dataWithOptimisticResults:t.cache.extract(!0)})}:void 0})}return r.prototype.stop=function(){this.queryManager.stop()},r.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=ia(this.defaultOptions.watchQuery,e)),this.disableNetworkFetches&&(e.fetchPolicy==="network-only"||e.fetchPolicy==="cache-and-network")&&(e=T(T({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},r.prototype.query=function(e){return this.defaultOptions.query&&(e=ia(this.defaultOptions.query,e)),__DEV__?$(e.fetchPolicy!=="cache-and-network","The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."):$(e.fetchPolicy!=="cache-and-network",10),this.disableNetworkFetches&&e.fetchPolicy==="network-only"&&(e=T(T({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},r.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=ia(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},r.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},r.prototype.readQuery=function(e,t){return t===void 0&&(t=!1),this.cache.readQuery(e,t)},r.prototype.readFragment=function(e,t){return t===void 0&&(t=!1),this.cache.readFragment(e,t)},r.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},r.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},r.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},r.prototype.__requestRaw=function(e){return li(this.link,e)},r.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!1})}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(t){return t()}))}).then(function(){return e.reFetchObservableQueries()})},r.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!0})}).then(function(){return Promise.all(e.clearStoreCallbacks.map(function(t){return t()}))})},r.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(n){return n!==e})}},r.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(n){return n!==e})}},r.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},r.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),n=[],i=[];t.forEach(function(o,s){n.push(s),i.push(o)});var a=Promise.all(i);return a.queries=n,a.results=i,a.catch(function(o){__DEV__&&$.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(o))}),a},r.prototype.getObservableQueries=function(e){return e===void 0&&(e="active"),this.queryManager.getObservableQueries(e)},r.prototype.extract=function(e){return this.cache.extract(e)},r.prototype.restore=function(e){return this.cache.restore(e)},r.prototype.addResolvers=function(e){this.localState.addResolvers(e)},r.prototype.setResolvers=function(e){this.localState.setResolvers(e)},r.prototype.getResolvers=function(){return this.localState.getResolvers()},r.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},r.prototype.setLink=function(e){this.link=this.queryManager.link=e},r}();Ll(sn?"log":"silent");function tt(r){return r===null?"null":Array.isArray(r)?"array":typeof r}function fr(r){return tt(r)==="object"}function Ip(r){return Array.isArray(r)&&r.length>0&&r.every(e=>"message"in e)}function yu(r,e){return r.length<124?r:e}var Tp="graphql-transport-ws";var lt;(function(r){r[r.InternalServerError=4500]="InternalServerError",r[r.InternalClientError=4005]="InternalClientError",r[r.BadRequest=4400]="BadRequest",r[r.BadResponse=4004]="BadResponse",r[r.Unauthorized=4401]="Unauthorized",r[r.Forbidden=4403]="Forbidden",r[r.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",r[r.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",r[r.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",r[r.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",r[r.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(lt||(lt={}));var Ce;(function(r){r.ConnectionInit="connection_init",r.ConnectionAck="connection_ack",r.Ping="ping",r.Pong="pong",r.Subscribe="subscribe",r.Next="next",r.Error="error",r.Complete="complete"})(Ce||(Ce={}));function kp(r){if(!fr(r))throw new Error(`Message is expected to be an object, but got ${tt(r)}`);if(!r.type)throw new Error("Message is missing the 'type' property");if(typeof r.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${tt(r.type)}`);switch(r.type){case Ce.ConnectionInit:case Ce.ConnectionAck:case Ce.Ping:case Ce.Pong:{if(r.payload!=null&&!fr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${r.payload}"`);break}case Ce.Subscribe:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${tt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!fr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object, but got ${tt(r.payload)}`);if(typeof r.payload.query!="string")throw new Error(`"${r.type}" message payload expects the 'query' property to be a string, but got ${tt(r.payload.query)}`);if(r.payload.variables!=null&&!fr(r.payload.variables))throw new Error(`"${r.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${tt(r.payload.variables)}`);if(r.payload.operationName!=null&&tt(r.payload.operationName)!=="string")throw new Error(`"${r.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${tt(r.payload.operationName)}`);if(r.payload.extensions!=null&&!fr(r.payload.extensions))throw new Error(`"${r.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${tt(r.payload.extensions)}`);break}case Ce.Next:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${tt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!fr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object, but got ${tt(r.payload)}`);break}case Ce.Error:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${tt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!Ip(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(r.payload)}`);break}case Ce.Complete:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${tt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${r.type}"`)}return r}function Ap(r,e){return kp(typeof r=="string"?JSON.parse(r,e):r)}function yi(r,e){return kp(r),JSON.stringify(r,e)}function vu(r){let{url:e,connectionParams:t,lazy:n=!0,onNonLazyError:i=console.error,lazyCloseTimeout:a=0,keepAlive:o=0,disablePong:s,connectionAckWaitTimeout:c=0,retryAttempts:u=5,retryWait:l=async function(ge){let ye=1e3;for(let ne=0;ne<ge;ne++)ye*=2;await new Promise(ne=>setTimeout(ne,ye+Math.floor(Math.random()*(3e3-300)+300)))},shouldRetry:d=Yo,isFatalConnectionProblem:p,on:f,webSocketImpl:h,generateID:m=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,ge=>{let ye=Math.random()*16|0;return(ge=="x"?ye:ye&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:_}=r,w;if(h){if(!iy(h))throw new Error("Invalid WebSocket implementation provided");w=h}else typeof WebSocket<"u"?w=WebSocket:typeof global<"u"?w=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(w=window.WebSocket||window.MozWebSocket);if(!w)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let y=w,b=(()=>{let O=(()=>{let ye={};return{on(ne,ue){return ye[ne]=ue,()=>{delete ye[ne]}},emit(ne){var ue;"id"in ne&&((ue=ye[ne.id])===null||ue===void 0||ue.call(ye,ne))}}})(),ge={connecting:f?.connecting?[f.connecting]:[],opened:f?.opened?[f.opened]:[],connected:f?.connected?[f.connected]:[],ping:f?.ping?[f.ping]:[],pong:f?.pong?[f.pong]:[],message:f?.message?[O.emit,f.message]:[O.emit],closed:f?.closed?[f.closed]:[],error:f?.error?[f.error]:[]};return{onMessage:O.on,on(ye,ne){let ue=ge[ye];return ue.push(ne),()=>{ue.splice(ue.indexOf(ne),1)}},emit(ye,...ne){for(let ue of[...ge[ye]])ue(...ne)}}})();function I(O){let ge=[b.on("error",ye=>{ge.forEach(ne=>ne()),O(ye)}),b.on("closed",ye=>{ge.forEach(ne=>ne()),O(ye)})]}let A,E=0,R,L=!1,N=0,F=!1;async function _e(){clearTimeout(R);let[O,ge]=await(A??(A=new Promise((ue,Vt)=>(async()=>{if(L){if(await l(N),!E)return A=void 0,Vt({code:1e3,reason:"All Subscriptions Gone"});N++}b.emit("connecting");let ie=new y(typeof e=="function"?await e():e,Tp),Qt,xr;function mo(){isFinite(o)&&o>0&&(clearTimeout(xr),xr=setTimeout(()=>{ie.readyState===y.OPEN&&(ie.send(yi({type:Ce.Ping})),b.emit("ping",!1,void 0))},o))}I(He=>{A=void 0,clearTimeout(Qt),clearTimeout(xr),Vt(He),Yo(He)&&He.code===4499&&(ie.close(4499,"Terminated"),ie.onerror=null,ie.onclose=null)}),ie.onerror=He=>b.emit("error",He),ie.onclose=He=>b.emit("closed",He),ie.onopen=async()=>{try{b.emit("opened",ie);let He=typeof t=="function"?await t():t;if(ie.readyState!==y.OPEN)return;ie.send(yi(He?{type:Ce.ConnectionInit,payload:He}:{type:Ce.ConnectionInit},g)),isFinite(c)&&c>0&&(Qt=setTimeout(()=>{ie.close(lt.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),mo()}catch(He){b.emit("error",He),ie.close(lt.InternalClientError,yu(He instanceof Error?He.message:new Error(He).message,"Internal client error"))}};let ti=!1;ie.onmessage=({data:He})=>{try{let We=Ap(He,_);if(b.emit("message",We),We.type==="ping"||We.type==="pong"){b.emit(We.type,!0,We.payload),We.type==="pong"?mo():s||(ie.send(yi(We.payload?{type:Ce.Pong,payload:We.payload}:{type:Ce.Pong})),b.emit("pong",!1,We.payload));return}if(ti)return;if(We.type!==Ce.ConnectionAck)throw new Error(`First message cannot be of type ${We.type}`);clearTimeout(Qt),ti=!0,b.emit("connected",ie,We.payload),L=!1,N=0,ue([ie,new Promise((n_,pm)=>I(pm))])}catch(We){ie.onmessage=null,b.emit("error",We),ie.close(lt.BadResponse,yu(We instanceof Error?We.message:new Error(We).message,"Bad response"))}}})())));O.readyState===y.CLOSING&&await ge;let ye=()=>{},ne=new Promise(ue=>ye=ue);return[O,ye,Promise.race([ne.then(()=>{if(!E){let ue=()=>O.close(1e3,"Normal Closure");isFinite(a)&&a>0?R=setTimeout(()=>{O.readyState===y.OPEN&&ue()},a):ue()}}),ge])]}function Ee(O){if(Yo(O)&&(ny(O.code)||[lt.InternalServerError,lt.InternalClientError,lt.BadRequest,lt.BadResponse,lt.Unauthorized,lt.SubprotocolNotAcceptable,lt.SubscriberAlreadyExists,lt.TooManyInitialisationRequests].includes(O.code)))throw O;if(F)return!1;if(Yo(O)&&O.code===1e3)return E>0;if(!u||N>=u||!d(O)||p?.(O))throw O;return L=!0}return n||(async()=>{for(E++;;)try{let[,,O]=await _e();await O}catch(O){try{if(!Ee(O))return}catch(ge){return i?.(ge)}}})(),{on:b.on,subscribe(O,ge){let ye=m(O),ne=!1,ue=!1,Vt=()=>{E--,ne=!0};return(async()=>{for(E++;;)try{let[ie,Qt,xr]=await _e();if(ne)return Qt();let mo=b.onMessage(ye,ti=>{switch(ti.type){case Ce.Next:{ge.next(ti.payload);return}case Ce.Error:{ue=!0,ne=!0,ge.error(ti.payload),Vt();return}case Ce.Complete:{ne=!0,Vt();return}}});ie.send(yi({id:ye,type:Ce.Subscribe,payload:O},g)),Vt=()=>{!ne&&ie.readyState===y.OPEN&&ie.send(yi({id:ye,type:Ce.Complete},g)),E--,ne=!0,Qt()},await xr.finally(mo);return}catch(ie){if(!Ee(ie))return}})().then(()=>{ue||ge.complete()}).catch(ie=>{ge.error(ie)}),()=>{ne||Vt()}},async dispose(){if(F=!0,A){let[O]=await A;O.close(1e3,"Normal Closure")}},terminate(){A&&b.emit("closed",{code:4499,reason:"Terminated",wasClean:!1})}}}function Yo(r){return fr(r)&&"code"in r&&"reason"in r}function ny(r){return[1e3,1001,1006,1005,1012,1013,1013].includes(r)?!1:r>=1e3&&r<=1999}function iy(r){return typeof r=="function"&&"constructor"in r&&"CLOSED"in r&&"CLOSING"in r&&"CONNECTING"in r&&"OPEN"in r}function ay(r){return le(r)&&"code"in r&&"reason"in r}var Op=function(r){Ae(e,r);function e(t){var n=r.call(this)||this;return n.client=t,n}return e.prototype.request=function(t){var n=this;return new ae(function(i){return n.client.subscribe(T(T({},t),{query:ri(t.query)}),{next:i.next.bind(i),complete:i.complete.bind(i),error:function(a){return a instanceof Error?i.error(a):ay(a)?i.error(new Error("Socket closed with event ".concat(a.code," ").concat(a.reason||""))):i.error(new lr({graphQLErrors:Array.isArray(a)?a:[a]}))}})})},e}(At);var Xo="0.13.0-test-2";function Cp(){return typeof window!="undefined"&&window.self!==window.top}function bu(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(r){return!1}return!0}function Kt(r,e){bu()&&localStorage.setItem(`${Xo}/${r}`,e)}function pa(r){return bu()?localStorage.getItem(`${Xo}/${r}`):null}function vi(r){bu()&&localStorage.removeItem(`${Xo}/${r}`)}function Rp(r,e=1e4){return fe(this,null,function*(){return Promise.race([new Promise((t,n)=>{let i;try{i=new WebSocket(r,"graphql-transport-ws"),i.onopen=()=>{i.close(),t(i)},i.onerror=a=>{n(a)},i.onclose=a=>{a.code!==1e3&&n(new Error(`WebSocket closed with code ${a.code}: ${a.reason}`))}}catch(a){i&&i.close(),n(a)}}),new Promise((t,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},e)})])})}var As=function(){return As=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},As.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function ps(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ps=function(t){return typeof t}:ps=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ps(r)}function sy(r){return ps(r)=="object"&&r!==null}var rh=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";function qu(r,e){for(var t=/\r\n|[\n\r]/g,n=1,i=e+1,a;(a=t.exec(r.body))&&a.index<e;)n+=1,i=e+1-(a.index+a[0].length);return{line:n,column:i}}function cy(r){return nh(r.source,qu(r.source,r.start))}function nh(r,e){var t=r.locationOffset.column-1,n=ds(t)+r.body,i=e.line-1,a=r.locationOffset.line-1,o=e.line+a,s=e.line===1?t:0,c=e.column+s,u="".concat(r.name,":").concat(o,":").concat(c,`
|
|
52
|
-
`),l=n.split(/\r\n|[\n\r]/g),d=l[i];if(d.length>120){for(var p=Math.floor(c/80),f=c%80,h=[],m=0;m<d.length;m+=80)h.push(d.slice(m,m+80));return u+Pp([["".concat(o),h[0]]].concat(h.slice(1,p+1).map(function(g){return["",g]}),[[" ",ds(f-1)+"^"],["",h[p+1]]]))}return u+Pp([["".concat(o-1),l[i-1]],["".concat(o),d],["",ds(c-1)+"^"],["".concat(o+1),l[i+1]]])}function Pp(r){var e=r.filter(function(n){n[0];var i=n[1];return i!==void 0}),t=Math.max.apply(Math,e.map(function(n){var i=n[0];return i.length}));return e.map(function(n){var i=n[0],a=n[1];return uy(t,i)+(a?" | "+a:" |")}).join(`
|
|
53
|
-
`)}function ds(r){return Array(r+1).join(" ")}function uy(r,e){return ds(r-e.length)+e}function hs(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?hs=function(t){return typeof t}:hs=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hs(r)}function Np(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function ly(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Np(Object(t),!0).forEach(function(n){fy(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Np(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function fy(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function py(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Dp(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function dy(r,e,t){return e&&Dp(r.prototype,e),t&&Dp(r,t),r}function hy(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&Wa(r,e)}function my(r){var e=ah();return function(){var n=Ga(r),i;if(e){var a=Ga(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ih(this,i)}}function ih(r,e){return e&&(hs(e)==="object"||typeof e=="function")?e:va(r)}function va(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Bu(r){var e=typeof Map=="function"?new Map:void 0;return Bu=function(n){if(n===null||!gy(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(n))return e.get(n);e.set(n,i)}function i(){return ms(n,arguments,Ga(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Wa(i,n)},Bu(r)}function ms(r,e,t){return ah()?ms=Reflect.construct:ms=function(i,a,o){var s=[null];s.push.apply(s,a);var c=Function.bind.apply(i,s),u=new c;return o&&Wa(u,o.prototype),u},ms.apply(null,arguments)}function ah(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function gy(r){return Function.toString.call(r).indexOf("[native code]")!==-1}function Wa(r,e){return Wa=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Wa(r,e)}function Ga(r){return Ga=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ga(r)}var yy=function(r){hy(t,r);var e=my(t);function t(n,i,a,o,s,c,u){var l,d,p,f;py(this,t),f=e.call(this,n),f.name="GraphQLError",f.originalError=c??void 0,f.nodes=Lp(Array.isArray(i)?i:i?[i]:void 0);for(var h=[],m=0,g=(_=f.nodes)!==null&&_!==void 0?_:[];m<g.length;m++){var _,w=g[m],y=w.loc;y!=null&&h.push(y)}h=Lp(h),f.source=a??((l=h)===null||l===void 0?void 0:l[0].source),f.positions=o??((d=h)===null||d===void 0?void 0:d.map(function(I){return I.start})),f.locations=o&&a?o.map(function(I){return qu(a,I)}):(p=h)===null||p===void 0?void 0:p.map(function(I){return qu(I.source,I.start)}),f.path=s??void 0;var b=c?.extensions;return u==null&&sy(b)?f.extensions=ly({},b):f.extensions=u??{},Object.defineProperties(va(f),{message:{enumerable:!0},locations:{enumerable:f.locations!=null},path:{enumerable:f.path!=null},extensions:{enumerable:f.extensions!=null&&Object.keys(f.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),c!=null&&c.stack?(Object.defineProperty(va(f),"stack",{value:c.stack,writable:!0,configurable:!0}),ih(f)):(Error.captureStackTrace?Error.captureStackTrace(va(f),t):Object.defineProperty(va(f),"stack",{value:Error().stack,writable:!0,configurable:!0}),f)}return dy(t,[{key:"toString",value:function(){return vy(this)}},{key:rh,get:function(){return"Object"}}]),t}(Bu(Error));function Lp(r){return r===void 0||r.length===0?void 0:r}function vy(r){var e=r.message;if(r.nodes)for(var t=0,n=r.nodes;t<n.length;t++){var i=n[t];i.loc&&(e+=`
|
|
54
|
-
|
|
55
|
-
`+cy(i.loc))}else if(r.source&&r.locations)for(var a=0,o=r.locations;a<o.length;a++){var s=o[a];e+=`
|
|
56
|
-
|
|
57
|
-
`+nh(r.source,s)}return e}function St(r,e,t){return new yy("Syntax Error: ".concat(t),void 0,r,[e])}var J=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function by(r,e){var t=Boolean(r);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var wy=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,Vu=wy;function oh(r){var e=r.prototype.toJSON;typeof e=="function"||by(0),r.prototype.inspect=e,Vu&&(r.prototype[Vu]=e)}var sh=function(){function r(t,n,i){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=i}var e=r.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},r}();oh(sh);var Ne=function(){function r(t,n,i,a,o,s,c){this.kind=t,this.start=n,this.end=i,this.line=a,this.column=o,this.value=c,this.prev=s,this.next=null}var e=r.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},r}();oh(Ne);var D=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function gs(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?gs=function(t){return typeof t}:gs=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gs(r)}var Sy=10,ch=2;function _y(r){return Ys(r,[])}function Ys(r,e){switch(gs(r)){case"string":return JSON.stringify(r);case"function":return r.name?"[function ".concat(r.name,"]"):"[function]";case"object":return r===null?"null":Ey(r,e);default:return String(r)}}function Ey(r,e){if(e.indexOf(r)!==-1)return"[Circular]";var t=[].concat(e,[r]),n=Ty(r);if(n!==void 0){var i=n.call(r);if(i!==r)return typeof i=="string"?i:Ys(i,t)}else if(Array.isArray(r))return Iy(r,t);return xy(r,t)}function xy(r,e){var t=Object.keys(r);if(t.length===0)return"{}";if(e.length>ch)return"["+ky(r)+"]";var n=t.map(function(i){var a=Ys(r[i],e);return i+": "+a});return"{ "+n.join(", ")+" }"}function Iy(r,e){if(r.length===0)return"[]";if(e.length>ch)return"[Array]";for(var t=Math.min(Sy,r.length),n=r.length-t,i=[],a=0;a<t;++a)i.push(Ys(r[a],e));return n===1?i.push("... 1 more item"):n>1&&i.push("... ".concat(n," more items")),"["+i.join(", ")+"]"}function Ty(r){var e=r[String(Vu)];if(typeof e=="function")return e;if(typeof r.inspect=="function")return r.inspect}function ky(r){var e=Object.prototype.toString.call(r).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof r.constructor=="function"){var t=r.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function wu(r,e){var t=Boolean(r);if(!t)throw new Error(e)}var Ay=function(e,t){return e instanceof t};function $p(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function Oy(r,e,t){return e&&$p(r.prototype,e),t&&$p(r,t),r}var uh=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||wu(0,"Body must be a string. Received: ".concat(_y(e),".")),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||wu(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||wu(0,"column in locationOffset is 1-indexed and must be positive.")}return Oy(r,[{key:rh,get:function(){return"Source"}}]),r}();function Cy(r){return Ay(r,uh)}var Ry=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function Py(r){var e=r.split(/\r\n|[\n\r]/g),t=Ny(r);if(t!==0)for(var n=1;n<e.length;n++)e[n]=e[n].slice(t);for(var i=0;i<e.length&&Fp(e[i]);)++i;for(var a=e.length;a>i&&Fp(e[a-1]);)--a;return e.slice(i,a).join(`
|
|
58
|
-
`)}function Fp(r){for(var e=0;e<r.length;++e)if(r[e]!==" "&&r[e]!==" ")return!1;return!0}function Ny(r){for(var e,t=!0,n=!0,i=0,a=null,o=0;o<r.length;++o)switch(r.charCodeAt(o)){case 13:r.charCodeAt(o+1)===10&&++o;case 10:t=!1,n=!0,i=0;break;case 9:case 32:++i;break;default:n&&!t&&(a===null||i<a)&&(a=i),n=!1}return(e=a)!==null&&e!==void 0?e:0}var Dy=function(){function r(t){var n=new Ne(D.SOF,0,0,0,0,null);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}var e=r.prototype;return e.advance=function(){this.lastToken=this.token;var n=this.token=this.lookahead();return n},e.lookahead=function(){var n=this.token;if(n.kind!==D.EOF)do{var i;n=(i=n.next)!==null&&i!==void 0?i:n.next=$y(this,n)}while(n.kind===D.COMMENT);return n},r}();function Ly(r){return r===D.BANG||r===D.DOLLAR||r===D.AMP||r===D.PAREN_L||r===D.PAREN_R||r===D.SPREAD||r===D.COLON||r===D.EQUALS||r===D.AT||r===D.BRACKET_L||r===D.BRACKET_R||r===D.BRACE_L||r===D.PIPE||r===D.BRACE_R}function Dn(r){return isNaN(r)?D.EOF:r<127?JSON.stringify(String.fromCharCode(r)):'"\\u'.concat(("00"+r.toString(16).toUpperCase()).slice(-4),'"')}function $y(r,e){for(var t=r.source,n=t.body,i=n.length,a=e.end;a<i;){var o=n.charCodeAt(a),s=r.line,c=1+a-r.lineStart;switch(o){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++r.line,r.lineStart=a;continue;case 13:n.charCodeAt(a+1)===10?a+=2:++a,++r.line,r.lineStart=a;continue;case 33:return new Ne(D.BANG,a,a+1,s,c,e);case 35:return My(t,a,s,c,e);case 36:return new Ne(D.DOLLAR,a,a+1,s,c,e);case 38:return new Ne(D.AMP,a,a+1,s,c,e);case 40:return new Ne(D.PAREN_L,a,a+1,s,c,e);case 41:return new Ne(D.PAREN_R,a,a+1,s,c,e);case 46:if(n.charCodeAt(a+1)===46&&n.charCodeAt(a+2)===46)return new Ne(D.SPREAD,a,a+3,s,c,e);break;case 58:return new Ne(D.COLON,a,a+1,s,c,e);case 61:return new Ne(D.EQUALS,a,a+1,s,c,e);case 64:return new Ne(D.AT,a,a+1,s,c,e);case 91:return new Ne(D.BRACKET_L,a,a+1,s,c,e);case 93:return new Ne(D.BRACKET_R,a,a+1,s,c,e);case 123:return new Ne(D.BRACE_L,a,a+1,s,c,e);case 124:return new Ne(D.PIPE,a,a+1,s,c,e);case 125:return new Ne(D.BRACE_R,a,a+1,s,c,e);case 34:return n.charCodeAt(a+1)===34&&n.charCodeAt(a+2)===34?qy(t,a,s,c,e,r):jy(t,a,s,c,e);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return Uy(t,a,o,s,c,e);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return Vy(t,a,s,c,e)}throw St(t,a,Fy(o))}var u=r.line,l=1+a-r.lineStart;return new Ne(D.EOF,i,i,u,l,e)}function Fy(r){return r<32&&r!==9&&r!==10&&r!==13?"Cannot contain the invalid character ".concat(Dn(r),"."):r===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(Dn(r),".")}function My(r,e,t,n,i){var a=r.body,o,s=e;do o=a.charCodeAt(++s);while(!isNaN(o)&&(o>31||o===9));return new Ne(D.COMMENT,e,s,t,n,i,a.slice(e+1,s))}function Uy(r,e,t,n,i,a){var o=r.body,s=t,c=e,u=!1;if(s===45&&(s=o.charCodeAt(++c)),s===48){if(s=o.charCodeAt(++c),s>=48&&s<=57)throw St(r,c,"Invalid number, unexpected digit after 0: ".concat(Dn(s),"."))}else c=Su(r,c,s),s=o.charCodeAt(c);if(s===46&&(u=!0,s=o.charCodeAt(++c),c=Su(r,c,s),s=o.charCodeAt(c)),(s===69||s===101)&&(u=!0,s=o.charCodeAt(++c),(s===43||s===45)&&(s=o.charCodeAt(++c)),c=Su(r,c,s),s=o.charCodeAt(c)),s===46||Qy(s))throw St(r,c,"Invalid number, expected digit but got: ".concat(Dn(s),"."));return new Ne(u?D.FLOAT:D.INT,e,c,n,i,a,o.slice(e,c))}function Su(r,e,t){var n=r.body,i=e,a=t;if(a>=48&&a<=57){do a=n.charCodeAt(++i);while(a>=48&&a<=57);return i}throw St(r,i,"Invalid number, expected digit but got: ".concat(Dn(a),"."))}function jy(r,e,t,n,i){for(var a=r.body,o=e+1,s=o,c=0,u="";o<a.length&&!isNaN(c=a.charCodeAt(o))&&c!==10&&c!==13;){if(c===34)return u+=a.slice(s,o),new Ne(D.STRING,e,o+1,t,n,i,u);if(c<32&&c!==9)throw St(r,o,"Invalid character within String: ".concat(Dn(c),"."));if(++o,c===92){switch(u+=a.slice(s,o-1),c=a.charCodeAt(o),c){case 34:u+='"';break;case 47:u+="/";break;case 92:u+="\\";break;case 98:u+="\b";break;case 102:u+="\f";break;case 110:u+=`
|
|
59
|
-
`;break;case 114:u+="\r";break;case 116:u+=" ";break;case 117:{var l=By(a.charCodeAt(o+1),a.charCodeAt(o+2),a.charCodeAt(o+3),a.charCodeAt(o+4));if(l<0){var d=a.slice(o+1,o+5);throw St(r,o,"Invalid character escape sequence: \\u".concat(d,"."))}u+=String.fromCharCode(l),o+=4;break}default:throw St(r,o,"Invalid character escape sequence: \\".concat(String.fromCharCode(c),"."))}++o,s=o}}throw St(r,o,"Unterminated string.")}function qy(r,e,t,n,i,a){for(var o=r.body,s=e+3,c=s,u=0,l="";s<o.length&&!isNaN(u=o.charCodeAt(s));){if(u===34&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34)return l+=o.slice(c,s),new Ne(D.BLOCK_STRING,e,s+3,t,n,i,Py(l));if(u<32&&u!==9&&u!==10&&u!==13)throw St(r,s,"Invalid character within String: ".concat(Dn(u),"."));u===10?(++s,++a.line,a.lineStart=s):u===13?(o.charCodeAt(s+1)===10?s+=2:++s,++a.line,a.lineStart=s):u===92&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34&&o.charCodeAt(s+3)===34?(l+=o.slice(c,s)+'"""',s+=4,c=s):++s}throw St(r,s,"Unterminated string.")}function By(r,e,t,n){return es(r)<<12|es(e)<<8|es(t)<<4|es(n)}function es(r){return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1}function Vy(r,e,t,n,i){for(var a=r.body,o=a.length,s=e+1,c=0;s!==o&&!isNaN(c=a.charCodeAt(s))&&(c===95||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++s;return new Ne(D.NAME,e,s,t,n,i,a.slice(e,s))}function Qy(r){return r===95||r>=65&&r<=90||r>=97&&r<=122}function zy(r,e){var t=new Hy(r,e);return t.parseDocument()}var Hy=function(){function r(t,n){var i=Cy(t)?t:new uh(t);this._lexer=new Dy(i),this._options=n}var e=r.prototype;return e.parseName=function(){var n=this.expectToken(D.NAME);return{kind:J.NAME,value:n.value,loc:this.loc(n)}},e.parseDocument=function(){var n=this._lexer.token;return{kind:J.DOCUMENT,definitions:this.many(D.SOF,this.parseDefinition,D.EOF),loc:this.loc(n)}},e.parseDefinition=function(){if(this.peek(D.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(D.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var n=this._lexer.token;if(this.peek(D.BRACE_L))return{kind:J.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(n)};var i=this.parseOperationType(),a;return this.peek(D.NAME)&&(a=this.parseName()),{kind:J.OPERATION_DEFINITION,operation:i,name:a,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseOperationType=function(){var n=this.expectToken(D.NAME);switch(n.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(n)},e.parseVariableDefinitions=function(){return this.optionalMany(D.PAREN_L,this.parseVariableDefinition,D.PAREN_R)},e.parseVariableDefinition=function(){var n=this._lexer.token;return{kind:J.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(D.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(D.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(n)}},e.parseVariable=function(){var n=this._lexer.token;return this.expectToken(D.DOLLAR),{kind:J.VARIABLE,name:this.parseName(),loc:this.loc(n)}},e.parseSelectionSet=function(){var n=this._lexer.token;return{kind:J.SELECTION_SET,selections:this.many(D.BRACE_L,this.parseSelection,D.BRACE_R),loc:this.loc(n)}},e.parseSelection=function(){return this.peek(D.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var n=this._lexer.token,i=this.parseName(),a,o;return this.expectOptionalToken(D.COLON)?(a=i,o=this.parseName()):o=i,{kind:J.FIELD,alias:a,name:o,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(D.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},e.parseArguments=function(n){var i=n?this.parseConstArgument:this.parseArgument;return this.optionalMany(D.PAREN_L,i,D.PAREN_R)},e.parseArgument=function(){var n=this._lexer.token,i=this.parseName();return this.expectToken(D.COLON),{kind:J.ARGUMENT,name:i,value:this.parseValueLiteral(!1),loc:this.loc(n)}},e.parseConstArgument=function(){var n=this._lexer.token;return{kind:J.ARGUMENT,name:this.parseName(),value:(this.expectToken(D.COLON),this.parseValueLiteral(!0)),loc:this.loc(n)}},e.parseFragment=function(){var n=this._lexer.token;this.expectToken(D.SPREAD);var i=this.expectOptionalKeyword("on");return!i&&this.peek(D.NAME)?{kind:J.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(n)}:{kind:J.INLINE_FRAGMENT,typeCondition:i?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseFragmentDefinition=function(){var n,i=this._lexer.token;return this.expectKeyword("fragment"),((n=this._options)===null||n===void 0?void 0:n.experimentalFragmentVariables)===!0?{kind:J.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}:{kind:J.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}},e.parseFragmentName=function(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()},e.parseValueLiteral=function(n){var i=this._lexer.token;switch(i.kind){case D.BRACKET_L:return this.parseList(n);case D.BRACE_L:return this.parseObject(n);case D.INT:return this._lexer.advance(),{kind:J.INT,value:i.value,loc:this.loc(i)};case D.FLOAT:return this._lexer.advance(),{kind:J.FLOAT,value:i.value,loc:this.loc(i)};case D.STRING:case D.BLOCK_STRING:return this.parseStringLiteral();case D.NAME:switch(this._lexer.advance(),i.value){case"true":return{kind:J.BOOLEAN,value:!0,loc:this.loc(i)};case"false":return{kind:J.BOOLEAN,value:!1,loc:this.loc(i)};case"null":return{kind:J.NULL,loc:this.loc(i)};default:return{kind:J.ENUM,value:i.value,loc:this.loc(i)}}case D.DOLLAR:if(!n)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var n=this._lexer.token;return this._lexer.advance(),{kind:J.STRING,value:n.value,block:n.kind===D.BLOCK_STRING,loc:this.loc(n)}},e.parseList=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseValueLiteral(n)};return{kind:J.LIST,values:this.any(D.BRACKET_L,o,D.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(n){var i=this,a=this._lexer.token,o=function(){return i.parseObjectField(n)};return{kind:J.OBJECT,fields:this.any(D.BRACE_L,o,D.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(n){var i=this._lexer.token,a=this.parseName();return this.expectToken(D.COLON),{kind:J.OBJECT_FIELD,name:a,value:this.parseValueLiteral(n),loc:this.loc(i)}},e.parseDirectives=function(n){for(var i=[];this.peek(D.AT);)i.push(this.parseDirective(n));return i},e.parseDirective=function(n){var i=this._lexer.token;return this.expectToken(D.AT),{kind:J.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(n),loc:this.loc(i)}},e.parseTypeReference=function(){var n=this._lexer.token,i;return this.expectOptionalToken(D.BRACKET_L)?(i=this.parseTypeReference(),this.expectToken(D.BRACKET_R),i={kind:J.LIST_TYPE,type:i,loc:this.loc(n)}):i=this.parseNamedType(),this.expectOptionalToken(D.BANG)?{kind:J.NON_NULL_TYPE,type:i,loc:this.loc(n)}:i},e.parseNamedType=function(){var n=this._lexer.token;return{kind:J.NAMED_TYPE,name:this.parseName(),loc:this.loc(n)}},e.parseTypeSystemDefinition=function(){var n=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(n.kind===D.NAME)switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(n)},e.peekDescription=function(){return this.peek(D.STRING)||this.peek(D.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),o=this.many(D.BRACE_L,this.parseOperationTypeDefinition,D.BRACE_R);return{kind:J.SCHEMA_DEFINITION,description:i,directives:a,operationTypes:o,loc:this.loc(n)}},e.parseOperationTypeDefinition=function(){var n=this._lexer.token,i=this.parseOperationType();this.expectToken(D.COLON);var a=this.parseNamedType();return{kind:J.OPERATION_TYPE_DEFINITION,operation:i,type:a,loc:this.loc(n)}},e.parseScalarTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),o=this.parseDirectives(!0);return{kind:J.SCALAR_TYPE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:J.OBJECT_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:c,loc:this.loc(n)}},e.parseImplementsInterfaces=function(){var n;if(!this.expectOptionalKeyword("implements"))return[];if(((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLImplementsInterfaces)===!0){var i=[];this.expectOptionalToken(D.AMP);do i.push(this.parseNamedType());while(this.expectOptionalToken(D.AMP)||this.peek(D.NAME));return i}return this.delimitedMany(D.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var n;return((n=this._options)===null||n===void 0?void 0:n.allowLegacySDLEmptyFields)===!0&&this.peek(D.BRACE_L)&&this._lexer.lookahead().kind===D.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(D.BRACE_L,this.parseFieldDefinition,D.BRACE_R)},e.parseFieldDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseArgumentDefs();this.expectToken(D.COLON);var s=this.parseTypeReference(),c=this.parseDirectives(!0);return{kind:J.FIELD_DEFINITION,description:i,name:a,arguments:o,type:s,directives:c,loc:this.loc(n)}},e.parseArgumentDefs=function(){return this.optionalMany(D.PAREN_L,this.parseInputValueDef,D.PAREN_R)},e.parseInputValueDef=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName();this.expectToken(D.COLON);var o=this.parseTypeReference(),s;this.expectOptionalToken(D.EQUALS)&&(s=this.parseValueLiteral(!0));var c=this.parseDirectives(!0);return{kind:J.INPUT_VALUE_DEFINITION,description:i,name:a,type:o,defaultValue:s,directives:c,loc:this.loc(n)}},e.parseInterfaceTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:J.INTERFACE_TYPE_DEFINITION,description:i,name:a,interfaces:o,directives:s,fields:c,loc:this.loc(n)}},e.parseUnionTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseUnionMemberTypes();return{kind:J.UNION_TYPE_DEFINITION,description:i,name:a,directives:o,types:s,loc:this.loc(n)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken(D.EQUALS)?this.delimitedMany(D.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();return{kind:J.ENUM_TYPE_DEFINITION,description:i,name:a,directives:o,values:s,loc:this.loc(n)}},e.parseEnumValuesDefinition=function(){return this.optionalMany(D.BRACE_L,this.parseEnumValueDefinition,D.BRACE_R)},e.parseEnumValueDefinition=function(){var n=this._lexer.token,i=this.parseDescription(),a=this.parseName(),o=this.parseDirectives(!0);return{kind:J.ENUM_VALUE_DEFINITION,description:i,name:a,directives:o,loc:this.loc(n)}},e.parseInputObjectTypeDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();return{kind:J.INPUT_OBJECT_TYPE_DEFINITION,description:i,name:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInputFieldsDefinition=function(){return this.optionalMany(D.BRACE_L,this.parseInputValueDef,D.BRACE_R)},e.parseTypeSystemExtension=function(){var n=this._lexer.lookahead();if(n.kind===D.NAME)switch(n.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(n)},e.parseSchemaExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var i=this.parseDirectives(!0),a=this.optionalMany(D.BRACE_L,this.parseOperationTypeDefinition,D.BRACE_R);if(i.length===0&&a.length===0)throw this.unexpected();return{kind:J.SCHEMA_EXTENSION,directives:i,operationTypes:a,loc:this.loc(n)}},e.parseScalarTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var i=this.parseName(),a=this.parseDirectives(!0);if(a.length===0)throw this.unexpected();return{kind:J.SCALAR_TYPE_EXTENSION,name:i,directives:a,loc:this.loc(n)}},e.parseObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:J.OBJECT_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseInterfaceTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var i=this.parseName(),a=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),s=this.parseFieldsDefinition();if(a.length===0&&o.length===0&&s.length===0)throw this.unexpected();return{kind:J.INTERFACE_TYPE_EXTENSION,name:i,interfaces:a,directives:o,fields:s,loc:this.loc(n)}},e.parseUnionTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseUnionMemberTypes();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:J.UNION_TYPE_EXTENSION,name:i,directives:a,types:o,loc:this.loc(n)}},e.parseEnumTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:J.ENUM_TYPE_EXTENSION,name:i,directives:a,values:o,loc:this.loc(n)}},e.parseInputObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var i=this.parseName(),a=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:J.INPUT_OBJECT_TYPE_EXTENSION,name:i,directives:a,fields:o,loc:this.loc(n)}},e.parseDirectiveDefinition=function(){var n=this._lexer.token,i=this.parseDescription();this.expectKeyword("directive"),this.expectToken(D.AT);var a=this.parseName(),o=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var c=this.parseDirectiveLocations();return{kind:J.DIRECTIVE_DEFINITION,description:i,name:a,arguments:o,repeatable:s,locations:c,loc:this.loc(n)}},e.parseDirectiveLocations=function(){return this.delimitedMany(D.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var n=this._lexer.token,i=this.parseName();if(Ry[i.value]!==void 0)return i;throw this.unexpected(n)},e.loc=function(n){var i;if(((i=this._options)===null||i===void 0?void 0:i.noLocation)!==!0)return new sh(n,this._lexer.lastToken,this._lexer.source)},e.peek=function(n){return this._lexer.token.kind===n},e.expectToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i;throw St(this._lexer.source,i.start,"Expected ".concat(lh(n),", found ").concat(_u(i),"."))},e.expectOptionalToken=function(n){var i=this._lexer.token;if(i.kind===n)return this._lexer.advance(),i},e.expectKeyword=function(n){var i=this._lexer.token;if(i.kind===D.NAME&&i.value===n)this._lexer.advance();else throw St(this._lexer.source,i.start,'Expected "'.concat(n,'", found ').concat(_u(i),"."))},e.expectOptionalKeyword=function(n){var i=this._lexer.token;return i.kind===D.NAME&&i.value===n?(this._lexer.advance(),!0):!1},e.unexpected=function(n){var i=n??this._lexer.token;return St(this._lexer.source,i.start,"Unexpected ".concat(_u(i),"."))},e.any=function(n,i,a){this.expectToken(n);for(var o=[];!this.expectOptionalToken(a);)o.push(i.call(this));return o},e.optionalMany=function(n,i,a){if(this.expectOptionalToken(n)){var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o}return[]},e.many=function(n,i,a){this.expectToken(n);var o=[];do o.push(i.call(this));while(!this.expectOptionalToken(a));return o},e.delimitedMany=function(n,i){this.expectOptionalToken(n);var a=[];do a.push(i.call(this));while(this.expectOptionalToken(n));return a},r}();function _u(r){var e=r.value;return lh(r.kind)+(e!=null?' "'.concat(e,'"'):"")}function lh(r){return Ly(r)?'"'.concat(r,'"'):r}var ys=new Map,Qu=new Map,fh=!0,Os=!1;function ph(r){return r.replace(/[\s,]+/g," ").trim()}function Wy(r){return ph(r.source.body.substring(r.start,r.end))}function Gy(r){var e=new Set,t=[];return r.definitions.forEach(function(n){if(n.kind==="FragmentDefinition"){var i=n.name.value,a=Wy(n.loc),o=Qu.get(i);o&&!o.has(a)?fh&&console.warn("Warning: fragment with name "+i+` already exists.
|
|
60
|
-
graphql-tag enforces all fragment names across your application to be unique; read more about
|
|
61
|
-
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||Qu.set(i,o=new Set),o.add(a),e.has(a)||(e.add(a),t.push(n))}else t.push(n)}),As(As({},r),{definitions:t})}function Ky(r){var e=new Set(r.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var a=n[i];a&&typeof a=="object"&&e.add(a)})});var t=r.loc;return t&&(delete t.startToken,delete t.endToken),r}function Jy(r){var e=ph(r);if(!ys.has(e)){var t=zy(r,{experimentalFragmentVariables:Os,allowLegacyFragmentVariables:Os});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");ys.set(e,Ky(Gy(t)))}return ys.get(e)}function x(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof r=="string"&&(r=[r]);var n=r[0];return e.forEach(function(i,a){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=r[a+1]}),Jy(n)}function Zy(){ys.clear(),Qu.clear()}function Yy(){fh=!1}function Xy(){Os=!0}function ev(){Os=!1}var da={gql:x,resetCaches:Zy,disableFragmentWarnings:Yy,enableExperimentalFragmentVariables:Xy,disableExperimentalFragmentVariables:ev};(function(r){r.gql=da.gql,r.resetCaches=da.resetCaches,r.disableFragmentWarnings=da.disableFragmentWarnings,r.enableExperimentalFragmentVariables=da.enableExperimentalFragmentVariables,r.disableExperimentalFragmentVariables=da.disableExperimentalFragmentVariables})(x||(x={}));x.default=x;function k(r){if(!r)throw"Got no result from Apollo";if(r.error)throw r.error;if(r.errors)throw r.errors;return r.data}function tv(){}function an(){return tv}var B=an,S=an,ze=an,re=an,K=an,Le=an,rv=an,gl=an,dh=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},hh=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Ln=class{constructor(e){this.code=e}};dh([S(),hh("design:type",String)],Ln.prototype,"code",void 0);Ln=dh([K(),hh("design:paramtypes",[String])],Ln);var yl=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},vl=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},er=class{constructor(e,t){this.address=e,this.name=t}};yl([S(),vl("design:type",String)],er.prototype,"address",void 0);yl([S(),vl("design:type",String)],er.prototype,"name",void 0);er=yl([K(),vl("design:paramtypes",[String,String])],er);var Te=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},je=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},wr=class{constructor(e,t){this.key=t,this.signature=e}};Te([S(),je("design:type",String)],wr.prototype,"signature",void 0);Te([S(),je("design:type",String)],wr.prototype,"key",void 0);Te([S(),je("design:type",Boolean)],wr.prototype,"valid",void 0);Te([S(),je("design:type",Boolean)],wr.prototype,"invalid",void 0);wr=Te([K(),ze(),je("design:paramtypes",[String,String])],wr);var $n=class{};Te([S(),je("design:type",String)],$n.prototype,"signature",void 0);Te([S(),je("design:type",String)],$n.prototype,"key",void 0);Te([S(),je("design:type",Boolean)],$n.prototype,"valid",void 0);Te([S(),je("design:type",Boolean)],$n.prototype,"invalid",void 0);$n=Te([ze()],$n);function on(r){let e=class{constructor(n,i,a,o){this.author=n,this.timestamp=i,this.data=a,this.proof=o}};return Te([S(),je("design:type",String)],e.prototype,"author",void 0),Te([S(),je("design:type",String)],e.prototype,"timestamp",void 0),Te([S(),je("design:type",Object)],e.prototype,"data",void 0),Te([S(),je("design:type",wr)],e.prototype,"proof",void 0),e=Te([K(),je("design:paramtypes",[String,String,Object,wr])],e),e}function nv(r){let e=class{};return Te([S(),je("design:type",String)],e.prototype,"author",void 0),Te([S(),je("design:type",String)],e.prototype,"timestamp",void 0),Te([S(),je("design:type",Object)],e.prototype,"data",void 0),Te([S(),je("design:type",$n)],e.prototype,"proof",void 0),e=Te([ze()],e),e}var Mp=class extends on(){};Mp=Te([K()],Mp);var Cs=class extends on(){};Te([S(),je("design:type",er)],Cs.prototype,"language",void 0);Te([S(),je("design:type",Ln)],Cs.prototype,"icon",void 0);Cs=Te([K()],Cs);function qk(r){return r&&r.author&&r.timestamp&&r.data}var $e=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Ze=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},mt=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};$e([S(),Ze("design:type",String)],mt.prototype,"source",void 0);$e([S(),Ze("design:type",String)],mt.prototype,"target",void 0);$e([S(),Ze("design:type",String)],mt.prototype,"predicate",void 0);mt=$e([K(),Ze("design:paramtypes",[Object])],mt);var Rs=class{};$e([S(),Ze("design:type",Array)],Rs.prototype,"additions",void 0);$e([S(),Ze("design:type",Array)],Rs.prototype,"removals",void 0);Rs=$e([ze()],Rs);var Ps=class{constructor(e,t){this.additions=e,this.removals=t}};$e([S(),Ze("design:type",Array)],Ps.prototype,"additions",void 0);$e([S(),Ze("design:type",Array)],Ps.prototype,"removals",void 0);Ps=$e([K(),Ze("design:paramtypes",[Array,Array])],Ps);var Ka=class{};$e([S(),Ze("design:type",String)],Ka.prototype,"source",void 0);$e([S(),Ze("design:type",String)],Ka.prototype,"target",void 0);$e([S(),Ze("design:type",String)],Ka.prototype,"predicate",void 0);Ka=$e([ze()],Ka);var Zr=class extends on(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,n,i;for(n=0;n<e.length;n++)i=e.charCodeAt(n),t=(t<<5)-t+i,t|=0;return t}};$e([S(),Ze("design:type",String)],Zr.prototype,"status",void 0);Zr=$e([K()],Zr);var zu=class extends nv(){};$e([S(),Ze("design:type",String)],zu.prototype,"status",void 0);zu=$e([ze()],zu);function Gk(r,e){return r.author==e.author&&r.timestamp==e.timestamp&&r.data.source==e.data.source&&r.data.predicate==e.data.predicate&&r.data.target==e.data.target}function Kk(r){return r&&r.source&&r.target}var Ns=class{constructor(e,t){this.oldLink=e,this.newLink=t}};$e([S(),Ze("design:type",Zr)],Ns.prototype,"oldLink",void 0);$e([S(),Ze("design:type",Zr)],Ns.prototype,"newLink",void 0);Ns=$e([K(),Ze("design:paramtypes",[Zr,Zr])],Ns);var Wn=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},co=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Hu,ir=class{constructor(e){e?this.links=e:this.links=[]}get(e){if(!e||!e.source&&!e.predicate&&!e.target)return this.links;if(e.source){let n=JSON.parse(JSON.stringify(this.links));return e.target&&(n=n.filter(i=>i.data.target===e.target)),e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}if(e.target){let n=JSON.parse(JSON.stringify(this.links));return e.predicate&&(n=n.filter(i=>i.data.predicate===e.predicate)),e.fromDate&&(n=n.filter(i=>new Date(i.timestamp)>=e.fromDate)),e.untilDate&&(n=n.filter(i=>new Date(i.timestamp)<=e.untilDate)),e.limit&&(n=n.slice(0,e.limit)),n}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(n=>n.data.predicate===e.predicate),e.limit&&(t=t.slice(0,e.limit)),t}getSingleTarget(e){delete e.target;let t=this.get(e);return t.length?t[0].data.target:null}};Wn([S(),co("design:type",Array)],ir.prototype,"links",void 0);ir=Wn([K(),co("design:paramtypes",[Array])],ir);var Ds=class{};Wn([S(),co("design:type",Array)],Ds.prototype,"links",void 0);Ds=Wn([ze()],Ds);var Wu=Hu=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new Hu;return t.links.push(e),t}};Wn([S(),co("design:type",Array)],Wu.prototype,"links",void 0);Wu=Hu=Wn([ze(),co("design:paramtypes",[Array])],Wu);var Fn=class extends on(){};Fn=Wn([K()],Fn);var Q=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},z=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Hr=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new ir}};Q([S(),z("design:type",String)],Hr.prototype,"did",void 0);Q([S(),z("design:type",ir)],Hr.prototype,"perspective",void 0);Q([S(),z("design:type",String)],Hr.prototype,"directMessageLanguage",void 0);Hr=Q([K(),z("design:paramtypes",[String,ir])],Hr);var Up=class extends on(){};Up=Q([K()],Up);var Yr=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};Q([S(),z("design:type",String)],Yr.prototype,"did",void 0);Q([S(),z("design:type",String)],Yr.prototype,"didSigningKeyId",void 0);Q([S(),z("design:type",String)],Yr.prototype,"deviceKeyType",void 0);Q([S(),z("design:type",String)],Yr.prototype,"deviceKey",void 0);Q([S(),z("design:type",String)],Yr.prototype,"deviceKeySignedByDid",void 0);Q([S(),z("design:type",String)],Yr.prototype,"didSignedByDeviceKey",void 0);Yr=Q([K(),z("design:paramtypes",[String,String,String,String,String,String])],Yr);var Xr=class{constructor(e,t,n,i,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=n,this.deviceKey=i,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};Q([S(),z("design:type",String)],Xr.prototype,"did",void 0);Q([S(),z("design:type",String)],Xr.prototype,"didSigningKeyId",void 0);Q([S(),z("design:type",String)],Xr.prototype,"deviceKeyType",void 0);Q([S(),z("design:type",String)],Xr.prototype,"deviceKey",void 0);Q([S(),z("design:type",String)],Xr.prototype,"deviceKeySignedByDid",void 0);Q([S(),z("design:type",String)],Xr.prototype,"didSignedByDeviceKey",void 0);Xr=Q([ze(),z("design:paramtypes",[String,String,String,String,String,String])],Xr);var Ls=class{constructor(e,t){this.signature=e,this.publicKey=t}};Q([S(),z("design:type",String)],Ls.prototype,"signature",void 0);Q([S(),z("design:type",String)],Ls.prototype,"publicKey",void 0);Ls=Q([K(),z("design:paramtypes",[String,String])],Ls);var Ci=class{constructor(e,t){this.domain=e,this.pointers=t}};Q([S(),z("design:type",String)],Ci.prototype,"domain",void 0);Q([S(),z("design:type",Array)],Ci.prototype,"pointers",void 0);Ci=Q([K(),z("design:paramtypes",[String,Array])],Ci);var $s=class{constructor(e,t){this.with=e,this.can=t}};Q([S(),z("design:type",Ci)],$s.prototype,"with",void 0);Q([S(),z("design:type",Array)],$s.prototype,"can",void 0);$s=Q([K(),z("design:paramtypes",[Ci,Array])],$s);var Sr=class{constructor(e,t,n,i,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=n,this.capabilities=i}};Q([S(),z("design:type",String)],Sr.prototype,"appName",void 0);Q([S(),z("design:type",String)],Sr.prototype,"appDesc",void 0);Q([S(),z("design:type",String)],Sr.prototype,"appUrl",void 0);Q([S(),z("design:type",String)],Sr.prototype,"appIconPath",void 0);Q([S(),z("design:type",Array)],Sr.prototype,"capabilities",void 0);Sr=Q([K(),z("design:paramtypes",[String,String,String,Array,String])],Sr);var Ri=class{constructor(e,t,n,i){this.requestId=e,this.auth=t,this.token=n,this.revoked=i}};Q([S(),z("design:type",String)],Ri.prototype,"requestId",void 0);Q([S(),z("design:type",String)],Ri.prototype,"token",void 0);Q([S(),z("design:type",Boolean)],Ri.prototype,"revoked",void 0);Q([S(),z("design:type",Sr)],Ri.prototype,"auth",void 0);Ri=Q([K(),z("design:paramtypes",[String,Sr,String,Boolean])],Ri);var Pi=class{constructor(e,t){this.domain=e,this.pointers=t}};Q([S(),z("design:type",String)],Pi.prototype,"domain",void 0);Q([S(),z("design:type",Array)],Pi.prototype,"pointers",void 0);Pi=Q([ze(),z("design:paramtypes",[String,Array])],Pi);var Fs=class{constructor(e,t){this.with=e,this.can=t}};Q([S(),z("design:type",Pi)],Fs.prototype,"with",void 0);Q([S(),z("design:type",Array)],Fs.prototype,"can",void 0);Fs=Q([ze(),z("design:paramtypes",[Pi,Array])],Fs);var ar=class{constructor(e,t,n,i,a,o){this.appName=e,this.appDesc=t,this.appUrl=i,this.appDomain=n,this.capabilities=o,this.appIconPath=a}};Q([S(),z("design:type",String)],ar.prototype,"appName",void 0);Q([S(),z("design:type",String)],ar.prototype,"appDesc",void 0);Q([S(),z("design:type",String)],ar.prototype,"appDomain",void 0);Q([S(),z("design:type",String)],ar.prototype,"appUrl",void 0);Q([S(),z("design:type",String)],ar.prototype,"appIconPath",void 0);Q([S(),z("design:type",Array)],ar.prototype,"capabilities",void 0);ar=Q([ze(),z("design:paramtypes",[String,String,String,String,String,Array])],ar);var Mn=class{constructor(e,t,n){this.did=e,this.success=t,this.error=n}};Q([S(),z("design:type",String)],Mn.prototype,"did",void 0);Q([S(),z("design:type",Boolean)],Mn.prototype,"success",void 0);Q([S(),z("design:type",String)],Mn.prototype,"error",void 0);Mn=Q([K(),z("design:paramtypes",[String,Boolean,String])],Mn);var ji=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},qi=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Rt=class{constructor(e){e?(this.isInitialized=e.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=e.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=e.did,this.didDocument=e.didDocument,this.error=e.error):(this.isInitialized=!1,this.isUnlocked=!1)}};ji([S(),qi("design:type",Boolean)],Rt.prototype,"isInitialized",void 0);ji([S(),qi("design:type",Boolean)],Rt.prototype,"isUnlocked",void 0);ji([S(),qi("design:type",String)],Rt.prototype,"did",void 0);ji([S(),qi("design:type",String)],Rt.prototype,"didDocument",void 0);ji([S(),qi("design:type",String)],Rt.prototype,"error",void 0);Rt=ji([K(),qi("design:paramtypes",[Object])],Rt);var jp=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Re=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},ft,pt,Gu=class{constructor(e,t){ft.set(this,void 0),pt.set(this,void 0),jp(this,ft,e,"f"),jp(this,pt,t,"f")}async otherAgents(){return await Re(this,ft,"f").otherAgents(Re(this,pt,"f"))}async hasTelepresenceAdapter(){return await Re(this,ft,"f").hasTelepresenceAdapter(Re(this,pt,"f"))}async onlineAgents(){return await Re(this,ft,"f").onlineAgents(Re(this,pt,"f"))}async setOnlineStatus(e){return await Re(this,ft,"f").setOnlineStatus(Re(this,pt,"f"),e)}async setOnlineStatusU(e){return await Re(this,ft,"f").setOnlineStatusU(Re(this,pt,"f"),e)}async sendSignal(e,t){return await Re(this,ft,"f").sendSignal(Re(this,pt,"f"),e,t)}async sendSignalU(e,t){return await Re(this,ft,"f").sendSignalU(Re(this,pt,"f"),e,t)}async sendBroadcast(e,t=!1){return await Re(this,ft,"f").sendBroadcast(Re(this,pt,"f"),e,t)}async sendBroadcastU(e,t=!1){return await Re(this,ft,"f").sendBroadcastU(Re(this,pt,"f"),e,t)}async addSignalHandler(e){await Re(this,ft,"f").addSignalHandler(Re(this,pt,"f"),e)}removeSignalHandler(e){Re(this,ft,"f").removeSignalHandler(Re(this,pt,"f"),e)}};ft=new WeakMap,pt=new WeakMap;var Gn=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Kn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},W=class{constructor(e){e&&(this.source=e.source,this.predicate=e.predicate,this.target=e.target,e.fromDate&&(this.fromDate=e.fromDate),e.untilDate&&(this.untilDate=e.untilDate),e.limit&&(this.limit=e.limit))}isMatch(e){return!(this.source&&this.source!==e.source||this.predicate&&this.predicate!==e.predicate||this.target&&this.target!==e.target)}};Gn([S(),Kn("design:type",String)],W.prototype,"source",void 0);Gn([S(),Kn("design:type",String)],W.prototype,"target",void 0);Gn([S(),Kn("design:type",String)],W.prototype,"predicate",void 0);Gn([S(),Kn("design:type",Date)],W.prototype,"fromDate",void 0);Gn([S(),Kn("design:type",Date)],W.prototype,"untilDate",void 0);Gn([S(),Kn("design:type",Number)],W.prototype,"limit",void 0);W=Gn([K(),ze(),Kn("design:paramtypes",[Object])],W);var qp=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ke=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},dt,dr;function ts(r){return encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var be=class{constructor(){dt.set(this,void 0),dr.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal:"))throw new Error("Can't create Literal from non-literal URL");if(e.startsWith("literal://"))throw new Error("literal:// format is no longer supported. Use literal: instead.");let t=new be;return qp(t,dr,e,"f"),t}static from(e){let t=new be;return qp(t,dt,e,"f"),t}toUrl(){if(Ke(this,dr,"f")&&!Ke(this,dt,"f"))return Ke(this,dr,"f");if(!Ke(this,dr,"f")&&(Ke(this,dt,"f")===void 0||Ke(this,dt,"f")===""||Ke(this,dt,"f")===null))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Ke(this,dt,"f")){case"string":e=`string:${ts(Ke(this,dt,"f"))}`;break;case"number":e=`number:${ts(Ke(this,dt,"f"))}`;break;case"boolean":e=`boolean:${ts(Ke(this,dt,"f"))}`;break;case"object":e=`json:${ts(JSON.stringify(Ke(this,dt,"f")))}`;break}return`literal:${e}`}get(){if(Ke(this,dt,"f"))return Ke(this,dt,"f");if(!Ke(this,dr,"f"))throw new Error("Can't render empty Literal");if(!Ke(this,dr,"f").startsWith("literal:"))throw new Error("Can't render Literal from non-literal URL");let e=Ke(this,dr,"f").substring(8);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let t=e.substring(7);return parseFloat(t)}if(e.startsWith("json:")){let t=e.substring(5);return JSON.parse(decodeURIComponent(t))}throw new Error(`Can't parse unknown literal: ${e}`)}};dt=new WeakMap,dr=new WeakMap;function st(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Xs(r){return`set${st(r)}`}function mh(r){return r.endsWith("ies")?r.slice(0,-3)+"y":r.endsWith("s")?r.slice(0,-1):r}function iv(r){return`add${st(mh(r))}`}function av(r){return`remove${st(mh(r))}`}function ov(r){return`set${st(r)}`}function gh(r){let e="",t="abcdefghijklmnopqrstuvwxyz",n=t.length;for(let i=0;i<r;i++)e+=t.charAt(Math.floor(Math.random()*n));return e}function bn(r){if(Array.isArray(r))return`[${r.map(bn).join(", ")}]`;let e=Object.keys(r),t=[];for(let n of e){let i=JSON.stringify(r[n]),a=`${n}: ${i}`;t.push(a)}return`{${t.join(", ")}}`}var Eu=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},ee=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},nt,it,Pe,Ba=class{constructor(r,e,t){nt.set(this,void 0),it.set(this,void 0),Pe.set(this,void 0),Eu(this,nt,e,"f"),Eu(this,it,t,"f"),Eu(this,Pe,r,"f")}get baseExpression(){return ee(this,nt,"f")}async init(){let isInstance=await ee(this,Pe,"f").isSubjectInstance(ee(this,nt,"f"),ee(this,it,"f"));if(!isInstance)throw`Not a valid subject instance of ${ee(this,it,"f")} for ${ee(this,nt,"f")}`;let results=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties)await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), property_resolve(C, "${r}")`),Object.defineProperty(this,r,{configurable:!0,get:async()=>{try{return await ee(this,Pe,"f").getPropertyValueViaSparql(ee(this,nt,"f"),ee(this,it,"f"),r)}catch(e){console.warn(`Failed to get property ${r} via SPARQL:`,e);return}}});let setters=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[Xs(property)]=async r=>{resolveLanguage&&(r=await ee(this,Pe,"f").createExpression(r,resolveLanguage)),await ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:r}])}}let results2=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let relations=results2.map(r=>r.Collection);for(let r of relations)Object.defineProperty(this,r,{configurable:!0,get:async()=>{try{return await ee(this,Pe,"f").getRelationValuesViaSparql(ee(this,nt,"f"),ee(this,it,"f"),r)}catch(e){return console.warn(`Failed to get relation ${r} via SPARQL:`,e),[]}}});let adders=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let relation=adder.Collection,actions=eval(adder.Adder);this[iv(relation)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:e}]))):await ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:r}])}}let removers=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let relation=remover.Collection,actions=eval(remover.Remover);this[av(relation)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:e}]))):await ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:r}])}}let relationSetters=await ee(this,Pe,"f").infer(`subject_class("${ee(this,it,"f")}", C), collection_setter(C, Collection, Setter)`);relationSetters||(relationSetters=[]);for(let relationSetter of relationSetters)if(relationSetter){let relation=relationSetter.Collection,actions=eval(relationSetter.Setter);this[ov(relation)]=async r=>{Array.isArray(r)?await ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),r.map(e=>({name:"value",value:e}))):await ee(this,Pe,"f").executeAction(actions,ee(this,nt,"f"),[{name:"value",value:r}])}}}};nt=new WeakMap,it=new WeakMap,Pe=new WeakMap;function sv(r,e,t,n){let i="",a=gh(8);i+=`subject_class("${r}", ${a}).
|
|
62
|
-
`;let o=[],s=[];e.subjectConstructor&&e.subjectConstructor.length&&(s=s.concat(e.subjectConstructor));let c=[];e.isSubjectInstance&&e.isSubjectInstance.length&&(c=c.concat(e.isSubjectInstance));let u=[];for(let f in t){let h=`property(${a}, "${f}").
|
|
63
|
-
`,{through:m,initial:g,required:_,resolveLanguage:w,writable:y,flag:b,prologGetter:I,prologSetter:A,local:E}=t[f];if(w&&(h+=`property_resolve(${a}, "${f}").
|
|
64
|
-
`,h+=`property_resolve_language(${a}, "${f}", "${w}").
|
|
65
|
-
`),I?h+=`property_getter(${a}, Base, "${f}", Value) :- ${I}.
|
|
66
|
-
`:m&&(h+=`property_getter(${a}, Base, "${f}", Value) :- triple(Base, "${m}", Value).
|
|
67
|
-
`,_&&(b?c.push(`triple(Base, "${m}", "${g}")`):c.push(`triple(Base, "${m}", _)`))),A)h+=`property_setter(${a}, "${f}", Actions) :- ${A}.
|
|
68
|
-
`;else if(y&&m&&typeof e[Xs(f)]=="function"){let N=[{action:"setSingleTarget",source:"this",predicate:m,target:"value",...E&&{local:!0}}];h+=`property_setter(${a}, "${f}", '${bn(N)}').
|
|
69
|
-
`}u.push(h);let R=g??(_&&y&&!b&&m?"literal:string:":void 0);R&&(s.push({action:"addLink",source:"this",predicate:m,target:R}),o.push({action:"removeLink",source:"this",predicate:m,target:"*"}))}let l=[],d=Object.fromEntries(Object.entries(n).filter(([,f])=>f.kind==="hasMany"||f.kind==="belongsToMany"));for(let f in d){let h=`collection(${a}, "${f}").
|
|
70
|
-
`,{predicate:m,local:g}=d[f];if(m){h+=`collection_getter(${a}, Base, "${f}", List) :- findall(C, triple(Base, "${m}", C), List).
|
|
71
|
-
`;let _=[{action:"addLink",source:"this",predicate:m,target:"value",...g&&{local:!0}}],w=[{action:"removeLink",source:"this",predicate:m,target:"value"}],y=[{action:"collectionSetter",source:"this",predicate:m,target:"value",...g&&{local:!0}}];h+=`collection_adder(${a}, "${f}", '${bn(_)}').
|
|
72
|
-
`,h+=`collection_remover(${a}, "${f}", '${bn(w)}').
|
|
73
|
-
`,h+=`collection_setter(${a}, "${f}", '${bn(y)}').
|
|
74
|
-
`}l.push(h)}let p=bn(s);if(i+=`constructor(${a}, '${p}').
|
|
75
|
-
`,c.length>0){let f=c.join(", ");i+=`instance(${a}, Base) :- ${f}.
|
|
76
|
-
`,i+=`
|
|
77
|
-
`}return i+=`destructor(${a}, '${bn(o)}').
|
|
78
|
-
`,i+=`
|
|
79
|
-
`,i+=u.join(`
|
|
80
|
-
`),i+=`
|
|
81
|
-
`,i+=l.join(`
|
|
82
|
-
`),{sdna:i,name:r}}function Bp(r){let e=r.lastIndexOf("#");if(e!==-1)return r.substring(0,e+1);let t=r.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)(.*)$/);if(t){let i=t[2],a=i.lastIndexOf("/");return a!==-1?t[1]+i.substring(0,a+1):t[1]}let n=r.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return n?n[1]:""}function Vp(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\b/g,"\\b").replace(/\f/g,"\\f")}function Qp(r){let e=r.lastIndexOf("#");if(e!==-1)return r.substring(e+1);let t=r.lastIndexOf("/");if(t!==-1&&t<r.length-1)return r.substring(t+1);let n=r.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return n?n[1]:r}var Wr=class{constructor(e,t){if(t!==void 0)this.nodeShapeUri=e,this.targetClass=t;else{this.targetClass=e;let n=Bp(e),i=Qp(e);this.nodeShapeUri=`${n}${i}Shape`}this.properties=[],this.parentShapes=[]}addParentShape(e){this.parentShapes.includes(e)||this.parentShapes.push(e)}addProperty(e){this.properties.push(e)}setConstructorActions(e){this.constructor_actions=e}setDestructorActions(e){this.destructor_actions=e}toTurtle(){let e=`@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
83
|
-
`;e+=`@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
84
|
-
`,e+=`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
85
|
-
`,e+=`@prefix ad4m: <ad4m://> .
|
|
86
|
-
|
|
87
|
-
`,e+=`<${this.nodeShapeUri}>
|
|
88
|
-
`,e+=` a sh:NodeShape ;
|
|
89
|
-
`,this.targetClass&&(e+=` sh:targetClass <${this.targetClass}> ;
|
|
90
|
-
`);for(let t of this.parentShapes)e+=` sh:node <${t}> ;
|
|
91
|
-
`;for(let t=0;t<this.properties.length;t++){let n=this.properties[t],i=t===this.properties.length-1;e+=` sh:property [
|
|
92
|
-
`,e+=` sh:path <${n.path}> ;
|
|
93
|
-
`,n.datatype&&(e+=` sh:datatype <${n.datatype}> ;
|
|
94
|
-
`),n.nodeKind&&(e+=` sh:nodeKind sh:${n.nodeKind} ;
|
|
95
|
-
`),n.minCount!==void 0&&(e+=` sh:minCount ${n.minCount} ;
|
|
96
|
-
`),n.maxCount!==void 0&&(e+=` sh:maxCount ${n.maxCount} ;
|
|
97
|
-
`),n.pattern&&(e+=` sh:pattern "${Vp(n.pattern)}" ;
|
|
98
|
-
`),n.minInclusive!==void 0&&(e+=` sh:minInclusive ${n.minInclusive} ;
|
|
99
|
-
`),n.maxInclusive!==void 0&&(e+=` sh:maxInclusive ${n.maxInclusive} ;
|
|
100
|
-
`),n.hasValue&&(e+=` sh:hasValue "${Vp(n.hasValue)}" ;
|
|
101
|
-
`),n.local!==void 0&&(e+=` ad4m:local ${n.local} ;
|
|
102
|
-
`),n.writable!==void 0&&(e+=` ad4m:writable ${n.writable} ;
|
|
103
|
-
`),e=e.slice(0,-2)+`
|
|
104
|
-
`,e+=i?` ] .
|
|
1
|
+
var z=(i,t,e)=>new Promise((n,r)=>{var s=l=>{try{o(e.next(l))}catch(c){r(c)}},a=l=>{try{o(e.throw(l))}catch(c){r(c)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);o((e=e.apply(i,t)).next())});var $i="0.13.0-test-4";function dr(){return typeof window!="undefined"&&window.self!==window.top}function ln(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(i){return!1}return!0}function _e(i,t){ln()&&localStorage.setItem(`${$i}/${i}`,t)}function Ut(i){return ln()?localStorage.getItem(`${$i}/${i}`):null}function bt(i){ln()&&localStorage.removeItem(`${$i}/${i}`)}function dn(i){return i.replace(/^ws(s?):\/\//,(t,e)=>`http${e}://`)}function ur(i,t=1e4){return z(this,null,function*(){let e=new AbortController,n=setTimeout(()=>e.abort(),t);try{let r=yield fetch(`${i}/health`,{signal:e.signal});if(!r.ok)throw new Error(`Health check returned ${r.status}`);let s=yield r.json();if((s==null?void 0:s.status)!=="ok")throw new Error("Not an AD4M executor")}catch(r){throw r.name==="AbortError"?new Error("Connection timed out"):r}finally{clearTimeout(n)}})}var We=class extends Error{constructor(t,e){super(`RPC error ${t}: ${e}`),this.name="RpcError",this.status=t,this.body=e}},fr=3e4,_a=3e4,hr=500,ya=0;function ba(){return String(++ya)}var Ae=class{constructor(t,e){this._ws=null,this._wsCallbacks=new Set,this._pendingCalls=new Map,this._wsReady=null,this._wsReadyResolve=null,this._wsReconnectTimer=null,this._wsReconnectDelay=hr,this._wsClosed=!1,this._wsPingTimer=null,this.baseUrl=t,this.token=e}getBaseUrl(){return this.baseUrl}getToken(){return this.token}setToken(t){this.token=t}_getWsUrl(){let t=this.baseUrl.replace(/^http:\/\//,"ws://").replace(/^https:\/\//,"wss://"),e=this.token?`token=${encodeURIComponent(this.token)}`:"",n="/api/v1/ws";return e?`${t}${n}?${e}`:`${t}${n}`}_ensureWs(){if(this._ws&&(this._ws.readyState===WebSocket.OPEN||this._ws.readyState===WebSocket.CONNECTING)||this._wsReady)return;this._wsClosed=!1,this._wsReady=new Promise(n=>{this._wsReadyResolve=n});let t=this._getWsUrl(),e=new WebSocket(t);this._ws=e,e.onopen=()=>{this._wsReconnectDelay=hr,this._wsReadyResolve&&(this._wsReadyResolve(),this._wsReadyResolve=null),this._startPing()},e.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch(a){console.error("Error parsing WebSocket data:",a);return}if(r.type==="pong")return;let s=r.id;if(s&&this._pendingCalls.has(s)){let a=this._pendingCalls.get(s);if(this._pendingCalls.delete(s),clearTimeout(a.timer),r.error){let o=r.error;a.reject(new We(o.code??500,o.message??"Unknown error"))}else a.resolve(r.result);return}for(let a of this._wsCallbacks)a(r)},e.onerror=n=>{console.error("WebSocket error:",n)},e.onclose=()=>{this._stopPing(),this._ws=null,this._wsReady=null;for(let[n,r]of this._pendingCalls)clearTimeout(r.timer),r.reject(new We(503,"WebSocket connection closed"));this._pendingCalls.clear(),!this._wsClosed&&(this._wsCallbacks.size>0||this._pendingCalls.size>0)&&this._scheduleReconnect()}}_startPing(){this._stopPing(),this._wsPingTimer=setInterval(()=>{this._ws&&this._ws.readyState===WebSocket.OPEN&&this._ws.send(JSON.stringify({type:"ping"}))},3e4)}_stopPing(){this._wsPingTimer&&(clearInterval(this._wsPingTimer),this._wsPingTimer=null)}_scheduleReconnect(){if(this._wsReconnectTimer)return;let t=this._wsReconnectDelay;this._wsReconnectDelay=Math.min(this._wsReconnectDelay*2,_a),this._wsReconnectTimer=setTimeout(()=>{this._wsReconnectTimer=null,this._wsClosed||this._ensureWs()},t)}async _ready(){this._ensureWs(),this._wsReady&&await this._wsReady}async call(t,e){await this._ready();let n=ba(),r={id:n,type:t,params:e||{}};return new Promise((s,a)=>{let o=setTimeout(()=>{this._pendingCalls.delete(n),a(new We(408,`RPC call '${t}' timed out after ${fr}ms`))},fr);this._pendingCalls.set(n,{resolve:s,reject:a,timer:o}),this._ws&&this._ws.readyState===WebSocket.OPEN?this._ws.send(JSON.stringify(r)):(this._pendingCalls.delete(n),clearTimeout(o),a(new We(503,"WebSocket not connected")))})}subscribe(t){return this._wsCallbacks.add(t),this._ensureWs(),()=>{this._wsCallbacks.delete(t),this._wsCallbacks.size===0&&this._pendingCalls.size===0&&this._closeWs()}}async waitForSubscription(){await this._ready()}connect(){this._ensureWs()}_closeWs(){this._stopPing(),this._wsReconnectTimer&&(clearTimeout(this._wsReconnectTimer),this._wsReconnectTimer=null),this._ws&&(this._wsClosed=!0,this._ws.close(),this._ws=null,this._wsReady=null)}closeAll(){for(let[t,e]of this._pendingCalls)clearTimeout(e.timer),e.reject(new We(503,"Client closed"));this._pendingCalls.clear(),this._closeWs(),this._wsCallbacks.clear()}};function Ke(i){class t{constructor(n,r,s,a){this.author=n,this.timestamp=r,this.data=s,this.proof=a}}return t}function va(i){class t{}return t}var pr=class extends Ke(){},gr=class extends Ke(){};var An=class{constructor(t){t?this.links=t:this.links=[]}get(t){if(!t||!t.source&&!t.predicate&&!t.target)return this.links;if(t.source){let n=JSON.parse(JSON.stringify(this.links));return t.target&&(n=n.filter(r=>r.data.target===t.target)),t.predicate&&(n=n.filter(r=>r.data.predicate===t.predicate)),t.fromDate&&(n=n.filter(r=>new Date(r.timestamp)>=t.fromDate)),t.untilDate&&(n=n.filter(r=>new Date(r.timestamp)<=t.untilDate)),t.limit&&(n=n.slice(0,t.limit)),n}if(t.target){let n=JSON.parse(JSON.stringify(this.links));return t.predicate&&(n=n.filter(r=>r.data.predicate===t.predicate)),t.fromDate&&(n=n.filter(r=>new Date(r.timestamp)>=t.fromDate)),t.untilDate&&(n=n.filter(r=>new Date(r.timestamp)<=t.untilDate)),t.limit&&(n=n.slice(0,t.limit)),n}let e=JSON.parse(JSON.stringify(this.links));return e=e.filter(n=>n.data.predicate===t.predicate),t.limit&&(e=e.slice(0,t.limit)),e}getSingleTarget(t){delete t.target;let e=this.get(t);return e.length?e[0].data.target:null}};var mr=class extends Ke(){},ui=class{constructor(t,e){this.did=t,e?this.perspective=e:this.perspective=new An}},wr=class extends Ke(){};var En=class{constructor(t,e,n,r=!1){this.email=t,this.remainingCredits=e,this.hotWalletAddress=n,this.freeAccess=r}};var lt=class{constructor(t){t?(this.isInitialized=t.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=t.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=t.did,this.didDocument=t.didDocument,this.error=t.error):(this.isInitialized=!1,this.isUnlocked=!1)}},_r=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},Q=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},ne,re,Tn=class{constructor(t,e){ne.set(this,void 0),re.set(this,void 0),_r(this,ne,t,"f"),_r(this,re,e,"f")}async otherAgents(){return await Q(this,ne,"f").otherAgents(Q(this,re,"f"))}async hasTelepresenceAdapter(){return await Q(this,ne,"f").hasTelepresenceAdapter(Q(this,re,"f"))}async onlineAgents(){return await Q(this,ne,"f").onlineAgents(Q(this,re,"f"))}async setOnlineStatus(t){return await Q(this,ne,"f").setOnlineStatus(Q(this,re,"f"),t)}async setOnlineStatusU(t){return await Q(this,ne,"f").setOnlineStatusU(Q(this,re,"f"),t)}async sendSignal(t,e){return await Q(this,ne,"f").sendSignal(Q(this,re,"f"),t,e)}async sendSignalU(t,e){return await Q(this,ne,"f").sendSignalU(Q(this,re,"f"),t,e)}async sendBroadcast(t,e=!1){return await Q(this,ne,"f").sendBroadcast(Q(this,re,"f"),t,e)}async sendBroadcastU(t,e=!1){return await Q(this,ne,"f").sendBroadcastU(Q(this,re,"f"),t,e)}async addSignalHandler(t){await Q(this,ne,"f").addSignalHandler(Q(this,re,"f"),t)}removeSignalHandler(t){Q(this,ne,"f").removeSignalHandler(Q(this,re,"f"),t)}};ne=new WeakMap,re=new WeakMap;var me=class{constructor(t){this.source=t.source?t.source:"",this.target=t.target?t.target:"",this.predicate=t.predicate?t.predicate:""}};var yr=class extends Ke(){hash(){let t=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,e=0,n,r;for(n=0;n<t.length;n++)r=t.charCodeAt(n),e=(e<<5)-e+r,e|=0;return e}},br=class extends va(){};var Z=class{constructor(t){t&&(this.source=t.source,this.predicate=t.predicate,this.target=t.target,t.fromDate&&(this.fromDate=t.fromDate),t.untilDate&&(this.untilDate=t.untilDate),t.limit&&(this.limit=t.limit))}isMatch(t){return!(this.source&&this.source!==t.source||this.predicate&&this.predicate!==t.predicate||this.target&&this.target!==t.target)}},vr=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},X=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},se,Le;function Li(i){return encodeURIComponent(i).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}var J=class{constructor(){se.set(this,void 0),Le.set(this,void 0)}static fromUrl(t){if(!t||!t.startsWith("literal:"))throw new Error("Can't create Literal from non-literal URL");if(t.startsWith("literal://"))throw new Error("literal:// format is no longer supported. Use literal: instead.");let e=new J;return vr(e,Le,t,"f"),e}static from(t){let e=new J;return vr(e,se,t,"f"),e}toUrl(){if(X(this,Le,"f")&&!X(this,se,"f"))return X(this,Le,"f");if(!X(this,Le,"f")&&(X(this,se,"f")===void 0||X(this,se,"f")===""||X(this,se,"f")===null))throw new Error("Can't turn empty Literal into URL");let t;switch(typeof X(this,se,"f")){case"string":t=`string:${Li(X(this,se,"f"))}`;break;case"number":t=`number:${Li(X(this,se,"f"))}`;break;case"boolean":t=`boolean:${Li(X(this,se,"f"))}`;break;case"object":t=`json:${Li(JSON.stringify(X(this,se,"f")))}`;break}return`literal:${t}`}get(){if(X(this,se,"f"))return X(this,se,"f");if(!X(this,Le,"f"))throw new Error("Can't render empty Literal");if(!X(this,Le,"f").startsWith("literal:"))throw new Error("Can't render Literal from non-literal URL");let t=X(this,Le,"f").substring(8);if(t.startsWith("string:"))return decodeURIComponent(t.substring(7));if(t.startsWith("number:")){let e=t.substring(7);return parseFloat(e)}if(t.startsWith("json:")){let e=t.substring(5);return JSON.parse(decodeURIComponent(e))}throw new Error(`Can't parse unknown literal: ${t}`)}};se=new WeakMap,Le=new WeakMap;function Ui(i){return i.charAt(0).toUpperCase()+i.slice(1)}function Yn(i){return`set${Ui(i)}`}function ks(i){let t="",e="abcdefghijklmnopqrstuvwxyz",n=e.length;for(let r=0;r<i;r++)t+=e.charAt(Math.floor(Math.random()*n));return t}function Ye(i){if(Array.isArray(i))return`[${i.map(Ye).join(", ")}]`;let t=Object.keys(i),e=[];for(let n of t){let r=JSON.stringify(i[n]),s=`${n}: ${r}`;e.push(s)}return`{${e.join(", ")}}`}function Sa(i,t,e,n){let r="",s=ks(8);r+=`subject_class("${i}", ${s}).
|
|
2
|
+
`;let a=[],o=[];t.subjectConstructor&&t.subjectConstructor.length&&(o=o.concat(t.subjectConstructor));let l=[];t.isSubjectInstance&&t.isSubjectInstance.length&&(l=l.concat(t.isSubjectInstance));let c=[];for(let u in e){let f=`property(${s}, "${u}").
|
|
3
|
+
`,{through:h,initial:w,required:y,resolveLanguage:v,writable:S,flag:b,prologGetter:T,prologSetter:O,local:C}=e[u];if(v&&(f+=`property_resolve(${s}, "${u}").
|
|
4
|
+
`,f+=`property_resolve_language(${s}, "${u}", "${v}").
|
|
5
|
+
`),T?f+=`property_getter(${s}, Base, "${u}", Value) :- ${T}.
|
|
6
|
+
`:h&&(f+=`property_getter(${s}, Base, "${u}", Value) :- triple(Base, "${h}", Value).
|
|
7
|
+
`,y&&(b?l.push(`triple(Base, "${h}", "${w}")`):l.push(`triple(Base, "${h}", _)`))),O)f+=`property_setter(${s}, "${u}", Actions) :- ${O}.
|
|
8
|
+
`;else if(S&&h&&typeof t[Yn(u)]=="function"){let x=[{action:"setSingleTarget",source:"this",predicate:h,target:"value",...C&&{local:!0}}];f+=`property_setter(${s}, "${u}", '${Ye(x)}').
|
|
9
|
+
`}c.push(f);let P=w??(y&&S&&!b&&h?"literal:string:":void 0);P&&(o.push({action:"addLink",source:"this",predicate:h,target:P}),a.push({action:"removeLink",source:"this",predicate:h,target:"*"}))}let d=[],g=Object.fromEntries(Object.entries(n).filter(([,u])=>u.kind==="hasMany"||u.kind==="belongsToMany"));for(let u in g){let f=`collection(${s}, "${u}").
|
|
10
|
+
`,{predicate:h,local:w}=g[u];if(h){f+=`collection_getter(${s}, Base, "${u}", List) :- findall(C, triple(Base, "${h}", C), List).
|
|
11
|
+
`;let y=[{action:"addLink",source:"this",predicate:h,target:"value",...w&&{local:!0}}],v=[{action:"removeLink",source:"this",predicate:h,target:"value"}],S=[{action:"collectionSetter",source:"this",predicate:h,target:"value",...w&&{local:!0}}];f+=`collection_adder(${s}, "${u}", '${Ye(y)}').
|
|
12
|
+
`,f+=`collection_remover(${s}, "${u}", '${Ye(v)}').
|
|
13
|
+
`,f+=`collection_setter(${s}, "${u}", '${Ye(S)}').
|
|
14
|
+
`}d.push(f)}let p=Ye(o);if(r+=`constructor(${s}, '${p}').
|
|
15
|
+
`,l.length>0){let u=l.join(", ");r+=`instance(${s}, Base) :- ${u}.
|
|
16
|
+
`,r+=`
|
|
17
|
+
`}return r+=`destructor(${s}, '${Ye(a)}').
|
|
18
|
+
`,r+=`
|
|
19
|
+
`,r+=c.join(`
|
|
20
|
+
`),r+=`
|
|
21
|
+
`,r+=d.join(`
|
|
22
|
+
`),{sdna:r,name:i}}function Sr(i){let t=i.lastIndexOf("#");if(t!==-1)return i.substring(0,t+1);let e=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)(.*)$/);if(e){let r=e[2],s=r.lastIndexOf("/");return s!==-1?e[1]+r.substring(0,s+1):e[1]}let n=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return n?n[1]:""}function Cr(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\b/g,"\\b").replace(/\f/g,"\\f")}function kr(i){let t=i.lastIndexOf("#");if(t!==-1)return i.substring(t+1);let e=i.lastIndexOf("/");if(e!==-1&&e<i.length-1)return i.substring(e+1);let n=i.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return n?n[1]:i}var Ze=class{constructor(t,e){if(e!==void 0)this.nodeShapeUri=t,this.targetClass=e;else{this.targetClass=t;let n=Sr(t),r=kr(t);this.nodeShapeUri=`${n}${r}Shape`}this.properties=[],this.parentShapes=[]}addParentShape(t){this.parentShapes.includes(t)||this.parentShapes.push(t)}addProperty(t){this.properties.push(t)}setConstructorActions(t){this.constructor_actions=t}setDestructorActions(t){this.destructor_actions=t}toTurtle(){let t=`@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
23
|
+
`;t+=`@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
24
|
+
`,t+=`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
25
|
+
`,t+=`@prefix ad4m: <ad4m://> .
|
|
26
|
+
|
|
27
|
+
`,t+=`<${this.nodeShapeUri}>
|
|
28
|
+
`,t+=` a sh:NodeShape ;
|
|
29
|
+
`,this.targetClass&&(t+=` sh:targetClass <${this.targetClass}> ;
|
|
30
|
+
`);for(let e of this.parentShapes)t+=` sh:node <${e}> ;
|
|
31
|
+
`;for(let e=0;e<this.properties.length;e++){let n=this.properties[e],r=e===this.properties.length-1;t+=` sh:property [
|
|
32
|
+
`,t+=` sh:path <${n.path}> ;
|
|
33
|
+
`,n.datatype&&(t+=` sh:datatype <${n.datatype}> ;
|
|
34
|
+
`),n.nodeKind&&(t+=` sh:nodeKind sh:${n.nodeKind} ;
|
|
35
|
+
`),n.minCount!==void 0&&(t+=` sh:minCount ${n.minCount} ;
|
|
36
|
+
`),n.maxCount!==void 0&&(t+=` sh:maxCount ${n.maxCount} ;
|
|
37
|
+
`),n.pattern&&(t+=` sh:pattern "${Cr(n.pattern)}" ;
|
|
38
|
+
`),n.minInclusive!==void 0&&(t+=` sh:minInclusive ${n.minInclusive} ;
|
|
39
|
+
`),n.maxInclusive!==void 0&&(t+=` sh:maxInclusive ${n.maxInclusive} ;
|
|
40
|
+
`),n.hasValue&&(t+=` sh:hasValue "${Cr(n.hasValue)}" ;
|
|
41
|
+
`),n.local!==void 0&&(t+=` ad4m:local ${n.local} ;
|
|
42
|
+
`),n.writable!==void 0&&(t+=` ad4m:writable ${n.writable} ;
|
|
43
|
+
`),t=t.slice(0,-2)+`
|
|
44
|
+
`,t+=r?` ] .
|
|
105
45
|
`:` ] ;
|
|
106
|
-
`}return e}toLinks(){let e=[];e.push({source:this.nodeShapeUri,predicate:"rdf://type",target:"sh://NodeShape"}),this.targetClass&&e.push({source:this.nodeShapeUri,predicate:"sh://targetClass",target:this.targetClass}),this.constructor_actions&&e.push({source:this.nodeShapeUri,predicate:"ad4m://constructor",target:`literal:string:${JSON.stringify(this.constructor_actions)}`}),this.destructor_actions&&e.push({source:this.nodeShapeUri,predicate:"ad4m://destructor",target:`literal:string:${JSON.stringify(this.destructor_actions)}`});for(let t=0;t<this.properties.length;t++){let n=this.properties[t],i;if(n.name&&this.targetClass){let a=Bp(this.targetClass),o=Qp(this.targetClass);i=`${a}${o}.${n.name}`}else i=`_:propShape${t}`;e.push({source:this.nodeShapeUri,predicate:"sh://property",target:i}),e.push({source:i,predicate:"sh://path",target:n.path}),n.datatype&&e.push({source:i,predicate:"sh://datatype",target:n.datatype}),n.nodeKind&&e.push({source:i,predicate:"sh://nodeKind",target:`sh://${n.nodeKind}`}),n.minCount!==void 0&&e.push({source:i,predicate:"sh://minCount",target:`literal:${n.minCount}^^xsd:integer`}),n.maxCount!==void 0&&e.push({source:i,predicate:"sh://maxCount",target:`literal:${n.maxCount}^^xsd:integer`}),n.pattern&&e.push({source:i,predicate:"sh://pattern",target:`literal:${n.pattern}`}),n.minInclusive!==void 0&&e.push({source:i,predicate:"sh://minInclusive",target:`literal:${n.minInclusive}`}),n.maxInclusive!==void 0&&e.push({source:i,predicate:"sh://maxInclusive",target:`literal:${n.maxInclusive}`}),n.hasValue&&e.push({source:i,predicate:"sh://hasValue",target:`literal:${n.hasValue}`}),n.local!==void 0&&e.push({source:i,predicate:"ad4m://local",target:`literal:${n.local}`}),n.writable!==void 0&&e.push({source:i,predicate:"ad4m://writable",target:`literal:${n.writable}`}),n.resolveLanguage&&e.push({source:i,predicate:"ad4m://resolveLanguage",target:`literal:string:${n.resolveLanguage}`}),n.setter&&n.setter.length>0&&e.push({source:i,predicate:"ad4m://setter",target:`literal:string:${JSON.stringify(n.setter)}`}),n.adder&&n.adder.length>0&&e.push({source:i,predicate:"ad4m://adder",target:`literal:string:${JSON.stringify(n.adder)}`}),n.remover&&n.remover.length>0&&e.push({source:i,predicate:"ad4m://remover",target:`literal:string:${JSON.stringify(n.remover)}`}),n.getter&&e.push({source:i,predicate:"ad4m://getter",target:`literal:string:${n.getter}`}),n.conformanceConditions&&n.conformanceConditions.length>0&&e.push({source:i,predicate:"ad4m://conformanceConditions",target:`literal:string:${JSON.stringify(n.conformanceConditions)}`}),n.class&&e.push({source:i,predicate:"sh://class",target:n.class})}return e}static fromLinks(e,t){let n=e.find(c=>c.source===t&&c.predicate==="sh://targetClass"),i=new Wr(t,n?.target),a=e.find(c=>c.source===t&&c.predicate==="ad4m://constructor");if(a)try{let c=a.target.replace(/^literal:\/\/string:|^literal:string:/,"");i.constructor_actions=JSON.parse(c)}catch{}let o=e.find(c=>c.source===t&&c.predicate==="ad4m://destructor");if(o)try{let c=o.target.replace(/^literal:\/\/string:|^literal:string:/,"");i.destructor_actions=JSON.parse(c)}catch{}let s=e.filter(c=>c.source===t&&c.predicate==="sh://property");for(let c of s){let u=c.target,l=e.find(O=>O.source===u&&O.predicate==="sh://path");if(!l)continue;let d;if(!u.startsWith("_:")){let O=u.lastIndexOf(".");O!==-1&&(d=u.substring(O+1))}let p={name:d,path:l.target},f=e.find(O=>O.source===u&&O.predicate==="sh://datatype");f&&(p.datatype=f.target);let h=e.find(O=>O.source===u&&O.predicate==="sh://nodeKind");h&&(p.nodeKind=h.target.replace("sh://",""));let m=e.find(O=>O.source===u&&O.predicate==="sh://minCount");if(m){let O=m.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");O.startsWith("number:")&&(O=O.substring(7)),p.minCount=parseInt(O)}let g=e.find(O=>O.source===u&&O.predicate==="sh://maxCount");if(g){let O=g.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");O.startsWith("number:")&&(O=O.substring(7)),p.maxCount=parseInt(O)}let _=e.find(O=>O.source===u&&O.predicate==="sh://pattern");_&&(p.pattern=_.target.replace(/^literal:\/\/|^literal:/,""));let w=e.find(O=>O.source===u&&O.predicate==="sh://minInclusive");if(w){let O=w.target.replace(/^literal:\/\/|^literal:/,"");O.startsWith("number:")&&(O=O.substring(7)),p.minInclusive=parseFloat(O)}let y=e.find(O=>O.source===u&&O.predicate==="sh://maxInclusive");if(y){let O=y.target.replace(/^literal:\/\/|^literal:/,"");O.startsWith("number:")&&(O=O.substring(7)),p.maxInclusive=parseFloat(O)}let b=e.find(O=>O.source===u&&O.predicate==="sh://hasValue");b&&(p.hasValue=b.target.replace(/^literal:\/\/|^literal:/,""));let I=e.find(O=>O.source===u&&O.predicate==="ad4m://local");if(I){let O=I.target.replace(/^literal:\/\/|^literal:/,"");O.startsWith("boolean:")&&(O=O.substring(8)),p.local=O==="true"}let A=e.find(O=>O.source===u&&O.predicate==="ad4m://writable");if(A){let O=A.target.replace(/^literal:\/\/|^literal:/,"");O.startsWith("boolean:")&&(O=O.substring(8)),p.writable=O==="true"}let E=e.find(O=>O.source===u&&O.predicate==="ad4m://resolveLanguage");E&&(p.resolveLanguage=E.target.replace(/^literal:\/\/string:|^literal:string:/,""));let R=e.find(O=>O.source===u&&O.predicate==="ad4m://setter");if(R)try{let O=R.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.setter=JSON.parse(O)}catch{}let L=e.find(O=>O.source===u&&O.predicate==="ad4m://adder");if(L)try{let O=L.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.adder=JSON.parse(O)}catch{}let N=e.find(O=>O.source===u&&O.predicate==="ad4m://remover");if(N)try{let O=N.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.remover=JSON.parse(O)}catch{}let F=e.find(O=>O.source===u&&O.predicate==="ad4m://getter");F&&(p.getter=F.target.replace(/^literal:\/\/string:|^literal:string:/,""));let _e=e.find(O=>O.source===u&&O.predicate==="ad4m://conformanceConditions");if(_e)try{let O=_e.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.conformanceConditions=JSON.parse(O)}catch{}let Ee=e.find(O=>O.source===u&&O.predicate==="sh://class");Ee&&(p.class=Ee.target),i.addProperty(p)}return i}toJSON(){return{node_shape_uri:this.nodeShapeUri,target_class:this.targetClass,parent_shapes:this.parentShapes.length>0?this.parentShapes:void 0,properties:this.properties.map(e=>({path:e.path,name:e.name,datatype:e.datatype,node_kind:e.nodeKind,min_count:e.minCount,max_count:e.maxCount,min_inclusive:e.minInclusive,max_inclusive:e.maxInclusive,pattern:e.pattern,has_value:e.hasValue,local:e.local,writable:e.writable,resolve_language:e.resolveLanguage,setter:e.setter,adder:e.adder,remover:e.remover,getter:e.getter,conformance_conditions:e.conformanceConditions,class:e.class})),constructor_actions:this.constructor_actions,destructor_actions:this.destructor_actions}}static fromJSON(e){let t=e.node_shape_uri?new Wr(e.node_shape_uri,e.target_class):new Wr(e.target_class);for(let n of e.properties||[])t.addProperty({path:n.path,name:n.name,datatype:n.datatype,nodeKind:n.node_kind,minCount:n.min_count,maxCount:n.max_count,minInclusive:n.min_inclusive,maxInclusive:n.max_inclusive,pattern:n.pattern,hasValue:n.has_value,local:n.local,writable:n.writable,resolveLanguage:n.resolve_language,setter:n.setter,adder:n.adder,remover:n.remover,getter:n.getter,conformanceConditions:n.conformance_conditions,class:n.class});if(e.constructor_actions&&(t.constructor_actions=e.constructor_actions),e.destructor_actions&&(t.destructor_actions=e.destructor_actions),e.parent_shapes)for(let n of e.parent_shapes)t.addParentShape(n);return t}};function zp(r){return r?.length?r.length===1?r.toString():r.length===2?r.join(" and "):r.slice(0,-1).join(", ")+", and "+r.slice(-1):""}function gA(r){let e=r.can.includes("*")?["READ","WRITE","UPDATE"]:r.can,t=r.with.domain==="*"?"":r.with.domain,n=r.with.pointers.includes("*")?["all AD4M data"]:r.with.pointers;return`${zp(e)} your ${t} actions, with access to ${zp(n)}`}function vr(r){return r.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function cv(r){return typeof r=="string"?`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`:typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?`[${r.map(e=>cv(e)).join(", ")}]`:String(r)}function uv(r,e,t){let n=vr(r),i=!t?.resolveLanguage||t.resolveLanguage==="literal";function a(o){return typeof o=="string"?i?`<literal:string:${vr(o)}>`:`<${vr(o)}>`:`<literal:string:${o}>`}if(Array.isArray(e)){let o=e.map(a).join(", ");return`FILTER EXISTS { ?target <${n}> ?_val . FILTER(?_val IN (${o})) }`}else if(typeof e=="object"&&e!==null){let o=e,s=[];if(o.not!==void 0)if(Array.isArray(o.not)){let u=o.not.map(l=>a(l)).join(", ");s.push(`FILTER NOT EXISTS { ?target <${n}> ?_nval . FILTER(?_nval IN (${u})) }`)}else s.push(`FILTER NOT EXISTS { ?target <${n}> ${a(o.not)} }`);return(o.gt!==void 0||o.gte!==void 0||o.lt!==void 0||o.lte!==void 0||o.between!==void 0||o.contains!==void 0)&&s.push(`FILTER EXISTS { ?target <${n}> ?_cmp }`),s.join(" ")}else return`?target <${n}> ${a(e)} .`}function yh(r,e){let t=[];for(let[n,i]of Object.entries(r)){if(["id","author","timestamp"].includes(n))continue;let a,o;if(e){let c=e.properties[n];c?(a=c.predicate,o=c.resolveLanguage):a=n}else a=n;let s=uv(a,i,{resolveLanguage:o});s&&t.push(s)}return t}function lv(r,e,t,n,i){let a=e.prototype,o="ad4m://",s=Object.fromEntries(Object.entries(n).filter(([,h])=>h.kind==="hasMany"||h.kind==="belongsToMany"));if(Object.keys(t).length>0){let h=t[Object.keys(t)[0]];if(h.through){let m=h.through.match(/^([^:]+:\/\/)/);m&&(o=m[1])}}else if(Object.keys(s).length>0){let h=s[Object.keys(s)[0]];if(h.predicate){let m=h.predicate.match(/^([^:]+:\/\/)/);m&&(o=m[1])}}let c=`${o}${r}Shape`,u=`${o}${r}`,l=new Wr(c,u),d=Object.getPrototypeOf(e);if(d&&typeof d.generateSHACL=="function"){let h=d.generateSHACL();h?.shape?.nodeShapeUri&&l.addParentShape(h.shape.nodeShapeUri)}let p=[];a.subjectConstructor&&a.subjectConstructor.length&&(p=p.concat(a.subjectConstructor));let f=[];for(let h in t){let m=t[h];if(!m.through)continue;let g={name:h,path:m.through};if(m.resolveLanguage==="literal")g.datatype="xsd://string";else if(m.initial){let w=typeof a[h];w==="number"?g.datatype="xsd://integer":w==="boolean"?g.datatype="xsd://boolean":w==="string"&&(g.datatype="xsd://string")}m.required&&(g.minCount=1),g.maxCount=1,m.flag&&m.initial&&(g.hasValue=m.initial),m.local!==void 0&&(g.local=m.local),m.writable!==void 0&&(g.writable=m.writable),m.resolveLanguage&&(g.resolveLanguage=m.resolveLanguage),m.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${h}' in class '${r}' is not yet supported. The property will be created without setter actions. Consider using standard writable properties or provide explicit SHACL JSON.`):m.writable&&m.through&&typeof a[Xs(h)]=="function"&&(g.setter=[{action:"setSingleTarget",source:"this",predicate:m.through,target:"value",...m.local&&{local:!0}}]);let _=m.initial??(m.required&&m.writable&&!m.flag&&m.through?"literal:string:":void 0);_&&(p.push({action:"addLink",source:"this",predicate:m.through,target:_}),f.push({action:"removeLink",source:"this",predicate:m.through,target:"*"})),l.addProperty(g)}for(let h in s){let m=s[h];if(!m.predicate)continue;let g={name:h,path:m.predicate};if(g.nodeKind="IRI",m.local!==void 0&&(g.local=m.local),g.adder=[{action:"addLink",source:"this",predicate:m.predicate,target:"value",...m.local&&{local:!0}}],g.remover=[{action:"removeLink",source:"this",predicate:m.predicate,target:"value",...m.local&&{local:!0}}],m.getter)g.getter=m.getter;else if(m.where)try{let _=m.target?.(),w=_?_.getModelMetadata?.()??null:null,y=yh(m.where,w);if(y.length>0){let b=vr(m.predicate);g.getter=`SELECT ?target WHERE { <Base> <${b}> ?target . ${y.join(" ")} }`}}catch{}else if(m.target&&m.filter!==!1){let _=m.target,w=m.predicate,y=!1,b,I,A=()=>{if(!y){y=!0;try{let E=_(),R=i(w,E);R&&(b=R.getter,I=R.conformanceConditions)}catch{}}};Object.defineProperty(g,"getter",{get(){return A(),b},set(E){y=!0,b=E},enumerable:!0,configurable:!0}),Object.defineProperty(g,"conformanceConditions",{get(){return A(),I},set(E){y=!0,I=E},enumerable:!0,configurable:!0})}if(m.target)try{let w=m.target().generateSHACL?.();w?.shape?.nodeShapeUri&&(g.class=w.shape.nodeShapeUri)}catch{}l.addProperty(g)}return l.setConstructorActions(p),l.setDestructorActions(f),{shape:l,name:r}}var tr=new WeakMap,et=new WeakMap,Hp=new WeakMap,Wp=new WeakMap,Gp=new WeakMap;function Un(r){let e=Hp.get(r);if(e)return e;let t={},n=[],i=r;for(;i&&i!==Object;)n.unshift(i),i=Object.getPrototypeOf(i);for(let a of n){let o=tr.get(a);o&&Object.assign(t,o)}return Hp.set(r,t),t}function ht(r){let e=Wp.get(r);if(e)return e;let t={},n=[],i=r;for(;i&&i!==Object;)n.unshift(i),i=Object.getPrototypeOf(i);for(let a of n){let o=et.get(a);o&&Object.assign(t,o)}return Wp.set(r,t),t}function fv(r,e){let t=Gp.get(r);if(t)return t;let n=e();return Gp.set(r,n),n}function pv(r,e,t){tr.has(r)||tr.set(r,{}),tr.get(r)[e]=t}function dv(r,e,t){et.has(r)||et.set(r,{}),et.get(r)[e]=t}function vh(r,e){try{let t=Un(e),n=[],i=[],a=0;for(let[s,c]of Object.entries(t))c.flag&&c.initial&&c.through&&(n.push({type:"flag",predicate:c.through,value:c.initial}),i.push(`?target <${vr(c.through)}> <${vr(c.initial)}> .`));for(let[s,c]of Object.entries(t))c.required&&!c.flag&&!c.getter&&c.through&&(n.push({type:"required",predicate:c.through}),i.push(`?target <${vr(c.through)}> ?_v${a++} .`));return n.length===0?void 0:{getter:`SELECT ?target WHERE { <Base> <${vr(r)}> ?target . ${i.join(" ")} }`,conformanceConditions:n}}catch{return}}function ec(r){return function(e,t){let n=r.readOnly?!1:!!r.through;if(r.required&&!r.initial)throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");if(!r.through&&!r.prologGetter&&!r.getter)throw new Error("SubjectProperty requires either 'through' or 'prologGetter' or 'getter' option");let i=e.constructor;if(tr.has(i)||tr.set(i,{}),tr.get(i)[t]={...r,writable:n},n){let a=t;e[`set${st(a)}`]=()=>{}}Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function yA(r){return ec({...r,required:r.required??!1,readOnly:r.readOnly??!1})}function vA(r){return function(e,t){if(!r.through&&!r.value)throw new Error("SubjectFlag requires a 'through' and 'value' option");if(!r.through)throw new Error("SubjectFlag requires a 'through' option");if(!r.value)throw new Error("SubjectFlag requires a 'value' option");let n={through:r.through,required:!0,initial:r.value,flag:!0,readOnly:!0,writable:!1},i=e.constructor;tr.has(i)||tr.set(i,{}),tr.get(i)[t]=n,e[t]=r.value,Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function hv(r){return function(e){e.prototype.className=r.name,e.className=r.name,e.generateSDNA=function(){return sv(r.name,e.prototype,Un(e),ht(e))},e.generateSHACL=function(){return fv(e,()=>lv(r.name,e,Un(e),ht(e),vh))},Object.defineProperty(e,"type",{configurable:!0})}}function mv(r){let e=r.required??!1;return ec({...r,required:e,readOnly:r.readOnly??!1,resolveLanguage:r.resolveLanguage??"literal",initial:r.initial??(e?"literal:string:uninitialized":void 0)})}function bA(r){return mv({...r,readOnly:!0})}function tc(r,e){let t=typeof r=="function"?{...e||{},target:r}:r;if(t.getter){if(t.through)throw new Error("Relation decorator: `getter` and `through` are mutually exclusive. Use `getter` alone for custom read-only relations, or `through` (with optional `target`) for standard link-based relations.");if(t.target)throw new Error("Relation decorator: `getter` and `target` are mutually exclusive. `target` auto-generates a conformance getter from the model shape; providing both is contradictory.");if(t.where)throw new Error("Relation decorator: `where` and `getter` are mutually exclusive. Use `where` for DSL-based filtering, or `getter` for raw getter expression.");return t}if(t.through||(t.through="ad4m://has_child"),t.where&&t.filter===!1)throw new Error("Relation decorator: `where` and `filter: false` are contradictory. `where` adds filtering constraints; `filter: false` disables filtering.");return t}function wA(r,e){let t=tc(r,e);return function(n,i){let a=n.constructor;et.has(a)||et.set(a,{});let o=et.get(a);o[i]={predicate:t.through,target:t.target,kind:"hasMany",local:t.local,...t.getter&&{getter:t.getter},...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}};let s=i;t.through&&(n[`add${st(s)}`]=async function(c,u){return this.addRelationValue(s,c,u)},n[`remove${st(s)}`]=async function(c,u){return this.removeRelationValue(s,c,u)},n[`set${st(s)}`]=async function(c,u){return this.setRelationValues(s,c,u)}),Object.defineProperty(n,s,{configurable:!0,writable:!0})}}function SA(r,e){let t=tc(r,e);return function(n,i){let a=n.constructor;et.has(a)||et.set(a,{});let o=et.get(a);o[i]={predicate:t.through,target:t.target,kind:"hasOne",maxCount:1,local:t.local,...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}};let s=i;t.through?(ec({through:t.through,readOnly:!1,local:t.local})(n,i),n[`add${st(s)}`]=async function(c){return this.addRelationValue(s,c)},n[`remove${st(s)}`]=async function(c){return this.removeRelationValue(s,c)},n[`set${st(s)}`]=async function(c){return this.setRelationValues(s,c)}):Object.defineProperty(n,s,{configurable:!0,writable:!0})}}function _A(r,e){let t=tc(r,e);return function(n,i){let a=n.constructor;et.has(a)||et.set(a,{});let o=et.get(a);o[i]={predicate:t.through,target:t.target,kind:"belongsToOne",maxCount:1,local:t.local,...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}},t.through?ec({through:t.through,readOnly:!0,local:t.local})(n,i):Object.defineProperty(n,i,{configurable:!0,writable:!0})}}function EA(r,e){let t=tc(r,e);return function(n,i){let a=n.constructor;et.has(a)||et.set(a,{});let o=et.get(a);o[i]={predicate:t.through,target:t.target,kind:"belongsToMany",local:t.local,...t.getter&&{getter:t.getter},...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}},Object.defineProperty(n,i,{configurable:!0,writable:!0})}}var br=new Map,gv=200;function bh(r,e){return`${r}:${e}`}function yv(r,e){let t=bh(r,e),n=br.get(t);if(!!n){if(Date.now()>n.expiry){br.delete(t);return}return n.result}}function vv(r,e,t,n=gv){let i=Date.now();for(let[o,s]of br)i>s.expiry&&br.delete(o);let a=bh(r,e);br.set(a,{result:t,expiry:i+n})}function Lr(r){let e=r+":";for(let[t]of br)t.startsWith(e)&&br.delete(t)}function xA(){br.clear()}function IA(){return br.size}var Ni=class{constructor(e,t){this.flowable="any",this.startAction=[],this._states=[],this._transitions=[],this.name=e,this.namespace=t}get states(){return[...this._states]}get transitions(){return[...this._transitions]}addState(e){this._states.push(e)}addTransition(e){this._transitions.push(e)}get flowUri(){return`${this.namespace}${this.name}Flow`}stateUri(e){return`${this.namespace}${this.name}.${e}`}transitionUri(e,t){return`${this.namespace}${this.name}.${e}To${t}`}toLinks(){let e=[],t=this.flowUri;e.push({source:t,predicate:"rdf://type",target:"ad4m://Flow"}),e.push({source:t,predicate:"ad4m://flowName",target:be.from(this.name).toUrl()}),this.flowable==="any"?e.push({source:t,predicate:"ad4m://flowable",target:"ad4m://any"}):e.push({source:t,predicate:"ad4m://flowable",target:`literal:string:${encodeURIComponent(JSON.stringify(this.flowable))}`}),this.startAction.length>0&&e.push({source:t,predicate:"ad4m://startAction",target:`literal:string:${encodeURIComponent(JSON.stringify(this.startAction))}`});for(let n of this._states){let i=this.stateUri(n.name);e.push({source:t,predicate:"ad4m://hasState",target:i}),e.push({source:i,predicate:"rdf://type",target:"ad4m://FlowState"}),e.push({source:i,predicate:"ad4m://stateName",target:be.from(n.name).toUrl()}),e.push({source:i,predicate:"ad4m://stateValue",target:be.from(n.value).toUrl()}),e.push({source:i,predicate:"ad4m://stateCheck",target:`literal:string:${encodeURIComponent(JSON.stringify(n.stateCheck))}`})}for(let n of this._transitions){let i=this.transitionUri(n.fromState,n.toState),a=this.stateUri(n.fromState),o=this.stateUri(n.toState);e.push({source:t,predicate:"ad4m://hasTransition",target:i}),e.push({source:i,predicate:"rdf://type",target:"ad4m://FlowTransition"}),e.push({source:i,predicate:"ad4m://actionName",target:be.from(n.actionName).toUrl()}),e.push({source:i,predicate:"ad4m://fromState",target:a}),e.push({source:i,predicate:"ad4m://toState",target:o}),e.push({source:i,predicate:"ad4m://transitionActions",target:`literal:string:${encodeURIComponent(JSON.stringify(n.actions))}`})}return e}static fromLinks(e,t){let n="Flow";if(!t.endsWith(n))throw new Error(`Invalid flow URI: ${t} (must end with 'Flow')`);let i=t.slice(0,-n.length),a=Math.max(i.lastIndexOf("/"),i.lastIndexOf(":")),o=i.slice(0,a+1),s=i.slice(a+1),c=new Ni(s,o),u=e.find(h=>h.source===t&&h.predicate==="ad4m://flowable");if(u)if(u.target==="ad4m://any")c.flowable="any";else try{let h=u.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.flowable=JSON.parse(decodeURIComponent(h))}catch{c.flowable="any"}let l=e.find(h=>h.source===t&&h.predicate==="ad4m://startAction");if(l)try{let h=l.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.startAction=JSON.parse(decodeURIComponent(h))}catch{}let d=e.filter(h=>h.source===t&&h.predicate==="ad4m://hasState"),p=new Map;for(let h of d){let m=h.target,g=e.find(A=>A.source===m&&A.predicate==="ad4m://stateName"),_=g?be.fromUrl(g.target).get():"";p.set(m,_);let w=e.find(A=>A.source===m&&A.predicate==="ad4m://stateValue"),y=w?be.fromUrl(w.target).get():0,b=e.find(A=>A.source===m&&A.predicate==="ad4m://stateCheck"),I={predicate:"",target:""};if(b)try{let A=b.target.replace(/^literal:\/\/string:|^literal:string:/,"");I=JSON.parse(decodeURIComponent(A))}catch{}c.addState({name:_,value:y,stateCheck:I})}let f=e.filter(h=>h.source===t&&h.predicate==="ad4m://hasTransition");for(let h of f){let m=h.target,g=e.find(N=>N.source===m&&N.predicate==="ad4m://actionName"),_=g?be.fromUrl(g.target).get():"",y=e.find(N=>N.source===m&&N.predicate==="ad4m://fromState")?.target||"",b=p.get(y)||"",A=e.find(N=>N.source===m&&N.predicate==="ad4m://toState")?.target||"",E=p.get(A)||"",R=e.find(N=>N.source===m&&N.predicate==="ad4m://transitionActions"),L=[];if(R)try{let N=R.target.replace(/^literal:\/\/string:|^literal:string:/,"");L=JSON.parse(decodeURIComponent(N))}catch{}c.addTransition({actionName:_,fromState:b,toState:E,actions:L})}return c}toJSON(){return{name:this.name,namespace:this.namespace,flowable:this.flowable,startAction:this.startAction,states:this._states,transitions:this._transitions}}static fromJSON(e){let t=new Ni(e.name,e.namespace);t.flowable=e.flowable||"any",t.startAction=e.startAction||[];for(let n of e.states||[])t.addState(n);for(let n of e.transitions||[])t.addTransition(n);return t}},de=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},P=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},vs,Ti,jr,wn,On,qr,Br,Sn,ba,bs,_n,En,Ot,wa,Ku,Y,pe,xn,In,Tn,Sa,_a,Ms=class{constructor(e,t,n){vs.add(this),Ti.set(this,void 0),jr.set(this,void 0),wn.set(this,void 0),On.set(this,void 0),qr.set(this,void 0),Br.set(this,void 0),Sn.set(this,void 0),ba.set(this,!1),bs.set(this,void 0),_n.set(this,void 0),En.set(this,void 0),Ot.set(this,void 0),wa.set(this,void 0),de(this,Ti,e,"f"),de(this,wa,t,"f"),de(this,wn,n,"f"),de(this,On,new Set,"f"),de(this,Sn,null,"f"),de(this,bs,new Promise((i,a)=>{de(this,_n,i,"f"),de(this,En,a,"f")}),"f")}async subscribe(){P(this,Br,"f")&&(P(this,Br,"f").call(this),de(this,Br,void 0,"f")),P(this,Ot,"f")&&(clearTimeout(P(this,Ot,"f")),de(this,Ot,void 0,"f")),P(this,qr,"f")&&(clearTimeout(P(this,qr,"f")),de(this,qr,void 0,"f"));try{let t;t=await P(this,wn,"f").subscribeQuery(P(this,Ti,"f"),P(this,wa,"f")),de(this,jr,t.subscriptionId,"f"),t.result?(de(this,Sn,t.result,"f"),P(this,vs,"m",Ku).call(this,t.result)):console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),de(this,Ot,setTimeout(()=>{console.error("Subscription initialization timed out after 30 seconds. Resubscribing..."),this.subscribe().catch(n=>{console.error("Error during subscription retry after timeout:",n)})},3e4),"f"),de(this,Br,P(this,wn,"f").subscribeToQueryUpdates(P(this,jr,"f"),n=>{P(this,Ot,"f")&&(clearTimeout(P(this,Ot,"f")),de(this,Ot,void 0,"f")),P(this,_n,"f")&&(P(this,_n,"f").call(this,!0),de(this,_n,void 0,"f"),de(this,En,void 0,"f")),!(n.isInit&&P(this,Sn,"f"))&&(de(this,Sn,n,"f"),P(this,vs,"m",Ku).call(this,n))}),"f")}catch(t){throw console.error("Error setting up subscription:",t),P(this,En,"f")&&(P(this,En,"f").call(this,t),de(this,_n,void 0,"f"),de(this,En,void 0,"f")),t}let e=async()=>{if(!P(this,ba,"f")){try{await P(this,wn,"f").keepAliveQuery(P(this,Ti,"f"),P(this,jr,"f"))}catch(t){console.error("Error in keepalive:",t),console.log("Reinitializing subscription for query:",P(this,wa,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(n){console.error("Error during resubscription from keepalive:",n);return}}P(this,ba,"f")||de(this,qr,setTimeout(e,3e4),"f")}};de(this,qr,setTimeout(e,3e4),"f")}get id(){return P(this,jr,"f")}get initialized(){return P(this,bs,"f")}get result(){return P(this,Sn,"f")}onResult(e){return P(this,On,"f").add(e),()=>P(this,On,"f").delete(e)}dispose(){de(this,ba,!0,"f"),clearTimeout(P(this,qr,"f")),P(this,Br,"f")&&P(this,Br,"f").call(this),P(this,On,"f").clear(),P(this,Ot,"f")&&(clearTimeout(P(this,Ot,"f")),de(this,Ot,void 0,"f")),P(this,jr,"f")&&P(this,wn,"f").disposeQuerySubscription(P(this,Ti,"f"),P(this,jr,"f")).catch(e=>console.error("Error disposing query subscription:",e))}};Ti=new WeakMap,jr=new WeakMap,wn=new WeakMap,On=new WeakMap,qr=new WeakMap,Br=new WeakMap,Sn=new WeakMap,ba=new WeakMap,bs=new WeakMap,_n=new WeakMap,En=new WeakMap,Ot=new WeakMap,wa=new WeakMap,vs=new WeakSet,Ku=function r(e){for(let t of P(this,On,"f"))try{t(e)}catch(n){console.error("Error in query subscription callback:",n)}};var Ju=class{constructor(e,t){Y.set(this,void 0),pe.set(this,void 0),xn.set(this,void 0),In.set(this,void 0),Tn.set(this,void 0),Sa.set(this,void 0),_a.set(this,new Set),de(this,xn,[],"f"),de(this,In,[],"f"),de(this,Tn,[],"f"),de(this,Sa,[],"f"),de(this,Y,e,"f"),de(this,pe,t,"f"),this.uuid=P(this,Y,"f").uuid,this.name=P(this,Y,"f").name,this.owners=P(this,Y,"f").owners,this.sharedUrl=P(this,Y,"f").sharedUrl,this.neighbourhood=P(this,Y,"f").neighbourhood,this.state=P(this,Y,"f").state,P(this,pe,"f").addPerspectiveLinkAddedListener(P(this,Y,"f").uuid,P(this,xn,"f")),P(this,pe,"f").addPerspectiveLinkRemovedListener(P(this,Y,"f").uuid,P(this,In,"f")),P(this,pe,"f").addPerspectiveLinkUpdatedListener(P(this,Y,"f").uuid,P(this,Tn,"f")),P(this,pe,"f").addPerspectiveSyncStateChangeListener(P(this,Y,"f").uuid,P(this,Sa,"f"))}updateHandle(e){if(e.uuid!==P(this,Y,"f").uuid)throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch \u2014 proxy is bound to "${P(this,Y,"f").uuid}" but received handle with UUID "${e.uuid}". This would silently diverge from listeners registered under the original UUID.`);de(this,Y,e,"f"),this.uuid=e.uuid,this.name=e.name,this.owners=e.owners,this.sharedUrl=e.sharedUrl,this.neighbourhood=e.neighbourhood,this.state=e.state}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(e,t,n,i){let a=await P(this,pe,"f").executeCommands(P(this,Y,"f").uuid,JSON.stringify(e),t,JSON.stringify(n),i);return Lr(P(this,Y,"f").uuid),a}async get(e){return await P(this,pe,"f").queryLinks(P(this,Y,"f").uuid,e)}async infer(e){return await P(this,pe,"f").queryProlog(P(this,Y,"f").uuid,e)}async querySparql(e){let t=yv(P(this,Y,"f").uuid,e);if(t!==void 0)return t;let n=await P(this,pe,"f").querySparql(P(this,Y,"f").uuid,e);return vv(P(this,Y,"f").uuid,e,n),n}async add(e,t="shared",n){let i=await P(this,pe,"f").addLink(P(this,Y,"f").uuid,e,t,n);return Lr(P(this,Y,"f").uuid),i}async addLinks(e,t="shared",n){let i=await P(this,pe,"f").addLinks(P(this,Y,"f").uuid,e,t,n);return Lr(P(this,Y,"f").uuid),i}async removeLinks(e,t){let n=await P(this,pe,"f").removeLinks(P(this,Y,"f").uuid,e,t);return Lr(P(this,Y,"f").uuid),n}async linkMutations(e,t="shared"){let n=await P(this,pe,"f").linkMutations(P(this,Y,"f").uuid,e,t);return Lr(P(this,Y,"f").uuid),n}async addLinkExpression(e,t="shared",n){return await P(this,pe,"f").addLinkExpression(P(this,Y,"f").uuid,e,t,n)}async update(e,t,n){let i=await P(this,pe,"f").updateLink(P(this,Y,"f").uuid,e,t,n);return Lr(P(this,Y,"f").uuid),i}async remove(e,t){let n=await P(this,pe,"f").removeLink(P(this,Y,"f").uuid,e,t);return Lr(P(this,Y,"f").uuid),n}async createBatch(){return await P(this,pe,"f").createBatch(P(this,Y,"f").uuid)}async commitBatch(e){let t=await P(this,pe,"f").commitBatch(P(this,Y,"f").uuid,e);return Lr(P(this,Y,"f").uuid),t}async getExpression(e){return await P(this,pe,"f").getExpression(e)}async createExpression(e,t){return await P(this,pe,"f").createExpression(e,t)}async addListener(e,t){e==="link-added"?P(this,xn,"f").push(t):e==="link-removed"?P(this,In,"f").push(t):e==="link-updated"&&P(this,Tn,"f").push(t)}async addSyncStateChangeListener(e){P(this,Sa,"f").push(e)}async removeListener(e,t){if(e==="link-added"){let n=P(this,xn,"f").indexOf(t);P(this,xn,"f").splice(n,1)}else if(e==="link-removed"){let n=P(this,In,"f").indexOf(t);P(this,In,"f").splice(n,1)}else if(e==="link-updated"){let n=P(this,Tn,"f").indexOf(t);P(this,Tn,"f").splice(n,1)}}async snapshot(){return P(this,pe,"f").snapshotByUUID(P(this,Y,"f").uuid)}async loadSnapshot(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(n=>{delete n.data.__typename});for(let n of t.links)await this.addLinkExpression(n)}async getSingleTarget(e){delete e.target;let t=await this.get(e);return t.length?t[0].data.target:null}async setSingleTarget(e,t="shared"){let n=new W({source:e.source,predicate:e.predicate}),i=await this.get(n),a=[];for(let s of i)delete s.__typename,delete s.data.__typename,delete s.proof.__typename,a.push(s);let o=[e];await this.linkMutations({additions:o,removals:a},t)}async sdnaFlows(){return(await this.get(new W({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(t=>{try{return be.fromUrl(t.data.target).get()}catch{return t.data.target}})}async availableFlows(e){let t=await this.sdnaFlows(),n=[];for(let i of t){let a=await this.getFlow(i);if(!!a)if(a.flowable==="any")n.push(i);else{let o=a.flowable,s=o.source||e;(await this.get(new W({source:s,predicate:o.predicate,target:o.target}))).length>0&&n.push(i)}}return n}async startFlow(e,t){let n=await this.getFlow(e);if(!n)throw`Flow "${e}" not found`;if(n.startAction.length===0)throw`Flow "${e}" has no start action`;await this.executeAction(n.startAction,t,void 0)}async expressionsInFlowState(e,t){let n=await this.getFlow(e);if(!n)return[];let i=n.states.find(s=>s.value===t);if(!i)return[];let a=i.stateCheck;return(await this.get(new W({predicate:a.predicate,target:a.target}))).map(s=>a.source?s.data.target:s.data.source)}async flowState(e,t){let n=await this.getFlow(e);if(!n)throw`Flow "${e}" not found`;for(let i of n.states){let a=i.stateCheck,o=a.source||t;if((await this.get(new W({source:o,predicate:a.predicate,target:a.target}))).length>0)return i.value}throw`Expression "${t}" is not in any state of flow "${e}"`}async flowActions(e,t){let n=await this.getFlow(e);if(!n)return[];let i=null;for(let a of n.states){let o=a.stateCheck,s=o.source||t;if((await this.get(new W({source:s,predicate:o.predicate,target:o.target}))).length>0){i=a.name;break}}return i?n.transitions.filter(a=>a.fromState===i).map(a=>a.actionName):[]}async runFlowAction(e,t,n){let i=await this.getFlow(e);if(!i)throw`Flow "${e}" not found`;let a=i.transitions.find(o=>o.actionName===n);if(!a)throw`Action "${n}" not found in flow "${e}"`;await this.executeAction(a.actions,t,void 0)}async getSdna(){let e=["ad4m://has_subject_class","ad4m://has_flow","ad4m://has_custom_sdna"],t=[];for(let n of e){let i=await this.get(new W({source:"ad4m://self",predicate:n}));for(let a of i){let o=a.data.target,s=await this.get(new W({source:o,predicate:"ad4m://sdna"}));for(let c of s){let u=be.fromUrl(c.data.target).get();typeof u=="string"&&t.push(u)}}}return t}async getSdnaForClass(e){let t=be.from(e);if((await this.get(new W({source:"ad4m://self",target:t.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let i=await this.get(new W({source:t.toUrl(),predicate:"ad4m://sdna"}));if(i.length===0)return null;let a=be.fromUrl(i[0].data.target).get();return typeof a=="string"?a:null}async addSdna(e,t,n,i){return P(this,pe,"f").addSdna(P(this,Y,"f").uuid,e,t,n,i)}async addSubjectClass(e,t){return this.addSdna(e,"","subject_class",t)}async addShacl(e,t){let n=t.toLinks(),i=be.fromUrl(`literal:string:shacl://${e}`),a=[...n.map(o=>new mt({source:o.source,predicate:o.predicate,target:o.target})),new mt({source:"ad4m://self",predicate:"ad4m://has_shacl",target:i.toUrl()}),new mt({source:i.toUrl(),predicate:"ad4m://shacl_shape_uri",target:t.nodeShapeUri})];await this.addLinks(a)}async getShacl(e){let t=be.fromUrl(`literal:string:shacl://${e}`),n=await this.get(new W({source:t.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(n.length===0)return null;let i=n[0].data.target,a=await this.get(new W({source:i,predicate:"sh://property"})),o=[i,...a.map(u=>u.data.target)],s=[];for(let u of o){let l=await this.get(new W({source:u}));for(let d of l)s.push({source:d.data.source,predicate:d.data.predicate,target:d.data.target})}let c=s;return Wr.fromLinks(c,i)}async getAllShacl(){let e=await this.get(new W({source:"ad4m://self",predicate:"ad4m://has_shacl"})),t=[];for(let n of e){let i=n.data.target,o=be.fromUrl(i).get().replace("shacl://",""),s=await this.getShacl(o);s&&t.push({name:o,shape:s})}return t}async addFlow(e,t){let n=t.toLinks(),i=be.from(e).toUrl(),a=[...n.map(o=>new mt({source:o.source,predicate:o.predicate,target:o.target})),new mt({source:"ad4m://self",predicate:"ad4m://has_flow",target:i}),new mt({source:i,predicate:"ad4m://flow_uri",target:t.flowUri})];await this.addLinks(a)}async getFlow(e){let t=be.from(e).toUrl(),n=await this.get(new W({source:t,predicate:"ad4m://flow_uri"}));if(n.length===0)return null;let i=n[0].data.target,a=i.endsWith("Flow")?i.slice(0,-4)+".":i+".",o=`SELECT ?s ?p ?o WHERE {
|
|
46
|
+
`}return t}toLinks(){let t=[];t.push({source:this.nodeShapeUri,predicate:"rdf://type",target:"sh://NodeShape"}),this.targetClass&&t.push({source:this.nodeShapeUri,predicate:"sh://targetClass",target:this.targetClass}),this.constructor_actions&&t.push({source:this.nodeShapeUri,predicate:"ad4m://constructor",target:`literal:string:${JSON.stringify(this.constructor_actions)}`}),this.destructor_actions&&t.push({source:this.nodeShapeUri,predicate:"ad4m://destructor",target:`literal:string:${JSON.stringify(this.destructor_actions)}`});for(let e=0;e<this.properties.length;e++){let n=this.properties[e],r;if(n.name&&this.targetClass){let s=Sr(this.targetClass),a=kr(this.targetClass);r=`${s}${a}.${n.name}`}else r=`_:propShape${e}`;t.push({source:this.nodeShapeUri,predicate:"sh://property",target:r}),t.push({source:r,predicate:"sh://path",target:n.path}),n.datatype&&t.push({source:r,predicate:"sh://datatype",target:n.datatype}),n.nodeKind&&t.push({source:r,predicate:"sh://nodeKind",target:`sh://${n.nodeKind}`}),n.minCount!==void 0&&t.push({source:r,predicate:"sh://minCount",target:`literal:${n.minCount}^^xsd:integer`}),n.maxCount!==void 0&&t.push({source:r,predicate:"sh://maxCount",target:`literal:${n.maxCount}^^xsd:integer`}),n.pattern&&t.push({source:r,predicate:"sh://pattern",target:`literal:${n.pattern}`}),n.minInclusive!==void 0&&t.push({source:r,predicate:"sh://minInclusive",target:`literal:${n.minInclusive}`}),n.maxInclusive!==void 0&&t.push({source:r,predicate:"sh://maxInclusive",target:`literal:${n.maxInclusive}`}),n.hasValue&&t.push({source:r,predicate:"sh://hasValue",target:`literal:${n.hasValue}`}),n.local!==void 0&&t.push({source:r,predicate:"ad4m://local",target:`literal:${n.local}`}),n.writable!==void 0&&t.push({source:r,predicate:"ad4m://writable",target:`literal:${n.writable}`}),n.resolveLanguage&&t.push({source:r,predicate:"ad4m://resolveLanguage",target:`literal:string:${n.resolveLanguage}`}),n.setter&&n.setter.length>0&&t.push({source:r,predicate:"ad4m://setter",target:`literal:string:${JSON.stringify(n.setter)}`}),n.adder&&n.adder.length>0&&t.push({source:r,predicate:"ad4m://adder",target:`literal:string:${JSON.stringify(n.adder)}`}),n.remover&&n.remover.length>0&&t.push({source:r,predicate:"ad4m://remover",target:`literal:string:${JSON.stringify(n.remover)}`}),n.getter&&t.push({source:r,predicate:"ad4m://getter",target:`literal:string:${n.getter}`}),n.conformanceConditions&&n.conformanceConditions.length>0&&t.push({source:r,predicate:"ad4m://conformanceConditions",target:`literal:string:${JSON.stringify(n.conformanceConditions)}`}),n.class&&t.push({source:r,predicate:"sh://class",target:n.class}),n.in&&n.in.length>0&&t.push({source:r,predicate:"sh://in",target:`literal:string:${JSON.stringify(n.in)}`})}return t}static fromLinks(t,e){let n=t.find(l=>l.source===e&&l.predicate==="sh://targetClass"),r=new Ze(e,n?.target),s=t.find(l=>l.source===e&&l.predicate==="ad4m://constructor");if(s)try{let l=s.target.replace(/^literal:\/\/string:|^literal:string:/,"");r.constructor_actions=JSON.parse(l)}catch{}let a=t.find(l=>l.source===e&&l.predicate==="ad4m://destructor");if(a)try{let l=a.target.replace(/^literal:\/\/string:|^literal:string:/,"");r.destructor_actions=JSON.parse(l)}catch{}let o=t.filter(l=>l.source===e&&l.predicate==="sh://property");for(let l of o){let c=l.target,d=t.find(_=>_.source===c&&_.predicate==="sh://path");if(!d)continue;let g;if(!c.startsWith("_:")){let _=c.lastIndexOf(".");_!==-1&&(g=c.substring(_+1))}let p={name:g,path:d.target},u=t.find(_=>_.source===c&&_.predicate==="sh://datatype");u&&(p.datatype=u.target);let f=t.find(_=>_.source===c&&_.predicate==="sh://nodeKind");f&&(p.nodeKind=f.target.replace("sh://",""));let h=t.find(_=>_.source===c&&_.predicate==="sh://minCount");if(h){let _=h.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");_.startsWith("number:")&&(_=_.substring(7)),p.minCount=parseInt(_)}let w=t.find(_=>_.source===c&&_.predicate==="sh://maxCount");if(w){let _=w.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");_.startsWith("number:")&&(_=_.substring(7)),p.maxCount=parseInt(_)}let y=t.find(_=>_.source===c&&_.predicate==="sh://pattern");y&&(p.pattern=y.target.replace(/^literal:\/\/|^literal:/,""));let v=t.find(_=>_.source===c&&_.predicate==="sh://minInclusive");if(v){let _=v.target.replace(/^literal:\/\/|^literal:/,"");_.startsWith("number:")&&(_=_.substring(7)),p.minInclusive=parseFloat(_)}let S=t.find(_=>_.source===c&&_.predicate==="sh://maxInclusive");if(S){let _=S.target.replace(/^literal:\/\/|^literal:/,"");_.startsWith("number:")&&(_=_.substring(7)),p.maxInclusive=parseFloat(_)}let b=t.find(_=>_.source===c&&_.predicate==="sh://hasValue");b&&(p.hasValue=b.target.replace(/^literal:\/\/|^literal:/,""));let T=t.find(_=>_.source===c&&_.predicate==="ad4m://local");if(T){let _=T.target.replace(/^literal:\/\/|^literal:/,"");_.startsWith("boolean:")&&(_=_.substring(8)),p.local=_==="true"}let O=t.find(_=>_.source===c&&_.predicate==="ad4m://writable");if(O){let _=O.target.replace(/^literal:\/\/|^literal:/,"");_.startsWith("boolean:")&&(_=_.substring(8)),p.writable=_==="true"}let C=t.find(_=>_.source===c&&_.predicate==="ad4m://resolveLanguage");C&&(p.resolveLanguage=C.target.replace(/^literal:\/\/string:|^literal:string:/,""));let P=t.find(_=>_.source===c&&_.predicate==="ad4m://setter");if(P)try{let _=P.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.setter=JSON.parse(_)}catch{}let R=t.find(_=>_.source===c&&_.predicate==="ad4m://adder");if(R)try{let _=R.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.adder=JSON.parse(_)}catch{}let x=t.find(_=>_.source===c&&_.predicate==="ad4m://remover");if(x)try{let _=x.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.remover=JSON.parse(_)}catch{}let N=t.find(_=>_.source===c&&_.predicate==="ad4m://getter");N&&(p.getter=N.target.replace(/^literal:\/\/string:|^literal:string:/,""));let we=t.find(_=>_.source===c&&_.predicate==="ad4m://conformanceConditions");if(we)try{let _=we.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.conformanceConditions=JSON.parse(_)}catch{}let Mt=t.find(_=>_.source===c&&_.predicate==="sh://class");Mt&&(p.class=Mt.target);let Ve=t.find(_=>_.source===c&&_.predicate==="sh://in");if(Ve)try{let _=Ve.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.in=JSON.parse(_)}catch{}r.addProperty(p)}return r}toJSON(){return{node_shape_uri:this.nodeShapeUri,target_class:this.targetClass,parent_shapes:this.parentShapes.length>0?this.parentShapes:void 0,properties:this.properties.map(t=>({path:t.path,name:t.name,datatype:t.datatype,node_kind:t.nodeKind,min_count:t.minCount,max_count:t.maxCount,min_inclusive:t.minInclusive,max_inclusive:t.maxInclusive,pattern:t.pattern,has_value:t.hasValue,local:t.local,writable:t.writable,resolve_language:t.resolveLanguage,setter:t.setter,adder:t.adder,remover:t.remover,getter:t.getter,conformance_conditions:t.conformanceConditions,class:t.class,in:t.in})),constructor_actions:this.constructor_actions,destructor_actions:this.destructor_actions}}static fromJSON(t){let e=t.node_shape_uri?new Ze(t.node_shape_uri,t.target_class):new Ze(t.target_class);for(let n of t.properties||[])e.addProperty({path:n.path,name:n.name,datatype:n.datatype,nodeKind:n.node_kind,minCount:n.min_count,maxCount:n.max_count,minInclusive:n.min_inclusive,maxInclusive:n.max_inclusive,pattern:n.pattern,hasValue:n.has_value,local:n.local,writable:n.writable,resolveLanguage:n.resolve_language,setter:n.setter,adder:n.adder,remover:n.remover,getter:n.getter,conformanceConditions:n.conformance_conditions,class:n.class,in:n.in});if(t.constructor_actions&&(e.constructor_actions=t.constructor_actions),t.destructor_actions&&(e.destructor_actions=t.destructor_actions),t.parent_shapes)for(let n of t.parent_shapes)e.addParentShape(n);return e}};function Ne(i){return i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Ca(i,t,e){let n=Ne(i),r=!e?.resolveLanguage||e.resolveLanguage==="literal";function s(a){return typeof a=="string"?r?`<literal:string:${Ne(a)}>`:`<${Ne(a)}>`:`<literal:string:${a}>`}if(Array.isArray(t)){let a=t.map(s).join(", ");return`FILTER EXISTS { ?target <${n}> ?_val . FILTER(?_val IN (${a})) }`}else if(typeof t=="object"&&t!==null){let a=t,o=[];if(a.not!==void 0)if(Array.isArray(a.not)){let c=a.not.map(d=>s(d)).join(", ");o.push(`FILTER NOT EXISTS { ?target <${n}> ?_nval . FILTER(?_nval IN (${c})) }`)}else o.push(`FILTER NOT EXISTS { ?target <${n}> ${s(a.not)} }`);return(a.gt!==void 0||a.gte!==void 0||a.lt!==void 0||a.lte!==void 0||a.between!==void 0||a.contains!==void 0)&&o.push(`FILTER EXISTS { ?target <${n}> ?_cmp }`),o.join(" ")}else return`?target <${n}> ${s(t)} .`}function Ki(i,t){let e=[];for(let[n,r]of Object.entries(i)){if(["id","author","timestamp"].includes(n))continue;let s,a;if(t){let l=t.properties[n];l?(s=l.predicate,a=l.resolveLanguage):s=n}else s=n;let o=Ca(s,r,{resolveLanguage:a});o&&e.push(o)}return e}function ka(i,t,e,n,r){let s=t.prototype,a="ad4m://",o=Object.fromEntries(Object.entries(n).filter(([,f])=>f.kind==="hasMany"||f.kind==="belongsToMany"));if(Object.keys(e).length>0){let f=e[Object.keys(e)[0]];if(f.through){let h=f.through.match(/^([^:]+:\/\/)/);h&&(a=h[1])}}else if(Object.keys(o).length>0){let f=o[Object.keys(o)[0]];if(f.predicate){let h=f.predicate.match(/^([^:]+:\/\/)/);h&&(a=h[1])}}let l=`${a}${i}Shape`,c=`${a}${i}`,d=new Ze(l,c),g=Object.getPrototypeOf(t);if(g&&typeof g.generateSHACL=="function"){let f=g.generateSHACL();f?.shape?.nodeShapeUri&&d.addParentShape(f.shape.nodeShapeUri)}let p=[];s.subjectConstructor&&s.subjectConstructor.length&&(p=p.concat(s.subjectConstructor));let u=[];for(let f in e){let h=e[f];if(!h.through)continue;let w={name:f,path:h.through};if(h.resolveLanguage==="literal")w.datatype="xsd://string";else if(h.initial){let v=typeof s[f];v==="number"?w.datatype="xsd://integer":v==="boolean"?w.datatype="xsd://boolean":v==="string"&&(w.datatype="xsd://string")}h.required&&(w.minCount=1),w.maxCount=1,h.flag&&h.initial&&(w.hasValue=h.initial),h.options&&h.options.length>0&&(w.in=h.options),h.local!==void 0&&(w.local=h.local),h.writable!==void 0&&(w.writable=h.writable),h.resolveLanguage&&(w.resolveLanguage=h.resolveLanguage),h.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${f}' in class '${i}' is not yet supported. The property will be created without setter actions. Consider using standard writable properties or provide explicit SHACL JSON.`):h.writable&&h.through&&typeof s[Yn(f)]=="function"&&(w.setter=[{action:"setSingleTarget",source:"this",predicate:h.through,target:"value",...h.local&&{local:!0}}]);let y=h.initial??(h.required&&h.writable&&!h.flag&&h.through?"literal:string:":void 0);y&&(p.push({action:"addLink",source:"this",predicate:h.through,target:y}),u.push({action:"removeLink",source:"this",predicate:h.through,target:"*"})),d.addProperty(w)}for(let f in o){let h=o[f];if(!h.predicate)continue;let w={name:f,path:h.predicate};if(w.nodeKind="IRI",h.local!==void 0&&(w.local=h.local),w.adder=[{action:"addLink",source:"this",predicate:h.predicate,target:"value",...h.local&&{local:!0}}],w.remover=[{action:"removeLink",source:"this",predicate:h.predicate,target:"value",...h.local&&{local:!0}}],h.getter)w.getter=h.getter;else if(h.where)try{let y=h.target?.(),v=y?y.getModelMetadata?.()??null:null,S=Ki(h.where,v);if(S.length>0){let b=Ne(h.predicate);w.getter=`SELECT ?target WHERE { <Base> <${b}> ?target . ${S.join(" ")} }`}}catch{}else if(h.target&&h.filter!==!1){let y=h.target,v=h.predicate,S=!1,b,T,O=()=>{if(!S){S=!0;try{let C=y(),P=r(v,C);P&&(b=P.getter,T=P.conformanceConditions)}catch{}}};Object.defineProperty(w,"getter",{get(){return O(),b},set(C){S=!0,b=C},enumerable:!0,configurable:!0}),Object.defineProperty(w,"conformanceConditions",{get(){return O(),T},set(C){S=!0,T=C},enumerable:!0,configurable:!0})}if(h.target)try{let v=h.target().generateSHACL?.();v?.shape?.nodeShapeUri&&(w.class=v.shape.nodeShapeUri)}catch{}d.addProperty(w)}return d.setConstructorActions(p),d.setDestructorActions(u),{shape:d,name:i}}var Di=new WeakMap,ji=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Er=new WeakMap;function Je(i){let t=xr.get(i);if(t)return t;let e={},n=[],r=i;for(;r&&r!==Object;)n.unshift(r),r=Object.getPrototypeOf(r);for(let s of n){let a=Di.get(s);a&&Object.assign(e,a)}return xr.set(i,e),e}function te(i){let t=Ar.get(i);if(t)return t;let e={},n=[],r=i;for(;r&&r!==Object;)n.unshift(r),r=Object.getPrototypeOf(r);for(let s of n){let a=ji.get(s);a&&Object.assign(e,a)}return Ar.set(i,e),e}function xa(i,t){let e=Er.get(i);if(e)return e;let n=t();return Er.set(i,n),n}function $n(i,t,e){Di.has(i)||Di.set(i,{}),Di.get(i)[t]=e}function xs(i,t,e){ji.has(i)||ji.set(i,{}),ji.get(i)[t]=e}function Vi(i,t){try{let e=Je(t),n=[],r=[],s=0;for(let[o,l]of Object.entries(e))l.flag&&l.initial&&l.through&&(n.push({type:"flag",predicate:l.through,value:l.initial}),r.push(`?target <${Ne(l.through)}> <${Ne(l.initial)}> .`));for(let[o,l]of Object.entries(e))l.required&&!l.flag&&!l.getter&&l.through&&(n.push({type:"required",predicate:l.through}),r.push(`?target <${Ne(l.through)}> ?_v${s++} .`));return n.length===0?void 0:{getter:`SELECT ?target WHERE { <Base> <${Ne(i)}> ?target . ${r.join(" ")} }`,conformanceConditions:n}}catch{return}}function As(i){return function(t){t.prototype.className=i.name,t.className=i.name,t.generateSDNA=function(){return Sa(i.name,t.prototype,Je(t),te(t))},t.generateSHACL=function(){return xa(t,()=>ka(i.name,t,Je(t),te(t),Vi))},Object.defineProperty(t,"type",{configurable:!0})}}var pt=new Map,Aa=200;function Es(i,t){return`${i}:${t}`}function Ea(i,t){let e=Es(i,t),n=pt.get(e);if(!!n){if(Date.now()>n.expiry){pt.delete(e);return}return n.result}}function Ta(i,t,e,n=Aa){let r=Date.now();for(let[a,o]of pt)r>o.expiry&&pt.delete(a);let s=Es(i,t);pt.set(s,{result:e,expiry:r+n})}function Me(i){let t=i+":";for(let[e]of pt)e.startsWith(t)&&pt.delete(e)}var Lt=class{constructor(t,e){this.flowable="any",this.startAction=[],this._states=[],this._transitions=[],this.name=t,this.namespace=e}get states(){return[...this._states]}get transitions(){return[...this._transitions]}addState(t){this._states.push(t)}addTransition(t){this._transitions.push(t)}get flowUri(){return`${this.namespace}${this.name}Flow`}stateUri(t){return`${this.namespace}${this.name}.${t}`}transitionUri(t,e){return`${this.namespace}${this.name}.${t}To${e}`}toLinks(){let t=[],e=this.flowUri;t.push({source:e,predicate:"rdf://type",target:"ad4m://Flow"}),t.push({source:e,predicate:"ad4m://flowName",target:J.from(this.name).toUrl()}),this.flowable==="any"?t.push({source:e,predicate:"ad4m://flowable",target:"ad4m://any"}):t.push({source:e,predicate:"ad4m://flowable",target:`literal:string:${encodeURIComponent(JSON.stringify(this.flowable))}`}),this.startAction.length>0&&t.push({source:e,predicate:"ad4m://startAction",target:`literal:string:${encodeURIComponent(JSON.stringify(this.startAction))}`});for(let n of this._states){let r=this.stateUri(n.name);t.push({source:e,predicate:"ad4m://hasState",target:r}),t.push({source:r,predicate:"rdf://type",target:"ad4m://FlowState"}),t.push({source:r,predicate:"ad4m://stateName",target:J.from(n.name).toUrl()}),t.push({source:r,predicate:"ad4m://stateValue",target:J.from(n.value).toUrl()}),t.push({source:r,predicate:"ad4m://stateCheck",target:`literal:string:${encodeURIComponent(JSON.stringify(n.stateCheck))}`})}for(let n of this._transitions){let r=this.transitionUri(n.fromState,n.toState),s=this.stateUri(n.fromState),a=this.stateUri(n.toState);t.push({source:e,predicate:"ad4m://hasTransition",target:r}),t.push({source:r,predicate:"rdf://type",target:"ad4m://FlowTransition"}),t.push({source:r,predicate:"ad4m://actionName",target:J.from(n.actionName).toUrl()}),t.push({source:r,predicate:"ad4m://fromState",target:s}),t.push({source:r,predicate:"ad4m://toState",target:a}),t.push({source:r,predicate:"ad4m://transitionActions",target:`literal:string:${encodeURIComponent(JSON.stringify(n.actions))}`})}return t}static fromLinks(t,e){let n="Flow";if(!e.endsWith(n))throw new Error(`Invalid flow URI: ${e} (must end with 'Flow')`);let r=e.slice(0,-n.length),s=Math.max(r.lastIndexOf("/"),r.lastIndexOf(":")),a=r.slice(0,s+1),o=r.slice(s+1),l=new Lt(o,a),c=t.find(f=>f.source===e&&f.predicate==="ad4m://flowable");if(c)if(c.target==="ad4m://any")l.flowable="any";else try{let f=c.target.replace(/^literal:\/\/string:|^literal:string:/,"");l.flowable=JSON.parse(decodeURIComponent(f))}catch{l.flowable="any"}let d=t.find(f=>f.source===e&&f.predicate==="ad4m://startAction");if(d)try{let f=d.target.replace(/^literal:\/\/string:|^literal:string:/,"");l.startAction=JSON.parse(decodeURIComponent(f))}catch{}let g=t.filter(f=>f.source===e&&f.predicate==="ad4m://hasState"),p=new Map;for(let f of g){let h=f.target,w=t.find(O=>O.source===h&&O.predicate==="ad4m://stateName"),y=w?J.fromUrl(w.target).get():"";p.set(h,y);let v=t.find(O=>O.source===h&&O.predicate==="ad4m://stateValue"),S=v?J.fromUrl(v.target).get():0,b=t.find(O=>O.source===h&&O.predicate==="ad4m://stateCheck"),T={predicate:"",target:""};if(b)try{let O=b.target.replace(/^literal:\/\/string:|^literal:string:/,"");T=JSON.parse(decodeURIComponent(O))}catch{}l.addState({name:y,value:S,stateCheck:T})}let u=t.filter(f=>f.source===e&&f.predicate==="ad4m://hasTransition");for(let f of u){let h=f.target,w=t.find(x=>x.source===h&&x.predicate==="ad4m://actionName"),y=w?J.fromUrl(w.target).get():"",S=t.find(x=>x.source===h&&x.predicate==="ad4m://fromState")?.target||"",b=p.get(S)||"",O=t.find(x=>x.source===h&&x.predicate==="ad4m://toState")?.target||"",C=p.get(O)||"",P=t.find(x=>x.source===h&&x.predicate==="ad4m://transitionActions"),R=[];if(P)try{let x=P.target.replace(/^literal:\/\/string:|^literal:string:/,"");R=JSON.parse(decodeURIComponent(x))}catch{}l.addTransition({actionName:y,fromState:b,toState:C,actions:R})}return l}toJSON(){return{name:this.name,namespace:this.namespace,flowable:this.flowable,startAction:this.startAction,states:this._states,transitions:this._transitions}}static fromJSON(t){let e=new Lt(t.name,t.namespace);e.flowable=t.flowable||"any",e.startAction=t.startAction||[];for(let n of t.states||[])e.addState(n);for(let n of t.transitions||[])e.addTransition(n);return e}},j=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},m=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},Fi,xt,Ue,et,dt,De,je,tt,zt,zi,ve,Fe,le,Wt,Ln,L,U,it,nt,rt,Ht,Bt;function $a(i){let t=i.lastIndexOf("#");if(t>=0)return i.substring(0,t+1);let e=i.lastIndexOf("/");if(e>=0)return i.substring(0,e+1);let n=i.lastIndexOf(":");return n>=0?i.substring(0,n+1):i}var Xi=class{constructor(t,e,n){Fi.add(this),xt.set(this,void 0),Ue.set(this,void 0),et.set(this,void 0),dt.set(this,void 0),De.set(this,void 0),je.set(this,void 0),tt.set(this,void 0),zt.set(this,!1),zi.set(this,void 0),ve.set(this,void 0),Fe.set(this,void 0),le.set(this,void 0),Wt.set(this,void 0),j(this,xt,t,"f"),j(this,Wt,e,"f"),j(this,et,n,"f"),j(this,dt,new Set,"f"),j(this,tt,null,"f"),j(this,zi,new Promise((r,s)=>{j(this,ve,r,"f"),j(this,Fe,s,"f")}),"f")}async subscribe(){m(this,je,"f")&&(m(this,je,"f").call(this),j(this,je,void 0,"f")),m(this,le,"f")&&(clearTimeout(m(this,le,"f")),j(this,le,void 0,"f")),m(this,De,"f")&&(clearTimeout(m(this,De,"f")),j(this,De,void 0,"f"));try{let e;e=await m(this,et,"f").subscribeQuery(m(this,xt,"f"),m(this,Wt,"f")),j(this,Ue,e.subscriptionId,"f"),e.result!==void 0?(j(this,tt,e.result,"f"),m(this,Fi,"m",Ln).call(this,e.result),m(this,ve,"f")&&(m(this,ve,"f").call(this,!0),j(this,ve,void 0,"f"),j(this,Fe,void 0,"f"))):(console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),j(this,le,setTimeout(()=>{console.error("Subscription initialization timed out after 30 seconds. Resubscribing..."),this.subscribe().catch(n=>{console.error("Error during subscription retry after timeout:",n)})},3e4),"f")),j(this,je,m(this,et,"f").subscribeToQueryUpdates(m(this,Ue,"f"),n=>{m(this,le,"f")&&(clearTimeout(m(this,le,"f")),j(this,le,void 0,"f")),m(this,ve,"f")&&(m(this,ve,"f").call(this,!0),j(this,ve,void 0,"f"),j(this,Fe,void 0,"f")),!(n.isInit&&m(this,tt,"f"))&&(j(this,tt,n,"f"),m(this,Fi,"m",Ln).call(this,n))}),"f")}catch(e){throw console.error("Error setting up subscription:",e),m(this,Fe,"f")&&(m(this,Fe,"f").call(this,e),j(this,ve,void 0,"f"),j(this,Fe,void 0,"f")),e}let t=async()=>{if(!m(this,zt,"f")){try{await m(this,et,"f").keepAliveQuery(m(this,xt,"f"),m(this,Ue,"f"))}catch(e){console.error("Error in keepalive:",e),console.log("Reinitializing subscription for query:",m(this,Wt,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(n){console.error("Error during resubscription from keepalive:",n);return}}m(this,zt,"f")||j(this,De,setTimeout(t,3e4),"f")}};j(this,De,setTimeout(t,3e4),"f")}get id(){return m(this,Ue,"f")}get initialized(){return m(this,zi,"f")}get result(){return m(this,tt,"f")}onResult(t){return m(this,dt,"f").add(t),()=>m(this,dt,"f").delete(t)}dispose(){j(this,zt,!0,"f"),clearTimeout(m(this,De,"f")),m(this,je,"f")&&m(this,je,"f").call(this),m(this,dt,"f").clear(),m(this,le,"f")&&(clearTimeout(m(this,le,"f")),j(this,le,void 0,"f")),m(this,Ue,"f")&&m(this,et,"f").disposeQuerySubscription(m(this,xt,"f"),m(this,Ue,"f")).catch(t=>console.error("Error disposing query subscription:",t))}};xt=new WeakMap,Ue=new WeakMap,et=new WeakMap,dt=new WeakMap,De=new WeakMap,je=new WeakMap,tt=new WeakMap,zt=new WeakMap,zi=new WeakMap,ve=new WeakMap,Fe=new WeakMap,le=new WeakMap,Wt=new WeakMap,Fi=new WeakSet,Ln=function(t){for(let e of m(this,dt,"f"))try{e(t)}catch(n){console.error("Error in query subscription callback:",n)}};var Tt=class{get client(){return m(this,U,"f")}constructor(t,e){L.set(this,void 0),U.set(this,void 0),it.set(this,void 0),nt.set(this,void 0),rt.set(this,void 0),Ht.set(this,void 0),Bt.set(this,new Set),j(this,it,[],"f"),j(this,nt,[],"f"),j(this,rt,[],"f"),j(this,Ht,[],"f"),j(this,L,t,"f"),j(this,U,e,"f"),this.uuid=m(this,L,"f").uuid,this.name=m(this,L,"f").name,this.owners=m(this,L,"f").owners,this.sharedUrl=m(this,L,"f").sharedUrl,this.neighbourhood=m(this,L,"f").neighbourhood,this.state=m(this,L,"f").state,m(this,U,"f").addPerspectiveLinkAddedListener(m(this,L,"f").uuid,m(this,it,"f")),m(this,U,"f").addPerspectiveLinkRemovedListener(m(this,L,"f").uuid,m(this,nt,"f")),m(this,U,"f").addPerspectiveLinkUpdatedListener(m(this,L,"f").uuid,m(this,rt,"f")),m(this,U,"f").addPerspectiveSyncStateChangeListener(m(this,L,"f").uuid,m(this,Ht,"f"))}updateHandle(t){if(t.uuid!==m(this,L,"f").uuid)throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch \u2014 proxy is bound to "${m(this,L,"f").uuid}" but received handle with UUID "${t.uuid}". This would silently diverge from listeners registered under the original UUID.`);j(this,L,t,"f"),this.uuid=t.uuid,this.name=t.name,this.owners=t.owners,this.sharedUrl=t.sharedUrl,this.neighbourhood=t.neighbourhood,this.state=t.state}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(t,e,n,r){let s=await m(this,U,"f").executeCommands(m(this,L,"f").uuid,JSON.stringify(t),e,JSON.stringify(n),r);return Me(m(this,L,"f").uuid),s}async get(t){return await m(this,U,"f").queryLinks(m(this,L,"f").uuid,t)}async infer(t){return await m(this,U,"f").queryProlog(m(this,L,"f").uuid,t)}async querySparql(t){let e=Ea(m(this,L,"f").uuid,t);if(e!==void 0)return e;let n=await m(this,U,"f").querySparql(m(this,L,"f").uuid,t);return Ta(m(this,L,"f").uuid,t,n),n}async modelQuery(t,e,n){return await m(this,U,"f").modelQuery(m(this,L,"f").uuid,t,e,n)}async modelSubscribe(t,e,n){return await m(this,U,"f").modelSubscribe(m(this,L,"f").uuid,t,e,n)}async add(t,e="shared",n){let r=await m(this,U,"f").addLink(m(this,L,"f").uuid,t,e,n);return Me(m(this,L,"f").uuid),r}async addLinks(t,e="shared",n){let r=await m(this,U,"f").addLinks(m(this,L,"f").uuid,t,e,n);return Me(m(this,L,"f").uuid),r}async removeLinks(t,e){let n=await m(this,U,"f").removeLinks(m(this,L,"f").uuid,t,e);return Me(m(this,L,"f").uuid),n}async linkMutations(t,e="shared"){let n=await m(this,U,"f").linkMutations(m(this,L,"f").uuid,t,e);return Me(m(this,L,"f").uuid),n}async addLinkExpression(t,e="shared",n){return await m(this,U,"f").addLinkExpression(m(this,L,"f").uuid,t,e,n)}async update(t,e,n){let r=await m(this,U,"f").updateLink(m(this,L,"f").uuid,t,e,n);return Me(m(this,L,"f").uuid),r}async remove(t,e){let n=await m(this,U,"f").removeLink(m(this,L,"f").uuid,t,e);return Me(m(this,L,"f").uuid),n}async createBatch(){return await m(this,U,"f").createBatch(m(this,L,"f").uuid)}async commitBatch(t){let e=await m(this,U,"f").commitBatch(m(this,L,"f").uuid,t);return Me(m(this,L,"f").uuid),e}async getExpression(t){return await m(this,U,"f").getExpression(t)}async createExpression(t,e){return await m(this,U,"f").createExpression(t,e)}async addListener(t,e){t==="link-added"?m(this,it,"f").push(e):t==="link-removed"?m(this,nt,"f").push(e):t==="link-updated"&&m(this,rt,"f").push(e)}async addSyncStateChangeListener(t){m(this,Ht,"f").push(t)}async removeListener(t,e){if(t==="link-added"){let n=m(this,it,"f").indexOf(e);m(this,it,"f").splice(n,1)}else if(t==="link-removed"){let n=m(this,nt,"f").indexOf(e);m(this,nt,"f").splice(n,1)}else if(t==="link-updated"){let n=m(this,rt,"f").indexOf(e);m(this,rt,"f").splice(n,1)}}async snapshot(){return m(this,U,"f").snapshotByUUID(m(this,L,"f").uuid)}async loadSnapshot(t){let e=JSON.parse(JSON.stringify(t));delete e.__typename,e.links.forEach(n=>{delete n.data.__typename});for(let n of e.links)await this.addLinkExpression(n)}async getSingleTarget(t){delete t.target;let e=await this.get(t);return e.length?e[0].data.target:null}async setSingleTarget(t,e="shared"){let n=new Z({source:t.source,predicate:t.predicate}),r=await this.get(n),s=[];for(let o of r)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,s.push(o);let a=[t];await this.linkMutations({additions:a,removals:s},e)}async sdnaFlows(){return(await this.get(new Z({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(e=>{try{return J.fromUrl(e.data.target).get()}catch{return e.data.target}})}async availableFlows(t){let e=await this.sdnaFlows(),n=[];for(let r of e){let s=await this.getFlow(r);if(!!s)if(s.flowable==="any")n.push(r);else{let a=s.flowable,o=a.source||t;(await this.get(new Z({source:o,predicate:a.predicate,target:a.target}))).length>0&&n.push(r)}}return n}async startFlow(t,e){let n=await this.getFlow(t);if(!n)throw`Flow "${t}" not found`;if(n.startAction.length===0)throw`Flow "${t}" has no start action`;await this.executeAction(n.startAction,e,void 0)}async expressionsInFlowState(t,e){let n=await this.getFlow(t);if(!n)return[];let r=n.states.find(o=>o.value===e);if(!r)return[];let s=r.stateCheck;return(await this.get(new Z({predicate:s.predicate,target:s.target}))).map(o=>s.source?o.data.target:o.data.source)}async flowState(t,e){let n=await this.getFlow(t);if(!n)throw`Flow "${t}" not found`;for(let r of n.states){let s=r.stateCheck,a=s.source||e;if((await this.get(new Z({source:a,predicate:s.predicate,target:s.target}))).length>0)return r.value}throw`Expression "${e}" is not in any state of flow "${t}"`}async flowActions(t,e){let n=await this.getFlow(t);if(!n)return[];let r=null;for(let s of n.states){let a=s.stateCheck,o=a.source||e;if((await this.get(new Z({source:o,predicate:a.predicate,target:a.target}))).length>0){r=s.name;break}}return r?n.transitions.filter(s=>s.fromState===r).map(s=>s.actionName):[]}async runFlowAction(t,e,n){let r=await this.getFlow(t);if(!r)throw`Flow "${t}" not found`;let s=r.transitions.find(a=>a.actionName===n);if(!s)throw`Action "${n}" not found in flow "${t}"`;await this.executeAction(s.actions,e,void 0)}async getSdna(){let t=["ad4m://has_subject_class","ad4m://has_flow","ad4m://has_custom_sdna"],e=[];for(let n of t){let r=await this.get(new Z({source:"ad4m://self",predicate:n}));for(let s of r){let a=s.data.target,o=await this.get(new Z({source:a,predicate:"ad4m://sdna"}));for(let l of o){let c=J.fromUrl(l.data.target).get();typeof c=="string"&&e.push(c)}}}return e}async getSdnaForClass(t){let e=J.from(t);if((await this.get(new Z({source:"ad4m://self",target:e.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let r=await this.get(new Z({source:e.toUrl(),predicate:"ad4m://sdna"}));if(r.length===0)return null;let s=J.fromUrl(r[0].data.target).get();return typeof s=="string"?s:null}async addSdna(t,e,n,r){return m(this,U,"f").addSdna(m(this,L,"f").uuid,t,e,n,r)}async addSubjectClass(t,e){return this.addSdna(t,"","subject_class",e)}async addShacl(t,e){let n=e.toLinks(),r=J.fromUrl(`literal:string:shacl://${t}`),s=[...n.map(a=>new me({source:a.source,predicate:a.predicate,target:a.target})),new me({source:"ad4m://self",predicate:"ad4m://has_shacl",target:r.toUrl()}),new me({source:r.toUrl(),predicate:"ad4m://shacl_shape_uri",target:e.nodeShapeUri})];await this.addLinks(s)}async getShacl(t){let e=J.fromUrl(`literal:string:shacl://${t}`),n=await this.get(new Z({source:e.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(n.length===0)return null;let r=n[0].data.target,s=await this.get(new Z({source:r,predicate:"sh://property"})),a=[r,...s.map(c=>c.data.target)],o=[];for(let c of a){let d=await this.get(new Z({source:c}));for(let g of d)o.push({source:g.data.source,predicate:g.data.predicate,target:g.data.target})}let l=o;return Ze.fromLinks(l,r)}async getAllShacl(){let t=await this.get(new Z({source:"ad4m://self",predicate:"ad4m://has_shacl"})),e=[];for(let n of t){let r=n.data.target,a=J.fromUrl(r).get().replace("shacl://",""),o=await this.getShacl(a);o&&e.push({name:a,shape:o})}return e}async addFlow(t,e){let n=e.toLinks(),r=J.from(t).toUrl(),s=[...n.map(a=>new me({source:a.source,predicate:a.predicate,target:a.target})),new me({source:"ad4m://self",predicate:"ad4m://has_flow",target:r}),new me({source:r,predicate:"ad4m://flow_uri",target:e.flowUri})];await this.addLinks(s)}async getFlow(t){let e=J.from(t).toUrl(),n=await this.get(new Z({source:e,predicate:"ad4m://flow_uri"}));if(n.length===0)return null;let r=n[0].data.target,s=r.endsWith("Flow")?r.slice(0,-4)+".":r+".",a=`SELECT ?s ?p ?o WHERE {
|
|
107
47
|
?s ?p ?o .
|
|
108
|
-
FILTER(?s = <${
|
|
109
|
-
}`,c=(await this.querySparql(o)||[]).map(u=>({source:u.s,predicate:u.p,target:u.o}));return Ni.fromLinks(c,i)}async subjectClasses(){try{let t=(await this.get(new W({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(n=>{let a=n.data.source.split("://");return a[a.length-1].split("/").pop()||""}).filter(n=>n.length>0);return[...new Set(t)]}catch(e){return console.warn("subjectClasses: SHACL lookup failed:",e),[]}}async stringOrTemplateObjectToSubjectClassName(e){if(typeof e=="string")return e;{let t=await this.subjectClassesByTemplate(e);return t[0]?t[0]:e.className}}async createSubject(e,t,n,i){let a;if(typeof e=="string")a=e,await P(this,pe,"f").createSubject(P(this,Y,"f").uuid,JSON.stringify({className:a,initialValues:n}),t,n?JSON.stringify(n):void 0,i);else{let o=e,s=o.className||o.constructor?.className||o.constructor?.prototype?.className||await this.findClassByProperties(o);if(!s)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await P(this,pe,"f").createSubject(P(this,Y,"f").uuid,JSON.stringify({className:s,initialValues:n}),t,n?JSON.stringify(n):void 0,i)}return i?t:this.getSubjectProxy(t,e)}async getSubjectData(e,t){if(typeof e=="string")return JSON.parse(await P(this,pe,"f").getSubjectData(P(this,Y,"f").uuid,JSON.stringify({className:e}),t));let n=e,i=n.className||n.constructor?.className||n.constructor?.prototype?.className||await this.findClassByProperties(n);if(!i)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");return JSON.parse(await P(this,pe,"f").getSubjectData(P(this,Y,"f").uuid,JSON.stringify({className:i}),t))}async getActionsFromSHACL(e,t){let n=this.escapeRegExp(e),i=new RegExp(`[/:#]${n}Shape$`),a=await this.get(new W({predicate:t}));for(let o of a)if(i.test(o.data.source)){let s="literal:string:";if(o.data.target.startsWith(s)){let c=o.data.target.slice(s.length),u=c;try{u=decodeURIComponent(c)}catch{}try{return JSON.parse(u)}catch(l){return console.warn(`Failed to parse SHACL actions JSON for ${e}:`,l),null}}}return null}async removeSubject(e,t,n){let i=await this.stringOrTemplateObjectToSubjectClassName(e),a=await this.getActionsFromSHACL(i,"ad4m://destructor");if(!a)throw`No destructor found for subject class: ${i}. Make sure the class was registered with SHACL.`;await this.executeAction(a,t,void 0,n)}async isSubjectInstance(e,t){let n=await this.stringOrTemplateObjectToSubjectClassName(t),i=await this.getSubjectClassMetadataFromSDNA(n);if(!i)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${n}`),!1;if(i.requiredTriples.length===0)return(await this.get(new W({source:e}))).length>0;for(let a of i.requiredTriples){let o;a.target?o=new W({source:e,predicate:a.predicate,target:a.target}):o=new W({source:e,predicate:a.predicate});let s=await this.get(o);if(!s||s.length===0)return!1}return!0}async getSubjectProxy(e,t){if(!await this.isSubjectInstance(e,t))throw`Expression ${e} is not a subject instance of given class: ${JSON.stringify(t)}`;let n=await this.stringOrTemplateObjectToSubjectClassName(t),i=new Ba(this,e,n);return await i.init(),i}async getSubjectClassMetadata(e){return this.getSubjectClassMetadataFromSDNA(e)}async getSubjectClassMetadataFromSDNA(e){try{let t=await this.getShacl(e);if(!t)return console.warn(`No SHACL metadata found for ${e}`),null;let n=[],i=[],a=new Map,o=new Map,s=new Set;for(let c of t.properties){if(!c.path||!c.name)continue;c.writable&&s.add(c.path),c.adder&&c.adder.length>0?o.set(c.name,{predicate:c.path}):a.set(c.name,{predicate:c.path,resolveLanguage:c.resolveLanguage})}if(t.constructor_actions){for(let c of t.constructor_actions)if(c.predicate){n.push(c.predicate);let u=s.has(c.predicate);c.target&&c.target!=="value"&&!u?i.push({predicate:c.predicate,target:c.target}):i.push({predicate:c.predicate})}}return{requiredPredicates:n,requiredTriples:i,properties:a,relations:o}}catch(t){return console.error(`Error getting SHACL metadata for ${e}:`,t),null}}async findInstancesByMetadata(e){if(e.requiredTriples.length===0){let o=await this.get(new W({})),s=new Set(o.map(c=>c.data.source));return Array.from(s).map(c=>({base:c}))}let t=e.requiredTriples[0],n;t.target?n=new W({predicate:t.predicate,target:t.target}):n=new W({predicate:t.predicate});let i=await this.get(n),a=[...new Set(i.map(o=>o.data.source))];for(let o=1;o<e.requiredTriples.length;o++){let s=e.requiredTriples[o],c=[];for(let u of a){let l;s.target?l=new W({source:u,predicate:s.predicate,target:s.target}):l=new W({source:u,predicate:s.predicate}),(await this.get(l)).length>0&&c.push(u)}a=c}return a.map(o=>({base:o}))}async getPropertyValueViaSparql(e,t,n){let i=await this.getSubjectClassMetadataFromSDNA(t);if(!i)return;let a=i.properties.get(n);if(!a)return;let o=await this.get(new W({source:e,predicate:a.predicate}));if(!o||o.length===0)return;let s=o[0].data.target;if(a.resolveLanguage&&s)try{let c=await this.getExpression(s);try{return JSON.parse(c.data)}catch{return c.data}}catch{return s}return s}async getRelationValuesViaSparql(e,t,n){let i=await this.getSubjectClassMetadataFromSDNA(t);if(!i)return[];let a=i.relations.get(n);if(!a)return[];let o=await this.get(new W({source:e,predicate:a.predicate}));if(!o||o.length===0)return[];o.sort((c,u)=>new Date(c.timestamp).getTime()-new Date(u.timestamp).getTime());let s=o.map(c=>c.data.target).filter(c=>c!==""&&c!=="");if(a.condition&&s.length>0)try{let c=[];for(let u of s){let l=a.condition.replace(/\$perspective/g,`'${this.uuid}'`).replace(/\$base/g,`'${e}'`).replace(/Target/g,`'${u.replace(/'/g,"\\'")}'`),d=l.match(/in\.uri\s*=\s*'([^']+)'/),p=l.match(/predicate\s*=\s*'([^']+)'/),f=l.match(/out\.uri\s*=\s*'([^']+)'/);if(d||p||f){let h={};d&&(h.source=d[1]),p&&(h.predicate=p[1]),f&&(h.target=f[1]),(await this.get(new W(h))).length>0&&c.push(u)}else c.push(u)}s=c}catch(c){console.warn(`Failed to apply condition filter for ${n}:`,c)}if(a.instanceFilter)try{let c=await this.getSubjectClassMetadataFromSDNA(a.instanceFilter);return c?await this.batchCheckSubjectInstances(s,c):this.filterInstancesSequential(s,a.instanceFilter)}catch{return this.filterInstancesSequential(s,a.instanceFilter)}return s}async batchCheckSubjectInstances(e,t){if(e.length===0)return[];if(t.requiredTriples.length===0){let a=[];for(let o of e)(await this.get(new W({source:o}))).length>0&&a.push(o);return a}let n=[];for(let a of t.requiredTriples){let o=new Set;for(let s of e){let c;a.target?c=new W({source:s,predicate:a.predicate,target:a.target}):c=new W({source:s,predicate:a.predicate}),(await this.get(c)).length>0&&o.add(s)}n.push(o)}return n.length===0?e:e.filter(a=>n.every(o=>o.has(a)))}async filterInstancesSequential(e,t){let n=[];for(let i of e)try{await this.isSubjectInstance(i,t)&&n.push(i)}catch{continue}return n}async getAllSubjectInstances(e){let t=[],n=typeof e=="function";typeof e=="string"?t=[e]:n?t=[e.name]:t=await this.subjectClassesByTemplate(e);let i=[];for(let a of t){let o=await this.getSubjectClassMetadataFromSDNA(a);if(o){let s=await this.findInstancesByMetadata(o);for(let c of s||[])try{let u;n?(u=new e(this,c.base),await u.get()):(u=new Ba(this,c.base,a),await u.init()),i.push(u)}catch{}}}return i}async getAllSubjectProxies(e){let t=[];typeof e=="string"?t=[e]:t=await this.subjectClassesByTemplate(e);let n=[];for(let i of t){let a=await this.getSubjectClassMetadataFromSDNA(i);if(a){let o=await this.findInstancesByMetadata(a);for(let s of o||[])try{let c=new Ba(this,s.base,i);await c.init(),n.push(c)}catch{}}}return n}async findClassByProperties(e){let t=[],n=[],a=Object.getPrototypeOf(e)?.constructor,o=a?Un(a):{};Object.keys(o).length>0?t=Object.keys(o):t=Object.keys(e).filter(f=>!Array.isArray(e[f]));let s=a?Object.fromEntries(Object.entries(ht(a)).filter(([,f])=>f.kind==="hasMany"||f.kind==="belongsToMany")):{};if(Object.keys(s).length>0?n=Object.keys(s).filter(f=>f!=="isSubjectInstance"):n=Object.keys(e).filter(f=>Array.isArray(e[f])&&f!=="isSubjectInstance"),t.length===0&&n.length===0)return null;let c=await this.get(new W({predicate:"rdf://type",target:"ad4m://SubjectClass"})),u=await this.get(new W({predicate:"sh://property"})),l=await this.get(new W({predicate:"sh://collection"})),d=[...c.map(f=>({shape_source:f.data.source,predicate:f.data.predicate,target:f.data.target})),...u.map(f=>({shape_source:f.data.source,predicate:f.data.predicate,target:f.data.target})),...l.map(f=>({shape_source:f.data.source,predicate:f.data.predicate,target:f.data.target}))];if(d.length===0)return null;let p=new Map;for(let f of d)if(f.predicate==="rdf://type"&&f.target==="ad4m://SubjectClass"){let h=f.shape_source,m=h.indexOf("://");if(m<0)continue;let g=h.substring(m+3).split("/").pop();if(!g)continue;p.set(g,{shapeUri:h,properties:[],relations:[]})}for(let f of d)if(f.predicate==="sh://property"||f.predicate==="sh://collection"){for(let[h,m]of p)if(f.shape_source.endsWith(`${h}Shape`)){let g=f.target.lastIndexOf(".");if(g<0)continue;let _=f.target.substring(g+1);f.predicate==="sh://property"?m.properties.push(_):m.relations.push(_)}}for(let[f,h]of p){let m=t.every(_=>h.properties.includes(_)),g=n.every(_=>h.relations.includes(_));if(m&&g)return f}return null}async subjectClassesByTemplate(e){try{let t=e.className||e.constructor?.className||e.constructor?.prototype?.className;if(t&&(await this.subjectClasses()).includes(t))return[t]}catch(t){console.warn("subjectClassesByTemplate: className lookup failed:",t)}try{let t=await this.findClassByProperties(e);if(t)return[t]}catch(t){console.warn("subjectClassesByTemplate: property matching failed:",t)}return[]}async ensureSDNASubjectClass(e){return this.ensureSubjectClass(e)}async ensureSubjectClass(e){let t=e.className||e.prototype?.className||e.name;if(P(this,_a,"f").has(t))return;if(!e.generateSHACL)throw new Error(`Class ${e.name} must have generateSHACL(). Use @Model decorator.`);let{shape:n}=e.generateSHACL(),i=JSON.stringify(n.toJSON());await this.addSdna(t,"","subject_class",i),P(this,_a,"f").add(t)}clearEnsuredSubjectClasses(){P(this,_a,"f").clear()}getNeighbourhoodProxy(){return P(this,pe,"f").getNeighbourhoodProxy(P(this,Y,"f").uuid)}get ai(){return P(this,pe,"f").aiClient}async subscribeInfer(e){let t=new Ms(this.uuid,e,P(this,pe,"f"));return await t.subscribe(),await t.initialized,t}async subscribeQuery(e){let t=new Ms(this.uuid,e,P(this,pe,"f"));return await t.subscribe(),await t.initialized,t}};Y=new WeakMap,pe=new WeakMap,xn=new WeakMap,In=new WeakMap,Tn=new WeakMap,Sa=new WeakMap,_a=new WeakMap;var $r=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},H=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},oe,Ea,xa,Ia,ws,Ta,Ss,_s,hr,rt=`
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
data {
|
|
123
|
-
linkLanguage
|
|
124
|
-
meta {
|
|
125
|
-
links
|
|
126
|
-
{
|
|
127
|
-
author
|
|
128
|
-
timestamp
|
|
129
|
-
data { source, predicate, target }
|
|
130
|
-
proof { valid, invalid, signature, key }
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
author
|
|
135
|
-
}
|
|
136
|
-
`,Us=class{constructor(e,t=!0){oe.set(this,void 0),Ea.set(this,void 0),xa.set(this,void 0),Ia.set(this,void 0),ws.set(this,void 0),Ta.set(this,void 0),Ss.set(this,void 0),_s.set(this,void 0),hr.set(this,new Map),$r(this,oe,e,"f"),$r(this,Ea,[],"f"),$r(this,xa,[],"f"),$r(this,Ia,[],"f"),$r(this,ws,[],"f"),t&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}getOrCreateProxy(e){let t=H(this,hr,"f").get(e.uuid);if(t)return t.updateHandle(e),t;let n=new Ju(e,this);return H(this,hr,"f").set(e.uuid,n),n}setExpressionClient(e){$r(this,Ta,e,"f")}setNeighbourhoodClient(e){$r(this,Ss,e,"f")}setAIClient(e){$r(this,_s,e,"f")}get aiClient(){return H(this,_s,"f")}async all(){let{perspectives:e}=k(await H(this,oe,"f").query({query:x`query perspectives {
|
|
137
|
-
perspectives {
|
|
138
|
-
${bi}
|
|
139
|
-
}
|
|
140
|
-
}`}));return e.map(t=>this.getOrCreateProxy(t))}async byUUID(e){let t=H(this,hr,"f").get(e);if(t)return t;let{perspective:n}=k(await H(this,oe,"f").query({query:x`query perspective($uuid: String!) {
|
|
141
|
-
perspective(uuid: $uuid) {
|
|
142
|
-
${bi}
|
|
143
|
-
}
|
|
144
|
-
}`,variables:{uuid:e}}));return n?this.getOrCreateProxy(n):null}async snapshotByUUID(e){let{perspectiveSnapshot:t}=k(await H(this,oe,"f").query({query:x`query perspectiveSnapshot($uuid: String!) {
|
|
145
|
-
perspectiveSnapshot(uuid: $uuid) {
|
|
146
|
-
links { ${rt} }
|
|
147
|
-
}
|
|
148
|
-
}`,variables:{uuid:e}}));return t}async publishSnapshotByUUID(e){let{perspectivePublishSnapshot:t}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectivePublishSnapshot($uuid: String!) {
|
|
149
|
-
perspectivePublishSnapshot(uuid: $uuid)
|
|
150
|
-
}`,variables:{uuid:e}}));return t}async queryLinks(e,t){let{perspectiveQueryLinks:n}=k(await H(this,oe,"f").query({query:x`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
|
|
151
|
-
perspectiveQueryLinks(query: $query, uuid: $uuid) {
|
|
152
|
-
${rt}
|
|
153
|
-
}
|
|
154
|
-
}`,variables:{uuid:e,query:t}}));return n}async queryProlog(e,t){let{perspectiveQueryProlog:n}=k(await H(this,oe,"f").query({query:x`query perspectiveQueryProlog($uuid: String!, $query: String!) {
|
|
155
|
-
perspectiveQueryProlog(uuid: $uuid, query: $query)
|
|
156
|
-
}`,variables:{uuid:e,query:t}}));return JSON.parse(n)}async querySparql(e,t){let{perspectiveQuerySparql:n}=k(await H(this,oe,"f").query({query:x`query perspectiveQuerySparql($uuid: String!, $query: String!) {
|
|
157
|
-
perspectiveQuerySparql(uuid: $uuid, query: $query)
|
|
158
|
-
}`,variables:{uuid:e,query:t}}));return JSON.parse(n)}async subscribeQuery(e,t){let{perspectiveSubscribeQuery:n}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
|
|
159
|
-
perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
|
|
160
|
-
subscriptionId
|
|
161
|
-
result
|
|
162
|
-
}
|
|
163
|
-
}`,variables:{uuid:e,query:t}})),{subscriptionId:i,result:a}=n,o=a,s=!1;o.startsWith("#init#")&&(o=o.substring(6),s=!0);try{o=JSON.parse(o)}catch(c){console.error("Error parsing perspectiveSubscribeQuery result:",c)}return{subscriptionId:i,result:o,isInit:s}}subscribeToQueryUpdates(e,t){let n=H(this,oe,"f").subscribe({query:x`
|
|
164
|
-
subscription perspectiveQuerySubscription($subscriptionId: String!) {
|
|
165
|
-
perspectiveQuerySubscription(subscriptionId: $subscriptionId)
|
|
166
|
-
}
|
|
167
|
-
`,variables:{subscriptionId:e}}).subscribe({next:i=>{if(i.data&&i.data.perspectiveQuerySubscription){let a=i.data.perspectiveQuerySubscription,o=!1;a.startsWith("#init#")&&(a=a.substring(6),o=!0);try{a=JSON.parse(a),o&&typeof a=="object"&&(a.isInit=!0)}catch(s){console.error("Error parsing perspectiveQuerySubscription:",s)}t(a)}},error:i=>console.error("Error in query subscription:",i)});return()=>n.unsubscribe()}async keepAliveQuery(e,t){let{perspectiveKeepAliveQuery:n}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
|
|
168
|
-
perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
169
|
-
}`,variables:{uuid:e,subscriptionId:t}}));return n}async disposeQuerySubscription(e,t){let{perspectiveDisposeQuerySubscription:n}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveDisposeQuerySubscription($uuid: String!, $subscriptionId: String!) {
|
|
170
|
-
perspectiveDisposeQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
|
|
171
|
-
}`,variables:{uuid:e,subscriptionId:t}}));return n}async add(e){let{perspectiveAdd:t}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveAdd($name: String!) {
|
|
172
|
-
perspectiveAdd(name: $name) {
|
|
173
|
-
${bi}
|
|
174
|
-
}
|
|
175
|
-
}`,variables:{name:e}}));return this.getOrCreateProxy(t)}async update(e,t){let{perspectiveUpdate:n}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveUpdate($uuid: String!, $name: String!) {
|
|
176
|
-
perspectiveUpdate(uuid: $uuid, name: $name) {
|
|
177
|
-
${bi}
|
|
178
|
-
}
|
|
179
|
-
}`,variables:{uuid:e,name:t}}));return H(this,hr,"f").delete(e),this.getOrCreateProxy(n)}async remove(e){return H(this,hr,"f").delete(e),k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveRemove($uuid: String!) {
|
|
180
|
-
perspectiveRemove(uuid: $uuid)
|
|
181
|
-
}`,variables:{uuid:e}}))}async addLink(e,t,n="shared",i){let{perspectiveAddLink:a}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
|
|
182
|
-
perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
183
|
-
${rt}
|
|
184
|
-
}
|
|
185
|
-
}`,variables:{uuid:e,link:t,status:n,batchId:i}}));return a}async addLinks(e,t,n="shared",i){let{perspectiveAddLinks:a}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
|
|
186
|
-
perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
|
|
187
|
-
${rt}
|
|
188
|
-
}
|
|
189
|
-
}`,variables:{uuid:e,links:t,status:n,batchId:i}}));return a}async removeLinks(e,t,n){let{perspectiveRemoveLinks:i}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
|
|
190
|
-
perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
|
|
191
|
-
${rt}
|
|
192
|
-
}
|
|
193
|
-
}`,variables:{uuid:e,links:t,batchId:n}}));return i}async linkMutations(e,t,n){let{perspectiveLinkMutations:i}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
|
|
194
|
-
perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
|
|
195
|
-
additions {
|
|
196
|
-
${rt}
|
|
197
|
-
}
|
|
198
|
-
removals {
|
|
199
|
-
${rt}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}`,variables:{uuid:e,mutations:t,status:n}}));return i}async addLinkExpression(e,t,n="shared",i){let{perspectiveAddLinkExpression:a}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
|
|
203
|
-
perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
|
|
204
|
-
${rt}
|
|
205
|
-
}
|
|
206
|
-
}`,variables:{uuid:e,link:t,status:n,batchId:i}}));return a}async updateLink(e,t,n,i){let{perspectiveUpdateLink:a}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
|
|
207
|
-
perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
|
|
208
|
-
${rt}
|
|
209
|
-
}
|
|
210
|
-
}`,variables:{uuid:e,oldLink:t,newLink:n,batchId:i}}));return a}async removeLink(e,t,n){delete t.__typename,delete t.data.__typename,delete t.proof.__typename,delete t.status;let{perspectiveRemoveLink:i}=k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
|
|
211
|
-
perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
|
|
212
|
-
}`,variables:{uuid:e,link:t,batchId:n}}));return i}async addSdna(e,t,n,i,a){return k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String, $sdnaType: String!, $shaclJson: String) {
|
|
213
|
-
perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType, shaclJson: $shaclJson)
|
|
214
|
-
}`,variables:{uuid:e,name:t,sdnaCode:n||"",sdnaType:i,shaclJson:a}})).perspectiveAddSdna}async executeCommands(e,t,n,i,a){return k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
|
|
215
|
-
perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
|
|
216
|
-
}`,variables:{uuid:e,commands:t,expression:n,parameters:i,batchId:a}})).perspectiveExecuteCommands}async createSubject(e,t,n,i,a){return k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
|
|
217
|
-
perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
|
|
218
|
-
}`,variables:{uuid:e,subjectClass:t,expressionAddress:n,initialValues:i,batchId:a}})).perspectiveCreateSubject}async getSubjectData(e,t,n){return k(await H(this,oe,"f").mutate({mutation:x`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
|
|
219
|
-
perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
|
|
220
|
-
}`,variables:{uuid:e,subjectClass:t,expressionAddress:n}})).perspectiveGetSubjectData}async getExpression(e){return await H(this,Ta,"f").get(e)}async createExpression(e,t){return await H(this,Ta,"f").create(e,t)}addPerspectiveAddedListener(e){H(this,Ea,"f").push(e)}subscribePerspectiveAdded(){H(this,oe,"f").subscribe({query:x` subscription {
|
|
221
|
-
perspectiveAdded { ${bi} }
|
|
222
|
-
}
|
|
223
|
-
`}).subscribe({next:e=>{let t=e.data.perspectiveAdded;H(this,Ea,"f").forEach(n=>{n(t)}),this.getOrCreateProxy(t)},error:e=>console.error(e)})}addPerspectiveUpdatedListener(e){H(this,xa,"f").push(e)}subscribePerspectiveUpdated(){H(this,oe,"f").subscribe({query:x` subscription {
|
|
224
|
-
perspectiveUpdated { ${bi} }
|
|
225
|
-
}
|
|
226
|
-
`}).subscribe({next:e=>{let t=e.data.perspectiveUpdated;H(this,xa,"f").forEach(n=>{n(t)}),H(this,hr,"f").delete(t.uuid),this.getOrCreateProxy(t)},error:e=>console.error(e)})}addPerspectiveSyncedListener(e){H(this,ws,"f").push(e)}async addPerspectiveSyncStateChangeListener(e,t){H(this,oe,"f").subscribe({query:x` subscription {
|
|
227
|
-
perspectiveSyncStateChange(uuid: "${e}")
|
|
228
|
-
}
|
|
229
|
-
`}).subscribe({next:n=>{t.forEach(i=>{i(n.data.perspectiveSyncStateChange)})},error:n=>console.error(n)}),await new Promise(n=>setTimeout(n,500))}addPerspectiveRemovedListener(e){H(this,Ia,"f").push(e)}subscribePerspectiveRemoved(){H(this,oe,"f").subscribe({query:x` subscription {
|
|
230
|
-
perspectiveRemoved
|
|
231
|
-
}
|
|
232
|
-
`}).subscribe({next:e=>{let t=e.data.perspectiveRemoved;H(this,Ia,"f").forEach(n=>{n(t)}),H(this,hr,"f").delete(t)},error:e=>console.error(e)})}async addPerspectiveLinkAddedListener(e,t){H(this,oe,"f").subscribe({query:x` subscription {
|
|
233
|
-
perspectiveLinkAdded(uuid: "${e}") { ${rt} }
|
|
48
|
+
FILTER(?s = <${r}> || STRSTARTS(STR(?s), "${s}"))
|
|
49
|
+
}`,l=(await this.querySparql(a)||[]).map(c=>({source:c.s,predicate:c.p,target:c.o}));return Lt.fromLinks(l,r)}async subjectClasses(){try{let e=(await this.get(new Z({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(n=>{let s=n.data.source.split("://");return s[s.length-1].split("/").pop()||""}).filter(n=>n.length>0);return[...new Set(e)]}catch(t){return console.warn("subjectClasses: SHACL lookup failed:",t),[]}}async stringOrTemplateObjectToSubjectClassName(t){if(typeof t=="string")return t;{let e=await this.subjectClassesByTemplate(t);return e[0]?e[0]:t.className}}async createSubject(t,e,n,r){let s;if(typeof t=="string")s=t,await m(this,U,"f").createSubject(m(this,L,"f").uuid,JSON.stringify({className:s,initialValues:n}),e,n?JSON.stringify(n):void 0,r);else{let a=t,o=a.className||a.constructor?.className||a.constructor?.prototype?.className||await this.findClassByProperties(a);if(!o)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await m(this,U,"f").createSubject(m(this,L,"f").uuid,JSON.stringify({className:o,initialValues:n}),e,n?JSON.stringify(n):void 0,r)}return e}async getSubjectData(t,e){if(typeof t=="string")return JSON.parse(await m(this,U,"f").getSubjectData(m(this,L,"f").uuid,JSON.stringify({className:t}),e));let n=t,r=n.className||n.constructor?.className||n.constructor?.prototype?.className||await this.findClassByProperties(n);if(!r)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");return JSON.parse(await m(this,U,"f").getSubjectData(m(this,L,"f").uuid,JSON.stringify({className:r}),e))}async getActionsFromSHACL(t,e){let n=this.escapeRegExp(t),r=new RegExp(`[/:#]${n}Shape$`),s=await this.get(new Z({predicate:e}));for(let a of s)if(r.test(a.data.source)){let o="literal:string:";if(a.data.target.startsWith(o)){let l=a.data.target.slice(o.length),c=l;try{c=decodeURIComponent(l)}catch{}try{return JSON.parse(c)}catch(d){return console.warn(`Failed to parse SHACL actions JSON for ${t}:`,d),null}}}return null}async removeSubject(t,e,n){let r=await this.stringOrTemplateObjectToSubjectClassName(t),s=await this.getActionsFromSHACL(r,"ad4m://destructor");if(!s)throw`No destructor found for subject class: ${r}. Make sure the class was registered with SHACL.`;await this.executeAction(s,e,void 0,n)}async isSubjectInstance(t,e){let n=await this.stringOrTemplateObjectToSubjectClassName(e),r=await this.getSubjectClassMetadata(n);if(!r)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${n}`),!1;if(r.requiredTriples.length===0)return(await this.get(new Z({source:t}))).length>0;let s=r.requiredTriples.map((o,l)=>{let c=o.target?`<${o.target}>`:`?t${l}`;return`<${t}> <${o.predicate}> ${c} .`}).join(`
|
|
50
|
+
`);return await this.querySparql(`ASK WHERE {
|
|
51
|
+
${s}
|
|
52
|
+
}`)===!0}async getSubjectClassMetadata(t){try{let e=await this.getShacl(t);if(!e)return console.warn(`No SHACL metadata found for ${t}`),null;let n=[],r=[],s=new Map,a=new Map,o=new Set;for(let l of e.properties){if(!l.path||!l.name)continue;l.writable&&o.add(l.path),l.adder&&l.adder.length>0?a.set(l.name,{predicate:l.path}):s.set(l.name,{predicate:l.path,resolveLanguage:l.resolveLanguage})}if(e.constructor_actions){for(let l of e.constructor_actions)if(l.predicate){n.push(l.predicate);let c=o.has(l.predicate);l.target&&l.target!=="value"&&!c?r.push({predicate:l.predicate,target:l.target}):r.push({predicate:l.predicate})}}return{requiredPredicates:n,requiredTriples:r,properties:s,relations:a}}catch(e){return console.error(`Error getting SHACL metadata for ${t}:`,e),null}}async findInstancesByMetadata(t){if(t.requiredTriples.length===0){let r=await this.get(new Z({})),s=new Set(r.map(a=>a.data.source));return Array.from(s).map(a=>({base:a}))}let e=t.requiredTriples.map((r,s)=>{let a=r.target?`<${r.target}>`:`?t${s}`;return`?base <${r.predicate}> ${a} .`}).join(`
|
|
53
|
+
`),n=await this.querySparql(`SELECT DISTINCT ?base WHERE {
|
|
54
|
+
${e}
|
|
55
|
+
}`);return Array.isArray(n)?n.map(r=>({base:r.base})):[]}async getAllSubjectInstances(t){let e=[],n=typeof t=="function";typeof t=="string"?e=[t]:n?e=[t.name]:e=await this.subjectClassesByTemplate(t);let r=[];for(let s of e){let a=await this.getSubjectClassMetadata(s);if(a){let o=await this.findInstancesByMetadata(a);for(let l of o||[])try{let c;if(n)c=new t(this,l.base),await c.get();else{let d=await this.getSubjectData(s,l.base);c={id:l.base,...d}}r.push(c)}catch{}}}return r}async findClassByProperties(t){let e=[],n=[],s=Object.getPrototypeOf(t)?.constructor,a=s?Je(s):{};Object.keys(a).length>0?e=Object.keys(a):e=Object.keys(t).filter(d=>!Array.isArray(t[d]));let o=s?Object.fromEntries(Object.entries(te(s)).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany")):{};if(Object.keys(o).length>0?n=Object.keys(o).filter(d=>d!=="isSubjectInstance"):n=Object.keys(t).filter(d=>Array.isArray(t[d])&&d!=="isSubjectInstance"),e.length===0&&n.length===0)return null;let l=await this.querySparql(`
|
|
56
|
+
SELECT ?shape ?predicate ?target WHERE {
|
|
57
|
+
{ ?shape <rdf://type> <ad4m://SubjectClass> . BIND(<rdf://type> AS ?predicate) BIND(<ad4m://SubjectClass> AS ?target) }
|
|
58
|
+
UNION
|
|
59
|
+
{ ?shape <sh://property> ?target . BIND(<sh://property> AS ?predicate) }
|
|
60
|
+
UNION
|
|
61
|
+
{ ?shape <sh://collection> ?target . BIND(<sh://collection> AS ?predicate) }
|
|
234
62
|
}
|
|
235
|
-
`}).
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
${rt}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}`,variables:{uuid:e,batchId:t}}));return n}};oe=new WeakMap,Ea=new WeakMap,xa=new WeakMap,Ia=new WeakMap,ws=new WeakMap,Ta=new WeakMap,Ss=new WeakMap,_s=new WeakMap,hr=new WeakMap;var wi=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Z=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},te,ka,Aa,Oa,Ca,Ra,ha=`
|
|
260
|
-
did
|
|
261
|
-
directMessageLanguage
|
|
262
|
-
perspective {
|
|
263
|
-
links {
|
|
264
|
-
author, timestamp,
|
|
265
|
-
proof {
|
|
266
|
-
signature, key, valid, invalid
|
|
267
|
-
}
|
|
268
|
-
data {
|
|
269
|
-
source, predicate, target
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
`,rs=`
|
|
274
|
-
requestId
|
|
275
|
-
revoked
|
|
276
|
-
auth {
|
|
277
|
-
appName
|
|
278
|
-
appDesc
|
|
279
|
-
appUrl
|
|
280
|
-
appIconPath
|
|
281
|
-
capabilities {
|
|
282
|
-
with {
|
|
283
|
-
domain
|
|
284
|
-
pointers
|
|
285
|
-
}
|
|
286
|
-
can
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
`,Si=`
|
|
290
|
-
isInitialized
|
|
291
|
-
isUnlocked
|
|
292
|
-
did
|
|
293
|
-
didDocument
|
|
294
|
-
error
|
|
295
|
-
`,ns=`
|
|
296
|
-
did
|
|
297
|
-
didSigningKeyId
|
|
298
|
-
deviceKeyType
|
|
299
|
-
deviceKey
|
|
300
|
-
deviceKeySignedByDid
|
|
301
|
-
didSignedByDeviceKey
|
|
302
|
-
`,bv=`
|
|
303
|
-
signature
|
|
304
|
-
publicKey
|
|
305
|
-
`,Ja=class{constructor(e,t=!0){te.set(this,void 0),ka.set(this,void 0),Aa.set(this,void 0),Oa.set(this,void 0),Ca.set(this,void 0),Ra.set(this,void 0),wi(this,te,e,"f"),wi(this,Aa,[],"f"),wi(this,Oa,[],"f"),wi(this,ka,[],"f"),wi(this,Ca,[],"f"),wi(this,Ra,[],"f"),t&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let{agent:e}=k(await Z(this,te,"f").query({query:x`query agent { agent { ${ha} } }`})),t=new Hr(e.did,e.perspective);return t.directMessageLanguage=e.directMessageLanguage,t}async status(){let{agentStatus:e}=k(await Z(this,te,"f").query({query:x`query agentStatus {
|
|
306
|
-
agentStatus {
|
|
307
|
-
${Si}
|
|
308
|
-
}
|
|
309
|
-
}`}));return new Rt(e)}async generate(e){let{agentGenerate:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentGenerate(
|
|
310
|
-
$passphrase: String!
|
|
311
|
-
) {
|
|
312
|
-
agentGenerate(passphrase: $passphrase) {
|
|
313
|
-
${Si}
|
|
314
|
-
}
|
|
315
|
-
}`,variables:{passphrase:e}}));return new Rt(t)}async import(e){let{did:t,didDocument:n,keystore:i,passphrase:a}=e,{agentImport:o}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentImport(
|
|
316
|
-
$did: String!,
|
|
317
|
-
$didDocument: String!,
|
|
318
|
-
$keystore: String!,
|
|
319
|
-
$passphrase: String!
|
|
320
|
-
) {
|
|
321
|
-
agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
|
|
322
|
-
${Si}
|
|
323
|
-
}
|
|
324
|
-
}`,variables:{did:t,didDocument:n,keystore:i,passphrase:a}}));return new Rt(o)}async lock(e){let{agentLock:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentLock($passphrase: String!) {
|
|
325
|
-
agentLock(passphrase: $passphrase) {
|
|
326
|
-
${Si}
|
|
327
|
-
}
|
|
328
|
-
}`,variables:{passphrase:e}}));return new Rt(t)}async unlock(e,t=!0){let{agentUnlock:n}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
|
|
329
|
-
agentUnlock(passphrase: $passphrase, holochain: $holochain) {
|
|
330
|
-
${Si}
|
|
331
|
-
}
|
|
332
|
-
}`,variables:{passphrase:e,holochain:t}}));return new Rt(n)}async byDID(e){let{agentByDID:t}=k(await Z(this,te,"f").query({query:x`query agentByDID($did: String!) {
|
|
333
|
-
agentByDID(did: $did) {
|
|
334
|
-
${ha}
|
|
335
|
-
}
|
|
336
|
-
}`,variables:{did:e}}));return t}async updatePublicPerspective(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(o=>{delete o.__typename,delete o.data.__typename,delete o.proof.__typename,delete o.status});let{agentUpdatePublicPerspective:n}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
|
|
337
|
-
agentUpdatePublicPerspective(perspective: $perspective) {
|
|
338
|
-
${ha}
|
|
339
|
-
}
|
|
340
|
-
}`,variables:{perspective:t}})),i=n,a=new Hr(i.did,i.perspective);return a.directMessageLanguage=i.directMessageLanguage,a}async mutatePublicPerspective(e){let t=new Us(Z(this,te,"f")),n=new Ja(Z(this,te,"f")),i=await t.add("Agent Perspective Proxy"),a=await n.me();a.perspective&&await i.loadSnapshot(a.perspective);for(let c of e.additions)await i.add(c);for(let c of e.removals)await i.remove(c);let o=await i.snapshot(),s=await this.updatePublicPerspective(o);return await t.remove(i.uuid),s}async updateDirectMessageLanguage(e){let{agentUpdateDirectMessageLanguage:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
|
|
341
|
-
agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
|
|
342
|
-
${ha}
|
|
343
|
-
}
|
|
344
|
-
}`,variables:{directMessageLanguage:e}})),n=t,i=new Hr(n.did,n.perspective);return i.directMessageLanguage=n.directMessageLanguage,i}async addEntanglementProofs(e){let{agentAddEntanglementProofs:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
345
|
-
agentAddEntanglementProofs(proofs: $proofs) {
|
|
346
|
-
${ns}
|
|
347
|
-
}
|
|
348
|
-
}`,variables:{proofs:e}}));return t}async deleteEntanglementProofs(e){let{agentDeleteEntanglementProofs:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
349
|
-
agentDeleteEntanglementProofs(proofs: $proofs) {
|
|
350
|
-
${ns}
|
|
351
|
-
}
|
|
352
|
-
}`,variables:{proofs:e}}));return t}async getEntanglementProofs(){let{agentGetEntanglementProofs:e}=k(await Z(this,te,"f").query({query:x`query agentGetEntanglementProofs {
|
|
353
|
-
agentGetEntanglementProofs {
|
|
354
|
-
${ns}
|
|
355
|
-
}
|
|
356
|
-
}`}));return e}async entanglementProofPreFlight(e,t){let{agentEntanglementProofPreFlight:n}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
|
|
357
|
-
agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
|
|
358
|
-
${ns}
|
|
359
|
-
}
|
|
360
|
-
}`,variables:{deviceKey:e,deviceKeyType:t}}));return n}addUpdatedListener(e){Z(this,Aa,"f").push(e)}addAppChangedListener(e){Z(this,ka,"f").push(e)}subscribeAgentUpdated(){Z(this,te,"f").subscribe({query:x` subscription {
|
|
361
|
-
agentUpdated { ${ha} }
|
|
362
|
-
}
|
|
363
|
-
`}).subscribe({next:e=>{let t=e.data.agentUpdated;Z(this,Aa,"f").forEach(n=>{n(t)})},error:e=>console.error(e)})}subscribeAppsChanged(){Z(this,te,"f").subscribe({query:x` subscription {
|
|
364
|
-
agentAppsChanged {
|
|
365
|
-
${rs}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
`}).subscribe({next:e=>{Z(this,ka,"f").forEach(t=>{t()})},error:e=>console.error(e)})}addAgentStatusChangedListener(e){Z(this,Oa,"f").push(e)}subscribeAgentStatusChanged(){Z(this,te,"f").subscribe({query:x` subscription {
|
|
369
|
-
agentStatusChanged { ${Si} }
|
|
370
|
-
}
|
|
371
|
-
`}).subscribe({next:e=>{let t=e.data.agentStatusChanged;Z(this,Oa,"f").forEach(n=>{n(t)})},error:e=>console.error(e)})}addHostingUserInfoChangedListener(e){Z(this,Ca,"f").push(e)}subscribeHostingUserInfoChanged(){Z(this,te,"f").subscribe({query:x`subscription {
|
|
372
|
-
runtimeHostingUserInfoChanged {
|
|
373
|
-
email
|
|
374
|
-
remainingCredits
|
|
375
|
-
hotWalletAddress
|
|
376
|
-
freeAccess
|
|
377
|
-
}
|
|
378
|
-
}`}).subscribe({next:e=>{let t=e.data.runtimeHostingUserInfoChanged;Z(this,Ca,"f").forEach(n=>n(t))},error:e=>console.error(e)})}addComputeLogUpdatedListener(e){Z(this,Ra,"f").push(e)}subscribeComputeLogUpdated(){Z(this,te,"f").subscribe({query:x`subscription {
|
|
379
|
-
runtimeComputeLogUpdated {
|
|
380
|
-
id
|
|
381
|
-
userEmail
|
|
382
|
-
timestamp
|
|
383
|
-
operation
|
|
384
|
-
summary
|
|
385
|
-
cost
|
|
386
|
-
creditsAfter
|
|
387
|
-
}
|
|
388
|
-
}`}).subscribe({next:e=>{let t=e.data.runtimeComputeLogUpdated;Z(this,Ra,"f").forEach(n=>n(t))},error:e=>console.error(e)})}async requestCapability(e){let{agentRequestCapability:t}=k(await Z(this,te,"f").mutate({mutation:x`
|
|
389
|
-
mutation agentRequestCapability($authInfo: AuthInfoInput!) {
|
|
390
|
-
agentRequestCapability(authInfo: $authInfo)
|
|
391
|
-
}
|
|
392
|
-
`,variables:{authInfo:e}}));return t}async permitCapability(e){let{agentPermitCapability:t}=k(await Z(this,te,"f").mutate({mutation:x`
|
|
393
|
-
mutation agentPermitCapability($auth: String!) {
|
|
394
|
-
agentPermitCapability(auth: $auth)
|
|
395
|
-
}
|
|
396
|
-
`,variables:{auth:e}}));return t}async generateJwt(e,t){let{agentGenerateJwt:n}=k(await Z(this,te,"f").mutate({mutation:x`
|
|
397
|
-
mutation agentGenerateJwt($requestId: String!, $rand: String!) {
|
|
398
|
-
agentGenerateJwt(requestId: $requestId, rand: $rand)
|
|
399
|
-
}
|
|
400
|
-
`,variables:{requestId:e,rand:t}}));return n}async getApps(){let{agentGetApps:e}=k(await Z(this,te,"f").mutate({mutation:x`query agentGetApps {
|
|
401
|
-
agentGetApps {
|
|
402
|
-
${rs}
|
|
403
|
-
}
|
|
404
|
-
}`}));return e}async removeApp(e){let{agentRemoveApp:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentRemoveApp($requestId: String!) {
|
|
405
|
-
agentRemoveApp(requestId: $requestId) {
|
|
406
|
-
${rs}
|
|
407
|
-
}
|
|
408
|
-
}`,variables:{requestId:e}}));return t}async revokeToken(e){let{agentRevokeToken:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentRevokeToken($requestId: String!) {
|
|
409
|
-
agentRevokeToken(requestId: $requestId) {
|
|
410
|
-
${rs}
|
|
411
|
-
}
|
|
412
|
-
}`,variables:{requestId:e}}));return t}async isLocked(){let{agentIsLocked:e}=k(await Z(this,te,"f").mutate({mutation:x`
|
|
413
|
-
query agentIsLocked {
|
|
414
|
-
agentIsLocked
|
|
415
|
-
}
|
|
416
|
-
`}));return e}async signMessage(e){let{agentSignMessage:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation agentSignMessage($message: String!) {
|
|
417
|
-
agentSignMessage(message: $message) {
|
|
418
|
-
${bv}
|
|
419
|
-
}
|
|
420
|
-
}`,variables:{message:e}}));return t}async createUser(e,t,n){let{runtimeCreateUser:i}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
|
|
421
|
-
runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
|
|
422
|
-
did
|
|
423
|
-
success
|
|
424
|
-
error
|
|
425
|
-
}
|
|
426
|
-
}`,variables:{email:e,password:t,appInfo:n}}));return i}async loginUser(e,t){let{runtimeLoginUser:n}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeLoginUser($email: String!, $password: String!) {
|
|
427
|
-
runtimeLoginUser(email: $email, password: $password)
|
|
428
|
-
}`,variables:{email:e,password:t}}));return n}async requestLoginVerification(e,t){let{runtimeRequestLoginVerification:n}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
|
|
429
|
-
runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
|
|
430
|
-
success
|
|
431
|
-
message
|
|
432
|
-
requiresPassword
|
|
433
|
-
isExistingUser
|
|
434
|
-
}
|
|
435
|
-
}`,variables:{email:e,appInfo:t}}));return n}async verifyEmailCode(e,t,n){let{runtimeVerifyEmailCode:i}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
436
|
-
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
437
|
-
}`,variables:{email:e,code:t,verificationType:n}}));return i}async hostingUserInfo(){let{runtimeHostingUserInfo:e}=k(await Z(this,te,"f").query({query:x`query runtimeHostingUserInfo {
|
|
438
|
-
runtimeHostingUserInfo {
|
|
439
|
-
email
|
|
440
|
-
remainingCredits
|
|
441
|
-
hotWalletAddress
|
|
442
|
-
freeAccess
|
|
443
|
-
}
|
|
444
|
-
}`}));return e}async computeLog(e,t,n){let{runtimeComputeLog:i}=k(await Z(this,te,"f").query({query:x`query runtimeComputeLog($since: String, $limit: Int, $userEmail: String) {
|
|
445
|
-
runtimeComputeLog(since: $since, limit: $limit, userEmail: $userEmail) {
|
|
446
|
-
id
|
|
447
|
-
userEmail
|
|
448
|
-
timestamp
|
|
449
|
-
operation
|
|
450
|
-
summary
|
|
451
|
-
cost
|
|
452
|
-
creditsAfter
|
|
453
|
-
}
|
|
454
|
-
}`,variables:{since:e,limit:t,userEmail:n},fetchPolicy:"network-only"}));return i}async setHotWalletAddress(e){let{runtimeSetHotWalletAddress:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeSetHotWalletAddress($address: String!) {
|
|
455
|
-
runtimeSetHotWalletAddress(address: $address)
|
|
456
|
-
}`,variables:{address:e}}));return t}async requestPayment(e){let{runtimeRequestPayment:t}=k(await Z(this,te,"f").mutate({mutation:x`mutation runtimeRequestPayment($amountHOT: String!) {
|
|
457
|
-
runtimeRequestPayment(amountHOT: $amountHOT) {
|
|
458
|
-
success
|
|
459
|
-
message
|
|
460
|
-
}
|
|
461
|
-
}`,variables:{amountHOT:e}}));return t}};te=new WeakMap,ka=new WeakMap,Aa=new WeakMap,Oa=new WeakMap,Ca=new WeakMap,Ra=new WeakMap;var wv=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Fr=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},qt,Kp=`
|
|
462
|
-
name
|
|
463
|
-
address
|
|
464
|
-
settings
|
|
465
|
-
icon { code }
|
|
466
|
-
constructorIcon { code }
|
|
467
|
-
settingsIcon { code }
|
|
468
|
-
`,Jp=`
|
|
469
|
-
name
|
|
470
|
-
address
|
|
471
|
-
description
|
|
472
|
-
author
|
|
473
|
-
templated
|
|
474
|
-
templateSourceLanguageAddress
|
|
475
|
-
templateAppliedParams
|
|
476
|
-
possibleTemplateParams
|
|
477
|
-
sourceCodeLink
|
|
478
|
-
`,Zu=class{constructor(e){qt.set(this,void 0),wv(this,qt,e,"f")}async byAddress(e){let{language:t}=k(await Fr(this,qt,"f").query({query:x`query byAddress($address: String!) {
|
|
479
|
-
language(address: $address) {
|
|
480
|
-
${Kp}
|
|
481
|
-
}
|
|
482
|
-
}`,variables:{address:e}}));return t}async byFilter(e){let{languages:t}=k(await Fr(this,qt,"f").query({query:x`query byFilter($filter: String!) {
|
|
483
|
-
languages(filter: $filter) {
|
|
484
|
-
${Kp}
|
|
485
|
-
}
|
|
486
|
-
}`,variables:{filter:e}}));return t}async all(){return this.byFilter("")}async writeSettings(e,t){let{languageWriteSettings:n}=k(await Fr(this,qt,"f").mutate({mutation:x`mutation writeSettings($languageAddress: String!, $settings: String!) {
|
|
487
|
-
languageWriteSettings(languageAddress: $languageAddress, settings: $settings)
|
|
488
|
-
}`,variables:{languageAddress:e,settings:t}}));return n}async applyTemplateAndPublish(e,t){let{languageApplyTemplateAndPublish:n}=k(await Fr(this,qt,"f").mutate({mutation:x`mutation languageApplyTemplateAndPublish(
|
|
489
|
-
$sourceLanguageHash: String!,
|
|
490
|
-
$templateData: String!,
|
|
491
|
-
) {
|
|
492
|
-
languageApplyTemplateAndPublish(sourceLanguageHash: $sourceLanguageHash, templateData: $templateData) {
|
|
493
|
-
name, address
|
|
494
|
-
}
|
|
495
|
-
}`,variables:{sourceLanguageHash:e,templateData:t}}));return n}async publish(e,t){let{languagePublish:n}=k(await Fr(this,qt,"f").mutate({mutation:x`mutation languagePublish(
|
|
496
|
-
$languagePath: String!,
|
|
497
|
-
$languageMeta: LanguageMetaInput!,
|
|
498
|
-
) {
|
|
499
|
-
languagePublish(languagePath: $languagePath, languageMeta: $languageMeta) {
|
|
500
|
-
${Jp}
|
|
501
|
-
}
|
|
502
|
-
}`,variables:{languagePath:e,languageMeta:t}}));return n}async meta(e){let{languageMeta:t}=k(await Fr(this,qt,"f").query({query:x`query languageMeta(
|
|
503
|
-
$address: String!,
|
|
504
|
-
) {
|
|
505
|
-
languageMeta(address: $address) {
|
|
506
|
-
${Jp}
|
|
507
|
-
}
|
|
508
|
-
}`,variables:{address:e}}));return t}async source(e){let{languageSource:t}=k(await Fr(this,qt,"f").query({query:x`query languageSource(
|
|
509
|
-
$address: String!,
|
|
510
|
-
) {
|
|
511
|
-
languageSource(address: $address)
|
|
512
|
-
}`,variables:{address:e}}));return t}async remove(e){let{languageRemove:t}=k(await Fr(this,qt,"f").mutate({mutation:x`mutation languageRemove(
|
|
513
|
-
$address: String!,
|
|
514
|
-
) {
|
|
515
|
-
languageRemove(address: $address)
|
|
516
|
-
}`,variables:{address:e}}));return t}};qt=new WeakMap;var Sv=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Xe=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},at,ki,Yu=class{constructor(e){at.set(this,void 0),ki.set(this,new Map),Sv(this,at,e,"f")}async publishFromPerspective(e,t,n){let{neighbourhoodPublishFromPerspective:i}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodPublishFromPerspective(
|
|
517
|
-
$linkLanguage: String!,
|
|
518
|
-
$meta: PerspectiveInput!,
|
|
519
|
-
$perspectiveUUID: String!
|
|
520
|
-
) {
|
|
521
|
-
neighbourhoodPublishFromPerspective(
|
|
522
|
-
linkLanguage: $linkLanguage,
|
|
523
|
-
meta: $meta,
|
|
524
|
-
perspectiveUUID: $perspectiveUUID
|
|
525
|
-
)
|
|
526
|
-
}`,variables:{perspectiveUUID:e,linkLanguage:t,meta:n}}));return i}async joinFromUrl(e){let{neighbourhoodJoinFromUrl:t}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodJoinFromUrl($url: String!) {
|
|
527
|
-
neighbourhoodJoinFromUrl(url: $url) {
|
|
528
|
-
uuid
|
|
529
|
-
name
|
|
530
|
-
sharedUrl
|
|
531
|
-
state
|
|
532
|
-
neighbourhood {
|
|
533
|
-
data {
|
|
534
|
-
linkLanguage
|
|
535
|
-
meta {
|
|
536
|
-
links
|
|
537
|
-
{
|
|
538
|
-
author
|
|
539
|
-
timestamp
|
|
540
|
-
data { source, predicate, target }
|
|
541
|
-
proof { valid, invalid, signature, key }
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
author
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}`,variables:{url:e}}));return t}async otherAgents(e){let{neighbourhoodOtherAgents:t}=k(await Xe(this,at,"f").query({query:x`query neighbourhoodOtherAgents($perspectiveUUID: String!) {
|
|
549
|
-
neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
|
|
550
|
-
}`,variables:{perspectiveUUID:e}}));return t}async hasTelepresenceAdapter(e){let{neighbourhoodHasTelepresenceAdapter:t}=k(await Xe(this,at,"f").query({query:x`query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
|
|
551
|
-
neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
|
|
552
|
-
}`,variables:{perspectiveUUID:e}}));return t}async onlineAgents(e){let{neighbourhoodOnlineAgents:t}=k(await Xe(this,at,"f").query({query:x`query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
|
|
553
|
-
neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
|
|
554
|
-
did
|
|
555
|
-
status {
|
|
556
|
-
author
|
|
557
|
-
timestamp
|
|
558
|
-
data {
|
|
559
|
-
links {
|
|
560
|
-
author
|
|
561
|
-
timestamp
|
|
562
|
-
data { source, predicate, target }
|
|
563
|
-
proof { valid, invalid, signature, key }
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
proof { valid, invalid, signature, key }
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}`,variables:{perspectiveUUID:e}}));return t}async setOnlineStatus(e,t){let{neighbourhoodSetOnlineStatus:n}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSetOnlineStatus(
|
|
570
|
-
$perspectiveUUID: String!,
|
|
571
|
-
$status: PerspectiveInput!
|
|
572
|
-
) {
|
|
573
|
-
neighbourhoodSetOnlineStatus(
|
|
574
|
-
perspectiveUUID: $perspectiveUUID,
|
|
575
|
-
status: $status
|
|
576
|
-
)
|
|
577
|
-
}`,variables:{perspectiveUUID:e,status:t}}));return n}async setOnlineStatusU(e,t){let{neighbourhoodSetOnlineStatusU:n}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSetOnlineStatusU(
|
|
578
|
-
$perspectiveUUID: String!,
|
|
579
|
-
$status: PerspectiveUnsignedInput!
|
|
580
|
-
) {
|
|
581
|
-
neighbourhoodSetOnlineStatusU(
|
|
582
|
-
perspectiveUUID: $perspectiveUUID,
|
|
583
|
-
status: $status
|
|
584
|
-
)
|
|
585
|
-
}`,variables:{perspectiveUUID:e,status:t}}));return n}async sendSignal(e,t,n){let{neighbourhoodSendSignal:i}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSendSignal(
|
|
586
|
-
$perspectiveUUID: String!,
|
|
587
|
-
$remoteAgentDid: String!,
|
|
588
|
-
$payload: PerspectiveInput!
|
|
589
|
-
) {
|
|
590
|
-
neighbourhoodSendSignal(
|
|
591
|
-
perspectiveUUID: $perspectiveUUID,
|
|
592
|
-
remoteAgentDid: $remoteAgentDid,
|
|
593
|
-
payload: $payload
|
|
594
|
-
)
|
|
595
|
-
}`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:n}}));return i}async sendSignalU(e,t,n){let{neighbourhoodSendSignalU:i}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSendSignalU(
|
|
596
|
-
$perspectiveUUID: String!,
|
|
597
|
-
$remoteAgentDid: String!,
|
|
598
|
-
$payload: PerspectiveUnsignedInput!
|
|
599
|
-
) {
|
|
600
|
-
neighbourhoodSendSignalU(
|
|
601
|
-
perspectiveUUID: $perspectiveUUID,
|
|
602
|
-
remoteAgentDid: $remoteAgentDid,
|
|
603
|
-
payload: $payload
|
|
604
|
-
)
|
|
605
|
-
}`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:n}}));return i}async sendBroadcast(e,t,n=!1){let{neighbourhoodSendBroadcast:i}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSendBroadcast(
|
|
606
|
-
$perspectiveUUID: String!,
|
|
607
|
-
$payload: PerspectiveInput!,
|
|
608
|
-
$loopback: Boolean
|
|
609
|
-
) {
|
|
610
|
-
neighbourhoodSendBroadcast(
|
|
611
|
-
perspectiveUUID: $perspectiveUUID,
|
|
612
|
-
payload: $payload,
|
|
613
|
-
loopback: $loopback
|
|
614
|
-
)
|
|
615
|
-
}`,variables:{perspectiveUUID:e,payload:t,loopback:n}}));return i}async sendBroadcastU(e,t,n=!1){let{neighbourhoodSendBroadcastU:i}=k(await Xe(this,at,"f").mutate({mutation:x`mutation neighbourhoodSendBroadcastU(
|
|
616
|
-
$perspectiveUUID: String!,
|
|
617
|
-
$payload: PerspectiveUnsignedInput!,
|
|
618
|
-
$loopback: Boolean
|
|
619
|
-
) {
|
|
620
|
-
neighbourhoodSendBroadcastU(
|
|
621
|
-
perspectiveUUID: $perspectiveUUID,
|
|
622
|
-
payload: $payload,
|
|
623
|
-
loopback: $loopback
|
|
624
|
-
)
|
|
625
|
-
}`,variables:{perspectiveUUID:e,payload:t,loopback:n}}));return i}dispatchSignal(e,t){let n=Xe(this,ki,"f").get(e);if(n)for(let i of n)try{i(t)}catch(a){console.error("Error in signal handler:",a)}}async subscribeToSignals(e){let t=this;Xe(this,at,"f").subscribe({query:x`subscription neighbourhoodSignal($perspectiveUUID: String!) {
|
|
626
|
-
neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
|
|
627
|
-
author
|
|
628
|
-
timestamp
|
|
629
|
-
data {
|
|
630
|
-
links
|
|
631
|
-
{
|
|
632
|
-
author
|
|
633
|
-
timestamp
|
|
634
|
-
data { source, predicate, target }
|
|
635
|
-
proof { valid, invalid, signature, key }
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
proof { valid, invalid, signature, key }
|
|
639
|
-
}
|
|
640
|
-
}`,variables:{perspectiveUUID:e}}).subscribe({next:n=>{try{let{neighbourhoodSignal:i}=k(n);t.dispatchSignal(e,i)}catch(i){console.error("Error in signal subscription:",i)}},error:n=>{console.error("Signal subscription error for perspective",e,n)}})}async addSignalHandler(e,t){let n=Xe(this,ki,"f").get(e);n?n.push(t):(n=[],Xe(this,ki,"f").set(e,n),n.push(t),await this.subscribeToSignals(e))}removeSignalHandler(e,t){let n=Xe(this,ki,"f").get(e);if(n){let i=n.indexOf(t);i>-1&&n.splice(i,1)}}};at=new WeakMap,ki=new WeakMap;var is=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},j=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},q,Pa,Na,Da,wh,as=`
|
|
641
|
-
author
|
|
642
|
-
timestamp
|
|
643
|
-
data {
|
|
644
|
-
links {
|
|
645
|
-
author
|
|
646
|
-
timestamp
|
|
647
|
-
data { source, predicate, target }
|
|
648
|
-
proof { valid, invalid, signature, key }
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
proof { valid, invalid, signature, key }
|
|
652
|
-
`,_v=`
|
|
653
|
-
description
|
|
654
|
-
appName
|
|
655
|
-
appUrl
|
|
656
|
-
appIconPath
|
|
657
|
-
trigger
|
|
658
|
-
perspectiveIds
|
|
659
|
-
webhookUrl
|
|
660
|
-
webhookAuth
|
|
661
|
-
`,Sh=`
|
|
662
|
-
id
|
|
663
|
-
granted
|
|
664
|
-
${_v}
|
|
665
|
-
`,Ev=`
|
|
666
|
-
notification { ${Sh} }
|
|
667
|
-
perspectiveId
|
|
668
|
-
triggerMatch
|
|
669
|
-
`,Xu=class{constructor(e,t=!0){q.set(this,void 0),Pa.set(this,void 0),Na.set(this,void 0),Da.set(this,void 0),wh.set(this,void 0),is(this,q,e,"f"),is(this,Pa,[],"f"),is(this,Na,[],"f"),is(this,Da,[],"f"),t&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){let{runtimeInfo:e}=k(await j(this,q,"f").query({query:x`query runtimeInfo {
|
|
670
|
-
runtimeInfo {
|
|
671
|
-
ad4mExecutorVersion,
|
|
672
|
-
isInitialized,
|
|
673
|
-
isUnlocked
|
|
674
|
-
}
|
|
675
|
-
}`}));return e}async tlsDomain(){let{runtimeTlsDomain:e}=k(await j(this,q,"f").query({query:x`query runtimeTlsDomain {
|
|
676
|
-
runtimeTlsDomain
|
|
677
|
-
}`}));return e}async quit(){return k(await j(this,q,"f").mutate({mutation:x`mutation runtimeQuit { runtimeQuit }`})).runtimeQuit}async openLink(e){let{runtimeOpenLink:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeOpenLink($url: String!) {
|
|
678
|
-
runtimeOpenLink(url: $url)
|
|
679
|
-
}`,variables:{url:e}}));return t}async addTrustedAgents(e){let{addTrustedAgents:t}=k(await j(this,q,"f").mutate({mutation:x`mutation addTrustedAgents($agents: [String!]!) {
|
|
680
|
-
addTrustedAgents(agents: $agents)
|
|
681
|
-
}`,variables:{agents:e}}));return t}async deleteTrustedAgents(e){let{deleteTrustedAgents:t}=k(await j(this,q,"f").mutate({mutation:x`mutation deleteTrustedAgents($agents: [String!]!) {
|
|
682
|
-
deleteTrustedAgents(agents: $agents)
|
|
683
|
-
}`,variables:{agents:e}}));return t}async getTrustedAgents(){let{getTrustedAgents:e}=k(await j(this,q,"f").query({query:x`query getTrustedAgents {
|
|
684
|
-
getTrustedAgents
|
|
685
|
-
}`}));return e}async addKnownLinkLanguageTemplates(e){let{runtimeAddKnownLinkLanguageTemplates:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
|
|
686
|
-
runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
|
|
687
|
-
}`,variables:{addresses:e}}));return t}async removeKnownLinkLanguageTemplates(e){let{runtimeRemoveKnownLinkLanguageTemplates:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
|
|
688
|
-
runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
|
|
689
|
-
}`,variables:{addresses:e}}));return t}async knownLinkLanguageTemplates(){let{runtimeKnownLinkLanguageTemplates:e}=k(await j(this,q,"f").query({query:x`query runtimeKnownLinkLanguageTemplates {
|
|
690
|
-
runtimeKnownLinkLanguageTemplates
|
|
691
|
-
}`}));return e}async addFriends(e){let{runtimeAddFriends:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeAddFriends($dids: [String!]!) {
|
|
692
|
-
runtimeAddFriends(dids: $dids)
|
|
693
|
-
}`,variables:{dids:e}}));return t}async removeFriends(e){let{runtimeRemoveFriends:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeRemoveFriends($dids: [String!]!) {
|
|
694
|
-
runtimeRemoveFriends(dids: $dids)
|
|
695
|
-
}`,variables:{dids:e}}));return t}async friends(){let{runtimeFriends:e}=k(await j(this,q,"f").query({query:x`query runtimeFriends {
|
|
696
|
-
runtimeFriends
|
|
697
|
-
}`}));return e}async hcAgentInfos(){let{runtimeHcAgentInfos:e}=k(await j(this,q,"f").query({query:x`query runtimeHcAgentInfos {
|
|
698
|
-
runtimeHcAgentInfos
|
|
699
|
-
}`}));return e}async getNetworkMetrics(){let{runtimeGetNetworkMetrics:e}=k(await j(this,q,"f").query({query:x`query runtimeGetNetworkMetrics {
|
|
700
|
-
runtimeGetNetworkMetrics
|
|
701
|
-
}`}));return e}async restartHolochain(){let{runtimeRestartHolochain:e}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeRestartHolochain {
|
|
702
|
-
runtimeRestartHolochain
|
|
703
|
-
}`}));return e}async hcAddAgentInfos(e){let{runtimeHcAddAgentInfos:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
|
|
704
|
-
runtimeHcAddAgentInfos(agentInfos: $agentInfos)
|
|
705
|
-
}`,variables:{agentInfos:e}}));return t}async verifyStringSignedByDid(e,t,n,i){let{runtimeVerifyStringSignedByDid:a}=k(await j(this,q,"f").mutate({mutation:x`query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
|
|
706
|
-
runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
|
|
707
|
-
}`,variables:{did:e,didSigningKeyId:t,data:n,signedData:i}}));return a}async setStatus(e){let{runtimeSetStatus:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetStatus($status: PerspectiveInput!) {
|
|
708
|
-
runtimeSetStatus(status: $status)
|
|
709
|
-
}`,variables:{status:e}}));return t}async friendStatus(e){let{runtimeFriendStatus:t}=k(await j(this,q,"f").query({query:x`query runtimeFriendStatus($did: String!) {
|
|
710
|
-
runtimeFriendStatus(did: $did) { ${as} }
|
|
711
|
-
}`,variables:{did:e}}));return t}async friendSendMessage(e,t){let{runtimeFriendSendMessage:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
|
|
712
|
-
runtimeFriendSendMessage(did: $did, message: $message)
|
|
713
|
-
}`,variables:{did:e,message:t}}));return n}async messageInbox(e){let{runtimeMessageInbox:t}=k(await j(this,q,"f").query({query:x`query runtimeMessageInbox($filter: String) {
|
|
714
|
-
runtimeMessageInbox(filter: $filter) { ${as} }
|
|
715
|
-
}`,variables:{filter:e}}));return t}async messageOutbox(e){let{runtimeMessageOutbox:t}=k(await j(this,q,"f").query({query:x`query runtimeMessageOutbox($filter: String) {
|
|
716
|
-
runtimeMessageOutbox(filter: $filter) {
|
|
717
|
-
recipient,
|
|
718
|
-
message {
|
|
719
|
-
${as}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}`,variables:{filter:e}}));return t}async requestInstallNotification(e){let{runtimeRequestInstallNotification:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
|
|
723
|
-
runtimeRequestInstallNotification(notification: $notification)
|
|
724
|
-
}`,variables:{notification:e}}));return t}async grantNotification(e){let{runtimeGrantNotification:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeGrantNotification($id: String!) {
|
|
725
|
-
runtimeGrantNotification(id: $id)
|
|
726
|
-
}`,variables:{id:e}}));return t}async exportDb(e){let{runtimeExportDb:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeExportDb($filePath: String!) {
|
|
727
|
-
runtimeExportDb(filePath: $filePath)
|
|
728
|
-
}`,variables:{filePath:e}}));return t}async importDb(e){let{runtimeImportDb:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeImportDb($filePath: String!) {
|
|
729
|
-
runtimeImportDb(filePath: $filePath) {
|
|
730
|
-
perspectives { total imported failed omitted errors }
|
|
731
|
-
links { total imported failed omitted errors }
|
|
732
|
-
expressions { total imported failed omitted errors }
|
|
733
|
-
perspectiveDiffs { total imported failed omitted errors }
|
|
734
|
-
notifications { total imported failed omitted errors }
|
|
735
|
-
models { total imported failed omitted errors }
|
|
736
|
-
defaultModels { total imported failed omitted errors }
|
|
737
|
-
tasks { total imported failed omitted errors }
|
|
738
|
-
friends { total imported failed omitted errors }
|
|
739
|
-
trustedAgents { total imported failed omitted errors }
|
|
740
|
-
knownLinkLanguages { total imported failed omitted errors }
|
|
741
|
-
}
|
|
742
|
-
}`,variables:{filePath:e}}));return t}async notifications(){let{runtimeNotifications:e}=k(await j(this,q,"f").query({query:x`query runtimeNotifications {
|
|
743
|
-
runtimeNotifications { ${Sh} }
|
|
744
|
-
}`}));return e}async updateNotification(e,t){let{runtimeUpdateNotification:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
|
|
745
|
-
runtimeUpdateNotification(id: $id, notification: $notification)
|
|
746
|
-
}`,variables:{id:e,notification:t}}));return n}async removeNotification(e){let{runtimeRemoveNotification:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeRemoveNotification($id: String!) {
|
|
747
|
-
runtimeRemoveNotification(id: $id)
|
|
748
|
-
}`,variables:{id:e}}));return t}async exportPerspective(e,t){let{runtimeExportPerspective:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
|
|
749
|
-
runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
|
|
750
|
-
}`,variables:{perspectiveUuid:e,filePath:t}}));return n}async importPerspective(e){let{runtimeImportPerspective:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeImportPerspective($filePath: String!) {
|
|
751
|
-
runtimeImportPerspective(filePath: $filePath)
|
|
752
|
-
}`,variables:{filePath:e}}));return t}async multiUserEnabled(){let{runtimeMultiUserEnabled:e}=k(await j(this,q,"f").query({query:x`query runtimeMultiUserEnabled {
|
|
753
|
-
runtimeMultiUserEnabled
|
|
754
|
-
}`}));return e}async setMultiUserEnabled(e){let{runtimeSetMultiUserEnabled:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
|
|
755
|
-
runtimeSetMultiUserEnabled(enabled: $enabled)
|
|
756
|
-
}`,variables:{enabled:e}}));return t}async freeHostingEnabled(){let{runtimeFreeHostingEnabled:e}=k(await j(this,q,"f").query({query:x`query runtimeFreeHostingEnabled {
|
|
757
|
-
runtimeFreeHostingEnabled
|
|
758
|
-
}`}));return e}async setFreeHostingEnabled(e){let{runtimeSetFreeHostingEnabled:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetFreeHostingEnabled($enabled: Boolean!) {
|
|
759
|
-
runtimeSetFreeHostingEnabled(enabled: $enabled)
|
|
760
|
-
}`,variables:{enabled:e}}));return t}async listUsers(){let{runtimeListUsers:e}=k(await j(this,q,"f").query({query:x`query runtimeListUsers {
|
|
761
|
-
runtimeListUsers {
|
|
762
|
-
email
|
|
763
|
-
did
|
|
764
|
-
lastSeen
|
|
765
|
-
perspectiveCount
|
|
766
|
-
remainingCredits
|
|
767
|
-
freeAccess
|
|
768
|
-
hotWalletAddress
|
|
769
|
-
}
|
|
770
|
-
}`}));return e}async userWalletAddress(e){let{runtimeUserWalletAddress:t}=k(await j(this,q,"f").query({query:x`query runtimeUserWalletAddress($email: String!) {
|
|
771
|
-
runtimeUserWalletAddress(email: $email)
|
|
772
|
-
}`,variables:{email:e}}));return t}async emailTestModeEnable(){let{runtimeEmailTestModeEnable:e}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeEmailTestModeEnable {
|
|
773
|
-
runtimeEmailTestModeEnable
|
|
774
|
-
}`}));return e}async emailTestModeDisable(){let{runtimeEmailTestModeDisable:e}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeEmailTestModeDisable {
|
|
775
|
-
runtimeEmailTestModeDisable
|
|
776
|
-
}`}));return e}async emailTestGetCode(e){let{runtimeEmailTestGetCode:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeEmailTestGetCode($email: String!) {
|
|
777
|
-
runtimeEmailTestGetCode(email: $email)
|
|
778
|
-
}`,variables:{email:e}}));return t}async emailTestClearCodes(){let{runtimeEmailTestClearCodes:e}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeEmailTestClearCodes {
|
|
779
|
-
runtimeEmailTestClearCodes
|
|
780
|
-
}`}));return e}async emailTestSetExpiry(e,t,n){let{runtimeEmailTestSetExpiry:i}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
|
|
781
|
-
runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
|
|
782
|
-
}`,variables:{email:e,verificationType:t,expiresAt:n}}));return i}async unytAgentKey(){let{runtimeUnytAgentKey:e}=k(await j(this,q,"f").query({query:x`query runtimeUnytAgentKey { runtimeUnytAgentKey }`,fetchPolicy:"network-only"}));return e}async unytHotAgentPubkey(){let{runtimeHotAgentPubkey:e}=k(await j(this,q,"f").query({query:x`query runtimeHotAgentPubkey { runtimeHotAgentPubkey }`,fetchPolicy:"network-only"}));return e}async unytWalletBalance(){let{runtimeHotWalletBalance:e}=k(await j(this,q,"f").query({query:x`query runtimeHotWalletBalance { runtimeHotWalletBalance }`,fetchPolicy:"network-only"}));return e}async unytWalletHistory(e,t){let{runtimeHotWalletHistory:n}=k(await j(this,q,"f").query({query:x`query runtimeHotWalletHistory($page: Int, $perPage: Int) {
|
|
783
|
-
runtimeHotWalletHistory(page: $page, perPage: $perPage)
|
|
784
|
-
}`,variables:{page:e,perPage:t},fetchPolicy:"network-only"}));return n}async unytVersionInfo(){let{runtimeUnytVersionInfo:e}=k(await j(this,q,"f").query({query:x`query runtimeUnytVersionInfo { runtimeUnytVersionInfo }`,fetchPolicy:"network-only"}));return e}async unytSetMembraneProof(e){let{runtimeSetUnytMembraneProof:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetUnytMembraneProof($proof: String!) {
|
|
785
|
-
runtimeSetUnytMembraneProof(proof: $proof) { success message }
|
|
786
|
-
}`,variables:{proof:e}}));return t}async unytReinstallDna(){let{runtimeReinstallUnytDna:e}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeReinstallUnytDna {
|
|
787
|
-
runtimeReinstallUnytDna { success message }
|
|
788
|
-
}`}));return e}async unytSendHot(e,t){let{runtimeSendHot:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSendHot($recipient: String!, $amount: String!) {
|
|
789
|
-
runtimeSendHot(recipient: $recipient, amount: $amount) { success message }
|
|
790
|
-
}`,variables:{recipient:e,amount:t}}));return n}async setUserCredits(e,t){let{runtimeSetUserCredits:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetUserCredits($email: String!, $amount: Float!) {
|
|
791
|
-
runtimeSetUserCredits(email: $email, amount: $amount)
|
|
792
|
-
}`,variables:{email:e,amount:t}}));return n}async setUserFreeAccess(e,t){let{runtimeSetUserFreeAccess:n}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetUserFreeAccess($email: String!, $enabled: Boolean!) {
|
|
793
|
-
runtimeSetUserFreeAccess(email: $email, enabled: $enabled)
|
|
794
|
-
}`,variables:{email:e,enabled:t}}));return n}async setHostRates(e){let{runtimeSetHostRates:t}=k(await j(this,q,"f").mutate({mutation:x`mutation runtimeSetHostRates($ratesJson: String!) {
|
|
795
|
-
runtimeSetHostRates(ratesJson: $ratesJson)
|
|
796
|
-
}`,variables:{ratesJson:e}}));return t}async getHostRates(){let{runtimeHostRates:e}=k(await j(this,q,"f").query({query:x`query runtimeHostRates {
|
|
797
|
-
runtimeHostRates
|
|
798
|
-
}`,fetchPolicy:"network-only"}));try{return JSON.parse(e)}catch{return[]}}addNotificationTriggeredCallback(e){j(this,Da,"f").push(e)}subscribeNotificationTriggered(){j(this,q,"f").subscribe({query:x` subscription {
|
|
799
|
-
runtimeNotificationTriggered { ${Ev} }
|
|
800
|
-
}
|
|
801
|
-
`}).subscribe({next:e=>{j(this,Da,"f").forEach(t=>{t(e.data.runtimeNotificationTriggered)})},error:e=>console.error(e)})}addMessageCallback(e){j(this,Pa,"f").push(e)}subscribeMessageReceived(){j(this,q,"f").subscribe({query:x` subscription {
|
|
802
|
-
runtimeMessageReceived { ${as} }
|
|
803
|
-
}
|
|
804
|
-
`}).subscribe({next:e=>{j(this,Pa,"f").forEach(t=>{t(e.data.runtimeMessageReceived)})},error:e=>console.error(e)})}addExceptionCallback(e){j(this,Na,"f").push(e)}subscribeExceptionOccurred(){j(this,q,"f").subscribe({query:x` subscription {
|
|
805
|
-
exceptionOccurred {
|
|
806
|
-
title
|
|
807
|
-
message
|
|
808
|
-
type
|
|
809
|
-
addon
|
|
810
|
-
}
|
|
811
|
-
}`}).subscribe({next:e=>{j(this,Na,"f").forEach(t=>{t(e.data.exceptionOccurred)})},error:e=>console.error(e)})}};q=new WeakMap,Pa=new WeakMap,Na=new WeakMap,Da=new WeakMap,wh=new WeakMap;var xv=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},_i=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},mr,el=class{constructor(e){mr.set(this,void 0),xv(this,mr,e,"f")}async get(e,t=!1){if(!t)try{let i=be.fromUrl(e).get();if(typeof i=="object"&&i!==null&&"author"in i&&"timestamp"in i&&"data"in i&&"proof"in i)return i}catch{}let{expression:n}=k(await _i(this,mr,"f").query({query:x`query expression($url: String!) {
|
|
812
|
-
expression(url: $url) {
|
|
813
|
-
author
|
|
814
|
-
timestamp
|
|
815
|
-
data
|
|
816
|
-
language {
|
|
817
|
-
address
|
|
818
|
-
}
|
|
819
|
-
proof {
|
|
820
|
-
valid
|
|
821
|
-
invalid
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}`,variables:{url:e}}));return n}async getMany(e){let{expressionMany:t}=k(await _i(this,mr,"f").query({query:x`query expressionMany($urls: [String!]!) {
|
|
825
|
-
expressionMany(urls: $urls) {
|
|
826
|
-
author
|
|
827
|
-
timestamp
|
|
828
|
-
data
|
|
829
|
-
language {
|
|
830
|
-
address
|
|
831
|
-
}
|
|
832
|
-
proof {
|
|
833
|
-
valid
|
|
834
|
-
invalid
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}`,variables:{urls:e}}));return t}async getRaw(e){let{expressionRaw:t}=k(await _i(this,mr,"f").query({query:x`query expressionRaw($url: String!) {
|
|
838
|
-
expressionRaw(url: $url)
|
|
839
|
-
}`,variables:{url:e}}));return t}async create(e,t){e=JSON.stringify(e);let{expressionCreate:n}=k(await _i(this,mr,"f").mutate({mutation:x`mutation expressionCreate($content: String!, $languageAddress: String!){
|
|
840
|
-
expressionCreate(content: $content, languageAddress: $languageAddress)
|
|
841
|
-
}`,variables:{content:e,languageAddress:t}}));return n}async interactions(e){let{expressionInteractions:t}=k(await _i(this,mr,"f").query({query:x`query expressionInteractions($url: String!) {
|
|
842
|
-
expressionInteractions(url: $url) {
|
|
843
|
-
label
|
|
844
|
-
name
|
|
845
|
-
parameters { name, type }
|
|
846
|
-
}
|
|
847
|
-
}`,variables:{url:e}}));return t}async interact(e,t){let{expressionInteract:n}=k(await _i(this,mr,"f").mutate({mutation:x`mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
|
|
848
|
-
expressionInteract(url: $url, interactionCall: $interactionCall)
|
|
849
|
-
}`,variables:{url:e,interactionCall:t}}));return n}};mr=new WeakMap;var rc={};rc.byteLength=Tv;rc.toByteArray=Av;rc.fromByteArray=Rv;var Yt=[],Ct=[],Iv=typeof Uint8Array<"u"?Uint8Array:Array,xu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vn=0,Zp=xu.length;vn<Zp;++vn)Yt[vn]=xu[vn],Ct[xu.charCodeAt(vn)]=vn;var vn,Zp;Ct["-".charCodeAt(0)]=62;Ct["_".charCodeAt(0)]=63;function _h(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function Tv(r){var e=_h(r),t=e[0],n=e[1];return(t+n)*3/4-n}function kv(r,e,t){return(e+t)*3/4-t}function Av(r){var e,t=_h(r),n=t[0],i=t[1],a=new Iv(kv(r,n,i)),o=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)e=Ct[r.charCodeAt(c)]<<18|Ct[r.charCodeAt(c+1)]<<12|Ct[r.charCodeAt(c+2)]<<6|Ct[r.charCodeAt(c+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return i===2&&(e=Ct[r.charCodeAt(c)]<<2|Ct[r.charCodeAt(c+1)]>>4,a[o++]=e&255),i===1&&(e=Ct[r.charCodeAt(c)]<<10|Ct[r.charCodeAt(c+1)]<<4|Ct[r.charCodeAt(c+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function Ov(r){return Yt[r>>18&63]+Yt[r>>12&63]+Yt[r>>6&63]+Yt[r&63]}function Cv(r,e,t){for(var n,i=[],a=e;a<t;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255),i.push(Ov(n));return i.join("")}function Rv(r){for(var e,t=r.length,n=t%3,i=[],a=16383,o=0,s=t-n;o<s;o+=a)i.push(Cv(r,o,o+a>s?s:o+a));return n===1?(e=r[t-1],i.push(Yt[e>>2]+Yt[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Yt[e>>10]+Yt[e>>4&63]+Yt[e<<2&63]+"=")),i.join("")}var Pv=4,Yp=0,Xp=1,Nv=2;function Bi(r){let e=r.length;for(;--e>=0;)r[e]=0}var Dv=0,Eh=1,Lv=2,$v=3,Fv=258,bl=29,uo=256,Za=uo+1+bl,Oi=30,wl=19,xh=2*Za+1,Cn=15,Iu=16,Mv=7,Sl=256,Ih=16,Th=17,kh=18,tl=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Es=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Uv=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ah=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jv=512,gr=new Array((Za+2)*2);Bi(gr);var Va=new Array(Oi*2);Bi(Va);var Ya=new Array(jv);Bi(Ya);var Xa=new Array(Fv-$v+1);Bi(Xa);var _l=new Array(bl);Bi(_l);var js=new Array(Oi);Bi(js);function Tu(r,e,t,n,i){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=n,this.max_length=i,this.has_stree=r&&r.length}var Oh,Ch,Rh;function ku(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}var Ph=r=>r<256?Ya[r]:Ya[256+(r>>>7)],eo=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},gt=(r,e,t)=>{r.bi_valid>Iu-t?(r.bi_buf|=e<<r.bi_valid&65535,eo(r,r.bi_buf),r.bi_buf=e>>Iu-r.bi_valid,r.bi_valid+=t-Iu):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},Xt=(r,e,t)=>{gt(r,t[e*2],t[e*2+1])},Nh=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},qv=r=>{r.bi_valid===16?(eo(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},Bv=(r,e)=>{let t=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,c=e.stat_desc.max_length,u,l,d,p,f,h,m=0;for(p=0;p<=Cn;p++)r.bl_count[p]=0;for(t[r.heap[r.heap_max]*2+1]=0,u=r.heap_max+1;u<xh;u++)l=r.heap[u],p=t[t[l*2+1]*2+1]+1,p>c&&(p=c,m++),t[l*2+1]=p,!(l>n)&&(r.bl_count[p]++,f=0,l>=s&&(f=o[l-s]),h=t[l*2],r.opt_len+=h*(p+f),a&&(r.static_len+=h*(i[l*2+1]+f)));if(m!==0){do{for(p=c-1;r.bl_count[p]===0;)p--;r.bl_count[p]--,r.bl_count[p+1]+=2,r.bl_count[c]--,m-=2}while(m>0);for(p=c;p!==0;p--)for(l=r.bl_count[p];l!==0;)d=r.heap[--u],!(d>n)&&(t[d*2+1]!==p&&(r.opt_len+=(p-t[d*2+1])*t[d*2],t[d*2+1]=p),l--)}},Dh=(r,e,t)=>{let n=new Array(Cn+1),i=0,a,o;for(a=1;a<=Cn;a++)i=i+t[a-1]<<1,n[a]=i;for(o=0;o<=e;o++){let s=r[o*2+1];s!==0&&(r[o*2]=Nh(n[s]++,s))}},Vv=()=>{let r,e,t,n,i,a=new Array(Cn+1);for(t=0,n=0;n<bl-1;n++)for(_l[n]=t,r=0;r<1<<tl[n];r++)Xa[t++]=n;for(Xa[t-1]=n,i=0,n=0;n<16;n++)for(js[n]=i,r=0;r<1<<Es[n];r++)Ya[i++]=n;for(i>>=7;n<Oi;n++)for(js[n]=i<<7,r=0;r<1<<Es[n]-7;r++)Ya[256+i++]=n;for(e=0;e<=Cn;e++)a[e]=0;for(r=0;r<=143;)gr[r*2+1]=8,r++,a[8]++;for(;r<=255;)gr[r*2+1]=9,r++,a[9]++;for(;r<=279;)gr[r*2+1]=7,r++,a[7]++;for(;r<=287;)gr[r*2+1]=8,r++,a[8]++;for(Dh(gr,Za+1,a),r=0;r<Oi;r++)Va[r*2+1]=5,Va[r*2]=Nh(r,5);Oh=new Tu(gr,tl,uo+1,Za,Cn),Ch=new Tu(Va,Es,0,Oi,Cn),Rh=new Tu(new Array(0),Uv,0,wl,Mv)},Lh=r=>{let e;for(e=0;e<Za;e++)r.dyn_ltree[e*2]=0;for(e=0;e<Oi;e++)r.dyn_dtree[e*2]=0;for(e=0;e<wl;e++)r.bl_tree[e*2]=0;r.dyn_ltree[Sl*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},$h=r=>{r.bi_valid>8?eo(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},ed=(r,e,t,n)=>{let i=e*2,a=t*2;return r[i]<r[a]||r[i]===r[a]&&n[e]<=n[t]},Au=(r,e,t)=>{let n=r.heap[t],i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&ed(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!ed(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},td=(r,e,t)=>{let n,i,a=0,o,s;if(r.sym_next!==0)do n=r.pending_buf[r.sym_buf+a++]&255,n+=(r.pending_buf[r.sym_buf+a++]&255)<<8,i=r.pending_buf[r.sym_buf+a++],n===0?Xt(r,i,e):(o=Xa[i],Xt(r,o+uo+1,e),s=tl[o],s!==0&&(i-=_l[o],gt(r,i,s)),n--,o=Ph(n),Xt(r,o,t),s=Es[o],s!==0&&(n-=js[o],gt(r,n,s)));while(a<r.sym_next);Xt(r,Sl,e)},rl=(r,e)=>{let t=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,c=-1,u;for(r.heap_len=0,r.heap_max=xh,o=0;o<a;o++)t[o*2]!==0?(r.heap[++r.heap_len]=c=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)u=r.heap[++r.heap_len]=c<2?++c:0,t[u*2]=1,r.depth[u]=0,r.opt_len--,i&&(r.static_len-=n[u*2+1]);for(e.max_code=c,o=r.heap_len>>1;o>=1;o--)Au(r,t,o);u=a;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],Au(r,t,1),s=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=s,t[u*2]=t[o*2]+t[s*2],r.depth[u]=(r.depth[o]>=r.depth[s]?r.depth[o]:r.depth[s])+1,t[o*2+1]=t[s*2+1]=u,r.heap[1]=u++,Au(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Bv(r,e),Dh(t,c,r.bl_count)},rd=(r,e,t)=>{let n,i=-1,a,o=e[0*2+1],s=0,c=7,u=4;for(o===0&&(c=138,u=3),e[(t+1)*2+1]=65535,n=0;n<=t;n++)a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)&&(s<u?r.bl_tree[a*2]+=s:a!==0?(a!==i&&r.bl_tree[a*2]++,r.bl_tree[Ih*2]++):s<=10?r.bl_tree[Th*2]++:r.bl_tree[kh*2]++,s=0,i=a,o===0?(c=138,u=3):a===o?(c=6,u=3):(c=7,u=4))},nd=(r,e,t)=>{let n,i=-1,a,o=e[0*2+1],s=0,c=7,u=4;for(o===0&&(c=138,u=3),n=0;n<=t;n++)if(a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)){if(s<u)do Xt(r,a,r.bl_tree);while(--s!==0);else a!==0?(a!==i&&(Xt(r,a,r.bl_tree),s--),Xt(r,Ih,r.bl_tree),gt(r,s-3,2)):s<=10?(Xt(r,Th,r.bl_tree),gt(r,s-3,3)):(Xt(r,kh,r.bl_tree),gt(r,s-11,7));s=0,i=a,o===0?(c=138,u=3):a===o?(c=6,u=3):(c=7,u=4)}},Qv=r=>{let e;for(rd(r,r.dyn_ltree,r.l_desc.max_code),rd(r,r.dyn_dtree,r.d_desc.max_code),rl(r,r.bl_desc),e=wl-1;e>=3&&r.bl_tree[Ah[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},zv=(r,e,t,n)=>{let i;for(gt(r,e-257,5),gt(r,t-1,5),gt(r,n-4,4),i=0;i<n;i++)gt(r,r.bl_tree[Ah[i]*2+1],3);nd(r,r.dyn_ltree,e-1),nd(r,r.dyn_dtree,t-1)},Hv=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return Yp;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return Xp;for(t=32;t<uo;t++)if(r.dyn_ltree[t*2]!==0)return Xp;return Yp},id=!1,Wv=r=>{id||(Vv(),id=!0),r.l_desc=new ku(r.dyn_ltree,Oh),r.d_desc=new ku(r.dyn_dtree,Ch),r.bl_desc=new ku(r.bl_tree,Rh),r.bi_buf=0,r.bi_valid=0,Lh(r)},Fh=(r,e,t,n)=>{gt(r,(Dv<<1)+(n?1:0),3),$h(r),eo(r,t),eo(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},Gv=r=>{gt(r,Eh<<1,3),Xt(r,Sl,gr),qv(r)},Kv=(r,e,t,n)=>{let i,a,o=0;r.level>0?(r.strm.data_type===Nv&&(r.strm.data_type=Hv(r)),rl(r,r.l_desc),rl(r,r.d_desc),o=Qv(r),i=r.opt_len+3+7>>>3,a=r.static_len+3+7>>>3,a<=i&&(i=a)):i=a=t+5,t+4<=i&&e!==-1?Fh(r,e,t,n):r.strategy===Pv||a===i?(gt(r,(Eh<<1)+(n?1:0),3),td(r,gr,Va)):(gt(r,(Lv<<1)+(n?1:0),3),zv(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),td(r,r.dyn_ltree,r.dyn_dtree)),Lh(r),n&&$h(r)},Jv=(r,e,t)=>(r.pending_buf[r.sym_buf+r.sym_next++]=e,r.pending_buf[r.sym_buf+r.sym_next++]=e>>8,r.pending_buf[r.sym_buf+r.sym_next++]=t,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(Xa[t]+uo+1)*2]++,r.dyn_dtree[Ph(e)*2]++),r.sym_next===r.sym_end),Zv=Wv,Yv=Fh,Xv=Kv,eb=Jv,tb=Gv,rb={_tr_init:Zv,_tr_stored_block:Yv,_tr_flush_block:Xv,_tr_tally:eb,_tr_align:tb},nb=(r,e,t,n)=>{let i=r&65535|0,a=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do i=i+e[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},to=nb,ib=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},ab=new Uint32Array(ib()),ob=(r,e,t,n)=>{let i=ab,a=n+t;r^=-1;for(let o=n;o<a;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},Ve=ob,jn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Jn={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:sb,_tr_stored_block:nl,_tr_flush_block:cb,_tr_tally:Gr,_tr_align:ub}=rb,{Z_NO_FLUSH:Kr,Z_PARTIAL_FLUSH:lb,Z_FULL_FLUSH:fb,Z_FINISH:Pt,Z_BLOCK:ad,Z_OK:Je,Z_STREAM_END:od,Z_STREAM_ERROR:rr,Z_DATA_ERROR:pb,Z_BUF_ERROR:Ou,Z_DEFAULT_COMPRESSION:db,Z_FILTERED:hb,Z_HUFFMAN_ONLY:os,Z_RLE:mb,Z_FIXED:gb,Z_DEFAULT_STRATEGY:yb,Z_UNKNOWN:vb,Z_DEFLATED:nc}=Jn,bb=9,wb=15,Sb=8,_b=29,Eb=256,il=Eb+1+_b,xb=30,Ib=19,Tb=2*il+1,kb=15,ce=3,Qr=258,nr=Qr+ce+1,Ab=32,Di=42,El=57,al=69,ol=73,sl=91,cl=103,Rn=113,La=666,ot=1,Vi=2,qn=3,Qi=4,Ob=3,Pn=(r,e)=>(r.msg=jn[e],e),sd=r=>r*2-(r>4?9:0),Vr=r=>{let e=r.length;for(;--e>=0;)r[e]=0},Cb=r=>{let e,t,n,i=r.w_size;e=r.hash_size,n=e;do t=r.head[--n],r.head[n]=t>=i?t-i:0;while(--e);e=i,n=e;do t=r.prev[--n],r.prev[n]=t>=i?t-i:0;while(--e)},Rb=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask,Jr=Rb,wt=r=>{let e=r.state,t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},_t=(r,e)=>{cb(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,wt(r.strm)},me=(r,e)=>{r.pending_buf[r.pending++]=e},ma=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},ul=(r,e,t,n)=>{let i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.input.subarray(r.next_in,r.next_in+i),t),r.state.wrap===1?r.adler=to(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Ve(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},Mh=(r,e)=>{let t=r.max_chain_length,n=r.strstart,i,a,o=r.prev_length,s=r.nice_match,c=r.strstart>r.w_size-nr?r.strstart-(r.w_size-nr):0,u=r.window,l=r.w_mask,d=r.prev,p=r.strstart+Qr,f=u[n+o-1],h=u[n+o];r.prev_length>=r.good_match&&(t>>=2),s>r.lookahead&&(s=r.lookahead);do if(i=e,!(u[i+o]!==h||u[i+o-1]!==f||u[i]!==u[n]||u[++i]!==u[n+1])){n+=2,i++;do;while(u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&n<p);if(a=Qr-(p-n),n=p-Qr,a>o){if(r.match_start=e,o=a,a>=s)break;f=u[n+o-1],h=u[n+o]}}while((e=d[e&l])>c&&--t!==0);return o<=r.lookahead?o:r.lookahead},Li=r=>{let e=r.w_size,t,n,i;do{if(n=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-nr)&&(r.window.set(r.window.subarray(e,e+e-n),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,r.insert>r.strstart&&(r.insert=r.strstart),Cb(r),n+=e),r.strm.avail_in===0)break;if(t=ul(r.strm,r.window,r.strstart+r.lookahead,n),r.lookahead+=t,r.lookahead+r.insert>=ce)for(i=r.strstart-r.insert,r.ins_h=r.window[i],r.ins_h=Jr(r,r.ins_h,r.window[i+1]);r.insert&&(r.ins_h=Jr(r,r.ins_h,r.window[i+ce-1]),r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,r.insert--,!(r.lookahead+r.insert<ce)););}while(r.lookahead<nr&&r.strm.avail_in!==0)},Uh=(r,e)=>{let t=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,n,i,a,o=0,s=r.strm.avail_in;do{if(n=65535,a=r.bi_valid+42>>3,r.strm.avail_out<a||(a=r.strm.avail_out-a,i=r.strstart-r.block_start,n>i+r.strm.avail_in&&(n=i+r.strm.avail_in),n>a&&(n=a),n<t&&(n===0&&e!==Pt||e===Kr||n!==i+r.strm.avail_in)))break;o=e===Pt&&n===i+r.strm.avail_in?1:0,nl(r,0,0,o),r.pending_buf[r.pending-4]=n,r.pending_buf[r.pending-3]=n>>8,r.pending_buf[r.pending-2]=~n,r.pending_buf[r.pending-1]=~n>>8,wt(r.strm),i&&(i>n&&(i=n),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+i),r.strm.next_out),r.strm.next_out+=i,r.strm.avail_out-=i,r.strm.total_out+=i,r.block_start+=i,n-=i),n&&(ul(r.strm,r.strm.output,r.strm.next_out,n),r.strm.next_out+=n,r.strm.avail_out-=n,r.strm.total_out+=n)}while(o===0);return s-=r.strm.avail_in,s&&(s>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=s&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-s,r.strm.next_in),r.strstart),r.strstart+=s,r.insert+=s>r.w_size-r.insert?r.w_size-r.insert:s),r.block_start=r.strstart),r.high_water<r.strstart&&(r.high_water=r.strstart),o?Qi:e!==Kr&&e!==Pt&&r.strm.avail_in===0&&r.strstart===r.block_start?Vi:(a=r.window_size-r.strstart,r.strm.avail_in>a&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,a+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),a>r.strm.avail_in&&(a=r.strm.avail_in),a&&(ul(r.strm,r.window,r.strstart,a),r.strstart+=a,r.insert+=a>r.w_size-r.insert?r.w_size-r.insert:a),r.high_water<r.strstart&&(r.high_water=r.strstart),a=r.bi_valid+42>>3,a=r.pending_buf_size-a>65535?65535:r.pending_buf_size-a,t=a>r.w_size?r.w_size:a,i=r.strstart-r.block_start,(i>=t||(i||e===Pt)&&e!==Kr&&r.strm.avail_in===0&&i<=a)&&(n=i>a?a:i,o=e===Pt&&r.strm.avail_in===0&&n===i?1:0,nl(r,r.block_start,n,o),r.block_start+=n,wt(r.strm)),o?qn:ot)},Cu=(r,e)=>{let t,n;for(;;){if(r.lookahead<nr){if(Li(r),r.lookahead<nr&&e===Kr)return ot;if(r.lookahead===0)break}if(t=0,r.lookahead>=ce&&(r.ins_h=Jr(r,r.ins_h,r.window[r.strstart+ce-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-nr&&(r.match_length=Mh(r,t)),r.match_length>=ce)if(n=Gr(r,r.strstart-r.match_start,r.match_length-ce),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=ce){r.match_length--;do r.strstart++,r.ins_h=Jr(r,r.ins_h,r.window[r.strstart+ce-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=Jr(r,r.ins_h,r.window[r.strstart+1]);else n=Gr(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&(_t(r,!1),r.strm.avail_out===0))return ot}return r.insert=r.strstart<ce-1?r.strstart:ce-1,e===Pt?(_t(r,!0),r.strm.avail_out===0?qn:Qi):r.sym_next&&(_t(r,!1),r.strm.avail_out===0)?ot:Vi},Ei=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<nr){if(Li(r),r.lookahead<nr&&e===Kr)return ot;if(r.lookahead===0)break}if(t=0,r.lookahead>=ce&&(r.ins_h=Jr(r,r.ins_h,r.window[r.strstart+ce-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=ce-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-nr&&(r.match_length=Mh(r,t),r.match_length<=5&&(r.strategy===hb||r.match_length===ce&&r.strstart-r.match_start>4096)&&(r.match_length=ce-1)),r.prev_length>=ce&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-ce,n=Gr(r,r.strstart-1-r.prev_match,r.prev_length-ce),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=Jr(r,r.ins_h,r.window[r.strstart+ce-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=ce-1,r.strstart++,n&&(_t(r,!1),r.strm.avail_out===0))return ot}else if(r.match_available){if(n=Gr(r,0,r.window[r.strstart-1]),n&&_t(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return ot}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=Gr(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<ce-1?r.strstart:ce-1,e===Pt?(_t(r,!0),r.strm.avail_out===0?qn:Qi):r.sym_next&&(_t(r,!1),r.strm.avail_out===0)?ot:Vi},Pb=(r,e)=>{let t,n,i,a,o=r.window;for(;;){if(r.lookahead<=Qr){if(Li(r),r.lookahead<=Qr&&e===Kr)return ot;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=ce&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=r.strstart+Qr;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);r.match_length=Qr-(a-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=ce?(t=Gr(r,1,r.match_length-ce),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=Gr(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(_t(r,!1),r.strm.avail_out===0))return ot}return r.insert=0,e===Pt?(_t(r,!0),r.strm.avail_out===0?qn:Qi):r.sym_next&&(_t(r,!1),r.strm.avail_out===0)?ot:Vi},Nb=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(Li(r),r.lookahead===0)){if(e===Kr)return ot;break}if(r.match_length=0,t=Gr(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(_t(r,!1),r.strm.avail_out===0))return ot}return r.insert=0,e===Pt?(_t(r,!0),r.strm.avail_out===0?qn:Qi):r.sym_next&&(_t(r,!1),r.strm.avail_out===0)?ot:Vi};function Jt(r,e,t,n,i){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=n,this.func=i}var $a=[new Jt(0,0,0,0,Uh),new Jt(4,4,8,4,Cu),new Jt(4,5,16,8,Cu),new Jt(4,6,32,32,Cu),new Jt(4,4,16,16,Ei),new Jt(8,16,32,32,Ei),new Jt(8,16,128,128,Ei),new Jt(8,32,128,256,Ei),new Jt(32,128,258,1024,Ei),new Jt(32,258,258,4096,Ei)],Db=r=>{r.window_size=2*r.w_size,Vr(r.head),r.max_lazy_match=$a[r.level].max_lazy,r.good_match=$a[r.level].good_length,r.nice_match=$a[r.level].nice_length,r.max_chain_length=$a[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=ce-1,r.match_available=0,r.ins_h=0};function Lb(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=nc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Tb*2),this.dyn_dtree=new Uint16Array((2*xb+1)*2),this.bl_tree=new Uint16Array((2*Ib+1)*2),Vr(this.dyn_ltree),Vr(this.dyn_dtree),Vr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(kb+1),this.heap=new Uint16Array(2*il+1),Vr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*il+1),Vr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var lo=r=>{if(!r)return 1;let e=r.state;return!e||e.strm!==r||e.status!==Di&&e.status!==El&&e.status!==al&&e.status!==ol&&e.status!==sl&&e.status!==cl&&e.status!==Rn&&e.status!==La?1:0},jh=r=>{if(lo(r))return Pn(r,rr);r.total_in=r.total_out=0,r.data_type=vb;let e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?El:e.wrap?Di:Rn,r.adler=e.wrap===2?0:1,e.last_flush=-2,sb(e),Je},qh=r=>{let e=jh(r);return e===Je&&Db(r.state),e},$b=(r,e)=>lo(r)||r.state.wrap!==2?rr:(r.state.gzhead=e,Je),Bh=(r,e,t,n,i,a)=>{if(!r)return rr;let o=1;if(e===db&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>bb||t!==nc||n<8||n>15||e<0||e>9||a<0||a>gb||n===8&&o!==1)return Pn(r,rr);n===8&&(n=9);let s=new Lb;return r.state=s,s.strm=r,s.status=Di,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+ce-1)/ce),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=e,s.strategy=a,s.method=t,qh(r)},Fb=(r,e)=>Bh(r,e,nc,wb,Sb,yb),Mb=(r,e)=>{if(lo(r)||e>ad||e<0)return r?Pn(r,rr):rr;let t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===La&&e!==Pt)return Pn(r,r.avail_out===0?Ou:rr);let n=t.last_flush;if(t.last_flush=e,t.pending!==0){if(wt(r),r.avail_out===0)return t.last_flush=-1,Je}else if(r.avail_in===0&&sd(e)<=sd(n)&&e!==Pt)return Pn(r,Ou);if(t.status===La&&r.avail_in!==0)return Pn(r,Ou);if(t.status===Di&&t.wrap===0&&(t.status=Rn),t.status===Di){let i=nc+(t.w_bits-8<<4)<<8,a=-1;if(t.strategy>=os||t.level<2?a=0:t.level<6?a=1:t.level===6?a=2:a=3,i|=a<<6,t.strstart!==0&&(i|=Ab),i+=31-i%31,ma(t,i),t.strstart!==0&&(ma(t,r.adler>>>16),ma(t,r.adler&65535)),r.adler=1,t.status=Rn,wt(r),t.pending!==0)return t.last_flush=-1,Je}if(t.status===El){if(r.adler=0,me(t,31),me(t,139),me(t,8),t.gzhead)me(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),me(t,t.gzhead.time&255),me(t,t.gzhead.time>>8&255),me(t,t.gzhead.time>>16&255),me(t,t.gzhead.time>>24&255),me(t,t.level===9?2:t.strategy>=os||t.level<2?4:0),me(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(me(t,t.gzhead.extra.length&255),me(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(r.adler=Ve(r.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=al;else if(me(t,0),me(t,0),me(t,0),me(t,0),me(t,0),me(t,t.level===9?2:t.strategy>=os||t.level<2?4:0),me(t,Ob),t.status=Rn,wt(r),t.pending!==0)return t.last_flush=-1,Je}if(t.status===al){if(t.gzhead.extra){let i=t.pending,a=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+a>t.pending_buf_size;){let s=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex+=s,wt(r),t.pending!==0)return t.last_flush=-1,Je;i=0,a-=s}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending+=a,t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=ol}if(t.status===ol){if(t.gzhead.name){let i=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i)),wt(r),t.pending!==0)return t.last_flush=-1,Je;i=0}t.gzindex<t.gzhead.name.length?a=t.gzhead.name.charCodeAt(t.gzindex++)&255:a=0,me(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i)),t.gzindex=0}t.status=sl}if(t.status===sl){if(t.gzhead.comment){let i=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i)),wt(r),t.pending!==0)return t.last_flush=-1,Je;i=0}t.gzindex<t.gzhead.comment.length?a=t.gzhead.comment.charCodeAt(t.gzindex++)&255:a=0,me(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>i&&(r.adler=Ve(r.adler,t.pending_buf,t.pending-i,i))}t.status=cl}if(t.status===cl){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(wt(r),t.pending!==0))return t.last_flush=-1,Je;me(t,r.adler&255),me(t,r.adler>>8&255),r.adler=0}if(t.status=Rn,wt(r),t.pending!==0)return t.last_flush=-1,Je}if(r.avail_in!==0||t.lookahead!==0||e!==Kr&&t.status!==La){let i=t.level===0?Uh(t,e):t.strategy===os?Nb(t,e):t.strategy===mb?Pb(t,e):$a[t.level].func(t,e);if((i===qn||i===Qi)&&(t.status=La),i===ot||i===qn)return r.avail_out===0&&(t.last_flush=-1),Je;if(i===Vi&&(e===lb?ub(t):e!==ad&&(nl(t,0,0,!1),e===fb&&(Vr(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),wt(r),r.avail_out===0))return t.last_flush=-1,Je}return e!==Pt?Je:t.wrap<=0?od:(t.wrap===2?(me(t,r.adler&255),me(t,r.adler>>8&255),me(t,r.adler>>16&255),me(t,r.adler>>24&255),me(t,r.total_in&255),me(t,r.total_in>>8&255),me(t,r.total_in>>16&255),me(t,r.total_in>>24&255)):(ma(t,r.adler>>>16),ma(t,r.adler&65535)),wt(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Je:od)},Ub=r=>{if(lo(r))return rr;let e=r.state.status;return r.state=null,e===Rn?Pn(r,pb):Je},jb=(r,e)=>{let t=e.length;if(lo(r))return rr;let n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==Di||n.lookahead)return rr;if(i===1&&(r.adler=to(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(Vr(n.head),n.strstart=0,n.block_start=0,n.insert=0);let c=new Uint8Array(n.w_size);c.set(e.subarray(t-n.w_size,t),0),e=c,t=n.w_size}let a=r.avail_in,o=r.next_in,s=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,Li(n);n.lookahead>=ce;){let c=n.strstart,u=n.lookahead-(ce-1);do n.ins_h=Jr(n,n.ins_h,n.window[c+ce-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--u);n.strstart=c,n.lookahead=ce-1,Li(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=ce-1,n.match_available=0,r.next_in=o,r.input=s,r.avail_in=a,n.wrap=i,Je},qb=Fb,Bb=Bh,Vb=qh,Qb=jh,zb=$b,Hb=Mb,Wb=Ub,Gb=jb,Kb="pako deflate (from Nodeca project)",Qa={deflateInit:qb,deflateInit2:Bb,deflateReset:Vb,deflateResetKeep:Qb,deflateSetHeader:zb,deflate:Hb,deflateEnd:Wb,deflateSetDictionary:Gb,deflateInfo:Kb},Jb=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),Zb=function(r){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let t=e.shift();if(!!t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let n in t)Jb(t,n)&&(r[n]=t[n])}}return r},Yb=r=>{let e=0;for(let n=0,i=r.length;n<i;n++)e+=r[n].length;let t=new Uint8Array(e);for(let n=0,i=0,a=r.length;n<a;n++){let o=r[n];t.set(o,i),i+=o.length}return t},ic={assign:Zb,flattenChunks:Yb},Vh=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(r){Vh=!1}var ro=new Uint8Array(256);for(let r=0;r<256;r++)ro[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;ro[254]=ro[254]=1;var Xb=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,n,i,a,o=r.length,s=0;for(i=0;i<o;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),s+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(s),a=0,i=0;a<s;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),t<128?e[a++]=t:t<2048?(e[a++]=192|t>>>6,e[a++]=128|t&63):t<65536?(e[a++]=224|t>>>12,e[a++]=128|t>>>6&63,e[a++]=128|t&63):(e[a++]=240|t>>>18,e[a++]=128|t>>>12&63,e[a++]=128|t>>>6&63,e[a++]=128|t&63);return e},ew=(r,e)=>{if(e<65534&&r.subarray&&Vh)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(r[n]);return t},tw=(r,e)=>{let t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let n,i,a=new Array(t*2);for(i=0,n=0;n<t;){let o=r[n++];if(o<128){a[i++]=o;continue}let s=ro[o];if(s>4){a[i++]=65533,n+=s-1;continue}for(o&=s===2?31:s===3?15:7;s>1&&n<t;)o=o<<6|r[n++]&63,s--;if(s>1){a[i++]=65533;continue}o<65536?a[i++]=o:(o-=65536,a[i++]=55296|o>>10&1023,a[i++]=56320|o&1023)}return ew(a,i)},rw=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+ro[r[t]]>e?t:e},no={string2buf:Xb,buf2string:tw,utf8border:rw};function nw(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Qh=nw,zh=Object.prototype.toString,{Z_NO_FLUSH:iw,Z_SYNC_FLUSH:aw,Z_FULL_FLUSH:ow,Z_FINISH:sw,Z_OK:qs,Z_STREAM_END:cw,Z_DEFAULT_COMPRESSION:uw,Z_DEFAULT_STRATEGY:lw,Z_DEFLATED:fw}=Jn;function fo(r){this.options=ic.assign({level:uw,method:fw,chunkSize:16384,windowBits:15,memLevel:8,strategy:lw},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qh,this.strm.avail_out=0;let t=Qa.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==qs)throw new Error(jn[t]);if(e.header&&Qa.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=no.string2buf(e.dictionary):zh.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=Qa.deflateSetDictionary(this.strm,n),t!==qs)throw new Error(jn[t]);this._dict_set=!0}}fo.prototype.push=function(r,e){let t=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?sw:iw,typeof r=="string"?t.input=no.string2buf(r):zh.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(a===aw||a===ow)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=Qa.deflate(t,a),i===cw)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=Qa.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===qs;if(t.avail_out===0){this.onData(t.output);continue}if(a>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};fo.prototype.onData=function(r){this.chunks.push(r)};fo.prototype.onEnd=function(r){r===qs&&(this.result=ic.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function xl(r,e){let t=new fo(e);if(t.push(r,!0),t.err)throw t.msg||jn[t.err];return t.result}function pw(r,e){return e=e||{},e.raw=!0,xl(r,e)}function dw(r,e){return e=e||{},e.gzip=!0,xl(r,e)}var hw=fo,mw=xl,gw=pw,yw=dw,vw=Jn,bw={Deflate:hw,deflate:mw,deflateRaw:gw,gzip:yw,constants:vw},ss=16209,ww=16191,Sw=function r(e,t){let n,i,a,o,s,c,u,l,d,p,f,h,m,g,_,w,y,b,I,A,E,R,L,N,F=e.state;n=e.next_in,L=e.input,i=n+(e.avail_in-5),a=e.next_out,N=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=F.dmax,u=F.wsize,l=F.whave,d=F.wnext,p=F.window,f=F.hold,h=F.bits,m=F.lencode,g=F.distcode,_=(1<<F.lenbits)-1,w=(1<<F.distbits)-1;e:do{h<15&&(f+=L[n++]<<h,h+=8,f+=L[n++]<<h,h+=8),y=m[f&_];t:for(;;){if(b=y>>>24,f>>>=b,h-=b,b=y>>>16&255,b===0)N[a++]=y&65535;else if(b&16){I=y&65535,b&=15,b&&(h<b&&(f+=L[n++]<<h,h+=8),I+=f&(1<<b)-1,f>>>=b,h-=b),h<15&&(f+=L[n++]<<h,h+=8,f+=L[n++]<<h,h+=8),y=g[f&w];r:for(;;){if(b=y>>>24,f>>>=b,h-=b,b=y>>>16&255,b&16){if(A=y&65535,b&=15,h<b&&(f+=L[n++]<<h,h+=8,h<b&&(f+=L[n++]<<h,h+=8)),A+=f&(1<<b)-1,A>c){e.msg="invalid distance too far back",F.mode=ss;break e}if(f>>>=b,h-=b,b=a-o,A>b){if(b=A-b,b>l&&F.sane){e.msg="invalid distance too far back",F.mode=ss;break e}if(E=0,R=p,d===0){if(E+=u-b,b<I){I-=b;do N[a++]=p[E++];while(--b);E=a-A,R=N}}else if(d<b){if(E+=u+d-b,b-=d,b<I){I-=b;do N[a++]=p[E++];while(--b);if(E=0,d<I){b=d,I-=b;do N[a++]=p[E++];while(--b);E=a-A,R=N}}}else if(E+=d-b,b<I){I-=b;do N[a++]=p[E++];while(--b);E=a-A,R=N}for(;I>2;)N[a++]=R[E++],N[a++]=R[E++],N[a++]=R[E++],I-=3;I&&(N[a++]=R[E++],I>1&&(N[a++]=R[E++]))}else{E=a-A;do N[a++]=N[E++],N[a++]=N[E++],N[a++]=N[E++],I-=3;while(I>2);I&&(N[a++]=N[E++],I>1&&(N[a++]=N[E++]))}}else if((b&64)===0){y=g[(y&65535)+(f&(1<<b)-1)];continue r}else{e.msg="invalid distance code",F.mode=ss;break e}break}}else if((b&64)===0){y=m[(y&65535)+(f&(1<<b)-1)];continue t}else if(b&32){F.mode=ww;break e}else{e.msg="invalid literal/length code",F.mode=ss;break e}break}}while(n<i&&a<s);I=h>>3,n-=I,h-=I<<3,f&=(1<<h)-1,e.next_in=n,e.next_out=a,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=a<s?257+(s-a):257-(a-s),F.hold=f,F.bits=h},xi=15,cd=852,ud=592,ld=0,Ru=1,fd=2,_w=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Ew=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),xw=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Iw=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Tw=(r,e,t,n,i,a,o,s)=>{let c=s.bits,u=0,l=0,d=0,p=0,f=0,h=0,m=0,g=0,_=0,w=0,y,b,I,A,E,R=null,L,N=new Uint16Array(xi+1),F=new Uint16Array(xi+1),_e=null,Ee,O,ge;for(u=0;u<=xi;u++)N[u]=0;for(l=0;l<n;l++)N[e[t+l]]++;for(f=c,p=xi;p>=1&&N[p]===0;p--);if(f>p&&(f=p),p===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<p&&N[d]===0;d++);for(f<d&&(f=d),g=1,u=1;u<=xi;u++)if(g<<=1,g-=N[u],g<0)return-1;if(g>0&&(r===ld||p!==1))return-1;for(F[1]=0,u=1;u<xi;u++)F[u+1]=F[u]+N[u];for(l=0;l<n;l++)e[t+l]!==0&&(o[F[e[t+l]]++]=l);if(r===ld?(R=_e=o,L=20):r===Ru?(R=_w,_e=Ew,L=257):(R=xw,_e=Iw,L=0),w=0,l=0,u=d,E=a,h=f,m=0,I=-1,_=1<<f,A=_-1,r===Ru&&_>cd||r===fd&&_>ud)return 1;for(;;){Ee=u-m,o[l]+1<L?(O=0,ge=o[l]):o[l]>=L?(O=_e[o[l]-L],ge=R[o[l]-L]):(O=32+64,ge=0),y=1<<u-m,b=1<<h,d=b;do b-=y,i[E+(w>>m)+b]=Ee<<24|O<<16|ge|0;while(b!==0);for(y=1<<u-1;w&y;)y>>=1;if(y!==0?(w&=y-1,w+=y):w=0,l++,--N[u]===0){if(u===p)break;u=e[t+o[l]]}if(u>f&&(w&A)!==I){for(m===0&&(m=f),E+=d,h=u-m,g=1<<h;h+m<p&&(g-=N[h+m],!(g<=0));)h++,g<<=1;if(_+=1<<h,r===Ru&&_>cd||r===fd&&_>ud)return 1;I=w&A,i[I]=f<<24|h<<16|E-a|0}}return w!==0&&(i[E+w]=u-m<<24|64<<16|0),s.bits=f,0},za=Tw,kw=0,Hh=1,Wh=2,{Z_FINISH:pd,Z_BLOCK:Aw,Z_TREES:cs,Z_OK:Bn,Z_STREAM_END:Ow,Z_NEED_DICT:Cw,Z_STREAM_ERROR:Dt,Z_DATA_ERROR:Gh,Z_MEM_ERROR:Kh,Z_BUF_ERROR:Rw,Z_DEFLATED:dd}=Jn,ac=16180,hd=16181,md=16182,gd=16183,yd=16184,vd=16185,bd=16186,wd=16187,Sd=16188,_d=16189,Bs=16190,pr=16191,Pu=16192,Ed=16193,Nu=16194,xd=16195,Id=16196,Td=16197,kd=16198,us=16199,ls=16200,Ad=16201,Od=16202,Cd=16203,Rd=16204,Pd=16205,Du=16206,Nd=16207,Dd=16208,Ie=16209,Jh=16210,Zh=16211,Pw=852,Nw=592,Dw=15,Lw=Dw,Ld=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function $w(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Zn=r=>{if(!r)return 1;let e=r.state;return!e||e.strm!==r||e.mode<ac||e.mode>Zh?1:0},Yh=r=>{if(Zn(r))return Dt;let e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=ac,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Pw),e.distcode=e.distdyn=new Int32Array(Nw),e.sane=1,e.back=-1,Bn},Xh=r=>{if(Zn(r))return Dt;let e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,Yh(r)},em=(r,e)=>{let t;if(Zn(r))return Dt;let n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?Dt:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,Xh(r))},tm=(r,e)=>{if(!r)return Dt;let t=new $w;r.state=t,t.strm=r,t.window=null,t.mode=ac;let n=em(r,e);return n!==Bn&&(r.state=null),n},Fw=r=>tm(r,Lw),$d=!0,Lu,$u,Mw=r=>{if($d){Lu=new Int32Array(512),$u=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(za(Hh,r.lens,0,288,Lu,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;za(Wh,r.lens,0,32,$u,0,r.work,{bits:5}),$d=!1}r.lencode=Lu,r.lenbits=9,r.distcode=$u,r.distbits=5},rm=(r,e,t,n)=>{let i,a=r.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(e.subarray(t-a.wsize,t),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),a.window.set(e.subarray(t-n,t-n+i),a.wnext),n-=i,n?(a.window.set(e.subarray(t-n,t),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},Uw=(r,e)=>{let t,n,i,a,o,s,c,u,l,d,p,f,h,m,g=0,_,w,y,b,I,A,E,R,L=new Uint8Array(4),N,F,_e=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Zn(r)||!r.output||!r.input&&r.avail_in!==0)return Dt;t=r.state,t.mode===pr&&(t.mode=Pu),o=r.next_out,i=r.output,c=r.avail_out,a=r.next_in,n=r.input,s=r.avail_in,u=t.hold,l=t.bits,d=s,p=c,R=Bn;e:for(;;)switch(t.mode){case ac:if(t.wrap===0){t.mode=Pu;break}for(;l<16;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(t.wrap&2&&u===35615){t.wbits===0&&(t.wbits=15),t.check=0,L[0]=u&255,L[1]=u>>>8&255,t.check=Ve(t.check,L,2,0),u=0,l=0,t.mode=hd;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((u&255)<<8)+(u>>8))%31){r.msg="incorrect header check",t.mode=Ie;break}if((u&15)!==dd){r.msg="unknown compression method",t.mode=Ie;break}if(u>>>=4,l-=4,E=(u&15)+8,t.wbits===0&&(t.wbits=E),E>15||E>t.wbits){r.msg="invalid window size",t.mode=Ie;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=u&512?_d:pr,u=0,l=0;break;case hd:for(;l<16;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(t.flags=u,(t.flags&255)!==dd){r.msg="unknown compression method",t.mode=Ie;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=Ie;break}t.head&&(t.head.text=u>>8&1),t.flags&512&&t.wrap&4&&(L[0]=u&255,L[1]=u>>>8&255,t.check=Ve(t.check,L,2,0)),u=0,l=0,t.mode=md;case md:for(;l<32;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.head&&(t.head.time=u),t.flags&512&&t.wrap&4&&(L[0]=u&255,L[1]=u>>>8&255,L[2]=u>>>16&255,L[3]=u>>>24&255,t.check=Ve(t.check,L,4,0)),u=0,l=0,t.mode=gd;case gd:for(;l<16;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.head&&(t.head.xflags=u&255,t.head.os=u>>8),t.flags&512&&t.wrap&4&&(L[0]=u&255,L[1]=u>>>8&255,t.check=Ve(t.check,L,2,0)),u=0,l=0,t.mode=yd;case yd:if(t.flags&1024){for(;l<16;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.length=u,t.head&&(t.head.extra_len=u),t.flags&512&&t.wrap&4&&(L[0]=u&255,L[1]=u>>>8&255,t.check=Ve(t.check,L,2,0)),u=0,l=0}else t.head&&(t.head.extra=null);t.mode=vd;case vd:if(t.flags&1024&&(f=t.length,f>s&&(f=s),f&&(t.head&&(E=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(a,a+f),E)),t.flags&512&&t.wrap&4&&(t.check=Ve(t.check,n,f,a)),s-=f,a+=f,t.length-=f),t.length))break e;t.length=0,t.mode=bd;case bd:if(t.flags&2048){if(s===0)break e;f=0;do E=n[a+f++],t.head&&E&&t.length<65536&&(t.head.name+=String.fromCharCode(E));while(E&&f<s);if(t.flags&512&&t.wrap&4&&(t.check=Ve(t.check,n,f,a)),s-=f,a+=f,E)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=wd;case wd:if(t.flags&4096){if(s===0)break e;f=0;do E=n[a+f++],t.head&&E&&t.length<65536&&(t.head.comment+=String.fromCharCode(E));while(E&&f<s);if(t.flags&512&&t.wrap&4&&(t.check=Ve(t.check,n,f,a)),s-=f,a+=f,E)break e}else t.head&&(t.head.comment=null);t.mode=Sd;case Sd:if(t.flags&512){for(;l<16;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(t.wrap&4&&u!==(t.check&65535)){r.msg="header crc mismatch",t.mode=Ie;break}u=0,l=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=pr;break;case _d:for(;l<32;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}r.adler=t.check=Ld(u),u=0,l=0,t.mode=Bs;case Bs:if(t.havedict===0)return r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=u,t.bits=l,Cw;r.adler=t.check=1,t.mode=pr;case pr:if(e===Aw||e===cs)break e;case Pu:if(t.last){u>>>=l&7,l-=l&7,t.mode=Du;break}for(;l<3;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}switch(t.last=u&1,u>>>=1,l-=1,u&3){case 0:t.mode=Ed;break;case 1:if(Mw(t),t.mode=us,e===cs){u>>>=2,l-=2;break e}break;case 2:t.mode=Id;break;case 3:r.msg="invalid block type",t.mode=Ie}u>>>=2,l-=2;break;case Ed:for(u>>>=l&7,l-=l&7;l<32;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if((u&65535)!==(u>>>16^65535)){r.msg="invalid stored block lengths",t.mode=Ie;break}if(t.length=u&65535,u=0,l=0,t.mode=Nu,e===cs)break e;case Nu:t.mode=xd;case xd:if(f=t.length,f){if(f>s&&(f=s),f>c&&(f=c),f===0)break e;i.set(n.subarray(a,a+f),o),s-=f,a+=f,c-=f,o+=f,t.length-=f;break}t.mode=pr;break;case Id:for(;l<14;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(t.nlen=(u&31)+257,u>>>=5,l-=5,t.ndist=(u&31)+1,u>>>=5,l-=5,t.ncode=(u&15)+4,u>>>=4,l-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=Ie;break}t.have=0,t.mode=Td;case Td:for(;t.have<t.ncode;){for(;l<3;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.lens[_e[t.have++]]=u&7,u>>>=3,l-=3}for(;t.have<19;)t.lens[_e[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,N={bits:t.lenbits},R=za(kw,t.lens,0,19,t.lencode,0,t.work,N),t.lenbits=N.bits,R){r.msg="invalid code lengths set",t.mode=Ie;break}t.have=0,t.mode=kd;case kd:for(;t.have<t.nlen+t.ndist;){for(;g=t.lencode[u&(1<<t.lenbits)-1],_=g>>>24,w=g>>>16&255,y=g&65535,!(_<=l);){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(y<16)u>>>=_,l-=_,t.lens[t.have++]=y;else{if(y===16){for(F=_+2;l<F;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(u>>>=_,l-=_,t.have===0){r.msg="invalid bit length repeat",t.mode=Ie;break}E=t.lens[t.have-1],f=3+(u&3),u>>>=2,l-=2}else if(y===17){for(F=_+3;l<F;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}u>>>=_,l-=_,E=0,f=3+(u&7),u>>>=3,l-=3}else{for(F=_+7;l<F;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}u>>>=_,l-=_,E=0,f=11+(u&127),u>>>=7,l-=7}if(t.have+f>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=Ie;break}for(;f--;)t.lens[t.have++]=E}}if(t.mode===Ie)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=Ie;break}if(t.lenbits=9,N={bits:t.lenbits},R=za(Hh,t.lens,0,t.nlen,t.lencode,0,t.work,N),t.lenbits=N.bits,R){r.msg="invalid literal/lengths set",t.mode=Ie;break}if(t.distbits=6,t.distcode=t.distdyn,N={bits:t.distbits},R=za(Wh,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,N),t.distbits=N.bits,R){r.msg="invalid distances set",t.mode=Ie;break}if(t.mode=us,e===cs)break e;case us:t.mode=ls;case ls:if(s>=6&&c>=258){r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=u,t.bits=l,Sw(r,p),o=r.next_out,i=r.output,c=r.avail_out,a=r.next_in,n=r.input,s=r.avail_in,u=t.hold,l=t.bits,t.mode===pr&&(t.back=-1);break}for(t.back=0;g=t.lencode[u&(1<<t.lenbits)-1],_=g>>>24,w=g>>>16&255,y=g&65535,!(_<=l);){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(w&&(w&240)===0){for(b=_,I=w,A=y;g=t.lencode[A+((u&(1<<b+I)-1)>>b)],_=g>>>24,w=g>>>16&255,y=g&65535,!(b+_<=l);){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}u>>>=b,l-=b,t.back+=b}if(u>>>=_,l-=_,t.back+=_,t.length=y,w===0){t.mode=Pd;break}if(w&32){t.back=-1,t.mode=pr;break}if(w&64){r.msg="invalid literal/length code",t.mode=Ie;break}t.extra=w&15,t.mode=Ad;case Ad:if(t.extra){for(F=t.extra;l<F;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.length+=u&(1<<t.extra)-1,u>>>=t.extra,l-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Od;case Od:for(;g=t.distcode[u&(1<<t.distbits)-1],_=g>>>24,w=g>>>16&255,y=g&65535,!(_<=l);){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if((w&240)===0){for(b=_,I=w,A=y;g=t.distcode[A+((u&(1<<b+I)-1)>>b)],_=g>>>24,w=g>>>16&255,y=g&65535,!(b+_<=l);){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}u>>>=b,l-=b,t.back+=b}if(u>>>=_,l-=_,t.back+=_,w&64){r.msg="invalid distance code",t.mode=Ie;break}t.offset=y,t.extra=w&15,t.mode=Cd;case Cd:if(t.extra){for(F=t.extra;l<F;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}t.offset+=u&(1<<t.extra)-1,u>>>=t.extra,l-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=Ie;break}t.mode=Rd;case Rd:if(c===0)break e;if(f=p-c,t.offset>f){if(f=t.offset-f,f>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=Ie;break}f>t.wnext?(f-=t.wnext,h=t.wsize-f):h=t.wnext-f,f>t.length&&(f=t.length),m=t.window}else m=i,h=o-t.offset,f=t.length;f>c&&(f=c),c-=f,t.length-=f;do i[o++]=m[h++];while(--f);t.length===0&&(t.mode=ls);break;case Pd:if(c===0)break e;i[o++]=t.length,c--,t.mode=ls;break;case Du:if(t.wrap){for(;l<32;){if(s===0)break e;s--,u|=n[a++]<<l,l+=8}if(p-=c,r.total_out+=p,t.total+=p,t.wrap&4&&p&&(r.adler=t.check=t.flags?Ve(t.check,i,p,o-p):to(t.check,i,p,o-p)),p=c,t.wrap&4&&(t.flags?u:Ld(u))!==t.check){r.msg="incorrect data check",t.mode=Ie;break}u=0,l=0}t.mode=Nd;case Nd:if(t.wrap&&t.flags){for(;l<32;){if(s===0)break e;s--,u+=n[a++]<<l,l+=8}if(t.wrap&4&&u!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=Ie;break}u=0,l=0}t.mode=Dd;case Dd:R=Ow;break e;case Ie:R=Gh;break e;case Jh:return Kh;case Zh:default:return Dt}return r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=u,t.bits=l,(t.wsize||p!==r.avail_out&&t.mode<Ie&&(t.mode<Du||e!==pd))&&rm(r,r.output,r.next_out,p-r.avail_out),d-=r.avail_in,p-=r.avail_out,r.total_in+=d,r.total_out+=p,t.total+=p,t.wrap&4&&p&&(r.adler=t.check=t.flags?Ve(t.check,i,p,r.next_out-p):to(t.check,i,p,r.next_out-p)),r.data_type=t.bits+(t.last?64:0)+(t.mode===pr?128:0)+(t.mode===us||t.mode===Nu?256:0),(d===0&&p===0||e===pd)&&R===Bn&&(R=Rw),R},jw=r=>{if(Zn(r))return Dt;let e=r.state;return e.window&&(e.window=null),r.state=null,Bn},qw=(r,e)=>{if(Zn(r))return Dt;let t=r.state;return(t.wrap&2)===0?Dt:(t.head=e,e.done=!1,Bn)},Bw=(r,e)=>{let t=e.length,n,i,a;return Zn(r)||(n=r.state,n.wrap!==0&&n.mode!==Bs)?Dt:n.mode===Bs&&(i=1,i=to(i,e,t,0),i!==n.check)?Gh:(a=rm(r,e,t,t),a?(n.mode=Jh,Kh):(n.havedict=1,Bn))},Vw=Xh,Qw=em,zw=Yh,Hw=Fw,Ww=tm,Gw=Uw,Kw=jw,Jw=qw,Zw=Bw,Yw="pako inflate (from Nodeca project)",yr={inflateReset:Vw,inflateReset2:Qw,inflateResetKeep:zw,inflateInit:Hw,inflateInit2:Ww,inflate:Gw,inflateEnd:Kw,inflateGetHeader:Jw,inflateSetDictionary:Zw,inflateInfo:Yw};function Xw(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var eS=Xw,nm=Object.prototype.toString,{Z_NO_FLUSH:tS,Z_FINISH:rS,Z_OK:io,Z_STREAM_END:Fu,Z_NEED_DICT:Mu,Z_STREAM_ERROR:nS,Z_DATA_ERROR:Fd,Z_MEM_ERROR:iS}=Jn;function po(r){this.options=ic.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Qh,this.strm.avail_out=0;let t=yr.inflateInit2(this.strm,e.windowBits);if(t!==io)throw new Error(jn[t]);if(this.header=new eS,yr.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=no.string2buf(e.dictionary):nm.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=yr.inflateSetDictionary(this.strm,e.dictionary),t!==io)))throw new Error(jn[t])}po.prototype.push=function(r,e){let t=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?rS:tS,nm.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),a=yr.inflate(t,o),a===Mu&&i&&(a=yr.inflateSetDictionary(t,i),a===io?a=yr.inflate(t,o):a===Fd&&(a=Mu));t.avail_in>0&&a===Fu&&t.state.wrap>0&&r[t.next_in]!==0;)yr.inflateReset(t),a=yr.inflate(t,o);switch(a){case nS:case Fd:case Mu:case iS:return this.onEnd(a),this.ended=!0,!1}if(s=t.avail_out,t.next_out&&(t.avail_out===0||a===Fu))if(this.options.to==="string"){let c=no.utf8border(t.output,t.next_out),u=t.next_out-c,l=no.buf2string(t.output,c);t.next_out=u,t.avail_out=n-u,u&&t.output.set(t.output.subarray(c,c+u),0),this.onData(l)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(a===io&&s===0)){if(a===Fu)return a=yr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};po.prototype.onData=function(r){this.chunks.push(r)};po.prototype.onEnd=function(r){r===io&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ic.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Il(r,e){let t=new po(e);if(t.push(r),t.err)throw t.msg||jn[t.err];return t.result}function aS(r,e){return e=e||{},e.raw=!0,Il(r,e)}var oS=po,sS=Il,cS=aS,uS=Il,lS=Jn,fS={Inflate:oS,inflate:sS,inflateRaw:cS,ungzip:uS,constants:lS},{Deflate:pS,deflate:dS,deflateRaw:hS,gzip:mS}=bw,{Inflate:gS,inflate:yS,inflateRaw:vS,ungzip:bS}=fS,wS=pS,SS=dS,_S=hS,ES=mS,xS=gS,IS=yS,TS=vS,kS=bS,AS=Jn,OS={Deflate:wS,deflate:SS,deflateRaw:_S,gzip:ES,Inflate:xS,inflate:IS,inflateRaw:TS,ungzip:kS,constants:AS},we=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Se=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Vs=class{constructor(e,t){this.input=e,this.output=t}};we([S(),Se("design:type",String)],Vs.prototype,"input",void 0);we([S(),Se("design:type",String)],Vs.prototype,"output",void 0);Vs=we([ze(),Se("design:paramtypes",[String,String])],Vs);var Qs=class{constructor(e,t){this.input=e,this.output=t}};we([S(),Se("design:type",String)],Qs.prototype,"input",void 0);we([S(),Se("design:type",String)],Qs.prototype,"output",void 0);Qs=we([K(),Se("design:paramtypes",[String,String])],Qs);var en=class{constructor(e,t,n,i,a){this.name=e,this.modelId=t,this.systemPrompt=n,this.promptExamples=i,this.metaData=a}};we([S(),Se("design:type",String)],en.prototype,"name",void 0);we([S(),Se("design:type",String)],en.prototype,"modelId",void 0);we([S(),Se("design:type",String)],en.prototype,"systemPrompt",void 0);we([S(),Se("design:type",Array)],en.prototype,"promptExamples",void 0);we([S(),Se("design:type",String)],en.prototype,"metaData",void 0);en=we([ze(),Se("design:paramtypes",[String,String,String,Array,String])],en);var or=class{constructor(e,t,n,i,a,o,s,c){this.name=e,this.modelId=t,this.taskId=n,this.systemPrompt=i,this.promptExamples=a,this.metaData=o,this.createdAt=s,this.updatedAt=c}};we([S(),Se("design:type",String)],or.prototype,"name",void 0);we([S(),Se("design:type",String)],or.prototype,"modelId",void 0);we([S(),Se("design:type",String)],or.prototype,"taskId",void 0);we([S(),Se("design:type",String)],or.prototype,"systemPrompt",void 0);we([S(),Se("design:type",Array)],or.prototype,"promptExamples",void 0);we([S(),Se("design:type",String)],or.prototype,"metaData",void 0);we([S(),Se("design:type",String)],or.prototype,"createdAt",void 0);we([S(),Se("design:type",String)],or.prototype,"updatedAt",void 0);or=we([K(),Se("design:paramtypes",[String,String,String,String,Array,String,String,String])],or);var Vn=class{constructor(e,t,n,i,a){this.model=e,this.status=t,this.progress=n,this.downloaded=i,this.loaded=a}};we([S(),Se("design:type",String)],Vn.prototype,"model",void 0);we([S(),Se("design:type",String)],Vn.prototype,"status",void 0);we([S(),Se("design:type",Number)],Vn.prototype,"progress",void 0);we([S(),Se("design:type",Boolean)],Vn.prototype,"downloaded",void 0);we([S(),Se("design:type",Boolean)],Vn.prototype,"loaded",void 0);Vn=we([K(),Se("design:paramtypes",[String,String,Number,Boolean,Boolean])],Vn);var CS=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},qe=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Ue,xs,ll=class{constructor(e,t=!0){Ue.set(this,void 0),xs.set(this,new Map),CS(this,Ue,e,"f")}async getModels(){let e=await qe(this,Ue,"f").query({query:x`
|
|
850
|
-
query {
|
|
851
|
-
aiGetModels {
|
|
852
|
-
id
|
|
853
|
-
name
|
|
854
|
-
api {
|
|
855
|
-
baseUrl
|
|
856
|
-
apiKey
|
|
857
|
-
model
|
|
858
|
-
apiType
|
|
859
|
-
}
|
|
860
|
-
local {
|
|
861
|
-
fileName
|
|
862
|
-
tokenizerSource {
|
|
863
|
-
repo
|
|
864
|
-
revision
|
|
865
|
-
fileName
|
|
866
|
-
}
|
|
867
|
-
huggingfaceRepo
|
|
868
|
-
revision
|
|
869
|
-
}
|
|
870
|
-
modelType
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
`});return k(e).aiGetModels}async addModel(e){let t=await qe(this,Ue,"f").mutate({mutation:x`
|
|
874
|
-
mutation($model: ModelInput!) {
|
|
875
|
-
aiAddModel(model: $model)
|
|
876
|
-
}
|
|
877
|
-
`,variables:{model:e}});return k(t).aiAddModel}async updateModel(e,t){let n=await qe(this,Ue,"f").mutate({mutation:x`
|
|
878
|
-
mutation($modelId: String!, $model: ModelInput!) {
|
|
879
|
-
aiUpdateModel(modelId: $modelId, model: $model)
|
|
880
|
-
}
|
|
881
|
-
`,variables:{modelId:e,model:t}});return k(n).aiUpdateModel}async removeModel(e){let t=await qe(this,Ue,"f").mutate({mutation:x`
|
|
882
|
-
mutation($modelId: String!) {
|
|
883
|
-
aiRemoveModel(modelId: $modelId)
|
|
884
|
-
}
|
|
885
|
-
`,variables:{modelId:e}});return k(t).aiRemoveModel}async setDefaultModel(e,t){let n=await qe(this,Ue,"f").mutate({mutation:x`
|
|
886
|
-
mutation($modelType: ModelType!, $modelId: String!) {
|
|
887
|
-
aiSetDefaultModel(modelType: $modelType modelId: $modelId)
|
|
888
|
-
}
|
|
889
|
-
`,variables:{modelId:t,modelType:e}});return k(n).aiSetDefaultModel}async getDefaultModel(e){let t=await qe(this,Ue,"f").query({query:x`
|
|
890
|
-
query($modelType: ModelType!) {
|
|
891
|
-
aiGetDefaultModel(modelType: $modelType) {
|
|
892
|
-
id
|
|
893
|
-
name
|
|
894
|
-
api {
|
|
895
|
-
baseUrl
|
|
896
|
-
apiKey
|
|
897
|
-
model
|
|
898
|
-
apiType
|
|
899
|
-
}
|
|
900
|
-
local {
|
|
901
|
-
fileName
|
|
902
|
-
tokenizerSource {
|
|
903
|
-
repo
|
|
904
|
-
revision
|
|
905
|
-
fileName
|
|
906
|
-
}
|
|
907
|
-
huggingfaceRepo
|
|
908
|
-
revision
|
|
909
|
-
}
|
|
910
|
-
modelType
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
`,variables:{modelType:e}});return k(t).aiGetDefaultModel}async tasks(){let{aiTasks:e}=k(await qe(this,Ue,"f").query({query:x`
|
|
914
|
-
query {
|
|
915
|
-
aiTasks {
|
|
916
|
-
name
|
|
917
|
-
modelId
|
|
918
|
-
taskId
|
|
919
|
-
systemPrompt
|
|
920
|
-
promptExamples {
|
|
921
|
-
input
|
|
922
|
-
output
|
|
923
|
-
}
|
|
924
|
-
metaData
|
|
925
|
-
createdAt
|
|
926
|
-
updatedAt
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
`}));return e}async addTask(e,t,n,i,a){let o=new en(e,t,n,i,a),{aiAddTask:s}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
930
|
-
mutation AiAddTask($task: AITaskInput!) {
|
|
931
|
-
aiAddTask(task: $task) {
|
|
932
|
-
name
|
|
933
|
-
modelId
|
|
934
|
-
taskId
|
|
935
|
-
systemPrompt
|
|
936
|
-
promptExamples {
|
|
937
|
-
input
|
|
938
|
-
output
|
|
939
|
-
}
|
|
940
|
-
metaData
|
|
941
|
-
createdAt
|
|
942
|
-
updatedAt
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
`,variables:{task:o}}));return s}async removeTask(e){let{aiRemoveTask:t}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
946
|
-
mutation AiRemoveTask($taskId: String!) {
|
|
947
|
-
aiRemoveTask(taskId: $taskId) {
|
|
948
|
-
name
|
|
949
|
-
modelId
|
|
950
|
-
taskId
|
|
951
|
-
systemPrompt
|
|
952
|
-
promptExamples {
|
|
953
|
-
input
|
|
954
|
-
output
|
|
955
|
-
}
|
|
956
|
-
metaData
|
|
957
|
-
createdAt
|
|
958
|
-
updatedAt
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
`,variables:{taskId:e}}));return t}async updateTask(e,t){let{aiUpdateTask:n}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
962
|
-
mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
|
|
963
|
-
aiUpdateTask(taskId: $taskId, task: $task) {
|
|
964
|
-
name
|
|
965
|
-
modelId
|
|
966
|
-
taskId
|
|
967
|
-
systemPrompt
|
|
968
|
-
promptExamples {
|
|
969
|
-
input
|
|
970
|
-
output
|
|
971
|
-
}
|
|
972
|
-
metaData
|
|
973
|
-
createdAt
|
|
974
|
-
updatedAt
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
`,variables:{taskId:e,task:{name:t.name,modelId:t.modelId,systemPrompt:t.systemPrompt,promptExamples:t.promptExamples}}}));return n}async modelLoadingStatus(e){let{aiModelLoadingStatus:t}=k(await qe(this,Ue,"f").query({query:x`
|
|
978
|
-
query AiModelLoadingStatus($model: String!) {
|
|
979
|
-
aiModelLoadingStatus(model: $model) {
|
|
980
|
-
model
|
|
981
|
-
status
|
|
982
|
-
progress
|
|
983
|
-
loaded
|
|
984
|
-
downloaded
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
`,variables:{model:e}}));return t}async prompt(e,t){let{aiPrompt:n}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
988
|
-
mutation AiPrompt($taskId: String!, $prompt: String!) {
|
|
989
|
-
aiPrompt(taskId: $taskId, prompt: $prompt)
|
|
990
|
-
}
|
|
991
|
-
`,variables:{taskId:e,prompt:t}}));return n}async embed(e,t){let{aiEmbed:n}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
992
|
-
mutation aiEmbed($modelId: String!, $text: String!) {
|
|
993
|
-
aiEmbed(modelId: $modelId, text: $text)
|
|
994
|
-
}
|
|
995
|
-
`,variables:{modelId:e,text:t}})),i=rc.toByteArray(n);return JSON.parse(OS.inflate(i,{to:"string"}))}async openTranscriptionStream(e,t,n){let{aiOpenTranscriptionStream:i}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
996
|
-
mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
|
|
997
|
-
aiOpenTranscriptionStream(modelId: $modelId, params: $params)
|
|
998
|
-
}
|
|
999
|
-
`,variables:{modelId:e,params:n}})),a=qe(this,Ue,"f").subscribe({query:x` subscription {
|
|
1000
|
-
aiTranscriptionText(streamId: "${i}")
|
|
1001
|
-
}`}).subscribe({next(o){return t(o.data.aiTranscriptionText),o.data.aiTranscriptionText},error(o){console.error(o)}});return qe(this,xs,"f").set(i,a),i}async closeTranscriptionStream(e){let{aiCloseTranscriptionStream:t}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
1002
|
-
mutation aiCloseTranscriptionStream($streamId: String!) {
|
|
1003
|
-
aiCloseTranscriptionStream(streamId: $streamId)
|
|
1004
|
-
}
|
|
1005
|
-
`,variables:{streamId:e}})),n=qe(this,xs,"f").get(e);return n.closed||n.unsubscribe(),t}async feedTranscriptionStream(e,t){let{aiFeedTranscriptionStream:n}=k(await qe(this,Ue,"f").mutate({mutation:x`
|
|
1006
|
-
mutation AiFeedTranscriptionStream($streamIds: [String!]!, $audio: [Float!]!) {
|
|
1007
|
-
aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
|
|
1008
|
-
}
|
|
1009
|
-
`,variables:{streamIds:Array.isArray(e)?e:[e],audio:t}}));return n}};Ue=new WeakMap,xs=new WeakMap;var Mr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Me=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Zt,Is,Fa,Ts,Ma,kn,ks,Ua,ao=class{constructor(e,t=!0){Zt.set(this,void 0),Is.set(this,void 0),Fa.set(this,void 0),Ts.set(this,void 0),Ma.set(this,void 0),kn.set(this,void 0),ks.set(this,void 0),Ua.set(this,void 0),Mr(this,Zt,e,"f"),Mr(this,Is,new Ja(Me(this,Zt,"f"),t),"f"),Mr(this,Fa,new el(Me(this,Zt,"f")),"f"),Mr(this,Ts,new Zu(Me(this,Zt,"f")),"f"),Mr(this,Ma,new Yu(Me(this,Zt,"f")),"f"),Mr(this,Ua,new ll(Me(this,Zt,"f"),t),"f"),Mr(this,kn,new Us(Me(this,Zt,"f"),t),"f"),Me(this,kn,"f").setExpressionClient(Me(this,Fa,"f")),Me(this,kn,"f").setNeighbourhoodClient(Me(this,Ma,"f")),Me(this,kn,"f").setAIClient(Me(this,Ua,"f")),Mr(this,ks,new Xu(Me(this,Zt,"f"),t),"f")}get agent(){return Me(this,Is,"f")}get expression(){return Me(this,Fa,"f")}get languages(){return Me(this,Ts,"f")}get neighbourhood(){return Me(this,Ma,"f")}get perspective(){return Me(this,kn,"f")}get runtime(){return Me(this,ks,"f")}get ai(){return Me(this,Ua,"f")}};Zt=new WeakMap,Is=new WeakMap,Fa=new WeakMap,Ts=new WeakMap,Ma=new WeakMap,kn=new WeakMap,ks=new WeakMap,Ua=new WeakMap;var fl;(function(r){r.LanguageIsNotLoaded="LANGUAGE_IS_NOT_LOADED",r.ExpressionIsNotVerified="EXPRESSION_IS_NOT_VERIFIED",r.AgentIsUntrusted="AGENT_IS_UNTRUSTED",r.CapabilityRequested="CAPABILITY_REQUESTED",r.InstallNotificationRequest="INSTALL_NOTIFICATION_REQUEST"})(fl||(fl={}));var Tl=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},kl=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Nn=class{constructor(e,t){this.language=e,this.expression=t}};Tl([S(),kl("design:type",er)],Nn.prototype,"language",void 0);Tl([S(),kl("design:type",String)],Nn.prototype,"expression",void 0);Nn=Tl([K(),kl("design:paramtypes",[er,String])],Nn);function PA(r){return r.language.address==="did"?r.expression.toString():`${r.language.address}://${r.expression}`}function NA(r){if(r.startsWith("literal:")){let a=new er;a.address="literal",a.name="literal";let o=r.substring(8);return new Nn(a,o)}let t=/^([^:^\s]+):\/\/([\s\S]+)$/.exec(r);if(t&&t.length==3){let a=t[1],o=t[2],s=new er;return s.address=a,new Nn(s,o)}let i=/^did:([^\s]+)$/.exec(r);if(i&&i.length==2){let a=new er;return a.address="did",new Nn(a,r)}throw new Error("Couldn't parse string as expression URL or DID: "+r)}var It=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},sr=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},zs=class{};It([S(),sr("design:type",String)],zs.prototype,"name",void 0);It([S(),sr("design:type",String)],zs.prototype,"type",void 0);zs=It([K()],zs);var oo=class{};It([S(),sr("design:type",String)],oo.prototype,"label",void 0);It([S(),sr("design:type",String)],oo.prototype,"name",void 0);It([S(),sr("design:type",Array)],oo.prototype,"parameters",void 0);oo=It([K()],oo);var Hs=class{get parameters(){return JSON.parse(this.parametersStringified)}constructor(e,t){this.name=e,this.parametersStringified=JSON.stringify(t)}};It([S(),sr("design:type",String)],Hs.prototype,"name",void 0);It([S(),sr("design:type",String)],Hs.prototype,"parametersStringified",void 0);Hs=It([ze(),sr("design:paramtypes",[String,Object])],Hs);var Ws=class{};It([S(),sr("design:type",String)],Ws.prototype,"did",void 0);It([S(),sr("design:type",Fn)],Ws.prototype,"status",void 0);Ws=It([K()],Ws);var Yn=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},zi=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},tn=class{};Yn([S(),zi("design:type",String)],tn.prototype,"name",void 0);Yn([S(),zi("design:type",String)],tn.prototype,"address",void 0);Yn([S(),zi("design:type",String)],tn.prototype,"settings",void 0);Yn([S(),zi("design:type",Ln)],tn.prototype,"icon",void 0);Yn([S(),zi("design:type",Ln)],tn.prototype,"constructorIcon",void 0);Yn([S(),zi("design:type",Ln)],tn.prototype,"settingsIcon",void 0);tn=Yn([K()],tn);var ct=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},yt=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Bt=class{};ct([S(),yt("design:type",String)],Bt.prototype,"name",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"address",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"description",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"author",void 0);ct([S(),yt("design:type",Boolean)],Bt.prototype,"templated",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"templateSourceLanguageAddress",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"templateAppliedParams",void 0);ct([S(),yt("design:type",Array)],Bt.prototype,"possibleTemplateParams",void 0);ct([S(),yt("design:type",String)],Bt.prototype,"sourceCodeLink",void 0);Bt=ct([K()],Bt);var $i=class{constructor(e,t){this.name=e,this.description=t,this.description||(this.description="")}};ct([S(),yt("design:type",String)],$i.prototype,"name",void 0);ct([S(),yt("design:type",String)],$i.prototype,"description",void 0);ct([S(),yt("design:type",Array)],$i.prototype,"possibleTemplateParams",void 0);ct([S(),yt("design:type",String)],$i.prototype,"sourceCodeLink",void 0);$i=ct([ze(),yt("design:paramtypes",[String,String])],$i);var Md=class{},Ud=class extends on(){},jd=class{},oc=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},Al=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Gs=class{constructor(e,t){this.linkLanguage=e,this.meta=t}};oc([S(),Al("design:type",String)],Gs.prototype,"linkLanguage",void 0);oc([S(),Al("design:type",ir)],Gs.prototype,"meta",void 0);Gs=oc([K(),Al("design:paramtypes",[String,ir])],Gs);var pl=class extends on(){};pl=oc([K()],pl);var Xn=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},ei=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},dl;(function(r){r.Private="PRIVATE",r.NeighboudhoodCreationInitiated="NEIGHBOURHOOD_CREATION_INITIATED",r.NeighbourhoodJoinInitiated="NEIGHBOURHOOD_JOIN_INITIATED",r.LinkLanguageFailedToInstall="LINK_LANGUAGE_FAILED_TO_INSTALL",r.LinkLanguageInstalledButNotSynced="LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",r.Synced="SYNCED"})(dl||(dl={}));var rn=class{constructor(e,t,n){this.uuid=e,this.name=t,n?this.state=n:this.state=dl.Private}};Xn([S(),ei("design:type",String)],rn.prototype,"uuid",void 0);Xn([S(),ei("design:type",String)],rn.prototype,"name",void 0);Xn([S(),ei("design:type",String)],rn.prototype,"state",void 0);Xn([S(),ei("design:type",String)],rn.prototype,"sharedUrl",void 0);Xn([S(),ei("design:type",pl)],rn.prototype,"neighbourhood",void 0);Xn([S(),ei("design:type",Array)],rn.prototype,"owners",void 0);rn=Xn([K(),ei("design:paramtypes",[String,String,String])],rn);var qd=class{constructor(e){this.proxies=new Map,this.activeSubscriptions=new Map,this.debounceTimers=new Map,this.seenMessages=new Map,this.perspectiveClient=e.perspectiveClient,this.logger=e.logger,this.debounceMs=e.debounceMs??2e3,this.onWake=e.onWake,this.onPersist=e.onPersist,this.QuerySubscriptionProxyCtor=e.QuerySubscriptionProxy??null,this.previousSeenMessages=e.previousSeenMessages??{}}async subscribe(e){if(this.dispose(e.id,!1),!this.QuerySubscriptionProxyCtor)throw new Error("WakerSubscriptionManager: QuerySubscriptionProxy must be provided via constructor options");let t=this.QuerySubscriptionProxyCtor;this.logger.info(`[waker] ${e.id}: creating subscription (perspective=${e.perspective}, type=${e.type})`),this.logger.info(`[waker] ${e.id}: SPARQL query:
|
|
1010
|
-
${e.query}`);let n=new t(e.perspective,e.query,this.perspectiveClient);n.isSPARQL=!0,n.initialized&&typeof n.initialized.catch=="function"&&n.initialized.catch(()=>{});try{await n.subscribe(),await n.initialized}catch(a){let o=a?.message??String(a);this.logger.warn(`[waker] ${e.id}: subscription failed \u2014 ${o}`);try{n.dispose()}catch{}this.activeSubscriptions.delete(e.id),this.seenMessages.delete(e.id),this.persist();return}this.logger.info(`[waker] ${e.id}: subscription initialized successfully`);let i=new Set(this.previousSeenMessages[e.id]??[]);this.seenMessages.set(e.id,i),i.size>0&&this.logger.info(`[waker] ${e.id}: seeded ${i.size} seen message(s) from persisted state`),n.onResult(async a=>{if(this.logger.info(`[waker] ${e.id}: onResult fired \u2014 type=${typeof a}, isArray=${Array.isArray(a)}, value=${String(JSON.stringify(a)).substring(0,500)}`),!Array.isArray(a)){this.logger.warn(`[waker] ${e.id}: ignoring non-array result: ${JSON.stringify(a)}`);return}if(e.type==="mention"){let o=this.seenMessages.get(e.id)??new Set,s=[];for(let l of a)l&&l.source&&!o.has(l.source)&&s.push(l.source);if(s.length===0){this.logger.info(`[waker] ${e.id}: all ${a.length} items already seen, skipping`);return}this.logger.info(`[waker] ${e.id}: ${s.length} new message(s) out of ${a.length} total`);let c=[];for(let l of s){let d=[];try{let p=`SELECT ?source WHERE { ?source <ad4m://has_child> <${l}> . }`;this.logger.info(`[waker] ${e.id}: resolving parents for ${l}`);let f=await this.perspectiveClient.querySparql(e.perspective,p);if(Array.isArray(f))for(let h of f)h&&h.source&&d.push(h.source)}catch(p){this.logger.warn(`[waker] ${e.id}: parent resolution failed for ${l} \u2014 ${p?.message??p}`)}this.logger.info(`[waker] ${e.id}: message ${l} has ${d.length} parent(s): ${d.join(", ")}`),c.push({address:l,parents:d})}for(let l of s)o.add(l);this.seenMessages.set(e.id,o);let u=this.debounceTimers.get(e.id);u&&clearTimeout(u),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a,c),this.debounceTimers.delete(e.id),this.persist()},this.debounceMs))}else{this.logger.info(`[waker] ${e.id}: channel update (${a.length} items)`);let o=this.debounceTimers.get(e.id);o&&clearTimeout(o),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a),this.debounceTimers.delete(e.id)},this.debounceMs))}}),this.proxies.set(e.id,n),this.activeSubscriptions.set(e.id,e),this.persist(),this.logger.info(`[waker] Subscription ${e.id} active (type=${e.type}, perspective=${e.perspective})`)}dispose(e,t=!0){let n=this.proxies.get(e);if(n){try{n.dispose()}catch{}this.proxies.delete(e)}let i=this.debounceTimers.get(e);i&&(clearTimeout(i),this.debounceTimers.delete(e)),this.activeSubscriptions.delete(e),this.seenMessages.delete(e),t&&this.persist()}disposeAll(){for(let[e]of this.proxies)this.dispose(e,!1)}getActive(){return Array.from(this.activeSubscriptions.values())}has(e){return this.activeSubscriptions.has(e)}persist(){if(this.onPersist){let e={};for(let[t,n]of this.seenMessages)e[t]=Array.from(n);this.onPersist(this.getActive(),e)}}},sc=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},im=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Ks=class{};sc([S(),im("design:type",Array)],Ks.prototype,"additions",void 0);sc([S(),im("design:type",Array)],Ks.prototype,"removals",void 0);Ks=sc([K()],Ks);var Bd=class extends on(){};Bd=sc([K()],Bd);var Vd=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ii=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},ja,An,fs="smart_literal://content";function RS(r){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length;for(let i=0;i<r;i++)e+=t.charAt(Math.floor(Math.random()*n));return e}var so=class{constructor(e,t){ja.set(this,void 0),An.set(this,void 0),Vd(this,ja,e,"f"),Vd(this,An,t,"f")}get base(){return Ii(this,An,"f")}static async create(e,t){let n=be.from(RS(10)).toUrl(),i=new so(e,n);return await i.set(t),i}static async isSmartLiteralBase(e,t){return(await e.get(new W({source:t,predicate:fs}))).length>0}static async getAllSmartLiterals(e){return(await e.get(new W({predicate:fs}))).map(n=>new so(e,n.data.source))}async get(){let e=await Ii(this,ja,"f").getSingleTarget(new W({source:Ii(this,An,"f"),predicate:fs}));if(!e)throw`No content for smart literal ${Ii(this,An,"f")}`;return be.fromUrl(e).get()}async set(e){let t=be.from(e);await Ii(this,ja,"f").setSingleTarget(new mt({source:Ii(this,An,"f"),predicate:fs,target:t.toUrl()}))}};ja=new WeakMap,An=new WeakMap;function Ai(r,e){if("predicate"in r)return r.predicate;let{model:t}=r,n=ht(t);if(r.field){let i=n[r.field];if(!i)throw new Error(`parent(): field "${r.field}" is not a registered relation on ${t.name}`);return i.predicate}for(let[,i]of Object.entries(n))if(i.target&&i.target()===e)return i.predicate;throw new Error(`parent(): could not resolve predicate \u2014 no relation on ${t.name} targets ${e.name||"the queried class"}`)}function Qd(r,e){return!r||!e?"":`triple("${r.id}", "${e}", Base)`}function zd(){return`
|
|
1011
|
-
findall(
|
|
1012
|
-
[T, A],
|
|
1013
|
-
link(Base, _, _, T, A),
|
|
1014
|
-
AllLinks
|
|
1015
|
-
),
|
|
1016
|
-
sort(AllLinks, SortedLinks),
|
|
1017
|
-
SortedLinks = [[Timestamp, Author]|_]
|
|
1018
|
-
`}function PS(r){return`
|
|
1019
|
-
findall([PropertyName, PropertyValue, Resolve], (
|
|
1020
|
-
% Constrain to specified properties if provided
|
|
1021
|
-
${r?`member(PropertyName, [${r.map(e=>`"${e}"`).join(", ")}]),`:""}
|
|
1022
|
-
resolve_property(SubjectClass, Base, PropertyName, PropertyValue, Resolve)
|
|
1023
|
-
), Properties)
|
|
1024
|
-
`}function Hd(r={}){function e(t){return typeof t=="string"?`"${t}"`:t}return Object.entries(r).map(([t,n])=>{let i=["id","author","timestamp"].includes(t),a=`resolve_property(SubjectClass, Base, "${t}", Value${t}, _)`,o=t==="id"?"Base":st(t);if(Array.isArray(n)){let s=n.map(c=>e(c)).join(", ");return i?`member(${o}, [${s}])`:`${a}, member(Value${t}, [${s}])`}if(typeof n=="object"&&n!==null){let{not:s,between:c,lt:u,lte:l,gt:d,gte:p}=n;if(s!==void 0)if(Array.isArray(s)){let h=s.map(m=>e(m)).join(", ");return i?`\\+ member(${o}, [${h}])`:`${a}, \\+ member(Value${t}, [${h}])`}else return i?`${o} \\= ${e(s)}`:`${a}, Value${t} \\= ${e(s)}`;if(c!==void 0&&Array.isArray(c)&&c.length===2)return i?`${o} >= ${c[0]}, ${o} =< ${c[1]}`:`${a}, Value${t} >= ${c[0]}, Value${t} =< ${c[1]}`;let f=[{value:u,symbol:"<"},{value:l,symbol:"=<"},{value:d,symbol:">"},{value:p,symbol:">="}];for(let{value:h,symbol:m}of f)if(h!==void 0)return i?`${o} ${m} ${h}`:`${a}, Value${t} ${m} ${h}`}return i?`${o} = ${e(n)}`:`${a}, Value${t} = ${e(n)}`}).join(", ")}function Wd(r){return r?"length(UnsortedInstances, TotalCount)":""}function Gd(r){if(!r)return"SortedInstances = UnsortedInstances";let e=Object.entries(r);if(e.length===1){let[n,i]=e[0];return`sort_instances(UnsortedInstances, "${n}", "${i}", SortedInstances)`}let t=[];for(let n=e.length-1;n>=0;n--){let[i,a]=e[n],o=n===e.length-1?"UnsortedInstances":`MultiSortIntermediate${n+1}`,s=n===0?"SortedInstances":`MultiSortIntermediate${n}`;t.push(`sort_instances(${o}, "${i}", "${a}", ${s})`)}return t.join(`,
|
|
1025
|
-
`)}function Kd(r){return!r||r<0?"InstancesWithOffset = SortedInstances":`skipN(SortedInstances, ${r}, InstancesWithOffset)`}function Jd(r){return!r||r<0?"AllInstances = InstancesWithOffset":`takeN(InstancesWithOffset, ${r}, AllInstances)`}function Zd(r){if(!r)return"";if(r.includes("://")){let[e,t]=r.split("://"),n=(t||"").replace(/\/+$/,"");return`${e}://${n}`}else return r.replace(/\/+$/,"")}function Ol(r){if(!!r){if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r.find(t=>t!=="null")||r[0]}}function am(r,e){return Ol(r.type)===e}function om(r){return am(r,"array")}function Yd(r){return am(r,"object")}function NS(r){let e=Ol(r.type);return e==="number"||e==="integer"}function sm(r,e){if(e.namespace)return e.namespace;if(r["x-ad4m"]?.namespace)return r["x-ad4m"].namespace;if(r.title)return`${r.title.toLowerCase()}://`;if(r.$id)try{let n=new URL(r.$id).pathname.split("/").filter(i=>i);if(n.length>0)return`${n[n.length-1].replace(/\.schema\.json$/,"").replace(/\.json$/,"").toLowerCase()}://`}catch{}throw new Error(`Cannot infer namespace for JSON Schema. Please provide one of:
|
|
63
|
+
`);if(!Array.isArray(l)||l.length===0)return null;let c=new Map;for(let d of l)if(d.predicate==="rdf://type"&&d.target==="ad4m://SubjectClass"){let g=d.shape,p=g.indexOf("://");if(p<0)continue;let u=g.substring(p+3).split("/").pop();if(!u)continue;c.set(u,{shapeUri:g,properties:[],relations:[]})}for(let d of l)if(d.predicate==="sh://property"||d.predicate==="sh://collection"){for(let[g,p]of c)if(d.shape.endsWith(`${g}Shape`)){let u=d.target.lastIndexOf(".");if(u<0)continue;let f=d.target.substring(u+1);d.predicate==="sh://property"?p.properties.push(f):p.relations.push(f)}}for(let[d,g]of c){let p=e.every(f=>g.properties.includes(f)),u=n.every(f=>g.relations.includes(f));if(p&&u)return d}return null}async subjectClassesByTemplate(t){try{let e=t.className||t.constructor?.className||t.constructor?.prototype?.className;if(e&&(await this.subjectClasses()).includes(e))return[e]}catch(e){console.warn("subjectClassesByTemplate: className lookup failed:",e)}try{let e=await this.findClassByProperties(t);if(e)return[e]}catch(e){console.warn("subjectClassesByTemplate: property matching failed:",e)}return[]}async ensureSDNASubjectClass(t){return this.ensureSubjectClass(t)}async ensureSubjectClass(t){let e=t.className||t.prototype?.className||t.name;if(m(this,Bt,"f").has(e))return;if(!t.generateSHACL)throw new Error(`Class ${t.name} must have generateSHACL(). Use @Model decorator.`);let{shape:n}=t.generateSHACL(),r=JSON.stringify(n.toJSON());await this.addSdna(e,"","subject_class",r),m(this,Bt,"f").add(e)}clearEnsuredSubjectClasses(){m(this,Bt,"f").clear()}async listRegisteredClasses(){let t=await this.querySparql("SELECT DISTINCT ?class WHERE { ?class <rdf://type> <ad4m://SubjectClass> . }");return Array.isArray(t)?t.map(e=>{let n=e.class||"",r=n.lastIndexOf("#");if(r>=0)return n.substring(r+1);let s=n.lastIndexOf("/");return s>=0?n.substring(s+1):n}).filter(Boolean):[]}async getClassShape(t){let e=t.replace(/['"\\]/g,""),n=await this.querySparql(`SELECT ?shapeUri ?targetClass WHERE {
|
|
64
|
+
?targetClass <rdf://type> <ad4m://SubjectClass> .
|
|
65
|
+
?targetClass <ad4m://shape> ?shapeUri .
|
|
66
|
+
FILTER(STRENDS(STR(?targetClass), "/${e}") || STRENDS(STR(?targetClass), "#${e}"))
|
|
67
|
+
} LIMIT 1`);if(!Array.isArray(n)||n.length===0)return null;let r=n[0].shapeUri;n[0].targetClass;let s=await this.querySparql(`SELECT ?propShape ?path ?datatype ?minCount ?maxCount ?writable ?propType ?shIn WHERE {
|
|
68
|
+
<${r}> <sh://property> ?propShape .
|
|
69
|
+
?propShape <sh://path> ?path .
|
|
70
|
+
?propShape <rdf://type> ?propType .
|
|
71
|
+
OPTIONAL { ?propShape <sh://datatype> ?datatype }
|
|
72
|
+
OPTIONAL { ?propShape <sh://minCount> ?minCount }
|
|
73
|
+
OPTIONAL { ?propShape <sh://maxCount> ?maxCount }
|
|
74
|
+
OPTIONAL { ?propShape <ad4m://writable> ?writable }
|
|
75
|
+
OPTIONAL { ?propShape <sh://in> ?shIn }
|
|
76
|
+
}`),a=(Array.isArray(s)?s:[]).map(o=>{let l=o.propShape||"",c=l.lastIndexOf("."),d=c>=0?l.substring(c+1):l,g=parseInt(o.minCount||"0",10),p=o.propType==="ad4m://CollectionShape",u=o.writable==="true"||o.writable==="literal:true",f;if(o.shIn)try{let h=o.shIn;h.startsWith("literal:string:")&&(h=decodeURIComponent(h.substring(15))),f=JSON.parse(h)}catch{}return{name:d,predicate:o.path||"",datatype:o.datatype||void 0,required:g>0,collection:p,writable:u,...f&&f.length>0?{options:f}:{}}});return{className:e,shapeUri:r,properties:a}}async getInstanceClasses(t){let e=t.replace(/['"\\]/g,""),n=await this.querySparql(`SELECT DISTINCT ?class WHERE {
|
|
77
|
+
?class <rdf://type> <ad4m://SubjectClass> .
|
|
78
|
+
?class <ad4m://shape> ?shape .
|
|
79
|
+
?shape <sh://property> ?propShape .
|
|
80
|
+
?propShape <sh://minCount> ?mc .
|
|
81
|
+
FILTER(?mc >= 1)
|
|
82
|
+
?propShape <sh://path> ?path .
|
|
83
|
+
<${e}> ?path ?_val .
|
|
84
|
+
}`);return Array.isArray(n)?n.map(r=>{let s=r.class||"",a=s.lastIndexOf("#");if(a>=0)return s.substring(a+1);let o=s.lastIndexOf("/");return o>=0?s.substring(o+1):s}).filter(Boolean):[]}async getNamedOptions(t){let e=await this.getClassShape(t);if(!e)return{};let n={};for(let r of e.properties)r.options&&r.options.length>0&&(n[r.name]=r.options);return n}async addNamedOption(t,e,n,r){let s=await this.getClassShape(t);if(!s)throw new Error(`Class "${t}" not found`);let a=s.properties.find(p=>p.name===e);if(!a)throw new Error(`Property "${e}" not found on class "${t}"`);let l=`${$a(s.shapeUri)}${t}.${e}`,c=a.options||[];if(c.some(p=>p.value===n))return;let d=[...c,{value:n,...r?{label:r}:{}}],g=await this.get(new Z({source:l,predicate:"sh://in"}));for(let p of g)await this.remove(p);await this.add(new me({source:l,predicate:"sh://in",target:`literal:string:${JSON.stringify(d)}`}))}getNeighbourhoodProxy(){return m(this,U,"f").getNeighbourhoodProxy(m(this,L,"f").uuid)}get ai(){return m(this,U,"f").aiClient}async subscribeInfer(t){let e=new Xi(this.uuid,t,m(this,U,"f"));return await e.subscribe(),await e.initialized,e}async subscribeQuery(t){let e=new Xi(this.uuid,t,m(this,U,"f"));return await e.subscribe(),await e.initialized,e}};L=new WeakMap,U=new WeakMap,it=new WeakMap,nt=new WeakMap,rt=new WeakMap,Ht=new WeakMap,Bt=new WeakMap;var pe=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},A=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},I,Zt,Jt,Qt,Wi,qt,Hi,Bi,st,Oe,At;function Tr(i,t){let e=i,n=!1;if(typeof e=="string"&&e.startsWith("#init#")&&(e=e.substring(6),n=!0),typeof e=="string")try{e=JSON.parse(e)}catch(r){console.error(t,r)}return n&&typeof e=="object"&&e!==null&&(e.isInit=!0),{result:e,isInit:n}}var Yi=class{constructor(t,e,n=!0,r){I.set(this,void 0),Zt.set(this,void 0),Jt.set(this,void 0),Qt.set(this,void 0),Wi.set(this,void 0),qt.set(this,void 0),Hi.set(this,void 0),Bi.set(this,void 0),st.set(this,void 0),Oe.set(this,void 0),At.set(this,void 0),pe(this,I,r||new Ae(t,e),"f"),pe(this,Zt,[],"f"),pe(this,Jt,[],"f"),pe(this,Qt,[],"f"),pe(this,Wi,[],"f"),pe(this,st,[],"f"),pe(this,Oe,new Map,"f"),pe(this,At,new Map,"f"),n&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}setExpressionClient(t){pe(this,qt,t,"f")}setNeighbourhoodClient(t){pe(this,Hi,t,"f")}setAIClient(t){pe(this,Bi,t,"f")}get aiClient(){return A(this,Bi,"f")}async all(){return(await A(this,I,"f").call("perspective.all")).map(e=>new Tt(e,this))}async byUUID(t){try{let e=await A(this,I,"f").call("perspective.get",{uuid:t});return e?new Tt(e,this):null}catch(e){if(e instanceof We&&e.status===404)return null;throw e}}async snapshotByUUID(t){return A(this,I,"f").call("perspective.snapshot",{uuid:t})}async publishSnapshotByUUID(t){return A(this,I,"f").call("perspective.publishSnapshot",{uuid:t})}async queryLinks(t,e){let n={uuid:t};return e.source&&(n.source=e.source),e.predicate&&(n.predicate=e.predicate),e.target&&(n.target=e.target),e.fromDate&&(n.fromDate=e.fromDate instanceof Date?e.fromDate.toISOString():String(e.fromDate)),e.untilDate&&(n.untilDate=e.untilDate instanceof Date?e.untilDate.toISOString():String(e.untilDate)),e.limit!==void 0&&(n.limit=e.limit),A(this,I,"f").call("perspective.queryLinks",n)}async queryProlog(t,e){let n=await A(this,I,"f").call("perspective.queryProlog",{uuid:t,query:e});return JSON.parse(n)}async querySparql(t,e){let n=await A(this,I,"f").call("perspective.querySparql",{uuid:t,engine:"sparql",query:e});return JSON.parse(n)}async subscribeQuery(t,e){let n=await A(this,I,"f").call("perspective.subscribeQuery",{uuid:t,query:e}),{subscriptionId:r,result:s}=n,a=Tr(s,"Error parsing subscribeQuery result:");return{subscriptionId:r,result:a.result,isInit:a.isInit}}async perspectiveKeepAliveQuery(t,e){return A(this,I,"f").call("perspective.keepAliveQuery",{uuid:t,subscriptionId:e})}async perspectiveDisposeQuerySubscription(t,e){return A(this,I,"f").call("perspective.disposeQuery",{uuid:t,subscriptionId:e})}subscribeToQueryUpdates(t,e){let n=A(this,I,"f").subscribe(r=>{let s=r;if(s.type!=="query-subscription-update"||(s.subscriptionId||s.subscription_id)!==t)return;let o=Tr(s.result,"Error parsing query subscription:");e(o.result)});return A(this,At,"f").set(t,n),n}async keepAliveQuery(t,e){return A(this,I,"f").call("perspective.keepAliveQuery",{uuid:t,subscriptionId:e})}async disposeQuerySubscription(t,e){let n=A(this,At,"f").get(e);return n&&(n(),A(this,At,"f").delete(e)),A(this,I,"f").call("perspective.disposeQuery",{uuid:t,subscriptionId:e})}async modelQuery(t,e,n,r){let s=await A(this,I,"f").call("perspective.modelQuery",{uuid:t,class_name:e,query_json:n,shape_json:r});return JSON.parse(s)}async modelSubscribe(t,e,n,r){let s=await A(this,I,"f").call("perspective.modelSubscribe",{uuid:t,class_name:e,query_json:n,shape_json:r});return{subscriptionId:s.subscription_id,result:JSON.parse(s.result)}}async add(t){let e=await A(this,I,"f").call("perspective.create",{name:t});return new Tt(e,this)}async update(t,e){let n=await A(this,I,"f").call("perspective.update",{uuid:t,name:e});return new Tt(n,this)}async remove(t){return{perspectiveRemove:await A(this,I,"f").call("perspective.remove",{uuid:t})}}async addLink(t,e,n="shared",r){return A(this,I,"f").call("perspective.addLink",{uuid:t,link:e,status:n,batchId:r})}async addLinks(t,e,n="shared",r){return A(this,I,"f").call("perspective.addLinks",{uuid:t,links:e,status:n,batchId:r})}async removeLinks(t,e,n){return A(this,I,"f").call("perspective.removeLinks",{uuid:t,links:e,batchId:n})}async linkMutations(t,e,n){return A(this,I,"f").call("perspective.linkMutations",{uuid:t,mutations:e,status:n})}async addLinkExpression(t,e,n="shared",r){return A(this,I,"f").call("perspective.addLinkExpression",{uuid:t,link:e,status:n,batchId:r})}async updateLink(t,e,n,r){return A(this,I,"f").call("perspective.updateLink",{uuid:t,oldLink:e,newLink:n,batchId:r})}async removeLink(t,e,n){return delete e.__typename,delete e.data.__typename,delete e.proof.__typename,delete e.status,A(this,I,"f").call("perspective.removeLink",{uuid:t,link:e,batchId:n})}async addSdna(t,e,n,r,s){return A(this,I,"f").call("perspective.addSdna",{uuid:t,name:e,sdnaCode:n||"",sdnaType:r,shaclJson:s})}async executeCommands(t,e,n,r,s){return A(this,I,"f").call("perspective.executeCommands",{uuid:t,commands:e,expression:n,parameters:r,batchId:s})}async createSubject(t,e,n,r,s){return A(this,I,"f").call("perspective.createSubject",{uuid:t,subjectClass:e,expressionAddress:n,initialValues:r,batchId:s})}async getSubjectData(t,e,n){return A(this,I,"f").call("perspective.getSubjectData",{uuid:t,subjectClass:e,expressionAddress:n})}async getExpression(t){return await A(this,qt,"f").get(t)}async createExpression(t,e){return await A(this,qt,"f").create(t,e)}addPerspectiveAddedListener(t){A(this,Zt,"f").push(t)}subscribePerspectiveAdded(){let t=A(this,I,"f").subscribe(e=>{e.type==="perspective-added"&&A(this,Zt,"f").forEach(n=>n(e.perspective))});A(this,st,"f").push(t)}addPerspectiveUpdatedListener(t){A(this,Jt,"f").push(t)}subscribePerspectiveUpdated(){let t=A(this,I,"f").subscribe(e=>{e.type==="perspective-updated"&&A(this,Jt,"f").forEach(n=>n(e.perspective))});A(this,st,"f").push(t)}addPerspectiveSyncedListener(t){A(this,Wi,"f").push(t)}async addPerspectiveSyncStateChangeListener(t,e){let n=A(this,I,"f").subscribe(r=>{r.type==="sync-state-change"&&r.uuid===t&&e.forEach(s=>s(r.state))});A(this,st,"f").push(n),await new Promise(r=>setTimeout(r,500))}addPerspectiveRemovedListener(t){A(this,Qt,"f").push(t)}subscribePerspectiveRemoved(){let t=A(this,I,"f").subscribe(e=>{e.type==="perspective-removed"&&A(this,Qt,"f").forEach(n=>n(e.uuid))});A(this,st,"f").push(t)}async addPerspectiveLinkAddedListener(t,e){let n=A(this,I,"f").subscribe(s=>{s.type==="link-added"&&s.perspectiveUuid===t&&e.forEach(a=>a(s.link))}),r=A(this,Oe,"f").get(t)||[];r.push(n),A(this,Oe,"f").set(t,r),await A(this,I,"f").waitForSubscription()}async addPerspectiveLinkRemovedListener(t,e){let n=A(this,I,"f").subscribe(s=>{if(s.type==="link-removed"&&s.perspectiveUuid===t){let a=s.link;a.status||delete a.status,e.forEach(o=>o(a))}}),r=A(this,Oe,"f").get(t)||[];r.push(n),A(this,Oe,"f").set(t,r),await A(this,I,"f").waitForSubscription()}async addPerspectiveLinkUpdatedListener(t,e){let n=A(this,I,"f").subscribe(s=>{if(s.type==="link-updated"&&s.perspectiveUuid===t){let a=s.newLink,o=s.oldLink;a.status||delete a.status,o.status||delete o.status,e.forEach(l=>l(s))}}),r=A(this,Oe,"f").get(t)||[];r.push(n),A(this,Oe,"f").set(t,r),await A(this,I,"f").waitForSubscription()}getNeighbourhoodProxy(t){return new Tn(A(this,Hi,"f"),t)}async createBatch(t){return A(this,I,"f").call("perspective.createBatch",{uuid:t})}async commitBatch(t,e){return A(this,I,"f").call("perspective.commitBatch",{uuid:t,batchId:e})}};I=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Wi=new WeakMap,qt=new WeakMap,Hi=new WeakMap,Bi=new WeakMap,st=new WeakMap,Oe=new WeakMap,At=new WeakMap;var Ee=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},$=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},M,Zi,Ji,Gt,Kt,Vt,Xt,Yt,ze,On=class{constructor(t,e,n=!0,r){M.set(this,void 0),Zi.set(this,void 0),Ji.set(this,void 0),Gt.set(this,void 0),Kt.set(this,void 0),Vt.set(this,void 0),Xt.set(this,void 0),Yt.set(this,void 0),ze.set(this,void 0),Ee(this,Zi,t,"f"),Ee(this,Ji,e,"f"),Ee(this,M,r||new Ae(t,e),"f"),Ee(this,Kt,[],"f"),Ee(this,Vt,[],"f"),Ee(this,Gt,[],"f"),Ee(this,Xt,[],"f"),Ee(this,Yt,[],"f"),Ee(this,ze,[],"f"),n&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let t=await $(this,M,"f").call("agent.get"),e=new ui(t.did,t.perspective);return e.directMessageLanguage=t.directMessageLanguage,e}async status(){let t=await $(this,M,"f").call("agent.status");return new lt(t)}async generate(t){let e=await $(this,M,"f").call("agent.generate",{passphrase:t});return new lt(e)}async import(t){let e=await $(this,M,"f").call("agent.import",{...t});return new lt(e)}async lock(t){let e=await $(this,M,"f").call("agent.lock",{passphrase:t});return new lt(e)}async unlock(t,e=!0){let n=await $(this,M,"f").call("agent.unlock",{passphrase:t,holochain:e});return new lt(n)}async byDID(t){return $(this,M,"f").call("agent.byDid",{did:t})}async updatePublicPerspective(t){let e=JSON.parse(JSON.stringify(t));delete e.__typename,e.links.forEach(s=>{delete s.__typename,delete s.data.__typename,delete s.proof.__typename,delete s.status});let n=await $(this,M,"f").call("agent.updateProfile",{publicPerspective:e}),r=new ui(n.did,n.perspective);return r.directMessageLanguage=n.directMessageLanguage,r}async mutatePublicPerspective(t){let e=new Yi($(this,Zi,"f"),$(this,Ji,"f")),n=await e.add("Agent Perspective Proxy"),r=await this.me();r.perspective&&await n.loadSnapshot(r.perspective);for(let o of t.additions)await n.add(o);for(let o of t.removals)await n.remove(o);let s=await n.snapshot(),a=await this.updatePublicPerspective(s);return await e.remove(n.uuid),a}async updateDirectMessageLanguage(t){let e=await $(this,M,"f").call("agent.updateProfile",{dmLanguage:t}),n=new ui(e.did,e.perspective);return n.directMessageLanguage=e.directMessageLanguage,n}async addEntanglementProofs(t){return $(this,M,"f").call("agent.addEntanglementProofs",{proofs:t})}async deleteEntanglementProofs(t){return $(this,M,"f").call("agent.deleteEntanglementProofs",{proofs:t})}async getEntanglementProofs(){return $(this,M,"f").call("agent.getEntanglementProofs")}async entanglementProofPreFlight(t,e){return $(this,M,"f").call("agent.entanglementProofPreflight",{deviceKey:t,deviceKeyType:e})}addUpdatedListener(t){$(this,Kt,"f").push(t)}addAppChangedListener(t){$(this,Gt,"f").push(t)}subscribeAgentUpdated(){let t=$(this,M,"f").subscribe(e=>{e.type==="agent-updated"&&$(this,Kt,"f").forEach(n=>n(e.agent||e))});$(this,ze,"f").push(t)}subscribeAppsChanged(){let t=$(this,M,"f").subscribe(e=>{e.type==="apps-changed"&&$(this,Gt,"f").forEach(n=>n())});$(this,ze,"f").push(t)}addAgentStatusChangedListener(t){$(this,Vt,"f").push(t)}subscribeAgentStatusChanged(){let t=$(this,M,"f").subscribe(e=>{e.type==="agent-status-changed"&&$(this,Vt,"f").forEach(n=>n(e.agent||e))});$(this,ze,"f").push(t)}addHostingUserInfoChangedListener(t){$(this,Xt,"f").push(t)}subscribeHostingUserInfoChanged(){let t=$(this,M,"f").subscribe(e=>{e.type==="hosting-user-info-changed"&&$(this,Xt,"f").forEach(n=>n(e.info||e))});$(this,ze,"f").push(t)}addComputeLogUpdatedListener(t){$(this,Yt,"f").push(t)}subscribeComputeLogUpdated(){let t=$(this,M,"f").subscribe(e=>{e.type==="compute-log-updated"&&$(this,Yt,"f").forEach(n=>n(e.entry||e))});$(this,ze,"f").push(t)}async requestCapability(t){return $(this,M,"f").call("agent.requestCapability",{authInfo:t})}async permitCapability(t){return $(this,M,"f").call("agent.permitCapability",{auth:t})}async generateJwt(t,e){return $(this,M,"f").call("agent.generateJwt",{requestId:t,rand:e})}async getApps(){return $(this,M,"f").call("agent.getApps")}async removeApp(t){return $(this,M,"f").call("agent.removeApp",{id:t})}async revokeToken(t){return $(this,M,"f").call("agent.revokeToken",{token:t})}async isLocked(){return $(this,M,"f").call("agent.isLocked")}async signMessage(t){return $(this,M,"f").call("agent.sign",{message:t})}async createUser(t,e,n){return $(this,M,"f").call("user.create",{email:t,password:e,appInfo:n})}async loginUser(t,e){return $(this,M,"f").call("user.login",{email:t,password:e})}async requestLoginVerification(t,e){return $(this,M,"f").call("user.requestVerification",{email:t,appInfo:e})}async verifyEmailCode(t,e,n){return $(this,M,"f").call("user.verifyEmail",{email:t,code:e,verificationType:n})}async hostingUserInfo(){let t=await $(this,M,"f").call("hosting.info"),e=t?.userInfo||t;return new En(e.email||"",e.freeAccess?"unlimited":String(e.credits??e.remainingCredits??"0"),e.hotWalletAddress||void 0,!!e.freeAccess)}async computeLog(t,e,n){return $(this,M,"f").call("runtime.computeLog",{since:t,limit:e,userEmail:n})}async setHotWalletAddress(t){return $(this,M,"f").call("hosting.setHotWallet",{address:t})}async requestPayment(t){return $(this,M,"f").call("hosting.requestPayment",{amountHOT:t})}};M=new WeakMap,Zi=new WeakMap,Ji=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Vt=new WeakMap,Xt=new WeakMap,Yt=new WeakMap,ze=new WeakMap;var La=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},Te=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},de,Pn=class{constructor(t,e,n){de.set(this,void 0),La(this,de,n||new Ae(t,e),"f")}async byAddress(t){return Te(this,de,"f").call("language.get",{address:t})}async byFilter(t){return Te(this,de,"f").call("language.all",{filter:t})}async all(){return Te(this,de,"f").call("language.all")}async writeSettings(t,e){return Te(this,de,"f").call("language.writeSettings",{address:t,settings:e})}async applyTemplateAndPublish(t,e){return Te(this,de,"f").call("language.applyTemplate",{sourceLanguageHash:t,templateData:e})}async publish(t,e){return Te(this,de,"f").call("language.publish",{languagePath:t,languageMeta:e})}async meta(t){return Te(this,de,"f").call("language.meta",{address:t})}async source(t){return Te(this,de,"f").call("language.source",{address:t})}async remove(t){return Te(this,de,"f").call("language.remove",{address:t})}};de=new WeakMap;var Oa=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},K=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},ee,at,ei,Rn=class{constructor(t,e,n){ee.set(this,void 0),at.set(this,new Map),ei.set(this,new Map),Oa(this,ee,n||new Ae(t,e),"f")}async publishFromPerspective(t,e,n){return K(this,ee,"f").call("neighbourhood.publish",{perspectiveUUID:t,linkLanguage:e,meta:n})}async joinFromUrl(t){return K(this,ee,"f").call("neighbourhood.join",{url:t})}async otherAgents(t){return K(this,ee,"f").call("neighbourhood.otherAgents",{uuid:t})}async hasTelepresenceAdapter(t){return K(this,ee,"f").call("neighbourhood.hasTelepresence",{uuid:t})}async onlineAgents(t){return K(this,ee,"f").call("neighbourhood.onlineAgents",{uuid:t})}async setOnlineStatus(t,e){return K(this,ee,"f").call("neighbourhood.setOnlineStatus",{uuid:t,status:e})}async setOnlineStatusU(t,e){return K(this,ee,"f").call("neighbourhood.setOnlineStatus",{uuid:t,status:e,signed:!1})}async sendSignal(t,e,n){return K(this,ee,"f").call("neighbourhood.sendSignal",{uuid:t,remoteAgentDid:e,payload:n})}async sendSignalU(t,e,n){return K(this,ee,"f").call("neighbourhood.sendSignal",{uuid:t,remoteAgentDid:e,payload:n,signed:!1})}async sendBroadcast(t,e,n=!1){return K(this,ee,"f").call("neighbourhood.sendBroadcast",{uuid:t,payload:e,loopback:n})}async sendBroadcastU(t,e,n=!1){return K(this,ee,"f").call("neighbourhood.sendBroadcast",{uuid:t,payload:e,loopback:n,signed:!1})}dispatchSignal(t,e){let n=K(this,at,"f").get(t);if(n)for(let r of n)try{r(e)}catch(s){console.error("Error in signal handler:",s)}}async subscribeToSignals(t){let e=K(this,ee,"f").subscribe(n=>{n.type==="signal"&&this.dispatchSignal(t,n.signal)});K(this,ei,"f").set(t,e)}async addSignalHandler(t,e){let n=K(this,at,"f").get(t);n?n.push(e):(n=[],K(this,at,"f").set(t,n),n.push(e),await this.subscribeToSignals(t))}removeSignalHandler(t,e){let n=K(this,at,"f").get(t);if(n){let r=n.indexOf(e);if(r>-1&&n.splice(r,1),n.length===0){K(this,at,"f").delete(t);let s=K(this,ei,"f").get(t);s&&(s(),K(this,ei,"f").delete(t))}}}};ee=new WeakMap,at=new WeakMap,ei=new WeakMap;var vt=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},k=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},E,ti,ii,ni,In,Et;function Pa(i){return typeof i!="string"||i===i.toUpperCase()?i:i.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toUpperCase()}var Nn=class{constructor(t,e,n=!0,r){E.set(this,void 0),ti.set(this,void 0),ii.set(this,void 0),ni.set(this,void 0),In.set(this,void 0),Et.set(this,void 0),vt(this,E,r||new Ae(t,e),"f"),vt(this,ti,[],"f"),vt(this,ii,[],"f"),vt(this,ni,[],"f"),vt(this,In,[],"f"),vt(this,Et,[],"f"),n&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){return k(this,E,"f").call("runtime.info")}async tlsDomain(){return k(this,E,"f").call("runtime.tlsDomain")}async quit(){return k(this,E,"f").call("runtime.quit")}async openLink(t){return k(this,E,"f").call("runtime.openLink",{url:t})}async addTrustedAgents(t){return k(this,E,"f").call("agent.addTrustedAgents",{agents:t})}async deleteTrustedAgents(t){return k(this,E,"f").call("agent.deleteTrustedAgents",{agents:t})}async getTrustedAgents(){return k(this,E,"f").call("agent.getTrustedAgents")}async addKnownLinkLanguageTemplates(t){return k(this,E,"f").call("runtime.addLinkLanguageTemplates",{addresses:t})}async removeKnownLinkLanguageTemplates(t){return k(this,E,"f").call("runtime.removeLinkLanguageTemplates",{addresses:t})}async knownLinkLanguageTemplates(){return k(this,E,"f").call("runtime.linkLanguageTemplates")}async addFriends(t){return k(this,E,"f").call("runtime.addFriends",{dids:t})}async removeFriends(t){return k(this,E,"f").call("runtime.removeFriends",{dids:t})}async friends(){return k(this,E,"f").call("runtime.friends")}async hcAgentInfos(){return k(this,E,"f").call("runtime.hcAgentInfos")}async getNetworkMetrics(){return k(this,E,"f").call("runtime.networkMetrics")}async restartHolochain(){return k(this,E,"f").call("runtime.restartHolochain")}async hcAddAgentInfos(t){return k(this,E,"f").call("runtime.addHcAgentInfos",{agentInfos:t})}async verifyStringSignedByDid(t,e,n,r){return k(this,E,"f").call("runtime.verifySignature",{did:t,didSigningKeyId:e,data:n,signedData:r})}async setStatus(t){return k(this,E,"f").call("runtime.setStatus",{status:t})}async friendStatus(t){return k(this,E,"f").call("runtime.friendStatus",{did:t})}async friendSendMessage(t,e){return k(this,E,"f").call("runtime.sendFriendMessage",{did:t,message:e})}async messageInbox(t){return k(this,E,"f").call("runtime.inbox",{filter:t})}async messageOutbox(t){return k(this,E,"f").call("runtime.outbox",{filter:t})}async requestInstallNotification(t){return k(this,E,"f").call("runtime.createNotification",{...t})}async grantNotification(t){return k(this,E,"f").call("runtime.grantNotification",{id:t,granted:!0})}async exportDb(t){return k(this,E,"f").call("runtime.exportData",{type:"db",filePath:t})}async importDb(t){return k(this,E,"f").call("runtime.importData",{type:"db",filePath:t})}async notifications(){return k(this,E,"f").call("runtime.notifications")}async updateNotification(t,e){return k(this,E,"f").call("runtime.updateNotification",{...e,id:t})}async removeNotification(t){return k(this,E,"f").call("runtime.deleteNotification",{id:t})}async exportPerspective(t,e){return k(this,E,"f").call("runtime.exportData",{type:"perspective",perspectiveUuid:t,filePath:e})}async importPerspective(t){return k(this,E,"f").call("runtime.importData",{type:"perspective",filePath:t})}async multiUserEnabled(){return k(this,E,"f").call("user.multiUserEnabled")}async setMultiUserEnabled(t){return k(this,E,"f").call("user.setMultiUserEnabled",{enabled:t})}async freeHostingEnabled(){return k(this,E,"f").call("runtime.freeHostingEnabled")}async setFreeHostingEnabled(t){return k(this,E,"f").call("runtime.setFreeHostingEnabled",{enabled:t})}async listUsers(){return k(this,E,"f").call("user.list")}async userWalletAddress(t){return k(this,E,"f").call("user.wallet",{email:t})}async emailTestModeEnable(){return k(this,E,"f").call("user.emailTest",{action:"enable"})}async emailTestModeDisable(){return k(this,E,"f").call("user.emailTest",{action:"disable"})}async emailTestGetCode(t){return k(this,E,"f").call("user.emailTest",{action:"get-code",email:t})}async emailTestClearCodes(){return k(this,E,"f").call("user.emailTest",{action:"clear-codes"})}async emailTestSetExpiry(t,e,n){return k(this,E,"f").call("user.emailTest",{action:"set-expiry",email:t,verificationType:e,expiresAt:n})}async unytAgentKey(){return k(this,E,"f").call("runtime.unytAgentKey")}async unytHotAgentPubkey(){return k(this,E,"f").call("runtime.unytHotAgentPubkey")}async unytWalletBalance(){return k(this,E,"f").call("runtime.unytWalletBalance")}async unytWalletHistory(t,e){return k(this,E,"f").call("runtime.unytWalletHistory",{page:t,perPage:e})}async unytVersionInfo(){return k(this,E,"f").call("runtime.unytVersionInfo")}async unytSetMembraneProof(t){return k(this,E,"f").call("runtime.unytSetMembraneProof",{proof:t})}async unytReinstallDna(){return k(this,E,"f").call("runtime.unytReinstallDna")}async unytSendHot(t,e){return k(this,E,"f").call("runtime.unytSendHot",{recipient:t,amount:e})}async setUserCredits(t,e){return k(this,E,"f").call("user.credits",{email:t,amount:e})}async setUserFreeAccess(t,e){return k(this,E,"f").call("user.freeAccess",{email:t,enabled:e})}async setHostRates(t){return k(this,E,"f").call("runtime.setHostRates",{ratesJson:t})}async getHostRates(){let t=await k(this,E,"f").call("runtime.getHostRates");try{return JSON.parse(t)}catch{return[]}}addNotificationTriggeredCallback(t){k(this,ni,"f").push(t)}subscribeNotificationTriggered(){let t=k(this,E,"f").subscribe(e=>{e.type==="notification-triggered"&&k(this,ni,"f").forEach(n=>n(e.notification))});k(this,Et,"f").push(t)}addMessageCallback(t){k(this,ti,"f").push(t)}subscribeMessageReceived(){let t=k(this,E,"f").subscribe(e=>{e.type==="message-received"&&k(this,ti,"f").forEach(n=>n(e.message))});k(this,Et,"f").push(t)}addExceptionCallback(t){k(this,ii,"f").push(t)}subscribeExceptionOccurred(){let t=k(this,E,"f").subscribe(e=>{if(e.type==="exception-occurred"&&e.exception){let n=e.exception,r={...n,type:Pa(n.type)};k(this,ii,"f").forEach(s=>s(r))}});k(this,Et,"f").push(t)}};E=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,In=new WeakMap,Et=new WeakMap;var Ra=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},St=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},Pe,Mn=class{constructor(t,e,n){Pe.set(this,void 0),Ra(this,Pe,n||new Ae(t,e),"f")}async get(t,e=!1){if(!e)try{let n=J.fromUrl(t).get();if(typeof n=="object"&&n!==null&&"author"in n&&"timestamp"in n&&"data"in n&&"proof"in n)return n}catch{}return St(this,Pe,"f").call("expression.get",{url:t})}async getMany(t){return St(this,Pe,"f").call("expression.getMany",{urls:t})}async getRaw(t){return St(this,Pe,"f").call("expression.get",{url:t,raw:!0})}async create(t,e){let n=JSON.stringify(t);return St(this,Pe,"f").call("expression.create",{content:n,languageAddress:e})}async interactions(t){return St(this,Pe,"f").call("expression.interactions",{url:t})}async interact(t,e){return St(this,Pe,"f").call("expression.interact",{url:t,interactionCall:e})}};Pe=new WeakMap;var sn={};sn.byteLength=Na;sn.toByteArray=Ua;sn.fromByteArray=Fa;var Se=[],ue=[],Ia=typeof Uint8Array<"u"?Uint8Array:Array,un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Xe=0,$r=un.length;Xe<$r;++Xe)Se[Xe]=un[Xe],ue[un.charCodeAt(Xe)]=Xe;var Xe,$r;ue["-".charCodeAt(0)]=62;ue["_".charCodeAt(0)]=63;function Ts(i){var t=i.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=i.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Na(i){var t=Ts(i),e=t[0],n=t[1];return(e+n)*3/4-n}function Ma(i,t,e){return(t+e)*3/4-e}function Ua(i){var t,e=Ts(i),n=e[0],r=e[1],s=new Ia(Ma(i,n,r)),a=0,o=r>0?n-4:n,l;for(l=0;l<o;l+=4)t=ue[i.charCodeAt(l)]<<18|ue[i.charCodeAt(l+1)]<<12|ue[i.charCodeAt(l+2)]<<6|ue[i.charCodeAt(l+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=t&255;return r===2&&(t=ue[i.charCodeAt(l)]<<2|ue[i.charCodeAt(l+1)]>>4,s[a++]=t&255),r===1&&(t=ue[i.charCodeAt(l)]<<10|ue[i.charCodeAt(l+1)]<<4|ue[i.charCodeAt(l+2)]>>2,s[a++]=t>>8&255,s[a++]=t&255),s}function Da(i){return Se[i>>18&63]+Se[i>>12&63]+Se[i>>6&63]+Se[i&63]}function ja(i,t,e){for(var n,r=[],s=t;s<e;s+=3)n=(i[s]<<16&16711680)+(i[s+1]<<8&65280)+(i[s+2]&255),r.push(Da(n));return r.join("")}function Fa(i){for(var t,e=i.length,n=e%3,r=[],s=16383,a=0,o=e-n;a<o;a+=s)r.push(ja(i,a,a+s>o?o:a+s));return n===1?(t=i[e-1],r.push(Se[t>>2]+Se[t<<4&63]+"==")):n===2&&(t=(i[e-2]<<8)+i[e-1],r.push(Se[t>>10]+Se[t>>4&63]+Se[t<<2&63]+"=")),r.join("")}var za=4,Lr=0,Or=1,Wa=2;function Rt(i){let t=i.length;for(;--t>=0;)i[t]=0}var Ha=0,$s=1,Ba=2,Za=3,Ja=258,er=29,xi=256,gi=xi+1+er,$t=30,tr=19,Ls=2*gi+1,ut=15,fn=16,Qa=7,ir=256,Os=16,Ps=17,Rs=18,Un=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Qi=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),qa=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Is=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ga=512,Re=new Array((gi+2)*2);Rt(Re);var fi=new Array($t*2);Rt(fi);var mi=new Array(Ga);Rt(mi);var wi=new Array(Ja-Za+1);Rt(wi);var nr=new Array(er);Rt(nr);var en=new Array($t);Rt(en);function hn(i,t,e,n,r){this.static_tree=i,this.extra_bits=t,this.extra_base=e,this.elems=n,this.max_length=r,this.has_stree=i&&i.length}var Ns,Ms,Us;function pn(i,t){this.dyn_tree=i,this.max_code=0,this.stat_desc=t}var Ds=i=>i<256?mi[i]:mi[256+(i>>>7)],_i=(i,t)=>{i.pending_buf[i.pending++]=t&255,i.pending_buf[i.pending++]=t>>>8&255},ae=(i,t,e)=>{i.bi_valid>fn-e?(i.bi_buf|=t<<i.bi_valid&65535,_i(i,i.bi_buf),i.bi_buf=t>>fn-i.bi_valid,i.bi_valid+=e-fn):(i.bi_buf|=t<<i.bi_valid&65535,i.bi_valid+=e)},Ce=(i,t,e)=>{ae(i,e[t*2],e[t*2+1])},js=(i,t)=>{let e=0;do e|=i&1,i>>>=1,e<<=1;while(--t>0);return e>>>1},Ka=i=>{i.bi_valid===16?(_i(i,i.bi_buf),i.bi_buf=0,i.bi_valid=0):i.bi_valid>=8&&(i.pending_buf[i.pending++]=i.bi_buf&255,i.bi_buf>>=8,i.bi_valid-=8)},Va=(i,t)=>{let e=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,d,g,p,u,f,h=0;for(p=0;p<=ut;p++)i.bl_count[p]=0;for(e[i.heap[i.heap_max]*2+1]=0,c=i.heap_max+1;c<Ls;c++)d=i.heap[c],p=e[e[d*2+1]*2+1]+1,p>l&&(p=l,h++),e[d*2+1]=p,!(d>n)&&(i.bl_count[p]++,u=0,d>=o&&(u=a[d-o]),f=e[d*2],i.opt_len+=f*(p+u),s&&(i.static_len+=f*(r[d*2+1]+u)));if(h!==0){do{for(p=l-1;i.bl_count[p]===0;)p--;i.bl_count[p]--,i.bl_count[p+1]+=2,i.bl_count[l]--,h-=2}while(h>0);for(p=l;p!==0;p--)for(d=i.bl_count[p];d!==0;)g=i.heap[--c],!(g>n)&&(e[g*2+1]!==p&&(i.opt_len+=(p-e[g*2+1])*e[g*2],e[g*2+1]=p),d--)}},Fs=(i,t,e)=>{let n=new Array(ut+1),r=0,s,a;for(s=1;s<=ut;s++)r=r+e[s-1]<<1,n[s]=r;for(a=0;a<=t;a++){let o=i[a*2+1];o!==0&&(i[a*2]=js(n[o]++,o))}},Xa=()=>{let i,t,e,n,r,s=new Array(ut+1);for(e=0,n=0;n<er-1;n++)for(nr[n]=e,i=0;i<1<<Un[n];i++)wi[e++]=n;for(wi[e-1]=n,r=0,n=0;n<16;n++)for(en[n]=r,i=0;i<1<<Qi[n];i++)mi[r++]=n;for(r>>=7;n<$t;n++)for(en[n]=r<<7,i=0;i<1<<Qi[n]-7;i++)mi[256+r++]=n;for(t=0;t<=ut;t++)s[t]=0;for(i=0;i<=143;)Re[i*2+1]=8,i++,s[8]++;for(;i<=255;)Re[i*2+1]=9,i++,s[9]++;for(;i<=279;)Re[i*2+1]=7,i++,s[7]++;for(;i<=287;)Re[i*2+1]=8,i++,s[8]++;for(Fs(Re,gi+1,s),i=0;i<$t;i++)fi[i*2+1]=5,fi[i*2]=js(i,5);Ns=new hn(Re,Un,xi+1,gi,ut),Ms=new hn(fi,Qi,0,$t,ut),Us=new hn(new Array(0),qa,0,tr,Qa)},zs=i=>{let t;for(t=0;t<gi;t++)i.dyn_ltree[t*2]=0;for(t=0;t<$t;t++)i.dyn_dtree[t*2]=0;for(t=0;t<tr;t++)i.bl_tree[t*2]=0;i.dyn_ltree[ir*2]=1,i.opt_len=i.static_len=0,i.sym_next=i.matches=0},Ws=i=>{i.bi_valid>8?_i(i,i.bi_buf):i.bi_valid>0&&(i.pending_buf[i.pending++]=i.bi_buf),i.bi_buf=0,i.bi_valid=0},Pr=(i,t,e,n)=>{let r=t*2,s=e*2;return i[r]<i[s]||i[r]===i[s]&&n[t]<=n[e]},gn=(i,t,e)=>{let n=i.heap[e],r=e<<1;for(;r<=i.heap_len&&(r<i.heap_len&&Pr(t,i.heap[r+1],i.heap[r],i.depth)&&r++,!Pr(t,n,i.heap[r],i.depth));)i.heap[e]=i.heap[r],e=r,r<<=1;i.heap[e]=n},Rr=(i,t,e)=>{let n,r,s=0,a,o;if(i.sym_next!==0)do n=i.pending_buf[i.sym_buf+s++]&255,n+=(i.pending_buf[i.sym_buf+s++]&255)<<8,r=i.pending_buf[i.sym_buf+s++],n===0?Ce(i,r,t):(a=wi[r],Ce(i,a+xi+1,t),o=Un[a],o!==0&&(r-=nr[a],ae(i,r,o)),n--,a=Ds(n),Ce(i,a,e),o=Qi[a],o!==0&&(n-=en[a],ae(i,n,o)));while(s<i.sym_next);Ce(i,ir,t)},Dn=(i,t)=>{let e=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems,a,o,l=-1,c;for(i.heap_len=0,i.heap_max=Ls,a=0;a<s;a++)e[a*2]!==0?(i.heap[++i.heap_len]=l=a,i.depth[a]=0):e[a*2+1]=0;for(;i.heap_len<2;)c=i.heap[++i.heap_len]=l<2?++l:0,e[c*2]=1,i.depth[c]=0,i.opt_len--,r&&(i.static_len-=n[c*2+1]);for(t.max_code=l,a=i.heap_len>>1;a>=1;a--)gn(i,e,a);c=s;do a=i.heap[1],i.heap[1]=i.heap[i.heap_len--],gn(i,e,1),o=i.heap[1],i.heap[--i.heap_max]=a,i.heap[--i.heap_max]=o,e[c*2]=e[a*2]+e[o*2],i.depth[c]=(i.depth[a]>=i.depth[o]?i.depth[a]:i.depth[o])+1,e[a*2+1]=e[o*2+1]=c,i.heap[1]=c++,gn(i,e,1);while(i.heap_len>=2);i.heap[--i.heap_max]=i.heap[1],Va(i,t),Fs(e,l,i.bl_count)},Ir=(i,t,e)=>{let n,r=-1,s,a=t[0*2+1],o=0,l=7,c=4;for(a===0&&(l=138,c=3),t[(e+1)*2+1]=65535,n=0;n<=e;n++)s=a,a=t[(n+1)*2+1],!(++o<l&&s===a)&&(o<c?i.bl_tree[s*2]+=o:s!==0?(s!==r&&i.bl_tree[s*2]++,i.bl_tree[Os*2]++):o<=10?i.bl_tree[Ps*2]++:i.bl_tree[Rs*2]++,o=0,r=s,a===0?(l=138,c=3):s===a?(l=6,c=3):(l=7,c=4))},Nr=(i,t,e)=>{let n,r=-1,s,a=t[0*2+1],o=0,l=7,c=4;for(a===0&&(l=138,c=3),n=0;n<=e;n++)if(s=a,a=t[(n+1)*2+1],!(++o<l&&s===a)){if(o<c)do Ce(i,s,i.bl_tree);while(--o!==0);else s!==0?(s!==r&&(Ce(i,s,i.bl_tree),o--),Ce(i,Os,i.bl_tree),ae(i,o-3,2)):o<=10?(Ce(i,Ps,i.bl_tree),ae(i,o-3,3)):(Ce(i,Rs,i.bl_tree),ae(i,o-11,7));o=0,r=s,a===0?(l=138,c=3):s===a?(l=6,c=3):(l=7,c=4)}},Ya=i=>{let t;for(Ir(i,i.dyn_ltree,i.l_desc.max_code),Ir(i,i.dyn_dtree,i.d_desc.max_code),Dn(i,i.bl_desc),t=tr-1;t>=3&&i.bl_tree[Is[t]*2+1]===0;t--);return i.opt_len+=3*(t+1)+5+5+4,t},eo=(i,t,e,n)=>{let r;for(ae(i,t-257,5),ae(i,e-1,5),ae(i,n-4,4),r=0;r<n;r++)ae(i,i.bl_tree[Is[r]*2+1],3);Nr(i,i.dyn_ltree,t-1),Nr(i,i.dyn_dtree,e-1)},to=i=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&i.dyn_ltree[e*2]!==0)return Lr;if(i.dyn_ltree[9*2]!==0||i.dyn_ltree[10*2]!==0||i.dyn_ltree[13*2]!==0)return Or;for(e=32;e<xi;e++)if(i.dyn_ltree[e*2]!==0)return Or;return Lr},Mr=!1,io=i=>{Mr||(Xa(),Mr=!0),i.l_desc=new pn(i.dyn_ltree,Ns),i.d_desc=new pn(i.dyn_dtree,Ms),i.bl_desc=new pn(i.bl_tree,Us),i.bi_buf=0,i.bi_valid=0,zs(i)},Hs=(i,t,e,n)=>{ae(i,(Ha<<1)+(n?1:0),3),Ws(i),_i(i,e),_i(i,~e),e&&i.pending_buf.set(i.window.subarray(t,t+e),i.pending),i.pending+=e},no=i=>{ae(i,$s<<1,3),Ce(i,ir,Re),Ka(i)},ro=(i,t,e,n)=>{let r,s,a=0;i.level>0?(i.strm.data_type===Wa&&(i.strm.data_type=to(i)),Dn(i,i.l_desc),Dn(i,i.d_desc),a=Ya(i),r=i.opt_len+3+7>>>3,s=i.static_len+3+7>>>3,s<=r&&(r=s)):r=s=e+5,e+4<=r&&t!==-1?Hs(i,t,e,n):i.strategy===za||s===r?(ae(i,($s<<1)+(n?1:0),3),Rr(i,Re,fi)):(ae(i,(Ba<<1)+(n?1:0),3),eo(i,i.l_desc.max_code+1,i.d_desc.max_code+1,a+1),Rr(i,i.dyn_ltree,i.dyn_dtree)),zs(i),n&&Ws(i)},so=(i,t,e)=>(i.pending_buf[i.sym_buf+i.sym_next++]=t,i.pending_buf[i.sym_buf+i.sym_next++]=t>>8,i.pending_buf[i.sym_buf+i.sym_next++]=e,t===0?i.dyn_ltree[e*2]++:(i.matches++,t--,i.dyn_ltree[(wi[e]+xi+1)*2]++,i.dyn_dtree[Ds(t)*2]++),i.sym_next===i.sym_end),ao=io,oo=Hs,co=ro,lo=so,uo=no,fo={_tr_init:ao,_tr_stored_block:oo,_tr_flush_block:co,_tr_tally:lo,_tr_align:uo},ho=(i,t,e,n)=>{let r=i&65535|0,s=i>>>16&65535|0,a=0;for(;e!==0;){a=e>2e3?2e3:e,e-=a;do r=r+t[n++]|0,s=s+r|0;while(--a);r%=65521,s%=65521}return r|s<<16|0},yi=ho,po=()=>{let i,t=[];for(var e=0;e<256;e++){i=e;for(var n=0;n<8;n++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i}return t},go=new Uint32Array(po()),mo=(i,t,e,n)=>{let r=go,s=n+e;i^=-1;for(let a=n;a<s;a++)i=i>>>8^r[(i^t[a])&255];return i^-1},V=mo,gt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},_t={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:wo,_tr_stored_block:jn,_tr_flush_block:_o,_tr_tally:Qe,_tr_align:yo}=fo,{Z_NO_FLUSH:qe,Z_PARTIAL_FLUSH:bo,Z_FULL_FLUSH:vo,Z_FINISH:fe,Z_BLOCK:Ur,Z_OK:Y,Z_STREAM_END:Dr,Z_STREAM_ERROR:ke,Z_DATA_ERROR:So,Z_BUF_ERROR:mn,Z_DEFAULT_COMPRESSION:Co,Z_FILTERED:ko,Z_HUFFMAN_ONLY:Oi,Z_RLE:xo,Z_FIXED:Ao,Z_DEFAULT_STRATEGY:Eo,Z_UNKNOWN:To,Z_DEFLATED:an}=_t,$o=9,Lo=15,Oo=8,Po=29,Ro=256,Fn=Ro+1+Po,Io=30,No=19,Mo=2*Fn+1,Uo=15,D=3,Be=258,xe=Be+D+1,Do=32,Ot=42,rr=57,zn=69,Wn=73,Hn=91,Bn=103,ft=113,ri=666,ie=1,It=2,mt=3,Nt=4,jo=3,ht=(i,t)=>(i.msg=gt[t],t),jr=i=>i*2-(i>4?9:0),He=i=>{let t=i.length;for(;--t>=0;)i[t]=0},Fo=i=>{let t,e,n,r=i.w_size;t=i.hash_size,n=t;do e=i.head[--n],i.head[n]=e>=r?e-r:0;while(--t);t=r,n=t;do e=i.prev[--n],i.prev[n]=e>=r?e-r:0;while(--t)},zo=(i,t,e)=>(t<<i.hash_shift^e)&i.hash_mask,Ge=zo,oe=i=>{let t=i.state,e=t.pending;e>i.avail_out&&(e=i.avail_out),e!==0&&(i.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),i.next_out),i.next_out+=e,t.pending_out+=e,i.total_out+=e,i.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},ce=(i,t)=>{_o(i,i.block_start>=0?i.block_start:-1,i.strstart-i.block_start,t),i.block_start=i.strstart,oe(i.strm)},F=(i,t)=>{i.pending_buf[i.pending++]=t},Dt=(i,t)=>{i.pending_buf[i.pending++]=t>>>8&255,i.pending_buf[i.pending++]=t&255},Zn=(i,t,e,n)=>{let r=i.avail_in;return r>n&&(r=n),r===0?0:(i.avail_in-=r,t.set(i.input.subarray(i.next_in,i.next_in+r),e),i.state.wrap===1?i.adler=yi(i.adler,t,r,e):i.state.wrap===2&&(i.adler=V(i.adler,t,r,e)),i.next_in+=r,i.total_in+=r,r)},Bs=(i,t)=>{let e=i.max_chain_length,n=i.strstart,r,s,a=i.prev_length,o=i.nice_match,l=i.strstart>i.w_size-xe?i.strstart-(i.w_size-xe):0,c=i.window,d=i.w_mask,g=i.prev,p=i.strstart+Be,u=c[n+a-1],f=c[n+a];i.prev_length>=i.good_match&&(e>>=2),o>i.lookahead&&(o=i.lookahead);do if(r=t,!(c[r+a]!==f||c[r+a-1]!==u||c[r]!==c[n]||c[++r]!==c[n+1])){n+=2,r++;do;while(c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&c[++n]===c[++r]&&n<p);if(s=Be-(p-n),n=p-Be,s>a){if(i.match_start=t,a=s,s>=o)break;u=c[n+a-1],f=c[n+a]}}while((t=g[t&d])>l&&--e!==0);return a<=i.lookahead?a:i.lookahead},Pt=i=>{let t=i.w_size,e,n,r;do{if(n=i.window_size-i.lookahead-i.strstart,i.strstart>=t+(t-xe)&&(i.window.set(i.window.subarray(t,t+t-n),0),i.match_start-=t,i.strstart-=t,i.block_start-=t,i.insert>i.strstart&&(i.insert=i.strstart),Fo(i),n+=t),i.strm.avail_in===0)break;if(e=Zn(i.strm,i.window,i.strstart+i.lookahead,n),i.lookahead+=e,i.lookahead+i.insert>=D)for(r=i.strstart-i.insert,i.ins_h=i.window[r],i.ins_h=Ge(i,i.ins_h,i.window[r+1]);i.insert&&(i.ins_h=Ge(i,i.ins_h,i.window[r+D-1]),i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++,i.insert--,!(i.lookahead+i.insert<D)););}while(i.lookahead<xe&&i.strm.avail_in!==0)},Zs=(i,t)=>{let e=i.pending_buf_size-5>i.w_size?i.w_size:i.pending_buf_size-5,n,r,s,a=0,o=i.strm.avail_in;do{if(n=65535,s=i.bi_valid+42>>3,i.strm.avail_out<s||(s=i.strm.avail_out-s,r=i.strstart-i.block_start,n>r+i.strm.avail_in&&(n=r+i.strm.avail_in),n>s&&(n=s),n<e&&(n===0&&t!==fe||t===qe||n!==r+i.strm.avail_in)))break;a=t===fe&&n===r+i.strm.avail_in?1:0,jn(i,0,0,a),i.pending_buf[i.pending-4]=n,i.pending_buf[i.pending-3]=n>>8,i.pending_buf[i.pending-2]=~n,i.pending_buf[i.pending-1]=~n>>8,oe(i.strm),r&&(r>n&&(r=n),i.strm.output.set(i.window.subarray(i.block_start,i.block_start+r),i.strm.next_out),i.strm.next_out+=r,i.strm.avail_out-=r,i.strm.total_out+=r,i.block_start+=r,n-=r),n&&(Zn(i.strm,i.strm.output,i.strm.next_out,n),i.strm.next_out+=n,i.strm.avail_out-=n,i.strm.total_out+=n)}while(a===0);return o-=i.strm.avail_in,o&&(o>=i.w_size?(i.matches=2,i.window.set(i.strm.input.subarray(i.strm.next_in-i.w_size,i.strm.next_in),0),i.strstart=i.w_size,i.insert=i.strstart):(i.window_size-i.strstart<=o&&(i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,i.insert>i.strstart&&(i.insert=i.strstart)),i.window.set(i.strm.input.subarray(i.strm.next_in-o,i.strm.next_in),i.strstart),i.strstart+=o,i.insert+=o>i.w_size-i.insert?i.w_size-i.insert:o),i.block_start=i.strstart),i.high_water<i.strstart&&(i.high_water=i.strstart),a?Nt:t!==qe&&t!==fe&&i.strm.avail_in===0&&i.strstart===i.block_start?It:(s=i.window_size-i.strstart,i.strm.avail_in>s&&i.block_start>=i.w_size&&(i.block_start-=i.w_size,i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,s+=i.w_size,i.insert>i.strstart&&(i.insert=i.strstart)),s>i.strm.avail_in&&(s=i.strm.avail_in),s&&(Zn(i.strm,i.window,i.strstart,s),i.strstart+=s,i.insert+=s>i.w_size-i.insert?i.w_size-i.insert:s),i.high_water<i.strstart&&(i.high_water=i.strstart),s=i.bi_valid+42>>3,s=i.pending_buf_size-s>65535?65535:i.pending_buf_size-s,e=s>i.w_size?i.w_size:s,r=i.strstart-i.block_start,(r>=e||(r||t===fe)&&t!==qe&&i.strm.avail_in===0&&r<=s)&&(n=r>s?s:r,a=t===fe&&i.strm.avail_in===0&&n===r?1:0,jn(i,i.block_start,n,a),i.block_start+=n,oe(i.strm)),a?mt:ie)},wn=(i,t)=>{let e,n;for(;;){if(i.lookahead<xe){if(Pt(i),i.lookahead<xe&&t===qe)return ie;if(i.lookahead===0)break}if(e=0,i.lookahead>=D&&(i.ins_h=Ge(i,i.ins_h,i.window[i.strstart+D-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),e!==0&&i.strstart-e<=i.w_size-xe&&(i.match_length=Bs(i,e)),i.match_length>=D)if(n=Qe(i,i.strstart-i.match_start,i.match_length-D),i.lookahead-=i.match_length,i.match_length<=i.max_lazy_match&&i.lookahead>=D){i.match_length--;do i.strstart++,i.ins_h=Ge(i,i.ins_h,i.window[i.strstart+D-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart;while(--i.match_length!==0);i.strstart++}else i.strstart+=i.match_length,i.match_length=0,i.ins_h=i.window[i.strstart],i.ins_h=Ge(i,i.ins_h,i.window[i.strstart+1]);else n=Qe(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++;if(n&&(ce(i,!1),i.strm.avail_out===0))return ie}return i.insert=i.strstart<D-1?i.strstart:D-1,t===fe?(ce(i,!0),i.strm.avail_out===0?mt:Nt):i.sym_next&&(ce(i,!1),i.strm.avail_out===0)?ie:It},Ct=(i,t)=>{let e,n,r;for(;;){if(i.lookahead<xe){if(Pt(i),i.lookahead<xe&&t===qe)return ie;if(i.lookahead===0)break}if(e=0,i.lookahead>=D&&(i.ins_h=Ge(i,i.ins_h,i.window[i.strstart+D-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),i.prev_length=i.match_length,i.prev_match=i.match_start,i.match_length=D-1,e!==0&&i.prev_length<i.max_lazy_match&&i.strstart-e<=i.w_size-xe&&(i.match_length=Bs(i,e),i.match_length<=5&&(i.strategy===ko||i.match_length===D&&i.strstart-i.match_start>4096)&&(i.match_length=D-1)),i.prev_length>=D&&i.match_length<=i.prev_length){r=i.strstart+i.lookahead-D,n=Qe(i,i.strstart-1-i.prev_match,i.prev_length-D),i.lookahead-=i.prev_length-1,i.prev_length-=2;do++i.strstart<=r&&(i.ins_h=Ge(i,i.ins_h,i.window[i.strstart+D-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart);while(--i.prev_length!==0);if(i.match_available=0,i.match_length=D-1,i.strstart++,n&&(ce(i,!1),i.strm.avail_out===0))return ie}else if(i.match_available){if(n=Qe(i,0,i.window[i.strstart-1]),n&&ce(i,!1),i.strstart++,i.lookahead--,i.strm.avail_out===0)return ie}else i.match_available=1,i.strstart++,i.lookahead--}return i.match_available&&(n=Qe(i,0,i.window[i.strstart-1]),i.match_available=0),i.insert=i.strstart<D-1?i.strstart:D-1,t===fe?(ce(i,!0),i.strm.avail_out===0?mt:Nt):i.sym_next&&(ce(i,!1),i.strm.avail_out===0)?ie:It},Wo=(i,t)=>{let e,n,r,s,a=i.window;for(;;){if(i.lookahead<=Be){if(Pt(i),i.lookahead<=Be&&t===qe)return ie;if(i.lookahead===0)break}if(i.match_length=0,i.lookahead>=D&&i.strstart>0&&(r=i.strstart-1,n=a[r],n===a[++r]&&n===a[++r]&&n===a[++r])){s=i.strstart+Be;do;while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&r<s);i.match_length=Be-(s-r),i.match_length>i.lookahead&&(i.match_length=i.lookahead)}if(i.match_length>=D?(e=Qe(i,1,i.match_length-D),i.lookahead-=i.match_length,i.strstart+=i.match_length,i.match_length=0):(e=Qe(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++),e&&(ce(i,!1),i.strm.avail_out===0))return ie}return i.insert=0,t===fe?(ce(i,!0),i.strm.avail_out===0?mt:Nt):i.sym_next&&(ce(i,!1),i.strm.avail_out===0)?ie:It},Ho=(i,t)=>{let e;for(;;){if(i.lookahead===0&&(Pt(i),i.lookahead===0)){if(t===qe)return ie;break}if(i.match_length=0,e=Qe(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++,e&&(ce(i,!1),i.strm.avail_out===0))return ie}return i.insert=0,t===fe?(ce(i,!0),i.strm.avail_out===0?mt:Nt):i.sym_next&&(ce(i,!1),i.strm.avail_out===0)?ie:It};function ye(i,t,e,n,r){this.good_length=i,this.max_lazy=t,this.nice_length=e,this.max_chain=n,this.func=r}var si=[new ye(0,0,0,0,Zs),new ye(4,4,8,4,wn),new ye(4,5,16,8,wn),new ye(4,6,32,32,wn),new ye(4,4,16,16,Ct),new ye(8,16,32,32,Ct),new ye(8,16,128,128,Ct),new ye(8,32,128,256,Ct),new ye(32,128,258,1024,Ct),new ye(32,258,258,4096,Ct)],Bo=i=>{i.window_size=2*i.w_size,He(i.head),i.max_lazy_match=si[i.level].max_lazy,i.good_match=si[i.level].good_length,i.nice_match=si[i.level].nice_length,i.max_chain_length=si[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=D-1,i.match_available=0,i.ins_h=0};function Zo(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=an,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Mo*2),this.dyn_dtree=new Uint16Array((2*Io+1)*2),this.bl_tree=new Uint16Array((2*No+1)*2),He(this.dyn_ltree),He(this.dyn_dtree),He(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Uo+1),this.heap=new Uint16Array(2*Fn+1),He(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Fn+1),He(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ai=i=>{if(!i)return 1;let t=i.state;return!t||t.strm!==i||t.status!==Ot&&t.status!==rr&&t.status!==zn&&t.status!==Wn&&t.status!==Hn&&t.status!==Bn&&t.status!==ft&&t.status!==ri?1:0},Js=i=>{if(Ai(i))return ht(i,ke);i.total_in=i.total_out=0,i.data_type=To;let t=i.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?rr:t.wrap?Ot:ft,i.adler=t.wrap===2?0:1,t.last_flush=-2,wo(t),Y},Qs=i=>{let t=Js(i);return t===Y&&Bo(i.state),t},Jo=(i,t)=>Ai(i)||i.state.wrap!==2?ke:(i.state.gzhead=t,Y),qs=(i,t,e,n,r,s)=>{if(!i)return ke;let a=1;if(t===Co&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),r<1||r>$o||e!==an||n<8||n>15||t<0||t>9||s<0||s>Ao||n===8&&a!==1)return ht(i,ke);n===8&&(n=9);let o=new Zo;return i.state=o,o.strm=i,o.status=Ot,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=r+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+D-1)/D),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<r+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=s,o.method=e,Qs(i)},Qo=(i,t)=>qs(i,t,an,Lo,Oo,Eo),qo=(i,t)=>{if(Ai(i)||t>Ur||t<0)return i?ht(i,ke):ke;let e=i.state;if(!i.output||i.avail_in!==0&&!i.input||e.status===ri&&t!==fe)return ht(i,i.avail_out===0?mn:ke);let n=e.last_flush;if(e.last_flush=t,e.pending!==0){if(oe(i),i.avail_out===0)return e.last_flush=-1,Y}else if(i.avail_in===0&&jr(t)<=jr(n)&&t!==fe)return ht(i,mn);if(e.status===ri&&i.avail_in!==0)return ht(i,mn);if(e.status===Ot&&e.wrap===0&&(e.status=ft),e.status===Ot){let r=an+(e.w_bits-8<<4)<<8,s=-1;if(e.strategy>=Oi||e.level<2?s=0:e.level<6?s=1:e.level===6?s=2:s=3,r|=s<<6,e.strstart!==0&&(r|=Do),r+=31-r%31,Dt(e,r),e.strstart!==0&&(Dt(e,i.adler>>>16),Dt(e,i.adler&65535)),i.adler=1,e.status=ft,oe(i),e.pending!==0)return e.last_flush=-1,Y}if(e.status===rr){if(i.adler=0,F(e,31),F(e,139),F(e,8),e.gzhead)F(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),F(e,e.gzhead.time&255),F(e,e.gzhead.time>>8&255),F(e,e.gzhead.time>>16&255),F(e,e.gzhead.time>>24&255),F(e,e.level===9?2:e.strategy>=Oi||e.level<2?4:0),F(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(F(e,e.gzhead.extra.length&255),F(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(i.adler=V(i.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=zn;else if(F(e,0),F(e,0),F(e,0),F(e,0),F(e,0),F(e,e.level===9?2:e.strategy>=Oi||e.level<2?4:0),F(e,jo),e.status=ft,oe(i),e.pending!==0)return e.last_flush=-1,Y}if(e.status===zn){if(e.gzhead.extra){let r=e.pending,s=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+s>e.pending_buf_size;){let o=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+o),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r)),e.gzindex+=o,oe(i),e.pending!==0)return e.last_flush=-1,Y;r=0,s-=o}let a=new Uint8Array(e.gzhead.extra);e.pending_buf.set(a.subarray(e.gzindex,e.gzindex+s),e.pending),e.pending+=s,e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r)),e.gzindex=0}e.status=Wn}if(e.status===Wn){if(e.gzhead.name){let r=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r)),oe(i),e.pending!==0)return e.last_flush=-1,Y;r=0}e.gzindex<e.gzhead.name.length?s=e.gzhead.name.charCodeAt(e.gzindex++)&255:s=0,F(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r)),e.gzindex=0}e.status=Hn}if(e.status===Hn){if(e.gzhead.comment){let r=e.pending,s;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r)),oe(i),e.pending!==0)return e.last_flush=-1,Y;r=0}e.gzindex<e.gzhead.comment.length?s=e.gzhead.comment.charCodeAt(e.gzindex++)&255:s=0,F(e,s)}while(s!==0);e.gzhead.hcrc&&e.pending>r&&(i.adler=V(i.adler,e.pending_buf,e.pending-r,r))}e.status=Bn}if(e.status===Bn){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(oe(i),e.pending!==0))return e.last_flush=-1,Y;F(e,i.adler&255),F(e,i.adler>>8&255),i.adler=0}if(e.status=ft,oe(i),e.pending!==0)return e.last_flush=-1,Y}if(i.avail_in!==0||e.lookahead!==0||t!==qe&&e.status!==ri){let r=e.level===0?Zs(e,t):e.strategy===Oi?Ho(e,t):e.strategy===xo?Wo(e,t):si[e.level].func(e,t);if((r===mt||r===Nt)&&(e.status=ri),r===ie||r===mt)return i.avail_out===0&&(e.last_flush=-1),Y;if(r===It&&(t===bo?yo(e):t!==Ur&&(jn(e,0,0,!1),t===vo&&(He(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),oe(i),i.avail_out===0))return e.last_flush=-1,Y}return t!==fe?Y:e.wrap<=0?Dr:(e.wrap===2?(F(e,i.adler&255),F(e,i.adler>>8&255),F(e,i.adler>>16&255),F(e,i.adler>>24&255),F(e,i.total_in&255),F(e,i.total_in>>8&255),F(e,i.total_in>>16&255),F(e,i.total_in>>24&255)):(Dt(e,i.adler>>>16),Dt(e,i.adler&65535)),oe(i),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?Y:Dr)},Go=i=>{if(Ai(i))return ke;let t=i.state.status;return i.state=null,t===ft?ht(i,So):Y},Ko=(i,t)=>{let e=t.length;if(Ai(i))return ke;let n=i.state,r=n.wrap;if(r===2||r===1&&n.status!==Ot||n.lookahead)return ke;if(r===1&&(i.adler=yi(i.adler,t,e,0)),n.wrap=0,e>=n.w_size){r===0&&(He(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(e-n.w_size,e),0),t=l,e=n.w_size}let s=i.avail_in,a=i.next_in,o=i.input;for(i.avail_in=e,i.next_in=0,i.input=t,Pt(n);n.lookahead>=D;){let l=n.strstart,c=n.lookahead-(D-1);do n.ins_h=Ge(n,n.ins_h,n.window[l+D-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++;while(--c);n.strstart=l,n.lookahead=D-1,Pt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=D-1,n.match_available=0,i.next_in=a,i.input=o,i.avail_in=s,n.wrap=r,Y},Vo=Qo,Xo=qs,Yo=Qs,ec=Js,tc=Jo,ic=qo,nc=Go,rc=Ko,sc="pako deflate (from Nodeca project)",hi={deflateInit:Vo,deflateInit2:Xo,deflateReset:Yo,deflateResetKeep:ec,deflateSetHeader:tc,deflate:ic,deflateEnd:nc,deflateSetDictionary:rc,deflateInfo:sc},ac=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),oc=function(i){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let e=t.shift();if(!!e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(let n in e)ac(e,n)&&(i[n]=e[n])}}return i},cc=i=>{let t=0;for(let n=0,r=i.length;n<r;n++)t+=i[n].length;let e=new Uint8Array(t);for(let n=0,r=0,s=i.length;n<s;n++){let a=i[n];e.set(a,r),r+=a.length}return e},on={assign:oc,flattenChunks:cc},Gs=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Gs=!1}var bi=new Uint8Array(256);for(let i=0;i<256;i++)bi[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;bi[254]=bi[254]=1;var lc=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let t,e,n,r,s,a=i.length,o=0;for(r=0;r<a;r++)e=i.charCodeAt(r),(e&64512)===55296&&r+1<a&&(n=i.charCodeAt(r+1),(n&64512)===56320&&(e=65536+(e-55296<<10)+(n-56320),r++)),o+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(o),s=0,r=0;s<o;r++)e=i.charCodeAt(r),(e&64512)===55296&&r+1<a&&(n=i.charCodeAt(r+1),(n&64512)===56320&&(e=65536+(e-55296<<10)+(n-56320),r++)),e<128?t[s++]=e:e<2048?(t[s++]=192|e>>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t},dc=(i,t)=>{if(t<65534&&i.subarray&&Gs)return String.fromCharCode.apply(null,i.length===t?i:i.subarray(0,t));let e="";for(let n=0;n<t;n++)e+=String.fromCharCode(i[n]);return e},uc=(i,t)=>{let e=t||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,t));let n,r,s=new Array(e*2);for(r=0,n=0;n<e;){let a=i[n++];if(a<128){s[r++]=a;continue}let o=bi[a];if(o>4){s[r++]=65533,n+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&n<e;)a=a<<6|i[n++]&63,o--;if(o>1){s[r++]=65533;continue}a<65536?s[r++]=a:(a-=65536,s[r++]=55296|a>>10&1023,s[r++]=56320|a&1023)}return dc(s,r)},fc=(i,t)=>{t=t||i.length,t>i.length&&(t=i.length);let e=t-1;for(;e>=0&&(i[e]&192)===128;)e--;return e<0||e===0?t:e+bi[i[e]]>t?e:t},vi={string2buf:lc,buf2string:uc,utf8border:fc};function hc(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Ks=hc,Vs=Object.prototype.toString,{Z_NO_FLUSH:pc,Z_SYNC_FLUSH:gc,Z_FULL_FLUSH:mc,Z_FINISH:wc,Z_OK:tn,Z_STREAM_END:_c,Z_DEFAULT_COMPRESSION:yc,Z_DEFAULT_STRATEGY:bc,Z_DEFLATED:vc}=_t;function Ei(i){this.options=on.assign({level:yc,method:vc,chunkSize:16384,windowBits:15,memLevel:8,strategy:bc},i||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ks,this.strm.avail_out=0;let e=hi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==tn)throw new Error(gt[e]);if(t.header&&hi.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=vi.string2buf(t.dictionary):Vs.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,e=hi.deflateSetDictionary(this.strm,n),e!==tn)throw new Error(gt[e]);this._dict_set=!0}}Ei.prototype.push=function(i,t){let e=this.strm,n=this.options.chunkSize,r,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?wc:pc,typeof i=="string"?e.input=vi.string2buf(i):Vs.call(i)==="[object ArrayBuffer]"?e.input=new Uint8Array(i):e.input=i,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(n),e.next_out=0,e.avail_out=n),(s===gc||s===mc)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(r=hi.deflate(e,s),r===_c)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),r=hi.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===tn;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0};Ei.prototype.onData=function(i){this.chunks.push(i)};Ei.prototype.onEnd=function(i){i===tn&&(this.result=on.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function sr(i,t){let e=new Ei(t);if(e.push(i,!0),e.err)throw e.msg||gt[e.err];return e.result}function Sc(i,t){return t=t||{},t.raw=!0,sr(i,t)}function Cc(i,t){return t=t||{},t.gzip=!0,sr(i,t)}var kc=Ei,xc=sr,Ac=Sc,Ec=Cc,Tc=_t,$c={Deflate:kc,deflate:xc,deflateRaw:Ac,gzip:Ec,constants:Tc},Pi=16209,Lc=16191,Oc=function(t,e){let n,r,s,a,o,l,c,d,g,p,u,f,h,w,y,v,S,b,T,O,C,P,R,x,N=t.state;n=t.next_in,R=t.input,r=n+(t.avail_in-5),s=t.next_out,x=t.output,a=s-(e-t.avail_out),o=s+(t.avail_out-257),l=N.dmax,c=N.wsize,d=N.whave,g=N.wnext,p=N.window,u=N.hold,f=N.bits,h=N.lencode,w=N.distcode,y=(1<<N.lenbits)-1,v=(1<<N.distbits)-1;e:do{f<15&&(u+=R[n++]<<f,f+=8,u+=R[n++]<<f,f+=8),S=h[u&y];t:for(;;){if(b=S>>>24,u>>>=b,f-=b,b=S>>>16&255,b===0)x[s++]=S&65535;else if(b&16){T=S&65535,b&=15,b&&(f<b&&(u+=R[n++]<<f,f+=8),T+=u&(1<<b)-1,u>>>=b,f-=b),f<15&&(u+=R[n++]<<f,f+=8,u+=R[n++]<<f,f+=8),S=w[u&v];i:for(;;){if(b=S>>>24,u>>>=b,f-=b,b=S>>>16&255,b&16){if(O=S&65535,b&=15,f<b&&(u+=R[n++]<<f,f+=8,f<b&&(u+=R[n++]<<f,f+=8)),O+=u&(1<<b)-1,O>l){t.msg="invalid distance too far back",N.mode=Pi;break e}if(u>>>=b,f-=b,b=s-a,O>b){if(b=O-b,b>d&&N.sane){t.msg="invalid distance too far back",N.mode=Pi;break e}if(C=0,P=p,g===0){if(C+=c-b,b<T){T-=b;do x[s++]=p[C++];while(--b);C=s-O,P=x}}else if(g<b){if(C+=c+g-b,b-=g,b<T){T-=b;do x[s++]=p[C++];while(--b);if(C=0,g<T){b=g,T-=b;do x[s++]=p[C++];while(--b);C=s-O,P=x}}}else if(C+=g-b,b<T){T-=b;do x[s++]=p[C++];while(--b);C=s-O,P=x}for(;T>2;)x[s++]=P[C++],x[s++]=P[C++],x[s++]=P[C++],T-=3;T&&(x[s++]=P[C++],T>1&&(x[s++]=P[C++]))}else{C=s-O;do x[s++]=x[C++],x[s++]=x[C++],x[s++]=x[C++],T-=3;while(T>2);T&&(x[s++]=x[C++],T>1&&(x[s++]=x[C++]))}}else if((b&64)===0){S=w[(S&65535)+(u&(1<<b)-1)];continue i}else{t.msg="invalid distance code",N.mode=Pi;break e}break}}else if((b&64)===0){S=h[(S&65535)+(u&(1<<b)-1)];continue t}else if(b&32){N.mode=Lc;break e}else{t.msg="invalid literal/length code",N.mode=Pi;break e}break}}while(n<r&&s<o);T=f>>3,n-=T,f-=T<<3,u&=(1<<f)-1,t.next_in=n,t.next_out=s,t.avail_in=n<r?5+(r-n):5-(n-r),t.avail_out=s<o?257+(o-s):257-(s-o),N.hold=u,N.bits=f},kt=15,Fr=852,zr=592,Wr=0,_n=1,Hr=2,Pc=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Rc=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Ic=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Nc=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Mc=(i,t,e,n,r,s,a,o)=>{let l=o.bits,c=0,d=0,g=0,p=0,u=0,f=0,h=0,w=0,y=0,v=0,S,b,T,O,C,P=null,R,x=new Uint16Array(kt+1),N=new Uint16Array(kt+1),we=null,Mt,Ve,_;for(c=0;c<=kt;c++)x[c]=0;for(d=0;d<n;d++)x[t[e+d]]++;for(u=l,p=kt;p>=1&&x[p]===0;p--);if(u>p&&(u=p),p===0)return r[s++]=1<<24|64<<16|0,r[s++]=1<<24|64<<16|0,o.bits=1,0;for(g=1;g<p&&x[g]===0;g++);for(u<g&&(u=g),w=1,c=1;c<=kt;c++)if(w<<=1,w-=x[c],w<0)return-1;if(w>0&&(i===Wr||p!==1))return-1;for(N[1]=0,c=1;c<kt;c++)N[c+1]=N[c]+x[c];for(d=0;d<n;d++)t[e+d]!==0&&(a[N[t[e+d]]++]=d);if(i===Wr?(P=we=a,R=20):i===_n?(P=Pc,we=Rc,R=257):(P=Ic,we=Nc,R=0),v=0,d=0,c=g,C=s,f=u,h=0,T=-1,y=1<<u,O=y-1,i===_n&&y>Fr||i===Hr&&y>zr)return 1;for(;;){Mt=c-h,a[d]+1<R?(Ve=0,_=a[d]):a[d]>=R?(Ve=we[a[d]-R],_=P[a[d]-R]):(Ve=32+64,_=0),S=1<<c-h,b=1<<f,g=b;do b-=S,r[C+(v>>h)+b]=Mt<<24|Ve<<16|_|0;while(b!==0);for(S=1<<c-1;v&S;)S>>=1;if(S!==0?(v&=S-1,v+=S):v=0,d++,--x[c]===0){if(c===p)break;c=t[e+a[d]]}if(c>u&&(v&O)!==T){for(h===0&&(h=u),C+=g,f=c-h,w=1<<f;f+h<p&&(w-=x[f+h],!(w<=0));)f++,w<<=1;if(y+=1<<f,i===_n&&y>Fr||i===Hr&&y>zr)return 1;T=v&O,r[T]=u<<24|f<<16|C-s|0}}return v!==0&&(r[C+v]=c-h<<24|64<<16|0),o.bits=u,0},pi=Mc,Uc=0,Xs=1,Ys=2,{Z_FINISH:Br,Z_BLOCK:Dc,Z_TREES:Ri,Z_OK:wt,Z_STREAM_END:jc,Z_NEED_DICT:Fc,Z_STREAM_ERROR:he,Z_DATA_ERROR:ea,Z_MEM_ERROR:ta,Z_BUF_ERROR:zc,Z_DEFLATED:Zr}=_t,cn=16180,Jr=16181,Qr=16182,qr=16183,Gr=16184,Kr=16185,Vr=16186,Xr=16187,Yr=16188,es=16189,nn=16190,$e=16191,yn=16192,ts=16193,bn=16194,is=16195,ns=16196,rs=16197,ss=16198,Ii=16199,Ni=16200,as=16201,os=16202,cs=16203,ls=16204,ds=16205,vn=16206,us=16207,fs=16208,H=16209,ia=16210,na=16211,Wc=852,Hc=592,Bc=15,Zc=Bc,hs=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function Jc(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var yt=i=>{if(!i)return 1;let t=i.state;return!t||t.strm!==i||t.mode<cn||t.mode>na?1:0},ra=i=>{if(yt(i))return he;let t=i.state;return i.total_in=i.total_out=t.total=0,i.msg="",t.wrap&&(i.adler=t.wrap&1),t.mode=cn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Wc),t.distcode=t.distdyn=new Int32Array(Hc),t.sane=1,t.back=-1,wt},sa=i=>{if(yt(i))return he;let t=i.state;return t.wsize=0,t.whave=0,t.wnext=0,ra(i)},aa=(i,t)=>{let e;if(yt(i))return he;let n=i.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?he:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=e,n.wbits=t,sa(i))},oa=(i,t)=>{if(!i)return he;let e=new Jc;i.state=e,e.strm=i,e.window=null,e.mode=cn;let n=aa(i,t);return n!==wt&&(i.state=null),n},Qc=i=>oa(i,Zc),ps=!0,Sn,Cn,qc=i=>{if(ps){Sn=new Int32Array(512),Cn=new Int32Array(32);let t=0;for(;t<144;)i.lens[t++]=8;for(;t<256;)i.lens[t++]=9;for(;t<280;)i.lens[t++]=7;for(;t<288;)i.lens[t++]=8;for(pi(Xs,i.lens,0,288,Sn,0,i.work,{bits:9}),t=0;t<32;)i.lens[t++]=5;pi(Ys,i.lens,0,32,Cn,0,i.work,{bits:5}),ps=!1}i.lencode=Sn,i.lenbits=9,i.distcode=Cn,i.distbits=5},ca=(i,t,e,n)=>{let r,s=i.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(e-n,e-n+r),s.wnext),n-=r,n?(s.window.set(t.subarray(e-n,e),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0},Gc=(i,t)=>{let e,n,r,s,a,o,l,c,d,g,p,u,f,h,w=0,y,v,S,b,T,O,C,P,R=new Uint8Array(4),x,N,we=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(yt(i)||!i.output||!i.input&&i.avail_in!==0)return he;e=i.state,e.mode===$e&&(e.mode=yn),a=i.next_out,r=i.output,l=i.avail_out,s=i.next_in,n=i.input,o=i.avail_in,c=e.hold,d=e.bits,g=o,p=l,P=wt;e:for(;;)switch(e.mode){case cn:if(e.wrap===0){e.mode=yn;break}for(;d<16;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(e.wrap&2&&c===35615){e.wbits===0&&(e.wbits=15),e.check=0,R[0]=c&255,R[1]=c>>>8&255,e.check=V(e.check,R,2,0),c=0,d=0,e.mode=Jr;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((c&255)<<8)+(c>>8))%31){i.msg="incorrect header check",e.mode=H;break}if((c&15)!==Zr){i.msg="unknown compression method",e.mode=H;break}if(c>>>=4,d-=4,C=(c&15)+8,e.wbits===0&&(e.wbits=C),C>15||C>e.wbits){i.msg="invalid window size",e.mode=H;break}e.dmax=1<<e.wbits,e.flags=0,i.adler=e.check=1,e.mode=c&512?es:$e,c=0,d=0;break;case Jr:for(;d<16;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(e.flags=c,(e.flags&255)!==Zr){i.msg="unknown compression method",e.mode=H;break}if(e.flags&57344){i.msg="unknown header flags set",e.mode=H;break}e.head&&(e.head.text=c>>8&1),e.flags&512&&e.wrap&4&&(R[0]=c&255,R[1]=c>>>8&255,e.check=V(e.check,R,2,0)),c=0,d=0,e.mode=Qr;case Qr:for(;d<32;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.head&&(e.head.time=c),e.flags&512&&e.wrap&4&&(R[0]=c&255,R[1]=c>>>8&255,R[2]=c>>>16&255,R[3]=c>>>24&255,e.check=V(e.check,R,4,0)),c=0,d=0,e.mode=qr;case qr:for(;d<16;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.head&&(e.head.xflags=c&255,e.head.os=c>>8),e.flags&512&&e.wrap&4&&(R[0]=c&255,R[1]=c>>>8&255,e.check=V(e.check,R,2,0)),c=0,d=0,e.mode=Gr;case Gr:if(e.flags&1024){for(;d<16;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.length=c,e.head&&(e.head.extra_len=c),e.flags&512&&e.wrap&4&&(R[0]=c&255,R[1]=c>>>8&255,e.check=V(e.check,R,2,0)),c=0,d=0}else e.head&&(e.head.extra=null);e.mode=Kr;case Kr:if(e.flags&1024&&(u=e.length,u>o&&(u=o),u&&(e.head&&(C=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(n.subarray(s,s+u),C)),e.flags&512&&e.wrap&4&&(e.check=V(e.check,n,u,s)),o-=u,s+=u,e.length-=u),e.length))break e;e.length=0,e.mode=Vr;case Vr:if(e.flags&2048){if(o===0)break e;u=0;do C=n[s+u++],e.head&&C&&e.length<65536&&(e.head.name+=String.fromCharCode(C));while(C&&u<o);if(e.flags&512&&e.wrap&4&&(e.check=V(e.check,n,u,s)),o-=u,s+=u,C)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=Xr;case Xr:if(e.flags&4096){if(o===0)break e;u=0;do C=n[s+u++],e.head&&C&&e.length<65536&&(e.head.comment+=String.fromCharCode(C));while(C&&u<o);if(e.flags&512&&e.wrap&4&&(e.check=V(e.check,n,u,s)),o-=u,s+=u,C)break e}else e.head&&(e.head.comment=null);e.mode=Yr;case Yr:if(e.flags&512){for(;d<16;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(e.wrap&4&&c!==(e.check&65535)){i.msg="header crc mismatch",e.mode=H;break}c=0,d=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),i.adler=e.check=0,e.mode=$e;break;case es:for(;d<32;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}i.adler=e.check=hs(c),c=0,d=0,e.mode=nn;case nn:if(e.havedict===0)return i.next_out=a,i.avail_out=l,i.next_in=s,i.avail_in=o,e.hold=c,e.bits=d,Fc;i.adler=e.check=1,e.mode=$e;case $e:if(t===Dc||t===Ri)break e;case yn:if(e.last){c>>>=d&7,d-=d&7,e.mode=vn;break}for(;d<3;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}switch(e.last=c&1,c>>>=1,d-=1,c&3){case 0:e.mode=ts;break;case 1:if(qc(e),e.mode=Ii,t===Ri){c>>>=2,d-=2;break e}break;case 2:e.mode=ns;break;case 3:i.msg="invalid block type",e.mode=H}c>>>=2,d-=2;break;case ts:for(c>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){i.msg="invalid stored block lengths",e.mode=H;break}if(e.length=c&65535,c=0,d=0,e.mode=bn,t===Ri)break e;case bn:e.mode=is;case is:if(u=e.length,u){if(u>o&&(u=o),u>l&&(u=l),u===0)break e;r.set(n.subarray(s,s+u),a),o-=u,s+=u,l-=u,a+=u,e.length-=u;break}e.mode=$e;break;case ns:for(;d<14;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(e.nlen=(c&31)+257,c>>>=5,d-=5,e.ndist=(c&31)+1,c>>>=5,d-=5,e.ncode=(c&15)+4,c>>>=4,d-=4,e.nlen>286||e.ndist>30){i.msg="too many length or distance symbols",e.mode=H;break}e.have=0,e.mode=rs;case rs:for(;e.have<e.ncode;){for(;d<3;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.lens[we[e.have++]]=c&7,c>>>=3,d-=3}for(;e.have<19;)e.lens[we[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,x={bits:e.lenbits},P=pi(Uc,e.lens,0,19,e.lencode,0,e.work,x),e.lenbits=x.bits,P){i.msg="invalid code lengths set",e.mode=H;break}e.have=0,e.mode=ss;case ss:for(;e.have<e.nlen+e.ndist;){for(;w=e.lencode[c&(1<<e.lenbits)-1],y=w>>>24,v=w>>>16&255,S=w&65535,!(y<=d);){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(S<16)c>>>=y,d-=y,e.lens[e.have++]=S;else{if(S===16){for(N=y+2;d<N;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(c>>>=y,d-=y,e.have===0){i.msg="invalid bit length repeat",e.mode=H;break}C=e.lens[e.have-1],u=3+(c&3),c>>>=2,d-=2}else if(S===17){for(N=y+3;d<N;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}c>>>=y,d-=y,C=0,u=3+(c&7),c>>>=3,d-=3}else{for(N=y+7;d<N;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}c>>>=y,d-=y,C=0,u=11+(c&127),c>>>=7,d-=7}if(e.have+u>e.nlen+e.ndist){i.msg="invalid bit length repeat",e.mode=H;break}for(;u--;)e.lens[e.have++]=C}}if(e.mode===H)break;if(e.lens[256]===0){i.msg="invalid code -- missing end-of-block",e.mode=H;break}if(e.lenbits=9,x={bits:e.lenbits},P=pi(Xs,e.lens,0,e.nlen,e.lencode,0,e.work,x),e.lenbits=x.bits,P){i.msg="invalid literal/lengths set",e.mode=H;break}if(e.distbits=6,e.distcode=e.distdyn,x={bits:e.distbits},P=pi(Ys,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,x),e.distbits=x.bits,P){i.msg="invalid distances set",e.mode=H;break}if(e.mode=Ii,t===Ri)break e;case Ii:e.mode=Ni;case Ni:if(o>=6&&l>=258){i.next_out=a,i.avail_out=l,i.next_in=s,i.avail_in=o,e.hold=c,e.bits=d,Oc(i,p),a=i.next_out,r=i.output,l=i.avail_out,s=i.next_in,n=i.input,o=i.avail_in,c=e.hold,d=e.bits,e.mode===$e&&(e.back=-1);break}for(e.back=0;w=e.lencode[c&(1<<e.lenbits)-1],y=w>>>24,v=w>>>16&255,S=w&65535,!(y<=d);){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(v&&(v&240)===0){for(b=y,T=v,O=S;w=e.lencode[O+((c&(1<<b+T)-1)>>b)],y=w>>>24,v=w>>>16&255,S=w&65535,!(b+y<=d);){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}c>>>=b,d-=b,e.back+=b}if(c>>>=y,d-=y,e.back+=y,e.length=S,v===0){e.mode=ds;break}if(v&32){e.back=-1,e.mode=$e;break}if(v&64){i.msg="invalid literal/length code",e.mode=H;break}e.extra=v&15,e.mode=as;case as:if(e.extra){for(N=e.extra;d<N;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.length+=c&(1<<e.extra)-1,c>>>=e.extra,d-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=os;case os:for(;w=e.distcode[c&(1<<e.distbits)-1],y=w>>>24,v=w>>>16&255,S=w&65535,!(y<=d);){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if((v&240)===0){for(b=y,T=v,O=S;w=e.distcode[O+((c&(1<<b+T)-1)>>b)],y=w>>>24,v=w>>>16&255,S=w&65535,!(b+y<=d);){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}c>>>=b,d-=b,e.back+=b}if(c>>>=y,d-=y,e.back+=y,v&64){i.msg="invalid distance code",e.mode=H;break}e.offset=S,e.extra=v&15,e.mode=cs;case cs:if(e.extra){for(N=e.extra;d<N;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}e.offset+=c&(1<<e.extra)-1,c>>>=e.extra,d-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){i.msg="invalid distance too far back",e.mode=H;break}e.mode=ls;case ls:if(l===0)break e;if(u=p-l,e.offset>u){if(u=e.offset-u,u>e.whave&&e.sane){i.msg="invalid distance too far back",e.mode=H;break}u>e.wnext?(u-=e.wnext,f=e.wsize-u):f=e.wnext-u,u>e.length&&(u=e.length),h=e.window}else h=r,f=a-e.offset,u=e.length;u>l&&(u=l),l-=u,e.length-=u;do r[a++]=h[f++];while(--u);e.length===0&&(e.mode=Ni);break;case ds:if(l===0)break e;r[a++]=e.length,l--,e.mode=Ni;break;case vn:if(e.wrap){for(;d<32;){if(o===0)break e;o--,c|=n[s++]<<d,d+=8}if(p-=l,i.total_out+=p,e.total+=p,e.wrap&4&&p&&(i.adler=e.check=e.flags?V(e.check,r,p,a-p):yi(e.check,r,p,a-p)),p=l,e.wrap&4&&(e.flags?c:hs(c))!==e.check){i.msg="incorrect data check",e.mode=H;break}c=0,d=0}e.mode=us;case us:if(e.wrap&&e.flags){for(;d<32;){if(o===0)break e;o--,c+=n[s++]<<d,d+=8}if(e.wrap&4&&c!==(e.total&4294967295)){i.msg="incorrect length check",e.mode=H;break}c=0,d=0}e.mode=fs;case fs:P=jc;break e;case H:P=ea;break e;case ia:return ta;case na:default:return he}return i.next_out=a,i.avail_out=l,i.next_in=s,i.avail_in=o,e.hold=c,e.bits=d,(e.wsize||p!==i.avail_out&&e.mode<H&&(e.mode<vn||t!==Br))&&ca(i,i.output,i.next_out,p-i.avail_out),g-=i.avail_in,p-=i.avail_out,i.total_in+=g,i.total_out+=p,e.total+=p,e.wrap&4&&p&&(i.adler=e.check=e.flags?V(e.check,r,p,i.next_out-p):yi(e.check,r,p,i.next_out-p)),i.data_type=e.bits+(e.last?64:0)+(e.mode===$e?128:0)+(e.mode===Ii||e.mode===bn?256:0),(g===0&&p===0||t===Br)&&P===wt&&(P=zc),P},Kc=i=>{if(yt(i))return he;let t=i.state;return t.window&&(t.window=null),i.state=null,wt},Vc=(i,t)=>{if(yt(i))return he;let e=i.state;return(e.wrap&2)===0?he:(e.head=t,t.done=!1,wt)},Xc=(i,t)=>{let e=t.length,n,r,s;return yt(i)||(n=i.state,n.wrap!==0&&n.mode!==nn)?he:n.mode===nn&&(r=1,r=yi(r,t,e,0),r!==n.check)?ea:(s=ca(i,t,e,e),s?(n.mode=ia,ta):(n.havedict=1,wt))},Yc=sa,el=aa,tl=ra,il=Qc,nl=oa,rl=Gc,sl=Kc,al=Vc,ol=Xc,cl="pako inflate (from Nodeca project)",Ie={inflateReset:Yc,inflateReset2:el,inflateResetKeep:tl,inflateInit:il,inflateInit2:nl,inflate:rl,inflateEnd:sl,inflateGetHeader:al,inflateSetDictionary:ol,inflateInfo:cl};function ll(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var dl=ll,la=Object.prototype.toString,{Z_NO_FLUSH:ul,Z_FINISH:fl,Z_OK:Si,Z_STREAM_END:kn,Z_NEED_DICT:xn,Z_STREAM_ERROR:hl,Z_DATA_ERROR:gs,Z_MEM_ERROR:pl}=_t;function Ti(i){this.options=on.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(i&&i.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ks,this.strm.avail_out=0;let e=Ie.inflateInit2(this.strm,t.windowBits);if(e!==Si)throw new Error(gt[e]);if(this.header=new dl,Ie.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vi.string2buf(t.dictionary):la.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Ie.inflateSetDictionary(this.strm,t.dictionary),e!==Si)))throw new Error(gt[e])}Ti.prototype.push=function(i,t){let e=this.strm,n=this.options.chunkSize,r=this.options.dictionary,s,a,o;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?fl:ul,la.call(i)==="[object ArrayBuffer]"?e.input=new Uint8Array(i):e.input=i,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(n),e.next_out=0,e.avail_out=n),s=Ie.inflate(e,a),s===xn&&r&&(s=Ie.inflateSetDictionary(e,r),s===Si?s=Ie.inflate(e,a):s===gs&&(s=xn));e.avail_in>0&&s===kn&&e.state.wrap>0&&i[e.next_in]!==0;)Ie.inflateReset(e),s=Ie.inflate(e,a);switch(s){case hl:case gs:case xn:case pl:return this.onEnd(s),this.ended=!0,!1}if(o=e.avail_out,e.next_out&&(e.avail_out===0||s===kn))if(this.options.to==="string"){let l=vi.utf8border(e.output,e.next_out),c=e.next_out-l,d=vi.buf2string(e.output,l);e.next_out=c,e.avail_out=n-c,c&&e.output.set(e.output.subarray(l,l+c),0),this.onData(d)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===Si&&o===0)){if(s===kn)return s=Ie.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};Ti.prototype.onData=function(i){this.chunks.push(i)};Ti.prototype.onEnd=function(i){i===Si&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=on.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function ar(i,t){let e=new Ti(t);if(e.push(i),e.err)throw e.msg||gt[e.err];return e.result}function gl(i,t){return t=t||{},t.raw=!0,ar(i,t)}var ml=Ti,wl=ar,_l=gl,yl=ar,bl=_t,vl={Inflate:ml,inflate:wl,inflateRaw:_l,ungzip:yl,constants:bl},{Deflate:Sl,deflate:Cl,deflateRaw:kl,gzip:xl}=$c,{Inflate:Al,inflate:El,inflateRaw:Tl,ungzip:$l}=vl,Ll=Sl,Ol=Cl,Pl=kl,Rl=xl,Il=Al,Nl=El,Ml=Tl,Ul=$l,Dl=_t,jl={Deflate:Ll,deflate:Ol,deflateRaw:Pl,gzip:Rl,Inflate:Il,inflate:Nl,inflateRaw:Ml,ungzip:Ul,constants:Dl};var Jn=class{constructor(t,e,n,r,s){this.name=t,this.modelId=e,this.systemPrompt=n,this.promptExamples=r,this.metaData=s}};var Fl=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},q=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},G,ai,Qn,qn=class{constructor(t,e,n=!0,r){G.set(this,void 0),ai.set(this,new Map),Qn.set(this,new Set),Fl(this,G,r||new Ae(t,e),"f")}serializeModelInput(t){let e={...t};return"modelType"in e&&(e.type=e.modelType,delete e.modelType),e}async getModels(){return q(this,G,"f").call("ai.models")}async addModel(t){return q(this,G,"f").call("ai.addModel",{model:this.serializeModelInput(t)})}async updateModel(t,e){return q(this,G,"f").call("ai.updateModel",{id:t,model:this.serializeModelInput(e)})}async removeModel(t){return q(this,G,"f").call("ai.removeModel",{id:t})}async setDefaultModel(t,e){return q(this,G,"f").call("ai.setDefaultModel",{id:e,modelType:t})}async getDefaultModel(t){return q(this,G,"f").call("ai.getDefaultModel",{modelType:t})}async tasks(){return q(this,G,"f").call("ai.tasks")}async addTask(t,e,n,r,s){let a=new Jn(t,e,n,r,s);return q(this,G,"f").call("ai.addTask",{task:a})}async removeTask(t){return q(this,G,"f").call("ai.removeTask",{id:t})}async updateTask(t,e){return q(this,G,"f").call("ai.updateTask",{id:t,task:{name:e.name,modelId:e.modelId,systemPrompt:e.systemPrompt,promptExamples:e.promptExamples}})}async modelLoadingStatus(t){return q(this,G,"f").call("ai.modelLoadingStatus",{model:t})}async prompt(t,e){return q(this,G,"f").call("ai.prompt",{taskId:t,prompt:e})}async embed(t,e){let n=await q(this,G,"f").call("ai.embed",{modelId:t,text:e}),r=sn.toByteArray(n);return JSON.parse(jl.inflate(r,{to:"string"}))}async openTranscriptionStream(t,e,n){let r=await q(this,G,"f").call("ai.transcriptionOpen",{modelId:t,params:n}),s=q(this,G,"f").subscribe(a=>{a.type==="transcription-text"&&a.streamId===r&&a.text&&e(a.text)});return q(this,ai,"f").set(r,s),r}async closeTranscriptionStream(t){q(this,Qn,"f").delete(t),await q(this,G,"f").call("ai.transcriptionClose",{streamId:t});let e=q(this,ai,"f").get(t);e&&(e(),q(this,ai,"f").delete(t))}async feedTranscriptionStream(t,e){let n=Array.isArray(t)?t:[t],r=e instanceof Float32Array?e:new Float32Array(e);if(n.length===0||r.length===0)return;let s=q(this,G,"f").getBaseUrl(),a=q(this,G,"f").getToken(),o=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),l=await fetch(`${s}/api/v1/ai/transcription/feed`,{method:"POST",headers:{"Content-Type":"application/octet-stream","X-Stream-Ids":n.join(","),...a?{Authorization:`Bearer ${a}`}:{}},body:o});if(!l.ok){let c=await l.text().catch(()=>"");throw new Error(`[AIClient] feed failed: ${l.status} ${l.statusText} ${c}`)}}};G=new WeakMap,ai=new WeakMap,Qn=new WeakMap;var be=function(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e},B=function(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)},Gn,Kn,ge,ot,oi,qi,ci,ct,Gi,li,Ci=class{constructor(t,e,n=!0){Gn.set(this,void 0),Kn.set(this,void 0),ge.set(this,void 0),ot.set(this,void 0),oi.set(this,void 0),qi.set(this,void 0),ci.set(this,void 0),ct.set(this,void 0),Gi.set(this,void 0),li.set(this,void 0),be(this,Gn,t,"f"),be(this,Kn,e,"f"),be(this,ge,new Ae(t,e),"f"),be(this,ot,new On(t,e,n,B(this,ge,"f")),"f"),be(this,oi,new Mn(t,e,B(this,ge,"f")),"f"),be(this,qi,new Pn(t,e,B(this,ge,"f")),"f"),be(this,ci,new Rn(t,e,B(this,ge,"f")),"f"),be(this,li,new qn(t,e,n,B(this,ge,"f")),"f"),be(this,ct,new Yi(t,e,n,B(this,ge,"f")),"f"),B(this,ct,"f").setExpressionClient(B(this,oi,"f")),B(this,ct,"f").setNeighbourhoodClient(B(this,ci,"f")),B(this,ct,"f").setAIClient(B(this,li,"f")),be(this,Gi,new Nn(t,e,n,B(this,ge,"f")),"f")}get agent(){return B(this,ot,"f")}get expression(){return B(this,oi,"f")}get languages(){return B(this,qi,"f")}get neighbourhood(){return B(this,ci,"f")}get perspective(){return B(this,ct,"f")}get runtime(){return B(this,Gi,"f")}get ai(){return B(this,li,"f")}startSubscriptions(){B(this,ot,"f").subscribeAgentUpdated(),B(this,ot,"f").subscribeAgentStatusChanged(),B(this,ot,"f").subscribeAppsChanged()}close(){B(this,ge,"f").closeAll()}};Gn=new WeakMap,Kn=new WeakMap,ge=new WeakMap,ot=new WeakMap,oi=new WeakMap,qi=new WeakMap,ci=new WeakMap,ct=new WeakMap,Gi=new WeakMap,li=new WeakMap;var ms;(function(i){i.LanguageIsNotLoaded="LANGUAGE_IS_NOT_LOADED",i.ExpressionIsNotVerified="EXPRESSION_IS_NOT_VERIFIED",i.AgentIsUntrusted="AGENT_IS_UNTRUSTED",i.CapabilityRequested="CAPABILITY_REQUESTED",i.InstallNotificationRequest="INSTALL_NOTIFICATION_REQUEST"})(ms||(ms={}));var ws=class extends Ke(){};var _s;(function(i){i.Private="PRIVATE",i.NeighboudhoodCreationInitiated="NEIGHBOURHOOD_CREATION_INITIATED",i.NeighbourhoodJoinInitiated="NEIGHBOURHOOD_JOIN_INITIATED",i.LinkLanguageFailedToInstall="LINK_LANGUAGE_FAILED_TO_INSTALL",i.LinkLanguageInstalledButNotSynced="LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",i.Synced="SYNCED"})(_s||(_s={}));var ys=class extends Ke(){};var zl,Wl;zl=new WeakMap,Wl=new WeakMap;function di(i,t){if("predicate"in i)return i.predicate;let{model:e}=i,n=te(e);if(i.field){let r=n[i.field];if(!r)throw new Error(`parent(): field "${i.field}" is not a registered relation on ${e.name}`);return r.predicate}for(let[,r]of Object.entries(n))if(r.target&&r.target()===t)return r.predicate;throw new Error(`parent(): could not resolve predicate \u2014 no relation on ${e.name} targets ${t.name||"the queried class"}`)}function bs(i){if(!i)return"";if(i.includes("://")){let[t,e]=i.split("://"),n=(e||"").replace(/\/+$/,"");return`${t}://${n}`}else return i.replace(/\/+$/,"")}function or(i){if(!!i){if(typeof i=="string")return i;if(Array.isArray(i)&&i.length>0)return i.find(e=>e!=="null")||i[0]}}function da(i,t){return or(i.type)===t}function ua(i){return da(i,"array")}function vs(i){return da(i,"object")}function Hl(i){let t=or(i.type);return t==="number"||t==="integer"}function fa(i,t){if(t.namespace)return t.namespace;if(i["x-ad4m"]?.namespace)return i["x-ad4m"].namespace;if(i.title)return`${i.title.toLowerCase()}://`;if(i.$id)try{let n=new URL(i.$id).pathname.split("/").filter(r=>r);if(n.length>0)return`${n[n.length-1].replace(/\.schema\.json$/,"").replace(/\.json$/,"").toLowerCase()}://`}catch{}throw new Error(`Cannot infer namespace for JSON Schema. Please provide one of:
|
|
1026
85
|
- options.namespace
|
|
1027
86
|
- schema["x-ad4m"].namespace
|
|
1028
87
|
- schema.title
|
|
1029
|
-
- valid schema.$id`)}function
|
|
1030
|
-
${
|
|
1031
|
-
?source ${
|
|
1032
|
-
?source ${
|
|
1033
|
-
?source ${
|
|
1034
|
-
?source ${
|
|
1035
|
-
{ SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${
|
|
1036
|
-
`),
|
|
1037
|
-
${
|
|
88
|
+
- valid schema.$id`)}function ha(i,t,e,n,r){if(r.propertyMapping?.[t])return r.propertyMapping[t];if(e["x-ad4m"]?.through)return e["x-ad4m"].through;if(r.predicateTemplate){let a=bs(n),[o,l]=a.includes("://")?a.split("://"):["",a],c=l||"";return r.predicateTemplate.replace("${namespace}",c).replace("${scheme}",o).replace("${ns}",c).replace("${title}",i.title||"").replace("${property}",t)}if(r.predicateGenerator)return r.predicateGenerator(i.title||"",t);let s=bs(n);return s.includes("://")?`${s}${t}`:`${s}://${t}`}function jt(i,t,e,n,r){return e.propertyOptions?.[i]?.[n]!==void 0?e.propertyOptions[i][n]:t["x-ad4m"]?.[n]!==void 0?t["x-ad4m"][n]:e[n]!==void 0?e[n]:r}function Bl(i){switch(i){case"string":return"";case"number":return 0;case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function Zl(i,t,e){if(t?.properties&&Object.prototype.hasOwnProperty.call(t.properties,"author"))throw new Error('JSON Schema must not define a top-level "author" property because Ad4mModel already exposes it. Please rename the property (e.g., "writer").');let n=fa(t,e),r=class extends i{};if(!e.name||e.name.trim()==="")throw new Error("options.name is required and cannot be empty");r.className=e.name,r.prototype.className=e.name;let s={},a={};if(t.properties)for(let[l,c]of Object.entries(t.properties)){let d=ha(t,l,c,n,e),g=t.required?.includes(l)||!1,p=or(c.type);if(ua(c)){a[l]={through:d,local:jt(l,c,e,"local")},Object.defineProperty(r.prototype,l,{configurable:!0,writable:!0,value:[]});let f=`add${Ui(l)}`,h=`remove${Ui(l)}`,w=`set${Ui(l)}`;r.prototype[f]=function(){},r.prototype[h]=function(){},r.prototype[w]=function(){}}else{let f=jt(l,c,e,"resolveLanguage");!f&&e.resolveLanguage&&(f=e.resolveLanguage);let h=jt(l,c,e,"local"),w=jt(l,c,e,"readOnly");if(w===void 0){let S=c["x-ad4m"]?.writable;w=S!==void 0?!S:!1}let y=!w,v=jt(l,c,e,"initial");if(vs(c)&&!f&&(f="literal",console.warn(`Property "${l}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`)),f==null&&Hl(c)&&(f="literal"),f==null&&(f="literal"),g&&!v&&(vs(c)?v="literal:json:{}":v="ad4m://undefined"),s[l]={through:d,required:g,writable:y,...f&&{resolveLanguage:f},...h!==void 0&&{local:h},...v&&{initial:v}},Object.defineProperty(r.prototype,l,{configurable:!0,writable:!0,value:Bl(p)}),y){let S=Yn(l);r.prototype[S]=function(){}}}}for(let[l,c]of Object.entries(s))$n(r,l,c);for(let[l,c]of Object.entries(a))xs(r,l,{predicate:c.through||"",kind:"hasMany",...c.getter!==void 0&&{getter:c.getter},...c.local!==void 0&&{local:c.local}});return r.prototype.__jsonSchema=t,r.prototype.__jsonSchemaOptions=e,As({name:e.name})(r),r}function Jl(i,t,e){if(!e)return!1;for(let[n,r]of Object.entries(e)){if(n==="base"||n==="id")continue;if(n==="author"||n==="timestamp")return!0;let s=i.properties[n];if(!s)continue;let a=t[n];if(a&&(a.kind==="belongsToOne"||a.kind==="belongsToMany"))return!0;if(pa(s)&&typeof r=="object"&&r!==null&&!Array.isArray(r)){let o=r;if(o.gt!==void 0||o.gte!==void 0||o.lt!==void 0||o.lte!==void 0||o.between!==void 0||o.contains!==void 0)return!0}}return!1}function pa(i){return!(i.flag||i.resolveLanguage&&i.resolveLanguage!=="literal")}function Ql(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Mi(i){return typeof i=="string"?`"${Ql(i)}"`:`"${String(i)}"`}function W(i){return`<${i}>`}function ql(i,t){let e=t.properties[i];if(e){if(e.required&&!e.getter&&!(e.flag&&e.initial))return`?cfTarget_${i}`;if(e.initial&&!e.flag)return`?cfInitTarget_${i}`}return`?wTarget_${i}`}function Gl(i,t,e,n){let r=[],s=[];if(e.parent){let u=di(e.parent,n);r.push(`
|
|
89
|
+
${W(e.parent.id)} ${W(u)} ?source .`)}let a=!1;for(let[,u]of Object.entries(i.properties))if(u.required){if(u.getter)continue;a=!0,u.flag&&u.initial?r.push(`
|
|
90
|
+
?source ${W(u.predicate)} ${W(u.initial)} .`):r.push(`
|
|
91
|
+
?source ${W(u.predicate)} ?cfTarget_${u.name} .`)}if(!a){for(let[,u]of Object.entries(i.properties))if(u.initial){a=!0,u.flag?r.push(`
|
|
92
|
+
?source ${W(u.predicate)} ${W(u.initial)} .`):r.push(`
|
|
93
|
+
?source ${W(u.predicate)} ?cfInitTarget_${u.name} .`);break}}if(!a&&r.length===0){let u=[];for(let[,f]of Object.entries(i.properties))f.predicate&&u.push(W(f.predicate));if(i.relations)for(let[,f]of Object.entries(i.relations))f.predicate&&u.push(W(f.predicate));u.length>0&&r.push(`
|
|
94
|
+
{ SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${u.join(", ")})) } }`)}let{joins:o,filters:l}=Xl(i,t,e.where);r.push(...o),s.push(...l);let c=r.join(`
|
|
95
|
+
`),d=s.length>0?`FILTER(
|
|
96
|
+
${s.join(` &&
|
|
1038
97
|
`)}
|
|
1039
|
-
)`:"",p=!
|
|
98
|
+
)`:"",p=!Jl(i,t,e.where)&&(e.limit!==void 0||e.offset!==void 0)?Vl(r,s,i,e):"";return p?`
|
|
99
|
+
|
|
1040
100
|
SELECT ?source ?predicate ?target ?author ?timestamp WHERE {
|
|
1041
|
-
${p}${
|
|
1042
|
-
|
|
101
|
+
${p}${c}
|
|
102
|
+
?source ?predicate ?target .
|
|
103
|
+
?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>> .
|
|
1043
104
|
FILTER(isIRI(?source) && isIRI(?predicate))
|
|
1044
|
-
?
|
|
1045
|
-
?
|
|
1046
|
-
${
|
|
105
|
+
?_reifier <ad4m://ontology/author> ?author .
|
|
106
|
+
?_reifier <ad4m://ontology/timestamp> ?timestamp .
|
|
107
|
+
${d}
|
|
1047
108
|
}
|
|
1048
109
|
`.trim():`
|
|
1049
|
-
|
|
1050
|
-
|
|
110
|
+
|
|
111
|
+
SELECT ?source ?predicate ?target ?author ?timestamp WHERE {${c}
|
|
112
|
+
?source ?predicate ?target .
|
|
113
|
+
?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>> .
|
|
1051
114
|
FILTER(isIRI(?source) && isIRI(?predicate))
|
|
1052
|
-
?
|
|
1053
|
-
?
|
|
1054
|
-
${
|
|
115
|
+
?_reifier <ad4m://ontology/author> ?author .
|
|
116
|
+
?_reifier <ad4m://ontology/timestamp> ?timestamp .
|
|
117
|
+
${d}
|
|
1055
118
|
}
|
|
1056
|
-
${
|
|
1057
|
-
`.trim()}function
|
|
1058
|
-
`),
|
|
1059
|
-
${
|
|
119
|
+
${Kl()}
|
|
120
|
+
`.trim()}function Kl(i,t){return""}function Vl(i,t,e,n){let r=i.join(`
|
|
121
|
+
`),s=t.length>0?`FILTER(
|
|
122
|
+
${t.join(` &&
|
|
1060
123
|
`)}
|
|
1061
|
-
)`:"",
|
|
1062
|
-
OPTIONAL { ?source <${
|
|
1063
|
-
{ SELECT DISTINCT ?source${
|
|
124
|
+
)`:"",a="",o=[];if(n.order){let p=Object.entries(n.order).map(([u,f])=>{let h=ql(u,e);if(!r.includes(h)){let y=e.properties[u];y&&y.predicate&&!y.getter&&o.push(`
|
|
125
|
+
OPTIONAL { ?source <${y.predicate}> ${h} . }`)}return f==="DESC"?`DESC(${h})`:`ASC(${h})`});p.length>0&&(a=`ORDER BY ${p.join(" ")}`)}let l="",c="",d=n.limit!==void 0?`LIMIT ${n.limit}`:"",g=n.offset!==void 0&&n.offset>0?`OFFSET ${n.offset}`:"";return`
|
|
126
|
+
{ SELECT DISTINCT ?source${l} WHERE {${r}${o.join("")}${c}
|
|
1064
127
|
FILTER(isIRI(?source))
|
|
1065
|
-
${
|
|
1066
|
-
}
|
|
1067
|
-
`}function
|
|
1068
|
-
${
|
|
1069
|
-
?source ${
|
|
1070
|
-
?source ${
|
|
1071
|
-
?source ${
|
|
1072
|
-
?source ${
|
|
1073
|
-
{ SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${d.join(", ")})) } }`)}let{joins:s,filters:c}=Cl(r,e,t.where);i.push(...s),a.push(...c);let u=i.join(`
|
|
1074
|
-
`),l=a.length>0?`FILTER(
|
|
1075
|
-
${a.join(` &&
|
|
1076
|
-
`)}
|
|
1077
|
-
)`:"";return`
|
|
1078
|
-
SELECT (COUNT(DISTINCT ?source) AS ?count) WHERE {${u}
|
|
1079
|
-
FILTER(isIRI(?source))
|
|
1080
|
-
${l}
|
|
1081
|
-
}
|
|
1082
|
-
`.trim()}function qS(r){return`
|
|
1083
|
-
SELECT ?source ?predicate ?target ?author ?timestamp WHERE {
|
|
1084
|
-
GRAPH ?linkGraph { ${G(r)} ?predicate ?target . }
|
|
1085
|
-
FILTER(isIRI(?predicate))
|
|
1086
|
-
BIND(${G(r)} AS ?source)
|
|
1087
|
-
?linkGraph <ad4m://ontology/author> ?author .
|
|
1088
|
-
?linkGraph <ad4m://ontology/timestamp> ?timestamp .
|
|
1089
|
-
}
|
|
1090
|
-
`.trim()}function qa(r){let e=new Map;for(let t of r){let n=t.source;e.has(n)||e.set(n,[]),e.get(n).push({predicate:t.predicate,target:t.target,author:t.author,timestamp:t.timestamp})}return Array.from(e.entries()).map(([t,n])=>({source_uri:t,links:n}))}function Cl(r,e,t){if(!t)return{joins:[],filters:[]};let n=[],i=[];for(let[a,o]of Object.entries(t)){if(a==="base"||a==="id"){if(Array.isArray(o)){let l=o.map(d=>G(d)).join(", ");i.push(`?source IN (${l})`)}else if(typeof o=="object"&&o!==null){let l=o;if(l.not!==void 0)if(Array.isArray(l.not)){let d=l.not.map(p=>G(p)).join(", ");i.push(`!(?source IN (${d}))`)}else i.push(`?source != ${G(l.not)}`)}else i.push(`?source = ${G(String(o))}`);continue}if(a==="author"){if(Array.isArray(o)){let l=o.map(d=>Ur(String(d))).join(", ");i.push(`STR(?author) IN (${l})`)}else if(typeof o=="object"&&o!==null){let l=o;if(l.not!==void 0)if(Array.isArray(l.not)){let d=l.not.map(p=>Ur(String(p))).join(", ");i.push(`!(STR(?author) IN (${d}))`)}else i.push(`STR(?author) != ${Ur(String(l.not))}`)}else i.push(`STR(?author) = ${Ur(String(o))}`);continue}if(a==="timestamp"){if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let l=o;l.gt!==void 0&&i.push(`?timestamp > ${Number(l.gt)}`),l.gte!==void 0&&i.push(`?timestamp >= ${Number(l.gte)}`),l.lt!==void 0&&i.push(`?timestamp < ${Number(l.lt)}`),l.lte!==void 0&&i.push(`?timestamp <= ${Number(l.lte)}`),l.between!==void 0&&Array.isArray(l.between)&&i.push(`?timestamp >= ${Number(l.between[0])} && ?timestamp <= ${Number(l.between[1])}`),l.not!==void 0&&i.push(`?timestamp != ${Number(l.not)}`)}else(typeof o=="number"||typeof o=="string"&&!isNaN(Number(o)))&&i.push(`?timestamp = ${Number(o)}`);continue}let s=r.properties[a];if(!s)continue;let c=e[a];if(c&&(c.kind==="belongsToOne"||c.kind==="belongsToMany"))continue;if(um(s))if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let l=o;if((l.gt!==void 0||l.gte!==void 0||l.lt!==void 0||l.lte!==void 0||l.between!==void 0||l.contains!==void 0)&&n.push(`
|
|
1091
|
-
?source ${G(s.predicate)} ?wTarget_cmp_${a} .`),l.not!==void 0)if(n.push(`
|
|
1092
|
-
?source ${G(s.predicate)} ?wTarget_${a} .`),Array.isArray(l.not)){let p=l.not.map(f=>Ur(f)).join(", ");i.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${a})) NOT IN (${p})`)}else i.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${a})) != ${Ur(l.not)}`)}else if(Array.isArray(o)){n.push(`
|
|
1093
|
-
?source ${G(s.predicate)} ?wTarget_${a} .`);let l=o.map(d=>Ur(d)).join(", ");i.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${a})) IN (${l})`)}else n.push(`
|
|
1094
|
-
?source ${G(s.predicate)} ?wTarget_${a} .`),i.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${a})) = ${Ur(o)}`);else if(Array.isArray(o)){let l=o.map(d=>G(d)).join(", ");n.push(`
|
|
1095
|
-
?source ${G(s.predicate)} ?wTarget_${a} .`),i.push(`?wTarget_${a} IN (${l})`)}else if(typeof o=="object"&&o!==null){let l=o;if(l.not!==void 0)if(Array.isArray(l.not)){let p=l.not.map(f=>G(f)).join(", ");i.push(`
|
|
128
|
+
${s}
|
|
129
|
+
} GROUP BY ?source ${a} ${d} ${g} }
|
|
130
|
+
`}function Xl(i,t,e){if(!e)return{joins:[],filters:[]};let n=[],r=[];for(let[s,a]of Object.entries(e)){if(s==="base"||s==="id"){if(Array.isArray(a)){let d=a.map(g=>W(g)).join(", ");r.push(`?source IN (${d})`)}else if(typeof a=="object"&&a!==null){let d=a;if(d.not!==void 0)if(Array.isArray(d.not)){let g=d.not.map(p=>W(p)).join(", ");r.push(`!(?source IN (${g}))`)}else r.push(`?source != ${W(d.not)}`)}else r.push(`?source = ${W(String(a))}`);continue}if(s==="author"||s==="timestamp")continue;let o=i.properties[s];if(!o)continue;let l=t[s];if(l&&(l.kind==="belongsToOne"||l.kind==="belongsToMany"))continue;if(pa(o))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let d=a;if((d.gt!==void 0||d.gte!==void 0||d.lt!==void 0||d.lte!==void 0||d.between!==void 0||d.contains!==void 0)&&n.push(`
|
|
131
|
+
?source ${W(o.predicate)} ?wTarget_cmp_${s} .`),d.not!==void 0)if(n.push(`
|
|
132
|
+
?source ${W(o.predicate)} ?wTarget_${s} .`),Array.isArray(d.not)){let p=d.not.map(u=>Mi(u)).join(", ");r.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${s})) NOT IN (${p})`)}else r.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${s})) != ${Mi(d.not)}`)}else if(Array.isArray(a)){n.push(`
|
|
133
|
+
?source ${W(o.predicate)} ?wTarget_${s} .`);let d=a.map(g=>Mi(g)).join(", ");r.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${s})) IN (${d})`)}else n.push(`
|
|
134
|
+
?source ${W(o.predicate)} ?wTarget_${s} .`),r.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${s})) = ${Mi(a)}`);else if(Array.isArray(a)){let d=a.map(g=>W(g)).join(", ");n.push(`
|
|
135
|
+
?source ${W(o.predicate)} ?wTarget_${s} .`),r.push(`?wTarget_${s} IN (${d})`)}else if(typeof a=="object"&&a!==null){let d=a;if(d.not!==void 0)if(Array.isArray(d.not)){let p=d.not.map(u=>W(u)).join(", ");r.push(`
|
|
1096
136
|
NOT EXISTS {
|
|
1097
|
-
?source ${
|
|
1098
|
-
FILTER(?wTarget_not_${
|
|
137
|
+
?source ${W(o.predicate)} ?wTarget_not_${s} .
|
|
138
|
+
FILTER(?wTarget_not_${s} IN (${p}))
|
|
1099
139
|
}
|
|
1100
|
-
`)}else
|
|
140
|
+
`)}else r.push(`
|
|
1101
141
|
NOT EXISTS {
|
|
1102
|
-
?source ${
|
|
142
|
+
?source ${W(o.predicate)} ${W(d.not)} .
|
|
1103
143
|
}
|
|
1104
|
-
`);(
|
|
1105
|
-
?source ${
|
|
1106
|
-
?source ${G(s.predicate)} ${G(String(o))} .`)}return{joins:n,filters:i}}function hl(r){if(!Array.isArray(r)||r.length===0)return null;let e=r[0],t=e.count?.value??e.count;if(t==null)return null;let n=typeof t=="number"?t:parseInt(String(t),10);return isNaN(n)?null:n}function BS(r,e,t,n,i){let a=[],o=[];a.push(`
|
|
1107
|
-
?parent ${G(t)} ?source .`);let s=n.map(f=>G(f)).join(", ");o.push(`?parent IN (${s})`);let c=!1;for(let[,f]of Object.entries(r.properties))if(f.required){if(f.getter)continue;c=!0,f.flag&&f.initial?a.push(`
|
|
1108
|
-
?source ${G(f.predicate)} ${G(f.initial)} .`):a.push(`
|
|
1109
|
-
?source ${G(f.predicate)} ?cfTarget_${f.name} .`)}if(!c){for(let[,f]of Object.entries(r.properties))if(f.initial){c=!0,f.flag?a.push(`
|
|
1110
|
-
?source ${G(f.predicate)} ${G(f.initial)} .`):a.push(`
|
|
1111
|
-
?source ${G(f.predicate)} ?cfInitTarget_${f.name} .`);break}}if(!c&&a.length<=1){let f=[];for(let[,h]of Object.entries(r.properties))h.predicate&&f.push(G(h.predicate));if(r.relations)for(let[,h]of Object.entries(r.relations))h.predicate&&f.push(G(h.predicate));f.length>0&&a.push(`
|
|
1112
|
-
{ SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${f.join(", ")})) } }`)}let{joins:u,filters:l}=Cl(r,e,i);a.push(...u),o.push(...l);let d=a.join(`
|
|
1113
|
-
`),p=o.length>0?`FILTER(
|
|
1114
|
-
${o.join(` &&
|
|
1115
|
-
`)}
|
|
1116
|
-
)`:"";return`
|
|
1117
|
-
SELECT ?parent (COUNT(DISTINCT ?source) AS ?count) WHERE {${d}
|
|
1118
|
-
GRAPH ?linkGraph { ?source ?predicate ?target . }
|
|
1119
|
-
FILTER(isIRI(?source) && isIRI(?predicate))
|
|
1120
|
-
?linkGraph <ad4m://ontology/author> ?author .
|
|
1121
|
-
?linkGraph <ad4m://ontology/timestamp> ?timestamp .
|
|
1122
|
-
${p}
|
|
1123
|
-
}
|
|
1124
|
-
GROUP BY ?parent
|
|
1125
|
-
`.trim()}function VS(r){let e=new Map;if(!Array.isArray(r))return e;for(let t of r){let n=t.parent?.value??t.parent,i=t.count?.value??t.count;if(!n||i===void 0||i===null)continue;let a=typeof i=="number"?i:parseInt(String(i),10);isNaN(a)||e.set(String(n),a)}return e}var Qn=new Map;function QS(r,e){return`${r}::${e}`}async function zS(r,e,t,n){let i=r.uuid||r.handle?.uuid||"",a=QS(i,e),o=Qn.get(a),s={onResult:n,hydrate:t};if(o){o.callbacks.add(s),o.refCount++;let d;return o.latestHydrated!==void 0?d=o.latestHydrated:o.latestRaw!==void 0&&(d=await t(o.latestRaw)),{initialResult:d,dispose:()=>eh(a,s)}}let c=await r.subscribeQuery(e),u={subscription:c,callbacks:new Set([s]),latestRaw:c.result,latestHydrated:void 0,hydrating:!1,refCount:1};Qn.set(a,u),c.onResult(async d=>{let p=u.latestRaw;u.latestRaw=d,u.hydrating=!0;try{let f=u.callbacks.values().next().value;if(f){let h=Array.isArray(p)?p:[],m=Array.isArray(d)?d:[],g=u.latestHydrated;if(g&&Array.isArray(g)&&m.length>h.length&&m.length-h.length<=5){let w=new Set(h.map(A=>`${A.source}|${A.predicate}|${A.target}`)),y=m.filter(A=>!w.has(`${A.source}|${A.predicate}|${A.target}`)),b=new Set(m.map(A=>`${A.source}|${A.predicate}|${A.target}`));if(h.filter(A=>!b.has(`${A.source}|${A.predicate}|${A.target}`)).length===0&&y.length>0){let A=new Set(h.map(R=>R.source));if(y.every(R=>!A.has(R.source)))try{let R=await f.hydrate(y);if(Array.isArray(R)){let L=[...g,...R];u.latestHydrated=L;for(let N of u.callbacks)try{N.onResult(L)}catch{}return}}catch{}}}let _=await f.hydrate(d);u.latestHydrated=_;for(let w of u.callbacks)try{w.onResult(_)}catch{}}}finally{u.hydrating=!1}});let l=await t(c.result);return u.latestHydrated=l,{initialResult:l,dispose:()=>eh(a,s)}}function eh(r,e){let t=Qn.get(r);!t||(t.callbacks.delete(e),t.refCount--,t.refCount<=0&&(t.subscription?.dispose&&t.subscription.dispose(),Qn.delete(r)))}function HA(){for(let r of Qn.values())r.subscription?.dispose&&r.subscription.dispose();Qn.clear()}function WA(){return Qn.size}var ml=class{constructor(e,t,n){this.queryParams={},this.modelClassName=null,this.engineFlag="sparql",this.perspective=e,this.ctor=t,n&&(this.queryParams=n)}dispose(){this.currentSubscription&&(this.currentSubscription.dispose(),this.currentSubscription=void 0)}where(e){return this.queryParams.where=e,this}order(e){return this.queryParams.order=e,this}limit(e){return this.queryParams.limit=e,this}offset(e){return this.queryParams.offset=e,this}parent(e,t,n){let i=typeof e=="string"?e:e.id;if(typeof t=="object"&&t!==null&&!("prototype"in t)){if(typeof e=="string")throw new Error("parent() called with a string id and options object requires a model class as second argument");let o=e.constructor;return this.queryParams.parent={id:i,model:o,field:t.field},this}let a=n?.field;if(typeof t=="string")this.queryParams.parent={id:i,predicate:t};else if(typeof t=="function")this.queryParams.parent={id:i,model:t,...a&&{field:a}};else if(typeof e!="string")this.queryParams.parent={id:i,model:e.constructor,...a&&{field:a}};else throw new Error("parent() called with a string id requires a second argument: either a model class or a predicate string");return this}properties(e){return this.queryParams.properties=e,this}deepQuery(){return this.queryParams.deepQuery=!0,this}include(e){return this.queryParams.include=e,this}overrideModelClassName(e){return this.modelClassName=e,this}engine(e){return this.engineFlag=e,this}async get(){let e;if(this.engineFlag==="sparql")e=await this.executeSparqlQuery();else{let t=await this.ctor.queryToProlog(this.perspective,this.queryParams,this.modelClassName),n=await this.perspective.infer(t);({results:e}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,n))}return e}async getSparql(){return this.executeSparqlQuery()}async executeSparqlQuery(){let e=await this.ctor.queryToSPARQL(this.perspective,this.queryParams),t=await this.perspective.querySparql(e),{results:n}=await this.processSparqlResult(t);return n}async processSparqlResult(e,t,n=!1){let i=qa(Array.isArray(e)?e:[]);return await this.ctor.instancesFromQueryResult(this.perspective,t||this.queryParams,i,n)}async first(){return this.queryParams.limit=1,(await this.get())[0]??null}async subscribe(e){this.dispose();let t=this.ctor;if(this.engineFlag==="sparql"){let n=await t.queryToSPARQL(this.perspective,this.queryParams),i=null,a=u=>u.length===0?"0:":JSON.stringify(u,(l,d)=>typeof d=="function"?void 0:d),o=async u=>{let{results:l}=await this.processSparqlResult(u);return l},s=await zS(this.perspective,n,o,u=>{let l=a(u);l!==i&&(i=l,e(u))});this.currentSubscription={dispose:s.dispose};let c=s.initialResult;return i=a(c),c}else{let n=await t.queryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(n);let i=async o=>{let{results:s}=await t.instancesFromPrologResult(this.perspective,this.queryParams,o);e(s)};this.currentSubscription.onResult(i);let{results:a}=await t.instancesFromPrologResult(this.perspective,this.queryParams,this.currentSubscription.result);return a}}async subscribeSparql(e){this.dispose();let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let n=async a=>{let{results:o}=await this.processSparqlResult(a);e(o)};this.currentSubscription.onResult(n);let{results:i}=await this.processSparqlResult(this.currentSubscription.result);return i}async count(){if(this.engineFlag==="sparql"){let e=this.ctor.getModelMetadata(),t=ht(this.ctor);if(Js(e,t,this.queryParams.where)){let a=await this.ctor.queryToSPARQL(this.perspective,this.queryParams),o=await this.perspective.querySparql(a),{totalCount:s}=await this.processSparqlResult(o,void 0,!0);return s}let n=await this.ctor.countQueryToSPARQL(this.perspective,this.queryParams),i=await this.perspective.querySparql(n);return hl(i)??0}else{let e=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);return(await this.perspective.infer(e))?.[0]?.TotalCount||0}}async countSparql(){let e=this.engineFlag;this.engineFlag="sparql";try{return await this.count()}finally{this.engineFlag=e}}async countSubscribe(e){if(this.dispose(),this.engineFlag==="sparql"){let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let n=async a=>{let{totalCount:o}=await this.processSparqlResult(a,void 0,!0);e(o)};this.currentSubscription.onResult(n);let{totalCount:i}=await this.processSparqlResult(this.currentSubscription.result,void 0,!0);return i}else{let t=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(t);let n=async a=>{let o=a?.[0]?.TotalCount||0;e(o)};return this.currentSubscription.onResult(n),this.currentSubscription.result?.[0]?.TotalCount||0}}async countSubscribeSparql(e){this.dispose();let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let n=async a=>{let{totalCount:o}=await this.processSparqlResult(a,void 0,!0);e(o)};this.currentSubscription.onResult(n);let{totalCount:i}=await this.processSparqlResult(this.currentSubscription.result,void 0,!0);return i}async paginate(e,t){let n={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.engineFlag==="sparql"){let i=await this.ctor.queryToSPARQL(this.perspective,n),a=await this.perspective.querySparql(i),{results:o,totalCount:s}=await this.processSparqlResult(a,n,!0);return{results:o,totalCount:s,pageSize:e,pageNumber:t}}else{let i=await this.ctor.queryToProlog(this.perspective,n,this.modelClassName),a=await this.perspective.infer(i),{results:o,totalCount:s}=await this.ctor.instancesFromPrologResult(this.perspective,n,a);return{results:o,totalCount:s,pageSize:e,pageNumber:t}}}async paginateSparql(e,t){let n=this.engineFlag;this.engineFlag="sparql";try{return await this.paginate(e,t)}finally{this.engineFlag=n}}async paginateSubscribe(e,t,n){this.dispose();let i={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.engineFlag==="sparql"){let a={...this.queryParams||{}};delete a.limit,delete a.offset;let o=await this.ctor.queryToSPARQL(this.perspective,a);this.currentSubscription=await this.perspective.subscribeQuery(o);let s={...this.queryParams||{},count:!0},c=async h=>{let{results:m,totalCount:g}=await this.processSparqlResult(h,s,!0),_=e*(t-1),w=m.slice(_,_+e);n({results:w,totalCount:g,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(c);let{results:u,totalCount:l}=await this.processSparqlResult(this.currentSubscription.result,s,!0),d=e*(t-1);return{results:u.slice(d,d+e),totalCount:l,pageSize:e,pageNumber:t}}else{let a=await this.ctor.queryToProlog(this.perspective,i,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(a);let o=async l=>{let{results:d,totalCount:p}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,l);n({results:d,totalCount:p,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(o);let{results:s,totalCount:c}=await this.ctor.instancesFromPrologResult(this.perspective,i,this.currentSubscription.result);return{results:s,totalCount:c,pageSize:e,pageNumber:t}}}async paginateSubscribeSparql(e,t,n){let i=this.engineFlag;this.engineFlag="sparql";try{return await this.paginateSubscribe(e,t,n)}finally{this.engineFlag=i}}};function ya(r){return Array.isArray(r)?r.map(e=>e&&typeof e=="object"&&typeof e.id=="string"?e.id:e):r}function Uu(r,e){if(Array.isArray(e))return e.includes(r);if(typeof e=="object"&&e!==null){let t=e;if(t.not!==void 0)return Array.isArray(t.not)?!t.not.includes(r):r!==t.not;if(t.between!==void 0&&Array.isArray(t.between)&&t.between.length===2)return r>=t.between[0]&&r<=t.between[1];let n=!0;return t.gt!==void 0&&(n=n&&r>t.gt),t.gte!==void 0&&(n=n&&r>=t.gte),t.lt!==void 0&&(n=n&&r<t.lt),t.lte!==void 0&&(n=n&&r<=t.lte),t.contains!==void 0&&(typeof r=="string"?n=n&&r.includes(String(t.contains)):Array.isArray(r)?n=n&&r.includes(t.contains):n=!1),n}return r===e}async function HS(r,e,t,n){let i=r;if(r!=null&&r!=="")if(e.resolveLanguage!=null&&e.resolveLanguage!=="literal"&&typeof r=="string"&&!r.startsWith("literal:"))try{let a=await t.getExpression(r);if(a)try{i=JSON.parse(a.data)}catch{i=a.data}}catch(a){console.warn(`hydratePropertyValue: failed to resolve expression for "${e.name}":`,a)}else if(e.resolveLanguage==="literal"&&typeof r=="string"&&r.startsWith("literal:"))try{let a=be.fromUrl(r).get();i=a.data!==void 0?a.data:a}catch{}else typeof r=="string"&&n&&(n==="number"?i=Number(r):n==="boolean"&&(i=r==="true"||r==="1"));return e.transform&&typeof e.transform=="function"&&(i=e.transform(i)),i}async function th(r,e,t,n,i){if(!e||e.length===0)return;let a=null,o=null,s=null,c=i&&i.length>0?new Set(i):null,u=new Map;for(let[h,m]of Object.entries(t.properties))m.getter||c&&!c.has(h)||u.set(m.predicate,[h,m]);let l=new Map,d=[];for(let[h,m]of Object.entries(t.relations))if(!m.getter){if(m.target&&m.filter!==!1){d.push([h,m]);continue}l.set(m.predicate,[h,m])}for(let[h,m]of d)l.has(m.predicate)||l.set(m.predicate,[h,m]);let p=new Map,f=new Map;for(let h=0;h<e.length;h++){let m=e[h],{predicate:g,target:_,author:w,timestamp:y}=m;if(_==="None"||_===void 0||_===null)continue;y!=null&&((a==null||y<a)&&(a=y,s=w??null),(o==null||y>o)&&(o=y));let b=u.get(g);if(b){p.get(b[0]),p.set(b[0],{target:_,timestamp:y});continue}let I=l.get(g);if(I){let[A]=I,E=f.get(A);E||(E=[],f.set(A,E)),E.push({target:_,timestamp:y??"",index:h})}}for(let[h,{target:m}]of p){let[,g]=u.get(t.properties[h].predicate),_=typeof r[h];r[h]=await HS(m,g,n,_!=="undefined"?_:void 0)}for(let[h,m]of f)m.sort((g,_)=>{let w=String(g.timestamp).localeCompare(String(_.timestamp));return w!==0?w:g.index-_.index}),r[h]=m.map(g=>g.target).filter(g=>g!=null&&g!==""&&g!=="None");s&&(r.author=s),a!=null&&(r.createdAt=typeof a=="string"&&a.includes("T")?new Date(a).getTime():typeof a=="string"?isNaN(parseInt(a,10))?a:parseInt(a,10):a),o!=null&&(r.updatedAt=typeof o=="string"&&o.includes("T")?new Date(o).getTime():typeof o=="string"?isNaN(parseInt(o,10))?o:parseInt(o,10):o)}async function WS(r,e,t){let n=Object.fromEntries(await Promise.all(t.map(async([a,o,s])=>{let c=o;if(!s&&typeof o=="string"){let d=Array.from(o,h=>h.codePointAt(0)),p=d.every(h=>h<=255),f=d.some(h=>h>=128);if(p&&f)try{let h=Uint8Array.from(d),m=new TextDecoder("utf-8",{fatal:!0}).decode(h);m!==o&&(c=m)}catch(h){console.warn(`UTF-8 byte reconstruction failed for property "${a}"`,{value:o,error:h})}}if(s){let d=await r.getExpression(o);if(d)try{c=JSON.parse(d.data)}catch{c=d.data}}let l=Un(e.constructor)[a]?.transform;return l&&typeof l=="function"&&(c=l(c)),[a,c]}))),i=Object.fromEntries(Object.entries(n).filter(([a])=>{let o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);return o?o.get!==void 0||o.set!==void 0?o.set!==void 0:o.writable!==!1:!0}));Object.assign(e,i)}function GS(r,e){let t=vh(r,e);if(!t){let n=e?.prototype?.className||e?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${n}".`);return}return t.getter}async function ju(r,e,t,n){`${r.id}`;let a=n?.requestedProperties&&n.requestedProperties.length>0?new Set(n.requestedProperties):null;if(!n?.skipPropertyGetters){for(let[o,s]of Object.entries(t.properties))if(!(a&&!a.has(o))&&s.getter)try{let c=s.getter,u=c.replace(/\?source\b/g,`<${r.id}>`).replace(/<Base>/g,`<${r.id}>`).replace(/Base/g,`<${r.id}>`),l=u.trim().toUpperCase();if(l.startsWith("SELECT")||l.startsWith("ASK")||l.startsWith("CONSTRUCT")){let d=await e.querySparql(u);if(l.startsWith("ASK"))r[o]=d===!0||d==="true";else if(d&&d.length>0){let p=d[0],f=Object.keys(p)[0],h=p[f]?.value??p[f];h!=null&&h!=="None"&&h!==""&&(r[o]=h)}}else console.warn(`Unsupported legacy getter syntax for property ${o} \u2014 use native SPARQL (SELECT/ASK): ${c.slice(0,100)}`)}catch(c){console.warn(`Failed to evaluate getter for ${o}:`,c)}}for(let[o,s]of Object.entries(t.relations)){if(a&&!a.has(o)&&!(n?.include&&o in n.include))continue;let c=s,u=c.getter;if(!u&&c.where&&c.direction!=="reverse")try{let d=c.target?.(),p=d?d.getModelMetadata?.()??null:null,f=!0;if(p)for(let h of Object.keys(c.where)){if(["id","author","timestamp"].includes(h))continue;let m=p.properties[h];if(m&&(!m.resolveLanguage||m.resolveLanguage==="literal")){f=!1;break}}else f=!1;if(f){let h=yh(c.where,p);h.length>0&&(u=`SELECT ?target WHERE { <Base> <${vr(c.predicate)}> ?target . ${h.join(" ")} }`)}}catch(d){console.warn(`[Ad4mModel] where-clause compilation failed for relation "${o}":`,d)}if(!u&&c.target&&c.filter!==!1&&c.direction!=="reverse")try{let d=c.target();u=GS(c.predicate,d),u||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${o}" (predicate: "${c.predicate}")`)}catch(d){console.warn(`[Ad4mModel] auto-generation failed for relation "${o}":`,d)}if(u)try{let d=u.replace(/\?source\b/g,`<${r.id}>`).replace(/<Base>/g,`<${r.id}>`).replace(/\bBase\b/g,`<${r.id}>`),p=d.trim().toUpperCase();if(p.startsWith("SELECT")||p.startsWith("ASK")||p.startsWith("CONSTRUCT")){let f=await e.querySparql(d);if(f&&f.length>0){let h=f.map(m=>{let g=Object.keys(m)[0];return m[g]?.value??m[g]}).filter(m=>m!=null&&m!==""&&m!=="None");r[o]=h}}else console.warn(`Unsupported legacy getter syntax for relation ${o} \u2014 use native SPARQL (SELECT/ASK): ${u.slice(0,100)}`)}catch(d){console.warn(`Failed to evaluate getter for ${o}:`,d)}let l=r[o];if(c.where&&Array.isArray(l)&&l.length>0){let d=c.target?.();if(d){let p=[];for(let f of l)try{let h=new d(e,f);await h.get();let m=!0;for(let[g,_]of Object.entries(c.where))if(h[g]!==_){m=!1;break}m&&p.push(f)}catch{p.push(f)}r[o]=p}}}}async function Ha(r,e,t,n){if(!n||Object.keys(n).length===0)return;let i=ht(r),a=[];for(let[o,s]of Object.entries(n))o.startsWith("$")&&s!==null&&typeof s=="object"&&"from"in s&&a.push([o,s]);for(let[o,s]of a){let c=i[s.from];if(!c){console.warn(`include projection "${o}": relation "${s.from}" not found in metadata, skipping`);for(let d of e)d[o]=s.count?0:[];continue}let u=c.target(),l=e.map(d=>d.id).filter(Boolean);if(s.count){let d=u.getModelMetadata?.()??null,p=u.getAllRelationsMetadata?.()??{},f=new Map;if(d&&l.length>0)try{let h=BS(d,p,c.predicate,l,s.where),m=await t.querySparql(h),g=Array.isArray(m)?m:m?.results?.bindings??m?.bindings??[];f=VS(g)}catch(h){console.warn(`include projection "${o}" count query failed, falling back to 0:`,h)}for(let h of e)h[o]=f.get(h.id)??0}else if(c.kind==="belongsToOne"||c.kind==="belongsToMany")if(l.length>0){let p=`SELECT ?source ?target WHERE {
|
|
1126
|
-
GRAPH ?g { ?source <${c.predicate}> ?target }
|
|
1127
|
-
FILTER(?target IN (${l.map(g=>`<${g}>`).join(", ")}))
|
|
1128
|
-
}`,f=new Map;try{let g=await t.querySparql(p),_=Array.isArray(g)?g:g?.results?.bindings??g?.bindings??[];for(let w of _){let y=w.source?.value??w.source,b=w.target?.value??w.target;!y||!b||(f.has(b)||f.set(b,[]),f.get(b).push(y))}}catch(g){console.warn(`include projection "${o}" reverse SPARQL failed:`,g)}let h=new Set;for(let g of f.values())for(let _ of g)h.add(_);let m=new Map;if(h.size>0){let g=await u.findAll(t,{where:{id:Array.from(h),...s.where??{}}});for(let _ of g)m.set(_.id,_)}for(let g of e){let w=(f.get(g.id)??[]).map(y=>m.get(y)).filter(y=>y!=null);s.limit!=null?s.limit===1?g[o]=w[0]??null:g[o]=w.slice(0,s.limit):g[o]=w}}else for(let p of e)p[o]=s.limit===1?null:[];else{let p=new Set,f=new Map;for(let m of e){let g=m[s.from],_=[];if(Array.isArray(g))for(let w of g){let y=typeof w=="string"?w:w?.id;y&&(p.add(y),_.push(y))}else typeof g=="string"?(p.add(g),_.push(g)):g?.id&&(p.add(g.id),_.push(g.id));f.set(m,_)}let h=new Map;if(p.size>0){let m=await u.findAll(t,{where:{id:Array.from(p),...s.where??{}}});for(let g of m)h.set(g.id,g)}for(let m of e){let _=(f.get(m)??[]).map(w=>h.get(w)).filter(w=>w!=null);s.limit===1?m[o]=_[0]??null:s.limit!=null?m[o]=_.slice(0,s.limit):m[o]=_}}}for(let[o,s]of Object.entries(n)){if(o.startsWith("$")&&typeof s=="object"&&s!==null&&"from"in s)continue;let c=i[o];if(!c){console.warn(`include: relation "${o}" not found in metadata, skipping`);continue}let u=c.target(),l=typeof s=="object"&&s!==null?s:void 0,d=l?.include;if(c.kind==="belongsToOne"||c.kind==="belongsToMany"){let w=e.map(A=>A.id).filter(Boolean),y=new Map;if(w.length>0){let A=`SELECT ?source ?target WHERE {
|
|
1129
|
-
GRAPH ?g { ?source <${c.predicate}> ?target }
|
|
1130
|
-
FILTER(?target IN (${w.map(E=>`<${E}>`).join(", ")}))
|
|
1131
|
-
}`;try{let E=await t.querySparql(A),R=Array.isArray(E)?E:E?.results?.bindings??E?.bindings??[];for(let L of R){let N=L.source?.value??L.source,F=L.target?.value??L.target;!N||!F||(y.has(F)||y.set(F,[]),y.get(F).push(N))}}catch(E){console.warn("Batched reverse relation SPARQL failed, falling back to sequential:",E);for(let R of e){let N=(await t.get(new W({predicate:c.predicate,target:R.id}))).filter(F=>F.data.target===R.id).map(F=>F.data.source);N.length>0&&y.set(R.id,N)}}}let b=new Set;for(let A of y.values())for(let E of A)b.add(E);let I=new Map;if(b.size>0){let A={where:{id:Array.from(b),...l?.where??{}},...l?.order&&{order:l.order},...l?.properties&&{properties:l.properties}};try{let E=await u.findAll(t,A);for(let R of E)I.set(R.id,R)}catch{await Promise.all(Array.from(b).map(async E=>{try{let R=new u(t,E);await R.get(l?.properties?{properties:l.properties}:void 0),I.set(E,R)}catch{}}))}}for(let A of e){let E=A.id,R=y.get(E)??[];if(c.kind==="belongsToOne"){if(R.length===0){A[o]=null;continue}let L=R[R.length-1];A[o]=I.get(L)??null}else{let L=R.map(N=>I.get(N)).filter(N=>N!=null);if(l?.order){let N=Object.entries(l.order);L=L.sort((F,_e)=>{for(let[Ee,O]of N){let ge=String(F[Ee]??""),ye=String(_e[Ee]??""),ne=ge.localeCompare(ye);if(ne!==0)return O==="DESC"?-ne:ne}return 0})}if(l?.offset!=null||l?.limit!=null){let N=l.offset??0,F=l.limit!=null?N+l.limit:void 0;L=L.slice(N,F)}A[o]=L,d&&L.length>0&&await Ha(u,L,t,d)}}continue}let p=new Set,f=new Map;for(let w of e){let y=w[o];if(f.set(w,Array.isArray(y)?[...y]:y),y!=null)if(Array.isArray(y))for(let b of y)typeof b=="string"?p.add(b):b&&typeof b=="object"&&typeof b.id=="string"&&p.add(b.id);else typeof y=="string"?p.add(y):y&&typeof y=="object"&&typeof y.id=="string"&&p.add(y.id)}if(p.size===0)continue;let h=new Map,g={where:{id:Array.from(p),...l?.where??{}},...l?.order&&{order:l.order},...l?.properties&&{properties:l.properties}},_=await u.findAll(t,g);for(let w of _)h.set(w.id,w);for(let w of e){let y=f.get(w);if(y!=null)if(Array.isArray(y)){let b=y.map(I=>typeof I=="string"?h.has(I)?h.get(I):null:I&&typeof I=="object"&&typeof I.id=="string"?h.has(I.id)?h.get(I.id):I:null).filter(I=>I!==null);if(l?.order){let I=Object.entries(l.order);b=b.sort((A,E)=>{for(let[R,L]of I){let N=String(A[R]??""),F=String(E[R]??""),_e=N.localeCompare(F);if(_e!==0)return L==="DESC"?-_e:_e}return 0})}if(l?.offset!=null||l?.limit!=null){let I=l.offset??0,A=l.limit!=null?I+l.limit:void 0;b=b.slice(I,A)}c.maxCount===1?(b.length>1&&console.warn(`include: relation "${o}" has maxCount 1 but ${b.length} values found; keeping the last`),w[o]=b.length>0?b[b.length-1]:null):w[o]=b}else typeof y=="string"&&h.has(y)?w[o]=h.get(y):y&&typeof y=="object"&&typeof y.id=="string"&&(w[o]=h.has(y.id)?h.get(y.id):y)}if(d){let w=Array.from(h.values());await Ha(u,w,t,d)}}}var Fi=class{static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(e){if(this===Fi)return await e.stringOrTemplateObjectToSubjectClassName(this);let n=this.classNamesByClass.get(this);n||(n={},this.classNamesByClass.set(this,n));let i=e.uuid;return n[i]||(n[i]=await e.stringOrTemplateObjectToSubjectClassName(this)),n[i]}get timestamp(){return this.createdAt}static getModelMetadata(){let e=this.prototype;if(!e.className||e.className==="Ad4mModel")throw new Error("Model class must be decorated with @Model");let t=e.className,n={},i=Un(this);for(let[d,p]of Object.entries(i)){let f=p;n[d]={name:d,predicate:f.through||"",required:f.required||!1,readOnly:!(f.writable??!1),...f.initial!==void 0&&{initial:f.initial},...f.resolveLanguage!==void 0&&{resolveLanguage:f.resolveLanguage},...f.prologGetter!==void 0&&{prologGetter:f.prologGetter},...f.getter!==void 0&&{getter:f.getter},...f.prologSetter!==void 0&&{prologSetter:f.prologSetter},...f.local!==void 0&&{local:f.local},...f.transform!==void 0&&{transform:f.transform},...f.flag!==void 0&&{flag:f.flag}}}let a={},o=ht(this),s=Object.fromEntries(Object.entries(o).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany"));for(let[d,p]of Object.entries(s)){let f=p;a[d]={name:d,predicate:f.predicate||"",...f.local!==void 0&&{local:f.local},...f.getter!==void 0&&{getter:f.getter},direction:f.kind==="belongsToMany"||f.kind==="belongsToOne"?"reverse":"forward",...f.target!==void 0&&{target:f.target},...f.filter!==void 0&&{filter:f.filter},...f.where!==void 0&&{where:f.where}}}let c=Object.keys(n).length>0,u=Object.keys(a).length>0;if(!(c||u)&&e.__jsonSchema){let d=e.__jsonSchema,p=e.__jsonSchemaOptions||{};if(d.properties)for(let[f,h]of Object.entries(d.properties)){let m=om(h),g=cm(d,f,h,sm(d,p),p);if(m)a[f]={name:f,predicate:g,...h["x-ad4m"]?.local!==void 0&&{local:h["x-ad4m"].local}};else{let _=d.required?.includes(f)||!1;n[f]={name:f,predicate:g,required:_,readOnly:h["x-ad4m"]?.writable===!1,...h["x-ad4m"]?.resolveLanguage&&{resolveLanguage:h["x-ad4m"].resolveLanguage},...h["x-ad4m"]?.initial&&{initial:h["x-ad4m"].initial},...h["x-ad4m"]?.local!==void 0&&{local:h["x-ad4m"].local}}}}}return{className:t,properties:n,relations:a}}constructor(e,t){this._snapshot=null,this._baseExpression=t||be.from(gh(24)).toUrl(),this._perspective=e}get id(){return this._baseExpression}get baseExpression(){return this._baseExpression}get perspective(){return this._perspective}getPropertyMetadata(e){let t=this.constructor;return Un(t)[e]}getRelationOptions(e){let t=this.constructor;return ht(t)[e]}generatePropertySetterAction(e,t){if(t.flag)throw new Error(`Property "${e}" is a @Flag and cannot be written. Flags are immutable type markers set at creation time.`);if(t.readOnly)throw new Error(`Property "${e}" is read-only and cannot be written`);if(t.prologSetter)throw new Error(`Custom Prolog setter for property "${e}" not yet supported without Prolog. Use standard @Property decorator or enable Prolog for custom setters.`);if(!t.through)throw new Error(`Property "${e}" has no 'through' predicate defined`);return[{action:"setSingleTarget",source:"this",predicate:t.through,target:"value",...t.local&&{local:!0}}]}generateRelationAction(e,t){let n=this.getRelationOptions(e);if(!n)throw new Error(`Relation "${e}" has no metadata defined`);if(!n.predicate)throw new Error(`Relation "${e}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[t],source:"this",predicate:n.predicate,target:"value",...n.local&&{local:!0}}]}static async assignValuesToInstance(e,t,n){return WS(e,t,n)}takeSnapshot(e){let n=this.constructor.getModelMetadata(),i={};for(let a of Object.keys(n.properties)){let o=this[a];i[a]=ya(Array.isArray(o)?[...o]:o)}if(e===void 0)for(let a of Object.keys(n.relations)){let o=this[a];i[a]=ya(Array.isArray(o)?[...o]:o)}else if(e&&Object.keys(e).length>0){for(let a of Object.keys(e))if(a in n.relations){let o=this[a];i[a]=ya(Array.isArray(o)?[...o]:o)}}this._snapshot=i}isDirty(){return this._snapshot?this.changedFields().length>0:!0}changedFields(){let t=this.constructor.getModelMetadata();if(!this._snapshot)return[...Object.keys(t.properties),...Object.keys(t.relations)];let n=[],i=[...Object.keys(t.properties),...Object.keys(t.relations)];for(let a of i){if(!(a in this._snapshot))continue;let o=ya(this[a]),s=this._snapshot[a];if(Array.isArray(o)||Array.isArray(s)){let c=Array.isArray(o)?[...o].sort():[],u=Array.isArray(s)?[...s].sort():[];(c.length!==u.length||c.some((l,d)=>l!==u[d]))&&n.push(a)}else o!==s&&n.push(a)}return n}async getData(e){try{let t=this.constructor,n=t.getModelMetadata(),i=qS(this._baseExpression),a=await this._perspective.querySparql(i);if(a&&a.length>0){let u=e?.properties&&e.properties.length>0?e.properties:void 0;await th(this,a,n,this._perspective,u)}let o=ht(t),s=e?.properties&&e.properties.length>0?new Set(e.properties):null;for(let[u,l]of Object.entries(o)){if(l.kind!=="belongsToOne"&&l.kind!=="belongsToMany"||s&&!s.has(u))continue;let p=(await this._perspective.get(new W({predicate:l.predicate,target:this._baseExpression}))).filter(f=>f.data.target===this._baseExpression).map(f=>f.data.source);l.kind==="belongsToOne"?this[u]=p.length>0?p[p.length-1]:null:this[u]=p}let c=e?.properties||e?.include?{requestedProperties:e?.properties,include:e?.include}:void 0;await ju(this,this._perspective,n,c),e?.include&&await Ha(t,[this],this._perspective,e.include)}catch(t){console.error(`SPARQL getData also failed for ${this._baseExpression}:`,t)}return this.takeSnapshot(),this}static async queryToProlog(e,t,n){let{properties:i,where:a,order:o,offset:s,limit:c,count:u}=t,l=n||await this.getClassName(e),d=t.parent?Ai(t.parent,this):void 0,p=[zd(),Qd(t.parent,d),PS(i),Hd(a)],f=[Wd(u),Gd(o),Kd(s),Jd(c)];return`
|
|
1132
|
-
findall([Base, Properties, Collections, Timestamp, Author], (
|
|
1133
|
-
subject_class("${l}", SubjectClass),
|
|
1134
|
-
instance(SubjectClass, Base),
|
|
1135
|
-
${p.filter(m=>m).join(", ")}
|
|
1136
|
-
), UnsortedInstances),
|
|
1137
|
-
${f.filter(m=>m).join(", ")}
|
|
1138
|
-
`}static async queryToSPARQL(e,t){let n=this.getModelMetadata(),i=ht(this);return MS(n,i,t,this)}static async instancesFromPrologResult(e,t,n){if(!n?.[0]?.AllInstances)return{results:[],totalCount:0};let i=t?.properties||[],o=(await Promise.all(n[0].AllInstances.map(async([c,u,l,d,p])=>{try{let f=new this(e,c);i.length&&Object.keys(f).forEach(m=>{!i.includes(m)&&m!=="createdAt"&&m!=="updatedAt"&&m!=="author"&&m!=="id"&&m!=="baseExpression"&&delete f[m]});let h=[...u,...l,["createdAt",d],["author",p]];return await Fi.assignValuesToInstance(e,f,h),f}catch(f){return console.error(`Failed to process instance ${c}:`,f),null}}))).filter(c=>c!==null);t.include&&o.length>0&&await Ha(this,o,e,t.include);let s=t.include;for(let c of o)c.takeSnapshot(s);return{results:o,totalCount:n[0].TotalCount}}static async instancesFromQueryResult(e,t,n,i=!1){if(!n||n.length===0)return{results:[],totalCount:0};let a=this.getModelMetadata(),o=t?.properties||[],s=[];for(let y of n){let b;try{if(b=y.source_uri,!b)continue;let I=y.links||[],A=new this(e,b),E=o.length>0?[...o]:void 0;if(E&&t.where)for(let R of Object.keys(t.where))E.includes(R)||E.push(R);await th(A,I,a,e,E),s.push(A)}catch(I){console.error(`Failed to process SPARQL instance ${b}:`,I)}}let c=ht(this),u=Object.entries(c).filter(([y,b])=>(b.kind==="belongsToOne"||b.kind==="belongsToMany")&&(o.length===0||o.includes(y)));u.length>0&&s.length>0&&await Promise.all(s.map(async y=>{for(let[b,I]of u){let E=(await e.get(new W({predicate:I.predicate,target:y.id}))).filter(R=>R.data.target===y.id).map(R=>R.data.source);I.kind==="belongsToOne"?y[b]=E.length>0?E[E.length-1]:null:y[b]=E}}));let l=t.where?Object.keys(t.where).filter(y=>a.properties[y]?.getter):[],d=t.deepQuery===!0||l.length>0;{let y=!d,b=d?o.length>0?Array.from(new Set([...o,...l])):t.deepQuery===!0?[]:l:[],I={...b.length>0&&{requestedProperties:b},...t.include&&{include:t.include},skipPropertyGetters:y};for(let A of s)await ju(A,e,a,I)}let p=s;t.where&&(p=s.filter(y=>{for(let[b,I]of Object.entries(t.where)){if(b==="base"||b==="id")continue;if(b==="author"||b==="timestamp"){if(!Uu(y[b],I))return!1;continue}if(!(b in a.properties)){if(!Uu(y[b],I))return!1;continue}if(!Uu(y[b],I))return!1}return!0}));let f=t.order||(t.limit!==void 0||t.offset!==void 0?{createdAt:"ASC"}:null);if(f){let y=Object.entries(f);p.sort((b,I)=>{for(let[A,E]of y){let R=b[A],L=I[A];if(R===void 0&&L===void 0)continue;if(R===void 0)return E==="ASC"?1:-1;if(L===void 0)return E==="ASC"?-1:1;let N=0;if(typeof R=="number"&&typeof L=="number"?N=R-L:typeof R=="string"&&typeof L=="string"?N=R.localeCompare(L):N=String(R).localeCompare(String(L)),N!==0)return E==="DESC"?-N:N}return 0})}let h=ht(this),m=!Js(a,h,t.where)&&(t.limit!==void 0||t.offset!==void 0)&&t.order!==void 0&&Object.keys(t.order).length>0,g;if(m&&i)try{let y=Xd(a,h,t,this),b=await e.querySparql(y);g=hl(b)??p.length}catch{g=p.length}else g=p.length;let _=p;if(!m&&(t.offset!==void 0||t.limit!==void 0)){let y=t.offset||0,b=t.limit?y+t.limit:void 0;_=p.slice(y,b)}if(o.length>0){let y=new Set(o);for(let b of _){for(let I of Object.keys(a.properties))y.has(I)||delete b[I];for(let I of Object.keys(a.relations))!y.has(I)&&!(t.include&&I in t.include)&&delete b[I];for(let I of["author","createdAt","updatedAt"])y.has(I)||delete b[I]}}t.include&&_.length>0&&await Ha(this,_,e,t.include);let w=t.include;for(let y of _)y.takeSnapshot(w);return{results:_,totalCount:g}}static async findAll(e,t={},n="sparql"){if(t.properties&&t.properties.length===0)throw new Error("properties[] must not be empty \u2014 omit the field to return all properties, or specify at least one field name");if((typeof n=="boolean"?n?"sparql":"prolog":n)==="sparql"){let a=await this.queryToSPARQL(e,t),o=await e.querySparql(a),s=qa(o),{results:c}=await this.instancesFromQueryResult(e,t,s);return c}else{let a=await this.queryToProlog(e,t),o=await e.infer(a),{results:s}=await this.instancesFromPrologResult(e,t,o);return s}}static async findOne(e,t={},n="sparql"){let i={...t,limit:1};return(await this.findAll(e,i,n))[0]??null}static async findAllAndCount(e,t={},n="sparql"){if((typeof n=="boolean"?n?"sparql":"prolog":n)==="sparql"){let a=await this.queryToSPARQL(e,t),o=await e.querySparql(a),s=qa(o);return await this.instancesFromQueryResult(e,t,s,!0)}else{let a=await this.queryToProlog(e,t),o=await e.infer(a);return await this.instancesFromPrologResult(e,t,o)}}static async paginate(e,t,n,i,a="sparql"){let o={...i||{},limit:t,offset:t*(n-1),count:!0};if((typeof a=="boolean"?a?"sparql":"prolog":a)==="sparql"){let c=await this.queryToSPARQL(e,o),u=await e.querySparql(c),l=qa(u),{results:d,totalCount:p}=await this.instancesFromQueryResult(e,o,l,!0);return{results:d,totalCount:p,pageSize:t,pageNumber:n}}else{let c=await this.queryToProlog(e,o),u=await e.infer(c),{results:l,totalCount:d}=await this.instancesFromPrologResult(e,o,u);return{results:l,totalCount:d,pageSize:t,pageNumber:n}}}static async countQueryToProlog(e,t={},n){let{where:i}=t,a=n||await this.getClassName(e),o=t.parent?Ai(t.parent,this):void 0,s=[zd(),Qd(t.parent,o),Hd(i)],c=[Wd(!0),Gd(),Kd(),Jd()];return`
|
|
1139
|
-
findall([Base, Properties, Collections, Timestamp, Author], (
|
|
1140
|
-
subject_class("${a}", SubjectClass),
|
|
1141
|
-
instance(SubjectClass, Base),
|
|
1142
|
-
${s.filter(l=>l).join(", ")}
|
|
1143
|
-
), UnsortedInstances),
|
|
1144
|
-
${c.filter(l=>l).join(", ")}
|
|
1145
|
-
`}static async countQueryToSPARQL(e,t){let n=this.getModelMetadata(),i=ht(this);return Xd(n,i,t,this)}static async count(e,t={},n="sparql"){if((typeof n=="boolean"?n?"sparql":"prolog":n)==="sparql"){let a=this.getModelMetadata(),o=ht(this);if(Js(a,o,t.where)){let u=await this.queryToSPARQL(e,t),l=await e.querySparql(u),d=qa(l),{totalCount:p}=await this.instancesFromQueryResult(e,t,d,!0);return p}let s=await this.countQueryToSPARQL(e,t),c=await e.querySparql(s);return hl(c)??0}else return(await e.infer(await this.countQueryToProlog(e,t)))?.[0]?.TotalCount||0}async setProperty(e,t,n){let i=this.getPropertyMetadata(e);if(!i){console.warn(`Property "${e}" has no metadata, skipping`);return}let a=this.generatePropertySetterAction(e,i),o=i.resolveLanguage;t==null||t===""||(o&&(t=await this._perspective.createExpression(t,o)),await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:t}],n))}resolveRelationId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:String(e)}async setRelationValues(e,t,n){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"setter");t!=null&&(Array.isArray(t)?await this._perspective.executeAction(a,this._baseExpression,t.map(o=>({name:"value",value:this.resolveRelationId(o)})),n):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],n))}async addRelationValue(e,t,n){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"adder");t!=null&&(Array.isArray(t)?await Promise.all(t.map(o=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(o)}],n))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],n))}async removeRelationValue(e,t,n){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"remover");t!=null&&(Array.isArray(t)?await Promise.all(t.map(o=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(o)}],n))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],n))}async save(e){if(this._snapshot){await this.innerUpdate(!0,e),e?this.takeSnapshot():await this.getData();return}let t=!1;e||(e=await this.perspective.createBatch(),t=!0);let n=this.constructor.getModelMetadata(),i=Object.values(n.properties).some(o=>o.required||o.flag||o.initial!==void 0),a=[];if(i){let o={};for(let[c,u]of Object.entries(this))if(u!=null&&!(Array.isArray(u)&&u.length>0)&&!u?.action){let l=n.properties[c];if(l?.resolveLanguage&&l.resolveLanguage!=="literal"&&typeof u=="object"){a.push(c);continue}o[c]=u}let s=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(s,this._baseExpression,o,e)}await this.innerUpdate(!i,e);for(let o of a){let s=this[o];s!=null&&await this.setProperty(o,s,e)}t?(await this.perspective.commitBatch(e),await this.getData()):this.takeSnapshot()}cleanCopy(){let t=this.constructor.getModelMetadata(),n={},i=new Set([...Object.keys(t.properties),...Object.keys(t.relations)]);for(let a of i){let o=this[a];o!=null&&a!=="author"&&a!=="timestamp"&&(n[a]=o)}return n}async innerUpdate(e=!0,t){let n=this.constructor,i=this._snapshot?new Set(this.changedFields()):null,a=n.getModelMetadata(),o=new Set([...Object.keys(a.properties),...Object.keys(a.relations)]),s=Object.entries(this);for(let[c,u]of s){if(!o.has(c)||i&&!i.has(c))continue;let l=a.relations[c];if(!(l&&(l.getter||l.target&&l.filter!==!1&&Object.entries(a.relations).some(([p,f])=>p!==c&&f.predicate===l.predicate)))&&u!=null){if(u?.action)switch(u.action){case"setter":await this.setRelationValues(c,u.value,t);break;case"adder":await this.addRelationValue(c,u.value,t);break;case"remover":await this.removeRelationValue(c,u.value,t);break;default:await this.setRelationValues(c,u.value,t);break}else if(Array.isArray(u))await this.setRelationValues(c,u,t);else if(u!=null&&u!==""&&e){if(this.getRelationOptions(c)||this.getPropertyMetadata(c)?.flag)continue;await this.setProperty(c,u,t)}}}}static async evaluateGetters(e,t,n){if(e.length===0)return;let i=this.getModelMetadata(),a=n&&n.length>0?{requestedProperties:n}:void 0,o=[];for(let[s,c]of Object.entries(i.properties))c.getter&&(!n||n.length===0||n.includes(s))&&o.push(s);for(let s of e){await ju(s,t,i,a);let c=s;if(c._snapshot)for(let u of o){let l=s[u];c._snapshot[u]=ya(Array.isArray(l)?[...l]:l)}}}async get(e){let t;return e?"include"in e||"properties"in e?t=e:t={include:e}:t=void 0,await this.getData(t)}async delete(e){let t=this.constructor.getModelMetadata();if(Object.values(t.properties).some(i=>i.required||i.flag||i.initial!==void 0))await this._perspective.removeSubject(this,this._baseExpression,e);else try{let i=new Set;for(let s of Object.values(t.properties))s.predicate&&i.add(s.predicate);for(let s of Object.values(t.relations))s.predicate&&i.add(s.predicate);let o=(await this._perspective.get(new W({source:this._baseExpression}))).filter(s=>s.data.predicate&&i.has(s.data.predicate));o.length>0&&await this._perspective.removeLinks(o,e)}catch(i){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,i)}try{let i=await this._perspective.get(new W({target:this._baseExpression}));i.length>0&&await this._perspective.removeLinks(i,e)}catch(i){console.warn(`delete(): failed to clean up incoming links for ${this._baseExpression}:`,i)}}static async create(e,t={},n){let i=new this(e);if(Object.assign(i,t),n?.parent&&!n?.batchId){let a=await e.createBatch();await i.save(a);let o=Ai(n.parent,this),s=new mt({source:n.parent.id,predicate:o,target:i.id});return await e.add(s,"shared",a),await e.commitBatch(a),await i.get(),i}if(await i.save(n?.batchId),n?.parent){let a=Ai(n.parent,this),o=new mt({source:n.parent.id,predicate:a,target:i.id});await e.add(o,"shared",n?.batchId)}return i}static async update(e,t,n){let i=new this(e,t);return await i.get(),Object.assign(i,n),await i.save(),i}static async remove(e,t){return this.delete(e,t)}static async delete(e,t){await new this(e,t).delete()}static async register(e){await e.ensureSDNASubjectClass(this)}static async transaction(e,t){let n=await e.createBatch(),i=await t({batchId:n});return await e.commitBatch(n),i}static query(e,t){return new ml(e,this,t)}static fromJSONSchema(e,t){return LS(this,e,t)}};Fi.classNamesByClass=new WeakMap;function Rl(r){return r.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}function KS(r,e){let t=e.properties,n=Object.values(t).filter(o=>o.flag&&o.predicate&&o.initial);if(n.length>0){let o=n.map(s=>`triple(X, '${s.predicate}', '${s.initial}')`).join(`,
|
|
1146
|
-
`);return`${r}(X) :-
|
|
1147
|
-
${o}.`}let i=Object.values(t).filter(o=>o.required&&o.predicate&&!o.flag);if(i.length>0){let o=i.map(s=>`triple(X, '${s.predicate}', _)`).join(`,
|
|
1148
|
-
`);return`${r}(X) :-
|
|
1149
|
-
${o}.`}let a=Object.values(t).filter(o=>o.predicate).map(o=>o.predicate);if(e.relations)for(let o of Object.values(e.relations))o.predicate&&a.push(o.predicate);if(a.length>0){let o=a.map(s=>`triple(X, '${s}', _)`).join(` ;
|
|
1150
|
-
`);return`${r}(X) :-
|
|
1151
|
-
(${o}).`}return null}function JS(r,e){return e.flag||!e.predicate?null:`${`${r}_${Rl(e.name)}`}(X, Value) :- triple(X, '${e.predicate}', Value).`}function ZS(r,e){if(!e.predicate)return null;let t=`${r}_${Rl(e.name)}`;return e.direction==="reverse"?`${t}(X, Values) :- findall(V, triple(V, '${e.predicate}', X), Values).`:`${t}(X, Values) :- findall(V, triple(X, '${e.predicate}', V), Values).`}function GA(r){let e=r.getModelMetadata(),t=Rl(e.className),n=[];n.push(`% ${e.className} \u2014 generated Prolog facts`);let i=KS(t,e);i&&(n.push(""),n.push("% Instance recognizer"),n.push(i));let a=Object.values(e.properties).map(s=>JS(t,s)).filter(s=>s!==null);a.length>0&&(n.push(""),n.push("% Field getters"),n.push(...a));let o=Object.values(e.relations).map(s=>ZS(t,s)).filter(s=>s!==null);return o.length>0&&(n.push(""),n.push("% Relation getters"),n.push(...o)),n.join(`
|
|
1152
|
-
`)}var KA=`
|
|
1153
|
-
type AIModelLoadingStatus {
|
|
1154
|
-
downloaded: Boolean!
|
|
1155
|
-
loaded: Boolean!
|
|
1156
|
-
model: String!
|
|
1157
|
-
progress: Float!
|
|
1158
|
-
status: String!
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
type AIPromptExamples {
|
|
1162
|
-
input: String!
|
|
1163
|
-
output: String!
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
input AIPromptExamplesInput {
|
|
1167
|
-
input: String!
|
|
1168
|
-
output: String!
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
type AITask {
|
|
1172
|
-
createdAt: String!
|
|
1173
|
-
metaData: String
|
|
1174
|
-
modelId: String!
|
|
1175
|
-
name: String!
|
|
1176
|
-
promptExamples: [AIPromptExamples!]!
|
|
1177
|
-
systemPrompt: String!
|
|
1178
|
-
taskId: String!
|
|
1179
|
-
updatedAt: String!
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
input AITaskInput {
|
|
1183
|
-
metaData: String
|
|
1184
|
-
modelId: String!
|
|
1185
|
-
name: String!
|
|
1186
|
-
promptExamples: [AIPromptExamplesInput!]!
|
|
1187
|
-
systemPrompt: String!
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
type Agent {
|
|
1191
|
-
did: String!
|
|
1192
|
-
directMessageLanguage: String
|
|
1193
|
-
perspective: Perspective
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
type AgentSignature {
|
|
1197
|
-
publicKey: String!
|
|
1198
|
-
signature: String!
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
type AgentStatus {
|
|
1202
|
-
did: String
|
|
1203
|
-
didDocument: String
|
|
1204
|
-
error: String
|
|
1205
|
-
isInitialized: Boolean!
|
|
1206
|
-
isUnlocked: Boolean!
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
type Apps {
|
|
1210
|
-
auth: AuthInfo!
|
|
1211
|
-
requestId: String!
|
|
1212
|
-
revoked: Boolean
|
|
1213
|
-
token: String!
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
type AuthInfo {
|
|
1217
|
-
appDesc: String!
|
|
1218
|
-
appIconPath: String
|
|
1219
|
-
appName: String!
|
|
1220
|
-
appUrl: String!
|
|
1221
|
-
capabilities: [Capability!]!
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
input AuthInfoInput {
|
|
1225
|
-
appDesc: String!
|
|
1226
|
-
appDomain: String!
|
|
1227
|
-
appIconPath: String
|
|
1228
|
-
appName: String!
|
|
1229
|
-
appUrl: String
|
|
1230
|
-
capabilities: [CapabilityInput!]
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
type Capability {
|
|
1234
|
-
can: [String!]!
|
|
1235
|
-
with: Resource!
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
input CapabilityInput {
|
|
1239
|
-
can: [String!]!
|
|
1240
|
-
with: ResourceInput!
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
type ComputeLogEntry {
|
|
1244
|
-
cost: Float!
|
|
1245
|
-
creditsAfter: Float!
|
|
1246
|
-
id: Float!
|
|
1247
|
-
operation: String!
|
|
1248
|
-
summary: String
|
|
1249
|
-
timestamp: String!
|
|
1250
|
-
userEmail: String!
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
scalar DateTime
|
|
1254
|
-
|
|
1255
|
-
type EntanglementProof {
|
|
1256
|
-
deviceKey: String!
|
|
1257
|
-
deviceKeySignedByDid: String!
|
|
1258
|
-
deviceKeyType: String!
|
|
1259
|
-
did: String!
|
|
1260
|
-
didSignedByDeviceKey: String
|
|
1261
|
-
didSigningKeyId: String!
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
input EntanglementProofInput {
|
|
1265
|
-
deviceKey: String!
|
|
1266
|
-
deviceKeySignedByDid: String!
|
|
1267
|
-
deviceKeyType: String!
|
|
1268
|
-
did: String!
|
|
1269
|
-
didSignedByDeviceKey: String!
|
|
1270
|
-
didSigningKeyId: String!
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
type ExceptionInfo {
|
|
1274
|
-
addon: String
|
|
1275
|
-
message: String!
|
|
1276
|
-
title: String!
|
|
1277
|
-
type: Int!
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
type ExpressionProof {
|
|
1281
|
-
invalid: Boolean
|
|
1282
|
-
key: String
|
|
1283
|
-
signature: String
|
|
1284
|
-
valid: Boolean
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
input ExpressionProofInput {
|
|
1288
|
-
invalid: Boolean
|
|
1289
|
-
key: String
|
|
1290
|
-
signature: String
|
|
1291
|
-
valid: Boolean
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
type ExpressionRendered {
|
|
1295
|
-
author: String!
|
|
1296
|
-
data: String!
|
|
1297
|
-
icon: Icon!
|
|
1298
|
-
language: LanguageRef!
|
|
1299
|
-
proof: ExpressionProof!
|
|
1300
|
-
timestamp: String!
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
type HostingUserInfo {
|
|
1304
|
-
email: String!
|
|
1305
|
-
freeAccess: Boolean!
|
|
1306
|
-
hotWalletAddress: String
|
|
1307
|
-
remainingCredits: String!
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
type Icon {
|
|
1311
|
-
code: String!
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
input InteractionCall {
|
|
1315
|
-
name: String!
|
|
1316
|
-
parametersStringified: String!
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
type InteractionMeta {
|
|
1320
|
-
label: String!
|
|
1321
|
-
name: String!
|
|
1322
|
-
parameters: [InteractionParameter!]!
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
type InteractionParameter {
|
|
1326
|
-
name: String!
|
|
1327
|
-
type: String!
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
type LanguageHandle {
|
|
1331
|
-
address: String!
|
|
1332
|
-
constructorIcon: Icon
|
|
1333
|
-
icon: Icon
|
|
1334
|
-
name: String!
|
|
1335
|
-
settings: String
|
|
1336
|
-
settingsIcon: Icon
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
type LanguageMeta {
|
|
1340
|
-
address: String!
|
|
1341
|
-
author: String!
|
|
1342
|
-
description: String
|
|
1343
|
-
name: String!
|
|
1344
|
-
possibleTemplateParams: [String!]
|
|
1345
|
-
sourceCodeLink: String
|
|
1346
|
-
templateAppliedParams: String
|
|
1347
|
-
templateSourceLanguageAddress: String
|
|
1348
|
-
templated: Boolean
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
input LanguageMetaInput {
|
|
1352
|
-
description: String = ""
|
|
1353
|
-
name: String!
|
|
1354
|
-
possibleTemplateParams: [String!]
|
|
1355
|
-
sourceCodeLink: String
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
type LanguageRef {
|
|
1359
|
-
address: String!
|
|
1360
|
-
name: String!
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
type Link {
|
|
1364
|
-
predicate: String
|
|
1365
|
-
source: String!
|
|
1366
|
-
target: String!
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
type LinkExpression {
|
|
1370
|
-
author: String!
|
|
1371
|
-
data: Link!
|
|
1372
|
-
proof: ExpressionProof!
|
|
1373
|
-
status: String
|
|
1374
|
-
timestamp: String!
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
input LinkExpressionInput {
|
|
1378
|
-
author: String!
|
|
1379
|
-
data: LinkInput!
|
|
1380
|
-
proof: ExpressionProofInput!
|
|
1381
|
-
status: String = "shared"
|
|
1382
|
-
timestamp: String!
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
type LinkExpressionMutations {
|
|
1386
|
-
additions: [LinkExpression!]!
|
|
1387
|
-
removals: [LinkExpression!]!
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
type LinkExpressionUpdated {
|
|
1391
|
-
newLink: LinkExpression!
|
|
1392
|
-
oldLink: LinkExpression!
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
input LinkInput {
|
|
1396
|
-
predicate: String
|
|
1397
|
-
source: String!
|
|
1398
|
-
target: String!
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
input LinkMutations {
|
|
1402
|
-
additions: [LinkInput!]!
|
|
1403
|
-
removals: [LinkExpressionInput!]!
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
input LinkQuery {
|
|
1407
|
-
fromDate: DateTime
|
|
1408
|
-
limit: Float
|
|
1409
|
-
predicate: String
|
|
1410
|
-
source: String
|
|
1411
|
-
target: String
|
|
1412
|
-
untilDate: DateTime
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
type LocalModel {
|
|
1416
|
-
fileName: String!
|
|
1417
|
-
huggingfaceRepo: String
|
|
1418
|
-
revision: String
|
|
1419
|
-
tokenizerSource: TokenizerSource
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
input LocalModelInput {
|
|
1423
|
-
fileName: String!
|
|
1424
|
-
huggingfaceRepo: String
|
|
1425
|
-
revision: String
|
|
1426
|
-
tokenizerSource: TokenizerSourceInput
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
type Model {
|
|
1430
|
-
api: ModelApi
|
|
1431
|
-
id: String!
|
|
1432
|
-
local: LocalModel
|
|
1433
|
-
modelType: String!
|
|
1434
|
-
name: String!
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
type ModelApi {
|
|
1438
|
-
apiKey: String!
|
|
1439
|
-
apiType: String!
|
|
1440
|
-
baseUrl: String!
|
|
1441
|
-
model: String!
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
input ModelApiInput {
|
|
1445
|
-
apiKey: String!
|
|
1446
|
-
apiType: String!
|
|
1447
|
-
baseUrl: String!
|
|
1448
|
-
model: String!
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
input ModelInput {
|
|
1452
|
-
api: ModelApiInput
|
|
1453
|
-
local: LocalModelInput
|
|
1454
|
-
modelType: String!
|
|
1455
|
-
name: String!
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
type Mutation {
|
|
1459
|
-
addTrustedAgents(agents: [String!]!): [String!]!
|
|
1460
|
-
agentAddEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
|
|
1461
|
-
agentDeleteEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
|
|
1462
|
-
agentEntanglementProofPreFlight(deviceKey: String!, deviceKeyType: String!): EntanglementProof!
|
|
1463
|
-
agentGenerate(passphrase: String!): AgentStatus!
|
|
1464
|
-
agentGenerateJwt(rand: String!, requestId: String!): String!
|
|
1465
|
-
agentImport(did: String!, didDocument: String!, keystore: String!, passphrase: String!): AgentStatus!
|
|
1466
|
-
agentLock(passphrase: String!): AgentStatus!
|
|
1467
|
-
agentPermitCapability(auth: String!): String!
|
|
1468
|
-
agentRemoveApp(requestId: String!): [Apps!]!
|
|
1469
|
-
agentRequestCapability(authInfo: AuthInfoInput!): String!
|
|
1470
|
-
agentRevokeToken(requestId: String!): [Apps!]!
|
|
1471
|
-
agentSignMessage(message: String!): AgentSignature!
|
|
1472
|
-
agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
|
|
1473
|
-
agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
|
|
1474
|
-
agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
|
|
1475
|
-
aiAddModel(model: ModelInput!): String!
|
|
1476
|
-
aiAddTask(task: AITaskInput!): AITask!
|
|
1477
|
-
aiCloseTranscriptionStream(streamId: String!): String!
|
|
1478
|
-
aiEmbed(modelId: String!, text: String!): String!
|
|
1479
|
-
aiFeedTranscriptionStream(audio: [Float!]!, streamIds: [String!]!): String!
|
|
1480
|
-
aiOpenTranscriptionStream(modelId: String!, params: VoiceActivityParamsInput): String!
|
|
1481
|
-
aiPrompt(prompt: String!, taskId: String!): String!
|
|
1482
|
-
aiRemoveModel(modelId: String!): Boolean!
|
|
1483
|
-
aiRemoveTask(taskId: String!): AITask!
|
|
1484
|
-
aiSetDefaultModel(modelId: String!, modelType: String!): Boolean!
|
|
1485
|
-
aiUpdateModel(model: ModelInput!, modelId: String!): Boolean!
|
|
1486
|
-
aiUpdateTask(task: AITaskInput!, taskId: String!): AITask!
|
|
1487
|
-
deleteTrustedAgents(agents: [String!]!): [String!]!
|
|
1488
|
-
expressionCreate(content: String!, languageAddress: String!): String!
|
|
1489
|
-
expressionInteract(interactionCall: InteractionCall!, url: String!): String
|
|
1490
|
-
languageApplyTemplateAndPublish(sourceLanguageHash: String!, templateData: String!): LanguageRef!
|
|
1491
|
-
languagePublish(languageMeta: LanguageMetaInput!, languagePath: String!): LanguageMeta!
|
|
1492
|
-
languageRemove(address: String!): Boolean!
|
|
1493
|
-
languageWriteSettings(languageAddress: String!, settings: String!): Boolean!
|
|
1494
|
-
neighbourhoodJoinFromUrl(url: String!): PerspectiveHandle!
|
|
1495
|
-
neighbourhoodPublishFromPerspective(linkLanguage: String!, meta: PerspectiveInput!, perspectiveUUID: String!): String!
|
|
1496
|
-
neighbourhoodSendBroadcast(loopback: Boolean, payload: PerspectiveInput!, perspectiveUUID: String!): Boolean!
|
|
1497
|
-
neighbourhoodSendBroadcastU(loopback: Boolean, payload: PerspectiveUnsignedInput!, perspectiveUUID: String!): Boolean!
|
|
1498
|
-
neighbourhoodSendSignal(payload: PerspectiveInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
|
|
1499
|
-
neighbourhoodSendSignalU(payload: PerspectiveUnsignedInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
|
|
1500
|
-
neighbourhoodSetOnlineStatus(perspectiveUUID: String!, status: PerspectiveInput!): Boolean!
|
|
1501
|
-
neighbourhoodSetOnlineStatusU(perspectiveUUID: String!, status: PerspectiveUnsignedInput!): Boolean!
|
|
1502
|
-
perspectiveAdd(name: String!): PerspectiveHandle!
|
|
1503
|
-
perspectiveAddLink(batchId: String, link: LinkInput!, status: String = "shared", uuid: String!): LinkExpression!
|
|
1504
|
-
perspectiveAddLinkExpression(batchId: String, link: LinkExpressionInput!, status: String = "shared", uuid: String!): LinkExpression!
|
|
1505
|
-
perspectiveAddLinks(batchId: String, links: [LinkInput!]!, status: String = "shared", uuid: String!): [LinkExpression!]!
|
|
1506
|
-
perspectiveAddSdna(name: String!, sdnaCode: String, sdnaType: String!, shaclJson: String, uuid: String!): Boolean!
|
|
1507
|
-
perspectiveCommitBatch(batchId: String!, uuid: String!): LinkExpressionMutations!
|
|
1508
|
-
perspectiveCreateBatch(uuid: String!): String!
|
|
1509
|
-
perspectiveCreateSubject(batchId: String, expressionAddress: String!, initialValues: String, subjectClass: String!, uuid: String!): Boolean!
|
|
1510
|
-
perspectiveDisposeQuerySubscription(subscriptionId: String!, uuid: String!): Boolean!
|
|
1511
|
-
perspectiveExecuteCommands(batchId: String, commands: String!, expression: String!, parameters: String, uuid: String!): Boolean!
|
|
1512
|
-
perspectiveGetSubjectData(expressionAddress: String!, subjectClass: String!, uuid: String!): String!
|
|
1513
|
-
perspectiveKeepAliveQuery(subscriptionId: String!, uuid: String!): Boolean!
|
|
1514
|
-
perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
|
|
1515
|
-
perspectivePublishSnapshot(uuid: String!): String
|
|
1516
|
-
perspectiveRemove(uuid: String!): Boolean!
|
|
1517
|
-
perspectiveRemoveLink(batchId: String, link: LinkExpressionInput!, uuid: String!): Boolean!
|
|
1518
|
-
perspectiveRemoveLinks(batchId: String, links: [LinkExpressionInput!]!, uuid: String!): [LinkExpression!]!
|
|
1519
|
-
perspectiveSubscribeQuery(query: String!, uuid: String!): QuerySubscription!
|
|
1520
|
-
perspectiveUpdate(name: String!, uuid: String!): PerspectiveHandle
|
|
1521
|
-
perspectiveUpdateLink(batchId: String, newLink: LinkInput!, oldLink: LinkExpressionInput!, uuid: String!): LinkExpression!
|
|
1522
|
-
runtimeAddFriends(dids: [String!]!): [String!]!
|
|
1523
|
-
runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
1524
|
-
runtimeCreateUser(appInfo: AuthInfoInput, email: String!, password: String!): UserCreationResult!
|
|
1525
|
-
runtimeEmailTestClearCodes: Boolean!
|
|
1526
|
-
runtimeEmailTestGetCode(email: String!): String
|
|
1527
|
-
runtimeEmailTestModeDisable: Boolean!
|
|
1528
|
-
runtimeEmailTestModeEnable: Boolean!
|
|
1529
|
-
runtimeEmailTestSetExpiry(email: String!, expiresAt: Float!, verificationType: String!): Boolean!
|
|
1530
|
-
runtimeExportDb(filePath: String!): Boolean!
|
|
1531
|
-
runtimeExportPerspective(filePath: String!, perspectiveUuid: String!): Boolean!
|
|
1532
|
-
runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
|
|
1533
|
-
runtimeGrantNotification(id: String!): Boolean!
|
|
1534
|
-
runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
|
|
1535
|
-
runtimeImportDb(filePath: String!): Boolean!
|
|
1536
|
-
runtimeImportPerspective(filePath: String!): Boolean!
|
|
1537
|
-
runtimeLoginUser(email: String!, password: String!): String!
|
|
1538
|
-
runtimeOpenLink(url: String!): Boolean!
|
|
1539
|
-
runtimeQuit: Boolean!
|
|
1540
|
-
runtimeReinstallUnytDna: PaymentRequestResult!
|
|
1541
|
-
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
1542
|
-
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
1543
|
-
runtimeRemoveNotification(id: String!): Boolean!
|
|
1544
|
-
runtimeRequestInstallNotification(notification: NotificationInput!): String!
|
|
1545
|
-
runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
|
|
1546
|
-
runtimeRequestPayment(amountHOT: String!): PaymentRequestResult!
|
|
1547
|
-
runtimeRestartHolochain: Boolean!
|
|
1548
|
-
runtimeSendHot(amount: String!, recipient: String!): PaymentRequestResult!
|
|
1549
|
-
runtimeSetFreeHostingEnabled(enabled: Boolean!): Boolean!
|
|
1550
|
-
runtimeSetHotWalletAddress(address: String!): Boolean!
|
|
1551
|
-
runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
|
|
1552
|
-
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
1553
|
-
runtimeSetUnytMembraneProof(proof: String!): PaymentRequestResult!
|
|
1554
|
-
runtimeSetUserCredits(amount: Float!, email: String!): Boolean!
|
|
1555
|
-
runtimeSetUserFreeAccess(email: String!, enabled: Boolean!): Boolean!
|
|
1556
|
-
runtimeTestEmail(to: String!): Boolean!
|
|
1557
|
-
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
1558
|
-
runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
type Neighbourhood {
|
|
1562
|
-
linkLanguage: String!
|
|
1563
|
-
meta: Perspective!
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
type NeighbourhoodExpression {
|
|
1567
|
-
author: String!
|
|
1568
|
-
data: Neighbourhood!
|
|
1569
|
-
proof: ExpressionProof!
|
|
1570
|
-
timestamp: String!
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
type Notification {
|
|
1574
|
-
appIconPath: String!
|
|
1575
|
-
appName: String!
|
|
1576
|
-
appUrl: String!
|
|
1577
|
-
description: String!
|
|
1578
|
-
granted: Boolean!
|
|
1579
|
-
id: String!
|
|
1580
|
-
perspectiveIds: [String!]!
|
|
1581
|
-
trigger: String!
|
|
1582
|
-
webhookAuth: String!
|
|
1583
|
-
webhookUrl: String!
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
input NotificationInput {
|
|
1587
|
-
appIconPath: String!
|
|
1588
|
-
appName: String!
|
|
1589
|
-
appUrl: String!
|
|
1590
|
-
description: String!
|
|
1591
|
-
perspectiveIds: [String!]!
|
|
1592
|
-
trigger: String!
|
|
1593
|
-
webhookAuth: String!
|
|
1594
|
-
webhookUrl: String!
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
type OnlineAgent {
|
|
1598
|
-
did: String!
|
|
1599
|
-
status: PerspectiveExpression!
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
type PaymentRequestResult {
|
|
1603
|
-
message: String!
|
|
1604
|
-
success: Boolean!
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
type Perspective {
|
|
1608
|
-
links: [LinkExpression!]!
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
type PerspectiveExpression {
|
|
1612
|
-
author: String!
|
|
1613
|
-
data: Perspective!
|
|
1614
|
-
proof: ExpressionProof!
|
|
1615
|
-
timestamp: String!
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
type PerspectiveHandle {
|
|
1619
|
-
name: String!
|
|
1620
|
-
neighbourhood: NeighbourhoodExpression
|
|
1621
|
-
owners: [String!]
|
|
1622
|
-
sharedUrl: String
|
|
1623
|
-
state: String!
|
|
1624
|
-
uuid: String!
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
input PerspectiveInput {
|
|
1628
|
-
links: [LinkExpressionInput!]!
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
input PerspectiveUnsignedInput {
|
|
1632
|
-
links: [LinkInput!] = []
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
type Query {
|
|
1636
|
-
agent: Agent!
|
|
1637
|
-
agentByDID(did: String!): Agent
|
|
1638
|
-
agentGetApps: [Apps!]!
|
|
1639
|
-
agentGetEntanglementProofs: [EntanglementProof!]!
|
|
1640
|
-
agentIsLocked: Boolean!
|
|
1641
|
-
agentStatus: AgentStatus!
|
|
1642
|
-
aiGetDefaultModel(modelType: String!): Model!
|
|
1643
|
-
aiGetModels: [Model!]!
|
|
1644
|
-
aiModelLoadingStatus(model: String!): AIModelLoadingStatus!
|
|
1645
|
-
aiTasks: [AITask!]!
|
|
1646
|
-
expression(url: String!): ExpressionRendered
|
|
1647
|
-
expressionInteractions(url: String!): [InteractionMeta!]!
|
|
1648
|
-
expressionMany(urls: [String!]!): [ExpressionRendered]!
|
|
1649
|
-
expressionRaw(url: String!): String
|
|
1650
|
-
getTrustedAgents: [String!]!
|
|
1651
|
-
language(address: String!): LanguageHandle
|
|
1652
|
-
languageMeta(address: String!): LanguageMeta!
|
|
1653
|
-
languageSource(address: String!): String!
|
|
1654
|
-
languages(filter: String): [LanguageHandle!]!
|
|
1655
|
-
neighbourhoodHasTelepresenceAdapter(perspectiveUUID: String!): Boolean!
|
|
1656
|
-
neighbourhoodOnlineAgents(perspectiveUUID: String!): [OnlineAgent!]!
|
|
1657
|
-
neighbourhoodOtherAgents(perspectiveUUID: String!): [String!]!
|
|
1658
|
-
perspective(uuid: String!): PerspectiveHandle
|
|
1659
|
-
perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
|
|
1660
|
-
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
1661
|
-
perspectiveSnapshot(uuid: String!): Perspective
|
|
1662
|
-
perspectives: [PerspectiveHandle!]!
|
|
1663
|
-
runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
|
|
1664
|
-
runtimeFreeHostingEnabled: Boolean!
|
|
1665
|
-
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
1666
|
-
runtimeFriends: [String!]!
|
|
1667
|
-
runtimeGetNetworkMetrics: String!
|
|
1668
|
-
runtimeHcAgentInfos: String!
|
|
1669
|
-
runtimeHostingUserInfo: HostingUserInfo!
|
|
1670
|
-
runtimeHotAgentPubkey: String!
|
|
1671
|
-
runtimeHotWalletBalance: String!
|
|
1672
|
-
runtimeHotWalletHistory(page: Float, perPage: Float): String!
|
|
1673
|
-
runtimeInfo: RuntimeInfo!
|
|
1674
|
-
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
1675
|
-
runtimeListUsers: [UserStatistics!]!
|
|
1676
|
-
runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
|
|
1677
|
-
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
1678
|
-
runtimeMultiUserEnabled: Boolean!
|
|
1679
|
-
runtimeNotifications: [Notification!]!
|
|
1680
|
-
runtimeUnytAgentKey: String!
|
|
1681
|
-
runtimeUnytVersionInfo: String!
|
|
1682
|
-
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
type QuerySubscription {
|
|
1686
|
-
result: String!
|
|
1687
|
-
subscriptionId: String!
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
type Resource {
|
|
1691
|
-
domain: String!
|
|
1692
|
-
pointers: [String!]!
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
input ResourceInput {
|
|
1696
|
-
domain: String!
|
|
1697
|
-
pointers: [String!]!
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
type RuntimeInfo {
|
|
1701
|
-
ad4mExecutorVersion: String!
|
|
1702
|
-
isInitialized: Boolean!
|
|
1703
|
-
isUnlocked: Boolean!
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
type SentMessage {
|
|
1707
|
-
message: PerspectiveExpression!
|
|
1708
|
-
recipient: String!
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
type Subscription {
|
|
1712
|
-
agentAppsChanged: [Apps!]
|
|
1713
|
-
agentStatusChanged: AgentStatus
|
|
1714
|
-
agentUpdated: Agent
|
|
1715
|
-
aiTranscriptionText(streamId: String!): String!
|
|
1716
|
-
exceptionOccurred: ExceptionInfo
|
|
1717
|
-
neighbourhoodSignal(perspectiveUUID: String!): PerspectiveExpression
|
|
1718
|
-
perspectiveAdded: PerspectiveHandle
|
|
1719
|
-
perspectiveLinkAdded(uuid: String!): LinkExpression
|
|
1720
|
-
perspectiveLinkRemoved(uuid: String!): LinkExpression
|
|
1721
|
-
perspectiveLinkUpdated(uuid: String!): LinkExpressionUpdated
|
|
1722
|
-
perspectiveQuerySubscription(subscriptionId: String!): String!
|
|
1723
|
-
perspectiveRemoved: String
|
|
1724
|
-
perspectiveSyncStateChange(uuid: String!): String!
|
|
1725
|
-
perspectiveUpdated: PerspectiveHandle
|
|
1726
|
-
runtimeMessageReceived: PerspectiveExpression
|
|
1727
|
-
runtimeNotificationTriggered: TriggeredNotification
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
type TokenizerSource {
|
|
1731
|
-
fileName: String!
|
|
1732
|
-
repo: String!
|
|
1733
|
-
revision: String!
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
input TokenizerSourceInput {
|
|
1737
|
-
fileName: String!
|
|
1738
|
-
repo: String!
|
|
1739
|
-
revision: String!
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
type TriggeredNotification {
|
|
1743
|
-
notification: Notification!
|
|
1744
|
-
perspectiveId: String!
|
|
1745
|
-
triggerMatch: String!
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
type UserCreationResult {
|
|
1749
|
-
did: String!
|
|
1750
|
-
error: String
|
|
1751
|
-
success: Boolean!
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
type UserStatistics {
|
|
1755
|
-
did: String!
|
|
1756
|
-
email: String!
|
|
1757
|
-
freeAccess: Boolean!
|
|
1758
|
-
hotWalletAddress: String
|
|
1759
|
-
lastSeen: String
|
|
1760
|
-
perspectiveCount: Int!
|
|
1761
|
-
remainingCredits: String!
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
type VerificationRequestResult {
|
|
1765
|
-
isExistingUser: Boolean!
|
|
1766
|
-
message: String!
|
|
1767
|
-
requiresPassword: Boolean!
|
|
1768
|
-
success: Boolean!
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
input VoiceActivityParamsInput {
|
|
1772
|
-
endThreshold: Float
|
|
1773
|
-
endWindow: Float
|
|
1774
|
-
startThreshold: Float
|
|
1775
|
-
startWindow: Float
|
|
1776
|
-
timeBeforeSpeech: Float
|
|
1777
|
-
}
|
|
1778
|
-
`,C=function(r,e,t,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,n);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(i<3?o(a):i>3?o(e,t,a):o(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a},v=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},V=function(r,e){return function(t,n){e(t,n,r)}},ho=new Zr;ho.author="did:ad4m:test";ho.timestamp=Date.now();ho.data={source:"root",target:"neighbourhood://Qm12345"};ho.proof={signature:"",key:"",valid:!0};var zr=new Fn;zr.author="did:ad4m:test";zr.timestamp=Date.now().toString();zr.proof=new wr("","");zr.data=new ir([ho]);var Zs=class{};C([S(),v("design:type",String)],Zs.prototype,"recipient",void 0);C([S(),v("design:type",Fn)],Zs.prototype,"message",void 0);Zs=C([K()],Zs);var Mi=class{};C([S(),v("design:type",String)],Mi.prototype,"ad4mExecutorVersion",void 0);C([S(),v("design:type",Boolean)],Mi.prototype,"isInitialized",void 0);C([S(),v("design:type",Boolean)],Mi.prototype,"isUnlocked",void 0);Mi=C([K()],Mi);var zn=class{};C([S(),v("design:type",String)],zn.prototype,"title",void 0);C([S(),v("design:type",String)],zn.prototype,"message",void 0);C([S(),v("design:type",String)],zn.prototype,"type",void 0);C([S(),v("design:type",String)],zn.prototype,"addon",void 0);zn=C([K()],zn);var Lt=class{};C([S(),v("design:type",String)],Lt.prototype,"description",void 0);C([S(),v("design:type",String)],Lt.prototype,"appName",void 0);C([S(),v("design:type",String)],Lt.prototype,"appUrl",void 0);C([S(),v("design:type",String)],Lt.prototype,"appIconPath",void 0);C([S(),v("design:type",String)],Lt.prototype,"trigger",void 0);C([S(),v("design:type",Array)],Lt.prototype,"perspectiveIds",void 0);C([S(),v("design:type",String)],Lt.prototype,"webhookUrl",void 0);C([S(),v("design:type",String)],Lt.prototype,"webhookAuth",void 0);Lt=C([ze()],Lt);var Et=class{};C([S(),v("design:type",String)],Et.prototype,"id",void 0);C([S(),v("design:type",Boolean)],Et.prototype,"granted",void 0);C([S(),v("design:type",String)],Et.prototype,"description",void 0);C([S(),v("design:type",String)],Et.prototype,"appName",void 0);C([S(),v("design:type",String)],Et.prototype,"appUrl",void 0);C([S(),v("design:type",String)],Et.prototype,"appIconPath",void 0);C([S(),v("design:type",String)],Et.prototype,"trigger",void 0);C([S(),v("design:type",Array)],Et.prototype,"perspectiveIds",void 0);C([S(),v("design:type",String)],Et.prototype,"webhookUrl",void 0);C([S(),v("design:type",String)],Et.prototype,"webhookAuth",void 0);Et=C([K()],Et);var Ui=class{};C([S(),v("design:type",Et)],Ui.prototype,"notification",void 0);C([S(),v("design:type",String)],Ui.prototype,"perspectiveId",void 0);C([S(),v("design:type",String)],Ui.prototype,"triggerMatch",void 0);Ui=C([K()],Ui);var Qe=class{};C([S(),v("design:type",Number)],Qe.prototype,"total",void 0);C([S(),v("design:type",Number)],Qe.prototype,"imported",void 0);C([S(),v("design:type",Number)],Qe.prototype,"failed",void 0);C([S(),v("design:type",Number)],Qe.prototype,"omitted",void 0);C([S(),v("design:type",Array)],Qe.prototype,"errors",void 0);Qe=C([K()],Qe);var xt=class{};C([S(),v("design:type",Qe)],xt.prototype,"perspectives",void 0);C([S(),v("design:type",Qe)],xt.prototype,"links",void 0);C([S(),v("design:type",Qe)],xt.prototype,"expressions",void 0);C([S(),v("design:type",Qe)],xt.prototype,"perspectiveDiffs",void 0);C([S(),v("design:type",Qe)],xt.prototype,"notifications",void 0);C([S(),v("design:type",Qe)],xt.prototype,"models",void 0);C([S(),v("design:type",Qe)],xt.prototype,"defaultModels",void 0);C([S(),v("design:type",Qe)],xt.prototype,"tasks",void 0);C([S(),v("design:type",Qe)],xt.prototype,"friends",void 0);C([S(),v("design:type",Qe)],xt.prototype,"trustedAgents",void 0);C([S(),v("design:type",Qe)],xt.prototype,"knownLinkLanguages",void 0);xt=C([K()],xt);var _r=class{};C([S(),v("design:type",String)],_r.prototype,"email",void 0);C([S(),v("design:type",String)],_r.prototype,"did",void 0);C([S(),v("design:type",String)],_r.prototype,"lastSeen",void 0);C([S(),v("design:type",Number)],_r.prototype,"perspectiveCount",void 0);C([S(),v("design:type",String)],_r.prototype,"remainingCredits",void 0);C([S(),v("design:type",Boolean)],_r.prototype,"freeAccess",void 0);C([S(),v("design:type",String)],_r.prototype,"hotWalletAddress",void 0);_r=C([K()],_r);var Hn=class{};C([S(),v("design:type",Boolean)],Hn.prototype,"success",void 0);C([S(),v("design:type",String)],Hn.prototype,"message",void 0);C([S(),v("design:type",Boolean)],Hn.prototype,"requiresPassword",void 0);C([S(),v("design:type",Boolean)],Hn.prototype,"isExistingUser",void 0);Hn=C([K()],Hn);var nn=class{constructor(e,t,n,i=!1){this.email=e,this.remainingCredits=t,this.hotWalletAddress=n,this.freeAccess=i}};C([S(),v("design:type",String)],nn.prototype,"email",void 0);C([S(),v("design:type",String)],nn.prototype,"remainingCredits",void 0);C([S(),v("design:type",String)],nn.prototype,"hotWalletAddress",void 0);C([S(),v("design:type",Boolean)],nn.prototype,"freeAccess",void 0);nn=C([K(),v("design:paramtypes",[String,String,String,Boolean])],nn);var Nt=class{constructor(e,t){this.success=e,this.message=t}};C([S(),v("design:type",Boolean)],Nt.prototype,"success",void 0);C([S(),v("design:type",String)],Nt.prototype,"message",void 0);Nt=C([K(),v("design:paramtypes",[Boolean,String])],Nt);var Er=class{constructor(e,t,n,i,a,o,s){this.id=e,this.userEmail=t,this.timestamp=n,this.operation=i,this.cost=a,this.creditsAfter=o,this.summary=s}};C([S(),v("design:type",Number)],Er.prototype,"id",void 0);C([S(),v("design:type",String)],Er.prototype,"userEmail",void 0);C([S(),v("design:type",String)],Er.prototype,"timestamp",void 0);C([S(),v("design:type",String)],Er.prototype,"operation",void 0);C([S(),v("design:type",String)],Er.prototype,"summary",void 0);C([S(),v("design:type",Number)],Er.prototype,"cost",void 0);C([S(),v("design:type",Number)],Er.prototype,"creditsAfter",void 0);Er=C([K(),v("design:paramtypes",[Number,String,String,String,Number,Number,String])],Er);var M=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeGetNetworkMetrics(){return JSON.stringify({metrics:{},stats:{}})}runtimeRestartHolochain(){return!0}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,t,n,i){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return zr}runtimeFriendSendMessage(e,t){return!0}runtimeMessageInbox(e){return[zr]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:zr}]}runtimeMessageReceived(){return zr}exceptionOccurred(){return{title:"Test title",message:"Test message",type:fl.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,t){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,t){return!0}runtimeImportPerspective(e){return!0}runtimeMultiUserEnabled(){return!1}runtimeSetMultiUserEnabled(e){return e}runtimeFreeHostingEnabled(){return!0}runtimeSetFreeHostingEnabled(e){return e}runtimeListUsers(){return[{email:"test@example.com",did:"did:key:test123",lastSeen:new Date().toISOString(),perspectiveCount:5,remainingCredits:"0",freeAccess:!1}]}runtimeRequestLoginVerification(e,t){return{success:!0,message:"Verification email sent",requiresPassword:!1,isExistingUser:!0}}runtimeVerifyEmailCode(e,t,n){return"test-jwt-token-from-email-verification"}runtimeTestEmail(e){return!0}runtimeCreateUser(e,t,n){return new Mn("did:key:test123",!0)}runtimeLoginUser(e,t){return"test-jwt-token-from-password-login"}runtimeEmailTestModeEnable(){return!0}runtimeEmailTestModeDisable(){return!0}runtimeEmailTestGetCode(e){return"123456"}runtimeEmailTestClearCodes(){return!0}runtimeEmailTestSetExpiry(e,t,n){return!0}runtimeHostingUserInfo(){return new nn("test@example.com","100000000",null,!1)}runtimeComputeLog(e,t,n){return[]}runtimeSetHotWalletAddress(e){return!0}runtimeRequestPayment(e){return new Nt(!0,"Mock payment of "+e+" base units credited")}runtimeSetUserCredits(e,t){return!0}runtimeSetUserFreeAccess(e,t){return!0}runtimeReinstallUnytDna(){return new Nt(!0,"")}runtimeSendHot(e,t){return new Nt(!0,"")}runtimeSetUnytMembraneProof(e){return new Nt(!0,"")}runtimeHotWalletBalance(){return""}runtimeHotWalletHistory(e,t){return""}runtimeHotAgentPubkey(){return""}runtimeUnytAgentKey(){return""}runtimeUnytVersionInfo(){return""}};C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeQuit",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeOpenLink",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Mi)],M.prototype,"runtimeInfo",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"addTrustedAgents",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"deleteTrustedAgents",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Array)],M.prototype,"getTrustedAgents",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Array)],M.prototype,"runtimeKnownLinkLanguageTemplates",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"runtimeAddKnownLinkLanguageTemplates",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Array)],M.prototype,"runtimeFriends",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"runtimeAddFriends",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Array]),v("design:returntype",Array)],M.prototype,"runtimeRemoveFriends",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeHcAgentInfos",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeGetNetworkMetrics",null);C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeRestartHolochain",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Object]),v("design:returntype",Boolean)],M.prototype,"runtimeHcAddAgentInfos",null);C([Le(),V(0,B()),V(1,B()),V(2,B()),V(3,B()),v("design:type",Function),v("design:paramtypes",[String,String,String,String]),v("design:returntype",void 0)],M.prototype,"runtimeVerifyStringSignedByDid",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[ir]),v("design:returntype",Boolean)],M.prototype,"runtimeSetStatus",null);C([Le(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Fn)],M.prototype,"runtimeFriendStatus",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,Ds]),v("design:returntype",Boolean)],M.prototype,"runtimeFriendSendMessage",null);C([Le(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Array)],M.prototype,"runtimeMessageInbox",null);C([Le(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Array)],M.prototype,"runtimeMessageOutbox",null);C([gl(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Fn)],M.prototype,"runtimeMessageReceived",null);C([gl(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",zn)],M.prototype,"exceptionOccurred",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Lt]),v("design:returntype",String)],M.prototype,"runtimeRequestInstallNotification",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Array)],M.prototype,"runtimeNotifications",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,Lt]),v("design:returntype",Boolean)],M.prototype,"runtimeUpdateNotification",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeRemoveNotification",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeGrantNotification",null);C([gl(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Ui)],M.prototype,"runtimeNotificationTriggered",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeExportDb",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeImportDb",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,String]),v("design:returntype",Boolean)],M.prototype,"runtimeExportPerspective",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeImportPerspective",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeMultiUserEnabled",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Boolean]),v("design:returntype",Boolean)],M.prototype,"runtimeSetMultiUserEnabled",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeFreeHostingEnabled",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[Boolean]),v("design:returntype",Boolean)],M.prototype,"runtimeSetFreeHostingEnabled",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Array)],M.prototype,"runtimeListUsers",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,ar]),v("design:returntype",Hn)],M.prototype,"runtimeRequestLoginVerification",null);C([re(),V(0,B()),V(1,B()),V(2,B()),v("design:type",Function),v("design:paramtypes",[String,String,String]),v("design:returntype",String)],M.prototype,"runtimeVerifyEmailCode",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeTestEmail",null);C([re(),V(0,B()),V(1,B()),V(2,B()),v("design:type",Function),v("design:paramtypes",[String,String,ar]),v("design:returntype",Mn)],M.prototype,"runtimeCreateUser",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,String]),v("design:returntype",String)],M.prototype,"runtimeLoginUser",null);C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeEmailTestModeEnable",null);C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeEmailTestModeDisable",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",String)],M.prototype,"runtimeEmailTestGetCode",null);C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Boolean)],M.prototype,"runtimeEmailTestClearCodes",null);C([re(),V(0,B()),V(1,B()),V(2,B()),v("design:type",Function),v("design:paramtypes",[String,String,Number]),v("design:returntype",Boolean)],M.prototype,"runtimeEmailTestSetExpiry",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",nn)],M.prototype,"runtimeHostingUserInfo",null);C([Le(),V(0,B()),V(1,B()),V(2,B()),v("design:type",Function),v("design:paramtypes",[String,Number,String]),v("design:returntype",Array)],M.prototype,"runtimeComputeLog",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Boolean)],M.prototype,"runtimeSetHotWalletAddress",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Nt)],M.prototype,"runtimeRequestPayment",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,Number]),v("design:returntype",Boolean)],M.prototype,"runtimeSetUserCredits",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,Boolean]),v("design:returntype",Boolean)],M.prototype,"runtimeSetUserFreeAccess",null);C([re(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",Nt)],M.prototype,"runtimeReinstallUnytDna",null);C([re(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[String,String]),v("design:returntype",Nt)],M.prototype,"runtimeSendHot",null);C([re(),V(0,B()),v("design:type",Function),v("design:paramtypes",[String]),v("design:returntype",Nt)],M.prototype,"runtimeSetUnytMembraneProof",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeHotWalletBalance",null);C([Le(),V(0,B()),V(1,B()),v("design:type",Function),v("design:paramtypes",[Number,Number]),v("design:returntype",String)],M.prototype,"runtimeHotWalletHistory",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeHotAgentPubkey",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeUnytAgentKey",null);C([Le(),v("design:type",Function),v("design:paramtypes",[]),v("design:returntype",String)],M.prototype,"runtimeUnytVersionInfo",null);M=C([rv()],M);var YS=r=>{let e=new Set;do for(let t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};function Pl(r,{include:e,exclude:t}={}){let n=i=>{let a=o=>typeof o=="string"?i===o:o.test(i);return e?e.some(a):t?!t.some(a):!0};for(let[i,a]of YS(r.constructor.prototype)){if(a==="constructor"||!n(a))continue;let o=Reflect.getOwnPropertyDescriptor(i,a);o&&typeof o.value=="function"&&(r[a]=r[a].bind(r))}return r}function lm(r){return fe(this,null,function*(){let e=yield r.agent.hostingUserInfo();return{email:e.email,remainingCredits:e.remainingCredits==="unlimited"?1/0:parseFloat(e.remainingCredits)||0,hotWalletAddress:e.hotWalletAddress||null,freeAccess:e.freeAccess}})}function fm(r,e){return fe(this,null,function*(){return r.agent.requestPayment(e.toString())})}var XS=12e3,e_="https://hosting.ad4m.dev",t_=6e4,r_=10,Nl=class extends EventTarget{constructor(t){var i;super();this.connectionState="not-connected";this.authState="unauthenticated";this.activeSocket=null;this.requestedRestart=!1;this.connectedHost=null;this.userInfo=null;this.creditPollInterval=null;Pl(this),this.options=t,this.port=t.port||parseInt(pa("ad4m-port"))||XS,this.url=t.url||pa("ad4m-url")||`ws://localhost:${this.port}/graphql`,this.token=pa("ad4m-token")||"",this.embedded=Cp(),this.hostIndexUrl=t.hostIndexUrl||e_,this.lowCreditThreshold=(i=t.lowCreditThreshold)!=null?i:r_;let n=pa("ad4m-last-host");if(n)try{let a=JSON.parse(n);a&&a.id&&a.url&&a.name&&(this.connectedHost={id:a.id,name:a.name,profilePicUrl:a.profilePicUrl||"",location:a.location||"",url:a.url,rates:a.rates||[],aiModels:a.aiModels||[]})}catch(a){}this.embedded&&this.initializeEmbeddedMode()}connect(){return fe(this,null,function*(){if(this.embedded)return console.log("[Ad4m Connect] Embedded mode - waiting for AD4M config via postMessage"),new Promise((t,n)=>{let i=setTimeout(()=>{n(new Error("Timeout waiting for AD4M config from parent window"))},3e4);this.embeddedResolve=a=>{clearTimeout(i),console.log("[Ad4m Connect] Successfully connected in embedded mode"),t(a)},this.embeddedReject=a=>{clearTimeout(i),n(a)},this.ad4mClient&&(this.authState==="authenticated"?(clearTimeout(i),console.log("[Ad4m Connect] Client already initialized in embedded mode"),t(this.ad4mClient)):(clearTimeout(i),n(new Error(`Embedded auth state: ${this.authState}`))))});try{return yield Rp(this.url),Kt("ad4m-url",this.url),this.ad4mClient=yield this.buildClient(),yield this.checkAuth(),this.ad4mClient}catch(t){throw console.error("[Ad4m Connect] Connection failed:",t),this.notifyConnectionChange("error"),t}})}buildClient(){return fe(this,null,function*(){return this.notifyConnectionChange("connecting"),this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=vu({url:this.url,connectionParams:()=>fe(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:t=>{this.activeSocket=t},error:t=>{this.notifyConnectionChange("error")},connected:()=>{this.notifyConnectionChange("connected")},closed:t=>fe(this,null,function*(){if(!(t.wasClean||this.requestedRestart))if(!this.token)this.notifyConnectionChange("error");else try{this.ad4mClient=yield this.buildClient(),yield this.checkAuth()}catch(n){console.error("[Ad4m Connect] Reconnection failed:",n),this.notifyConnectionChange("error")}})}}),this.apolloClient=this.createApolloClient(this.wsClient),this.ad4mClient=new ao(this.apolloClient),this.requestedRestart=!1,this.ad4mClient})}createApolloClient(t){return new gu({link:new Op(t),cache:new Wo({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}})}withTempClient(t,n){return fe(this,null,function*(){let i=vu({url:t,connectionParams:()=>fe(this,null,function*(){return{headers:{authorization:""}}})}),a=this.createApolloClient(i),o=new ao(a);try{return yield n(o)}finally{i.dispose()}})}checkAuth(){return fe(this,null,function*(){try{return console.log("[Ad4m Connect] Checking authentication status..."),(yield this.ad4mClient.agent.isLocked())?(console.log("[Ad4m Connect] Agent wallet is locked"),this.notifyAuthChange("locked")):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(t){console.error("[Ad4m Connect] Authentication check failed:",t);let n="Cannot extractByTags from a ciphered wallet. You must unlock first.";return t.message===n?(this.notifyAuthChange("locked"),!0):(t.message==="InvalidSignature"&&(console.log("[Ad4m Connect] Clearing invalid token due to InvalidSignature"),this.token="",vi("ad4m-token")),this.notifyAuthChange("unauthenticated"),!1)}})}disconnect(){return fe(this,null,function*(){console.log("[Ad4m Connect] Disconnecting..."),this.wsClient&&(this.wsClient.dispose(),this.wsClient=null),this.apolloClient&&(this.apolloClient.stop(),this.apolloClient=null),this.ad4mClient=void 0,this.token="",vi("ad4m-token"),this.notifyAuthChange("unauthenticated"),this.connectedHost=null,this.userInfo=null,this.stopCreditPolling(),vi("ad4m-last-host"),this.notifyConnectionChange("not-connected"),console.log("[Ad4m Connect] Disconnected successfully")})}startCreditSubscription(){if(!!this.ad4mClient){try{this.ad4mClient.agent.addHostingUserInfoChangedListener(t=>{let n={email:t.email,remainingCredits:t.remainingCredits==="unlimited"?1/0:parseFloat(t.remainingCredits)||0,hotWalletAddress:t.hotWalletAddress||null,freeAccess:t.freeAccess};this.userInfo=n,this.dispatchEvent(new CustomEvent("userinfochange",{detail:n})),n.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted")),n.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow"))}),this.ad4mClient.agent.subscribeHostingUserInfoChanged()}catch(t){console.warn("[Ad4m Connect] Subscription not available, falling back to polling:",t)}try{this.ad4mClient.agent.addComputeLogUpdatedListener(t=>{this.dispatchEvent(new CustomEvent("computelogentry",{detail:t}))}),this.ad4mClient.agent.subscribeComputeLogUpdated()}catch(t){console.warn("[Ad4m Connect] Compute log subscription not available:",t)}this.startCreditPolling()}}startCreditPolling(){this.stopCreditPolling();let t=()=>fe(this,null,function*(){try{if(!this.ad4mClient)return;let n=yield lm(this.ad4mClient);this.userInfo=n,this.dispatchEvent(new CustomEvent("userinfochange",{detail:n})),n.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow")),n.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted"))}catch(n){console.error("[Ad4m Connect] Credit polling error:",n)}});t(),this.creditPollInterval=setInterval(t,t_)}stopCreditPolling(){this.creditPollInterval&&(clearInterval(this.creditPollInterval),this.creditPollInterval=null)}requestTopUp(t){return fe(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return fm(this.ad4mClient,t)})}fetchComputeLog(t,n){return fe(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return this.ad4mClient.agent.computeLog(t,n)})}setConnectedHost(t){this.connectedHost=t,Kt("ad4m-last-host",JSON.stringify({id:t.id,url:t.url,name:t.name,location:t.location}))}initializeEmbeddedMode(){console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent"),window.addEventListener("message",t=>fe(this,null,function*(){var n;if(((n=t.data)==null?void 0:n.type)==="AD4M_CONFIG"){if(t.source!==window.parent){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");return}if(this.options.allowedOrigins&&this.options.allowedOrigins.length>0&&(!t.origin||!this.options.allowedOrigins.includes(t.origin))){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from unauthorized origin:",t.origin),this.rejectEmbedded(new Error(`Unauthorized origin: ${t.origin}`));return}console.log("[Ad4m Connect] Received AD4M_CONFIG from parent:",{port:t.data.port,hasToken:!!t.data.token});let{port:i,token:a}=t.data;if(i==null){let c=new Error("AD4M_CONFIG missing required field: port");console.error("[Ad4m Connect]",c.message),this.rejectEmbedded(c);return}let o=parseInt(i,10);if(!Number.isFinite(o)||o<=0){let c=new Error(`AD4M_CONFIG invalid port: ${i} (must be a positive integer)`);console.error("[Ad4m Connect]",c.message),this.rejectEmbedded(c);return}let s=a!=null&&typeof a=="string"?a:"";try{this.port=o,this.token=s,this.url=`ws://localhost:${o}/graphql`,Kt("ad4m-port",o.toString()),s?Kt("ad4m-token",s):vi("ad4m-token"),Kt("ad4m-url",this.url),this.ad4mClient=yield this.buildClient(),yield this.checkAuth()}catch(c){console.error("[Ad4m Connect] Failed to initialize from AD4M_CONFIG:",c),this.rejectEmbedded(c)}}})),console.log("[Ad4m Connect] Requesting AD4M config from parent window"),window.parent.postMessage({type:"REQUEST_AD4M_CONFIG"},"*")}buildAppInfo(){return{appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appDomain:this.options.appInfo.url,appUrl:window.location.origin,appIconPath:this.options.appInfo.iconPath}}requestCapability(t=!1){return fe(this,null,function*(){return t&&(this.token="",vi("ad4m-token"),this.notifyConfigChange("token",this.token)),this.requestId=yield this.ad4mClient.agent.requestCapability({appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appUrl:this.options.appInfo.url,appDomain:this.options.appInfo.url,appIconPath:this.options.appInfo.iconPath,capabilities:this.options.capabilities}),this.requestId})}verifyLocalAd4mCode(t){return fe(this,null,function*(){if(!this.requestId)return console.error("[Ad4m Connect] Cannot verify code: requestId is missing. Call requestCapability() first to obtain a requestId."),!1;try{let n=yield this.ad4mClient.agent.generateJwt(this.requestId,t);return this.token=n,Kt("ad4m-token",this.token),yield this.connect(),!0}catch(n){return console.error("[Ad4m Connect] Code verification failed:",n),!1}})}isValidAd4mAPI(){return fe(this,null,function*(){try{return yield this.withTempClient(this.url,t=>fe(this,null,function*(){return yield t.runtime.info()})),!0}catch(t){return console.error("[Ad4m Connect] Failed to verify AD4M API:",t),!1}})}isMultiUser(){return fe(this,null,function*(){try{return yield this.withTempClient(this.url,t=>fe(this,null,function*(){return yield t.runtime.multiUserEnabled()}))}catch(t){return console.error("[Ad4m Connect] Failed to detect multi-user mode:",t),!1}})}submitEmail(t){return fe(this,null,function*(){try{return yield this.withTempClient(this.url,n=>fe(this,null,function*(){return yield n.agent.requestLoginVerification(t,this.buildAppInfo())}))}catch(n){return{success:!1,message:n.message||"Failed to process email. Please try again.",requiresPassword:!1,isExistingUser:!1}}})}verifyEmailCode(t,n){return fe(this,null,function*(){try{let i=yield this.withTempClient(this.url,a=>fe(this,null,function*(){return yield a.agent.verifyEmailCode(t,n,"login")}));return this.token=i,Kt("ad4m-token",this.token),yield this.connect(),!0}catch(i){return console.error("[Ad4m Connect] Email code verification failed:",i),!1}})}loginWithPassword(t,n){return fe(this,null,function*(){try{let i=yield this.withTempClient(this.url,a=>fe(this,null,function*(){return yield a.agent.loginUser(t,n)}));return this.token=i,Kt("ad4m-token",this.token),yield this.connect(),!0}catch(i){return console.error("[Ad4m Connect] Password login failed:",i),!1}})}createAccount(t,n){return fe(this,null,function*(){try{let i=yield this.withTempClient(this.url,a=>fe(this,null,function*(){let o=yield a.agent.createUser(t,n);if(o.success)return yield a.agent.loginUser(t,n);throw new Error(o.error||"Failed to create account")}));return this.token=i,Kt("ad4m-token",this.token),yield this.connect(),!0}catch(i){return console.error("[Ad4m Connect] Account creation error:",i),!1}})}resolveEmbedded(t){this.embeddedResolve&&(this.embeddedResolve(t),this.embeddedResolve=void 0,this.embeddedReject=void 0)}rejectEmbedded(t){this.embeddedReject&&(this.embeddedReject(t),this.embeddedResolve=void 0,this.embeddedReject=void 0)}notifyConnectionChange(t){this.connectionState!==t&&(this.connectionState=t,this.dispatchEvent(new CustomEvent("connectionstatechange",{detail:t})))}notifyAuthChange(t){if(this.authState=t,this.dispatchEvent(new CustomEvent("authstatechange",{detail:t})),this.embedded&&(t==="authenticated"&&this.resolveEmbedded(this.ad4mClient),t==="unauthenticated"||t==="locked")){let n=t==="locked"?"Authentication failed: Agent is locked":"Authentication failed: Unauthenticated";this.rejectEmbedded(new Error(n))}}notifyConfigChange(t,n){this.dispatchEvent(new CustomEvent("configstatechange",{detail:{type:t,value:n}}))}};export{Nl as default};
|
|
144
|
+
`);(d.gt!==void 0||d.gte!==void 0||d.lt!==void 0||d.lte!==void 0||d.between!==void 0||d.contains!==void 0)&&n.push(`
|
|
145
|
+
?source ${W(o.predicate)} ?wTarget_cmp_${s} .`)}else n.push(`
|
|
146
|
+
?source ${W(o.predicate)} ${W(String(a))} .`)}return{joins:n,filters:r}}var Vn=class{constructor(t,e,n){this.queryParams={},this.modelClassName=null,this.perspective=t,this.ctor=e,n&&(this.queryParams=n)}dispose(){this.currentSubscription&&(this.currentSubscription.dispose(),this.currentSubscription=void 0)}where(t){return this.queryParams.where=t,this}order(t){return this.queryParams.order=t,this}limit(t){return this.queryParams.limit=t,this}offset(t){return this.queryParams.offset=t,this}parent(t,e,n){let r=typeof t=="string"?t:t.id;if(typeof e=="object"&&e!==null&&!("prototype"in e)){if(typeof t=="string")throw new Error("parent() called with a string id and options object requires a model class as second argument");let a=t.constructor;return this.queryParams.parent={id:r,model:a,field:e.field},this}let s=n?.field;if(typeof e=="string")this.queryParams.parent={id:r,predicate:e};else if(typeof e=="function")this.queryParams.parent={id:r,model:e,...s&&{field:s}};else if(typeof t!="string")this.queryParams.parent={id:r,model:t.constructor,...s&&{field:s}};else throw new Error("parent() called with a string id requires a second argument: either a model class or a predicate string");return this}properties(t){return this.queryParams.properties=t,this}deepQuery(){return this.queryParams.deepQuery=!0,this}include(t){return this.queryParams.include=t,this}overrideModelClassName(t){return this.modelClassName=t,this}engine(t){return this}async get(){return await this.executeSparqlQuery()}async getSparql(){return this.executeSparqlQuery()}async executeSparqlQuery(){let{results:t}=await this.ctor.executeModelQuery(this.perspective,this.queryParams,this.modelClassName);return t}async first(){return this.queryParams.limit=1,(await this.get())[0]??null}async subscribe(t){this.dispose();let e=this.ctor,{className:n,queryJson:r,shapeJson:s}=e.prepareModelQueryParams(this.queryParams,this.modelClassName),{subscriptionId:a,result:o}=await this.perspective.modelSubscribe(n,r,s),l=f=>e.parseModelResult(this.perspective,f,this.queryParams.include,this.queryParams.properties),c=l(o),d=null,g=f=>f.length===0?"0:":JSON.stringify(f,(h,w)=>typeof w=="function"?void 0:w);d=g(c);let p=this.perspective.client.subscribeToQueryUpdates(a,f=>{if(!(f&&f.isInit))try{let h=l(f),w=g(h);if(w===d)return;d=w,t(h)}catch(h){console.error("Model subscription update parse error:",h)}}),u=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,a).catch(()=>{})},3e4);this.currentSubscription={dispose:()=>{clearInterval(u),p(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,a).catch(()=>{})}};for(let f of c)f.takeSnapshot?.(this.queryParams.include);return c}async subscribeSparql(t){return this.subscribe(t)}async count(){let{totalCount:t}=await this.ctor.executeModelQuery(this.perspective,{...this.queryParams,limit:0},this.modelClassName);return t}async countSparql(){return await this.count()}async countSubscribe(t){this.dispose();let e={...this.queryParams,limit:0},{className:n,queryJson:r,shapeJson:s}=this.ctor.prepareModelQueryParams(e,this.modelClassName),{subscriptionId:a,result:o}=await this.perspective.modelSubscribe(n,r,s),l=p=>(typeof p=="string"?JSON.parse(p):p).totalCount??0,c=l(o),d=this.perspective.client.subscribeToQueryUpdates(a,p=>{if(!(p&&p.isInit))try{t(l(p))}catch(u){console.error("Count subscription update parse error:",u)}}),g=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,a).catch(()=>{})},3e4);return this.currentSubscription={dispose:()=>{clearInterval(g),d(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,a).catch(()=>{})}},c}async countSubscribeSparql(t){return this.countSubscribe(t)}async paginate(t,e){let n={...this.queryParams||{},limit:t,offset:t*(e-1),count:!0},{results:r,totalCount:s}=await this.ctor.executeModelQuery(this.perspective,n,this.modelClassName);return{results:r,totalCount:s,pageSize:t,pageNumber:e}}async paginateSparql(t,e){return await this.paginate(t,e)}async paginateSubscribe(t,e,n){this.dispose();let r=this.ctor,s={...this.queryParams||{}};delete s.limit,delete s.offset;let{className:a,queryJson:o,shapeJson:l}=r.prepareModelQueryParams(s,this.modelClassName),{subscriptionId:c}=await this.perspective.modelSubscribe(a,o,l),d={...this.queryParams||{},limit:t,offset:t*(e-1),count:!0},g=async()=>{let{results:w,totalCount:y}=await r.executeModelQuery(this.perspective,d,this.modelClassName);n({results:w,totalCount:y,pageSize:t,pageNumber:e})},p=this.perspective.client.subscribeToQueryUpdates(c,w=>{w&&w.isInit||g().catch(y=>console.error("Paginate subscription error:",y))}),u=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,c).catch(()=>{})},3e4);this.currentSubscription={dispose:()=>{clearInterval(u),p(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,c).catch(()=>{})}};let{results:f,totalCount:h}=await r.executeModelQuery(this.perspective,d,this.modelClassName);return{results:f,totalCount:h,pageSize:t,pageNumber:e}}async paginateSubscribeSparql(t,e,n){return await this.paginateSubscribe(t,e,n)}};function Ft(i){return Array.isArray(i)?i.map(t=>t&&typeof t=="object"&&typeof t.id=="string"?t.id:t):i}function Yl(i,t){let e=Vi(i,t);if(!e){let n=t?.prototype?.className||t?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${n}".`);return}return e.getter}async function Ss(i,t,e,n){`${i.id}`;let s=n?.requestedProperties&&n.requestedProperties.length>0?new Set(n.requestedProperties):null;if(!n?.skipPropertyGetters){for(let[a,o]of Object.entries(e.properties))if(!(s&&!s.has(a))&&o.getter)try{let l=o.getter,c=l.replace(/\?source\b/g,`<${i.id}>`).replace(/<Base>/g,`<${i.id}>`).replace(/Base/g,`<${i.id}>`),d=c.trim().toUpperCase();if(d.startsWith("SELECT")||d.startsWith("ASK")||d.startsWith("CONSTRUCT")){let g=await t.querySparql(c);if(d.startsWith("ASK"))i[a]=g===!0||g==="true";else if(g&&g.length>0){let p=g[0],u=Object.keys(p)[0],f=p[u]?.value??p[u];f!=null&&f!=="None"&&f!==""&&(i[a]=f)}}else console.warn(`Unsupported legacy getter syntax for property ${a} \u2014 use native SPARQL (SELECT/ASK): ${l.slice(0,100)}`)}catch(l){console.warn(`Failed to evaluate getter for ${a}:`,l)}}for(let[a,o]of Object.entries(e.relations)){if(s&&!s.has(a)&&!(n?.include&&a in n.include))continue;let l=o,c=l.getter;if(!c&&l.where&&l.direction!=="reverse")try{let g=l.target?.(),p=g?g.getModelMetadata?.()??null:null,u=!0;if(p)for(let f of Object.keys(l.where)){if(["id","author","timestamp"].includes(f))continue;let h=p.properties[f];if(h&&(!h.resolveLanguage||h.resolveLanguage==="literal")){u=!1;break}}else u=!1;if(u){let f=Ki(l.where,p);f.length>0&&(c=`SELECT ?target WHERE { <Base> <${Ne(l.predicate)}> ?target . ${f.join(" ")} }`)}}catch(g){console.warn(`[Ad4mModel] where-clause compilation failed for relation "${a}":`,g)}if(!c&&l.target&&l.filter!==!1&&l.direction!=="reverse")try{let g=l.target();c=Yl(l.predicate,g),c||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${a}" (predicate: "${l.predicate}")`)}catch(g){console.warn(`[Ad4mModel] auto-generation failed for relation "${a}":`,g)}if(c)try{let g=c.replace(/\?source\b/g,`<${i.id}>`).replace(/<Base>/g,`<${i.id}>`).replace(/\bBase\b/g,`<${i.id}>`),p=g.trim().toUpperCase();if(p.startsWith("SELECT")||p.startsWith("ASK")||p.startsWith("CONSTRUCT")){let u=await t.querySparql(g);if(u&&u.length>0){let f=u.map(h=>{let w=Object.keys(h)[0];return h[w]?.value??h[w]}).filter(h=>h!=null&&h!==""&&h!=="None");i[a]=f}}else console.warn(`Unsupported legacy getter syntax for relation ${a} \u2014 use native SPARQL (SELECT/ASK): ${c.slice(0,100)}`)}catch(g){console.warn(`Failed to evaluate getter for ${a}:`,g)}let d=i[a];if(l.where&&Array.isArray(d)&&d.length>0){let g=l.target?.();if(g){let p=[];for(let u of d)try{let f=new g(t,u);await f.get();let h=!0;for(let[w,y]of Object.entries(l.where))if(f[w]!==y){h=!1;break}h&&p.push(u)}catch{p.push(u)}i[a]=p}}}}function Xn(i,t,e){for(let[n,r]of Object.entries(t)){if(!r)continue;let s=e[n];if(!s?.target)continue;let a=s.target(),o=JSON.parse(JSON.stringify(a.getModelMetadata()));i.relations[n]||(i.relations[n]={name:n,predicate:s.predicate,direction:s.kind==="belongsToMany"||s.kind==="belongsToOne"?"reverse":"forward"});let l=i.relations[n];l.kind=s.kind,l.maxCount=s.maxCount,l.targetShape=o,l.targetClassName=o.className;let c=typeof r=="object"&&r!==null?r.include:void 0;if(c){let d=te(a);Xn(o,c,d)}}}function rn(i,t,e,n,r){let s=new i(t,e.id||e.baseExpression);if(r){let a=new Set(Object.keys(e));for(let o of Object.getOwnPropertyNames(s))o==="id"||o==="baseExpression"||o==="perspective"||o.startsWith("_")||a.has(o)||delete s[o]}for(let[a,o]of Object.entries(e)){if(a==="baseExpression"||a==="id")continue;let l=!1,c=Object.getPrototypeOf(s);for(;c;){let d=Object.getOwnPropertyDescriptor(c,a);if(d){l=!!(d.get&&!d.set);break}c=Object.getPrototypeOf(c)}if(!l){if((a==="createdAt"||a==="updatedAt")&&typeof o=="string"&&o.includes("T")){s[a]=new Date(o).getTime();continue}s[a]=o}}try{let a=Je(i);for(let[o,l]of Object.entries(a)){let c=l;typeof c.transform!="function"||!(o in e)||c.resolveLanguage!=null&&c.resolveLanguage!=="literal"||(s[o]=c.transform(s[o]))}}catch{}if(n){let a=te(i);for(let[o,l]of Object.entries(n)){if(!l)continue;let c=a[o];if(!c?.target)continue;let d=c.target(),g=typeof l=="object"&&l!==null?l.include:void 0,p=typeof l=="object"&&l!==null?l.properties:void 0,u=s[o];Array.isArray(u)?s[o]=u.map(f=>typeof f=="object"&&f!==null&&f.id?rn(d,t,f,g,p):f):typeof u=="object"&&u!==null&&u.id&&(s[o]=rn(d,t,u,g,p))}}return s}var ki=class{get timestamp(){return this.createdAt}static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(t){if(this===ki)return await t.stringOrTemplateObjectToSubjectClassName(this);let n=this.classNamesByClass.get(this);n||(n={},this.classNamesByClass.set(this,n));let r=t.uuid;return n[r]||(n[r]=await t.stringOrTemplateObjectToSubjectClassName(this)),n[r]}static getModelMetadata(){let t=this.prototype;if(!t.className||t.className==="Ad4mModel")throw new Error("Model class must be decorated with @Model");let e=t.className,n={},r=Je(this);for(let[g,p]of Object.entries(r)){let u=p;n[g]={name:g,predicate:u.through||"",required:u.required||!1,readOnly:!(u.writable??!1),...u.initial!==void 0&&{initial:u.initial},...u.resolveLanguage!==void 0&&{resolveLanguage:u.resolveLanguage},...u.prologGetter!==void 0&&{prologGetter:u.prologGetter},...u.getter!==void 0&&{getter:u.getter},...u.prologSetter!==void 0&&{prologSetter:u.prologSetter},...u.local!==void 0&&{local:u.local},...u.transform!==void 0&&{transform:u.transform},...u.flag!==void 0&&{flag:u.flag}}}let s={},o=te(this);for(let[g,p]of Object.entries(o)){let u=p;s[g]={name:g,predicate:u.predicate||"",...u.local!==void 0&&{local:u.local},...u.getter!==void 0&&{getter:u.getter},direction:u.kind==="belongsToMany"||u.kind==="belongsToOne"?"reverse":"forward",...u.kind!==void 0&&{kind:u.kind},...u.maxCount!==void 0&&{maxCount:u.maxCount},...u.target!==void 0&&{target:u.target},...u.filter!==void 0&&{filter:u.filter},...u.where!==void 0&&{where:u.where}}}let l=Object.keys(n).length>0,c=Object.keys(s).length>0;if(!(l||c)&&t.__jsonSchema){let g=t.__jsonSchema,p=t.__jsonSchemaOptions||{};if(g.properties)for(let[u,f]of Object.entries(g.properties)){let h=ua(f),w=ha(g,u,f,fa(g,p),p);if(h)s[u]={name:u,predicate:w,...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}};else{let y=g.required?.includes(u)||!1;n[u]={name:u,predicate:w,required:y,readOnly:f["x-ad4m"]?.writable===!1,...f["x-ad4m"]?.resolveLanguage&&{resolveLanguage:f["x-ad4m"].resolveLanguage},...f["x-ad4m"]?.initial&&{initial:f["x-ad4m"].initial},...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}}}}}return{className:e,properties:n,relations:s}}constructor(t,e){this._snapshot=null,this._baseExpression=e||J.from(ks(24)).toUrl(),this._perspective=t}get id(){return this._baseExpression}get perspective(){return this._perspective}getPropertyMetadata(t){let e=this.constructor;return Je(e)[t]}getRelationOptions(t){let e=this.constructor;return te(e)[t]}generatePropertySetterAction(t,e){if(e.flag)throw new Error(`Property "${t}" is a @Flag and cannot be written. Flags are immutable type markers set at creation time.`);if(e.readOnly)throw new Error(`Property "${t}" is read-only and cannot be written`);if(e.prologSetter)throw new Error(`Custom Prolog setter for property "${t}" not yet supported without Prolog. Use standard @Property decorator or enable Prolog for custom setters.`);if(!e.through)throw new Error(`Property "${t}" has no 'through' predicate defined`);return[{action:"setSingleTarget",source:"this",predicate:e.through,target:"value",...e.local&&{local:!0}}]}generateRelationAction(t,e){let n=this.getRelationOptions(t);if(!n)throw new Error(`Relation "${t}" has no metadata defined`);if(!n.predicate)throw new Error(`Relation "${t}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[e],source:"this",predicate:n.predicate,target:"value",...n.local&&{local:!0}}]}takeSnapshot(t){let n=this.constructor.getModelMetadata(),r={};for(let s of Object.keys(n.properties)){let a=this[s];r[s]=Ft(Array.isArray(a)?[...a]:a)}if(t===void 0)for(let s of Object.keys(n.relations)){let a=this[s];r[s]=Ft(Array.isArray(a)?[...a]:a)}else if(t&&Object.keys(t).length>0){for(let s of Object.keys(t))if(s in n.relations){let a=this[s];r[s]=Ft(Array.isArray(a)?[...a]:a)}}this._snapshot=r}isDirty(){return this._snapshot?this.changedFields().length>0:!0}changedFields(){let e=this.constructor.getModelMetadata();if(!this._snapshot)return[...Object.keys(e.properties),...Object.keys(e.relations)];let n=[],r=[...Object.keys(e.properties),...Object.keys(e.relations)];for(let s of r){if(!(s in this._snapshot))continue;let a=Ft(this[s]),o=this._snapshot[s];if(Array.isArray(a)||Array.isArray(o)){let l=Array.isArray(a)?[...a].sort():[],c=Array.isArray(o)?[...o].sort():[];(l.length!==c.length||l.some((d,g)=>d!==c[g]))&&n.push(s)}else a!==o&&n.push(s)}return n}async getData(t){try{let e=this.constructor,n={where:{id:this._baseExpression},limit:1};t?.properties&&(n.properties=t.properties),t?.include&&(n.include=t.include);let{results:r}=await e.executeModelQuery(this._perspective,n,null);if(r.length>0){let s=r[0];for(let[a,o]of Object.entries(s)){if(a==="_baseExpression"||a==="_perspective"||a==="_snapshot"||a.startsWith("_"))continue;let l=!1,c=Object.getPrototypeOf(this);for(;c;){let d=Object.getOwnPropertyDescriptor(c,a);if(d){l=!!(d.get&&!d.set);break}c=Object.getPrototypeOf(c)}l||(this[a]=o)}}}catch(e){console.error(`getData via Rust model query failed for ${this._baseExpression}:`,e)}return this.takeSnapshot(t?.include),this}static async queryToSPARQL(t,e){let n=this.getModelMetadata(),r=te(this);return Gl(n,r,e,this)}static prepareModelQueryParams(t={},e){let n=this.getModelMetadata(),r=e||n.className,s={};if(t.parent){let a=di(t.parent,this);s.parent={id:t.parent.id,predicate:a}}if(t.properties&&(s.properties=t.properties),t.include&&(s.include=t.include),t.where&&(s.where=t.where),t.order&&(s.order=Object.entries(t.order).map(([a,o])=>[a,o])),t.offset!==void 0&&(s.offset=t.offset),t.limit!==void 0&&(s.limit=t.limit),t.count!==void 0&&(s.count=t.count),t.include){let a=te(this);Xn(n,t.include,a)}{let a=te(this);for(let[o,l]of Object.entries(n.relations)){let c=l;if(c.getter||c.direction==="reverse"||c.filter===!1)continue;let d=a[o];if(!!d?.target)try{let g=d.target(),p=Vi(d.predicate,g),u=[];if(c.where)try{let f=g.getModelMetadata?.()??null,h=!0;if(f)for(let w of Object.keys(c.where)){if(["id","author","timestamp"].includes(w))continue;let y=f.properties[w];if(y&&(!y.resolveLanguage||y.resolveLanguage==="literal")){h=!1;break}}else h=!1;h&&(u=Ki(c.where,f))}catch{}if(p){let f=p.getter;u.length>0&&(f=f.replace(/ \}$/,` ${u.join(" ")} }`)),c.getter=f}else if(u.length>0){let f=d.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g,"");c.getter=`SELECT ?target WHERE { <Base> <${f}> ?target . ${u.join(" ")} }`}}catch{}}}return{className:r,queryJson:JSON.stringify(s),shapeJson:JSON.stringify(n)}}static parseModelResult(t,e,n,r){let s=typeof e=="string"?JSON.parse(e):e,a=s.instances||s;return Array.isArray(a)?a.map(o=>rn(this,t,o,n,r)):[]}static async executeModelQuery(t,e={},n){let r=this.getModelMetadata(),s=n||r.className;if(e.includeAll){let h=te(this),w={};for(let[y,v]of Object.entries(h))v.direction!=="reverse"&&(w[y]=!0);e={...e,include:{...w,...e.include}}}let a={};if(e.parent){let h=di(e.parent,this);a.parent={id:e.parent.id,predicate:h}}if(e.properties&&(a.properties=e.properties),e.include){let h={},w={};for(let[y,v]of Object.entries(e.include))y.startsWith("$")?w[y]=v:h[y]=v;if(Object.keys(h).length>0&&(a.include=h),Object.keys(w).length>0){let y=te(this);for(let[,v]of Object.entries(w)){let S=y[v.from];if(!v.targetShape&&S?.target)try{let T=S.target().getModelMetadata?.();T&&(v.targetShape=T)}catch{}}a.projections=w}}if(e.where&&(a.where=e.where),e.order&&(a.order=Object.entries(e.order).map(([h,w])=>[h,w])),e.offset!==void 0&&(a.offset=e.offset),e.limit!==void 0&&(a.limit=e.limit),e.count!==void 0&&(a.count=e.count),a.include){let h=te(this);Xn(r,a.include,h)}{let h=te(this);for(let[w,y]of Object.entries(r.relations)){let v=y;if(v.getter||v.direction==="reverse"||v.filter===!1)continue;let S=h[w];if(!!S?.target)try{let b=S.target(),T=Vi(S.predicate,b),O=[];if(v.where)try{let C=b.getModelMetadata?.()??null,P=!0;if(C)for(let R of Object.keys(v.where)){if(["id","author","timestamp"].includes(R))continue;let x=C.properties[R];if(x&&(!x.resolveLanguage||x.resolveLanguage==="literal")){P=!1;break}}else P=!1;P&&(O=Ki(v.where,C))}catch{}if(T){let C=T.getter;O.length>0&&(C=C.replace(/ \}$/,` ${O.join(" ")} }`)),v.getter=C}else if(O.length>0){let C=S.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g,"");v.getter=`SELECT ?target WHERE { <Base> <${C}> ?target . ${O.join(" ")} }`}}catch{}}}let o=JSON.stringify(r),l=JSON.stringify(a),c=await t.modelQuery(s,l,o),d=c.instances.map(h=>rn(this,t,h,e.include,e.properties)),g=Je(this),p=Object.entries(g).filter(([,h])=>h.resolveLanguage!=null&&h.resolveLanguage!=="literal");p.length>0&&await Promise.all(d.map(async h=>{for(let[w,y]of p){let v=h[w];if(!(typeof v!="string"||!v||v.startsWith("literal:")))try{let S=await t.getExpression(v);if(S){let b;try{b=JSON.parse(S.data)}catch{b=S.data}let T=y.transform;h[w]=typeof T=="function"?T(b):b}}catch{}}}));let u=a.include?new Set(Object.keys(a.include)):new Set;for(let h of d){let w={};for(let y of u)h[y]!==void 0&&(w[y]=h[y]);await Ss(h,t,r,{skipPropertyGetters:!0});for(let[y,v]of Object.entries(w))h[y]=v;for(let[y,v]of Object.entries(r.relations)){if(u.has(y))continue;let S=v.kind;if((S==="hasOne"||S==="belongsToOne")&&Array.isArray(h[y])){let b=h[y];h[y]=b.length>0?b[0]:null}}}let f=a.include;for(let h of d)h.takeSnapshot(f);return{results:d,totalCount:c.totalCount}}static async findAll(t,e={},n){if(e.properties&&e.properties.length===0)throw new Error("properties[] must not be empty \u2014 omit the field to return all properties, or specify at least one field name");let{results:r}=await this.executeModelQuery(t,e);return r}static async findOne(t,e={},n){let r={...e,limit:1};return(await this.findAll(t,r))[0]??null}static async findAllAndCount(t,e={},n){return await this.executeModelQuery(t,e)}static async paginate(t,e,n,r,s){let a={...r||{},limit:e,offset:e*(n-1),count:!0},{results:o,totalCount:l}=await this.executeModelQuery(t,a);return{results:o,totalCount:l,pageSize:e,pageNumber:n}}static async count(t,e={}){let{totalCount:n}=await this.executeModelQuery(t,{...e,limit:0});return n}async setProperty(t,e,n){let r=this.getPropertyMetadata(t);if(!r){console.warn(`Property "${t}" has no metadata, skipping`);return}let s=this.generatePropertySetterAction(t,r),a=r.resolveLanguage;e==null||e===""||(a&&(e=await this._perspective.createExpression(e,a)),await this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:e}],n))}resolveRelationId(t){return typeof t=="string"?t:t&&typeof t=="object"&&typeof t.id=="string"?t.id:String(t)}async setRelationValues(t,e,n){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let s=this.generateRelationAction(t,"setter");e!=null&&(Array.isArray(e)?await this._perspective.executeAction(s,this._baseExpression,e.map(a=>({name:"value",value:this.resolveRelationId(a)})),n):await this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],n))}async addRelationValue(t,e,n){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let s=this.generateRelationAction(t,"adder");e!=null&&(Array.isArray(e)?await Promise.all(e.map(a=>this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:this.resolveRelationId(a)}],n))):await this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],n))}async removeRelationValue(t,e,n){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let s=this.generateRelationAction(t,"remover");e!=null&&(Array.isArray(e)?await Promise.all(e.map(a=>this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:this.resolveRelationId(a)}],n))):await this._perspective.executeAction(s,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],n))}async save(t){if(this._snapshot){await this.innerUpdate(!0,t),t?this.takeSnapshot():await this.getData();return}let e=!1;t||(t=await this.perspective.createBatch(),e=!0);let n=this.constructor.getModelMetadata(),r=Object.values(n.properties).some(a=>a.required||a.flag||a.initial!==void 0),s=[];if(r){let a={};for(let[l,c]of Object.entries(this))if(c!=null&&!(Array.isArray(c)&&c.length>0)&&!c?.action){let d=n.properties[l];if(d?.resolveLanguage&&d.resolveLanguage!=="literal"&&typeof c=="object"){s.push(l);continue}a[l]=c}let o=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(o,this._baseExpression,a,t)}await this.innerUpdate(!r,t);for(let a of s){let o=this[a];o!=null&&await this.setProperty(a,o,t)}e?(await this.perspective.commitBatch(t),await this.getData()):this.takeSnapshot()}cleanCopy(){let e=this.constructor.getModelMetadata(),n={},r=new Set([...Object.keys(e.properties),...Object.keys(e.relations)]);for(let s of r){let a=this[s];a!=null&&s!=="author"&&s!=="timestamp"&&(n[s]=a)}return n}async innerUpdate(t=!0,e){let n=this.constructor,r=this._snapshot?new Set(this.changedFields()):null,s=n.getModelMetadata(),a=new Set([...Object.keys(s.properties),...Object.keys(s.relations)]),o=Object.entries(this);for(let[l,c]of o){if(!a.has(l)||r&&!r.has(l))continue;let d=s.relations[l];if(!(d&&(d.getter||d.target&&d.filter!==!1&&Object.entries(s.relations).some(([p,u])=>p!==l&&u.predicate===d.predicate)))&&c!=null){if(c?.action)switch(c.action){case"setter":await this.setRelationValues(l,c.value,e);break;case"adder":await this.addRelationValue(l,c.value,e);break;case"remover":await this.removeRelationValue(l,c.value,e);break;default:await this.setRelationValues(l,c.value,e);break}else if(Array.isArray(c))await this.setRelationValues(l,c,e);else if(c!=null&&c!==""&&t){if(this.getRelationOptions(l)||this.getPropertyMetadata(l)?.flag)continue;await this.setProperty(l,c,e)}}}}static async evaluateGetters(t,e,n){if(t.length===0)return;let r=this.getModelMetadata(),s=n&&n.length>0?{requestedProperties:n}:void 0,a=[];for(let[o,l]of Object.entries(r.properties))l.getter&&(!n||n.length===0||n.includes(o))&&a.push(o);for(let o of t){await Ss(o,e,r,s);let l=o;if(l._snapshot)for(let c of a){let d=o[c];l._snapshot[c]=Ft(Array.isArray(d)?[...d]:d)}}}async get(t){let e;return t?"include"in t||"properties"in t?e=t:e={include:t}:e=void 0,await this.getData(e)}async delete(t){let e=this.constructor.getModelMetadata();if(Object.values(e.properties).some(r=>r.required||r.flag||r.initial!==void 0))await this._perspective.removeSubject(this,this._baseExpression,t);else try{let r=new Set;for(let o of Object.values(e.properties))o.predicate&&r.add(o.predicate);for(let o of Object.values(e.relations))o.predicate&&r.add(o.predicate);let a=(await this._perspective.get(new Z({source:this._baseExpression}))).filter(o=>o.data.predicate&&r.has(o.data.predicate));a.length>0&&await this._perspective.removeLinks(a,t)}catch(r){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,r)}try{let r=await this._perspective.get(new Z({target:this._baseExpression}));r.length>0&&await this._perspective.removeLinks(r,t)}catch(r){console.warn(`delete(): failed to clean up incoming links for ${this._baseExpression}:`,r)}}static async create(t,e={},n){let r=new this(t);if(Object.assign(r,e),n?.parent&&!n?.batchId){let s=await t.createBatch();await r.save(s);let a=di(n.parent,this),o=new me({source:n.parent.id,predicate:a,target:r.id});return await t.add(o,"shared",s),await t.commitBatch(s),await r.get(),r}if(await r.save(n?.batchId),n?.parent){let s=di(n.parent,this),a=new me({source:n.parent.id,predicate:s,target:r.id});await t.add(a,"shared",n?.batchId)}return r}static async update(t,e,n){let r=new this(t,e);return await r.get(),Object.assign(r,n),await r.save(),r}static async remove(t,e){return this.delete(t,e)}static async delete(t,e){await new this(t,e).delete()}static async register(t){await t.ensureSDNASubjectClass(this)}static async transaction(t,e){let n=await t.createBatch(),r=await e({batchId:n});return await t.commitBatch(n),r}static query(t,e){return new Vn(t,this,e)}static fromJSONSchema(t,e){return Zl(this,t,e)}static fromSHACL(t,e){let n=class extends this{};n.className=e,n.prototype.className=e;let r=new Map;for(let a of t.constructor_actions??[])a.action==="addLink"&&typeof a.predicate=="string"&&typeof a.target=="string"&&a.target!=="value"&&!a.target.startsWith("literal:")&&r.set(a.predicate,a.target);for(let a of t.properties){let o=a.hasValue??r.get(a.path);if(o!==void 0){let c=a.name??`_flag_${a.path.replace(/[^a-zA-Z0-9_]/g,"_")}`;$n(n,c,{through:a.path,required:!0,initial:o,flag:!0,writable:!1,readOnly:!0});continue}if(!a.name)continue;a.maxCount===void 0||a.maxCount>1?xs(n,a.name,{predicate:a.path,kind:"hasMany",...a.local!==void 0&&{local:a.local},...a.getter!==void 0&&{getter:a.getter}}):$n(n,a.name,{through:a.path,writable:a.writable??!0,...a.resolveLanguage!==void 0&&{resolveLanguage:a.resolveLanguage},...a.local!==void 0&&{local:a.local}})}return As({name:e})(n),n}};ki.classNamesByClass=new WeakMap;var Cs=class extends Ke(){};var ed=i=>{let t=new Set;do for(let e of Reflect.ownKeys(i))t.add([i,e]);while((i=Reflect.getPrototypeOf(i))&&i!==Object.prototype);return t};function cr(i,{include:t,exclude:e}={}){let n=r=>{let s=a=>typeof a=="string"?r===a:a.test(r);return t?t.some(s):e?!e.some(s):!0};for(let[r,s]of ed(i.constructor.prototype)){if(s==="constructor"||!n(s))continue;let a=Reflect.getOwnPropertyDescriptor(r,s);a&&typeof a.value=="function"&&(i[s]=i[s].bind(i))}return i}function ga(i){return z(this,null,function*(){let t=yield i.agent.hostingUserInfo();return{email:t.email,remainingCredits:t.remainingCredits==="unlimited"?1/0:parseFloat(t.remainingCredits)||0,hotWalletAddress:t.hotWalletAddress||null,freeAccess:t.freeAccess}})}function ma(i,t){return z(this,null,function*(){return i.agent.requestPayment(t.toString())})}var td=12e3,id="https://hosting.ad4m.dev",nd=6e4,rd=10,lr=class extends EventTarget{constructor(e){var r;super();this.connectionState="not-connected";this.authState="unauthenticated";this.requestedRestart=!1;this.connectedHost=null;this.userInfo=null;this.creditPollInterval=null;cr(this),this.options=e,this.port=e.port||parseInt(Ut("ad4m-port"))||td,this.url=e.url||Ut("ad4m-url")||`http://localhost:${this.port}`,this.token=Ut("ad4m-token")||"",this.embedded=dr(),this.hostIndexUrl=e.hostIndexUrl||id,this.lowCreditThreshold=(r=e.lowCreditThreshold)!=null?r:rd;let n=Ut("ad4m-last-host");if(n)try{let s=JSON.parse(n);s&&s.id&&s.url&&s.name&&(this.connectedHost={id:s.id,name:s.name,profilePicUrl:s.profilePicUrl||"",location:s.location||"",url:s.url,rates:s.rates||[],aiModels:s.aiModels||[]})}catch(s){}this.embedded&&this.initializeEmbeddedMode()}get baseUrl(){return dn(this.url)}connect(){return z(this,null,function*(){if(this.embedded)return console.log("[Ad4m Connect] Embedded mode - waiting for AD4M config via postMessage"),new Promise((e,n)=>{let r=setTimeout(()=>{n(new Error("Timeout waiting for AD4M config from parent window"))},3e4);this.embeddedResolve=s=>{clearTimeout(r),console.log("[Ad4m Connect] Successfully connected in embedded mode"),e(s)},this.embeddedReject=s=>{clearTimeout(r),n(s)},this.ad4mClient&&(this.authState==="authenticated"?(clearTimeout(r),console.log("[Ad4m Connect] Client already initialized in embedded mode"),e(this.ad4mClient)):(clearTimeout(r),n(new Error(`Embedded auth state: ${this.authState}`))))});try{return yield ur(this.baseUrl),_e("ad4m-url",this.url),this.ad4mClient=this.buildClient(),yield this.checkAuth(),this.ad4mClient}catch(e){throw console.error("[Ad4m Connect] Connection failed:",e),this.notifyConnectionChange("error"),e}})}buildClient(){return this.notifyConnectionChange("connecting"),this.ad4mClient&&typeof this.ad4mClient.close=="function"&&this.ad4mClient.close(),this.ad4mClient=new Ci(this.baseUrl,this.token,!1),this.notifyConnectionChange("connected"),this.ad4mClient}withTempClient(e,n){return z(this,null,function*(){let r=dn(e),s=new Ci(r,void 0,!1);try{return yield n(s)}finally{s.close()}})}checkAuth(){return z(this,null,function*(){try{console.log("[Ad4m Connect] Checking authentication status...");let e=!1;try{e=yield this.ad4mClient.agent.isLocked()}catch(n){let r=(n==null?void 0:n.message)||"";if(r==="Cannot extractByTags from a ciphered wallet. You must unlock first.")return console.log("[Ad4m Connect] Agent wallet is locked (error path)"),this.notifyAuthChange("locked"),!0;console.warn("[Ad4m Connect] isLocked check unavailable, assuming unlocked:",r)}return e?(console.log("[Ad4m Connect] Agent wallet is locked"),this.notifyAuthChange("locked")):(yield this.ad4mClient.agent.status(),this.ad4mClient.startSubscriptions(),this.notifyAuthChange("authenticated")),!0}catch(e){return console.error("[Ad4m Connect] Authentication check failed:",e),e.message==="InvalidSignature"&&(console.log("[Ad4m Connect] Clearing invalid token due to InvalidSignature"),this.token="",bt("ad4m-token")),this.notifyAuthChange("unauthenticated"),!1}})}disconnect(){return z(this,null,function*(){console.log("[Ad4m Connect] Disconnecting..."),this.ad4mClient=void 0,this.token="",bt("ad4m-token"),this.notifyAuthChange("unauthenticated"),this.connectedHost=null,this.userInfo=null,this.stopCreditPolling(),bt("ad4m-last-host"),this.notifyConnectionChange("not-connected"),console.log("[Ad4m Connect] Disconnected successfully")})}startCreditSubscription(){if(!!this.ad4mClient){try{this.ad4mClient.agent.addHostingUserInfoChangedListener(e=>{let n={email:e.email,remainingCredits:e.remainingCredits==="unlimited"?1/0:parseFloat(e.remainingCredits)||0,hotWalletAddress:e.hotWalletAddress||null,freeAccess:e.freeAccess};this.userInfo=n,this.dispatchEvent(new CustomEvent("userinfochange",{detail:n})),!n.freeAccess&&n.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted")),!n.freeAccess&&n.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow"))}),this.ad4mClient.agent.subscribeHostingUserInfoChanged()}catch(e){console.warn("[Ad4m Connect] Subscription not available, falling back to polling:",e)}try{this.ad4mClient.agent.addComputeLogUpdatedListener(e=>{this.dispatchEvent(new CustomEvent("computelogentry",{detail:e}))}),this.ad4mClient.agent.subscribeComputeLogUpdated()}catch(e){console.warn("[Ad4m Connect] Compute log subscription not available:",e)}this.startCreditPolling()}}startCreditPolling(){this.stopCreditPolling();let e=()=>z(this,null,function*(){try{if(!this.ad4mClient)return;let n=yield ga(this.ad4mClient);this.userInfo=n,this.dispatchEvent(new CustomEvent("userinfochange",{detail:n})),!n.freeAccess&&n.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow")),!n.freeAccess&&n.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted"))}catch(n){console.error("[Ad4m Connect] Credit polling error:",n)}});e(),this.creditPollInterval=setInterval(e,nd)}stopCreditPolling(){this.creditPollInterval&&(clearInterval(this.creditPollInterval),this.creditPollInterval=null)}requestTopUp(e){return z(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return ma(this.ad4mClient,e)})}fetchComputeLog(e,n){return z(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return this.ad4mClient.agent.computeLog(e,n)})}setConnectedHost(e){this.connectedHost=e,_e("ad4m-last-host",JSON.stringify({id:e.id,url:e.url,name:e.name,location:e.location}))}initializeEmbeddedMode(){var r;console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent"),window.addEventListener("message",s=>z(this,null,function*(){var a;if(((a=s.data)==null?void 0:a.type)==="AD4M_CONFIG"){if(s.source!==window.parent){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");return}if(this.options.allowedOrigins&&this.options.allowedOrigins.length>0&&(!s.origin||!this.options.allowedOrigins.includes(s.origin))){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from unauthorized origin:",s.origin),this.rejectEmbedded(new Error(`Unauthorized origin: ${s.origin}`));return}console.log("[Ad4m Connect] Received AD4M_CONFIG from parent:",{port:s.data.port,hasToken:!!s.data.token});let{port:o,token:l}=s.data;if(o==null){let g=new Error("AD4M_CONFIG missing required field: port");console.error("[Ad4m Connect]",g.message),this.rejectEmbedded(g);return}let c=parseInt(o,10);if(!Number.isFinite(c)||c<=0){let g=new Error(`AD4M_CONFIG invalid port: ${o} (must be a positive integer)`);console.error("[Ad4m Connect]",g.message),this.rejectEmbedded(g);return}let d=l!=null&&typeof l=="string"?l:"";try{this.port=c,this.token=d,this.url=`http://localhost:${c}`,_e("ad4m-port",c.toString()),d?_e("ad4m-token",d):bt("ad4m-token"),_e("ad4m-url",this.url),this.ad4mClient=this.buildClient(),yield this.checkAuth()}catch(g){console.error("[Ad4m Connect] Failed to initialize from AD4M_CONFIG:",g),this.rejectEmbedded(g)}}})),console.log("[Ad4m Connect] Requesting AD4M config from parent window");let e="*",n=document.referrer?new URL(document.referrer).origin:null;n&&((r=this.options.allowedOrigins)==null?void 0:r.includes(n))?e=n:this.options.allowedOrigins&&this.options.allowedOrigins.length===1&&(e=this.options.allowedOrigins[0]),window.parent.postMessage({type:"REQUEST_AD4M_CONFIG"},e)}buildAppInfo(){return{appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appDomain:this.options.appInfo.url,appUrl:window.location.origin,appIconPath:this.options.appInfo.iconPath}}requestCapability(e=!1){return z(this,null,function*(){return e&&(this.token="",bt("ad4m-token"),this.notifyConfigChange("token",this.token)),this.requestId=yield this.ad4mClient.agent.requestCapability({appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appUrl:this.options.appInfo.url,appDomain:this.options.appInfo.url,appIconPath:this.options.appInfo.iconPath,capabilities:this.options.capabilities}),this.requestId})}verifyLocalAd4mCode(e){return z(this,null,function*(){if(!this.requestId)return console.error("[Ad4m Connect] Cannot verify code: requestId is missing. Call requestCapability() first to obtain a requestId."),!1;try{let n=yield this.ad4mClient.agent.generateJwt(this.requestId,e);return this.token=n,_e("ad4m-token",this.token),yield this.connect(),!0}catch(n){return console.error("[Ad4m Connect] Code verification failed:",n),!1}})}isValidAd4mAPI(){return z(this,null,function*(){try{return yield this.withTempClient(this.url,e=>z(this,null,function*(){return yield e.runtime.info()})),!0}catch(e){return console.error("[Ad4m Connect] Failed to verify AD4M API:",e),!1}})}isMultiUser(){return z(this,null,function*(){try{return yield this.withTempClient(this.url,e=>z(this,null,function*(){return yield e.runtime.multiUserEnabled()}))}catch(e){return console.error("[Ad4m Connect] Failed to detect multi-user mode:",e),!1}})}submitEmail(e){return z(this,null,function*(){try{return yield this.withTempClient(this.url,n=>z(this,null,function*(){return yield n.agent.requestLoginVerification(e,this.buildAppInfo())}))}catch(n){return{success:!1,message:n.message||"Failed to process email. Please try again.",requiresPassword:!1,isExistingUser:!1}}})}verifyEmailCode(e,n){return z(this,null,function*(){try{let r=yield this.withTempClient(this.url,s=>z(this,null,function*(){return yield s.agent.verifyEmailCode(e,n,"login")}));return this.token=r,_e("ad4m-token",this.token),yield this.connect(),!0}catch(r){return console.error("[Ad4m Connect] Email code verification failed:",r),!1}})}loginWithPassword(e,n){return z(this,null,function*(){try{let r=yield this.withTempClient(this.url,s=>z(this,null,function*(){return yield s.agent.loginUser(e,n)}));return this.token=r,_e("ad4m-token",this.token),yield this.connect(),!0}catch(r){return console.error("[Ad4m Connect] Password login failed:",r),!1}})}createAccount(e,n){return z(this,null,function*(){try{let r=yield this.withTempClient(this.url,s=>z(this,null,function*(){let a=yield s.agent.createUser(e,n);if(a.success)return yield s.agent.loginUser(e,n);throw new Error(a.error||"Failed to create account")}));return this.token=r,_e("ad4m-token",this.token),yield this.connect(),!0}catch(r){return console.error("[Ad4m Connect] Account creation error:",r),!1}})}resolveEmbedded(e){this.embeddedResolve&&(this.embeddedResolve(e),this.embeddedResolve=void 0,this.embeddedReject=void 0)}rejectEmbedded(e){this.embeddedReject&&(this.embeddedReject(e),this.embeddedResolve=void 0,this.embeddedReject=void 0)}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.dispatchEvent(new CustomEvent("connectionstatechange",{detail:e})))}notifyAuthChange(e){if(this.authState=e,this.dispatchEvent(new CustomEvent("authstatechange",{detail:e})),this.embedded&&(e==="authenticated"&&this.resolveEmbedded(this.ad4mClient),e==="unauthenticated"||e==="locked")){let n=e==="locked"?"Authentication failed: Agent is locked":"Authentication failed: Unauthenticated";this.rejectEmbedded(new Error(n))}}notifyConfigChange(e,n){this.dispatchEvent(new CustomEvent("configstatechange",{detail:{type:e,value:n}}))}};export{lr as default};
|
|
1779
147
|
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|