jat-feedback 2.0.0 → 2.0.1

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.
@@ -1,6 +1,6 @@
1
- var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=>Te in Se?pr(Se,Te,{enumerable:!0,configurable:!0,writable:!0,value:Oe}):Se[Te]=Oe;var te=(Se,Te,Oe)=>hr(Se,typeof Te!="symbol"?Te+"":Te,Oe),Gn=(Se,Te,Oe)=>Te.has(Se)||nr("Cannot "+Oe);var E=(Se,Te,Oe)=>(Gn(Se,Te,"read from private field"),Oe?Oe.call(Se):Te.get(Se)),ue=(Se,Te,Oe)=>Te.has(Se)?nr("Cannot add the same private member more than once"):Te instanceof WeakSet?Te.add(Se):Te.set(Se,Oe),ae=(Se,Te,Oe,It)=>(Gn(Se,Te,"write to private field"),It?It.call(Se,Oe):Te.set(Se,Oe),Oe),je=(Se,Te,Oe)=>(Gn(Se,Te,"access private method"),Oe);(function(){"use strict";var Se,Te,Oe,It,sn,Ht,an,gn,vn,qt,Nt,ln,bt,Yn,Xn,rr,tt,_n,yt,Wt,wt,it,Xe,xt,Ot,Ut,Gt,Lt,cn,Yt,un,dn,Pt,Tn,Le,or,sr,Kn,On,Ln,Jn,Qn,er,dt,kt,nt,Xt,mn,bn,Cn,Mt,at,tr;const PUBLIC_VERSION="5";typeof window<"u"&&((Se=window.__svelte??(window.__svelte={})).v??(Se.v=new Set)).add("5");const EACH_ITEM_REACTIVE=1,EACH_INDEX_REACTIVE=2,EACH_IS_CONTROLLED=4,EACH_IS_ANIMATED=8,EACH_ITEM_IMMUTABLE=16,PROPS_IS_IMMUTABLE=1,PROPS_IS_UPDATED=4,PROPS_IS_BINDABLE=8,PROPS_IS_LAZY_INITIAL=16,TRANSITION_GLOBAL=4,TEMPLATE_FRAGMENT=1,TEMPLATE_USE_IMPORT_NODE=2,HYDRATION_START="[",HYDRATION_START_ELSE="[!",HYDRATION_END="]",HYDRATION_ERROR={},UNINITIALIZED=Symbol(),NAMESPACE_HTML="http://www.w3.org/1999/xhtml",DEV=!1;var is_array=Array.isArray,index_of=Array.prototype.indexOf,includes=Array.prototype.includes,array_from=Array.from,object_keys=Object.keys,define_property=Object.defineProperty,get_descriptor=Object.getOwnPropertyDescriptor,get_descriptors=Object.getOwnPropertyDescriptors,object_prototype=Object.prototype,array_prototype=Array.prototype,get_prototype_of=Object.getPrototypeOf,is_extensible=Object.isExtensible;function is_function(e){return typeof e=="function"}const noop=()=>{};function run_all(e){for(var t=0;t<e.length;t++)e[t]()}function deferred(){var e,t,n=new Promise((r,o)=>{e=r,t=o});return{promise:n,resolve:e,reject:t}}const DERIVED=2,EFFECT=4,RENDER_EFFECT=8,MANAGED_EFFECT=1<<24,BLOCK_EFFECT=16,BRANCH_EFFECT=32,ROOT_EFFECT=64,BOUNDARY_EFFECT=128,CONNECTED=512,CLEAN=1024,DIRTY=2048,MAYBE_DIRTY=4096,INERT=8192,DESTROYED=16384,REACTION_RAN=32768,EFFECT_TRANSPARENT=65536,EAGER_EFFECT=1<<17,HEAD_EFFECT=1<<18,EFFECT_PRESERVED=1<<19,USER_EFFECT=1<<20,EFFECT_OFFSCREEN=1<<25,WAS_MARKED=65536,REACTION_IS_UPDATING=1<<21,ASYNC=1<<22,ERROR_VALUE=1<<23,STATE_SYMBOL=Symbol("$state"),LEGACY_PROPS=Symbol("legacy props"),LOADING_ATTR_SYMBOL=Symbol(""),STALE_REACTION=new class extends Error{constructor(){super(...arguments);te(this,"name","StaleReactionError");te(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},IS_XHTML=((Oe=(Te=globalThis.document)==null?void 0:Te.contentType)==null?void 0:Oe.includes("xml"))??!1,TEXT_NODE=3,COMMENT_NODE=8;function lifecycle_outside_component(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function async_derived_orphan(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function each_key_duplicate(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function effect_in_teardown(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function effect_in_unowned_derived(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function effect_orphan(e){throw new Error("https://svelte.dev/e/effect_orphan")}function effect_update_depth_exceeded(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function hydration_failed(){throw new Error("https://svelte.dev/e/hydration_failed")}function props_invalid_value(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function state_descriptors_fixed(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function state_prototype_fixed(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function state_unsafe_mutation(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function svelte_boundary_reset_onerror(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function hydration_mismatch(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function select_multiple_invalid_value(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function svelte_boundary_reset_noop(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let hydrating=!1;function set_hydrating(e){hydrating=e}let hydrate_node;function set_hydrate_node(e){if(e===null)throw hydration_mismatch(),HYDRATION_ERROR;return hydrate_node=e}function hydrate_next(){return set_hydrate_node(get_next_sibling(hydrate_node))}function reset(e){if(hydrating){if(get_next_sibling(hydrate_node)!==null)throw hydration_mismatch(),HYDRATION_ERROR;hydrate_node=e}}function next(e=1){if(hydrating){for(var t=e,n=hydrate_node;t--;)n=get_next_sibling(n);hydrate_node=n}}function skip_nodes(e=!0){for(var t=0,n=hydrate_node;;){if(n.nodeType===COMMENT_NODE){var r=n.data;if(r===HYDRATION_END){if(t===0)return n;t-=1}else(r===HYDRATION_START||r===HYDRATION_START_ELSE||r[0]==="["&&!isNaN(Number(r.slice(1))))&&(t+=1)}var o=get_next_sibling(n);e&&n.remove(),n=o}}function read_hydration_instruction(e){if(!e||e.nodeType!==COMMENT_NODE)throw hydration_mismatch(),HYDRATION_ERROR;return e.data}function equals(e){return e===this.v}function safe_not_equal(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function safe_equals(e){return!safe_not_equal(e,this.v)}let tracing_mode_flag=!1,component_context=null;function set_component_context(e){component_context=e}function push(e,t=!1,n){component_context={p:component_context,i:!1,c:null,e:null,s:e,x:null,l:null}}function pop(e){var t=component_context,n=t.e;if(n!==null){t.e=null;for(var r of n)create_user_effect(r)}return e!==void 0&&(t.x=e),t.i=!0,component_context=t.p,e??{}}function is_runes(){return!0}let micro_tasks=[];function run_micro_tasks(){var e=micro_tasks;micro_tasks=[],run_all(e)}function queue_micro_task(e){if(micro_tasks.length===0&&!is_flushing_sync){var t=micro_tasks;queueMicrotask(()=>{t===micro_tasks&&run_micro_tasks()})}micro_tasks.push(e)}function flush_tasks(){for(;micro_tasks.length>0;)run_micro_tasks()}function handle_error(e){var t=active_effect;if(t===null)return active_reaction.f|=ERROR_VALUE,e;if((t.f&REACTION_RAN)===0&&(t.f&EFFECT)===0)throw e;invoke_error_boundary(e,t)}function invoke_error_boundary(e,t){for(;t!==null;){if((t.f&BOUNDARY_EFFECT)!==0){if((t.f&REACTION_RAN)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const STATUS_MASK=-7169;function set_signal_status(e,t){e.f=e.f&STATUS_MASK|t}function update_derived_status(e){(e.f&CONNECTED)!==0||e.deps===null?set_signal_status(e,CLEAN):set_signal_status(e,MAYBE_DIRTY)}function clear_marked(e){if(e!==null)for(const t of e)(t.f&DERIVED)===0||(t.f&WAS_MARKED)===0||(t.f^=WAS_MARKED,clear_marked(t.deps))}function defer_effect(e,t,n){(e.f&DIRTY)!==0?t.add(e):(e.f&MAYBE_DIRTY)!==0&&n.add(e),clear_marked(e.deps),set_signal_status(e,CLEAN)}const batches=new Set;let current_batch=null,previous_batch=null,batch_values=null,queued_root_effects=[],last_scheduled_effect=null,is_flushing=!1,is_flushing_sync=!1;const Pn=class Pn{constructor(){ue(this,bt);te(this,"committed",!1);te(this,"current",new Map);te(this,"previous",new Map);ue(this,It,new Set);ue(this,sn,new Set);ue(this,Ht,0);ue(this,an,0);ue(this,gn,null);ue(this,vn,new Set);ue(this,qt,new Set);ue(this,Nt,new Map);te(this,"is_fork",!1);ue(this,ln,!1)}is_deferred(){return this.is_fork||E(this,an)>0}skip_effect(t){E(this,Nt).has(t)||E(this,Nt).set(t,{d:[],m:[]})}unskip_effect(t){var n=E(this,Nt).get(t);if(n){E(this,Nt).delete(t);for(var r of n.d)set_signal_status(r,DIRTY),schedule_effect(r);for(r of n.m)set_signal_status(r,MAYBE_DIRTY),schedule_effect(r)}}process(t){var o;queued_root_effects=[],this.apply();var n=[],r=[];for(const s of t)je(this,bt,Yn).call(this,s,n,r);if(this.is_deferred()){je(this,bt,Xn).call(this,r),je(this,bt,Xn).call(this,n);for(const[s,i]of E(this,Nt))reset_branch(s,i)}else{for(const s of E(this,It))s();E(this,It).clear(),E(this,Ht)===0&&je(this,bt,rr).call(this),previous_batch=this,current_batch=null,flush_queued_effects(r),flush_queued_effects(n),previous_batch=null,(o=E(this,gn))==null||o.resolve()}batch_values=null}capture(t,n){n!==UNINITIALIZED&&!this.previous.has(t)&&this.previous.set(t,n),(t.f&ERROR_VALUE)===0&&(this.current.set(t,t.v),batch_values==null||batch_values.set(t,t.v))}activate(){current_batch=this,this.apply()}deactivate(){current_batch===this&&(current_batch=null,batch_values=null)}flush(){if(this.activate(),queued_root_effects.length>0){if(flush_effects(),current_batch!==null&&current_batch!==this)return}else E(this,Ht)===0&&this.process([]);this.deactivate()}discard(){for(const t of E(this,sn))t(this);E(this,sn).clear()}increment(t){ae(this,Ht,E(this,Ht)+1),t&&ae(this,an,E(this,an)+1)}decrement(t){ae(this,Ht,E(this,Ht)-1),t&&ae(this,an,E(this,an)-1),!E(this,ln)&&(ae(this,ln,!0),queue_micro_task(()=>{ae(this,ln,!1),this.is_deferred()?queued_root_effects.length>0&&this.flush():this.revive()}))}revive(){for(const t of E(this,vn))E(this,qt).delete(t),set_signal_status(t,DIRTY),schedule_effect(t);for(const t of E(this,qt))set_signal_status(t,MAYBE_DIRTY),schedule_effect(t);this.flush()}oncommit(t){E(this,It).add(t)}ondiscard(t){E(this,sn).add(t)}settled(){return(E(this,gn)??ae(this,gn,deferred())).promise}static ensure(){if(current_batch===null){const t=current_batch=new Pn;batches.add(current_batch),is_flushing_sync||queue_micro_task(()=>{current_batch===t&&t.flush()})}return current_batch}apply(){}};It=new WeakMap,sn=new WeakMap,Ht=new WeakMap,an=new WeakMap,gn=new WeakMap,vn=new WeakMap,qt=new WeakMap,Nt=new WeakMap,ln=new WeakMap,bt=new WeakSet,Yn=function(t,n,r){t.f^=CLEAN;for(var o=t.first,s=null;o!==null;){var i=o.f,a=(i&(BRANCH_EFFECT|ROOT_EFFECT))!==0,l=a&&(i&CLEAN)!==0,u=l||(i&INERT)!==0||E(this,Nt).has(o);if(!u&&o.fn!==null){a?o.f^=CLEAN:s!==null&&(i&(EFFECT|RENDER_EFFECT|MANAGED_EFFECT))!==0?s.b.defer_effect(o):(i&EFFECT)!==0?n.push(o):is_dirty(o)&&((i&BLOCK_EFFECT)!==0&&E(this,qt).add(o),update_effect(o));var c=o.first;if(c!==null){o=c;continue}}var d=o.parent;for(o=o.next;o===null&&d!==null;)d===s&&(s=null),o=d.next,d=d.parent}},Xn=function(t){for(var n=0;n<t.length;n+=1)defer_effect(t[n],E(this,vn),E(this,qt))},rr=function(){var o;if(batches.size>1){this.previous.clear();var t=batch_values,n=!0;for(const s of batches){if(s===this){n=!1;continue}const i=[];for(const[l,u]of this.current){if(s.current.has(l))if(n&&u!==s.current.get(l))s.current.set(l,u);else continue;i.push(l)}if(i.length===0)continue;const a=[...s.current.keys()].filter(l=>!this.current.has(l));if(a.length>0){var r=queued_root_effects;queued_root_effects=[];const l=new Set,u=new Map;for(const c of i)mark_effects(c,a,l,u);if(queued_root_effects.length>0){current_batch=s,s.apply();for(const c of queued_root_effects)je(o=s,bt,Yn).call(o,c,[],[]);s.deactivate()}queued_root_effects=r}}current_batch=null,batch_values=t}this.committed=!0,batches.delete(this)};let Batch=Pn;function flushSync(e){var t=is_flushing_sync;is_flushing_sync=!0;try{for(var n;;){if(flush_tasks(),queued_root_effects.length===0&&(current_batch==null||current_batch.flush(),queued_root_effects.length===0))return last_scheduled_effect=null,n;flush_effects()}}finally{is_flushing_sync=t}}function flush_effects(){is_flushing=!0;var e=null;try{for(var t=0;queued_root_effects.length>0;){var n=Batch.ensure();if(t++>1e3){var r,o;infinite_loop_guard()}n.process(queued_root_effects),old_values.clear()}}finally{queued_root_effects=[],is_flushing=!1,last_scheduled_effect=null}}function infinite_loop_guard(){try{effect_update_depth_exceeded()}catch(e){invoke_error_boundary(e,last_scheduled_effect)}}let eager_block_effects=null;function flush_queued_effects(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(DESTROYED|INERT))===0&&is_dirty(r)&&(eager_block_effects=new Set,update_effect(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&unlink_effect(r),(eager_block_effects==null?void 0:eager_block_effects.size)>0)){old_values.clear();for(const o of eager_block_effects){if((o.f&(DESTROYED|INERT))!==0)continue;const s=[o];let i=o.parent;for(;i!==null;)eager_block_effects.has(i)&&(eager_block_effects.delete(i),s.push(i)),i=i.parent;for(let a=s.length-1;a>=0;a--){const l=s[a];(l.f&(DESTROYED|INERT))===0&&update_effect(l)}}eager_block_effects.clear()}}eager_block_effects=null}}function mark_effects(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const o of e.reactions){const s=o.f;(s&DERIVED)!==0?mark_effects(o,t,n,r):(s&(ASYNC|BLOCK_EFFECT))!==0&&(s&DIRTY)===0&&depends_on(o,t,r)&&(set_signal_status(o,DIRTY),schedule_effect(o))}}function depends_on(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const o of e.deps){if(includes.call(t,o))return!0;if((o.f&DERIVED)!==0&&depends_on(o,t,n))return n.set(o,!0),!0}return n.set(e,!1),!1}function schedule_effect(e){for(var t=last_scheduled_effect=e;t.parent!==null;){t=t.parent;var n=t.f;if(is_flushing&&t===active_effect&&(n&BLOCK_EFFECT)!==0&&(n&HEAD_EFFECT)===0)return;if((n&(ROOT_EFFECT|BRANCH_EFFECT))!==0){if((n&CLEAN)===0)return;t.f^=CLEAN}}queued_root_effects.push(t)}function reset_branch(e,t){if(!((e.f&BRANCH_EFFECT)!==0&&(e.f&CLEAN)!==0)){(e.f&DIRTY)!==0?t.d.push(e):(e.f&MAYBE_DIRTY)!==0&&t.m.push(e),set_signal_status(e,CLEAN);for(var n=e.first;n!==null;)reset_branch(n,t),n=n.next}}function createSubscriber(e){let t=0,n=source(0),r;return()=>{effect_tracking()&&(get(n),render_effect(()=>(t===0&&(r=untrack(()=>e(()=>increment(n)))),t+=1,()=>{queue_micro_task(()=>{t-=1,t===0&&(r==null||r(),r=void 0,increment(n))})})))}}var flags=EFFECT_TRANSPARENT|EFFECT_PRESERVED|BOUNDARY_EFFECT;function boundary(e,t,n){new Boundary(e,t,n)}class Boundary{constructor(t,n,r){ue(this,Le);te(this,"parent");te(this,"is_pending",!1);ue(this,tt);ue(this,_n,hydrating?hydrate_node:null);ue(this,yt);ue(this,Wt);ue(this,wt);ue(this,it,null);ue(this,Xe,null);ue(this,xt,null);ue(this,Ot,null);ue(this,Ut,null);ue(this,Gt,0);ue(this,Lt,0);ue(this,cn,!1);ue(this,Yt,!1);ue(this,un,new Set);ue(this,dn,new Set);ue(this,Pt,null);ue(this,Tn,createSubscriber(()=>(ae(this,Pt,source(E(this,Gt))),()=>{ae(this,Pt,null)})));ae(this,tt,t),ae(this,yt,n),ae(this,Wt,r),this.parent=active_effect.b,this.is_pending=!!E(this,yt).pending,ae(this,wt,block(()=>{if(active_effect.b=this,hydrating){const s=E(this,_n);hydrate_next(),s.nodeType===COMMENT_NODE&&s.data===HYDRATION_START_ELSE?je(this,Le,sr).call(this):(je(this,Le,or).call(this),E(this,Lt)===0&&(this.is_pending=!1))}else{var o=je(this,Le,Kn).call(this);try{ae(this,it,branch(()=>r(o)))}catch(s){this.error(s)}E(this,Lt)>0?je(this,Le,Ln).call(this):this.is_pending=!1}return()=>{var s;(s=E(this,Ut))==null||s.remove()}},flags)),hydrating&&ae(this,tt,hydrate_node)}defer_effect(t){defer_effect(t,E(this,un),E(this,dn))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!E(this,yt).pending}update_pending_count(t){je(this,Le,Jn).call(this,t),ae(this,Gt,E(this,Gt)+t),!(!E(this,Pt)||E(this,cn))&&(ae(this,cn,!0),queue_micro_task(()=>{ae(this,cn,!1),E(this,Pt)&&internal_set(E(this,Pt),E(this,Gt))}))}get_effect_pending(){return E(this,Tn).call(this),get(E(this,Pt))}error(t){var n=E(this,yt).onerror;let r=E(this,yt).failed;if(E(this,Yt)||!n&&!r)throw t;E(this,it)&&(destroy_effect(E(this,it)),ae(this,it,null)),E(this,Xe)&&(destroy_effect(E(this,Xe)),ae(this,Xe,null)),E(this,xt)&&(destroy_effect(E(this,xt)),ae(this,xt,null)),hydrating&&(set_hydrate_node(E(this,_n)),next(),set_hydrate_node(skip_nodes()));var o=!1,s=!1;const i=()=>{if(o){svelte_boundary_reset_noop();return}o=!0,s&&svelte_boundary_reset_onerror(),Batch.ensure(),ae(this,Gt,0),E(this,xt)!==null&&pause_effect(E(this,xt),()=>{ae(this,xt,null)}),this.is_pending=this.has_pending_snippet(),ae(this,it,je(this,Le,On).call(this,()=>(ae(this,Yt,!1),branch(()=>E(this,Wt).call(this,E(this,tt)))))),E(this,Lt)>0?je(this,Le,Ln).call(this):this.is_pending=!1};queue_micro_task(()=>{try{s=!0,n==null||n(t,i),s=!1}catch(a){invoke_error_boundary(a,E(this,wt)&&E(this,wt).parent)}r&&ae(this,xt,je(this,Le,On).call(this,()=>{Batch.ensure(),ae(this,Yt,!0);try{return branch(()=>{r(E(this,tt),()=>t,()=>i)})}catch(a){return invoke_error_boundary(a,E(this,wt).parent),null}finally{ae(this,Yt,!1)}}))})}}tt=new WeakMap,_n=new WeakMap,yt=new WeakMap,Wt=new WeakMap,wt=new WeakMap,it=new WeakMap,Xe=new WeakMap,xt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Gt=new WeakMap,Lt=new WeakMap,cn=new WeakMap,Yt=new WeakMap,un=new WeakMap,dn=new WeakMap,Pt=new WeakMap,Tn=new WeakMap,Le=new WeakSet,or=function(){try{ae(this,it,branch(()=>E(this,Wt).call(this,E(this,tt))))}catch(t){this.error(t)}},sr=function(){const t=E(this,yt).pending;t&&(ae(this,Xe,branch(()=>t(E(this,tt)))),queue_micro_task(()=>{var n=je(this,Le,Kn).call(this);ae(this,it,je(this,Le,On).call(this,()=>(Batch.ensure(),branch(()=>E(this,Wt).call(this,n))))),E(this,Lt)>0?je(this,Le,Ln).call(this):(pause_effect(E(this,Xe),()=>{ae(this,Xe,null)}),this.is_pending=!1)}))},Kn=function(){var t=E(this,tt);return this.is_pending&&(ae(this,Ut,create_text()),E(this,tt).before(E(this,Ut)),t=E(this,Ut)),t},On=function(t){var n=active_effect,r=active_reaction,o=component_context;set_active_effect(E(this,wt)),set_active_reaction(E(this,wt)),set_component_context(E(this,wt).ctx);try{return t()}catch(s){return handle_error(s),null}finally{set_active_effect(n),set_active_reaction(r),set_component_context(o)}},Ln=function(){const t=E(this,yt).pending;E(this,it)!==null&&(ae(this,Ot,document.createDocumentFragment()),E(this,Ot).append(E(this,Ut)),move_effect(E(this,it),E(this,Ot))),E(this,Xe)===null&&ae(this,Xe,branch(()=>t(E(this,tt))))},Jn=function(t){var n;if(!this.has_pending_snippet()){this.parent&&je(n=this.parent,Le,Jn).call(n,t);return}if(ae(this,Lt,E(this,Lt)+t),E(this,Lt)===0){this.is_pending=!1;for(const r of E(this,un))set_signal_status(r,DIRTY),schedule_effect(r);for(const r of E(this,dn))set_signal_status(r,MAYBE_DIRTY),schedule_effect(r);E(this,un).clear(),E(this,dn).clear(),E(this,Xe)&&pause_effect(E(this,Xe),()=>{ae(this,Xe,null)}),E(this,Ot)&&(E(this,tt).before(E(this,Ot)),ae(this,Ot,null))}};function flatten(e,t,n,r){const o=derived;var s=e.filter(p=>!p.settled);if(n.length===0&&s.length===0){r(t.map(o));return}var i=current_batch,a=active_effect,l=capture(),u=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(p=>p.promise)):null;function c(p){l();try{r(p)}catch(g){(a.f&DESTROYED)===0&&invoke_error_boundary(g,a)}i==null||i.deactivate(),unset_context()}if(n.length===0){u.then(()=>c(t.map(o)));return}function d(){l(),Promise.all(n.map(p=>async_derived(p))).then(p=>c([...t.map(o),...p])).catch(p=>invoke_error_boundary(p,a))}u?u.then(d):d()}function capture(){var e=active_effect,t=active_reaction,n=component_context,r=current_batch;return function(s=!0){set_active_effect(e),set_active_reaction(t),set_component_context(n),s&&(r==null||r.activate())}}function unset_context(){set_active_effect(null),set_active_reaction(null),set_component_context(null)}function derived(e){var t=DERIVED|DIRTY,n=active_reaction!==null&&(active_reaction.f&DERIVED)!==0?active_reaction:null;return active_effect!==null&&(active_effect.f|=EFFECT_PRESERVED),{ctx:component_context,deps:null,effects:null,equals,f:t,fn:e,reactions:null,rv:0,v:UNINITIALIZED,wv:0,parent:n??active_effect,ac:null}}function async_derived(e,t,n){let r=active_effect;r===null&&async_derived_orphan();var o=r.b,s=void 0,i=source(UNINITIALIZED),a=!active_reaction,l=new Map;return async_effect(()=>{var g;var u=deferred();s=u.promise;try{Promise.resolve(e()).then(u.resolve,u.reject).then(()=>{c===current_batch&&c.committed&&c.deactivate(),unset_context()})}catch(_){u.reject(_),unset_context()}var c=current_batch;if(a){var d=o.is_rendered();o.update_pending_count(1),c.increment(d),(g=l.get(c))==null||g.reject(STALE_REACTION),l.delete(c),l.set(c,u)}const p=(_,y=void 0)=>{if(c.activate(),y)y!==STALE_REACTION&&(i.f|=ERROR_VALUE,internal_set(i,y));else{(i.f&ERROR_VALUE)!==0&&(i.f^=ERROR_VALUE),internal_set(i,_);for(const[h,f]of l){if(l.delete(h),h===c)break;f.reject(STALE_REACTION)}}a&&(o.update_pending_count(-1),c.decrement(d))};u.promise.then(p,_=>p(null,_||"unknown"))}),teardown(()=>{for(const u of l.values())u.reject(STALE_REACTION)}),new Promise(u=>{function c(d){function p(){d===s?u(i):c(s)}d.then(p,p)}c(s)})}function user_derived(e){const t=derived(e);return push_reaction_value(t),t}function derived_safe_equal(e){const t=derived(e);return t.equals=safe_equals,t}function destroy_derived_effects(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)destroy_effect(t[n])}}function get_derived_parent_effect(e){for(var t=e.parent;t!==null;){if((t.f&DERIVED)===0)return(t.f&DESTROYED)===0?t:null;t=t.parent}return null}function execute_derived(e){var t,n=active_effect;set_active_effect(get_derived_parent_effect(e));try{e.f&=~WAS_MARKED,destroy_derived_effects(e),t=update_reaction(e)}finally{set_active_effect(n)}return t}function update_derived(e){var t=execute_derived(e);if(!e.equals(t)&&(e.wv=increment_write_version(),(!(current_batch!=null&&current_batch.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){set_signal_status(e,CLEAN);return}is_destroying_effect||(batch_values!==null?(effect_tracking()||current_batch!=null&&current_batch.is_fork)&&batch_values.set(e,t):update_derived_status(e))}function freeze_derived_effects(e){var t,n;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(n=r.ac)==null||n.abort(STALE_REACTION),r.teardown=noop,r.ac=null,remove_reactions(r,0),destroy_effect_children(r))}function unfreeze_derived_effects(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&update_effect(t)}let eager_effects=new Set;const old_values=new Map;let eager_effects_deferred=!1;function source(e,t){var n={f:0,v:e,reactions:null,equals,rv:0,wv:0};return n}function state(e,t){const n=source(e);return push_reaction_value(n),n}function mutable_source(e,t=!1,n=!0){const r=source(e);return t||(r.equals=safe_equals),r}function set(e,t,n=!1){active_reaction!==null&&(!untracking||(active_reaction.f&EAGER_EFFECT)!==0)&&is_runes()&&(active_reaction.f&(DERIVED|BLOCK_EFFECT|ASYNC|EAGER_EFFECT))!==0&&(current_sources===null||!includes.call(current_sources,e))&&state_unsafe_mutation();let r=n?proxy(t):t;return internal_set(e,r)}function internal_set(e,t){if(!e.equals(t)){var n=e.v;is_destroying_effect?old_values.set(e,t):old_values.set(e,n),e.v=t;var r=Batch.ensure();if(r.capture(e,n),(e.f&DERIVED)!==0){const o=e;(e.f&DIRTY)!==0&&execute_derived(o),update_derived_status(o)}e.wv=increment_write_version(),mark_reactions(e,DIRTY),active_effect!==null&&(active_effect.f&CLEAN)!==0&&(active_effect.f&(BRANCH_EFFECT|ROOT_EFFECT))===0&&(untracked_writes===null?set_untracked_writes([e]):untracked_writes.push(e)),!r.is_fork&&eager_effects.size>0&&!eager_effects_deferred&&flush_eager_effects()}return t}function flush_eager_effects(){eager_effects_deferred=!1;for(const e of eager_effects)(e.f&CLEAN)!==0&&set_signal_status(e,MAYBE_DIRTY),is_dirty(e)&&update_effect(e);eager_effects.clear()}function increment(e){set(e,e.v+1)}function mark_reactions(e,t){var n=e.reactions;if(n!==null)for(var r=n.length,o=0;o<r;o++){var s=n[o],i=s.f,a=(i&DIRTY)===0;if(a&&set_signal_status(s,t),(i&DERIVED)!==0){var l=s;batch_values==null||batch_values.delete(l),(i&WAS_MARKED)===0&&(i&CONNECTED&&(s.f|=WAS_MARKED),mark_reactions(l,MAYBE_DIRTY))}else a&&((i&BLOCK_EFFECT)!==0&&eager_block_effects!==null&&eager_block_effects.add(s),schedule_effect(s))}}function proxy(e){if(typeof e!="object"||e===null||STATE_SYMBOL in e)return e;const t=get_prototype_of(e);if(t!==object_prototype&&t!==array_prototype)return e;var n=new Map,r=is_array(e),o=state(0),s=update_version,i=a=>{if(update_version===s)return a();var l=active_reaction,u=update_version;set_active_reaction(null),set_update_version(s);var c=a();return set_active_reaction(l),set_update_version(u),c};return r&&n.set("length",state(e.length)),new Proxy(e,{defineProperty(a,l,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&state_descriptors_fixed();var c=n.get(l);return c===void 0?i(()=>{var d=state(u.value);return n.set(l,d),d}):set(c,u.value,!0),!0},deleteProperty(a,l){var u=n.get(l);if(u===void 0){if(l in a){const c=i(()=>state(UNINITIALIZED));n.set(l,c),increment(o)}}else set(u,UNINITIALIZED),increment(o);return!0},get(a,l,u){var g;if(l===STATE_SYMBOL)return e;var c=n.get(l),d=l in a;if(c===void 0&&(!d||(g=get_descriptor(a,l))!=null&&g.writable)&&(c=i(()=>{var _=proxy(d?a[l]:UNINITIALIZED),y=state(_);return y}),n.set(l,c)),c!==void 0){var p=get(c);return p===UNINITIALIZED?void 0:p}return Reflect.get(a,l,u)},getOwnPropertyDescriptor(a,l){var u=Reflect.getOwnPropertyDescriptor(a,l);if(u&&"value"in u){var c=n.get(l);c&&(u.value=get(c))}else if(u===void 0){var d=n.get(l),p=d==null?void 0:d.v;if(d!==void 0&&p!==UNINITIALIZED)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return u},has(a,l){var p;if(l===STATE_SYMBOL)return!0;var u=n.get(l),c=u!==void 0&&u.v!==UNINITIALIZED||Reflect.has(a,l);if(u!==void 0||active_effect!==null&&(!c||(p=get_descriptor(a,l))!=null&&p.writable)){u===void 0&&(u=i(()=>{var g=c?proxy(a[l]):UNINITIALIZED,_=state(g);return _}),n.set(l,u));var d=get(u);if(d===UNINITIALIZED)return!1}return c},set(a,l,u,c){var m;var d=n.get(l),p=l in a;if(r&&l==="length")for(var g=u;g<d.v;g+=1){var _=n.get(g+"");_!==void 0?set(_,UNINITIALIZED):g in a&&(_=i(()=>state(UNINITIALIZED)),n.set(g+"",_))}if(d===void 0)(!p||(m=get_descriptor(a,l))!=null&&m.writable)&&(d=i(()=>state(void 0)),set(d,proxy(u)),n.set(l,d));else{p=d.v!==UNINITIALIZED;var y=i(()=>proxy(u));set(d,y)}var h=Reflect.getOwnPropertyDescriptor(a,l);if(h!=null&&h.set&&h.set.call(c,u),!p){if(r&&typeof l=="string"){var f=n.get("length"),b=Number(l);Number.isInteger(b)&&b>=f.v&&set(f,b+1)}increment(o)}return!0},ownKeys(a){get(o);var l=Reflect.ownKeys(a).filter(d=>{var p=n.get(d);return p===void 0||p.v!==UNINITIALIZED});for(var[u,c]of n)c.v!==UNINITIALIZED&&!(u in a)&&l.push(u);return l},setPrototypeOf(){state_prototype_fixed()}})}function get_proxied_value(e){try{if(e!==null&&typeof e=="object"&&STATE_SYMBOL in e)return e[STATE_SYMBOL]}catch{}return e}function is(e,t){return Object.is(get_proxied_value(e),get_proxied_value(t))}var $window,is_firefox,first_child_getter,next_sibling_getter;function init_operations(){if($window===void 0){$window=window,is_firefox=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;first_child_getter=get_descriptor(t,"firstChild").get,next_sibling_getter=get_descriptor(t,"nextSibling").get,is_extensible(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),is_extensible(n)&&(n.__t=void 0)}}function create_text(e=""){return document.createTextNode(e)}function get_first_child(e){return first_child_getter.call(e)}function get_next_sibling(e){return next_sibling_getter.call(e)}function child(e,t){if(!hydrating)return get_first_child(e);var n=get_first_child(hydrate_node);if(n===null)n=hydrate_node.appendChild(create_text());else if(t&&n.nodeType!==TEXT_NODE){var r=create_text();return n==null||n.before(r),set_hydrate_node(r),r}return t&&merge_text_nodes(n),set_hydrate_node(n),n}function first_child(e,t=!1){if(!hydrating){var n=get_first_child(e);return n instanceof Comment&&n.data===""?get_next_sibling(n):n}if(t){if((hydrate_node==null?void 0:hydrate_node.nodeType)!==TEXT_NODE){var r=create_text();return hydrate_node==null||hydrate_node.before(r),set_hydrate_node(r),r}merge_text_nodes(hydrate_node)}return hydrate_node}function sibling(e,t=1,n=!1){let r=hydrating?hydrate_node:e;for(var o;t--;)o=r,r=get_next_sibling(r);if(!hydrating)return r;if(n){if((r==null?void 0:r.nodeType)!==TEXT_NODE){var s=create_text();return r===null?o==null||o.after(s):r.before(s),set_hydrate_node(s),s}merge_text_nodes(r)}return set_hydrate_node(r),r}function clear_text_content(e){e.textContent=""}function should_defer_append(){return!1}function create_element(e,t,n){return document.createElementNS(NAMESPACE_HTML,e,void 0)}function merge_text_nodes(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===TEXT_NODE;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function remove_textarea_child(e){hydrating&&get_first_child(e)!==null&&clear_text_content(e)}let listening_to_form_reset=!1;function add_form_reset_listener(){listening_to_form_reset||(listening_to_form_reset=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const n of e.target.elements)(t=n.__on_r)==null||t.call(n)})},{capture:!0}))}function without_reactive_context(e){var t=active_reaction,n=active_effect;set_active_reaction(null),set_active_effect(null);try{return e()}finally{set_active_reaction(t),set_active_effect(n)}}function listen_to_event_and_reset_event(e,t,n,r=n){e.addEventListener(t,()=>without_reactive_context(n));const o=e.__on_r;o?e.__on_r=()=>{o(),r(!0)}:e.__on_r=()=>r(!0),add_form_reset_listener()}function validate_effect(e){active_effect===null&&(active_reaction===null&&effect_orphan(),effect_in_unowned_derived()),is_destroying_effect&&effect_in_teardown()}function push_effect(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function create_effect(e,t,n){var r=active_effect;r!==null&&(r.f&INERT)!==0&&(e|=INERT);var o={ctx:component_context,deps:null,nodes:null,f:e|DIRTY|CONNECTED,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{update_effect(o)}catch(a){throw destroy_effect(o),a}else t!==null&&schedule_effect(o);var s=o;if(n&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&EFFECT_PRESERVED)===0&&(s=s.first,(e&BLOCK_EFFECT)!==0&&(e&EFFECT_TRANSPARENT)!==0&&s!==null&&(s.f|=EFFECT_TRANSPARENT)),s!==null&&(s.parent=r,r!==null&&push_effect(s,r),active_reaction!==null&&(active_reaction.f&DERIVED)!==0&&(e&ROOT_EFFECT)===0)){var i=active_reaction;(i.effects??(i.effects=[])).push(s)}return o}function effect_tracking(){return active_reaction!==null&&!untracking}function teardown(e){const t=create_effect(RENDER_EFFECT,null,!1);return set_signal_status(t,CLEAN),t.teardown=e,t}function user_effect(e){validate_effect();var t=active_effect.f,n=!active_reaction&&(t&BRANCH_EFFECT)!==0&&(t&REACTION_RAN)===0;if(n){var r=component_context;(r.e??(r.e=[])).push(e)}else return create_user_effect(e)}function create_user_effect(e){return create_effect(EFFECT|USER_EFFECT,e,!1)}function effect_root(e){Batch.ensure();const t=create_effect(ROOT_EFFECT|EFFECT_PRESERVED,e,!0);return()=>{destroy_effect(t)}}function component_root(e){Batch.ensure();const t=create_effect(ROOT_EFFECT|EFFECT_PRESERVED,e,!0);return(n={})=>new Promise(r=>{n.outro?pause_effect(t,()=>{destroy_effect(t),r(void 0)}):(destroy_effect(t),r(void 0))})}function effect(e){return create_effect(EFFECT,e,!1)}function async_effect(e){return create_effect(ASYNC|EFFECT_PRESERVED,e,!0)}function render_effect(e,t=0){return create_effect(RENDER_EFFECT|t,e,!0)}function template_effect(e,t=[],n=[],r=[]){flatten(r,t,n,o=>{create_effect(RENDER_EFFECT,()=>e(...o.map(get)),!0)})}function block(e,t=0){var n=create_effect(BLOCK_EFFECT|t,e,!0);return n}function branch(e){return create_effect(BRANCH_EFFECT|EFFECT_PRESERVED,e,!0)}function execute_effect_teardown(e){var t=e.teardown;if(t!==null){const n=is_destroying_effect,r=active_reaction;set_is_destroying_effect(!0),set_active_reaction(null);try{t.call(null)}finally{set_is_destroying_effect(n),set_active_reaction(r)}}}function destroy_effect_children(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const o=n.ac;o!==null&&without_reactive_context(()=>{o.abort(STALE_REACTION)});var r=n.next;(n.f&ROOT_EFFECT)!==0?n.parent=null:destroy_effect(n,t),n=r}}function destroy_block_effect_children(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&BRANCH_EFFECT)===0&&destroy_effect(t),t=n}}function destroy_effect(e,t=!0){var n=!1;(t||(e.f&HEAD_EFFECT)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(remove_effect_dom(e.nodes.start,e.nodes.end),n=!0),destroy_effect_children(e,t&&!n),remove_reactions(e,0),set_signal_status(e,DESTROYED);var r=e.nodes&&e.nodes.t;if(r!==null)for(const s of r)s.stop();execute_effect_teardown(e);var o=e.parent;o!==null&&o.first!==null&&unlink_effect(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function remove_effect_dom(e,t){for(;e!==null;){var n=e===t?null:get_next_sibling(e);e.remove(),e=n}}function unlink_effect(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function pause_effect(e,t,n=!0){var r=[];pause_children(e,r,!0);var o=()=>{n&&destroy_effect(e),t&&t()},s=r.length;if(s>0){var i=()=>--s||o();for(var a of r)a.out(i)}else o()}function pause_children(e,t,n){if((e.f&INERT)===0){e.f^=INERT;var r=e.nodes&&e.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&t.push(a);for(var o=e.first;o!==null;){var s=o.next,i=(o.f&EFFECT_TRANSPARENT)!==0||(o.f&BRANCH_EFFECT)!==0&&(e.f&BLOCK_EFFECT)!==0;pause_children(o,t,i?n:!1),o=s}}}function resume_effect(e){resume_children(e,!0)}function resume_children(e,t){if((e.f&INERT)!==0){e.f^=INERT,(e.f&CLEAN)===0&&(set_signal_status(e,DIRTY),schedule_effect(e));for(var n=e.first;n!==null;){var r=n.next,o=(n.f&EFFECT_TRANSPARENT)!==0||(n.f&BRANCH_EFFECT)!==0;resume_children(n,o?t:!1),n=r}var s=e.nodes&&e.nodes.t;if(s!==null)for(const i of s)(i.is_global||t)&&i.in()}}function move_effect(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var o=n===r?null:get_next_sibling(n);t.append(n),n=o}}let is_updating_effect=!1,is_destroying_effect=!1;function set_is_destroying_effect(e){is_destroying_effect=e}let active_reaction=null,untracking=!1;function set_active_reaction(e){active_reaction=e}let active_effect=null;function set_active_effect(e){active_effect=e}let current_sources=null;function push_reaction_value(e){active_reaction!==null&&(current_sources===null?current_sources=[e]:current_sources.push(e))}let new_deps=null,skipped_deps=0,untracked_writes=null;function set_untracked_writes(e){untracked_writes=e}let write_version=1,read_version=0,update_version=read_version;function set_update_version(e){update_version=e}function increment_write_version(){return++write_version}function is_dirty(e){var t=e.f;if((t&DIRTY)!==0)return!0;if(t&DERIVED&&(e.f&=~WAS_MARKED),(t&MAYBE_DIRTY)!==0){for(var n=e.deps,r=n.length,o=0;o<r;o++){var s=n[o];if(is_dirty(s)&&update_derived(s),s.wv>e.wv)return!0}(t&CONNECTED)!==0&&batch_values===null&&set_signal_status(e,CLEAN)}return!1}function schedule_possible_effect_self_invalidation(e,t,n=!0){var r=e.reactions;if(r!==null&&!(current_sources!==null&&includes.call(current_sources,e)))for(var o=0;o<r.length;o++){var s=r[o];(s.f&DERIVED)!==0?schedule_possible_effect_self_invalidation(s,t,!1):t===s&&(n?set_signal_status(s,DIRTY):(s.f&CLEAN)!==0&&set_signal_status(s,MAYBE_DIRTY),schedule_effect(s))}}function update_reaction(e){var y;var t=new_deps,n=skipped_deps,r=untracked_writes,o=active_reaction,s=current_sources,i=component_context,a=untracking,l=update_version,u=e.f;new_deps=null,skipped_deps=0,untracked_writes=null,active_reaction=(u&(BRANCH_EFFECT|ROOT_EFFECT))===0?e:null,current_sources=null,set_component_context(e.ctx),untracking=!1,update_version=++read_version,e.ac!==null&&(without_reactive_context(()=>{e.ac.abort(STALE_REACTION)}),e.ac=null);try{e.f|=REACTION_IS_UPDATING;var c=e.fn,d=c();e.f|=REACTION_RAN;var p=e.deps,g=current_batch==null?void 0:current_batch.is_fork;if(new_deps!==null){var _;if(g||remove_reactions(e,skipped_deps),p!==null&&skipped_deps>0)for(p.length=skipped_deps+new_deps.length,_=0;_<new_deps.length;_++)p[skipped_deps+_]=new_deps[_];else e.deps=p=new_deps;if(effect_tracking()&&(e.f&CONNECTED)!==0)for(_=skipped_deps;_<p.length;_++)((y=p[_]).reactions??(y.reactions=[])).push(e)}else!g&&p!==null&&skipped_deps<p.length&&(remove_reactions(e,skipped_deps),p.length=skipped_deps);if(is_runes()&&untracked_writes!==null&&!untracking&&p!==null&&(e.f&(DERIVED|MAYBE_DIRTY|DIRTY))===0)for(_=0;_<untracked_writes.length;_++)schedule_possible_effect_self_invalidation(untracked_writes[_],e);if(o!==null&&o!==e){if(read_version++,o.deps!==null)for(let h=0;h<n;h+=1)o.deps[h].rv=read_version;if(t!==null)for(const h of t)h.rv=read_version;untracked_writes!==null&&(r===null?r=untracked_writes:r.push(...untracked_writes))}return(e.f&ERROR_VALUE)!==0&&(e.f^=ERROR_VALUE),d}catch(h){return handle_error(h)}finally{e.f^=REACTION_IS_UPDATING,new_deps=t,skipped_deps=n,untracked_writes=r,active_reaction=o,current_sources=s,set_component_context(i),untracking=a,update_version=l}}function remove_reaction(e,t){let n=t.reactions;if(n!==null){var r=index_of.call(n,e);if(r!==-1){var o=n.length-1;o===0?n=t.reactions=null:(n[r]=n[o],n.pop())}}if(n===null&&(t.f&DERIVED)!==0&&(new_deps===null||!includes.call(new_deps,t))){var s=t;(s.f&CONNECTED)!==0&&(s.f^=CONNECTED,s.f&=~WAS_MARKED),update_derived_status(s),freeze_derived_effects(s),remove_reactions(s,0)}}function remove_reactions(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)remove_reaction(e,n[r])}function update_effect(e){var t=e.f;if((t&DESTROYED)===0){set_signal_status(e,CLEAN);var n=active_effect,r=is_updating_effect;active_effect=e,is_updating_effect=!0;try{(t&(BLOCK_EFFECT|MANAGED_EFFECT))!==0?destroy_block_effect_children(e):destroy_effect_children(e),execute_effect_teardown(e);var o=update_reaction(e);e.teardown=typeof o=="function"?o:null,e.wv=write_version;var s;DEV&&tracing_mode_flag&&(e.f&DIRTY)!==0&&e.deps}finally{is_updating_effect=r,active_effect=n}}}async function tick(){await Promise.resolve(),flushSync()}function get(e){var t=e.f,n=(t&DERIVED)!==0;if(active_reaction!==null&&!untracking){var r=active_effect!==null&&(active_effect.f&DESTROYED)!==0;if(!r&&(current_sources===null||!includes.call(current_sources,e))){var o=active_reaction.deps;if((active_reaction.f&REACTION_IS_UPDATING)!==0)e.rv<read_version&&(e.rv=read_version,new_deps===null&&o!==null&&o[skipped_deps]===e?skipped_deps++:new_deps===null?new_deps=[e]:new_deps.push(e));else{(active_reaction.deps??(active_reaction.deps=[])).push(e);var s=e.reactions;s===null?e.reactions=[active_reaction]:includes.call(s,active_reaction)||s.push(active_reaction)}}}if(is_destroying_effect&&old_values.has(e))return old_values.get(e);if(n){var i=e;if(is_destroying_effect){var a=i.v;return((i.f&CLEAN)===0&&i.reactions!==null||depends_on_old_values(i))&&(a=execute_derived(i)),old_values.set(i,a),a}var l=(i.f&CONNECTED)===0&&!untracking&&active_reaction!==null&&(is_updating_effect||(active_reaction.f&CONNECTED)!==0),u=(i.f&REACTION_RAN)===0;is_dirty(i)&&(l&&(i.f|=CONNECTED),update_derived(i)),l&&!u&&(unfreeze_derived_effects(i),reconnect(i))}if(batch_values!=null&&batch_values.has(e))return batch_values.get(e);if((e.f&ERROR_VALUE)!==0)throw e.v;return e.v}function reconnect(e){if(e.f|=CONNECTED,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&DERIVED)!==0&&(t.f&CONNECTED)===0&&(unfreeze_derived_effects(t),reconnect(t))}function depends_on_old_values(e){if(e.v===UNINITIALIZED)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(old_values.has(t)||(t.f&DERIVED)!==0&&depends_on_old_values(t))return!0;return!1}function untrack(e){var t=untracking;try{return untracking=!0,e()}finally{untracking=t}}const PASSIVE_EVENTS=["touchstart","touchmove"];function is_passive_event(e){return PASSIVE_EVENTS.includes(e)}const event_symbol=Symbol("events"),all_registered_events=new Set,root_event_handles=new Set;function create_event(e,t,n,r={}){function o(s){if(r.capture||handle_event_propagation.call(t,s),!s.cancelBubble)return without_reactive_context(()=>n==null?void 0:n.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?queue_micro_task(()=>{t.addEventListener(e,o,r)}):t.addEventListener(e,o,r),o}function event(e,t,n,r,o){var s={capture:r,passive:o},i=create_event(e,t,n,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&teardown(()=>{t.removeEventListener(e,i,s)})}function delegated(e,t,n){(t[event_symbol]??(t[event_symbol]={}))[e]=n}function delegate(e){for(var t=0;t<e.length;t++)all_registered_events.add(e[t]);for(var n of root_event_handles)n(e)}let last_propagated_event=null;function handle_event_propagation(e){var h,f;var t=this,n=t.ownerDocument,r=e.type,o=((h=e.composedPath)==null?void 0:h.call(e))||[],s=o[0]||e.target;last_propagated_event=e;var i=0,a=last_propagated_event===e&&e.__root;if(a){var l=o.indexOf(a);if(l!==-1&&(t===document||t===window)){e.__root=t;return}var u=o.indexOf(t);if(u===-1)return;l<=u&&(i=l)}if(s=o[i]||e.target,s!==t){define_property(e,"currentTarget",{configurable:!0,get(){return s||n}});var c=active_reaction,d=active_effect;set_active_reaction(null),set_active_effect(null);try{for(var p,g=[];s!==null;){var _=s.assignedSlot||s.parentNode||s.host||null;try{var y=(f=s[event_symbol])==null?void 0:f[r];y!=null&&(!s.disabled||e.target===s)&&y.call(s,e)}catch(b){p?g.push(b):p=b}if(e.cancelBubble||_===t||_===null)break;s=_}if(p){for(let b of g)queueMicrotask(()=>{throw b});throw p}}finally{e.__root=t,delete e.currentTarget,set_active_reaction(c),set_active_effect(d)}}}const policy=(er=(Qn=globalThis==null?void 0:globalThis.window)==null?void 0:Qn.trustedTypes)==null?void 0:er.createPolicy("svelte-trusted-html",{createHTML:e=>e});function create_trusted_html(e){return(policy==null?void 0:policy.createHTML(e))??e}function create_fragment_from_html(e,t=!1){var n=create_element("template");return e=e.replaceAll("<!>","<!---->"),n.innerHTML=t?create_trusted_html(e):e,n.content}function assign_nodes(e,t){var n=active_effect;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function from_html(e,t){var n=(t&TEMPLATE_FRAGMENT)!==0,r=(t&TEMPLATE_USE_IMPORT_NODE)!==0,o,s=!e.startsWith("<!>");return()=>{if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;o===void 0&&(o=create_fragment_from_html(s?e:"<!>"+e,!0),n||(o=get_first_child(o)));var i=r||is_firefox?document.importNode(o,!0):o.cloneNode(!0);if(n){var a=get_first_child(i),l=i.lastChild;assign_nodes(a,l)}else assign_nodes(i,i);return i}}function from_namespace(e,t,n="svg"){var r=!e.startsWith("<!>"),o=(t&TEMPLATE_FRAGMENT)!==0,s=`<${n}>${r?e:"<!>"+e}</${n}>`,i;return()=>{if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;if(!i){var a=create_fragment_from_html(s,!0),l=get_first_child(a);if(o)for(i=document.createDocumentFragment();get_first_child(l);)i.appendChild(get_first_child(l));else i=get_first_child(l)}var u=i.cloneNode(!0);if(o){var c=get_first_child(u),d=u.lastChild;assign_nodes(c,d)}else assign_nodes(u,u);return u}}function from_svg(e,t){return from_namespace(e,t,"svg")}function text(e=""){if(!hydrating){var t=create_text(e+"");return assign_nodes(t,t),t}var n=hydrate_node;return n.nodeType!==TEXT_NODE?(n.before(n=create_text()),set_hydrate_node(n)):merge_text_nodes(n),assign_nodes(n,n),n}function comment(){if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;var e=document.createDocumentFragment(),t=document.createComment(""),n=create_text();return e.append(t,n),assign_nodes(t,n),e}function append(e,t){if(hydrating){var n=active_effect;((n.f&REACTION_RAN)===0||n.nodes.end===null)&&(n.nodes.end=hydrate_node),hydrate_next();return}e!==null&&e.before(t)}let should_intro=!0;function set_text(e,t){var n=t==null?"":typeof t=="object"?t+"":t;n!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=n,e.nodeValue=n+"")}function mount(e,t){return _mount(e,t)}function hydrate(e,t){init_operations(),t.intro=t.intro??!1;const n=t.target,r=hydrating,o=hydrate_node;try{for(var s=get_first_child(n);s&&(s.nodeType!==COMMENT_NODE||s.data!==HYDRATION_START);)s=get_next_sibling(s);if(!s)throw HYDRATION_ERROR;set_hydrating(!0),set_hydrate_node(s);const i=_mount(e,{...t,anchor:s});return set_hydrating(!1),i}catch(i){if(i instanceof Error&&i.message.split(`
2
- `).some(a=>a.startsWith("https://svelte.dev/e/")))throw i;return i!==HYDRATION_ERROR&&console.warn("Failed to hydrate: ",i),t.recover===!1&&hydration_failed(),init_operations(),clear_text_content(n),set_hydrating(!1),mount(e,t)}finally{set_hydrating(r),set_hydrate_node(o)}}const listeners=new Map;function _mount(e,{target:t,anchor:n,props:r={},events:o,context:s,intro:i=!0}){init_operations();var a=new Set,l=d=>{for(var p=0;p<d.length;p++){var g=d[p];if(!a.has(g)){a.add(g);var _=is_passive_event(g);for(const f of[t,document]){var y=listeners.get(f);y===void 0&&(y=new Map,listeners.set(f,y));var h=y.get(g);h===void 0?(f.addEventListener(g,handle_event_propagation,{passive:_}),y.set(g,1)):y.set(g,h+1)}}}};l(array_from(all_registered_events)),root_event_handles.add(l);var u=void 0,c=component_root(()=>{var d=n??t.appendChild(create_text());return boundary(d,{pending:()=>{}},p=>{push({});var g=component_context;if(s&&(g.c=s),o&&(r.$$events=o),hydrating&&assign_nodes(p,null),should_intro=i,u=e(p,r)||{},should_intro=!0,hydrating&&(active_effect.nodes.end=hydrate_node,hydrate_node===null||hydrate_node.nodeType!==COMMENT_NODE||hydrate_node.data!==HYDRATION_END))throw hydration_mismatch(),HYDRATION_ERROR;pop()}),()=>{var y;for(var p of a)for(const h of[t,document]){var g=listeners.get(h),_=g.get(p);--_==0?(h.removeEventListener(p,handle_event_propagation),g.delete(p),g.size===0&&listeners.delete(h)):g.set(p,_)}root_event_handles.delete(l),d!==n&&((y=d.parentNode)==null||y.removeChild(d))}});return mounted_components.set(u,c),u}let mounted_components=new WeakMap;function unmount(e,t){const n=mounted_components.get(e);return n?(mounted_components.delete(e),n(t)):Promise.resolve()}class BranchManager{constructor(t,n=!0){te(this,"anchor");ue(this,dt,new Map);ue(this,kt,new Map);ue(this,nt,new Map);ue(this,Xt,new Set);ue(this,mn,!0);ue(this,bn,()=>{var t=current_batch;if(E(this,dt).has(t)){var n=E(this,dt).get(t),r=E(this,kt).get(n);if(r)resume_effect(r),E(this,Xt).delete(n);else{var o=E(this,nt).get(n);o&&(E(this,kt).set(n,o.effect),E(this,nt).delete(n),o.fragment.lastChild.remove(),this.anchor.before(o.fragment),r=o.effect)}for(const[s,i]of E(this,dt)){if(E(this,dt).delete(s),s===t)break;const a=E(this,nt).get(i);a&&(destroy_effect(a.effect),E(this,nt).delete(i))}for(const[s,i]of E(this,kt)){if(s===n||E(this,Xt).has(s))continue;const a=()=>{if(Array.from(E(this,dt).values()).includes(s)){var u=document.createDocumentFragment();move_effect(i,u),u.append(create_text()),E(this,nt).set(s,{effect:i,fragment:u})}else destroy_effect(i);E(this,Xt).delete(s),E(this,kt).delete(s)};E(this,mn)||!r?(E(this,Xt).add(s),pause_effect(i,a,!1)):a()}}});ue(this,Cn,t=>{E(this,dt).delete(t);const n=Array.from(E(this,dt).values());for(const[r,o]of E(this,nt))n.includes(r)||(destroy_effect(o.effect),E(this,nt).delete(r))});this.anchor=t,ae(this,mn,n)}ensure(t,n){var r=current_batch,o=should_defer_append();if(n&&!E(this,kt).has(t)&&!E(this,nt).has(t))if(o){var s=document.createDocumentFragment(),i=create_text();s.append(i),E(this,nt).set(t,{effect:branch(()=>n(i)),fragment:s})}else E(this,kt).set(t,branch(()=>n(this.anchor)));if(E(this,dt).set(r,t),o){for(const[a,l]of E(this,kt))a===t?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of E(this,nt))a===t?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(E(this,bn)),r.ondiscard(E(this,Cn))}else hydrating&&(this.anchor=hydrate_node),E(this,bn).call(this)}}dt=new WeakMap,kt=new WeakMap,nt=new WeakMap,Xt=new WeakMap,mn=new WeakMap,bn=new WeakMap,Cn=new WeakMap;function onMount(e){component_context===null&&lifecycle_outside_component(),user_effect(()=>{const t=untrack(e);if(typeof t=="function")return t})}function onDestroy(e){component_context===null&&lifecycle_outside_component(),onMount(()=>()=>untrack(e))}function if_block(e,t,n=!1){hydrating&&hydrate_next();var r=new BranchManager(e),o=n?EFFECT_TRANSPARENT:0;function s(i,a){if(hydrating){const c=read_hydration_instruction(e);var l;if(c===HYDRATION_START?l=0:c===HYDRATION_START_ELSE?l=!1:l=parseInt(c.substring(1)),i!==l){var u=skip_nodes();set_hydrate_node(u),r.anchor=u,set_hydrating(!1),r.ensure(i,a),set_hydrating(!0);return}}r.ensure(i,a)}block(()=>{var i=!1;t((a,l=0)=>{i=!0,s(l,a)}),i||s(!1,null)},o)}const NAN=Symbol("NaN");function key(e,t,n){hydrating&&hydrate_next();var r=new BranchManager(e);block(()=>{var o=t();o!==o&&(o=NAN),r.ensure(o,n)})}function index(e,t){return t}function pause_effects(e,t,n){for(var r=[],o=t.length,s,i=t.length,a=0;a<o;a++){let d=t[a];pause_effect(d,()=>{if(s){if(s.pending.delete(d),s.done.add(d),s.pending.size===0){var p=e.outrogroups;destroy_effects(array_from(s.done)),p.delete(s),p.size===0&&(e.outrogroups=null)}}else i-=1},!1)}if(i===0){var l=r.length===0&&n!==null;if(l){var u=n,c=u.parentNode;clear_text_content(c),c.append(u),e.items.clear()}destroy_effects(t,!l)}else s={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(s)}function destroy_effects(e,t=!0){for(var n=0;n<e.length;n++)destroy_effect(e[n],t)}var offscreen_anchor;function each(e,t,n,r,o,s=null){var i=e,a=new Map,l=(t&EACH_IS_CONTROLLED)!==0;if(l){var u=e;i=hydrating?set_hydrate_node(get_first_child(u)):u.appendChild(create_text())}hydrating&&hydrate_next();var c=null,d=derived_safe_equal(()=>{var f=n();return is_array(f)?f:f==null?[]:array_from(f)}),p,g=!0;function _(){h.fallback=c,reconcile(h,p,i,t,r),c!==null&&(p.length===0?(c.f&EFFECT_OFFSCREEN)===0?resume_effect(c):(c.f^=EFFECT_OFFSCREEN,move(c,null,i)):pause_effect(c,()=>{c=null}))}var y=block(()=>{p=get(d);var f=p.length;let b=!1;if(hydrating){var m=read_hydration_instruction(i)===HYDRATION_START_ELSE;m!==(f===0)&&(i=skip_nodes(),set_hydrate_node(i),set_hydrating(!1),b=!0)}for(var x=new Set,S=current_batch,N=should_defer_append(),P=0;P<f;P+=1){hydrating&&hydrate_node.nodeType===COMMENT_NODE&&hydrate_node.data===HYDRATION_END&&(i=hydrate_node,b=!0,set_hydrating(!1));var M=p[P],re=r(M,P),oe=g?null:a.get(re);oe?(oe.v&&internal_set(oe.v,M),oe.i&&internal_set(oe.i,P),N&&S.unskip_effect(oe.e)):(oe=create_item(a,g?i:offscreen_anchor??(offscreen_anchor=create_text()),M,re,P,o,t,n),g||(oe.e.f|=EFFECT_OFFSCREEN),a.set(re,oe)),x.add(re)}if(f===0&&s&&!c&&(g?c=branch(()=>s(i)):(c=branch(()=>s(offscreen_anchor??(offscreen_anchor=create_text()))),c.f|=EFFECT_OFFSCREEN)),f>x.size&&each_key_duplicate(),hydrating&&f>0&&set_hydrate_node(skip_nodes()),!g)if(N){for(const[ne,ce]of a)x.has(ne)||S.skip_effect(ce.e);S.oncommit(_),S.ondiscard(()=>{})}else _();b&&set_hydrating(!0),get(d)}),h={effect:y,items:a,outrogroups:null,fallback:c};g=!1,hydrating&&(i=hydrate_node)}function skip_to_branch(e){for(;e!==null&&(e.f&BRANCH_EFFECT)===0;)e=e.next;return e}function reconcile(e,t,n,r,o){var oe,ne,ce,_e,ge,$e,be,ye,de;var s=(r&EACH_IS_ANIMATED)!==0,i=t.length,a=e.items,l=skip_to_branch(e.effect.first),u,c=null,d,p=[],g=[],_,y,h,f;if(s)for(f=0;f<i;f+=1)_=t[f],y=o(_,f),h=a.get(y).e,(h.f&EFFECT_OFFSCREEN)===0&&((ne=(oe=h.nodes)==null?void 0:oe.a)==null||ne.measure(),(d??(d=new Set)).add(h));for(f=0;f<i;f+=1){if(_=t[f],y=o(_,f),h=a.get(y).e,e.outrogroups!==null)for(const v of e.outrogroups)v.pending.delete(h),v.done.delete(h);if((h.f&EFFECT_OFFSCREEN)!==0)if(h.f^=EFFECT_OFFSCREEN,h===l)move(h,null,n);else{var b=c?c.next:l;h===e.effect.last&&(e.effect.last=h.prev),h.prev&&(h.prev.next=h.next),h.next&&(h.next.prev=h.prev),link(e,c,h),link(e,h,b),move(h,b,n),c=h,p=[],g=[],l=skip_to_branch(c.next);continue}if((h.f&INERT)!==0&&(resume_effect(h),s&&((_e=(ce=h.nodes)==null?void 0:ce.a)==null||_e.unfix(),(d??(d=new Set)).delete(h))),h!==l){if(u!==void 0&&u.has(h)){if(p.length<g.length){var m=g[0],x;c=m.prev;var S=p[0],N=p[p.length-1];for(x=0;x<p.length;x+=1)move(p[x],m,n);for(x=0;x<g.length;x+=1)u.delete(g[x]);link(e,S.prev,N.next),link(e,c,S),link(e,N,m),l=m,c=N,f-=1,p=[],g=[]}else u.delete(h),move(h,l,n),link(e,h.prev,h.next),link(e,h,c===null?e.effect.first:c.next),link(e,c,h),c=h;continue}for(p=[],g=[];l!==null&&l!==h;)(u??(u=new Set)).add(l),g.push(l),l=skip_to_branch(l.next);if(l===null)continue}(h.f&EFFECT_OFFSCREEN)===0&&p.push(h),c=h,l=skip_to_branch(h.next)}if(e.outrogroups!==null){for(const v of e.outrogroups)v.pending.size===0&&(destroy_effects(array_from(v.done)),(ge=e.outrogroups)==null||ge.delete(v));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var P=[];if(u!==void 0)for(h of u)(h.f&INERT)===0&&P.push(h);for(;l!==null;)(l.f&INERT)===0&&l!==e.fallback&&P.push(l),l=skip_to_branch(l.next);var M=P.length;if(M>0){var re=(r&EACH_IS_CONTROLLED)!==0&&i===0?n:null;if(s){for(f=0;f<M;f+=1)(be=($e=P[f].nodes)==null?void 0:$e.a)==null||be.measure();for(f=0;f<M;f+=1)(de=(ye=P[f].nodes)==null?void 0:ye.a)==null||de.fix()}pause_effects(e,P,re)}}s&&queue_micro_task(()=>{var v,w;if(d!==void 0)for(h of d)(w=(v=h.nodes)==null?void 0:v.a)==null||w.apply()})}function create_item(e,t,n,r,o,s,i,a){var l=(i&EACH_ITEM_REACTIVE)!==0?(i&EACH_ITEM_IMMUTABLE)===0?mutable_source(n,!1,!1):source(n):null,u=(i&EACH_INDEX_REACTIVE)!==0?source(o):null;return{v:l,i:u,e:branch(()=>(s(t,l??n,u??o,a),()=>{e.delete(r)}))}}function move(e,t,n){if(e.nodes)for(var r=e.nodes.start,o=e.nodes.end,s=t&&(t.f&EFFECT_OFFSCREEN)===0?t.nodes.start:n;r!==null;){var i=get_next_sibling(r);if(s.before(r),r===o)return;r=i}}function link(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function html(e,t,n=!1,r=!1,o=!1){var s=e,i="";template_effect(()=>{var a=active_effect;if(i===(i=t()??"")){hydrating&&hydrate_next();return}if(a.nodes!==null&&(remove_effect_dom(a.nodes.start,a.nodes.end),a.nodes=null),i!==""){if(hydrating){hydrate_node.data;for(var l=hydrate_next(),u=l;l!==null&&(l.nodeType!==COMMENT_NODE||l.data!=="");)u=l,l=get_next_sibling(l);if(l===null)throw hydration_mismatch(),HYDRATION_ERROR;assign_nodes(hydrate_node,u),s=set_hydrate_node(l);return}var c=i+"";n?c=`<svg>${c}</svg>`:r&&(c=`<math>${c}</math>`);var d=create_fragment_from_html(c);if((n||r)&&(d=get_first_child(d)),assign_nodes(get_first_child(d),d.lastChild),n||r)for(;get_first_child(d);)s.before(get_first_child(d));else s.before(d)}})}const now=()=>performance.now(),raf={tick:e=>requestAnimationFrame(e),now:()=>now(),tasks:new Set};function run_tasks(){const e=raf.now();raf.tasks.forEach(t=>{t.c(e)||(raf.tasks.delete(t),t.f())}),raf.tasks.size!==0&&raf.tick(run_tasks)}function loop(e){let t;return raf.tasks.size===0&&raf.tick(run_tasks),{promise:new Promise(n=>{raf.tasks.add(t={c:e,f:n})}),abort(){raf.tasks.delete(t)}}}function dispatch_event(e,t){without_reactive_context(()=>{e.dispatchEvent(new CustomEvent(t))})}function css_property_to_camelcase(e){if(e==="float")return"cssFloat";if(e==="offset")return"cssOffset";if(e.startsWith("--"))return e;const t=e.split("-");return t.length===1?t[0]:t[0]+t.slice(1).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function css_to_keyframe(e){const t={},n=e.split(";");for(const r of n){const[o,s]=r.split(":");if(!o||s===void 0)break;const i=css_property_to_camelcase(o.trim());t[i]=s.trim()}return t}const linear=e=>e;function transition(e,t,n,r){var h;var o=(e&TRANSITION_GLOBAL)!==0,s="both",i,a=t.inert,l=t.style.overflow,u,c;function d(){return without_reactive_context(()=>i??(i=n()(t,(r==null?void 0:r())??{},{direction:s})))}var p={is_global:o,in(){t.inert=a,u=animate(t,d(),c,1,()=>{dispatch_event(t,"introend"),u==null||u.abort(),u=i=void 0,t.style.overflow=l})},out(f){t.inert=!0,c=animate(t,d(),u,0,()=>{dispatch_event(t,"outroend"),f==null||f()})},stop:()=>{u==null||u.abort(),c==null||c.abort()}},g=active_effect;if(((h=g.nodes).t??(h.t=[])).push(p),should_intro){var _=o;if(!_){for(var y=g.parent;y&&(y.f&EFFECT_TRANSPARENT)!==0;)for(;(y=y.parent)&&(y.f&BLOCK_EFFECT)===0;);_=!y||(y.f&REACTION_RAN)!==0}_&&effect(()=>{untrack(()=>p.in())})}}function animate(e,t,n,r,o){var s=r===1;if(is_function(t)){var i,a=!1;return queue_micro_task(()=>{if(!a){var h=t({direction:s?"in":"out"});i=animate(e,h,n,r,o)}}),{abort:()=>{a=!0,i==null||i.abort()},deactivate:()=>i.deactivate(),reset:()=>i.reset(),t:()=>i.t()}}if(n==null||n.deactivate(),!(t!=null&&t.duration)&&!(t!=null&&t.delay))return dispatch_event(e,s?"introstart":"outrostart"),o(),{abort:noop,deactivate:noop,reset:noop,t:()=>r};const{delay:l=0,css:u,tick:c,easing:d=linear}=t;var p=[];if(s&&n===void 0&&(c&&c(0,1),u)){var g=css_to_keyframe(u(0,1));p.push(g,g)}var _=()=>1-r,y=e.animate(p,{duration:l,fill:"forwards"});return y.onfinish=()=>{y.cancel(),dispatch_event(e,s?"introstart":"outrostart");var h=(n==null?void 0:n.t())??1-r;n==null||n.abort();var f=r-h,b=t.duration*Math.abs(f),m=[];if(b>0){var x=!1;if(u)for(var S=Math.ceil(b/16.666666666666668),N=0;N<=S;N+=1){var P=h+f*d(N/S),M=css_to_keyframe(u(P,1-P));m.push(M),x||(x=M.overflow==="hidden")}x&&(e.style.overflow="hidden"),_=()=>{var re=y.currentTime;return h+f*d(re/b)},c&&loop(()=>{if(y.playState!=="running")return!1;var re=_();return c(re,1-re),!0})}y=e.animate(m,{duration:b,fill:"forwards"}),y.onfinish=()=>{_=()=>r,c==null||c(r,1-r),o()}},{abort:()=>{y&&(y.cancel(),y.effect=null,y.onfinish=noop)},deactivate:()=>{o=noop},reset:()=>{r===0&&(c==null||c(1,0))},t:()=>_()}}function append_styles(e,t){effect(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+t.hash)){const o=create_element("style");o.id=t.hash,o.textContent=t.code,r.appendChild(o)}})}const whitespace=[...`
3
- \r\f \v\uFEFF`];function to_class(e,t,n){var r=e==null?"":""+e;if(t&&(r=r?r+" "+t:t),n){for(var o in n)if(n[o])r=r?r+" "+o:o;else if(r.length)for(var s=o.length,i=0;(i=r.indexOf(o,i))>=0;){var a=i+s;(i===0||whitespace.includes(r[i-1]))&&(a===r.length||whitespace.includes(r[a]))?r=(i===0?"":r.substring(0,i))+r.substring(a+1):i=a}}return r===""?null:r}function to_style(e,t){return e==null?null:String(e)}function set_class(e,t,n,r,o,s){var i=e.__className;if(hydrating||i!==n||i===void 0){var a=to_class(n,r,s);(!hydrating||a!==e.getAttribute("class"))&&(a==null?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a)),e.__className=n}else if(s&&o!==s)for(var l in s){var u=!!s[l];(o==null||u!==!!o[l])&&e.classList.toggle(l,u)}return s}function set_style(e,t,n,r){var o=e.__style;if(hydrating||o!==t){var s=to_style(t);(!hydrating||s!==e.getAttribute("style"))&&(s==null?e.removeAttribute("style"):e.style.cssText=s),e.__style=t}return r}function select_option(e,t,n=!1){if(e.multiple){if(t==null)return;if(!is_array(t))return select_multiple_invalid_value();for(var r of e.options)r.selected=t.includes(get_option_value(r));return}for(r of e.options){var o=get_option_value(r);if(is(o,t)){r.selected=!0;return}}(!n||t!==void 0)&&(e.selectedIndex=-1)}function init_select(e){var t=new MutationObserver(()=>{select_option(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),teardown(()=>{t.disconnect()})}function bind_select_value(e,t,n=t){var r=new WeakSet,o=!0;listen_to_event_and_reset_event(e,"change",s=>{var i=s?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),get_option_value);else{var l=e.querySelector(i)??e.querySelector("option:not([disabled])");a=l&&get_option_value(l)}n(a),current_batch!==null&&r.add(current_batch)}),effect(()=>{var s=t();if(e===document.activeElement){var i=previous_batch??current_batch;if(r.has(i))return}if(select_option(e,s,o),o&&s===void 0){var a=e.querySelector(":checked");a!==null&&(s=get_option_value(a),n(s))}e.__value=s,o=!1}),init_select(e)}function get_option_value(e){return"__value"in e?e.__value:e.value}const IS_CUSTOM_ELEMENT=Symbol("is custom element"),IS_HTML=Symbol("is html"),LINK_TAG=IS_XHTML?"link":"LINK";function remove_input_defaults(e){if(hydrating){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute("value")){var r=e.value;set_attribute(e,"value",null),e.value=r}if(e.hasAttribute("checked")){var o=e.checked;set_attribute(e,"checked",null),e.checked=o}}};e.__on_r=n,queue_micro_task(n),add_form_reset_listener()}}function set_checked(e,t){var n=get_attributes(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function set_attribute(e,t,n,r){var o=get_attributes(e);hydrating&&(o[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName===LINK_TAG)||o[t]!==(o[t]=n)&&(t==="loading"&&(e[LOADING_ATTR_SYMBOL]=n),n==null?e.removeAttribute(t):typeof n!="string"&&get_setters(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function get_attributes(e){return e.__attributes??(e.__attributes={[IS_CUSTOM_ELEMENT]:e.nodeName.includes("-"),[IS_HTML]:e.namespaceURI===NAMESPACE_HTML})}var setters_cache=new Map;function get_setters(e){var t=e.getAttribute("is")||e.nodeName,n=setters_cache.get(t);if(n)return n;setters_cache.set(t,n=[]);for(var r,o=e,s=Element.prototype;s!==o;){r=get_descriptors(o);for(var i in r)r[i].set&&n.push(i);o=get_prototype_of(o)}return n}function bind_value(e,t,n=t){var r=new WeakSet;listen_to_event_and_reset_event(e,"input",async o=>{var s=o?e.defaultValue:e.value;if(s=is_numberlike_input(e)?to_number(s):s,n(s),current_batch!==null&&r.add(current_batch),await tick(),s!==(s=t())){var i=e.selectionStart,a=e.selectionEnd,l=e.value.length;if(e.value=s??"",a!==null){var u=e.value.length;i===a&&a===l&&u>l?(e.selectionStart=u,e.selectionEnd=u):(e.selectionStart=i,e.selectionEnd=Math.min(a,u))}}}),(hydrating&&e.defaultValue!==e.value||untrack(t)==null&&e.value)&&(n(is_numberlike_input(e)?to_number(e.value):e.value),current_batch!==null&&r.add(current_batch)),render_effect(()=>{var o=t();if(e===document.activeElement){var s=previous_batch??current_batch;if(r.has(s))return}is_numberlike_input(e)&&o===to_number(e.value)||e.type==="date"&&!o&&!e.value||o!==e.value&&(e.value=o??"")})}function is_numberlike_input(e){var t=e.type;return t==="number"||t==="range"}function to_number(e){return e===""?null:+e}function is_bound_this(e,t){return e===t||(e==null?void 0:e[STATE_SYMBOL])===t}function bind_this(e={},t,n,r){return effect(()=>{var o,s;return render_effect(()=>{o=s,s=[],untrack(()=>{e!==n(...s)&&(t(e,...s),o&&is_bound_this(n(...o),e)&&t(null,...o))})}),()=>{queue_micro_task(()=>{s&&is_bound_this(n(...s),e)&&t(null,...s)})}}),e}let is_store_binding=!1;function capture_store_binding(e){var t=is_store_binding;try{return is_store_binding=!1,[e(),is_store_binding]}finally{is_store_binding=t}}function prop(e,t,n,r){var b;var o=(n&PROPS_IS_BINDABLE)!==0,s=(n&PROPS_IS_LAZY_INITIAL)!==0,i=r,a=!0,l=()=>(a&&(a=!1,i=s?untrack(r):r),i),u;if(o){var c=STATE_SYMBOL in e||LEGACY_PROPS in e;u=((b=get_descriptor(e,t))==null?void 0:b.set)??(c&&t in e?m=>e[t]=m:void 0)}var d,p=!1;o?[d,p]=capture_store_binding(()=>e[t]):d=e[t],d===void 0&&r!==void 0&&(d=l(),u&&(props_invalid_value(),u(d)));var g;if(g=()=>{var m=e[t];return m===void 0?l():(a=!0,m)},(n&PROPS_IS_UPDATED)===0)return g;if(u){var _=e.$$legacy;return(function(m,x){return arguments.length>0?((!x||_||p)&&u(x?g():m),m):g()})}var y=!1,h=((n&PROPS_IS_IMMUTABLE)!==0?derived:derived_safe_equal)(()=>(y=!1,g()));o&&get(h);var f=active_effect;return(function(m,x){if(arguments.length>0){const S=x?get(h):o?proxy(m):m;return set(h,S),y=!0,i!==void 0&&(i=S),m}return is_destroying_effect&&y||(f.f&DESTROYED)!==0?h.v:get(h)})}function createClassComponent(e){return new Svelte4Component(e)}class Svelte4Component{constructor(t){ue(this,Mt);ue(this,at);var s;var n=new Map,r=(i,a)=>{var l=mutable_source(a,!1,!1);return n.set(i,l),l};const o=new Proxy({...t.props||{},$$events:{}},{get(i,a){return get(n.get(a)??r(a,Reflect.get(i,a)))},has(i,a){return a===LEGACY_PROPS?!0:(get(n.get(a)??r(a,Reflect.get(i,a))),Reflect.has(i,a))},set(i,a,l){return set(n.get(a)??r(a,l),l),Reflect.set(i,a,l)}});ae(this,at,(t.hydrate?hydrate:mount)(t.component,{target:t.target,anchor:t.anchor,props:o,context:t.context,intro:t.intro??!1,recover:t.recover})),(!((s=t==null?void 0:t.props)!=null&&s.$$host)||t.sync===!1)&&flushSync(),ae(this,Mt,o.$$events);for(const i of Object.keys(E(this,at)))i==="$set"||i==="$destroy"||i==="$on"||define_property(this,i,{get(){return E(this,at)[i]},set(a){E(this,at)[i]=a},enumerable:!0});E(this,at).$set=i=>{Object.assign(o,i)},E(this,at).$destroy=()=>{unmount(E(this,at))}}$set(t){E(this,at).$set(t)}$on(t,n){E(this,Mt)[t]=E(this,Mt)[t]||[];const r=(...o)=>n.call(this,...o);return E(this,Mt)[t].push(r),()=>{E(this,Mt)[t]=E(this,Mt)[t].filter(o=>o!==r)}}$destroy(){E(this,at).$destroy()}}Mt=new WeakMap,at=new WeakMap;let SvelteElement;typeof HTMLElement=="function"&&(SvelteElement=class extends HTMLElement{constructor(t,n,r){super();te(this,"$$ctor");te(this,"$$s");te(this,"$$c");te(this,"$$cn",!1);te(this,"$$d",{});te(this,"$$r",!1);te(this,"$$p_d",{});te(this,"$$l",{});te(this,"$$l_u",new Map);te(this,"$$me");te(this,"$$shadowRoot",null);this.$$ctor=t,this.$$s=n,r&&(this.$$shadowRoot=this.attachShadow(r))}addEventListener(t,n,r){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(n),this.$$c){const o=this.$$c.$on(t,n);this.$$l_u.set(n,o)}super.addEventListener(t,n,r)}removeEventListener(t,n,r){if(super.removeEventListener(t,n,r),this.$$c){const o=this.$$l_u.get(n);o&&(o(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let t=function(o){return s=>{const i=create_element("slot");o!=="default"&&(i.name=o),append(s,i)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},r=get_custom_elements_slots(this);for(const o of this.$$s)o in r&&(o==="default"&&!this.$$d.children?(this.$$d.children=t(o),n.default=!0):n[o]=t(o));for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=get_custom_element_value(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=createClassComponent({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:n,$$host:this}}),this.$$me=effect_root(()=>{render_effect(()=>{var o;this.$$r=!0;for(const s of object_keys(this.$$c)){if(!((o=this.$$p_d[s])!=null&&o.reflect))continue;this.$$d[s]=this.$$c[s];const i=get_custom_element_value(s,this.$$d[s],this.$$p_d,"toAttribute");i==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,i)}this.$$r=!1})});for(const o in this.$$l)for(const s of this.$$l[o]){const i=this.$$c.$on(o,s);this.$$l_u.set(s,i)}this.$$l={}}}attributeChangedCallback(t,n,r){var o;this.$$r||(t=this.$$g_p(t),this.$$d[t]=get_custom_element_value(t,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[t]:this.$$d[t]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(t){return object_keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===t||!this.$$p_d[n].attribute&&n.toLowerCase()===t)||t}});function get_custom_element_value(e,t,n,r){var s;const o=(s=n[e])==null?void 0:s.type;if(t=o==="Boolean"&&typeof t!="boolean"?t!=null:t,!r||!n[e])return t;if(r==="toAttribute")switch(o){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(o){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function get_custom_elements_slots(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function create_custom_element(e,t,n,r,o,s){let i=class extends SvelteElement{constructor(){super(e,n,o),this.$$p_d=t}static get observedAttributes(){return object_keys(t).map(a=>(t[a].attribute||a).toLowerCase())}};return object_keys(t).forEach(a=>{define_property(i.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(l){var d;l=get_custom_element_value(a,l,t),this.$$d[a]=l;var u=this.$$c;if(u){var c=(d=get_descriptor(u,a))==null?void 0:d.get;c?u[a]=l:u.$set({[a]:l})}}})}),r.forEach(a=>{define_property(i.prototype,a,{get(){var l;return(l=this.$$c)==null?void 0:l[a]}})}),e.element=i,i}const DEFAULT_CONFIG={endpoint:"",position:"bottom-right",theme:"dark",buttonColor:"#3b82f6",maxScreenshots:5,maxConsoleLogs:50,captureConsole:!0},SENSITIVE_PATTERNS=[/\b(api[_-]?key|apikey|api[_-]?token|access[_-]?token|auth[_-]?token|bearer)\s*[:=]\s*["']?[\w\-\.]+["']?/gi,/\bBearer\s+[\w\-\.]+/gi,/\b(sk|pk|rk)[_-][a-zA-Z0-9]{20,}/gi,/\bghp_[a-zA-Z0-9]{36,}/gi,/\bsk-[a-zA-Z0-9]{20,}/gi,/\b(password|passwd|pwd|secret|credential)\s*[:=]\s*["']?[^"'\s,}{]+["']?/gi,/\beyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/gi,/\b\d{4}[\s\-]?\d{4}[\s\-]?\d{4}[\s\-]?\d{4}\b/g,/\b(email|e-mail)\s*[:=]\s*["']?[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}["']?/gi,/-----BEGIN\s+(RSA\s+)?PRIVATE\s+KEY-----[\s\S]*?-----END\s+(RSA\s+)?PRIVATE\s+KEY-----/gi,/\b(AKIA|ABIA|ACCA|AGPA|AIDA|AIPA|AKIA|ANPA|ANVA|AROA|APKA|ASCA|ASIA)[A-Z0-9]{16}\b/g,/\b(aws[_-]?secret[_-]?access[_-]?key|aws[_-]?access[_-]?key[_-]?id)\s*[:=]\s*["']?[\w\/\+]+["']?/gi],REDACTED="[REDACTED]";function filterSensitiveData(e){let t=e;for(const n of SENSITIVE_PATTERNS)n.lastIndex=0,t=t.replace(n,REDACTED);return t}let maxEntries=50;const capturedLogs=[];let capturing=!1;const originalConsole={log:console.log,error:console.error,warn:console.warn,info:console.info,debug:console.debug,trace:console.trace};function safeStringify(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(e instanceof Error)return`${e.name}: ${e.message}${e.stack?`
1
+ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=>Te in Se?pr(Se,Te,{enumerable:!0,configurable:!0,writable:!0,value:Oe}):Se[Te]=Oe;var te=(Se,Te,Oe)=>hr(Se,typeof Te!="symbol"?Te+"":Te,Oe),Gn=(Se,Te,Oe)=>Te.has(Se)||nr("Cannot "+Oe);var E=(Se,Te,Oe)=>(Gn(Se,Te,"read from private field"),Oe?Oe.call(Se):Te.get(Se)),ue=(Se,Te,Oe)=>Te.has(Se)?nr("Cannot add the same private member more than once"):Te instanceof WeakSet?Te.add(Se):Te.set(Se,Oe),ae=(Se,Te,Oe,Rt)=>(Gn(Se,Te,"write to private field"),Rt?Rt.call(Se,Oe):Te.set(Se,Oe),Oe),je=(Se,Te,Oe)=>(Gn(Se,Te,"access private method"),Oe);(function(){"use strict";var Se,Te,Oe,Rt,sn,Ht,an,gn,vn,qt,Nt,ln,bt,Yn,Xn,rr,tt,_n,yt,Wt,wt,it,Xe,xt,Ot,Ut,Gt,Lt,cn,Yt,un,dn,Mt,Tn,Le,or,sr,Kn,On,Ln,Jn,Qn,er,dt,kt,nt,Xt,mn,bn,Cn,Pt,at,tr;const PUBLIC_VERSION="5";typeof window<"u"&&((Se=window.__svelte??(window.__svelte={})).v??(Se.v=new Set)).add("5");const EACH_ITEM_REACTIVE=1,EACH_INDEX_REACTIVE=2,EACH_IS_CONTROLLED=4,EACH_IS_ANIMATED=8,EACH_ITEM_IMMUTABLE=16,PROPS_IS_IMMUTABLE=1,PROPS_IS_UPDATED=4,PROPS_IS_BINDABLE=8,PROPS_IS_LAZY_INITIAL=16,TRANSITION_GLOBAL=4,TEMPLATE_FRAGMENT=1,TEMPLATE_USE_IMPORT_NODE=2,HYDRATION_START="[",HYDRATION_START_ELSE="[!",HYDRATION_END="]",HYDRATION_ERROR={},UNINITIALIZED=Symbol(),NAMESPACE_HTML="http://www.w3.org/1999/xhtml",DEV=!1;var is_array=Array.isArray,index_of=Array.prototype.indexOf,includes=Array.prototype.includes,array_from=Array.from,object_keys=Object.keys,define_property=Object.defineProperty,get_descriptor=Object.getOwnPropertyDescriptor,get_descriptors=Object.getOwnPropertyDescriptors,object_prototype=Object.prototype,array_prototype=Array.prototype,get_prototype_of=Object.getPrototypeOf,is_extensible=Object.isExtensible;function is_function(e){return typeof e=="function"}const noop=()=>{};function run_all(e){for(var t=0;t<e.length;t++)e[t]()}function deferred(){var e,t,n=new Promise((r,o)=>{e=r,t=o});return{promise:n,resolve:e,reject:t}}const DERIVED=2,EFFECT=4,RENDER_EFFECT=8,MANAGED_EFFECT=1<<24,BLOCK_EFFECT=16,BRANCH_EFFECT=32,ROOT_EFFECT=64,BOUNDARY_EFFECT=128,CONNECTED=512,CLEAN=1024,DIRTY=2048,MAYBE_DIRTY=4096,INERT=8192,DESTROYED=16384,REACTION_RAN=32768,EFFECT_TRANSPARENT=65536,EAGER_EFFECT=1<<17,HEAD_EFFECT=1<<18,EFFECT_PRESERVED=1<<19,USER_EFFECT=1<<20,EFFECT_OFFSCREEN=1<<25,WAS_MARKED=65536,REACTION_IS_UPDATING=1<<21,ASYNC=1<<22,ERROR_VALUE=1<<23,STATE_SYMBOL=Symbol("$state"),LEGACY_PROPS=Symbol("legacy props"),LOADING_ATTR_SYMBOL=Symbol(""),STALE_REACTION=new class extends Error{constructor(){super(...arguments);te(this,"name","StaleReactionError");te(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},IS_XHTML=((Oe=(Te=globalThis.document)==null?void 0:Te.contentType)==null?void 0:Oe.includes("xml"))??!1,TEXT_NODE=3,COMMENT_NODE=8;function lifecycle_outside_component(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function async_derived_orphan(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function each_key_duplicate(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function effect_in_teardown(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function effect_in_unowned_derived(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function effect_orphan(e){throw new Error("https://svelte.dev/e/effect_orphan")}function effect_update_depth_exceeded(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function hydration_failed(){throw new Error("https://svelte.dev/e/hydration_failed")}function props_invalid_value(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function state_descriptors_fixed(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function state_prototype_fixed(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function state_unsafe_mutation(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function svelte_boundary_reset_onerror(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function hydration_mismatch(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function select_multiple_invalid_value(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function svelte_boundary_reset_noop(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let hydrating=!1;function set_hydrating(e){hydrating=e}let hydrate_node;function set_hydrate_node(e){if(e===null)throw hydration_mismatch(),HYDRATION_ERROR;return hydrate_node=e}function hydrate_next(){return set_hydrate_node(get_next_sibling(hydrate_node))}function reset(e){if(hydrating){if(get_next_sibling(hydrate_node)!==null)throw hydration_mismatch(),HYDRATION_ERROR;hydrate_node=e}}function next(e=1){if(hydrating){for(var t=e,n=hydrate_node;t--;)n=get_next_sibling(n);hydrate_node=n}}function skip_nodes(e=!0){for(var t=0,n=hydrate_node;;){if(n.nodeType===COMMENT_NODE){var r=n.data;if(r===HYDRATION_END){if(t===0)return n;t-=1}else(r===HYDRATION_START||r===HYDRATION_START_ELSE||r[0]==="["&&!isNaN(Number(r.slice(1))))&&(t+=1)}var o=get_next_sibling(n);e&&n.remove(),n=o}}function read_hydration_instruction(e){if(!e||e.nodeType!==COMMENT_NODE)throw hydration_mismatch(),HYDRATION_ERROR;return e.data}function equals(e){return e===this.v}function safe_not_equal(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function safe_equals(e){return!safe_not_equal(e,this.v)}let tracing_mode_flag=!1,component_context=null;function set_component_context(e){component_context=e}function push(e,t=!1,n){component_context={p:component_context,i:!1,c:null,e:null,s:e,x:null,l:null}}function pop(e){var t=component_context,n=t.e;if(n!==null){t.e=null;for(var r of n)create_user_effect(r)}return e!==void 0&&(t.x=e),t.i=!0,component_context=t.p,e??{}}function is_runes(){return!0}let micro_tasks=[];function run_micro_tasks(){var e=micro_tasks;micro_tasks=[],run_all(e)}function queue_micro_task(e){if(micro_tasks.length===0&&!is_flushing_sync){var t=micro_tasks;queueMicrotask(()=>{t===micro_tasks&&run_micro_tasks()})}micro_tasks.push(e)}function flush_tasks(){for(;micro_tasks.length>0;)run_micro_tasks()}function handle_error(e){var t=active_effect;if(t===null)return active_reaction.f|=ERROR_VALUE,e;if((t.f&REACTION_RAN)===0&&(t.f&EFFECT)===0)throw e;invoke_error_boundary(e,t)}function invoke_error_boundary(e,t){for(;t!==null;){if((t.f&BOUNDARY_EFFECT)!==0){if((t.f&REACTION_RAN)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const STATUS_MASK=-7169;function set_signal_status(e,t){e.f=e.f&STATUS_MASK|t}function update_derived_status(e){(e.f&CONNECTED)!==0||e.deps===null?set_signal_status(e,CLEAN):set_signal_status(e,MAYBE_DIRTY)}function clear_marked(e){if(e!==null)for(const t of e)(t.f&DERIVED)===0||(t.f&WAS_MARKED)===0||(t.f^=WAS_MARKED,clear_marked(t.deps))}function defer_effect(e,t,n){(e.f&DIRTY)!==0?t.add(e):(e.f&MAYBE_DIRTY)!==0&&n.add(e),clear_marked(e.deps),set_signal_status(e,CLEAN)}const batches=new Set;let current_batch=null,previous_batch=null,batch_values=null,queued_root_effects=[],last_scheduled_effect=null,is_flushing=!1,is_flushing_sync=!1;const Mn=class Mn{constructor(){ue(this,bt);te(this,"committed",!1);te(this,"current",new Map);te(this,"previous",new Map);ue(this,Rt,new Set);ue(this,sn,new Set);ue(this,Ht,0);ue(this,an,0);ue(this,gn,null);ue(this,vn,new Set);ue(this,qt,new Set);ue(this,Nt,new Map);te(this,"is_fork",!1);ue(this,ln,!1)}is_deferred(){return this.is_fork||E(this,an)>0}skip_effect(t){E(this,Nt).has(t)||E(this,Nt).set(t,{d:[],m:[]})}unskip_effect(t){var n=E(this,Nt).get(t);if(n){E(this,Nt).delete(t);for(var r of n.d)set_signal_status(r,DIRTY),schedule_effect(r);for(r of n.m)set_signal_status(r,MAYBE_DIRTY),schedule_effect(r)}}process(t){var o;queued_root_effects=[],this.apply();var n=[],r=[];for(const s of t)je(this,bt,Yn).call(this,s,n,r);if(this.is_deferred()){je(this,bt,Xn).call(this,r),je(this,bt,Xn).call(this,n);for(const[s,i]of E(this,Nt))reset_branch(s,i)}else{for(const s of E(this,Rt))s();E(this,Rt).clear(),E(this,Ht)===0&&je(this,bt,rr).call(this),previous_batch=this,current_batch=null,flush_queued_effects(r),flush_queued_effects(n),previous_batch=null,(o=E(this,gn))==null||o.resolve()}batch_values=null}capture(t,n){n!==UNINITIALIZED&&!this.previous.has(t)&&this.previous.set(t,n),(t.f&ERROR_VALUE)===0&&(this.current.set(t,t.v),batch_values==null||batch_values.set(t,t.v))}activate(){current_batch=this,this.apply()}deactivate(){current_batch===this&&(current_batch=null,batch_values=null)}flush(){if(this.activate(),queued_root_effects.length>0){if(flush_effects(),current_batch!==null&&current_batch!==this)return}else E(this,Ht)===0&&this.process([]);this.deactivate()}discard(){for(const t of E(this,sn))t(this);E(this,sn).clear()}increment(t){ae(this,Ht,E(this,Ht)+1),t&&ae(this,an,E(this,an)+1)}decrement(t){ae(this,Ht,E(this,Ht)-1),t&&ae(this,an,E(this,an)-1),!E(this,ln)&&(ae(this,ln,!0),queue_micro_task(()=>{ae(this,ln,!1),this.is_deferred()?queued_root_effects.length>0&&this.flush():this.revive()}))}revive(){for(const t of E(this,vn))E(this,qt).delete(t),set_signal_status(t,DIRTY),schedule_effect(t);for(const t of E(this,qt))set_signal_status(t,MAYBE_DIRTY),schedule_effect(t);this.flush()}oncommit(t){E(this,Rt).add(t)}ondiscard(t){E(this,sn).add(t)}settled(){return(E(this,gn)??ae(this,gn,deferred())).promise}static ensure(){if(current_batch===null){const t=current_batch=new Mn;batches.add(current_batch),is_flushing_sync||queue_micro_task(()=>{current_batch===t&&t.flush()})}return current_batch}apply(){}};Rt=new WeakMap,sn=new WeakMap,Ht=new WeakMap,an=new WeakMap,gn=new WeakMap,vn=new WeakMap,qt=new WeakMap,Nt=new WeakMap,ln=new WeakMap,bt=new WeakSet,Yn=function(t,n,r){t.f^=CLEAN;for(var o=t.first,s=null;o!==null;){var i=o.f,a=(i&(BRANCH_EFFECT|ROOT_EFFECT))!==0,l=a&&(i&CLEAN)!==0,u=l||(i&INERT)!==0||E(this,Nt).has(o);if(!u&&o.fn!==null){a?o.f^=CLEAN:s!==null&&(i&(EFFECT|RENDER_EFFECT|MANAGED_EFFECT))!==0?s.b.defer_effect(o):(i&EFFECT)!==0?n.push(o):is_dirty(o)&&((i&BLOCK_EFFECT)!==0&&E(this,qt).add(o),update_effect(o));var c=o.first;if(c!==null){o=c;continue}}var d=o.parent;for(o=o.next;o===null&&d!==null;)d===s&&(s=null),o=d.next,d=d.parent}},Xn=function(t){for(var n=0;n<t.length;n+=1)defer_effect(t[n],E(this,vn),E(this,qt))},rr=function(){var o;if(batches.size>1){this.previous.clear();var t=batch_values,n=!0;for(const s of batches){if(s===this){n=!1;continue}const i=[];for(const[l,u]of this.current){if(s.current.has(l))if(n&&u!==s.current.get(l))s.current.set(l,u);else continue;i.push(l)}if(i.length===0)continue;const a=[...s.current.keys()].filter(l=>!this.current.has(l));if(a.length>0){var r=queued_root_effects;queued_root_effects=[];const l=new Set,u=new Map;for(const c of i)mark_effects(c,a,l,u);if(queued_root_effects.length>0){current_batch=s,s.apply();for(const c of queued_root_effects)je(o=s,bt,Yn).call(o,c,[],[]);s.deactivate()}queued_root_effects=r}}current_batch=null,batch_values=t}this.committed=!0,batches.delete(this)};let Batch=Mn;function flushSync(e){var t=is_flushing_sync;is_flushing_sync=!0;try{for(var n;;){if(flush_tasks(),queued_root_effects.length===0&&(current_batch==null||current_batch.flush(),queued_root_effects.length===0))return last_scheduled_effect=null,n;flush_effects()}}finally{is_flushing_sync=t}}function flush_effects(){is_flushing=!0;var e=null;try{for(var t=0;queued_root_effects.length>0;){var n=Batch.ensure();if(t++>1e3){var r,o;infinite_loop_guard()}n.process(queued_root_effects),old_values.clear()}}finally{queued_root_effects=[],is_flushing=!1,last_scheduled_effect=null}}function infinite_loop_guard(){try{effect_update_depth_exceeded()}catch(e){invoke_error_boundary(e,last_scheduled_effect)}}let eager_block_effects=null;function flush_queued_effects(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(DESTROYED|INERT))===0&&is_dirty(r)&&(eager_block_effects=new Set,update_effect(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&unlink_effect(r),(eager_block_effects==null?void 0:eager_block_effects.size)>0)){old_values.clear();for(const o of eager_block_effects){if((o.f&(DESTROYED|INERT))!==0)continue;const s=[o];let i=o.parent;for(;i!==null;)eager_block_effects.has(i)&&(eager_block_effects.delete(i),s.push(i)),i=i.parent;for(let a=s.length-1;a>=0;a--){const l=s[a];(l.f&(DESTROYED|INERT))===0&&update_effect(l)}}eager_block_effects.clear()}}eager_block_effects=null}}function mark_effects(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const o of e.reactions){const s=o.f;(s&DERIVED)!==0?mark_effects(o,t,n,r):(s&(ASYNC|BLOCK_EFFECT))!==0&&(s&DIRTY)===0&&depends_on(o,t,r)&&(set_signal_status(o,DIRTY),schedule_effect(o))}}function depends_on(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const o of e.deps){if(includes.call(t,o))return!0;if((o.f&DERIVED)!==0&&depends_on(o,t,n))return n.set(o,!0),!0}return n.set(e,!1),!1}function schedule_effect(e){for(var t=last_scheduled_effect=e;t.parent!==null;){t=t.parent;var n=t.f;if(is_flushing&&t===active_effect&&(n&BLOCK_EFFECT)!==0&&(n&HEAD_EFFECT)===0)return;if((n&(ROOT_EFFECT|BRANCH_EFFECT))!==0){if((n&CLEAN)===0)return;t.f^=CLEAN}}queued_root_effects.push(t)}function reset_branch(e,t){if(!((e.f&BRANCH_EFFECT)!==0&&(e.f&CLEAN)!==0)){(e.f&DIRTY)!==0?t.d.push(e):(e.f&MAYBE_DIRTY)!==0&&t.m.push(e),set_signal_status(e,CLEAN);for(var n=e.first;n!==null;)reset_branch(n,t),n=n.next}}function createSubscriber(e){let t=0,n=source(0),r;return()=>{effect_tracking()&&(get(n),render_effect(()=>(t===0&&(r=untrack(()=>e(()=>increment(n)))),t+=1,()=>{queue_micro_task(()=>{t-=1,t===0&&(r==null||r(),r=void 0,increment(n))})})))}}var flags=EFFECT_TRANSPARENT|EFFECT_PRESERVED|BOUNDARY_EFFECT;function boundary(e,t,n){new Boundary(e,t,n)}class Boundary{constructor(t,n,r){ue(this,Le);te(this,"parent");te(this,"is_pending",!1);ue(this,tt);ue(this,_n,hydrating?hydrate_node:null);ue(this,yt);ue(this,Wt);ue(this,wt);ue(this,it,null);ue(this,Xe,null);ue(this,xt,null);ue(this,Ot,null);ue(this,Ut,null);ue(this,Gt,0);ue(this,Lt,0);ue(this,cn,!1);ue(this,Yt,!1);ue(this,un,new Set);ue(this,dn,new Set);ue(this,Mt,null);ue(this,Tn,createSubscriber(()=>(ae(this,Mt,source(E(this,Gt))),()=>{ae(this,Mt,null)})));ae(this,tt,t),ae(this,yt,n),ae(this,Wt,r),this.parent=active_effect.b,this.is_pending=!!E(this,yt).pending,ae(this,wt,block(()=>{if(active_effect.b=this,hydrating){const s=E(this,_n);hydrate_next(),s.nodeType===COMMENT_NODE&&s.data===HYDRATION_START_ELSE?je(this,Le,sr).call(this):(je(this,Le,or).call(this),E(this,Lt)===0&&(this.is_pending=!1))}else{var o=je(this,Le,Kn).call(this);try{ae(this,it,branch(()=>r(o)))}catch(s){this.error(s)}E(this,Lt)>0?je(this,Le,Ln).call(this):this.is_pending=!1}return()=>{var s;(s=E(this,Ut))==null||s.remove()}},flags)),hydrating&&ae(this,tt,hydrate_node)}defer_effect(t){defer_effect(t,E(this,un),E(this,dn))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!E(this,yt).pending}update_pending_count(t){je(this,Le,Jn).call(this,t),ae(this,Gt,E(this,Gt)+t),!(!E(this,Mt)||E(this,cn))&&(ae(this,cn,!0),queue_micro_task(()=>{ae(this,cn,!1),E(this,Mt)&&internal_set(E(this,Mt),E(this,Gt))}))}get_effect_pending(){return E(this,Tn).call(this),get(E(this,Mt))}error(t){var n=E(this,yt).onerror;let r=E(this,yt).failed;if(E(this,Yt)||!n&&!r)throw t;E(this,it)&&(destroy_effect(E(this,it)),ae(this,it,null)),E(this,Xe)&&(destroy_effect(E(this,Xe)),ae(this,Xe,null)),E(this,xt)&&(destroy_effect(E(this,xt)),ae(this,xt,null)),hydrating&&(set_hydrate_node(E(this,_n)),next(),set_hydrate_node(skip_nodes()));var o=!1,s=!1;const i=()=>{if(o){svelte_boundary_reset_noop();return}o=!0,s&&svelte_boundary_reset_onerror(),Batch.ensure(),ae(this,Gt,0),E(this,xt)!==null&&pause_effect(E(this,xt),()=>{ae(this,xt,null)}),this.is_pending=this.has_pending_snippet(),ae(this,it,je(this,Le,On).call(this,()=>(ae(this,Yt,!1),branch(()=>E(this,Wt).call(this,E(this,tt)))))),E(this,Lt)>0?je(this,Le,Ln).call(this):this.is_pending=!1};queue_micro_task(()=>{try{s=!0,n==null||n(t,i),s=!1}catch(a){invoke_error_boundary(a,E(this,wt)&&E(this,wt).parent)}r&&ae(this,xt,je(this,Le,On).call(this,()=>{Batch.ensure(),ae(this,Yt,!0);try{return branch(()=>{r(E(this,tt),()=>t,()=>i)})}catch(a){return invoke_error_boundary(a,E(this,wt).parent),null}finally{ae(this,Yt,!1)}}))})}}tt=new WeakMap,_n=new WeakMap,yt=new WeakMap,Wt=new WeakMap,wt=new WeakMap,it=new WeakMap,Xe=new WeakMap,xt=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Gt=new WeakMap,Lt=new WeakMap,cn=new WeakMap,Yt=new WeakMap,un=new WeakMap,dn=new WeakMap,Mt=new WeakMap,Tn=new WeakMap,Le=new WeakSet,or=function(){try{ae(this,it,branch(()=>E(this,Wt).call(this,E(this,tt))))}catch(t){this.error(t)}},sr=function(){const t=E(this,yt).pending;t&&(ae(this,Xe,branch(()=>t(E(this,tt)))),queue_micro_task(()=>{var n=je(this,Le,Kn).call(this);ae(this,it,je(this,Le,On).call(this,()=>(Batch.ensure(),branch(()=>E(this,Wt).call(this,n))))),E(this,Lt)>0?je(this,Le,Ln).call(this):(pause_effect(E(this,Xe),()=>{ae(this,Xe,null)}),this.is_pending=!1)}))},Kn=function(){var t=E(this,tt);return this.is_pending&&(ae(this,Ut,create_text()),E(this,tt).before(E(this,Ut)),t=E(this,Ut)),t},On=function(t){var n=active_effect,r=active_reaction,o=component_context;set_active_effect(E(this,wt)),set_active_reaction(E(this,wt)),set_component_context(E(this,wt).ctx);try{return t()}catch(s){return handle_error(s),null}finally{set_active_effect(n),set_active_reaction(r),set_component_context(o)}},Ln=function(){const t=E(this,yt).pending;E(this,it)!==null&&(ae(this,Ot,document.createDocumentFragment()),E(this,Ot).append(E(this,Ut)),move_effect(E(this,it),E(this,Ot))),E(this,Xe)===null&&ae(this,Xe,branch(()=>t(E(this,tt))))},Jn=function(t){var n;if(!this.has_pending_snippet()){this.parent&&je(n=this.parent,Le,Jn).call(n,t);return}if(ae(this,Lt,E(this,Lt)+t),E(this,Lt)===0){this.is_pending=!1;for(const r of E(this,un))set_signal_status(r,DIRTY),schedule_effect(r);for(const r of E(this,dn))set_signal_status(r,MAYBE_DIRTY),schedule_effect(r);E(this,un).clear(),E(this,dn).clear(),E(this,Xe)&&pause_effect(E(this,Xe),()=>{ae(this,Xe,null)}),E(this,Ot)&&(E(this,tt).before(E(this,Ot)),ae(this,Ot,null))}};function flatten(e,t,n,r){const o=derived;var s=e.filter(p=>!p.settled);if(n.length===0&&s.length===0){r(t.map(o));return}var i=current_batch,a=active_effect,l=capture(),u=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(p=>p.promise)):null;function c(p){l();try{r(p)}catch(g){(a.f&DESTROYED)===0&&invoke_error_boundary(g,a)}i==null||i.deactivate(),unset_context()}if(n.length===0){u.then(()=>c(t.map(o)));return}function d(){l(),Promise.all(n.map(p=>async_derived(p))).then(p=>c([...t.map(o),...p])).catch(p=>invoke_error_boundary(p,a))}u?u.then(d):d()}function capture(){var e=active_effect,t=active_reaction,n=component_context,r=current_batch;return function(s=!0){set_active_effect(e),set_active_reaction(t),set_component_context(n),s&&(r==null||r.activate())}}function unset_context(){set_active_effect(null),set_active_reaction(null),set_component_context(null)}function derived(e){var t=DERIVED|DIRTY,n=active_reaction!==null&&(active_reaction.f&DERIVED)!==0?active_reaction:null;return active_effect!==null&&(active_effect.f|=EFFECT_PRESERVED),{ctx:component_context,deps:null,effects:null,equals,f:t,fn:e,reactions:null,rv:0,v:UNINITIALIZED,wv:0,parent:n??active_effect,ac:null}}function async_derived(e,t,n){let r=active_effect;r===null&&async_derived_orphan();var o=r.b,s=void 0,i=source(UNINITIALIZED),a=!active_reaction,l=new Map;return async_effect(()=>{var g;var u=deferred();s=u.promise;try{Promise.resolve(e()).then(u.resolve,u.reject).then(()=>{c===current_batch&&c.committed&&c.deactivate(),unset_context()})}catch(_){u.reject(_),unset_context()}var c=current_batch;if(a){var d=o.is_rendered();o.update_pending_count(1),c.increment(d),(g=l.get(c))==null||g.reject(STALE_REACTION),l.delete(c),l.set(c,u)}const p=(_,y=void 0)=>{if(c.activate(),y)y!==STALE_REACTION&&(i.f|=ERROR_VALUE,internal_set(i,y));else{(i.f&ERROR_VALUE)!==0&&(i.f^=ERROR_VALUE),internal_set(i,_);for(const[h,f]of l){if(l.delete(h),h===c)break;f.reject(STALE_REACTION)}}a&&(o.update_pending_count(-1),c.decrement(d))};u.promise.then(p,_=>p(null,_||"unknown"))}),teardown(()=>{for(const u of l.values())u.reject(STALE_REACTION)}),new Promise(u=>{function c(d){function p(){d===s?u(i):c(s)}d.then(p,p)}c(s)})}function user_derived(e){const t=derived(e);return push_reaction_value(t),t}function derived_safe_equal(e){const t=derived(e);return t.equals=safe_equals,t}function destroy_derived_effects(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)destroy_effect(t[n])}}function get_derived_parent_effect(e){for(var t=e.parent;t!==null;){if((t.f&DERIVED)===0)return(t.f&DESTROYED)===0?t:null;t=t.parent}return null}function execute_derived(e){var t,n=active_effect;set_active_effect(get_derived_parent_effect(e));try{e.f&=~WAS_MARKED,destroy_derived_effects(e),t=update_reaction(e)}finally{set_active_effect(n)}return t}function update_derived(e){var t=execute_derived(e);if(!e.equals(t)&&(e.wv=increment_write_version(),(!(current_batch!=null&&current_batch.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){set_signal_status(e,CLEAN);return}is_destroying_effect||(batch_values!==null?(effect_tracking()||current_batch!=null&&current_batch.is_fork)&&batch_values.set(e,t):update_derived_status(e))}function freeze_derived_effects(e){var t,n;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(n=r.ac)==null||n.abort(STALE_REACTION),r.teardown=noop,r.ac=null,remove_reactions(r,0),destroy_effect_children(r))}function unfreeze_derived_effects(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&update_effect(t)}let eager_effects=new Set;const old_values=new Map;let eager_effects_deferred=!1;function source(e,t){var n={f:0,v:e,reactions:null,equals,rv:0,wv:0};return n}function state(e,t){const n=source(e);return push_reaction_value(n),n}function mutable_source(e,t=!1,n=!0){const r=source(e);return t||(r.equals=safe_equals),r}function set(e,t,n=!1){active_reaction!==null&&(!untracking||(active_reaction.f&EAGER_EFFECT)!==0)&&is_runes()&&(active_reaction.f&(DERIVED|BLOCK_EFFECT|ASYNC|EAGER_EFFECT))!==0&&(current_sources===null||!includes.call(current_sources,e))&&state_unsafe_mutation();let r=n?proxy(t):t;return internal_set(e,r)}function internal_set(e,t){if(!e.equals(t)){var n=e.v;is_destroying_effect?old_values.set(e,t):old_values.set(e,n),e.v=t;var r=Batch.ensure();if(r.capture(e,n),(e.f&DERIVED)!==0){const o=e;(e.f&DIRTY)!==0&&execute_derived(o),update_derived_status(o)}e.wv=increment_write_version(),mark_reactions(e,DIRTY),active_effect!==null&&(active_effect.f&CLEAN)!==0&&(active_effect.f&(BRANCH_EFFECT|ROOT_EFFECT))===0&&(untracked_writes===null?set_untracked_writes([e]):untracked_writes.push(e)),!r.is_fork&&eager_effects.size>0&&!eager_effects_deferred&&flush_eager_effects()}return t}function flush_eager_effects(){eager_effects_deferred=!1;for(const e of eager_effects)(e.f&CLEAN)!==0&&set_signal_status(e,MAYBE_DIRTY),is_dirty(e)&&update_effect(e);eager_effects.clear()}function increment(e){set(e,e.v+1)}function mark_reactions(e,t){var n=e.reactions;if(n!==null)for(var r=n.length,o=0;o<r;o++){var s=n[o],i=s.f,a=(i&DIRTY)===0;if(a&&set_signal_status(s,t),(i&DERIVED)!==0){var l=s;batch_values==null||batch_values.delete(l),(i&WAS_MARKED)===0&&(i&CONNECTED&&(s.f|=WAS_MARKED),mark_reactions(l,MAYBE_DIRTY))}else a&&((i&BLOCK_EFFECT)!==0&&eager_block_effects!==null&&eager_block_effects.add(s),schedule_effect(s))}}function proxy(e){if(typeof e!="object"||e===null||STATE_SYMBOL in e)return e;const t=get_prototype_of(e);if(t!==object_prototype&&t!==array_prototype)return e;var n=new Map,r=is_array(e),o=state(0),s=update_version,i=a=>{if(update_version===s)return a();var l=active_reaction,u=update_version;set_active_reaction(null),set_update_version(s);var c=a();return set_active_reaction(l),set_update_version(u),c};return r&&n.set("length",state(e.length)),new Proxy(e,{defineProperty(a,l,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&state_descriptors_fixed();var c=n.get(l);return c===void 0?i(()=>{var d=state(u.value);return n.set(l,d),d}):set(c,u.value,!0),!0},deleteProperty(a,l){var u=n.get(l);if(u===void 0){if(l in a){const c=i(()=>state(UNINITIALIZED));n.set(l,c),increment(o)}}else set(u,UNINITIALIZED),increment(o);return!0},get(a,l,u){var g;if(l===STATE_SYMBOL)return e;var c=n.get(l),d=l in a;if(c===void 0&&(!d||(g=get_descriptor(a,l))!=null&&g.writable)&&(c=i(()=>{var _=proxy(d?a[l]:UNINITIALIZED),y=state(_);return y}),n.set(l,c)),c!==void 0){var p=get(c);return p===UNINITIALIZED?void 0:p}return Reflect.get(a,l,u)},getOwnPropertyDescriptor(a,l){var u=Reflect.getOwnPropertyDescriptor(a,l);if(u&&"value"in u){var c=n.get(l);c&&(u.value=get(c))}else if(u===void 0){var d=n.get(l),p=d==null?void 0:d.v;if(d!==void 0&&p!==UNINITIALIZED)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return u},has(a,l){var p;if(l===STATE_SYMBOL)return!0;var u=n.get(l),c=u!==void 0&&u.v!==UNINITIALIZED||Reflect.has(a,l);if(u!==void 0||active_effect!==null&&(!c||(p=get_descriptor(a,l))!=null&&p.writable)){u===void 0&&(u=i(()=>{var g=c?proxy(a[l]):UNINITIALIZED,_=state(g);return _}),n.set(l,u));var d=get(u);if(d===UNINITIALIZED)return!1}return c},set(a,l,u,c){var m;var d=n.get(l),p=l in a;if(r&&l==="length")for(var g=u;g<d.v;g+=1){var _=n.get(g+"");_!==void 0?set(_,UNINITIALIZED):g in a&&(_=i(()=>state(UNINITIALIZED)),n.set(g+"",_))}if(d===void 0)(!p||(m=get_descriptor(a,l))!=null&&m.writable)&&(d=i(()=>state(void 0)),set(d,proxy(u)),n.set(l,d));else{p=d.v!==UNINITIALIZED;var y=i(()=>proxy(u));set(d,y)}var h=Reflect.getOwnPropertyDescriptor(a,l);if(h!=null&&h.set&&h.set.call(c,u),!p){if(r&&typeof l=="string"){var f=n.get("length"),b=Number(l);Number.isInteger(b)&&b>=f.v&&set(f,b+1)}increment(o)}return!0},ownKeys(a){get(o);var l=Reflect.ownKeys(a).filter(d=>{var p=n.get(d);return p===void 0||p.v!==UNINITIALIZED});for(var[u,c]of n)c.v!==UNINITIALIZED&&!(u in a)&&l.push(u);return l},setPrototypeOf(){state_prototype_fixed()}})}function get_proxied_value(e){try{if(e!==null&&typeof e=="object"&&STATE_SYMBOL in e)return e[STATE_SYMBOL]}catch{}return e}function is(e,t){return Object.is(get_proxied_value(e),get_proxied_value(t))}var $window,is_firefox,first_child_getter,next_sibling_getter;function init_operations(){if($window===void 0){$window=window,is_firefox=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;first_child_getter=get_descriptor(t,"firstChild").get,next_sibling_getter=get_descriptor(t,"nextSibling").get,is_extensible(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),is_extensible(n)&&(n.__t=void 0)}}function create_text(e=""){return document.createTextNode(e)}function get_first_child(e){return first_child_getter.call(e)}function get_next_sibling(e){return next_sibling_getter.call(e)}function child(e,t){if(!hydrating)return get_first_child(e);var n=get_first_child(hydrate_node);if(n===null)n=hydrate_node.appendChild(create_text());else if(t&&n.nodeType!==TEXT_NODE){var r=create_text();return n==null||n.before(r),set_hydrate_node(r),r}return t&&merge_text_nodes(n),set_hydrate_node(n),n}function first_child(e,t=!1){if(!hydrating){var n=get_first_child(e);return n instanceof Comment&&n.data===""?get_next_sibling(n):n}if(t){if((hydrate_node==null?void 0:hydrate_node.nodeType)!==TEXT_NODE){var r=create_text();return hydrate_node==null||hydrate_node.before(r),set_hydrate_node(r),r}merge_text_nodes(hydrate_node)}return hydrate_node}function sibling(e,t=1,n=!1){let r=hydrating?hydrate_node:e;for(var o;t--;)o=r,r=get_next_sibling(r);if(!hydrating)return r;if(n){if((r==null?void 0:r.nodeType)!==TEXT_NODE){var s=create_text();return r===null?o==null||o.after(s):r.before(s),set_hydrate_node(s),s}merge_text_nodes(r)}return set_hydrate_node(r),r}function clear_text_content(e){e.textContent=""}function should_defer_append(){return!1}function create_element(e,t,n){return document.createElementNS(NAMESPACE_HTML,e,void 0)}function merge_text_nodes(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===TEXT_NODE;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function remove_textarea_child(e){hydrating&&get_first_child(e)!==null&&clear_text_content(e)}let listening_to_form_reset=!1;function add_form_reset_listener(){listening_to_form_reset||(listening_to_form_reset=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const n of e.target.elements)(t=n.__on_r)==null||t.call(n)})},{capture:!0}))}function without_reactive_context(e){var t=active_reaction,n=active_effect;set_active_reaction(null),set_active_effect(null);try{return e()}finally{set_active_reaction(t),set_active_effect(n)}}function listen_to_event_and_reset_event(e,t,n,r=n){e.addEventListener(t,()=>without_reactive_context(n));const o=e.__on_r;o?e.__on_r=()=>{o(),r(!0)}:e.__on_r=()=>r(!0),add_form_reset_listener()}function validate_effect(e){active_effect===null&&(active_reaction===null&&effect_orphan(),effect_in_unowned_derived()),is_destroying_effect&&effect_in_teardown()}function push_effect(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function create_effect(e,t,n){var r=active_effect;r!==null&&(r.f&INERT)!==0&&(e|=INERT);var o={ctx:component_context,deps:null,nodes:null,f:e|DIRTY|CONNECTED,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{update_effect(o)}catch(a){throw destroy_effect(o),a}else t!==null&&schedule_effect(o);var s=o;if(n&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&EFFECT_PRESERVED)===0&&(s=s.first,(e&BLOCK_EFFECT)!==0&&(e&EFFECT_TRANSPARENT)!==0&&s!==null&&(s.f|=EFFECT_TRANSPARENT)),s!==null&&(s.parent=r,r!==null&&push_effect(s,r),active_reaction!==null&&(active_reaction.f&DERIVED)!==0&&(e&ROOT_EFFECT)===0)){var i=active_reaction;(i.effects??(i.effects=[])).push(s)}return o}function effect_tracking(){return active_reaction!==null&&!untracking}function teardown(e){const t=create_effect(RENDER_EFFECT,null,!1);return set_signal_status(t,CLEAN),t.teardown=e,t}function user_effect(e){validate_effect();var t=active_effect.f,n=!active_reaction&&(t&BRANCH_EFFECT)!==0&&(t&REACTION_RAN)===0;if(n){var r=component_context;(r.e??(r.e=[])).push(e)}else return create_user_effect(e)}function create_user_effect(e){return create_effect(EFFECT|USER_EFFECT,e,!1)}function effect_root(e){Batch.ensure();const t=create_effect(ROOT_EFFECT|EFFECT_PRESERVED,e,!0);return()=>{destroy_effect(t)}}function component_root(e){Batch.ensure();const t=create_effect(ROOT_EFFECT|EFFECT_PRESERVED,e,!0);return(n={})=>new Promise(r=>{n.outro?pause_effect(t,()=>{destroy_effect(t),r(void 0)}):(destroy_effect(t),r(void 0))})}function effect(e){return create_effect(EFFECT,e,!1)}function async_effect(e){return create_effect(ASYNC|EFFECT_PRESERVED,e,!0)}function render_effect(e,t=0){return create_effect(RENDER_EFFECT|t,e,!0)}function template_effect(e,t=[],n=[],r=[]){flatten(r,t,n,o=>{create_effect(RENDER_EFFECT,()=>e(...o.map(get)),!0)})}function block(e,t=0){var n=create_effect(BLOCK_EFFECT|t,e,!0);return n}function branch(e){return create_effect(BRANCH_EFFECT|EFFECT_PRESERVED,e,!0)}function execute_effect_teardown(e){var t=e.teardown;if(t!==null){const n=is_destroying_effect,r=active_reaction;set_is_destroying_effect(!0),set_active_reaction(null);try{t.call(null)}finally{set_is_destroying_effect(n),set_active_reaction(r)}}}function destroy_effect_children(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const o=n.ac;o!==null&&without_reactive_context(()=>{o.abort(STALE_REACTION)});var r=n.next;(n.f&ROOT_EFFECT)!==0?n.parent=null:destroy_effect(n,t),n=r}}function destroy_block_effect_children(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&BRANCH_EFFECT)===0&&destroy_effect(t),t=n}}function destroy_effect(e,t=!0){var n=!1;(t||(e.f&HEAD_EFFECT)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(remove_effect_dom(e.nodes.start,e.nodes.end),n=!0),destroy_effect_children(e,t&&!n),remove_reactions(e,0),set_signal_status(e,DESTROYED);var r=e.nodes&&e.nodes.t;if(r!==null)for(const s of r)s.stop();execute_effect_teardown(e);var o=e.parent;o!==null&&o.first!==null&&unlink_effect(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function remove_effect_dom(e,t){for(;e!==null;){var n=e===t?null:get_next_sibling(e);e.remove(),e=n}}function unlink_effect(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function pause_effect(e,t,n=!0){var r=[];pause_children(e,r,!0);var o=()=>{n&&destroy_effect(e),t&&t()},s=r.length;if(s>0){var i=()=>--s||o();for(var a of r)a.out(i)}else o()}function pause_children(e,t,n){if((e.f&INERT)===0){e.f^=INERT;var r=e.nodes&&e.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&t.push(a);for(var o=e.first;o!==null;){var s=o.next,i=(o.f&EFFECT_TRANSPARENT)!==0||(o.f&BRANCH_EFFECT)!==0&&(e.f&BLOCK_EFFECT)!==0;pause_children(o,t,i?n:!1),o=s}}}function resume_effect(e){resume_children(e,!0)}function resume_children(e,t){if((e.f&INERT)!==0){e.f^=INERT,(e.f&CLEAN)===0&&(set_signal_status(e,DIRTY),schedule_effect(e));for(var n=e.first;n!==null;){var r=n.next,o=(n.f&EFFECT_TRANSPARENT)!==0||(n.f&BRANCH_EFFECT)!==0;resume_children(n,o?t:!1),n=r}var s=e.nodes&&e.nodes.t;if(s!==null)for(const i of s)(i.is_global||t)&&i.in()}}function move_effect(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var o=n===r?null:get_next_sibling(n);t.append(n),n=o}}let is_updating_effect=!1,is_destroying_effect=!1;function set_is_destroying_effect(e){is_destroying_effect=e}let active_reaction=null,untracking=!1;function set_active_reaction(e){active_reaction=e}let active_effect=null;function set_active_effect(e){active_effect=e}let current_sources=null;function push_reaction_value(e){active_reaction!==null&&(current_sources===null?current_sources=[e]:current_sources.push(e))}let new_deps=null,skipped_deps=0,untracked_writes=null;function set_untracked_writes(e){untracked_writes=e}let write_version=1,read_version=0,update_version=read_version;function set_update_version(e){update_version=e}function increment_write_version(){return++write_version}function is_dirty(e){var t=e.f;if((t&DIRTY)!==0)return!0;if(t&DERIVED&&(e.f&=~WAS_MARKED),(t&MAYBE_DIRTY)!==0){for(var n=e.deps,r=n.length,o=0;o<r;o++){var s=n[o];if(is_dirty(s)&&update_derived(s),s.wv>e.wv)return!0}(t&CONNECTED)!==0&&batch_values===null&&set_signal_status(e,CLEAN)}return!1}function schedule_possible_effect_self_invalidation(e,t,n=!0){var r=e.reactions;if(r!==null&&!(current_sources!==null&&includes.call(current_sources,e)))for(var o=0;o<r.length;o++){var s=r[o];(s.f&DERIVED)!==0?schedule_possible_effect_self_invalidation(s,t,!1):t===s&&(n?set_signal_status(s,DIRTY):(s.f&CLEAN)!==0&&set_signal_status(s,MAYBE_DIRTY),schedule_effect(s))}}function update_reaction(e){var y;var t=new_deps,n=skipped_deps,r=untracked_writes,o=active_reaction,s=current_sources,i=component_context,a=untracking,l=update_version,u=e.f;new_deps=null,skipped_deps=0,untracked_writes=null,active_reaction=(u&(BRANCH_EFFECT|ROOT_EFFECT))===0?e:null,current_sources=null,set_component_context(e.ctx),untracking=!1,update_version=++read_version,e.ac!==null&&(without_reactive_context(()=>{e.ac.abort(STALE_REACTION)}),e.ac=null);try{e.f|=REACTION_IS_UPDATING;var c=e.fn,d=c();e.f|=REACTION_RAN;var p=e.deps,g=current_batch==null?void 0:current_batch.is_fork;if(new_deps!==null){var _;if(g||remove_reactions(e,skipped_deps),p!==null&&skipped_deps>0)for(p.length=skipped_deps+new_deps.length,_=0;_<new_deps.length;_++)p[skipped_deps+_]=new_deps[_];else e.deps=p=new_deps;if(effect_tracking()&&(e.f&CONNECTED)!==0)for(_=skipped_deps;_<p.length;_++)((y=p[_]).reactions??(y.reactions=[])).push(e)}else!g&&p!==null&&skipped_deps<p.length&&(remove_reactions(e,skipped_deps),p.length=skipped_deps);if(is_runes()&&untracked_writes!==null&&!untracking&&p!==null&&(e.f&(DERIVED|MAYBE_DIRTY|DIRTY))===0)for(_=0;_<untracked_writes.length;_++)schedule_possible_effect_self_invalidation(untracked_writes[_],e);if(o!==null&&o!==e){if(read_version++,o.deps!==null)for(let h=0;h<n;h+=1)o.deps[h].rv=read_version;if(t!==null)for(const h of t)h.rv=read_version;untracked_writes!==null&&(r===null?r=untracked_writes:r.push(...untracked_writes))}return(e.f&ERROR_VALUE)!==0&&(e.f^=ERROR_VALUE),d}catch(h){return handle_error(h)}finally{e.f^=REACTION_IS_UPDATING,new_deps=t,skipped_deps=n,untracked_writes=r,active_reaction=o,current_sources=s,set_component_context(i),untracking=a,update_version=l}}function remove_reaction(e,t){let n=t.reactions;if(n!==null){var r=index_of.call(n,e);if(r!==-1){var o=n.length-1;o===0?n=t.reactions=null:(n[r]=n[o],n.pop())}}if(n===null&&(t.f&DERIVED)!==0&&(new_deps===null||!includes.call(new_deps,t))){var s=t;(s.f&CONNECTED)!==0&&(s.f^=CONNECTED,s.f&=~WAS_MARKED),update_derived_status(s),freeze_derived_effects(s),remove_reactions(s,0)}}function remove_reactions(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)remove_reaction(e,n[r])}function update_effect(e){var t=e.f;if((t&DESTROYED)===0){set_signal_status(e,CLEAN);var n=active_effect,r=is_updating_effect;active_effect=e,is_updating_effect=!0;try{(t&(BLOCK_EFFECT|MANAGED_EFFECT))!==0?destroy_block_effect_children(e):destroy_effect_children(e),execute_effect_teardown(e);var o=update_reaction(e);e.teardown=typeof o=="function"?o:null,e.wv=write_version;var s;DEV&&tracing_mode_flag&&(e.f&DIRTY)!==0&&e.deps}finally{is_updating_effect=r,active_effect=n}}}async function tick(){await Promise.resolve(),flushSync()}function get(e){var t=e.f,n=(t&DERIVED)!==0;if(active_reaction!==null&&!untracking){var r=active_effect!==null&&(active_effect.f&DESTROYED)!==0;if(!r&&(current_sources===null||!includes.call(current_sources,e))){var o=active_reaction.deps;if((active_reaction.f&REACTION_IS_UPDATING)!==0)e.rv<read_version&&(e.rv=read_version,new_deps===null&&o!==null&&o[skipped_deps]===e?skipped_deps++:new_deps===null?new_deps=[e]:new_deps.push(e));else{(active_reaction.deps??(active_reaction.deps=[])).push(e);var s=e.reactions;s===null?e.reactions=[active_reaction]:includes.call(s,active_reaction)||s.push(active_reaction)}}}if(is_destroying_effect&&old_values.has(e))return old_values.get(e);if(n){var i=e;if(is_destroying_effect){var a=i.v;return((i.f&CLEAN)===0&&i.reactions!==null||depends_on_old_values(i))&&(a=execute_derived(i)),old_values.set(i,a),a}var l=(i.f&CONNECTED)===0&&!untracking&&active_reaction!==null&&(is_updating_effect||(active_reaction.f&CONNECTED)!==0),u=(i.f&REACTION_RAN)===0;is_dirty(i)&&(l&&(i.f|=CONNECTED),update_derived(i)),l&&!u&&(unfreeze_derived_effects(i),reconnect(i))}if(batch_values!=null&&batch_values.has(e))return batch_values.get(e);if((e.f&ERROR_VALUE)!==0)throw e.v;return e.v}function reconnect(e){if(e.f|=CONNECTED,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&DERIVED)!==0&&(t.f&CONNECTED)===0&&(unfreeze_derived_effects(t),reconnect(t))}function depends_on_old_values(e){if(e.v===UNINITIALIZED)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(old_values.has(t)||(t.f&DERIVED)!==0&&depends_on_old_values(t))return!0;return!1}function untrack(e){var t=untracking;try{return untracking=!0,e()}finally{untracking=t}}const PASSIVE_EVENTS=["touchstart","touchmove"];function is_passive_event(e){return PASSIVE_EVENTS.includes(e)}const event_symbol=Symbol("events"),all_registered_events=new Set,root_event_handles=new Set;function create_event(e,t,n,r={}){function o(s){if(r.capture||handle_event_propagation.call(t,s),!s.cancelBubble)return without_reactive_context(()=>n==null?void 0:n.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?queue_micro_task(()=>{t.addEventListener(e,o,r)}):t.addEventListener(e,o,r),o}function event(e,t,n,r,o){var s={capture:r,passive:o},i=create_event(e,t,n,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&teardown(()=>{t.removeEventListener(e,i,s)})}function delegated(e,t,n){(t[event_symbol]??(t[event_symbol]={}))[e]=n}function delegate(e){for(var t=0;t<e.length;t++)all_registered_events.add(e[t]);for(var n of root_event_handles)n(e)}let last_propagated_event=null;function handle_event_propagation(e){var h,f;var t=this,n=t.ownerDocument,r=e.type,o=((h=e.composedPath)==null?void 0:h.call(e))||[],s=o[0]||e.target;last_propagated_event=e;var i=0,a=last_propagated_event===e&&e.__root;if(a){var l=o.indexOf(a);if(l!==-1&&(t===document||t===window)){e.__root=t;return}var u=o.indexOf(t);if(u===-1)return;l<=u&&(i=l)}if(s=o[i]||e.target,s!==t){define_property(e,"currentTarget",{configurable:!0,get(){return s||n}});var c=active_reaction,d=active_effect;set_active_reaction(null),set_active_effect(null);try{for(var p,g=[];s!==null;){var _=s.assignedSlot||s.parentNode||s.host||null;try{var y=(f=s[event_symbol])==null?void 0:f[r];y!=null&&(!s.disabled||e.target===s)&&y.call(s,e)}catch(b){p?g.push(b):p=b}if(e.cancelBubble||_===t||_===null)break;s=_}if(p){for(let b of g)queueMicrotask(()=>{throw b});throw p}}finally{e.__root=t,delete e.currentTarget,set_active_reaction(c),set_active_effect(d)}}}const policy=(er=(Qn=globalThis==null?void 0:globalThis.window)==null?void 0:Qn.trustedTypes)==null?void 0:er.createPolicy("svelte-trusted-html",{createHTML:e=>e});function create_trusted_html(e){return(policy==null?void 0:policy.createHTML(e))??e}function create_fragment_from_html(e,t=!1){var n=create_element("template");return e=e.replaceAll("<!>","<!---->"),n.innerHTML=t?create_trusted_html(e):e,n.content}function assign_nodes(e,t){var n=active_effect;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function from_html(e,t){var n=(t&TEMPLATE_FRAGMENT)!==0,r=(t&TEMPLATE_USE_IMPORT_NODE)!==0,o,s=!e.startsWith("<!>");return()=>{if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;o===void 0&&(o=create_fragment_from_html(s?e:"<!>"+e,!0),n||(o=get_first_child(o)));var i=r||is_firefox?document.importNode(o,!0):o.cloneNode(!0);if(n){var a=get_first_child(i),l=i.lastChild;assign_nodes(a,l)}else assign_nodes(i,i);return i}}function from_namespace(e,t,n="svg"){var r=!e.startsWith("<!>"),o=(t&TEMPLATE_FRAGMENT)!==0,s=`<${n}>${r?e:"<!>"+e}</${n}>`,i;return()=>{if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;if(!i){var a=create_fragment_from_html(s,!0),l=get_first_child(a);if(o)for(i=document.createDocumentFragment();get_first_child(l);)i.appendChild(get_first_child(l));else i=get_first_child(l)}var u=i.cloneNode(!0);if(o){var c=get_first_child(u),d=u.lastChild;assign_nodes(c,d)}else assign_nodes(u,u);return u}}function from_svg(e,t){return from_namespace(e,t,"svg")}function text(e=""){if(!hydrating){var t=create_text(e+"");return assign_nodes(t,t),t}var n=hydrate_node;return n.nodeType!==TEXT_NODE?(n.before(n=create_text()),set_hydrate_node(n)):merge_text_nodes(n),assign_nodes(n,n),n}function comment(){if(hydrating)return assign_nodes(hydrate_node,null),hydrate_node;var e=document.createDocumentFragment(),t=document.createComment(""),n=create_text();return e.append(t,n),assign_nodes(t,n),e}function append(e,t){if(hydrating){var n=active_effect;((n.f&REACTION_RAN)===0||n.nodes.end===null)&&(n.nodes.end=hydrate_node),hydrate_next();return}e!==null&&e.before(t)}let should_intro=!0;function set_text(e,t){var n=t==null?"":typeof t=="object"?t+"":t;n!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=n,e.nodeValue=n+"")}function mount(e,t){return _mount(e,t)}function hydrate(e,t){init_operations(),t.intro=t.intro??!1;const n=t.target,r=hydrating,o=hydrate_node;try{for(var s=get_first_child(n);s&&(s.nodeType!==COMMENT_NODE||s.data!==HYDRATION_START);)s=get_next_sibling(s);if(!s)throw HYDRATION_ERROR;set_hydrating(!0),set_hydrate_node(s);const i=_mount(e,{...t,anchor:s});return set_hydrating(!1),i}catch(i){if(i instanceof Error&&i.message.split(`
2
+ `).some(a=>a.startsWith("https://svelte.dev/e/")))throw i;return i!==HYDRATION_ERROR&&console.warn("Failed to hydrate: ",i),t.recover===!1&&hydration_failed(),init_operations(),clear_text_content(n),set_hydrating(!1),mount(e,t)}finally{set_hydrating(r),set_hydrate_node(o)}}const listeners=new Map;function _mount(e,{target:t,anchor:n,props:r={},events:o,context:s,intro:i=!0}){init_operations();var a=new Set,l=d=>{for(var p=0;p<d.length;p++){var g=d[p];if(!a.has(g)){a.add(g);var _=is_passive_event(g);for(const f of[t,document]){var y=listeners.get(f);y===void 0&&(y=new Map,listeners.set(f,y));var h=y.get(g);h===void 0?(f.addEventListener(g,handle_event_propagation,{passive:_}),y.set(g,1)):y.set(g,h+1)}}}};l(array_from(all_registered_events)),root_event_handles.add(l);var u=void 0,c=component_root(()=>{var d=n??t.appendChild(create_text());return boundary(d,{pending:()=>{}},p=>{push({});var g=component_context;if(s&&(g.c=s),o&&(r.$$events=o),hydrating&&assign_nodes(p,null),should_intro=i,u=e(p,r)||{},should_intro=!0,hydrating&&(active_effect.nodes.end=hydrate_node,hydrate_node===null||hydrate_node.nodeType!==COMMENT_NODE||hydrate_node.data!==HYDRATION_END))throw hydration_mismatch(),HYDRATION_ERROR;pop()}),()=>{var y;for(var p of a)for(const h of[t,document]){var g=listeners.get(h),_=g.get(p);--_==0?(h.removeEventListener(p,handle_event_propagation),g.delete(p),g.size===0&&listeners.delete(h)):g.set(p,_)}root_event_handles.delete(l),d!==n&&((y=d.parentNode)==null||y.removeChild(d))}});return mounted_components.set(u,c),u}let mounted_components=new WeakMap;function unmount(e,t){const n=mounted_components.get(e);return n?(mounted_components.delete(e),n(t)):Promise.resolve()}class BranchManager{constructor(t,n=!0){te(this,"anchor");ue(this,dt,new Map);ue(this,kt,new Map);ue(this,nt,new Map);ue(this,Xt,new Set);ue(this,mn,!0);ue(this,bn,()=>{var t=current_batch;if(E(this,dt).has(t)){var n=E(this,dt).get(t),r=E(this,kt).get(n);if(r)resume_effect(r),E(this,Xt).delete(n);else{var o=E(this,nt).get(n);o&&(E(this,kt).set(n,o.effect),E(this,nt).delete(n),o.fragment.lastChild.remove(),this.anchor.before(o.fragment),r=o.effect)}for(const[s,i]of E(this,dt)){if(E(this,dt).delete(s),s===t)break;const a=E(this,nt).get(i);a&&(destroy_effect(a.effect),E(this,nt).delete(i))}for(const[s,i]of E(this,kt)){if(s===n||E(this,Xt).has(s))continue;const a=()=>{if(Array.from(E(this,dt).values()).includes(s)){var u=document.createDocumentFragment();move_effect(i,u),u.append(create_text()),E(this,nt).set(s,{effect:i,fragment:u})}else destroy_effect(i);E(this,Xt).delete(s),E(this,kt).delete(s)};E(this,mn)||!r?(E(this,Xt).add(s),pause_effect(i,a,!1)):a()}}});ue(this,Cn,t=>{E(this,dt).delete(t);const n=Array.from(E(this,dt).values());for(const[r,o]of E(this,nt))n.includes(r)||(destroy_effect(o.effect),E(this,nt).delete(r))});this.anchor=t,ae(this,mn,n)}ensure(t,n){var r=current_batch,o=should_defer_append();if(n&&!E(this,kt).has(t)&&!E(this,nt).has(t))if(o){var s=document.createDocumentFragment(),i=create_text();s.append(i),E(this,nt).set(t,{effect:branch(()=>n(i)),fragment:s})}else E(this,kt).set(t,branch(()=>n(this.anchor)));if(E(this,dt).set(r,t),o){for(const[a,l]of E(this,kt))a===t?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of E(this,nt))a===t?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(E(this,bn)),r.ondiscard(E(this,Cn))}else hydrating&&(this.anchor=hydrate_node),E(this,bn).call(this)}}dt=new WeakMap,kt=new WeakMap,nt=new WeakMap,Xt=new WeakMap,mn=new WeakMap,bn=new WeakMap,Cn=new WeakMap;function onMount(e){component_context===null&&lifecycle_outside_component(),user_effect(()=>{const t=untrack(e);if(typeof t=="function")return t})}function onDestroy(e){component_context===null&&lifecycle_outside_component(),onMount(()=>()=>untrack(e))}function if_block(e,t,n=!1){hydrating&&hydrate_next();var r=new BranchManager(e),o=n?EFFECT_TRANSPARENT:0;function s(i,a){if(hydrating){const c=read_hydration_instruction(e);var l;if(c===HYDRATION_START?l=0:c===HYDRATION_START_ELSE?l=!1:l=parseInt(c.substring(1)),i!==l){var u=skip_nodes();set_hydrate_node(u),r.anchor=u,set_hydrating(!1),r.ensure(i,a),set_hydrating(!0);return}}r.ensure(i,a)}block(()=>{var i=!1;t((a,l=0)=>{i=!0,s(l,a)}),i||s(!1,null)},o)}const NAN=Symbol("NaN");function key(e,t,n){hydrating&&hydrate_next();var r=new BranchManager(e);block(()=>{var o=t();o!==o&&(o=NAN),r.ensure(o,n)})}function index(e,t){return t}function pause_effects(e,t,n){for(var r=[],o=t.length,s,i=t.length,a=0;a<o;a++){let d=t[a];pause_effect(d,()=>{if(s){if(s.pending.delete(d),s.done.add(d),s.pending.size===0){var p=e.outrogroups;destroy_effects(array_from(s.done)),p.delete(s),p.size===0&&(e.outrogroups=null)}}else i-=1},!1)}if(i===0){var l=r.length===0&&n!==null;if(l){var u=n,c=u.parentNode;clear_text_content(c),c.append(u),e.items.clear()}destroy_effects(t,!l)}else s={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(s)}function destroy_effects(e,t=!0){for(var n=0;n<e.length;n++)destroy_effect(e[n],t)}var offscreen_anchor;function each(e,t,n,r,o,s=null){var i=e,a=new Map,l=(t&EACH_IS_CONTROLLED)!==0;if(l){var u=e;i=hydrating?set_hydrate_node(get_first_child(u)):u.appendChild(create_text())}hydrating&&hydrate_next();var c=null,d=derived_safe_equal(()=>{var f=n();return is_array(f)?f:f==null?[]:array_from(f)}),p,g=!0;function _(){h.fallback=c,reconcile(h,p,i,t,r),c!==null&&(p.length===0?(c.f&EFFECT_OFFSCREEN)===0?resume_effect(c):(c.f^=EFFECT_OFFSCREEN,move(c,null,i)):pause_effect(c,()=>{c=null}))}var y=block(()=>{p=get(d);var f=p.length;let b=!1;if(hydrating){var m=read_hydration_instruction(i)===HYDRATION_START_ELSE;m!==(f===0)&&(i=skip_nodes(),set_hydrate_node(i),set_hydrating(!1),b=!0)}for(var x=new Set,S=current_batch,N=should_defer_append(),M=0;M<f;M+=1){hydrating&&hydrate_node.nodeType===COMMENT_NODE&&hydrate_node.data===HYDRATION_END&&(i=hydrate_node,b=!0,set_hydrating(!1));var P=p[M],re=r(P,M),oe=g?null:a.get(re);oe?(oe.v&&internal_set(oe.v,P),oe.i&&internal_set(oe.i,M),N&&S.unskip_effect(oe.e)):(oe=create_item(a,g?i:offscreen_anchor??(offscreen_anchor=create_text()),P,re,M,o,t,n),g||(oe.e.f|=EFFECT_OFFSCREEN),a.set(re,oe)),x.add(re)}if(f===0&&s&&!c&&(g?c=branch(()=>s(i)):(c=branch(()=>s(offscreen_anchor??(offscreen_anchor=create_text()))),c.f|=EFFECT_OFFSCREEN)),f>x.size&&each_key_duplicate(),hydrating&&f>0&&set_hydrate_node(skip_nodes()),!g)if(N){for(const[ne,ce]of a)x.has(ne)||S.skip_effect(ce.e);S.oncommit(_),S.ondiscard(()=>{})}else _();b&&set_hydrating(!0),get(d)}),h={effect:y,items:a,outrogroups:null,fallback:c};g=!1,hydrating&&(i=hydrate_node)}function skip_to_branch(e){for(;e!==null&&(e.f&BRANCH_EFFECT)===0;)e=e.next;return e}function reconcile(e,t,n,r,o){var oe,ne,ce,_e,ge,$e,be,ye,de;var s=(r&EACH_IS_ANIMATED)!==0,i=t.length,a=e.items,l=skip_to_branch(e.effect.first),u,c=null,d,p=[],g=[],_,y,h,f;if(s)for(f=0;f<i;f+=1)_=t[f],y=o(_,f),h=a.get(y).e,(h.f&EFFECT_OFFSCREEN)===0&&((ne=(oe=h.nodes)==null?void 0:oe.a)==null||ne.measure(),(d??(d=new Set)).add(h));for(f=0;f<i;f+=1){if(_=t[f],y=o(_,f),h=a.get(y).e,e.outrogroups!==null)for(const v of e.outrogroups)v.pending.delete(h),v.done.delete(h);if((h.f&EFFECT_OFFSCREEN)!==0)if(h.f^=EFFECT_OFFSCREEN,h===l)move(h,null,n);else{var b=c?c.next:l;h===e.effect.last&&(e.effect.last=h.prev),h.prev&&(h.prev.next=h.next),h.next&&(h.next.prev=h.prev),link(e,c,h),link(e,h,b),move(h,b,n),c=h,p=[],g=[],l=skip_to_branch(c.next);continue}if((h.f&INERT)!==0&&(resume_effect(h),s&&((_e=(ce=h.nodes)==null?void 0:ce.a)==null||_e.unfix(),(d??(d=new Set)).delete(h))),h!==l){if(u!==void 0&&u.has(h)){if(p.length<g.length){var m=g[0],x;c=m.prev;var S=p[0],N=p[p.length-1];for(x=0;x<p.length;x+=1)move(p[x],m,n);for(x=0;x<g.length;x+=1)u.delete(g[x]);link(e,S.prev,N.next),link(e,c,S),link(e,N,m),l=m,c=N,f-=1,p=[],g=[]}else u.delete(h),move(h,l,n),link(e,h.prev,h.next),link(e,h,c===null?e.effect.first:c.next),link(e,c,h),c=h;continue}for(p=[],g=[];l!==null&&l!==h;)(u??(u=new Set)).add(l),g.push(l),l=skip_to_branch(l.next);if(l===null)continue}(h.f&EFFECT_OFFSCREEN)===0&&p.push(h),c=h,l=skip_to_branch(h.next)}if(e.outrogroups!==null){for(const v of e.outrogroups)v.pending.size===0&&(destroy_effects(array_from(v.done)),(ge=e.outrogroups)==null||ge.delete(v));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var M=[];if(u!==void 0)for(h of u)(h.f&INERT)===0&&M.push(h);for(;l!==null;)(l.f&INERT)===0&&l!==e.fallback&&M.push(l),l=skip_to_branch(l.next);var P=M.length;if(P>0){var re=(r&EACH_IS_CONTROLLED)!==0&&i===0?n:null;if(s){for(f=0;f<P;f+=1)(be=($e=M[f].nodes)==null?void 0:$e.a)==null||be.measure();for(f=0;f<P;f+=1)(de=(ye=M[f].nodes)==null?void 0:ye.a)==null||de.fix()}pause_effects(e,M,re)}}s&&queue_micro_task(()=>{var v,w;if(d!==void 0)for(h of d)(w=(v=h.nodes)==null?void 0:v.a)==null||w.apply()})}function create_item(e,t,n,r,o,s,i,a){var l=(i&EACH_ITEM_REACTIVE)!==0?(i&EACH_ITEM_IMMUTABLE)===0?mutable_source(n,!1,!1):source(n):null,u=(i&EACH_INDEX_REACTIVE)!==0?source(o):null;return{v:l,i:u,e:branch(()=>(s(t,l??n,u??o,a),()=>{e.delete(r)}))}}function move(e,t,n){if(e.nodes)for(var r=e.nodes.start,o=e.nodes.end,s=t&&(t.f&EFFECT_OFFSCREEN)===0?t.nodes.start:n;r!==null;){var i=get_next_sibling(r);if(s.before(r),r===o)return;r=i}}function link(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function html(e,t,n=!1,r=!1,o=!1){var s=e,i="";template_effect(()=>{var a=active_effect;if(i===(i=t()??"")){hydrating&&hydrate_next();return}if(a.nodes!==null&&(remove_effect_dom(a.nodes.start,a.nodes.end),a.nodes=null),i!==""){if(hydrating){hydrate_node.data;for(var l=hydrate_next(),u=l;l!==null&&(l.nodeType!==COMMENT_NODE||l.data!=="");)u=l,l=get_next_sibling(l);if(l===null)throw hydration_mismatch(),HYDRATION_ERROR;assign_nodes(hydrate_node,u),s=set_hydrate_node(l);return}var c=i+"";n?c=`<svg>${c}</svg>`:r&&(c=`<math>${c}</math>`);var d=create_fragment_from_html(c);if((n||r)&&(d=get_first_child(d)),assign_nodes(get_first_child(d),d.lastChild),n||r)for(;get_first_child(d);)s.before(get_first_child(d));else s.before(d)}})}const now=()=>performance.now(),raf={tick:e=>requestAnimationFrame(e),now:()=>now(),tasks:new Set};function run_tasks(){const e=raf.now();raf.tasks.forEach(t=>{t.c(e)||(raf.tasks.delete(t),t.f())}),raf.tasks.size!==0&&raf.tick(run_tasks)}function loop(e){let t;return raf.tasks.size===0&&raf.tick(run_tasks),{promise:new Promise(n=>{raf.tasks.add(t={c:e,f:n})}),abort(){raf.tasks.delete(t)}}}function dispatch_event(e,t){without_reactive_context(()=>{e.dispatchEvent(new CustomEvent(t))})}function css_property_to_camelcase(e){if(e==="float")return"cssFloat";if(e==="offset")return"cssOffset";if(e.startsWith("--"))return e;const t=e.split("-");return t.length===1?t[0]:t[0]+t.slice(1).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function css_to_keyframe(e){const t={},n=e.split(";");for(const r of n){const[o,s]=r.split(":");if(!o||s===void 0)break;const i=css_property_to_camelcase(o.trim());t[i]=s.trim()}return t}const linear=e=>e;function transition(e,t,n,r){var h;var o=(e&TRANSITION_GLOBAL)!==0,s="both",i,a=t.inert,l=t.style.overflow,u,c;function d(){return without_reactive_context(()=>i??(i=n()(t,(r==null?void 0:r())??{},{direction:s})))}var p={is_global:o,in(){t.inert=a,u=animate(t,d(),c,1,()=>{dispatch_event(t,"introend"),u==null||u.abort(),u=i=void 0,t.style.overflow=l})},out(f){t.inert=!0,c=animate(t,d(),u,0,()=>{dispatch_event(t,"outroend"),f==null||f()})},stop:()=>{u==null||u.abort(),c==null||c.abort()}},g=active_effect;if(((h=g.nodes).t??(h.t=[])).push(p),should_intro){var _=o;if(!_){for(var y=g.parent;y&&(y.f&EFFECT_TRANSPARENT)!==0;)for(;(y=y.parent)&&(y.f&BLOCK_EFFECT)===0;);_=!y||(y.f&REACTION_RAN)!==0}_&&effect(()=>{untrack(()=>p.in())})}}function animate(e,t,n,r,o){var s=r===1;if(is_function(t)){var i,a=!1;return queue_micro_task(()=>{if(!a){var h=t({direction:s?"in":"out"});i=animate(e,h,n,r,o)}}),{abort:()=>{a=!0,i==null||i.abort()},deactivate:()=>i.deactivate(),reset:()=>i.reset(),t:()=>i.t()}}if(n==null||n.deactivate(),!(t!=null&&t.duration)&&!(t!=null&&t.delay))return dispatch_event(e,s?"introstart":"outrostart"),o(),{abort:noop,deactivate:noop,reset:noop,t:()=>r};const{delay:l=0,css:u,tick:c,easing:d=linear}=t;var p=[];if(s&&n===void 0&&(c&&c(0,1),u)){var g=css_to_keyframe(u(0,1));p.push(g,g)}var _=()=>1-r,y=e.animate(p,{duration:l,fill:"forwards"});return y.onfinish=()=>{y.cancel(),dispatch_event(e,s?"introstart":"outrostart");var h=(n==null?void 0:n.t())??1-r;n==null||n.abort();var f=r-h,b=t.duration*Math.abs(f),m=[];if(b>0){var x=!1;if(u)for(var S=Math.ceil(b/16.666666666666668),N=0;N<=S;N+=1){var M=h+f*d(N/S),P=css_to_keyframe(u(M,1-M));m.push(P),x||(x=P.overflow==="hidden")}x&&(e.style.overflow="hidden"),_=()=>{var re=y.currentTime;return h+f*d(re/b)},c&&loop(()=>{if(y.playState!=="running")return!1;var re=_();return c(re,1-re),!0})}y=e.animate(m,{duration:b,fill:"forwards"}),y.onfinish=()=>{_=()=>r,c==null||c(r,1-r),o()}},{abort:()=>{y&&(y.cancel(),y.effect=null,y.onfinish=noop)},deactivate:()=>{o=noop},reset:()=>{r===0&&(c==null||c(1,0))},t:()=>_()}}function append_styles(e,t){effect(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+t.hash)){const o=create_element("style");o.id=t.hash,o.textContent=t.code,r.appendChild(o)}})}const whitespace=[...`
3
+ \r\f \v\uFEFF`];function to_class(e,t,n){var r=e==null?"":""+e;if(t&&(r=r?r+" "+t:t),n){for(var o in n)if(n[o])r=r?r+" "+o:o;else if(r.length)for(var s=o.length,i=0;(i=r.indexOf(o,i))>=0;){var a=i+s;(i===0||whitespace.includes(r[i-1]))&&(a===r.length||whitespace.includes(r[a]))?r=(i===0?"":r.substring(0,i))+r.substring(a+1):i=a}}return r===""?null:r}function to_style(e,t){return e==null?null:String(e)}function set_class(e,t,n,r,o,s){var i=e.__className;if(hydrating||i!==n||i===void 0){var a=to_class(n,r,s);(!hydrating||a!==e.getAttribute("class"))&&(a==null?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a)),e.__className=n}else if(s&&o!==s)for(var l in s){var u=!!s[l];(o==null||u!==!!o[l])&&e.classList.toggle(l,u)}return s}function set_style(e,t,n,r){var o=e.__style;if(hydrating||o!==t){var s=to_style(t);(!hydrating||s!==e.getAttribute("style"))&&(s==null?e.removeAttribute("style"):e.style.cssText=s),e.__style=t}return r}function select_option(e,t,n=!1){if(e.multiple){if(t==null)return;if(!is_array(t))return select_multiple_invalid_value();for(var r of e.options)r.selected=t.includes(get_option_value(r));return}for(r of e.options){var o=get_option_value(r);if(is(o,t)){r.selected=!0;return}}(!n||t!==void 0)&&(e.selectedIndex=-1)}function init_select(e){var t=new MutationObserver(()=>{select_option(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),teardown(()=>{t.disconnect()})}function bind_select_value(e,t,n=t){var r=new WeakSet,o=!0;listen_to_event_and_reset_event(e,"change",s=>{var i=s?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),get_option_value);else{var l=e.querySelector(i)??e.querySelector("option:not([disabled])");a=l&&get_option_value(l)}n(a),current_batch!==null&&r.add(current_batch)}),effect(()=>{var s=t();if(e===document.activeElement){var i=previous_batch??current_batch;if(r.has(i))return}if(select_option(e,s,o),o&&s===void 0){var a=e.querySelector(":checked");a!==null&&(s=get_option_value(a),n(s))}e.__value=s,o=!1}),init_select(e)}function get_option_value(e){return"__value"in e?e.__value:e.value}const IS_CUSTOM_ELEMENT=Symbol("is custom element"),IS_HTML=Symbol("is html"),LINK_TAG=IS_XHTML?"link":"LINK";function remove_input_defaults(e){if(hydrating){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute("value")){var r=e.value;set_attribute(e,"value",null),e.value=r}if(e.hasAttribute("checked")){var o=e.checked;set_attribute(e,"checked",null),e.checked=o}}};e.__on_r=n,queue_micro_task(n),add_form_reset_listener()}}function set_checked(e,t){var n=get_attributes(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function set_attribute(e,t,n,r){var o=get_attributes(e);hydrating&&(o[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName===LINK_TAG)||o[t]!==(o[t]=n)&&(t==="loading"&&(e[LOADING_ATTR_SYMBOL]=n),n==null?e.removeAttribute(t):typeof n!="string"&&get_setters(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function get_attributes(e){return e.__attributes??(e.__attributes={[IS_CUSTOM_ELEMENT]:e.nodeName.includes("-"),[IS_HTML]:e.namespaceURI===NAMESPACE_HTML})}var setters_cache=new Map;function get_setters(e){var t=e.getAttribute("is")||e.nodeName,n=setters_cache.get(t);if(n)return n;setters_cache.set(t,n=[]);for(var r,o=e,s=Element.prototype;s!==o;){r=get_descriptors(o);for(var i in r)r[i].set&&n.push(i);o=get_prototype_of(o)}return n}function bind_value(e,t,n=t){var r=new WeakSet;listen_to_event_and_reset_event(e,"input",async o=>{var s=o?e.defaultValue:e.value;if(s=is_numberlike_input(e)?to_number(s):s,n(s),current_batch!==null&&r.add(current_batch),await tick(),s!==(s=t())){var i=e.selectionStart,a=e.selectionEnd,l=e.value.length;if(e.value=s??"",a!==null){var u=e.value.length;i===a&&a===l&&u>l?(e.selectionStart=u,e.selectionEnd=u):(e.selectionStart=i,e.selectionEnd=Math.min(a,u))}}}),(hydrating&&e.defaultValue!==e.value||untrack(t)==null&&e.value)&&(n(is_numberlike_input(e)?to_number(e.value):e.value),current_batch!==null&&r.add(current_batch)),render_effect(()=>{var o=t();if(e===document.activeElement){var s=previous_batch??current_batch;if(r.has(s))return}is_numberlike_input(e)&&o===to_number(e.value)||e.type==="date"&&!o&&!e.value||o!==e.value&&(e.value=o??"")})}function is_numberlike_input(e){var t=e.type;return t==="number"||t==="range"}function to_number(e){return e===""?null:+e}function is_bound_this(e,t){return e===t||(e==null?void 0:e[STATE_SYMBOL])===t}function bind_this(e={},t,n,r){return effect(()=>{var o,s;return render_effect(()=>{o=s,s=[],untrack(()=>{e!==n(...s)&&(t(e,...s),o&&is_bound_this(n(...o),e)&&t(null,...o))})}),()=>{queue_micro_task(()=>{s&&is_bound_this(n(...s),e)&&t(null,...s)})}}),e}let is_store_binding=!1;function capture_store_binding(e){var t=is_store_binding;try{return is_store_binding=!1,[e(),is_store_binding]}finally{is_store_binding=t}}function prop(e,t,n,r){var b;var o=(n&PROPS_IS_BINDABLE)!==0,s=(n&PROPS_IS_LAZY_INITIAL)!==0,i=r,a=!0,l=()=>(a&&(a=!1,i=s?untrack(r):r),i),u;if(o){var c=STATE_SYMBOL in e||LEGACY_PROPS in e;u=((b=get_descriptor(e,t))==null?void 0:b.set)??(c&&t in e?m=>e[t]=m:void 0)}var d,p=!1;o?[d,p]=capture_store_binding(()=>e[t]):d=e[t],d===void 0&&r!==void 0&&(d=l(),u&&(props_invalid_value(),u(d)));var g;if(g=()=>{var m=e[t];return m===void 0?l():(a=!0,m)},(n&PROPS_IS_UPDATED)===0)return g;if(u){var _=e.$$legacy;return(function(m,x){return arguments.length>0?((!x||_||p)&&u(x?g():m),m):g()})}var y=!1,h=((n&PROPS_IS_IMMUTABLE)!==0?derived:derived_safe_equal)(()=>(y=!1,g()));o&&get(h);var f=active_effect;return(function(m,x){if(arguments.length>0){const S=x?get(h):o?proxy(m):m;return set(h,S),y=!0,i!==void 0&&(i=S),m}return is_destroying_effect&&y||(f.f&DESTROYED)!==0?h.v:get(h)})}function createClassComponent(e){return new Svelte4Component(e)}class Svelte4Component{constructor(t){ue(this,Pt);ue(this,at);var s;var n=new Map,r=(i,a)=>{var l=mutable_source(a,!1,!1);return n.set(i,l),l};const o=new Proxy({...t.props||{},$$events:{}},{get(i,a){return get(n.get(a)??r(a,Reflect.get(i,a)))},has(i,a){return a===LEGACY_PROPS?!0:(get(n.get(a)??r(a,Reflect.get(i,a))),Reflect.has(i,a))},set(i,a,l){return set(n.get(a)??r(a,l),l),Reflect.set(i,a,l)}});ae(this,at,(t.hydrate?hydrate:mount)(t.component,{target:t.target,anchor:t.anchor,props:o,context:t.context,intro:t.intro??!1,recover:t.recover})),(!((s=t==null?void 0:t.props)!=null&&s.$$host)||t.sync===!1)&&flushSync(),ae(this,Pt,o.$$events);for(const i of Object.keys(E(this,at)))i==="$set"||i==="$destroy"||i==="$on"||define_property(this,i,{get(){return E(this,at)[i]},set(a){E(this,at)[i]=a},enumerable:!0});E(this,at).$set=i=>{Object.assign(o,i)},E(this,at).$destroy=()=>{unmount(E(this,at))}}$set(t){E(this,at).$set(t)}$on(t,n){E(this,Pt)[t]=E(this,Pt)[t]||[];const r=(...o)=>n.call(this,...o);return E(this,Pt)[t].push(r),()=>{E(this,Pt)[t]=E(this,Pt)[t].filter(o=>o!==r)}}$destroy(){E(this,at).$destroy()}}Pt=new WeakMap,at=new WeakMap;let SvelteElement;typeof HTMLElement=="function"&&(SvelteElement=class extends HTMLElement{constructor(t,n,r){super();te(this,"$$ctor");te(this,"$$s");te(this,"$$c");te(this,"$$cn",!1);te(this,"$$d",{});te(this,"$$r",!1);te(this,"$$p_d",{});te(this,"$$l",{});te(this,"$$l_u",new Map);te(this,"$$me");te(this,"$$shadowRoot",null);this.$$ctor=t,this.$$s=n,r&&(this.$$shadowRoot=this.attachShadow(r))}addEventListener(t,n,r){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(n),this.$$c){const o=this.$$c.$on(t,n);this.$$l_u.set(n,o)}super.addEventListener(t,n,r)}removeEventListener(t,n,r){if(super.removeEventListener(t,n,r),this.$$c){const o=this.$$l_u.get(n);o&&(o(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let t=function(o){return s=>{const i=create_element("slot");o!=="default"&&(i.name=o),append(s,i)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},r=get_custom_elements_slots(this);for(const o of this.$$s)o in r&&(o==="default"&&!this.$$d.children?(this.$$d.children=t(o),n.default=!0):n[o]=t(o));for(const o of this.attributes){const s=this.$$g_p(o.name);s in this.$$d||(this.$$d[s]=get_custom_element_value(s,o.value,this.$$p_d,"toProp"))}for(const o in this.$$p_d)!(o in this.$$d)&&this[o]!==void 0&&(this.$$d[o]=this[o],delete this[o]);this.$$c=createClassComponent({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:n,$$host:this}}),this.$$me=effect_root(()=>{render_effect(()=>{var o;this.$$r=!0;for(const s of object_keys(this.$$c)){if(!((o=this.$$p_d[s])!=null&&o.reflect))continue;this.$$d[s]=this.$$c[s];const i=get_custom_element_value(s,this.$$d[s],this.$$p_d,"toAttribute");i==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,i)}this.$$r=!1})});for(const o in this.$$l)for(const s of this.$$l[o]){const i=this.$$c.$on(o,s);this.$$l_u.set(s,i)}this.$$l={}}}attributeChangedCallback(t,n,r){var o;this.$$r||(t=this.$$g_p(t),this.$$d[t]=get_custom_element_value(t,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[t]:this.$$d[t]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(t){return object_keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===t||!this.$$p_d[n].attribute&&n.toLowerCase()===t)||t}});function get_custom_element_value(e,t,n,r){var s;const o=(s=n[e])==null?void 0:s.type;if(t=o==="Boolean"&&typeof t!="boolean"?t!=null:t,!r||!n[e])return t;if(r==="toAttribute")switch(o){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(o){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function get_custom_elements_slots(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function create_custom_element(e,t,n,r,o,s){let i=class extends SvelteElement{constructor(){super(e,n,o),this.$$p_d=t}static get observedAttributes(){return object_keys(t).map(a=>(t[a].attribute||a).toLowerCase())}};return object_keys(t).forEach(a=>{define_property(i.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(l){var d;l=get_custom_element_value(a,l,t),this.$$d[a]=l;var u=this.$$c;if(u){var c=(d=get_descriptor(u,a))==null?void 0:d.get;c?u[a]=l:u.$set({[a]:l})}}})}),r.forEach(a=>{define_property(i.prototype,a,{get(){var l;return(l=this.$$c)==null?void 0:l[a]}})}),e.element=i,i}const DEFAULT_CONFIG={endpoint:"",position:"bottom-right",theme:"dark",buttonColor:"#3b82f6",maxScreenshots:5,maxConsoleLogs:50,captureConsole:!0},SENSITIVE_PATTERNS=[/\b(api[_-]?key|apikey|api[_-]?token|access[_-]?token|auth[_-]?token|bearer)\s*[:=]\s*["']?[\w\-\.]+["']?/gi,/\bBearer\s+[\w\-\.]+/gi,/\b(sk|pk|rk)[_-][a-zA-Z0-9]{20,}/gi,/\bghp_[a-zA-Z0-9]{36,}/gi,/\bsk-[a-zA-Z0-9]{20,}/gi,/\b(password|passwd|pwd|secret|credential)\s*[:=]\s*["']?[^"'\s,}{]+["']?/gi,/\beyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/gi,/\b\d{4}[\s\-]?\d{4}[\s\-]?\d{4}[\s\-]?\d{4}\b/g,/\b(email|e-mail)\s*[:=]\s*["']?[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}["']?/gi,/-----BEGIN\s+(RSA\s+)?PRIVATE\s+KEY-----[\s\S]*?-----END\s+(RSA\s+)?PRIVATE\s+KEY-----/gi,/\b(AKIA|ABIA|ACCA|AGPA|AIDA|AIPA|AKIA|ANPA|ANVA|AROA|APKA|ASCA|ASIA)[A-Z0-9]{16}\b/g,/\b(aws[_-]?secret[_-]?access[_-]?key|aws[_-]?access[_-]?key[_-]?id)\s*[:=]\s*["']?[\w\/\+]+["']?/gi],REDACTED="[REDACTED]";function filterSensitiveData(e){let t=e;for(const n of SENSITIVE_PATTERNS)n.lastIndex=0,t=t.replace(n,REDACTED);return t}let maxEntries=50;const capturedLogs=[];let capturing=!1;const originalConsole={log:console.log,error:console.error,warn:console.warn,info:console.info,debug:console.debug,trace:console.trace};function safeStringify(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(e instanceof Error)return`${e.name}: ${e.message}${e.stack?`
4
4
  `+e.stack:""}`;if(typeof e=="object")try{const t=new WeakSet;return JSON.stringify(e,(n,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return typeof r=="function"?`[Function: ${r.name||"anonymous"}]`:r instanceof Error?`${r.name}: ${r.message}`:r},2)}catch{return"[Object - stringify failed]"}return String(e)}function captureStackInfo(){const e=new Error().stack;if(!e)return{};const n=e.split(`
5
5
  `).slice(4),r=n.join(`
6
6
  `),s=(n[0]||"").match(/(?:at\s+(?:\S+\s+)?\()?([^()]+):(\d+):(\d+)\)?/);return s?{stackTrace:r,fileName:s[1],lineNumber:parseInt(s[2],10),columnNumber:parseInt(s[3],10)}:{stackTrace:r}}function createLogEntry(e,t,n){const r=new Date,o=filterSensitiveData(t.map(safeStringify).join(" ")),s={type:e,message:o,timestamp:r.toISOString(),timestampMs:r.getTime(),url:window.location.href};return(n||e==="error"||e==="warn"||e==="trace")&&Object.assign(s,captureStackInfo()),s}function addLogEntry(e){for(capturedLogs.push(e);capturedLogs.length>maxEntries;)capturedLogs.shift()}function startConsoleCapture(e){capturing||(capturing=!0,e&&(maxEntries=e),console.log=(...t)=>{originalConsole.log(...t),addLogEntry(createLogEntry("log",t,!1))},console.error=(...t)=>{originalConsole.error(...t),addLogEntry(createLogEntry("error",t,!0))},console.warn=(...t)=>{originalConsole.warn(...t),addLogEntry(createLogEntry("warn",t,!0))},console.info=(...t)=>{originalConsole.info(...t),addLogEntry(createLogEntry("info",t,!1))},console.debug=(...t)=>{originalConsole.debug(...t),addLogEntry(createLogEntry("debug",t,!1))},console.trace=(...t)=>{originalConsole.trace(...t),addLogEntry(createLogEntry("trace",t,!0))})}function stopConsoleCapture(){capturing&&(capturing=!1,console.log=originalConsole.log,console.error=originalConsole.error,console.warn=originalConsole.warn,console.info=originalConsole.info,console.debug=originalConsole.debug,console.trace=originalConsole.trace)}function getCapturedLogs(){return[...capturedLogs]}function getXPath(e){var r;if(e.id!=="")return'id("'+e.id+'")';if(e===document.body)return e.tagName;let t=0;const n=((r=e.parentNode)==null?void 0:r.childNodes)||[];for(let o=0;o<n.length;o++){const s=n[o];if(s===e)return getXPath(e.parentElement)+"/"+e.tagName+"["+(t+1)+"]";s.nodeType===1&&s.tagName===e.tagName&&t++}return""}function generateSelector(e){if(e.id)return"#"+CSS.escape(e.id);const t=[];let n=e;for(;n&&n!==document.body&&n!==document.documentElement;){let o=n.tagName.toLowerCase();if(n.id){o="#"+CSS.escape(n.id),t.unshift(o);break}if(n.className&&typeof n.className=="string"){const l=n.className.split(/\s+/).filter(u=>u&&!u.match(/^(ng-|v-|svelte-|css-|_|js-|is-|has-)/)&&!u.match(/^\d/)&&u.length>1);l.length>0&&(o+="."+l.slice(0,2).map(u=>CSS.escape(u)).join("."))}const s=["data-testid","data-id","data-name","name","role","aria-label"];for(const l of s){const u=n.getAttribute(l);if(u){o+=`[${l}="${CSS.escape(u)}"]`;break}}const i=n.parentElement;if(i){const l=Array.from(i.children).filter(u=>u.tagName===n.tagName);if(l.length>1){const u=l.indexOf(n)+1;o+=`:nth-of-type(${u})`}}t.unshift(o);const a=t.join(" > ");try{if(document.querySelectorAll(a).length===1)break}catch{}n=n.parentElement}const r=t.join(" > ");try{if(document.querySelectorAll(r).length===1)return r}catch{}return generateFallbackSelector(e)}function generateFallbackSelector(e){const t=[];let n=e;for(;n&&n!==document.body;){const r=n.parentElement;if(r){const o=Array.from(r.children).indexOf(n)+1;t.unshift(`*:nth-child(${o})`),n=r}else break}return"body > "+t.join(" > ")}let isActive=!1,originalCursor="",overlay=null,tooltip=null,onSelect=null;function createOverlay(){const e=document.createElement("div");return e.id="jat-feedback-picker-overlay",e.style.cssText=`
@@ -35,17 +35,17 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
35
35
  -webkit-background-clip: text;
36
36
  }
37
37
  `);return t.appendChild(n),t}function resolveBoundingBox(e,t){let{width:n,height:r}=t;if(isElementNode(e)&&(!n||!r)){const o=e.getBoundingClientRect();n=n||o.width||Number(e.getAttribute("width"))||0,r=r||o.height||Number(e.getAttribute("height"))||0}return{width:n,height:r}}async function imageToCanvas(e,t){const{log:n,timeout:r,drawImageCount:o,drawImageInterval:s}=t;n.time("image to canvas");const i=await loadMedia(e,{timeout:r,onWarn:t.log.warn}),{canvas:a,context2d:l}=createCanvas(e.ownerDocument,t),u=()=>{try{l==null||l.drawImage(i,0,0,a.width,a.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(u(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<o;c++)await new Promise(d=>{setTimeout(()=>{l==null||l.clearRect(0,0,a.width,a.height),u(),d()},c+s)});return t.drawImageCount=0,n.timeEnd("image to canvas"),a}function createCanvas(e,t){const{width:n,height:r,scale:o,backgroundColor:s,maximumCanvasSize:i}=t,a=e.createElement("canvas");a.width=Math.floor(n*o),a.height=Math.floor(r*o),a.style.width=`${n}px`,a.style.height=`${r}px`,i&&(a.width>i||a.height>i)&&(a.width>i&&a.height>i?a.width>a.height?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i):a.width>i?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i));const l=a.getContext("2d");return l&&s&&(l.fillStyle=s,l.fillRect(0,0,a.width,a.height)),{canvas:a,context2d:l}}function cloneCanvas(e,t){if(e.ownerDocument)try{const s=e.toDataURL();if(s!=="data:,")return createImage(s,e.ownerDocument)}catch(s){t.log.warn("Failed to clone canvas",s)}const n=e.cloneNode(!1),r=e.getContext("2d"),o=n.getContext("2d");try{return r&&o&&o.putImageData(r.getImageData(0,0,e.width,e.height),0,0),n}catch(s){t.log.warn("Failed to clone canvas",s)}return n}function cloneIframe(e,t){var n;try{if((n=e==null?void 0:e.contentDocument)!=null&&n.body)return cloneNode(e.contentDocument.body,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(!1)}function cloneImage(e){const t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function cloneVideo(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return createImage(e.poster,e.ownerDocument);const n=e.cloneNode(!1);n.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);const r=n.ownerDocument;if(r){let o=!0;if(await loadMedia(n,{onError:()=>o=!1,onWarn:t.log.warn}),!o)return e.poster?createImage(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(i=>{n.addEventListener("seeked",i,{once:!0})});const s=r.createElement("canvas");s.width=e.offsetWidth,s.height=e.offsetHeight;try{const i=s.getContext("2d");i&&i.drawImage(n,0,0,s.width,s.height)}catch(i){return t.log.warn("Failed to clone video",i),e.poster?createImage(e.poster,e.ownerDocument):n}return cloneCanvas(s,t)}return n}function cloneElement(e,t){return isCanvasElement(e)?cloneCanvas(e,t):isIFrameElement(e)?cloneIframe(e,t):isImageElement(e)?cloneImage(e):isVideoElement(e)?cloneVideo(e,t):e.cloneNode(!1)}function getSandBox(e){let t=e.sandbox;if(!t){const{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${uuid$1()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",n.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(r){e.log.warn("Failed to getSandBox",r)}}return t}const ignoredStyles=["width","height","-webkit-text-fill-color"],includedAttributes=["stroke","fill"];function getDefaultStyle(e,t,n){const{defaultComputedStyles:r}=n,o=e.nodeName.toLowerCase(),s=isSVGElementNode(e)&&o!=="svg",i=s?includedAttributes.map(y=>[y,e.getAttribute(y)]).filter(([,y])=>y!==null):[],a=[s&&"svg",o,i.map((y,h)=>`${y}=${h}`).join(","),t].filter(Boolean).join(":");if(r.has(a))return r.get(a);const l=getSandBox(n),u=l==null?void 0:l.contentWindow;if(!u)return new Map;const c=u==null?void 0:u.document;let d,p;s?(d=c.createElementNS(XMLNS,"svg"),p=d.ownerDocument.createElementNS(d.namespaceURI,o),i.forEach(([y,h])=>{p.setAttributeNS(null,y,h)}),d.appendChild(p)):d=p=c.createElement(o),p.textContent=" ",c.body.appendChild(d);const g=u.getComputedStyle(p,t),_=new Map;for(let y=g.length,h=0;h<y;h++){const f=g.item(h);ignoredStyles.includes(f)||_.set(f,g.getPropertyValue(f))}return c.body.removeChild(d),r.set(a,_),_}function getDiffStyle(e,t,n){var a;const r=new Map,o=[],s=new Map;if(n)for(const l of n)i(l);else for(let l=e.length,u=0;u<l;u++){const c=e.item(u);i(c)}for(let l=o.length,u=0;u<l;u++)(a=s.get(o[u]))==null||a.forEach((c,d)=>r.set(d,c));function i(l){const u=e.getPropertyValue(l),c=e.getPropertyPriority(l),d=l.lastIndexOf("-"),p=d>-1?l.substring(0,d):void 0;if(p){let g=s.get(p);g||(g=new Map,s.set(p,g)),g.set(l,[u,c])}t.get(l)===u&&!c||(p?o.push(p):r.set(l,[u,c]))}return r}function copyCssStyles(e,t,n,r){var d,p,g,_;const{ownerWindow:o,includeStyleProperties:s,currentParentNodeStyle:i}=r,a=t.style,l=o.getComputedStyle(e),u=getDefaultStyle(e,null,r);i==null||i.forEach((y,h)=>{u.delete(h)});const c=getDiffStyle(l,u,s);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),n&&(c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),((d=c.get("background-clip"))==null?void 0:d[0])==="text"&&t.classList.add("______background-clip--text"),IN_CHROME&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(((p=c.get("overflow-x"))==null?void 0:p[0])==="hidden"||((g=c.get("overflow-y"))==null?void 0:g[0])==="hidden")&&((_=c.get("text-overflow"))==null?void 0:_[0])==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let y=a.length,h=0;h<y;h++)a.removeProperty(a.item(h));return c.forEach(([y,h],f)=>{a.setProperty(f,y,h)}),c}function copyInputValue(e,t){(isTextareaElement(e)||isInputElement(e)||isSelectElement(e))&&t.setAttribute("value",e.value)}const pseudoClasses=["::before","::after"],scrollbarPseudoClasses=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function copyPseudoClass(e,t,n,r,o){const{ownerWindow:s,svgStyleElement:i,svgStyles:a,currentNodeStyle:l}=r;if(!i||!s)return;function u(c){var m;const d=s.getComputedStyle(e,c);let p=d.getPropertyValue("content");if(!p||p==="none")return;o==null||o(p),p=p.replace(/(')|(")|(counter\(.+\))/g,"");const g=[uuid$1()],_=getDefaultStyle(e,c,r);l==null||l.forEach((x,S)=>{_.delete(S)});const y=getDiffStyle(d,_,r.includeStyleProperties);y.delete("content"),y.delete("-webkit-locale"),((m=y.get("background-clip"))==null?void 0:m[0])==="text"&&t.classList.add("______background-clip--text");const h=[`content: '${p}';`];if(y.forEach(([x,S],N)=>{h.push(`${N}: ${x}${S?" !important":""};`)}),h.length===1)return;try{t.className=[t.className,...g].join(" ")}catch(x){r.log.warn("Failed to copyPseudoClass",x);return}const f=h.join(`
38
- `);let b=a.get(f);b||(b=[],a.set(f,b)),b.push(`.${g[0]}${c}`)}pseudoClasses.forEach(u),n&&scrollbarPseudoClasses.forEach(u)}const excludeParentNodes=new Set(["symbol"]);async function appendChildNode(e,t,n,r,o){if(isElementNode(n)&&(isStyleElement(n)||isScriptElement(n))||r.filter&&!r.filter(n))return;excludeParentNodes.has(t.nodeName)||excludeParentNodes.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;const s=await cloneNode(n,r,!1,o);r.isEnable("restoreScrollPosition")&&restoreScrollPosition(e,s),t.appendChild(s)}async function cloneChildNodes(e,t,n,r){var s;let o=e.firstChild;isElementNode(e)&&e.shadowRoot&&(o=(s=e.shadowRoot)==null?void 0:s.firstChild,n.shadowRoots.push(e.shadowRoot));for(let i=o;i;i=i.nextSibling)if(!isCommentNode(i))if(isElementNode(i)&&isSlotElement(i)&&typeof i.assignedNodes=="function"){const a=i.assignedNodes();for(let l=0;l<a.length;l++)await appendChildNode(e,t,a[l],n,r)}else await appendChildNode(e,t,i,n,r)}function restoreScrollPosition(e,t){if(!isHTMLElementNode(e)||!isHTMLElementNode(t))return;const{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;const{transform:o}=t.style,s=new DOMMatrix(o),{a:i,b:a,c:l,d:u}=s;s.a=1,s.b=0,s.c=0,s.d=1,s.translateSelf(-r,-n),s.a=i,s.b=a,s.c=l,s.d=u,t.style.transform=s.toString()}function applyCssStyleWithOptions(e,t){const{backgroundColor:n,width:r,height:o,style:s}=t,i=e.style;if(n&&i.setProperty("background-color",n,"important"),r&&i.setProperty("width",`${r}px`,"important"),o&&i.setProperty("height",`${o}px`,"important"),s)for(const a in s)i[a]=s[a]}const NORMAL_ATTRIBUTE_RE=/^[\w-:]+$/;async function cloneNode(e,t,n=!1,r){var u,c,d,p;const{ownerDocument:o,ownerWindow:s,fontFamilies:i,onCloneEachNode:a}=t;if(o&&isTextNode(e))return r&&/\S/.test(e.data)&&r(e.data),o.createTextNode(e.data);if(o&&s&&isElementNode(e)&&(isHTMLElementNode(e)||isSVGElementNode(e))){const g=await cloneElement(e,t);if(t.isEnable("removeAbnormalAttributes")){const m=g.getAttributeNames();for(let x=m.length,S=0;S<x;S++){const N=m[S];NORMAL_ATTRIBUTE_RE.test(N)||g.removeAttribute(N)}}const _=t.currentNodeStyle=copyCssStyles(e,g,n,t);n&&applyCssStyleWithOptions(g,t);let y=!1;if(t.isEnable("copyScrollbar")){const m=[(u=_.get("overflow-x"))==null?void 0:u[0],(c=_.get("overflow-y"))==null?void 0:c[0]];y=m.includes("scroll")||(m.includes("auto")||m.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const h=(d=_.get("text-transform"))==null?void 0:d[0],f=splitFontFamily((p=_.get("font-family"))==null?void 0:p[0]),b=f?m=>{h==="uppercase"?m=m.toUpperCase():h==="lowercase"?m=m.toLowerCase():h==="capitalize"&&(m=m[0].toUpperCase()+m.substring(1)),f.forEach(x=>{let S=i.get(x);S||i.set(x,S=new Set),m.split("").forEach(N=>S.add(N))})}:void 0;return copyPseudoClass(e,g,y,t,b),copyInputValue(e,g),isVideoElement(e)||await cloneChildNodes(e,g,t,b),await(a==null?void 0:a(g)),g}const l=e.cloneNode(!1);return await cloneChildNodes(e,l,t),await(a==null?void 0:a(l)),l}function destroyContext(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function baseFetch(e){const{url:t,timeout:n,responseType:r,...o}=e,s=new AbortController,i=n?setTimeout(()=>s.abort(),n):void 0;return fetch(t,{signal:s.signal,...o}).then(a=>{if(!a.ok)throw new Error("Failed fetch, not 2xx response",{cause:a});switch(r){case"arrayBuffer":return a.arrayBuffer();case"dataUrl":return a.blob().then(blobToDataUrl);case"text":default:return a.text()}}).finally(()=>clearTimeout(i))}function contextFetch(e,t){const{url:n,requestType:r="text",responseType:o="text",imageDom:s}=t;let i=n;const{timeout:a,acceptOfImage:l,requests:u,fetchFn:c,fetch:{requestInit:d,bypassingCache:p,placeholderImage:g},font:_,workers:y,fontFamilies:h}=e;r==="image"&&(IN_SAFARI||IN_FIREFOX)&&e.drawImageCount++;let f=u.get(n);if(!f){p&&p instanceof RegExp&&p.test(i)&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());const b=r.startsWith("font")&&_&&_.minify,m=new Set;b&&r.split(";")[1].split(",").forEach(P=>{h.has(P)&&h.get(P).forEach(M=>m.add(M))});const x=b&&m.size,S={url:i,timeout:a,responseType:x?"arrayBuffer":o,headers:r==="image"?{accept:l}:void 0,...d};f={type:r,resolve:void 0,reject:void 0,response:null},f.response=(async()=>{if(c&&r==="image"){const N=await c(n);if(N)return N}return!IN_SAFARI&&n.startsWith("http")&&y.length?new Promise((N,P)=>{y[u.size&y.length-1].postMessage({rawUrl:n,...S}),f.resolve=N,f.reject=P}):baseFetch(S)})().catch(N=>{if(u.delete(n),r==="image"&&g)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",i),typeof g=="string"?g:g(s);throw N}),u.set(n,f)}return f.response}async function replaceCssUrlToDataUrl(e,t,n,r){if(!hasCssUrl(e))return e;for(const[o,s]of parseCssUrls(e,t))try{const i=await contextFetch(n,{url:s,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(toRE(o),`$1${i}$3`)}catch(i){n.log.warn("Failed to fetch css data url",o,i)}return e}function hasCssUrl(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const URL_RE=/url\((['"]?)([^'"]+?)\1\)/g;function parseCssUrls(e,t){const n=[];return e.replace(URL_RE,(r,o,s)=>(n.push([s,resolveUrl(s,t)]),r)),n.filter(([r])=>!isDataUrl(r))}function toRE(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const properties=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function embedCssStyleImage(e,t){return properties.map(n=>{const r=e.getPropertyValue(n);return!r||r==="none"?null:((IN_SAFARI||IN_FIREFOX)&&t.drawImageCount++,replaceCssUrlToDataUrl(r,null,t,!0).then(o=>{!o||r===o||e.setProperty(n,o,e.getPropertyPriority(n))}))}).filter(Boolean)}function embedImageElement(e,t){if(isImageElement(e)){const n=e.currentSrc||e.src;if(!isDataUrl(n))return[contextFetch(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.srcset="",e.dataset.originalSrc=n,e.src=r||"")})];(IN_SAFARI||IN_FIREFOX)&&t.drawImageCount++}else if(isSVGElementNode(e)&&!isDataUrl(e.href.baseVal)){const n=e.href.baseVal;return[contextFetch(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.dataset.originalSrc=n,e.href.baseVal=r||"")})]}return[]}function embedSvgUse(e,t){const{ownerDocument:n,svgDefsElement:r}=t,o=e.getAttribute("href")??e.getAttribute("xlink:href");if(!o)return[];const[s,i]=o.split("#");if(i){const a=`#${i}`,l=t.shadowRoots.reduce((u,c)=>u??c.querySelector(`svg ${a}`),n==null?void 0:n.querySelector(`svg ${a}`));if(s&&e.setAttribute("href",a),r!=null&&r.querySelector(a))return[];if(l)return r==null||r.appendChild(l.cloneNode(!0)),[];if(s)return[contextFetch(t,{url:s,responseType:"text"}).then(u=>{r==null||r.insertAdjacentHTML("beforeend",u)})]}return[]}function embedNode(e,t){const{tasks:n}=t;isElementNode(e)&&((isImageElement(e)||isSVGImageElementNode(e))&&n.push(...embedImageElement(e,t)),isSVGUseElementNode(e)&&n.push(...embedSvgUse(e,t))),isHTMLElementNode(e)&&n.push(...embedCssStyleImage(e.style,t)),e.childNodes.forEach(r=>{embedNode(r,t)})}async function embedWebFont(e,t){const{ownerDocument:n,svgStyleElement:r,fontFamilies:o,fontCssTexts:s,tasks:i,font:a}=t;if(!(!n||!r||!o.size))if(a&&a.cssText){const l=filterPreferredFormat(a.cssText,t);r.appendChild(n.createTextNode(`${l}
38
+ `);let b=a.get(f);b||(b=[],a.set(f,b)),b.push(`.${g[0]}${c}`)}pseudoClasses.forEach(u),n&&scrollbarPseudoClasses.forEach(u)}const excludeParentNodes=new Set(["symbol"]);async function appendChildNode(e,t,n,r,o){if(isElementNode(n)&&(isStyleElement(n)||isScriptElement(n))||r.filter&&!r.filter(n))return;excludeParentNodes.has(t.nodeName)||excludeParentNodes.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;const s=await cloneNode(n,r,!1,o);r.isEnable("restoreScrollPosition")&&restoreScrollPosition(e,s),t.appendChild(s)}async function cloneChildNodes(e,t,n,r){var s;let o=e.firstChild;isElementNode(e)&&e.shadowRoot&&(o=(s=e.shadowRoot)==null?void 0:s.firstChild,n.shadowRoots.push(e.shadowRoot));for(let i=o;i;i=i.nextSibling)if(!isCommentNode(i))if(isElementNode(i)&&isSlotElement(i)&&typeof i.assignedNodes=="function"){const a=i.assignedNodes();for(let l=0;l<a.length;l++)await appendChildNode(e,t,a[l],n,r)}else await appendChildNode(e,t,i,n,r)}function restoreScrollPosition(e,t){if(!isHTMLElementNode(e)||!isHTMLElementNode(t))return;const{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;const{transform:o}=t.style,s=new DOMMatrix(o),{a:i,b:a,c:l,d:u}=s;s.a=1,s.b=0,s.c=0,s.d=1,s.translateSelf(-r,-n),s.a=i,s.b=a,s.c=l,s.d=u,t.style.transform=s.toString()}function applyCssStyleWithOptions(e,t){const{backgroundColor:n,width:r,height:o,style:s}=t,i=e.style;if(n&&i.setProperty("background-color",n,"important"),r&&i.setProperty("width",`${r}px`,"important"),o&&i.setProperty("height",`${o}px`,"important"),s)for(const a in s)i[a]=s[a]}const NORMAL_ATTRIBUTE_RE=/^[\w-:]+$/;async function cloneNode(e,t,n=!1,r){var u,c,d,p;const{ownerDocument:o,ownerWindow:s,fontFamilies:i,onCloneEachNode:a}=t;if(o&&isTextNode(e))return r&&/\S/.test(e.data)&&r(e.data),o.createTextNode(e.data);if(o&&s&&isElementNode(e)&&(isHTMLElementNode(e)||isSVGElementNode(e))){const g=await cloneElement(e,t);if(t.isEnable("removeAbnormalAttributes")){const m=g.getAttributeNames();for(let x=m.length,S=0;S<x;S++){const N=m[S];NORMAL_ATTRIBUTE_RE.test(N)||g.removeAttribute(N)}}const _=t.currentNodeStyle=copyCssStyles(e,g,n,t);n&&applyCssStyleWithOptions(g,t);let y=!1;if(t.isEnable("copyScrollbar")){const m=[(u=_.get("overflow-x"))==null?void 0:u[0],(c=_.get("overflow-y"))==null?void 0:c[0]];y=m.includes("scroll")||(m.includes("auto")||m.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const h=(d=_.get("text-transform"))==null?void 0:d[0],f=splitFontFamily((p=_.get("font-family"))==null?void 0:p[0]),b=f?m=>{h==="uppercase"?m=m.toUpperCase():h==="lowercase"?m=m.toLowerCase():h==="capitalize"&&(m=m[0].toUpperCase()+m.substring(1)),f.forEach(x=>{let S=i.get(x);S||i.set(x,S=new Set),m.split("").forEach(N=>S.add(N))})}:void 0;return copyPseudoClass(e,g,y,t,b),copyInputValue(e,g),isVideoElement(e)||await cloneChildNodes(e,g,t,b),await(a==null?void 0:a(g)),g}const l=e.cloneNode(!1);return await cloneChildNodes(e,l,t),await(a==null?void 0:a(l)),l}function destroyContext(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function baseFetch(e){const{url:t,timeout:n,responseType:r,...o}=e,s=new AbortController,i=n?setTimeout(()=>s.abort(),n):void 0;return fetch(t,{signal:s.signal,...o}).then(a=>{if(!a.ok)throw new Error("Failed fetch, not 2xx response",{cause:a});switch(r){case"arrayBuffer":return a.arrayBuffer();case"dataUrl":return a.blob().then(blobToDataUrl);case"text":default:return a.text()}}).finally(()=>clearTimeout(i))}function contextFetch(e,t){const{url:n,requestType:r="text",responseType:o="text",imageDom:s}=t;let i=n;const{timeout:a,acceptOfImage:l,requests:u,fetchFn:c,fetch:{requestInit:d,bypassingCache:p,placeholderImage:g},font:_,workers:y,fontFamilies:h}=e;r==="image"&&(IN_SAFARI||IN_FIREFOX)&&e.drawImageCount++;let f=u.get(n);if(!f){p&&p instanceof RegExp&&p.test(i)&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());const b=r.startsWith("font")&&_&&_.minify,m=new Set;b&&r.split(";")[1].split(",").forEach(M=>{h.has(M)&&h.get(M).forEach(P=>m.add(P))});const x=b&&m.size,S={url:i,timeout:a,responseType:x?"arrayBuffer":o,headers:r==="image"?{accept:l}:void 0,...d};f={type:r,resolve:void 0,reject:void 0,response:null},f.response=(async()=>{if(c&&r==="image"){const N=await c(n);if(N)return N}return!IN_SAFARI&&n.startsWith("http")&&y.length?new Promise((N,M)=>{y[u.size&y.length-1].postMessage({rawUrl:n,...S}),f.resolve=N,f.reject=M}):baseFetch(S)})().catch(N=>{if(u.delete(n),r==="image"&&g)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",i),typeof g=="string"?g:g(s);throw N}),u.set(n,f)}return f.response}async function replaceCssUrlToDataUrl(e,t,n,r){if(!hasCssUrl(e))return e;for(const[o,s]of parseCssUrls(e,t))try{const i=await contextFetch(n,{url:s,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(toRE(o),`$1${i}$3`)}catch(i){n.log.warn("Failed to fetch css data url",o,i)}return e}function hasCssUrl(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const URL_RE=/url\((['"]?)([^'"]+?)\1\)/g;function parseCssUrls(e,t){const n=[];return e.replace(URL_RE,(r,o,s)=>(n.push([s,resolveUrl(s,t)]),r)),n.filter(([r])=>!isDataUrl(r))}function toRE(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const properties=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function embedCssStyleImage(e,t){return properties.map(n=>{const r=e.getPropertyValue(n);return!r||r==="none"?null:((IN_SAFARI||IN_FIREFOX)&&t.drawImageCount++,replaceCssUrlToDataUrl(r,null,t,!0).then(o=>{!o||r===o||e.setProperty(n,o,e.getPropertyPriority(n))}))}).filter(Boolean)}function embedImageElement(e,t){if(isImageElement(e)){const n=e.currentSrc||e.src;if(!isDataUrl(n))return[contextFetch(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.srcset="",e.dataset.originalSrc=n,e.src=r||"")})];(IN_SAFARI||IN_FIREFOX)&&t.drawImageCount++}else if(isSVGElementNode(e)&&!isDataUrl(e.href.baseVal)){const n=e.href.baseVal;return[contextFetch(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.dataset.originalSrc=n,e.href.baseVal=r||"")})]}return[]}function embedSvgUse(e,t){const{ownerDocument:n,svgDefsElement:r}=t,o=e.getAttribute("href")??e.getAttribute("xlink:href");if(!o)return[];const[s,i]=o.split("#");if(i){const a=`#${i}`,l=t.shadowRoots.reduce((u,c)=>u??c.querySelector(`svg ${a}`),n==null?void 0:n.querySelector(`svg ${a}`));if(s&&e.setAttribute("href",a),r!=null&&r.querySelector(a))return[];if(l)return r==null||r.appendChild(l.cloneNode(!0)),[];if(s)return[contextFetch(t,{url:s,responseType:"text"}).then(u=>{r==null||r.insertAdjacentHTML("beforeend",u)})]}return[]}function embedNode(e,t){const{tasks:n}=t;isElementNode(e)&&((isImageElement(e)||isSVGImageElementNode(e))&&n.push(...embedImageElement(e,t)),isSVGUseElementNode(e)&&n.push(...embedSvgUse(e,t))),isHTMLElementNode(e)&&n.push(...embedCssStyleImage(e.style,t)),e.childNodes.forEach(r=>{embedNode(r,t)})}async function embedWebFont(e,t){const{ownerDocument:n,svgStyleElement:r,fontFamilies:o,fontCssTexts:s,tasks:i,font:a}=t;if(!(!n||!r||!o.size))if(a&&a.cssText){const l=filterPreferredFormat(a.cssText,t);r.appendChild(n.createTextNode(`${l}
39
39
  `))}else{const l=Array.from(n.styleSheets).filter(c=>{try{return"cssRules"in c&&!!c.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${c.href}`,d),!1}});await Promise.all(l.flatMap(c=>Array.from(c.cssRules).map(async(d,p)=>{if(isCSSImportRule(d)){let g=p+1;const _=d.href;let y="";try{y=await contextFetch(t,{url:_,requestType:"text",responseType:"text"})}catch(f){t.log.warn(`Error fetch remote css import from ${_}`,f)}const h=y.replace(URL_RE,(f,b,m)=>f.replace(m,resolveUrl(m,_)));for(const f of parseCss(h))try{c.insertRule(f,f.startsWith("@import")?g+=1:c.cssRules.length)}catch(b){t.log.warn("Error inserting rule from remote css import",{rule:f,error:b})}}})));const u=[];l.forEach(c=>{unwrapCssLayers(c.cssRules,u)}),u.filter(c=>{var d;return isCssFontFaceRule(c)&&hasCssUrl(c.style.getPropertyValue("src"))&&((d=splitFontFamily(c.style.getPropertyValue("font-family")))==null?void 0:d.some(p=>o.has(p)))}).forEach(c=>{const d=c,p=s.get(d.cssText);p?r.appendChild(n.createTextNode(`${p}
40
40
  `)):i.push(replaceCssUrlToDataUrl(d.cssText,d.parentStyleSheet?d.parentStyleSheet.href:null,t).then(g=>{g=filterPreferredFormat(g,t),s.set(d.cssText,g),r.appendChild(n.createTextNode(`${g}
41
41
  `))}))})}}const COMMENTS_RE=/(\/\*[\s\S]*?\*\/)/g,KEYFRAMES_RE=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function parseCss(e){if(e==null)return[];const t=[];let n=e.replace(COMMENTS_RE,"");for(;;){const s=KEYFRAMES_RE.exec(n);if(!s)break;t.push(s[0])}n=n.replace(KEYFRAMES_RE,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=r.exec(n);if(s)o.lastIndex=r.lastIndex;else if(s=o.exec(n),s)r.lastIndex=o.lastIndex;else break;t.push(s[0])}return t}const URL_WITH_FORMAT_RE=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,FONT_SRC_RE=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function filterPreferredFormat(e,t){const{font:n}=t,r=n?n==null?void 0:n.preferredFormat:void 0;return r?e.replace(FONT_SRC_RE,o=>{for(;;){const[s,,i]=URL_WITH_FORMAT_RE.exec(o)||[];if(!i)return"";if(i===r)return`src: ${s};`}}):e}function unwrapCssLayers(e,t=[]){for(const n of Array.from(e))isLayerBlockRule(n)?t.push(...unwrapCssLayers(n.cssRules)):"cssRules"in n?unwrapCssLayers(n.cssRules,t):t.push(n);return t}async function domToForeignObjectSvg(e,t){const n=await orCreateContext(e,t);if(isElementNode(n.node)&&isSVGElementNode(n.node))return n.node;const{ownerDocument:r,log:o,tasks:s,svgStyleElement:i,svgDefsElement:a,svgStyles:l,font:u,progress:c,autoDestruct:d,onCloneNode:p,onEmbedNode:g,onCreateForeignObjectSvg:_}=n;o.time("clone node");const y=await cloneNode(n.node,n,!0);if(i&&r){let x="";l.forEach((S,N)=>{x+=`${S.join(`,
42
42
  `)} {
43
43
  ${N}
44
44
  }
45
- `}),i.appendChild(r.createTextNode(x))}o.timeEnd("clone node"),await(p==null?void 0:p(y)),u!==!1&&isElementNode(y)&&(o.time("embed web font"),await embedWebFont(y,n),o.timeEnd("embed web font")),o.time("embed node"),embedNode(y,n);const h=s.length;let f=0;const b=async()=>{for(;;){const x=s.pop();if(!x)break;try{await x}catch(S){n.log.warn("Failed to run task",S)}c==null||c(++f,h)}};c==null||c(f,h),await Promise.all([...Array.from({length:4})].map(b)),o.timeEnd("embed node"),await(g==null?void 0:g(y));const m=createForeignObjectSvg(y,n);return a&&m.insertBefore(a,m.children[0]),i&&m.insertBefore(i,m.children[0]),d&&destroyContext(n),await(_==null?void 0:_(m)),m}function createForeignObjectSvg(e,t){const{width:n,height:r}=t,o=createSvg(n,r,e.ownerDocument),s=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(e),o.appendChild(s),o}async function domToCanvas(e,t){var i;const n=await orCreateContext(e,t),r=await domToForeignObjectSvg(n),o=svgToDataUrl(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=createStyleElement(n.ownerDocument),n.svgDefsElement=(i=n.ownerDocument)==null?void 0:i.createElementNS(XMLNS,"defs"),n.svgStyles.clear());const s=createImage(o,r.ownerDocument);return await imageToCanvas(s,n)}const PLACEHOLDER="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function isFragmentUrl(e){try{const t=new URL(e,window.location.href);return t.origin===window.location.origin&&t.pathname===window.location.pathname&&!!t.hash}catch{return!0}}function withFetchIntercept(e){const t=window.fetch;return window.fetch=function(n,r){const o=typeof n=="string"?n:n instanceof URL?n.toString():n.url;return isFragmentUrl(o)?Promise.resolve(new Response("",{status:200})):t.call(window,n,r)},e().finally(()=>{window.fetch=t})}const sharedOptions={fetch:{placeholderImage:PLACEHOLDER},filter:e=>{var t;return!(e instanceof HTMLElement&&(e.tagName==="JAT-FEEDBACK"||(t=e.id)!=null&&t.startsWith("jat-feedback-")))}};async function captureViewport(){return withFetchIntercept(async()=>(await domToCanvas(document.documentElement,{...sharedOptions,width:window.innerWidth,height:window.innerHeight,style:{transform:`translate(-${window.scrollX}px, -${window.scrollY}px)`}})).toDataURL("image/jpeg",.8))}async function captureViewportQuick(){return withFetchIntercept(async()=>(await domToCanvas(document.documentElement,{...sharedOptions,scale:.5,width:window.innerWidth,height:window.innerHeight,style:{transform:`translate(-${window.scrollX}px, -${window.scrollY}px)`}})).toDataURL("image/jpeg",.6))}function cubic_out(e){const t=e-1;return t*t*t+1}function slide(e,{delay:t=0,duration:n=400,easing:r=cubic_out,axis:o="y"}={}){const s=getComputedStyle(e),i=+s.opacity,a=o==="y"?"height":"width",l=parseFloat(s[a]),u=o==="y"?["top","bottom"]:["left","right"],c=u.map(f=>`${f[0].toUpperCase()}${f.slice(1)}`),d=parseFloat(s[`padding${c[0]}`]),p=parseFloat(s[`padding${c[1]}`]),g=parseFloat(s[`margin${c[0]}`]),_=parseFloat(s[`margin${c[1]}`]),y=parseFloat(s[`border${c[0]}Width`]),h=parseFloat(s[`border${c[1]}Width`]);return{delay:t,duration:n,easing:r,css:f=>`overflow: hidden;opacity: ${Math.min(f*20,1)*i};${a}: ${f*l}px;padding-${u[0]}: ${f*d}px;padding-${u[1]}: ${f*p}px;margin-${u[0]}: ${f*g}px;margin-${u[1]}: ${f*_}px;border-${u[0]}-width: ${f*y}px;border-${u[1]}-width: ${f*h}px;min-${a}: 0`}}var root_3$6=from_html('<button class="thumb-edit svelte-1dhybq8" aria-label="Edit screenshot"><svg width="10" height="10" viewBox="0 0 24 24" fill="none"><path d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button>'),root_2$7=from_html('<div class="thumb-wrap svelte-1dhybq8"><img class="thumb svelte-1dhybq8"/> <!> <button class="thumb-remove svelte-1dhybq8" aria-label="Remove screenshot">&times;</button></div>'),root_4$4=from_html('<span class="more-badge svelte-1dhybq8"> </span>'),root_1$7=from_html('<div class="thumb-strip svelte-1dhybq8"><!> <!></div>');const $$css$8={hash:"svelte-1dhybq8",code:".thumb-strip.svelte-1dhybq8 {display:flex;gap:6px;align-items:center;}.thumb-wrap.svelte-1dhybq8 {position:relative;}.thumb.svelte-1dhybq8 {width:60px;height:42px;object-fit:cover;border-radius:4px;border:1px solid #374151;}.thumb-edit.svelte-1dhybq8 {position:absolute;bottom:2px;right:2px;width:20px;height:20px;border-radius:3px;background:rgba(59, 130, 246, 0.85);color:white;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;opacity:0;transition:opacity 0.15s;}.thumb-wrap.svelte-1dhybq8:hover .thumb-edit:where(.svelte-1dhybq8) {opacity:1;}.thumb-edit.svelte-1dhybq8:hover {background:#2563eb;}.thumb-remove.svelte-1dhybq8 {position:absolute;top:-4px;right:-4px;width:16px;height:16px;border-radius:50%;background:#ef4444;color:white;border:none;cursor:pointer;font-size:10px;display:flex;align-items:center;justify-content:center;line-height:1;padding:0;}.more-badge.svelte-1dhybq8 {font-size:11px;color:#6b7280;padding:0 4px;}"};function ScreenshotPreview(e,t){push(t,!0),append_styles(e,$$css$8);let n=prop(t,"screenshots",23,()=>[]),r=prop(t,"capturing",7,!1),o=prop(t,"oncapture",7),s=prop(t,"onremove",7),i=prop(t,"onedit",7);var a={get screenshots(){return n()},set screenshots(d=[]){n(d),flushSync()},get capturing(){return r()},set capturing(d=!1){r(d),flushSync()},get oncapture(){return o()},set oncapture(d){o(d),flushSync()},get onremove(){return s()},set onremove(d){s(d),flushSync()},get onedit(){return i()},set onedit(d){i(d),flushSync()}},l=comment(),u=first_child(l);{var c=d=>{var p=root_1$7(),g=child(p);each(g,17,()=>n().slice(-3),index,(h,f,b)=>{const m=user_derived(()=>n().length>3?n().length-3+b:b);var x=root_2$7(),S=child(x);set_attribute(S,"alt",`Screenshot ${b+1}`);var N=sibling(S,2);{var P=re=>{var oe=root_3$6();delegated("click",oe,()=>i()(get(m))),append(re,oe)};if_block(N,re=>{i()&&re(P)})}var M=sibling(N,2);reset(x),template_effect(()=>set_attribute(S,"src",get(f))),delegated("click",M,()=>s()(get(m))),append(h,x)});var _=sibling(g,2);{var y=h=>{var f=root_4$4(),b=child(f);reset(f),template_effect(()=>set_text(b,`+${n().length-3}`)),append(h,f)};if_block(_,h=>{n().length>3&&h(y)})}reset(p),append(d,p)};if_block(u,d=>{n().length>0&&d(c)})}return append(e,l),pop(a)}delegate(["click"]),create_custom_element(ScreenshotPreview,{screenshots:{},capturing:{},oncapture:{},onremove:{},onedit:{}},[],[],{mode:"open"});var root_2$6=from_svg('<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><ellipse cx="12" cy="12" rx="10" ry="7" stroke="currentColor" stroke-width="2" fill="none"></ellipse></svg>'),root_3$5=from_svg('<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"></path></svg>'),root_1$6=from_html('<button><!> <span class="tool-label svelte-yff65c"> </span></button>'),root_4$3=from_html("<button></button>"),root_5$3=from_html('<canvas class="base-canvas svelte-yff65c"></canvas> <canvas></canvas>',1),root_6$4=from_html('<div class="loading svelte-yff65c">Loading image...</div>'),root_7$4=from_html('<input type="text" class="text-overlay-input svelte-yff65c" placeholder="Type here..."/>'),root$5=from_html('<div class="annotation-backdrop svelte-yff65c"><div class="annotation-toolbar svelte-yff65c"><div class="tool-group svelte-yff65c"></div> <div class="divider svelte-yff65c"></div> <div class="color-group svelte-yff65c"></div> <div class="divider svelte-yff65c"></div> <div class="action-group svelte-yff65c"><button class="action-btn svelte-yff65c" title="Undo (Ctrl+Z)"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 10h10a5 5 0 015 5v0a5 5 0 01-5 5H8M3 10l4-4M3 10l4 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Undo</button> <button class="action-btn svelte-yff65c" title="Clear all"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 6h18M8 6V4h8v2M10 11v6M14 11v6M5 6l1 14h12l1-14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Clear</button></div> <div class="spacer svelte-yff65c"></div> <div class="commit-group svelte-yff65c"><button class="cancel-btn svelte-yff65c">Cancel</button> <button class="done-btn svelte-yff65c">Done</button></div></div> <div class="canvas-container svelte-yff65c"><!></div> <!></div>');const $$css$7={hash:"svelte-yff65c",code:`.annotation-backdrop.svelte-yff65c {position:fixed;inset:0;z-index:2147483647;background:rgba(0, 0, 0, 0.85);display:flex;flex-direction:column;align-items:center;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;}.annotation-toolbar.svelte-yff65c {display:flex;align-items:center;gap:6px;padding:8px 12px;background:#1f2937;border-bottom:1px solid #374151;width:100%;flex-shrink:0;flex-wrap:wrap;}.tool-group.svelte-yff65c, .color-group.svelte-yff65c, .action-group.svelte-yff65c, .commit-group.svelte-yff65c {display:flex;align-items:center;gap:4px;}.divider.svelte-yff65c {width:1px;height:24px;background:#374151;margin:0 4px;}.spacer.svelte-yff65c {flex:1;}.tool-btn.svelte-yff65c {display:flex;align-items:center;gap:4px;padding:5px 8px;background:transparent;border:1px solid transparent;border-radius:4px;color:#9ca3af;font-size:11px;cursor:pointer;font-family:inherit;transition:all 0.15s;}.tool-btn.svelte-yff65c:hover {color:#e5e7eb;background:#374151;}.tool-btn.active.svelte-yff65c {color:#fff;background:#3b82f6;border-color:#3b82f6;}.tool-label.svelte-yff65c {display:none;}
45
+ `}),i.appendChild(r.createTextNode(x))}o.timeEnd("clone node"),await(p==null?void 0:p(y)),u!==!1&&isElementNode(y)&&(o.time("embed web font"),await embedWebFont(y,n),o.timeEnd("embed web font")),o.time("embed node"),embedNode(y,n);const h=s.length;let f=0;const b=async()=>{for(;;){const x=s.pop();if(!x)break;try{await x}catch(S){n.log.warn("Failed to run task",S)}c==null||c(++f,h)}};c==null||c(f,h),await Promise.all([...Array.from({length:4})].map(b)),o.timeEnd("embed node"),await(g==null?void 0:g(y));const m=createForeignObjectSvg(y,n);return a&&m.insertBefore(a,m.children[0]),i&&m.insertBefore(i,m.children[0]),d&&destroyContext(n),await(_==null?void 0:_(m)),m}function createForeignObjectSvg(e,t){const{width:n,height:r}=t,o=createSvg(n,r,e.ownerDocument),s=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(e),o.appendChild(s),o}async function domToCanvas(e,t){var i;const n=await orCreateContext(e,t),r=await domToForeignObjectSvg(n),o=svgToDataUrl(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=createStyleElement(n.ownerDocument),n.svgDefsElement=(i=n.ownerDocument)==null?void 0:i.createElementNS(XMLNS,"defs"),n.svgStyles.clear());const s=createImage(o,r.ownerDocument);return await imageToCanvas(s,n)}const PLACEHOLDER="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function isFragmentUrl(e){try{const t=new URL(e,window.location.href);return t.origin===window.location.origin&&t.pathname===window.location.pathname&&!!t.hash}catch{return!0}}function withFetchIntercept(e){const t=window.fetch;return window.fetch=function(n,r){const o=typeof n=="string"?n:n instanceof URL?n.toString():n.url;return isFragmentUrl(o)?Promise.resolve(new Response("",{status:200})):t.call(window,n,r)},e().finally(()=>{window.fetch=t})}const sharedOptions={fetch:{placeholderImage:PLACEHOLDER},filter:e=>{var t;return!(e instanceof HTMLElement&&(e.tagName==="JAT-FEEDBACK"||(t=e.id)!=null&&t.startsWith("jat-feedback-")))}};async function captureViewport(){return withFetchIntercept(async()=>(await domToCanvas(document.documentElement,{...sharedOptions,width:window.innerWidth,height:window.innerHeight,style:{transform:`translate(-${window.scrollX}px, -${window.scrollY}px)`}})).toDataURL("image/jpeg",.8))}async function captureViewportQuick(){return withFetchIntercept(async()=>(await domToCanvas(document.documentElement,{...sharedOptions,scale:.5,width:window.innerWidth,height:window.innerHeight,style:{transform:`translate(-${window.scrollX}px, -${window.scrollY}px)`}})).toDataURL("image/jpeg",.6))}function cubic_out(e){const t=e-1;return t*t*t+1}function slide(e,{delay:t=0,duration:n=400,easing:r=cubic_out,axis:o="y"}={}){const s=getComputedStyle(e),i=+s.opacity,a=o==="y"?"height":"width",l=parseFloat(s[a]),u=o==="y"?["top","bottom"]:["left","right"],c=u.map(f=>`${f[0].toUpperCase()}${f.slice(1)}`),d=parseFloat(s[`padding${c[0]}`]),p=parseFloat(s[`padding${c[1]}`]),g=parseFloat(s[`margin${c[0]}`]),_=parseFloat(s[`margin${c[1]}`]),y=parseFloat(s[`border${c[0]}Width`]),h=parseFloat(s[`border${c[1]}Width`]);return{delay:t,duration:n,easing:r,css:f=>`overflow: hidden;opacity: ${Math.min(f*20,1)*i};${a}: ${f*l}px;padding-${u[0]}: ${f*d}px;padding-${u[1]}: ${f*p}px;margin-${u[0]}: ${f*g}px;margin-${u[1]}: ${f*_}px;border-${u[0]}-width: ${f*y}px;border-${u[1]}-width: ${f*h}px;min-${a}: 0`}}var root_3$6=from_html('<button class="thumb-edit svelte-1dhybq8" aria-label="Edit screenshot"><svg width="10" height="10" viewBox="0 0 24 24" fill="none"><path d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button>'),root_2$7=from_html('<div class="thumb-wrap svelte-1dhybq8"><img class="thumb svelte-1dhybq8"/> <!> <button class="thumb-remove svelte-1dhybq8" aria-label="Remove screenshot">&times;</button></div>'),root_4$4=from_html('<span class="more-badge svelte-1dhybq8"> </span>'),root_1$7=from_html('<div class="thumb-strip svelte-1dhybq8"><!> <!></div>');const $$css$8={hash:"svelte-1dhybq8",code:".thumb-strip.svelte-1dhybq8 {display:flex;gap:6px;align-items:center;}.thumb-wrap.svelte-1dhybq8 {position:relative;}.thumb.svelte-1dhybq8 {width:60px;height:42px;object-fit:cover;border-radius:4px;border:1px solid #374151;}.thumb-edit.svelte-1dhybq8 {position:absolute;bottom:2px;right:2px;width:20px;height:20px;border-radius:3px;background:rgba(59, 130, 246, 0.85);color:white;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;opacity:0;transition:opacity 0.15s;}.thumb-wrap.svelte-1dhybq8:hover .thumb-edit:where(.svelte-1dhybq8) {opacity:1;}.thumb-edit.svelte-1dhybq8:hover {background:#2563eb;}.thumb-remove.svelte-1dhybq8 {position:absolute;top:-4px;right:-4px;width:16px;height:16px;border-radius:50%;background:#ef4444;color:white;border:none;cursor:pointer;font-size:10px;display:flex;align-items:center;justify-content:center;line-height:1;padding:0;}.more-badge.svelte-1dhybq8 {font-size:11px;color:#6b7280;padding:0 4px;}"};function ScreenshotPreview(e,t){push(t,!0),append_styles(e,$$css$8);let n=prop(t,"screenshots",23,()=>[]),r=prop(t,"capturing",7,!1),o=prop(t,"oncapture",7),s=prop(t,"onremove",7),i=prop(t,"onedit",7);var a={get screenshots(){return n()},set screenshots(d=[]){n(d),flushSync()},get capturing(){return r()},set capturing(d=!1){r(d),flushSync()},get oncapture(){return o()},set oncapture(d){o(d),flushSync()},get onremove(){return s()},set onremove(d){s(d),flushSync()},get onedit(){return i()},set onedit(d){i(d),flushSync()}},l=comment(),u=first_child(l);{var c=d=>{var p=root_1$7(),g=child(p);each(g,17,()=>n().slice(-3),index,(h,f,b)=>{const m=user_derived(()=>n().length>3?n().length-3+b:b);var x=root_2$7(),S=child(x);set_attribute(S,"alt",`Screenshot ${b+1}`);var N=sibling(S,2);{var M=re=>{var oe=root_3$6();delegated("click",oe,()=>i()(get(m))),append(re,oe)};if_block(N,re=>{i()&&re(M)})}var P=sibling(N,2);reset(x),template_effect(()=>set_attribute(S,"src",get(f))),delegated("click",P,()=>s()(get(m))),append(h,x)});var _=sibling(g,2);{var y=h=>{var f=root_4$4(),b=child(f);reset(f),template_effect(()=>set_text(b,`+${n().length-3}`)),append(h,f)};if_block(_,h=>{n().length>3&&h(y)})}reset(p),append(d,p)};if_block(u,d=>{n().length>0&&d(c)})}return append(e,l),pop(a)}delegate(["click"]),create_custom_element(ScreenshotPreview,{screenshots:{},capturing:{},oncapture:{},onremove:{},onedit:{}},[],[],{mode:"open"});var root_2$6=from_svg('<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><ellipse cx="12" cy="12" rx="10" ry="7" stroke="currentColor" stroke-width="2" fill="none"></ellipse></svg>'),root_3$5=from_svg('<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"></path></svg>'),root_1$6=from_html('<button><!> <span class="tool-label svelte-yff65c"> </span></button>'),root_4$3=from_html("<button></button>"),root_5$3=from_html('<canvas class="base-canvas svelte-yff65c"></canvas> <canvas></canvas>',1),root_6$4=from_html('<div class="loading svelte-yff65c">Loading image...</div>'),root_7$4=from_html('<input type="text" class="text-overlay-input svelte-yff65c" placeholder="Type here..."/>'),root$5=from_html('<div class="annotation-backdrop svelte-yff65c"><div class="annotation-toolbar svelte-yff65c"><div class="tool-group svelte-yff65c"></div> <div class="divider svelte-yff65c"></div> <div class="color-group svelte-yff65c"></div> <div class="divider svelte-yff65c"></div> <div class="action-group svelte-yff65c"><button class="action-btn svelte-yff65c" title="Undo (Ctrl+Z)"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 10h10a5 5 0 015 5v0a5 5 0 01-5 5H8M3 10l4-4M3 10l4 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Undo</button> <button class="action-btn svelte-yff65c" title="Clear all"><svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 6h18M8 6V4h8v2M10 11v6M14 11v6M5 6l1 14h12l1-14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Clear</button></div> <div class="spacer svelte-yff65c"></div> <div class="commit-group svelte-yff65c"><button class="cancel-btn svelte-yff65c">Cancel</button> <button class="done-btn svelte-yff65c">Done</button></div></div> <div class="canvas-container svelte-yff65c"><!></div> <!></div>');const $$css$7={hash:"svelte-yff65c",code:`.annotation-backdrop.svelte-yff65c {position:fixed;inset:0;z-index:2147483647;background:rgba(0, 0, 0, 0.85);display:flex;flex-direction:column;align-items:center;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;}.annotation-toolbar.svelte-yff65c {display:flex;align-items:center;gap:6px;padding:8px 12px;background:#1f2937;border-bottom:1px solid #374151;width:100%;flex-shrink:0;flex-wrap:wrap;}.tool-group.svelte-yff65c, .color-group.svelte-yff65c, .action-group.svelte-yff65c, .commit-group.svelte-yff65c {display:flex;align-items:center;gap:4px;}.divider.svelte-yff65c {width:1px;height:24px;background:#374151;margin:0 4px;}.spacer.svelte-yff65c {flex:1;}.tool-btn.svelte-yff65c {display:flex;align-items:center;gap:4px;padding:5px 8px;background:transparent;border:1px solid transparent;border-radius:4px;color:#9ca3af;font-size:11px;cursor:pointer;font-family:inherit;transition:all 0.15s;}.tool-btn.svelte-yff65c:hover {color:#e5e7eb;background:#374151;}.tool-btn.active.svelte-yff65c {color:#fff;background:#3b82f6;border-color:#3b82f6;}.tool-label.svelte-yff65c {display:none;}
46
46
  @media (min-width: 640px) {.tool-label.svelte-yff65c {display:inline;}
47
47
  }.color-swatch.svelte-yff65c {width:20px;height:20px;border-radius:50%;border:2px solid transparent;cursor:pointer;transition:transform 0.1s, border-color 0.1s;padding:0;}.color-swatch.svelte-yff65c:hover {transform:scale(1.15);}.color-swatch.active.svelte-yff65c {border-color:#fff;transform:scale(1.2);}.action-btn.svelte-yff65c {display:flex;align-items:center;gap:4px;padding:5px 8px;background:transparent;border:1px solid #374151;border-radius:4px;color:#9ca3af;font-size:11px;cursor:pointer;font-family:inherit;transition:all 0.15s;}.action-btn.svelte-yff65c:hover:not(:disabled) {color:#e5e7eb;background:#374151;}.action-btn.svelte-yff65c:disabled {opacity:0.4;cursor:not-allowed;}.cancel-btn.svelte-yff65c {padding:6px 14px;background:#374151;border:1px solid #4b5563;border-radius:5px;color:#d1d5db;font-size:12px;cursor:pointer;font-family:inherit;transition:background 0.15s;}.cancel-btn.svelte-yff65c:hover {background:#4b5563;}.done-btn.svelte-yff65c {padding:6px 16px;background:#3b82f6;border:none;border-radius:5px;color:white;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit;transition:background 0.15s;}.done-btn.svelte-yff65c:hover {background:#2563eb;}.canvas-container.svelte-yff65c {flex:1;display:flex;align-items:center;justify-content:center;position:relative;overflow:hidden;padding:20px;}.base-canvas.svelte-yff65c, .overlay-canvas.svelte-yff65c {max-width:calc(100vw - 80px);max-height:calc(100vh - 120px);object-fit:contain;border-radius:4px;}.base-canvas.svelte-yff65c {display:block;}.overlay-canvas.svelte-yff65c {position:absolute;
48
- /* Overlays exactly on base-canvas — sized by max-width/max-height */}.cursor-crosshair.svelte-yff65c {cursor:crosshair;}.cursor-text.svelte-yff65c {cursor:text;}.text-overlay-input.svelte-yff65c {position:fixed;background:transparent;border:1px dashed rgba(255,255,255,0.5);outline:none;font-size:16px;font-weight:bold;font-family:sans-serif;padding:2px 4px;z-index:2147483647;min-width:80px;}.loading.svelte-yff65c {color:#9ca3af;font-size:14px;}`};function AnnotationEditor(e,t){push(t,!0),append_styles(e,$$css$7);let n=prop(t,"imageDataUrl",7),r=prop(t,"onsave",7),o=prop(t,"oncancel",7),s=state("arrow"),i=state(proxy(ANNOTATION_COLORS[0])),a=state(proxy([])),l=state(void 0),u=state(void 0),c=state(0),d=state(0),p=state(!1),g=state("idle"),_={x:0,y:0},y=[],h=state(void 0),f=state(proxy({x:0,y:0})),b=state(proxy({left:"0px",top:"0px"})),m=state("");onMount(()=>{setAnnotationEditorOpen(!0);const A=new Image;A.onload=()=>{set(c,A.naturalWidth,!0),set(d,A.naturalHeight,!0),set(p,!0),requestAnimationFrame(()=>S(A))},A.src=n()}),onDestroy(()=>{setAnnotationEditorOpen(!1)});function x(){return new Promise((A,O)=>{const L=new Image;L.onload=()=>A(L),L.onerror=O,L.src=n()})}async function S(A){if(!get(l))return;const O=get(l).getContext("2d");O&&(A||(A=await x()),get(l).width=get(c),get(l).height=get(d),O.drawImage(A,0,0,get(c),get(d)),renderAllShapes(O,get(a)))}function N(){if(!get(u))return;const A=get(u).getContext("2d");A&&(get(u).width=get(c),get(u).height=get(d),A.clearRect(0,0,get(c),get(d)))}function P(A){if(!get(u))return{x:0,y:0};const O=get(u).getBoundingClientRect(),L=get(c)/O.width,F=get(d)/O.height;return{x:(A.clientX-O.left)*L,y:(A.clientY-O.top)*F}}function M(A){if(!get(u))return{left:"0px",top:"0px"};const O=get(u).getBoundingClientRect();return{left:`${O.left+A.x/(get(c)/O.width)}px`,top:`${O.top+A.y/(get(d)/O.height)}px`}}function re(A){const O={color:get(i),strokeWidth:DEFAULT_STROKE_WIDTH};switch(get(s)){case"arrow":return{...O,id:nextShapeId(),type:"arrow",start:_,end:A};case"rectangle":return{...O,id:nextShapeId(),type:"rectangle",start:_,end:A};case"ellipse":return{...O,id:nextShapeId(),type:"ellipse",start:_,end:A};case"freehand":return{...O,id:nextShapeId(),type:"freehand",points:[...y,A]};default:return null}}function oe(A){if(get(g)==="typing"){_e();return}const O=P(A);if(get(s)==="text"){set(g,"typing"),set(f,O,!0),set(b,M(O),!0),set(m,""),requestAnimationFrame(()=>{var L;return(L=get(h))==null?void 0:L.focus()});return}set(g,"drawing"),_=O,y=[O]}function ne(A){if(get(g)!=="drawing")return;const O=P(A);get(s)==="freehand"&&y.push(O),N();const L=re(O);if(L&&get(u)){const F=get(u).getContext("2d");F&&renderShape(F,L)}}function ce(A){if(get(g)!=="drawing")return;const O=P(A),L=re(O);L&&set(a,[...get(a),L],!0),set(g,"idle"),y=[],N(),S()}function _e(){if(get(m).trim()){const A={id:nextShapeId(),type:"text",color:get(i),strokeWidth:DEFAULT_STROKE_WIDTH,position:get(f),content:get(m).trim(),fontSize:20};set(a,[...get(a),A],!0),S()}set(m,""),set(g,"idle")}function ge(A){A.key==="Enter"?(A.preventDefault(),_e()):A.key==="Escape"&&(A.preventDefault(),set(m,""),set(g,"idle"))}function $e(){get(a).length!==0&&(set(a,get(a).slice(0,-1),!0),S())}function be(){set(a,[],!0),S()}async function ye(){if(get(a).length===0){r()(n());return}const A=await mergeAnnotation(n(),get(a),get(c),get(d));r()(A)}function de(){o()()}function v(A){A.stopPropagation(),A.key==="Escape"&&get(g)!=="typing"&&de(),(A.ctrlKey||A.metaKey)&&A.key==="z"&&(A.preventDefault(),$e())}const w={arrow:"M5 19L19 5M19 5H9M19 5V15",rectangle:"M3 3h18v18H3z",ellipse:"",freehand:"M3 17c1-2 3-6 5-6s3 4 5 4 3-6 5-6 2 4 3 4",text:"M6 4v16M18 4v16M6 12h12M8 4h-4M20 4h-4M8 20h-4M20 20h-4"},z={arrow:"Arrow",rectangle:"Rect",ellipse:"Ellipse",freehand:"Draw",text:"Text"},R=["arrow","rectangle","ellipse","freehand","text"];var k={get imageDataUrl(){return n()},set imageDataUrl(A){n(A),flushSync()},get onsave(){return r()},set onsave(A){r(A),flushSync()},get oncancel(){return o()},set oncancel(A){o(A),flushSync()}},U=root$5(),D=child(U),K=child(D);each(K,21,()=>R,index,(A,O)=>{var L=root_1$6();let F;var q=child(L);{var C=xe=>{var Ue=root_2$6();append(xe,Ue)},H=xe=>{var Ue=root_3$5(),Ke=child(Ue);reset(Ue),template_effect(()=>set_attribute(Ke,"d",w[get(O)])),append(xe,Ue)};if_block(q,xe=>{get(O)==="ellipse"?xe(C):xe(H,!1)})}var se=sibling(q,2),ke=child(se,!0);reset(se),reset(L),template_effect(()=>{F=set_class(L,1,"tool-btn svelte-yff65c",null,F,{active:get(s)===get(O)}),set_attribute(L,"title",z[get(O)]),set_text(ke,z[get(O)])}),delegated("click",L,()=>{set(s,get(O),!0)}),append(A,L)}),reset(K);var j=sibling(K,4);each(j,21,()=>ANNOTATION_COLORS,index,(A,O)=>{var L=root_4$3();let F;template_effect(()=>{F=set_class(L,1,"color-swatch svelte-yff65c",null,F,{active:get(i)===get(O)}),set_style(L,`background: ${get(O)??""}; ${get(O)==="#111827"?"border-color: #6b7280;":""}`),set_attribute(L,"title",get(O))}),delegated("click",L,()=>{set(i,get(O),!0)}),append(A,L)}),reset(j);var J=sibling(j,4),ee=child(J),ie=sibling(ee,2);reset(J);var I=sibling(J,4),Z=child(I),W=sibling(Z,2);reset(I),reset(D);var T=sibling(D,2),V=child(T);{var Q=A=>{var O=root_5$3(),L=first_child(O);bind_this(L,C=>set(l,C),()=>get(l));var F=sibling(L,2);let q;bind_this(F,C=>set(u,C),()=>get(u)),template_effect(()=>{set_attribute(L,"width",get(c)),set_attribute(L,"height",get(d)),set_attribute(F,"width",get(c)),set_attribute(F,"height",get(d)),q=set_class(F,1,"overlay-canvas svelte-yff65c",null,q,{"cursor-crosshair":get(s)!=="text","cursor-text":get(s)==="text"})}),delegated("mousedown",F,oe),delegated("mousemove",F,ne),delegated("mouseup",F,ce),append(A,O)},G=A=>{var O=root_6$4();append(A,O)};if_block(V,A=>{get(p)?A(Q):A(G,!1)})}reset(T);var we=sibling(T,2);{var fe=A=>{var O=root_7$4();remove_input_defaults(O),bind_this(O,L=>set(h,L),()=>get(h)),template_effect(()=>set_style(O,`left: ${get(b).left??""}; top: ${get(b).top??""}; color: ${get(i)??""};`)),delegated("keydown",O,ge),event("blur",O,_e),bind_value(O,()=>get(m),L=>set(m,L)),append(A,O)};if_block(we,A=>{get(g)==="typing"&&A(fe)})}return reset(U),template_effect(()=>{ee.disabled=get(a).length===0,ie.disabled=get(a).length===0}),delegated("keydown",U,v),delegated("keyup",U,A=>A.stopPropagation()),event("keypress",U,A=>A.stopPropagation()),delegated("click",ee,$e),delegated("click",ie,be),delegated("click",Z,de),delegated("click",W,ye),append(e,U),pop(k)}delegate(["keydown","keyup","click","mousedown","mousemove","mouseup"]),create_custom_element(AnnotationEditor,{imageDataUrl:{},onsave:{},oncancel:{}},[],[],{mode:"open"});var root_2$5=from_html('<div class="log-entry svelte-x1hlqn"><span class="log-type svelte-x1hlqn"> </span> <span class="log-msg svelte-x1hlqn"> </span></div>'),root_3$4=from_html('<div class="log-more svelte-x1hlqn"> </div>'),root_1$5=from_html('<div class="log-list svelte-x1hlqn"><div class="log-header svelte-x1hlqn"> </div> <div class="log-scroll svelte-x1hlqn"><!> <!></div></div>');const $$css$6={hash:"svelte-x1hlqn",code:".log-list.svelte-x1hlqn {border:1px solid #374151;border-radius:6px;overflow:hidden;}.log-header.svelte-x1hlqn {padding:6px 10px;background:#1f2937;font-size:11px;font-weight:600;color:#d1d5db;border-bottom:1px solid #374151;}.log-scroll.svelte-x1hlqn {max-height:140px;overflow-y:auto;background:#111827;}.log-entry.svelte-x1hlqn {padding:4px 10px;font-size:11px;font-family:'SF Mono', 'Fira Code', 'Cascadia Code', monospace;display:flex;gap:8px;border-bottom:1px solid #1f293780;line-height:1.4;}.log-type.svelte-x1hlqn {font-weight:600;text-transform:uppercase;font-size:10px;min-width:40px;flex-shrink:0;}.log-msg.svelte-x1hlqn {color:#d1d5db;word-break:break-word;}.log-more.svelte-x1hlqn {padding:4px 10px;font-size:10px;color:#6b7280;text-align:center;}"};function ConsoleLogList(e,t){push(t,!0),append_styles(e,$$css$6);let n=prop(t,"logs",23,()=>[]);const r={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",log:"#9ca3af",debug:"#8b5cf6",trace:"#6b7280"};var o={get logs(){return n()},set logs(l=[]){n(l),flushSync()}},s=comment(),i=first_child(s);{var a=l=>{var u=root_1$5(),c=child(u),d=child(c);reset(c);var p=sibling(c,2),g=child(p);each(g,17,()=>n().slice(-10),index,(h,f)=>{var b=root_2$5(),m=child(b),x=child(m,!0);reset(m);var S=sibling(m,2),N=child(S);reset(S),reset(b),template_effect(P=>{set_style(m,`color: ${(r[get(f).type]||"#9ca3af")??""}`),set_text(x,get(f).type),set_text(N,`${P??""}${get(f).message.length>120?"...":""}`)},[()=>get(f).message.substring(0,120)]),append(h,b)});var _=sibling(g,2);{var y=h=>{var f=root_3$4(),b=child(f);reset(f),template_effect(()=>set_text(b,`+${n().length-10} more`)),append(h,f)};if_block(_,h=>{n().length>10&&h(y)})}reset(p),reset(u),template_effect(()=>set_text(d,`Console Logs (${n().length??""})`)),append(l,u)};if_block(i,l=>{n().length>0&&l(a)})}return append(e,s),pop(o)}create_custom_element(ConsoleLogList,{logs:{}},[],[],{mode:"open"});var root_2$4=from_svg('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M3 8L6.5 11.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),root_3$3=from_svg('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.5"></circle><path d="M8 5V8.5M8 10.5V11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>'),root_1$4=from_html('<div><span class="icon svelte-1f5s7q1"><!></span> <span class="msg"> </span></div>');const $$css$5={hash:"svelte-1f5s7q1",code:`.jat-toast.svelte-1f5s7q1 {position:absolute;bottom:70px;right:0;padding:10px 16px;border-radius:8px;font-size:13px;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;display:flex;align-items:center;gap:8px;box-shadow:0 4px 12px rgba(0,0,0,0.2);
48
+ /* Overlays exactly on base-canvas — sized by max-width/max-height */}.cursor-crosshair.svelte-yff65c {cursor:crosshair;}.cursor-text.svelte-yff65c {cursor:text;}.text-overlay-input.svelte-yff65c {position:fixed;background:transparent;border:1px dashed rgba(255,255,255,0.5);outline:none;font-size:16px;font-weight:bold;font-family:sans-serif;padding:2px 4px;z-index:2147483647;min-width:80px;}.loading.svelte-yff65c {color:#9ca3af;font-size:14px;}`};function AnnotationEditor(e,t){push(t,!0),append_styles(e,$$css$7);let n=prop(t,"imageDataUrl",7),r=prop(t,"onsave",7),o=prop(t,"oncancel",7),s=state("arrow"),i=state(proxy(ANNOTATION_COLORS[0])),a=state(proxy([])),l=state(void 0),u=state(void 0),c=state(0),d=state(0),p=state(!1),g=state("idle"),_={x:0,y:0},y=[],h=state(void 0),f=state(proxy({x:0,y:0})),b=state(proxy({left:"0px",top:"0px"})),m=state("");onMount(()=>{setAnnotationEditorOpen(!0);const A=new Image;A.onload=()=>{set(c,A.naturalWidth,!0),set(d,A.naturalHeight,!0),set(p,!0),requestAnimationFrame(()=>S(A))},A.src=n()}),onDestroy(()=>{setAnnotationEditorOpen(!1)});function x(){return new Promise((A,O)=>{const L=new Image;L.onload=()=>A(L),L.onerror=O,L.src=n()})}async function S(A){if(!get(l))return;const O=get(l).getContext("2d");O&&(A||(A=await x()),get(l).width=get(c),get(l).height=get(d),O.drawImage(A,0,0,get(c),get(d)),renderAllShapes(O,get(a)))}function N(){if(!get(u))return;const A=get(u).getContext("2d");A&&(get(u).width=get(c),get(u).height=get(d),A.clearRect(0,0,get(c),get(d)))}function M(A){if(!get(u))return{x:0,y:0};const O=get(u).getBoundingClientRect(),L=get(c)/O.width,F=get(d)/O.height;return{x:(A.clientX-O.left)*L,y:(A.clientY-O.top)*F}}function P(A){if(!get(u))return{left:"0px",top:"0px"};const O=get(u).getBoundingClientRect();return{left:`${O.left+A.x/(get(c)/O.width)}px`,top:`${O.top+A.y/(get(d)/O.height)}px`}}function re(A){const O={color:get(i),strokeWidth:DEFAULT_STROKE_WIDTH};switch(get(s)){case"arrow":return{...O,id:nextShapeId(),type:"arrow",start:_,end:A};case"rectangle":return{...O,id:nextShapeId(),type:"rectangle",start:_,end:A};case"ellipse":return{...O,id:nextShapeId(),type:"ellipse",start:_,end:A};case"freehand":return{...O,id:nextShapeId(),type:"freehand",points:[...y,A]};default:return null}}function oe(A){if(get(g)==="typing"){_e();return}const O=M(A);if(get(s)==="text"){set(g,"typing"),set(f,O,!0),set(b,P(O),!0),set(m,""),requestAnimationFrame(()=>{var L;return(L=get(h))==null?void 0:L.focus()});return}set(g,"drawing"),_=O,y=[O]}function ne(A){if(get(g)!=="drawing")return;const O=M(A);get(s)==="freehand"&&y.push(O),N();const L=re(O);if(L&&get(u)){const F=get(u).getContext("2d");F&&renderShape(F,L)}}function ce(A){if(get(g)!=="drawing")return;const O=M(A),L=re(O);L&&set(a,[...get(a),L],!0),set(g,"idle"),y=[],N(),S()}function _e(){if(get(m).trim()){const A={id:nextShapeId(),type:"text",color:get(i),strokeWidth:DEFAULT_STROKE_WIDTH,position:get(f),content:get(m).trim(),fontSize:20};set(a,[...get(a),A],!0),S()}set(m,""),set(g,"idle")}function ge(A){A.key==="Enter"?(A.preventDefault(),_e()):A.key==="Escape"&&(A.preventDefault(),set(m,""),set(g,"idle"))}function $e(){get(a).length!==0&&(set(a,get(a).slice(0,-1),!0),S())}function be(){set(a,[],!0),S()}async function ye(){if(get(a).length===0){r()(n());return}const A=await mergeAnnotation(n(),get(a),get(c),get(d));r()(A)}function de(){o()()}function v(A){A.stopPropagation(),A.key==="Escape"&&get(g)!=="typing"&&de(),(A.ctrlKey||A.metaKey)&&A.key==="z"&&(A.preventDefault(),$e())}const w={arrow:"M5 19L19 5M19 5H9M19 5V15",rectangle:"M3 3h18v18H3z",ellipse:"",freehand:"M3 17c1-2 3-6 5-6s3 4 5 4 3-6 5-6 2 4 3 4",text:"M6 4v16M18 4v16M6 12h12M8 4h-4M20 4h-4M8 20h-4M20 20h-4"},z={arrow:"Arrow",rectangle:"Rect",ellipse:"Ellipse",freehand:"Draw",text:"Text"},I=["arrow","rectangle","ellipse","freehand","text"];var k={get imageDataUrl(){return n()},set imageDataUrl(A){n(A),flushSync()},get onsave(){return r()},set onsave(A){r(A),flushSync()},get oncancel(){return o()},set oncancel(A){o(A),flushSync()}},U=root$5(),D=child(U),K=child(D);each(K,21,()=>I,index,(A,O)=>{var L=root_1$6();let F;var q=child(L);{var C=xe=>{var Ue=root_2$6();append(xe,Ue)},H=xe=>{var Ue=root_3$5(),Ke=child(Ue);reset(Ue),template_effect(()=>set_attribute(Ke,"d",w[get(O)])),append(xe,Ue)};if_block(q,xe=>{get(O)==="ellipse"?xe(C):xe(H,!1)})}var se=sibling(q,2),ke=child(se,!0);reset(se),reset(L),template_effect(()=>{F=set_class(L,1,"tool-btn svelte-yff65c",null,F,{active:get(s)===get(O)}),set_attribute(L,"title",z[get(O)]),set_text(ke,z[get(O)])}),delegated("click",L,()=>{set(s,get(O),!0)}),append(A,L)}),reset(K);var j=sibling(K,4);each(j,21,()=>ANNOTATION_COLORS,index,(A,O)=>{var L=root_4$3();let F;template_effect(()=>{F=set_class(L,1,"color-swatch svelte-yff65c",null,F,{active:get(i)===get(O)}),set_style(L,`background: ${get(O)??""}; ${get(O)==="#111827"?"border-color: #6b7280;":""}`),set_attribute(L,"title",get(O))}),delegated("click",L,()=>{set(i,get(O),!0)}),append(A,L)}),reset(j);var J=sibling(j,4),ee=child(J),ie=sibling(ee,2);reset(J);var R=sibling(J,4),Z=child(R),W=sibling(Z,2);reset(R),reset(D);var T=sibling(D,2),V=child(T);{var Q=A=>{var O=root_5$3(),L=first_child(O);bind_this(L,C=>set(l,C),()=>get(l));var F=sibling(L,2);let q;bind_this(F,C=>set(u,C),()=>get(u)),template_effect(()=>{set_attribute(L,"width",get(c)),set_attribute(L,"height",get(d)),set_attribute(F,"width",get(c)),set_attribute(F,"height",get(d)),q=set_class(F,1,"overlay-canvas svelte-yff65c",null,q,{"cursor-crosshair":get(s)!=="text","cursor-text":get(s)==="text"})}),delegated("mousedown",F,oe),delegated("mousemove",F,ne),delegated("mouseup",F,ce),append(A,O)},G=A=>{var O=root_6$4();append(A,O)};if_block(V,A=>{get(p)?A(Q):A(G,!1)})}reset(T);var we=sibling(T,2);{var fe=A=>{var O=root_7$4();remove_input_defaults(O),bind_this(O,L=>set(h,L),()=>get(h)),template_effect(()=>set_style(O,`left: ${get(b).left??""}; top: ${get(b).top??""}; color: ${get(i)??""};`)),delegated("keydown",O,ge),event("blur",O,_e),bind_value(O,()=>get(m),L=>set(m,L)),append(A,O)};if_block(we,A=>{get(g)==="typing"&&A(fe)})}return reset(U),template_effect(()=>{ee.disabled=get(a).length===0,ie.disabled=get(a).length===0}),delegated("keydown",U,v),delegated("keyup",U,A=>A.stopPropagation()),event("keypress",U,A=>A.stopPropagation()),delegated("click",ee,$e),delegated("click",ie,be),delegated("click",Z,de),delegated("click",W,ye),append(e,U),pop(k)}delegate(["keydown","keyup","click","mousedown","mousemove","mouseup"]),create_custom_element(AnnotationEditor,{imageDataUrl:{},onsave:{},oncancel:{}},[],[],{mode:"open"});var root_2$5=from_html('<div class="log-entry svelte-x1hlqn"><span class="log-type svelte-x1hlqn"> </span> <span class="log-msg svelte-x1hlqn"> </span></div>'),root_3$4=from_html('<div class="log-more svelte-x1hlqn"> </div>'),root_1$5=from_html('<div class="log-list svelte-x1hlqn"><div class="log-header svelte-x1hlqn"> </div> <div class="log-scroll svelte-x1hlqn"><!> <!></div></div>');const $$css$6={hash:"svelte-x1hlqn",code:".log-list.svelte-x1hlqn {border:1px solid #374151;border-radius:6px;overflow:hidden;}.log-header.svelte-x1hlqn {padding:6px 10px;background:#1f2937;font-size:11px;font-weight:600;color:#d1d5db;border-bottom:1px solid #374151;}.log-scroll.svelte-x1hlqn {max-height:140px;overflow-y:auto;background:#111827;}.log-entry.svelte-x1hlqn {padding:4px 10px;font-size:11px;font-family:'SF Mono', 'Fira Code', 'Cascadia Code', monospace;display:flex;gap:8px;border-bottom:1px solid #1f293780;line-height:1.4;}.log-type.svelte-x1hlqn {font-weight:600;text-transform:uppercase;font-size:10px;min-width:40px;flex-shrink:0;}.log-msg.svelte-x1hlqn {color:#d1d5db;word-break:break-word;}.log-more.svelte-x1hlqn {padding:4px 10px;font-size:10px;color:#6b7280;text-align:center;}"};function ConsoleLogList(e,t){push(t,!0),append_styles(e,$$css$6);let n=prop(t,"logs",23,()=>[]);const r={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",log:"#9ca3af",debug:"#8b5cf6",trace:"#6b7280"};var o={get logs(){return n()},set logs(l=[]){n(l),flushSync()}},s=comment(),i=first_child(s);{var a=l=>{var u=root_1$5(),c=child(u),d=child(c);reset(c);var p=sibling(c,2),g=child(p);each(g,17,()=>n().slice(-10),index,(h,f)=>{var b=root_2$5(),m=child(b),x=child(m,!0);reset(m);var S=sibling(m,2),N=child(S);reset(S),reset(b),template_effect(M=>{set_style(m,`color: ${(r[get(f).type]||"#9ca3af")??""}`),set_text(x,get(f).type),set_text(N,`${M??""}${get(f).message.length>120?"...":""}`)},[()=>get(f).message.substring(0,120)]),append(h,b)});var _=sibling(g,2);{var y=h=>{var f=root_3$4(),b=child(f);reset(f),template_effect(()=>set_text(b,`+${n().length-10} more`)),append(h,f)};if_block(_,h=>{n().length>10&&h(y)})}reset(p),reset(u),template_effect(()=>set_text(d,`Console Logs (${n().length??""})`)),append(l,u)};if_block(i,l=>{n().length>0&&l(a)})}return append(e,s),pop(o)}create_custom_element(ConsoleLogList,{logs:{}},[],[],{mode:"open"});var root_2$4=from_svg('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M3 8L6.5 11.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),root_3$3=from_svg('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.5"></circle><path d="M8 5V8.5M8 10.5V11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>'),root_1$4=from_html('<div><span class="icon svelte-1f5s7q1"><!></span> <span class="msg"> </span></div>');const $$css$5={hash:"svelte-1f5s7q1",code:`.jat-toast.svelte-1f5s7q1 {position:absolute;bottom:70px;right:0;padding:10px 16px;border-radius:8px;font-size:13px;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;display:flex;align-items:center;gap:8px;box-shadow:0 4px 12px rgba(0,0,0,0.2);
49
49
  animation: svelte-1f5s7q1-toast-in 0.3s ease;white-space:nowrap;}.success.svelte-1f5s7q1 {background:#065f46;color:#d1fae5;border:1px solid #10b981;}.error.svelte-1f5s7q1 {background:#7f1d1d;color:#fecaca;border:1px solid #ef4444;}.icon.svelte-1f5s7q1 {display:flex;align-items:center;}
50
50
  @keyframes svelte-1f5s7q1-toast-in {
51
51
  from { opacity: 0; transform: translateY(8px); }
@@ -64,7 +64,7 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
64
64
 
65
65
  /* Thread container */.thread.svelte-1fnmin5 {margin-top:6px;display:flex;flex-direction:column;gap:4px;}.thread-entry.svelte-1fnmin5 {padding:6px 8px;border-radius:5px;font-size:12px;border-left:2px solid;}.thread-user.svelte-1fnmin5 {background:#111827;border-left-color:#6b7280;}.thread-dev.svelte-1fnmin5 {background:#0f172a;border-left-color:#3b82f6;}.thread-entry-header.svelte-1fnmin5 {display:flex;align-items:center;gap:6px;margin-bottom:3px;}.thread-from.svelte-1fnmin5 {font-weight:600;font-size:11px;color:#d1d5db;}.thread-type-badge.svelte-1fnmin5 {font-size:9px;font-weight:600;padding:1px 5px;border-radius:3px;text-transform:uppercase;letter-spacing:0.3px;}.thread-type-badge.submission.svelte-1fnmin5 {background:#6b728020;color:#9ca3af;}.thread-type-badge.completion.svelte-1fnmin5 {background:#3b82f620;color:#60a5fa;}.thread-type-badge.rejection.svelte-1fnmin5 {background:#ef444420;color:#f87171;}.thread-type-badge.acceptance.svelte-1fnmin5 {background:#10b98120;color:#34d399;}.thread-time.svelte-1fnmin5 {font-size:10px;color:#4b5563;margin-left:auto;}.thread-message.svelte-1fnmin5 {color:#d1d5db;line-height:1.5;margin:0;word-break:break-word;}.thread-summary.svelte-1fnmin5 {margin:4px 0 0 0;padding:0 0 0 16px;font-size:11px;color:#9ca3af;}.thread-summary.svelte-1fnmin5 li:where(.svelte-1fnmin5) {margin:1px 0;}.thread-screenshots.svelte-1fnmin5 {display:flex;gap:4px;margin-top:4px;}.thread-elements.svelte-1fnmin5 {display:flex;gap:3px;flex-wrap:wrap;margin-top:4px;}.element-badge.svelte-1fnmin5 {font-size:10px;font-family:'SF Mono', 'Fira Code', 'Consolas', monospace;padding:1px 5px;background:#1e293b;border:1px solid #334155;border-radius:3px;color:#94a3b8;}.element-badge.removable.svelte-1fnmin5 {display:inline-flex;align-items:center;gap:3px;}.element-remove.svelte-1fnmin5 {background:none;border:none;color:#6b7280;cursor:pointer;padding:0;font-size:12px;line-height:1;}.element-remove.svelte-1fnmin5:hover {color:#ef4444;}
66
66
 
67
- /* Enhanced rejection form */.reject-attachments.svelte-1fnmin5 {display:flex;gap:6px;margin-top:6px;}.attach-btn.svelte-1fnmin5 {display:flex;align-items:center;gap:4px;padding:3px 8px;background:#111827;border:1px solid #374151;border-radius:4px;color:#9ca3af;font-size:11px;cursor:pointer;font-family:inherit;transition:border-color 0.15s, color 0.15s;}.attach-btn.svelte-1fnmin5:hover:not(:disabled) {border-color:#60a5fa;color:#d1d5db;}.attach-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.reject-preview-strip.svelte-1fnmin5 {display:flex;gap:4px;margin-top:6px;overflow-x:auto;}.reject-preview-item.svelte-1fnmin5 {position:relative;flex-shrink:0;width:52px;height:36px;border-radius:4px;overflow:hidden;border:1px solid #374151;}.reject-preview-item.svelte-1fnmin5 img:where(.svelte-1fnmin5) {width:100%;height:100%;object-fit:cover;display:block;}.reject-preview-remove.svelte-1fnmin5 {position:absolute;top:1px;right:1px;width:14px;height:14px;border-radius:50%;background:rgba(0,0,0,0.7);color:#e5e7eb;border:none;cursor:pointer;font-size:10px;line-height:1;display:flex;align-items:center;justify-content:center;}.reject-preview-remove.svelte-1fnmin5:hover {background:#ef4444;}.reject-element-strip.svelte-1fnmin5 {display:flex;gap:3px;flex-wrap:wrap;margin-top:6px;}.report-footer.svelte-1fnmin5 {display:flex;align-items:center;justify-content:space-between;margin-top:8px;}.report-time.svelte-1fnmin5 {font-size:11px;color:#6b7280;}.status-pill.svelte-1fnmin5 {font-size:11px;font-weight:600;padding:2px 8px;border-radius:4px;}.status-pill.accepted.svelte-1fnmin5 {color:#10b981;background:#10b98118;}.status-pill.rejected.svelte-1fnmin5 {color:#ef4444;background:#ef444418;}.response-actions.svelte-1fnmin5 {display:flex;gap:6px;}.accept-btn.svelte-1fnmin5, .reject-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid;font-family:inherit;transition:background 0.15s;}.accept-btn.svelte-1fnmin5 {background:#10b98118;color:#10b981;border-color:#10b98140;}.accept-btn.svelte-1fnmin5:hover:not(:disabled) {background:#10b98130;}.reject-btn.svelte-1fnmin5 {background:#ef444418;color:#ef4444;border-color:#ef444440;}.reject-btn.svelte-1fnmin5:hover:not(:disabled) {background:#ef444430;}.accept-btn.svelte-1fnmin5:disabled, .reject-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.reject-reason-form.svelte-1fnmin5 {width:100%;margin-top:6px;}.reject-reason-input.svelte-1fnmin5 {width:100%;padding:6px 8px;background:#111827;border:1px solid #374151;border-radius:5px;color:#d1d5db;font-size:12px;font-family:inherit;resize:vertical;min-height:40px;}.reject-reason-input.svelte-1fnmin5:focus {outline:none;border-color:#ef4444;}.reject-reason-actions.svelte-1fnmin5 {display:flex;justify-content:flex-end;gap:6px;margin-top:6px;}.cancel-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid #374151;background:#1f2937;color:#9ca3af;font-family:inherit;transition:background 0.15s;}.cancel-btn.svelte-1fnmin5:hover {background:#374151;}.confirm-reject-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid #ef444440;background:#ef444418;color:#ef4444;font-family:inherit;transition:background 0.15s;}.confirm-reject-btn.svelte-1fnmin5:hover:not(:disabled) {background:#ef444430;}.confirm-reject-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.char-hint.svelte-1fnmin5 {display:block;font-size:10px;color:#6b7280;margin-top:3px;}`};function RequestList(e,t){push(t,!0),append_styles(e,$$css$4);let n=prop(t,"endpoint",7),r=prop(t,"reports",31,()=>proxy([])),o=prop(t,"loading",7),s=prop(t,"error",7),i=prop(t,"onreload",7),a=state(null),l=state(null),u=state(null),c=state(void 0),d=state(""),p=state(""),g=state(""),_=state(proxy([])),y=state(proxy([])),h=state(!1),f=state("active"),b=user_derived(()=>get(f)==="active"?r().filter(T=>["submitted","in_progress","rejected","completed","wontfix"].includes(T.status)):r().filter(T=>T.status==="accepted"||T.status==="closed")),m=user_derived(()=>r().filter(T=>["submitted","in_progress","rejected","completed","wontfix"].includes(T.status)).length),x=user_derived(()=>r().filter(T=>T.status==="accepted"||T.status==="closed").length);function S(T){return T?T.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/^#{1,3} (.+)$/gm,'<strong style="display:block;margin-top:6px;color:#f3f4f6">$1</strong>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/^[-*] (.+)$/gm,'<span style="display:block;padding-left:10px">• $1</span>').replace(/\n/g,"<br>"):""}function N(T){const V=get(u)===T;set(u,V?null:T,!0),V?(get(l)===T&&set(l,null),set(a,null)):setTimeout(()=>{if(!get(c))return;const Q=get(c).querySelector(`[data-card-id="${T}"]`);Q&&Q.scrollIntoView({behavior:"smooth",block:"nearest"})},220)}function P(T){set(p,T,!0),set(g,""),set(_,[],!0),set(y,[],!0)}function M(){set(p,""),set(g,""),set(_,[],!0),set(y,[],!0)}async function re(){if(!get(h)){set(h,!0);try{const T=await captureViewport();set(_,[...get(_),T],!0)}catch(T){console.error("Screenshot capture failed:",T)}set(h,!1)}}function oe(T){set(_,get(_).filter((V,Q)=>Q!==T),!0)}function ne(){startElementPicker(T=>{set(y,[...get(y),{tagName:T.tagName,className:T.className,id:T.id,selector:T.selector,textContent:T.textContent}],!0)})}function ce(T){set(y,get(y).filter((V,Q)=>Q!==T),!0)}async function _e(T,V,Q){set(d,T,!0);const G=V==="rejected"?{screenshots:get(_).length>0?get(_):void 0,elements:get(y).length>0?get(y):void 0}:void 0;(await respondToReport(n(),T,V,Q,G)).ok?(r(r().map(fe=>fe.id===T?{...fe,status:V==="rejected"?"submitted":"accepted",responded_at:new Date().toISOString(),...V==="rejected"?{revision_count:(fe.revision_count||0)+1}:{}}:fe)),set(p,""),set(g,""),set(_,[],!0),set(y,[],!0),i()()):set(p,""),set(d,"")}function ge(T){set(l,get(l)===T?null:T,!0)}function $e(T){return T?T.length:0}function be(T){return{submission:"Submitted",completion:"Completed",rejection:"Rejected",acceptance:"Accepted",note:"Note"}[T.type]||T.type}function ye(T){return{submitted:"Submitted",in_progress:"Working On It",completed:"Ready for Review",accepted:"Done",rejected:"Revising",wontfix:"Won't Fix",closed:"Closed"}[T]||T}function de(T){return{submitted:"#6b7280",in_progress:"#3b82f6",completed:"#f59e0b",accepted:"#10b981",rejected:"#f59e0b",wontfix:"#6b7280",closed:"#6b7280"}[T]||"#6b7280"}function v(T){return T==="bug"?"🐛":T==="enhancement"?"✨":"📝"}function w(T){const V=Date.now(),Q=new Date(T).getTime(),G=V-Q,we=Math.floor(G/6e4);if(we<1)return"just now";if(we<60)return`${we}m ago`;const fe=Math.floor(we/60);if(fe<24)return`${fe}h ago`;const A=Math.floor(fe/24);return A<30?`${A}d ago`:new Date(T).toLocaleDateString()}var z={get endpoint(){return n()},set endpoint(T){n(T),flushSync()},get reports(){return r()},set reports(T=[]){r(T),flushSync()},get loading(){return o()},set loading(T){o(T),flushSync()},get error(){return s()},set error(T){s(T),flushSync()},get onreload(){return i()},set onreload(T){i(T),flushSync()}},R=root$4(),k=child(R),U=child(k);let D;var K=sibling(child(U));{var j=T=>{var V=root_1$3(),Q=child(V,!0);reset(V),template_effect(()=>set_text(Q,get(m))),append(T,V)};if_block(K,T=>{get(m)>0&&T(j)})}reset(U);var J=sibling(U,2);let ee;var ie=sibling(child(J));{var I=T=>{var V=root_2$3(),Q=child(V,!0);reset(V),template_effect(()=>set_text(Q,get(x))),append(T,V)};if_block(ie,T=>{get(x)>0&&T(I)})}reset(J),reset(k);var Z=sibling(k,2),W=child(Z);return key(W,()=>get(f),T=>{var V=root_3$2(),Q=child(V);{var G=L=>{var F=root_4$2();append(L,F)},we=L=>{var F=root_5$2(),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2);reset(F),template_effect(()=>set_text(C,s())),delegated("click",H,function(...se){var ke;(ke=i())==null||ke.apply(this,se)}),append(L,F)},fe=L=>{var F=root_6$3(),q=child(F);q.textContent="📋",next(4),reset(F),append(L,F)},A=L=>{var F=root_7$3(),q=child(F),C=child(q,!0);reset(q),reset(F),template_effect(()=>set_text(C,get(f)==="submitted"?"No submitted requests":get(f)==="review"?"Nothing to review right now":"No completed requests yet")),append(L,F)},O=L=>{var F=root_8$3();each(F,21,()=>get(b),q=>q.id,(q,C)=>{var H=root_9$2();let se;var ke=child(H),xe=child(ke),Ue=child(xe,!0);reset(xe);var Ke=sibling(xe,2),rt=child(Ke,!0);reset(Ke);var Be=sibling(Ke,2),Kt=child(Be,!0);reset(Be);var Fe=sibling(Be,2);let Pe;reset(ke);var ft=sibling(ke,2);{var Jt=pt=>{var me=root_10$2(),Ee=child(me);{var Me=pe=>{var ve=root_11$2(),Re=sibling(child(ve),2),qe=child(Re,!0);reset(Re),reset(ve),template_effect($t=>{set_attribute(ve,"href",get(C).page_url),set_text(qe,$t)},[()=>get(C).page_url.replace(/^https?:\/\//,"").split("?")[0]]),append(pe,ve)};if_block(Ee,pe=>{get(C).page_url&&pe(Me)})}var lt=sibling(Ee,2);{var Et=pe=>{var ve=root_12$2(),Re=child(ve);reset(ve),template_effect(()=>set_text(Re,`Revision ${get(C).revision_count??""}`)),append(pe,ve)};if_block(lt,pe=>{get(C).revision_count>0&&get(C).status!=="accepted"&&pe(Et)})}var zn=sibling(lt,2);{var yn=pe=>{var ve=root_13$2(),Re=first_child(ve),qe=child(Re);let $t;var Je=sibling(qe,2),Ve=child(Je);reset(Je),reset(Re);var Ie=sibling(Re,2);{var We=Ce=>{var $=root_14$3();each($,21,()=>get(C).thread,B=>B.id,(B,Y)=>{var he=root_15$3();let He;var Ft=child(he),ht=child(Ft),jt=child(ht,!0);reset(ht);var Qe=sibling(ht,2);let en;var Bt=child(Qe,!0);reset(Qe);var Vt=sibling(Qe,2),tn=child(Vt,!0);reset(Vt),reset(Ft);var ze=sibling(Ft,2),Ge=child(ze);html(Ge,()=>S(get(Y).message)),reset(ze);var St=sibling(ze,2);{var gt=Ne=>{var et=root_16$3();each(et,21,()=>get(Y).summary,index,(Dt,st)=>{var ct=root_17$3(),ut=child(ct,!0);reset(ct),template_effect(()=>set_text(ut,get(st))),append(Dt,ct)}),reset(et),append(Ne,et)};if_block(St,Ne=>{get(Y).summary&&get(Y).summary.length>0&&Ne(gt)})}var ot=sibling(St,2);{var vt=Ne=>{var et=root_18$2(),Dt=first_child(et);each(Dt,21,()=>get(Y).screenshots,index,(ut,Ct,zt)=>{var pn=comment(),hn=first_child(pn);{var At=Zt=>{var Rt=root_20$2();set_attribute(Rt,"aria-label",`Screenshot ${zt+1}`);var rn=child(Rt);set_attribute(rn,"alt",`Screenshot ${zt+1}`),reset(Rt),template_effect(()=>set_attribute(rn,"src",`${n()??""}${get(Ct).url??""}`)),delegated("click",Rt,()=>set(a,get(a)===get(Ct).url?null:get(Ct).url,!0)),append(Zt,Rt)};if_block(hn,Zt=>{get(Ct).url&&Zt(At)})}append(ut,pn)}),reset(Dt);var st=sibling(Dt,2);{var ct=ut=>{const Ct=user_derived(()=>get(Y).screenshots.find(At=>At.url===get(a)));var zt=comment(),pn=first_child(zt);{var hn=At=>{var Zt=root_22$2(),Rt=child(Zt),rn=sibling(Rt,2);reset(Zt),template_effect(()=>set_attribute(Rt,"src",`${n()??""}${get(a)??""}`)),delegated("click",rn,()=>set(a,null)),append(At,Zt)};if_block(pn,At=>{get(Ct)&&At(hn)})}append(ut,zt)};if_block(st,ut=>{get(a)&&ut(ct)})}append(Ne,et)};if_block(ot,Ne=>{get(Y).screenshots&&get(Y).screenshots.length>0&&Ne(vt)})}var Tt=sibling(ot,2);{var nn=Ne=>{var et=root_23$1();each(et,21,()=>get(Y).elements,index,(Dt,st)=>{var ct=root_24$1(),ut=child(ct);reset(ct),template_effect((Ct,zt)=>{set_attribute(ct,"title",get(st).selector),set_text(ut,`<${Ct??""}${get(st).id?`#${get(st).id}`:""}${zt??""}>`)},[()=>get(st).tagName.toLowerCase(),()=>get(st).className?`.${get(st).className.split(" ")[0]}`:""]),append(Dt,ct)}),reset(et),append(Ne,et)};if_block(Tt,Ne=>{get(Y).elements&&get(Y).elements.length>0&&Ne(nn)})}reset(he),template_effect((Ne,et)=>{He=set_class(he,1,"thread-entry svelte-1fnmin5",null,He,{"thread-user":get(Y).from==="user","thread-dev":get(Y).from==="dev"}),set_text(jt,get(Y).from==="user"?"You":"Dev"),en=set_class(Qe,1,"thread-type-badge svelte-1fnmin5",null,en,{submission:get(Y).type==="submission",completion:get(Y).type==="completion",rejection:get(Y).type==="rejection",acceptance:get(Y).type==="acceptance"}),set_text(Bt,Ne),set_text(tn,et)},[()=>be(get(Y)),()=>w(get(Y).at)]),append(B,he)}),reset($),append(Ce,$)};if_block(Ie,Ce=>{get(l)===get(C).id&&Ce(We)})}template_effect((Ce,$)=>{$t=set_class(qe,0,"thread-toggle-icon svelte-1fnmin5",null,$t,{expanded:get(l)===get(C).id}),set_text(Ve,`${Ce??""} ${$??""}`)},[()=>$e(get(C).thread),()=>$e(get(C).thread)===1?"message":"messages"]),delegated("click",Re,()=>ge(get(C).id)),append(pe,ve)},wn=pe=>{var ve=root_25$1(),Re=child(ve,!0);reset(ve),template_effect(qe=>set_text(Re,qe),[()=>get(C).description.length>120?get(C).description.slice(0,120)+"...":get(C).description]),append(pe,ve)};if_block(zn,pe=>{get(C).thread&&get(C).thread.length>0?pe(yn):get(C).description&&pe(wn,1)})}var xn=sibling(zn,2);{var Qt=pe=>{var ve=root_26$1(),Re=first_child(ve);each(Re,21,()=>get(C).screenshot_urls,index,(Ve,Ie,We)=>{var Ce=root_27();set_attribute(Ce,"aria-label",`Screenshot ${We+1}`);var $=child(Ce);set_attribute($,"alt",`Screenshot ${We+1}`),reset(Ce),template_effect(()=>set_attribute($,"src",`${n()??""}${get(Ie)??""}`)),delegated("click",Ce,()=>set(a,get(a)===get(Ie)?null:get(Ie),!0)),append(Ve,Ce)}),reset(Re);var qe=sibling(Re,2);{var $t=Ve=>{var Ie=root_28(),We=child(Ie),Ce=sibling(We,2);reset(Ie),template_effect(()=>set_attribute(We,"src",`${n()??""}${get(a)??""}`)),delegated("click",Ce,()=>set(a,null)),append(Ve,Ie)},Je=user_derived(()=>get(a)&&get(C).screenshot_urls.includes(get(a)));if_block(qe,Ve=>{get(Je)&&Ve($t)})}append(pe,ve)};if_block(xn,pe=>{!get(C).thread&&get(C).screenshot_urls&&get(C).screenshot_urls.length>0&&pe(Qt)})}var kn=sibling(xn,2);{var Mn=pe=>{var ve=root_29(),Re=sibling(child(ve),2),qe=child(Re);html(qe,()=>S(get(C).dev_notes)),reset(Re),reset(ve),append(pe,ve)};if_block(kn,pe=>{get(C).dev_notes&&!get(C).thread&&get(C).status!=="in_progress"&&pe(Mn)})}var An=sibling(kn,2),fn=child(An),Fn=child(fn,!0);reset(fn);var Rn=sibling(fn,2);{var In=pe=>{var ve=root_30();ve.textContent="✓ Accepted",append(pe,ve)},Dn=pe=>{var ve=root_31();ve.textContent="✗ Rejected",append(pe,ve)},Nn=pe=>{var ve=comment(),Re=first_child(ve);{var qe=Je=>{var Ve=root_33(),Ie=child(Ve);remove_textarea_child(Ie);var We=sibling(Ie,2),Ce=child(We),$=sibling(child(Ce));reset(Ce);var B=sibling(Ce,2);reset(We);var Y=sibling(We,2);{var he=ze=>{var Ge=root_34();each(Ge,21,()=>get(_),index,(St,gt,ot)=>{var vt=root_35(),Tt=child(vt);set_attribute(Tt,"alt",`Screenshot ${ot+1}`);var nn=sibling(Tt,2);reset(vt),template_effect(()=>set_attribute(Tt,"src",get(gt))),delegated("click",nn,()=>oe(ot)),append(St,vt)}),reset(Ge),append(ze,Ge)};if_block(Y,ze=>{get(_).length>0&&ze(he)})}var He=sibling(Y,2);{var Ft=ze=>{var Ge=root_36();each(Ge,21,()=>get(y),index,(St,gt,ot)=>{var vt=root_37(),Tt=child(vt),nn=sibling(Tt);reset(vt),template_effect(Ne=>set_text(Tt,`<${Ne??""}${get(gt).id?`#${get(gt).id}`:""}> `),[()=>get(gt).tagName.toLowerCase()]),delegated("click",nn,()=>ce(ot)),append(St,vt)}),reset(Ge),append(ze,Ge)};if_block(He,ze=>{get(y).length>0&&ze(Ft)})}var ht=sibling(He,2),jt=child(ht),Qe=sibling(jt,2),en=child(Qe,!0);reset(Qe),reset(ht);var Bt=sibling(ht,2);{var Vt=ze=>{var Ge=root_38(),St=child(Ge);reset(Ge),template_effect(gt=>set_text(St,`${gt??""} more characters needed`),[()=>10-get(g).trim().length]),append(ze,Ge)},tn=user_derived(()=>get(g).trim().length>0&&get(g).trim().length<10);if_block(Bt,ze=>{get(tn)&&ze(Vt)})}reset(Ve),template_effect(ze=>{Ce.disabled=get(h),set_text($,` ${get(h)?"...":"Screenshot"}`),Qe.disabled=ze,set_text(en,get(d)===get(C).id?"...":"✗ Reject")},[()=>get(g).trim().length<10||get(d)===get(C).id]),bind_value(Ie,()=>get(g),ze=>set(g,ze)),delegated("click",Ce,re),delegated("click",B,ne),delegated("click",jt,M),delegated("click",Qe,()=>_e(get(C).id,"rejected",get(g).trim())),append(Je,Ve)},$t=Je=>{var Ve=root_39(),Ie=child(Ve),We=child(Ie,!0);reset(Ie);var Ce=sibling(Ie,2);Ce.textContent="✗ Reject",reset(Ve),template_effect(()=>{Ie.disabled=get(d)===get(C).id,set_text(We,get(d)===get(C).id?"...":"✓ Accept"),Ce.disabled=get(d)===get(C).id}),delegated("click",Ie,()=>_e(get(C).id,"accepted")),delegated("click",Ce,()=>P(get(C).id)),append(Je,Ve)};if_block(Re,Je=>{get(p)===get(C).id?Je(qe):Je($t,!1)})}append(pe,ve)};if_block(Rn,pe=>{get(C).status==="accepted"?pe(In):get(C).status==="rejected"?pe(Dn,1):(get(C).status==="completed"||get(C).status==="wontfix")&&pe(Nn,2)})}reset(An),reset(me),template_effect(pe=>set_text(Fn,pe),[()=>w(get(C).created_at)]),transition(3,me,()=>slide,()=>({duration:200})),append(pt,me)};if_block(ft,pt=>{get(u)===get(C).id&&pt(Jt)})}reset(H),template_effect((pt,me,Ee,Me,lt)=>{se=set_class(H,1,"report-card svelte-1fnmin5",null,se,{awaiting:get(C).status==="completed",expanded:get(u)===get(C).id}),set_attribute(H,"data-card-id",get(C).id),set_text(Ue,pt),set_text(rt,get(C).title),set_style(Be,`background: ${me??""}20; color: ${Ee??""}; border-color: ${Me??""}40;`),set_text(Kt,lt),Pe=set_class(Fe,0,"chevron svelte-1fnmin5",null,Pe,{"chevron-open":get(u)===get(C).id})},[()=>v(get(C).type),()=>de(get(C).status),()=>de(get(C).status),()=>de(get(C).status),()=>ye(get(C).status)]),delegated("click",ke,()=>N(get(C).id)),append(q,H)}),reset(F),append(L,F)};if_block(Q,L=>{o()?L(G):s()&&r().length===0?L(we,1):r().length===0?L(fe,2):get(b).length===0?L(A,3):L(O,!1)})}reset(V),transition(3,V,()=>slide,()=>({duration:200})),append(T,V)}),reset(Z),bind_this(Z,T=>set(c,T),()=>get(c)),reset(R),template_effect(()=>{D=set_class(U,1,"subtab svelte-1fnmin5",null,D,{active:get(f)==="active"}),ee=set_class(J,1,"subtab svelte-1fnmin5",null,ee,{active:get(f)==="done"})}),delegated("click",U,()=>set(f,"active")),delegated("click",J,()=>set(f,"done")),append(e,R),pop(z)}delegate(["click"]),create_custom_element(RequestList,{endpoint:{},reports:{},loading:{},error:{},onreload:{}},[],[],{mode:"open"});var root_6$2=from_html('<span class="step-counter svelte-bez0nz"> </span>'),root_7$2=from_html('<div class="empty-state svelte-bez0nz"><div class="empty-icon svelte-bez0nz"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor" opacity="0.3" class="svelte-bez0nz"></path><path d="M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none" class="svelte-bez0nz"></path></svg></div> <p class="empty-text svelte-bez0nz">Tell the agent what to do on this page</p> <p class="empty-hint svelte-bez0nz">e.g. "Fill in the contact form" or "Click the sign up button"</p></div>'),root_14$2=from_html('<span class="msg-tool svelte-bez0nz"> </span>'),root_15$2=from_html('<div class="approval-buttons svelte-bez0nz"><button class="approve-btn svelte-bez0nz"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M20 6L9 17l-5-5" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-bez0nz"></path></svg> Approve</button> <button class="skip-btn svelte-bez0nz"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M5 5l14 14M19 5L5 19" stroke="currentColor" stroke-width="2" stroke-linecap="round" class="svelte-bez0nz"></path></svg> Skip</button></div>'),root_16$2=from_html("<span> </span>"),root_17$2=from_html('<span class="msg-step svelte-bez0nz"> </span>'),root_10$1=from_html('<div><span class="msg-icon svelte-bez0nz"><!></span> <div class="msg-body svelte-bez0nz"><!> <span class="msg-text svelte-bez0nz"> </span> <!></div> <!></div>'),root_19$1=from_html('<span class="msg-tool svelte-bez0nz"> </span>'),root_20$1=from_html('<span class="msg-duration svelte-bez0nz"> </span>'),root_21$1=from_html('<span class="msg-step svelte-bez0nz"> </span>'),root_18$1=from_html('<div><span class="msg-icon svelte-bez0nz"> </span> <div class="msg-body svelte-bez0nz"><!> <span class="msg-text svelte-bez0nz"> </span> <!></div> <!></div>'),root_22$1=from_html('<div class="message msg-thinking live svelte-bez0nz"><span class="msg-icon svelte-bez0nz">…</span> <div class="msg-body svelte-bez0nz"><span class="thinking-dots svelte-bez0nz"><span class="dot svelte-bez0nz"></span> <span class="dot svelte-bez0nz"></span> <span class="dot svelte-bez0nz"></span></span></div></div>'),root_8$2=from_html("<!> <!>",1),root_23=from_html('<button class="stop-btn svelte-bez0nz" aria-label="Stop agent"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" class="svelte-bez0nz"><rect x="6" y="6" width="12" height="12" rx="1" class="svelte-bez0nz"></rect></svg> Stop</button>'),root$3=from_html('<div class="agent-panel svelte-bez0nz"><div class="status-bar svelte-bez0nz"><div><span class="status-dot svelte-bez0nz"></span> <span class="status-text svelte-bez0nz"><!></span></div> <div class="status-right svelte-bez0nz"><!> <label class="auto-approve-toggle svelte-bez0nz" title="Auto-approve all actions"><input type="checkbox" class="svelte-bez0nz"/> <span class="toggle-label svelte-bez0nz">Auto</span></label></div></div> <div class="messages svelte-bez0nz"><!></div> <div class="input-area svelte-bez0nz"><!> <div class="input-row svelte-bez0nz"><input type="text" class="chat-input svelte-bez0nz"/> <button class="send-btn svelte-bez0nz" aria-label="Send"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-bez0nz"></path></svg></button></div></div></div>');const $$css$3={hash:"svelte-bez0nz",code:`.agent-panel.svelte-bez0nz {display:flex;flex-direction:column;height:100%;min-height:0;font-family:inherit;color:#e5e7eb;}
67
+ /* Enhanced rejection form */.reject-attachments.svelte-1fnmin5 {display:flex;gap:6px;margin-top:6px;}.attach-btn.svelte-1fnmin5 {display:flex;align-items:center;gap:4px;padding:3px 8px;background:#111827;border:1px solid #374151;border-radius:4px;color:#9ca3af;font-size:11px;cursor:pointer;font-family:inherit;transition:border-color 0.15s, color 0.15s;}.attach-btn.svelte-1fnmin5:hover:not(:disabled) {border-color:#60a5fa;color:#d1d5db;}.attach-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.reject-preview-strip.svelte-1fnmin5 {display:flex;gap:4px;margin-top:6px;overflow-x:auto;}.reject-preview-item.svelte-1fnmin5 {position:relative;flex-shrink:0;width:52px;height:36px;border-radius:4px;overflow:hidden;border:1px solid #374151;}.reject-preview-item.svelte-1fnmin5 img:where(.svelte-1fnmin5) {width:100%;height:100%;object-fit:cover;display:block;}.reject-preview-remove.svelte-1fnmin5 {position:absolute;top:1px;right:1px;width:14px;height:14px;border-radius:50%;background:rgba(0,0,0,0.7);color:#e5e7eb;border:none;cursor:pointer;font-size:10px;line-height:1;display:flex;align-items:center;justify-content:center;}.reject-preview-remove.svelte-1fnmin5:hover {background:#ef4444;}.reject-element-strip.svelte-1fnmin5 {display:flex;gap:3px;flex-wrap:wrap;margin-top:6px;}.report-footer.svelte-1fnmin5 {display:flex;align-items:center;justify-content:space-between;margin-top:8px;}.report-time.svelte-1fnmin5 {font-size:11px;color:#6b7280;}.status-pill.svelte-1fnmin5 {font-size:11px;font-weight:600;padding:2px 8px;border-radius:4px;}.status-pill.accepted.svelte-1fnmin5 {color:#10b981;background:#10b98118;}.status-pill.rejected.svelte-1fnmin5 {color:#ef4444;background:#ef444418;}.response-actions.svelte-1fnmin5 {display:flex;gap:6px;}.accept-btn.svelte-1fnmin5, .reject-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid;font-family:inherit;transition:background 0.15s;}.accept-btn.svelte-1fnmin5 {background:#10b98118;color:#10b981;border-color:#10b98140;}.accept-btn.svelte-1fnmin5:hover:not(:disabled) {background:#10b98130;}.reject-btn.svelte-1fnmin5 {background:#ef444418;color:#ef4444;border-color:#ef444440;}.reject-btn.svelte-1fnmin5:hover:not(:disabled) {background:#ef444430;}.accept-btn.svelte-1fnmin5:disabled, .reject-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.reject-reason-form.svelte-1fnmin5 {width:100%;margin-top:6px;}.reject-reason-input.svelte-1fnmin5 {width:100%;padding:6px 8px;background:#111827;border:1px solid #374151;border-radius:5px;color:#d1d5db;font-size:12px;font-family:inherit;resize:vertical;min-height:40px;}.reject-reason-input.svelte-1fnmin5:focus {outline:none;border-color:#ef4444;}.reject-reason-actions.svelte-1fnmin5 {display:flex;justify-content:flex-end;gap:6px;margin-top:6px;}.cancel-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid #374151;background:#1f2937;color:#9ca3af;font-family:inherit;transition:background 0.15s;}.cancel-btn.svelte-1fnmin5:hover {background:#374151;}.confirm-reject-btn.svelte-1fnmin5 {padding:3px 10px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;border:1px solid #ef444440;background:#ef444418;color:#ef4444;font-family:inherit;transition:background 0.15s;}.confirm-reject-btn.svelte-1fnmin5:hover:not(:disabled) {background:#ef444430;}.confirm-reject-btn.svelte-1fnmin5:disabled {opacity:0.5;cursor:not-allowed;}.char-hint.svelte-1fnmin5 {display:block;font-size:10px;color:#6b7280;margin-top:3px;}`};function RequestList(e,t){push(t,!0),append_styles(e,$$css$4);let n=prop(t,"endpoint",7),r=prop(t,"reports",31,()=>proxy([])),o=prop(t,"loading",7),s=prop(t,"error",7),i=prop(t,"onreload",7),a=state(null),l=state(null),u=state(null),c=state(void 0),d=state(""),p=state(""),g=state(""),_=state(proxy([])),y=state(proxy([])),h=state(!1),f=state("active"),b=user_derived(()=>get(f)==="active"?r().filter(T=>["submitted","in_progress","rejected","completed","wontfix"].includes(T.status)):r().filter(T=>T.status==="accepted"||T.status==="closed")),m=user_derived(()=>r().filter(T=>["submitted","in_progress","rejected","completed","wontfix"].includes(T.status)).length),x=user_derived(()=>r().filter(T=>T.status==="accepted"||T.status==="closed").length);function S(T){return T?T.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/^#{1,3} (.+)$/gm,'<strong style="display:block;margin-top:6px;color:#f3f4f6">$1</strong>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/^[-*] (.+)$/gm,'<span style="display:block;padding-left:10px">• $1</span>').replace(/\n/g,"<br>"):""}function N(T){const V=get(u)===T;set(u,V?null:T,!0),V?(get(l)===T&&set(l,null),set(a,null)):setTimeout(()=>{if(!get(c))return;const Q=get(c).querySelector(`[data-card-id="${T}"]`);Q&&Q.scrollIntoView({behavior:"smooth",block:"nearest"})},220)}function M(T){set(p,T,!0),set(g,""),set(_,[],!0),set(y,[],!0)}function P(){set(p,""),set(g,""),set(_,[],!0),set(y,[],!0)}async function re(){if(!get(h)){set(h,!0);try{const T=await captureViewport();set(_,[...get(_),T],!0)}catch(T){console.error("Screenshot capture failed:",T)}set(h,!1)}}function oe(T){set(_,get(_).filter((V,Q)=>Q!==T),!0)}function ne(){startElementPicker(T=>{set(y,[...get(y),{tagName:T.tagName,className:T.className,id:T.id,selector:T.selector,textContent:T.textContent}],!0)})}function ce(T){set(y,get(y).filter((V,Q)=>Q!==T),!0)}async function _e(T,V,Q){set(d,T,!0);const G=V==="rejected"?{screenshots:get(_).length>0?get(_):void 0,elements:get(y).length>0?get(y):void 0}:void 0;(await respondToReport(n(),T,V,Q,G)).ok?(r(r().map(fe=>fe.id===T?{...fe,status:V==="rejected"?"submitted":"accepted",responded_at:new Date().toISOString(),...V==="rejected"?{revision_count:(fe.revision_count||0)+1}:{}}:fe)),set(p,""),set(g,""),set(_,[],!0),set(y,[],!0),i()()):set(p,""),set(d,"")}function ge(T){set(l,get(l)===T?null:T,!0)}function $e(T){return T?T.length:0}function be(T){return{submission:"Submitted",completion:"Completed",rejection:"Rejected",acceptance:"Accepted",note:"Note"}[T.type]||T.type}function ye(T){return{submitted:"Submitted",in_progress:"Working On It",completed:"Ready for Review",accepted:"Done",rejected:"Revising",wontfix:"Won't Fix",closed:"Closed"}[T]||T}function de(T){return{submitted:"#6b7280",in_progress:"#3b82f6",completed:"#f59e0b",accepted:"#10b981",rejected:"#f59e0b",wontfix:"#6b7280",closed:"#6b7280"}[T]||"#6b7280"}function v(T){return T==="bug"?"🐛":T==="enhancement"?"✨":"📝"}function w(T){const V=Date.now(),Q=new Date(T).getTime(),G=V-Q,we=Math.floor(G/6e4);if(we<1)return"just now";if(we<60)return`${we}m ago`;const fe=Math.floor(we/60);if(fe<24)return`${fe}h ago`;const A=Math.floor(fe/24);return A<30?`${A}d ago`:new Date(T).toLocaleDateString()}var z={get endpoint(){return n()},set endpoint(T){n(T),flushSync()},get reports(){return r()},set reports(T=[]){r(T),flushSync()},get loading(){return o()},set loading(T){o(T),flushSync()},get error(){return s()},set error(T){s(T),flushSync()},get onreload(){return i()},set onreload(T){i(T),flushSync()}},I=root$4(),k=child(I),U=child(k);let D;var K=sibling(child(U));{var j=T=>{var V=root_1$3(),Q=child(V,!0);reset(V),template_effect(()=>set_text(Q,get(m))),append(T,V)};if_block(K,T=>{get(m)>0&&T(j)})}reset(U);var J=sibling(U,2);let ee;var ie=sibling(child(J));{var R=T=>{var V=root_2$3(),Q=child(V,!0);reset(V),template_effect(()=>set_text(Q,get(x))),append(T,V)};if_block(ie,T=>{get(x)>0&&T(R)})}reset(J),reset(k);var Z=sibling(k,2),W=child(Z);return key(W,()=>get(f),T=>{var V=root_3$2(),Q=child(V);{var G=L=>{var F=root_4$2();append(L,F)},we=L=>{var F=root_5$2(),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2);reset(F),template_effect(()=>set_text(C,s())),delegated("click",H,function(...se){var ke;(ke=i())==null||ke.apply(this,se)}),append(L,F)},fe=L=>{var F=root_6$3(),q=child(F);q.textContent="📋",next(4),reset(F),append(L,F)},A=L=>{var F=root_7$3(),q=child(F),C=child(q,!0);reset(q),reset(F),template_effect(()=>set_text(C,get(f)==="submitted"?"No submitted requests":get(f)==="review"?"Nothing to review right now":"No completed requests yet")),append(L,F)},O=L=>{var F=root_8$3();each(F,21,()=>get(b),q=>q.id,(q,C)=>{var H=root_9$2();let se;var ke=child(H),xe=child(ke),Ue=child(xe,!0);reset(xe);var Ke=sibling(xe,2),rt=child(Ke,!0);reset(Ke);var Be=sibling(Ke,2),Kt=child(Be,!0);reset(Be);var Fe=sibling(Be,2);let Me;reset(ke);var ft=sibling(ke,2);{var Jt=pt=>{var me=root_10$2(),Ee=child(me);{var Pe=pe=>{var ve=root_11$2(),Ie=sibling(child(ve),2),qe=child(Ie,!0);reset(Ie),reset(ve),template_effect($t=>{set_attribute(ve,"href",get(C).page_url),set_text(qe,$t)},[()=>get(C).page_url.replace(/^https?:\/\//,"").split("?")[0]]),append(pe,ve)};if_block(Ee,pe=>{get(C).page_url&&pe(Pe)})}var lt=sibling(Ee,2);{var Et=pe=>{var ve=root_12$2(),Ie=child(ve);reset(ve),template_effect(()=>set_text(Ie,`Revision ${get(C).revision_count??""}`)),append(pe,ve)};if_block(lt,pe=>{get(C).revision_count>0&&get(C).status!=="accepted"&&pe(Et)})}var zn=sibling(lt,2);{var yn=pe=>{var ve=root_13$2(),Ie=first_child(ve),qe=child(Ie);let $t;var Je=sibling(qe,2),Ve=child(Je);reset(Je),reset(Ie);var Re=sibling(Ie,2);{var We=Ce=>{var $=root_14$3();each($,21,()=>get(C).thread,B=>B.id,(B,Y)=>{var he=root_15$3();let He;var Ft=child(he),ht=child(Ft),jt=child(ht,!0);reset(ht);var Qe=sibling(ht,2);let en;var Bt=child(Qe,!0);reset(Qe);var Vt=sibling(Qe,2),tn=child(Vt,!0);reset(Vt),reset(Ft);var ze=sibling(Ft,2),Ge=child(ze);html(Ge,()=>S(get(Y).message)),reset(ze);var St=sibling(ze,2);{var gt=Ne=>{var et=root_16$3();each(et,21,()=>get(Y).summary,index,(Dt,st)=>{var ct=root_17$3(),ut=child(ct,!0);reset(ct),template_effect(()=>set_text(ut,get(st))),append(Dt,ct)}),reset(et),append(Ne,et)};if_block(St,Ne=>{get(Y).summary&&get(Y).summary.length>0&&Ne(gt)})}var ot=sibling(St,2);{var vt=Ne=>{var et=root_18$2(),Dt=first_child(et);each(Dt,21,()=>get(Y).screenshots,index,(ut,Ct,zt)=>{var pn=comment(),hn=first_child(pn);{var At=Zt=>{var It=root_20$2();set_attribute(It,"aria-label",`Screenshot ${zt+1}`);var rn=child(It);set_attribute(rn,"alt",`Screenshot ${zt+1}`),reset(It),template_effect(()=>set_attribute(rn,"src",`${n()??""}${get(Ct).url??""}`)),delegated("click",It,()=>set(a,get(a)===get(Ct).url?null:get(Ct).url,!0)),append(Zt,It)};if_block(hn,Zt=>{get(Ct).url&&Zt(At)})}append(ut,pn)}),reset(Dt);var st=sibling(Dt,2);{var ct=ut=>{const Ct=user_derived(()=>get(Y).screenshots.find(At=>At.url===get(a)));var zt=comment(),pn=first_child(zt);{var hn=At=>{var Zt=root_22$2(),It=child(Zt),rn=sibling(It,2);reset(Zt),template_effect(()=>set_attribute(It,"src",`${n()??""}${get(a)??""}`)),delegated("click",rn,()=>set(a,null)),append(At,Zt)};if_block(pn,At=>{get(Ct)&&At(hn)})}append(ut,zt)};if_block(st,ut=>{get(a)&&ut(ct)})}append(Ne,et)};if_block(ot,Ne=>{get(Y).screenshots&&get(Y).screenshots.length>0&&Ne(vt)})}var Tt=sibling(ot,2);{var nn=Ne=>{var et=root_23$1();each(et,21,()=>get(Y).elements,index,(Dt,st)=>{var ct=root_24$1(),ut=child(ct);reset(ct),template_effect((Ct,zt)=>{set_attribute(ct,"title",get(st).selector),set_text(ut,`<${Ct??""}${get(st).id?`#${get(st).id}`:""}${zt??""}>`)},[()=>get(st).tagName.toLowerCase(),()=>get(st).className?`.${get(st).className.split(" ")[0]}`:""]),append(Dt,ct)}),reset(et),append(Ne,et)};if_block(Tt,Ne=>{get(Y).elements&&get(Y).elements.length>0&&Ne(nn)})}reset(he),template_effect((Ne,et)=>{He=set_class(he,1,"thread-entry svelte-1fnmin5",null,He,{"thread-user":get(Y).from==="user","thread-dev":get(Y).from==="dev"}),set_text(jt,get(Y).from==="user"?"You":"Dev"),en=set_class(Qe,1,"thread-type-badge svelte-1fnmin5",null,en,{submission:get(Y).type==="submission",completion:get(Y).type==="completion",rejection:get(Y).type==="rejection",acceptance:get(Y).type==="acceptance"}),set_text(Bt,Ne),set_text(tn,et)},[()=>be(get(Y)),()=>w(get(Y).at)]),append(B,he)}),reset($),append(Ce,$)};if_block(Re,Ce=>{get(l)===get(C).id&&Ce(We)})}template_effect((Ce,$)=>{$t=set_class(qe,0,"thread-toggle-icon svelte-1fnmin5",null,$t,{expanded:get(l)===get(C).id}),set_text(Ve,`${Ce??""} ${$??""}`)},[()=>$e(get(C).thread),()=>$e(get(C).thread)===1?"message":"messages"]),delegated("click",Ie,()=>ge(get(C).id)),append(pe,ve)},wn=pe=>{var ve=root_25$1(),Ie=child(ve,!0);reset(ve),template_effect(qe=>set_text(Ie,qe),[()=>get(C).description.length>120?get(C).description.slice(0,120)+"...":get(C).description]),append(pe,ve)};if_block(zn,pe=>{get(C).thread&&get(C).thread.length>0?pe(yn):get(C).description&&pe(wn,1)})}var xn=sibling(zn,2);{var Qt=pe=>{var ve=root_26$1(),Ie=first_child(ve);each(Ie,21,()=>get(C).screenshot_urls,index,(Ve,Re,We)=>{var Ce=root_27();set_attribute(Ce,"aria-label",`Screenshot ${We+1}`);var $=child(Ce);set_attribute($,"alt",`Screenshot ${We+1}`),reset(Ce),template_effect(()=>set_attribute($,"src",`${n()??""}${get(Re)??""}`)),delegated("click",Ce,()=>set(a,get(a)===get(Re)?null:get(Re),!0)),append(Ve,Ce)}),reset(Ie);var qe=sibling(Ie,2);{var $t=Ve=>{var Re=root_28(),We=child(Re),Ce=sibling(We,2);reset(Re),template_effect(()=>set_attribute(We,"src",`${n()??""}${get(a)??""}`)),delegated("click",Ce,()=>set(a,null)),append(Ve,Re)},Je=user_derived(()=>get(a)&&get(C).screenshot_urls.includes(get(a)));if_block(qe,Ve=>{get(Je)&&Ve($t)})}append(pe,ve)};if_block(xn,pe=>{!get(C).thread&&get(C).screenshot_urls&&get(C).screenshot_urls.length>0&&pe(Qt)})}var kn=sibling(xn,2);{var Pn=pe=>{var ve=root_29(),Ie=sibling(child(ve),2),qe=child(Ie);html(qe,()=>S(get(C).dev_notes)),reset(Ie),reset(ve),append(pe,ve)};if_block(kn,pe=>{get(C).dev_notes&&!get(C).thread&&get(C).status!=="in_progress"&&pe(Pn)})}var An=sibling(kn,2),fn=child(An),Fn=child(fn,!0);reset(fn);var In=sibling(fn,2);{var Rn=pe=>{var ve=root_30();ve.textContent="✓ Accepted",append(pe,ve)},Dn=pe=>{var ve=root_31();ve.textContent="✗ Rejected",append(pe,ve)},Nn=pe=>{var ve=comment(),Ie=first_child(ve);{var qe=Je=>{var Ve=root_33(),Re=child(Ve);remove_textarea_child(Re);var We=sibling(Re,2),Ce=child(We),$=sibling(child(Ce));reset(Ce);var B=sibling(Ce,2);reset(We);var Y=sibling(We,2);{var he=ze=>{var Ge=root_34();each(Ge,21,()=>get(_),index,(St,gt,ot)=>{var vt=root_35(),Tt=child(vt);set_attribute(Tt,"alt",`Screenshot ${ot+1}`);var nn=sibling(Tt,2);reset(vt),template_effect(()=>set_attribute(Tt,"src",get(gt))),delegated("click",nn,()=>oe(ot)),append(St,vt)}),reset(Ge),append(ze,Ge)};if_block(Y,ze=>{get(_).length>0&&ze(he)})}var He=sibling(Y,2);{var Ft=ze=>{var Ge=root_36();each(Ge,21,()=>get(y),index,(St,gt,ot)=>{var vt=root_37(),Tt=child(vt),nn=sibling(Tt);reset(vt),template_effect(Ne=>set_text(Tt,`<${Ne??""}${get(gt).id?`#${get(gt).id}`:""}> `),[()=>get(gt).tagName.toLowerCase()]),delegated("click",nn,()=>ce(ot)),append(St,vt)}),reset(Ge),append(ze,Ge)};if_block(He,ze=>{get(y).length>0&&ze(Ft)})}var ht=sibling(He,2),jt=child(ht),Qe=sibling(jt,2),en=child(Qe,!0);reset(Qe),reset(ht);var Bt=sibling(ht,2);{var Vt=ze=>{var Ge=root_38(),St=child(Ge);reset(Ge),template_effect(gt=>set_text(St,`${gt??""} more characters needed`),[()=>10-get(g).trim().length]),append(ze,Ge)},tn=user_derived(()=>get(g).trim().length>0&&get(g).trim().length<10);if_block(Bt,ze=>{get(tn)&&ze(Vt)})}reset(Ve),template_effect(ze=>{Ce.disabled=get(h),set_text($,` ${get(h)?"...":"Screenshot"}`),Qe.disabled=ze,set_text(en,get(d)===get(C).id?"...":"✗ Reject")},[()=>get(g).trim().length<10||get(d)===get(C).id]),bind_value(Re,()=>get(g),ze=>set(g,ze)),delegated("click",Ce,re),delegated("click",B,ne),delegated("click",jt,P),delegated("click",Qe,()=>_e(get(C).id,"rejected",get(g).trim())),append(Je,Ve)},$t=Je=>{var Ve=root_39(),Re=child(Ve),We=child(Re,!0);reset(Re);var Ce=sibling(Re,2);Ce.textContent="✗ Reject",reset(Ve),template_effect(()=>{Re.disabled=get(d)===get(C).id,set_text(We,get(d)===get(C).id?"...":"✓ Accept"),Ce.disabled=get(d)===get(C).id}),delegated("click",Re,()=>_e(get(C).id,"accepted")),delegated("click",Ce,()=>M(get(C).id)),append(Je,Ve)};if_block(Ie,Je=>{get(p)===get(C).id?Je(qe):Je($t,!1)})}append(pe,ve)};if_block(In,pe=>{get(C).status==="accepted"?pe(Rn):get(C).status==="rejected"?pe(Dn,1):(get(C).status==="completed"||get(C).status==="wontfix")&&pe(Nn,2)})}reset(An),reset(me),template_effect(pe=>set_text(Fn,pe),[()=>w(get(C).created_at)]),transition(3,me,()=>slide,()=>({duration:200})),append(pt,me)};if_block(ft,pt=>{get(u)===get(C).id&&pt(Jt)})}reset(H),template_effect((pt,me,Ee,Pe,lt)=>{se=set_class(H,1,"report-card svelte-1fnmin5",null,se,{awaiting:get(C).status==="completed",expanded:get(u)===get(C).id}),set_attribute(H,"data-card-id",get(C).id),set_text(Ue,pt),set_text(rt,get(C).title),set_style(Be,`background: ${me??""}20; color: ${Ee??""}; border-color: ${Pe??""}40;`),set_text(Kt,lt),Me=set_class(Fe,0,"chevron svelte-1fnmin5",null,Me,{"chevron-open":get(u)===get(C).id})},[()=>v(get(C).type),()=>de(get(C).status),()=>de(get(C).status),()=>de(get(C).status),()=>ye(get(C).status)]),delegated("click",ke,()=>N(get(C).id)),append(q,H)}),reset(F),append(L,F)};if_block(Q,L=>{o()?L(G):s()&&r().length===0?L(we,1):r().length===0?L(fe,2):get(b).length===0?L(A,3):L(O,!1)})}reset(V),transition(3,V,()=>slide,()=>({duration:200})),append(T,V)}),reset(Z),bind_this(Z,T=>set(c,T),()=>get(c)),reset(I),template_effect(()=>{D=set_class(U,1,"subtab svelte-1fnmin5",null,D,{active:get(f)==="active"}),ee=set_class(J,1,"subtab svelte-1fnmin5",null,ee,{active:get(f)==="done"})}),delegated("click",U,()=>set(f,"active")),delegated("click",J,()=>set(f,"done")),append(e,I),pop(z)}delegate(["click"]),create_custom_element(RequestList,{endpoint:{},reports:{},loading:{},error:{},onreload:{}},[],[],{mode:"open"});var root_6$2=from_html('<span class="step-counter svelte-bez0nz"> </span>'),root_7$2=from_html('<div class="empty-state svelte-bez0nz"><div class="empty-icon svelte-bez0nz"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor" opacity="0.3" class="svelte-bez0nz"></path><path d="M21 11.5a8.38 8.38 0 01-.9 3.8 8.5 8.5 0 01-7.6 4.7 8.38 8.38 0 01-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 01-.9-3.8 8.5 8.5 0 014.7-7.6 8.38 8.38 0 013.8-.9h.5a8.48 8.48 0 018 8v.5z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none" class="svelte-bez0nz"></path></svg></div> <p class="empty-text svelte-bez0nz">Tell the agent what to do on this page</p> <p class="empty-hint svelte-bez0nz">e.g. "Fill in the contact form" or "Click the sign up button"</p></div>'),root_14$2=from_html('<span class="msg-tool svelte-bez0nz"> </span>'),root_15$2=from_html('<div class="approval-buttons svelte-bez0nz"><button class="approve-btn svelte-bez0nz"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M20 6L9 17l-5-5" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-bez0nz"></path></svg> Approve</button> <button class="skip-btn svelte-bez0nz"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M5 5l14 14M19 5L5 19" stroke="currentColor" stroke-width="2" stroke-linecap="round" class="svelte-bez0nz"></path></svg> Skip</button></div>'),root_16$2=from_html("<span> </span>"),root_17$2=from_html('<span class="msg-step svelte-bez0nz"> </span>'),root_10$1=from_html('<div><span class="msg-icon svelte-bez0nz"><!></span> <div class="msg-body svelte-bez0nz"><!> <span class="msg-text svelte-bez0nz"> </span> <!></div> <!></div>'),root_19$1=from_html('<span class="msg-tool svelte-bez0nz"> </span>'),root_20$1=from_html('<span class="msg-duration svelte-bez0nz"> </span>'),root_21$1=from_html('<span class="msg-step svelte-bez0nz"> </span>'),root_18$1=from_html('<div><span class="msg-icon svelte-bez0nz"> </span> <div class="msg-body svelte-bez0nz"><!> <span class="msg-text svelte-bez0nz"> </span> <!></div> <!></div>'),root_22$1=from_html('<div class="message msg-thinking live svelte-bez0nz"><span class="msg-icon svelte-bez0nz">…</span> <div class="msg-body svelte-bez0nz"><span class="thinking-dots svelte-bez0nz"><span class="dot svelte-bez0nz"></span> <span class="dot svelte-bez0nz"></span> <span class="dot svelte-bez0nz"></span></span></div></div>'),root_8$2=from_html("<!> <!>",1),root_23=from_html('<button class="stop-btn svelte-bez0nz" aria-label="Stop agent"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" class="svelte-bez0nz"><rect x="6" y="6" width="12" height="12" rx="1" class="svelte-bez0nz"></rect></svg> Stop</button>'),root$3=from_html('<div class="agent-panel svelte-bez0nz"><div class="status-bar svelte-bez0nz"><div><span class="status-dot svelte-bez0nz"></span> <span class="status-text svelte-bez0nz"><!></span></div> <div class="status-right svelte-bez0nz"><!> <label class="auto-approve-toggle svelte-bez0nz" title="Auto-approve all actions"><input type="checkbox" class="svelte-bez0nz"/> <span class="toggle-label svelte-bez0nz">Auto</span></label></div></div> <div class="messages svelte-bez0nz"><!></div> <div class="input-area svelte-bez0nz"><!> <div class="input-row svelte-bez0nz"><input type="text" class="chat-input svelte-bez0nz"/> <button class="send-btn svelte-bez0nz" aria-label="Send"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" class="svelte-bez0nz"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-bez0nz"></path></svg></button></div></div></div>');const $$css$3={hash:"svelte-bez0nz",code:`.agent-panel.svelte-bez0nz {display:flex;flex-direction:column;height:100%;min-height:0;font-family:inherit;color:#e5e7eb;}
68
68
 
69
69
  /* Status bar */.status-bar.svelte-bez0nz {display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-bottom:1px solid #1f2937;flex-shrink:0;}.status-indicator.svelte-bez0nz {display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;}.status-dot.svelte-bez0nz {width:7px;height:7px;border-radius:50%;flex-shrink:0;}.status-indicator.idle.svelte-bez0nz .status-dot:where(.svelte-bez0nz) {background:#6b7280;}.status-indicator.idle.svelte-bez0nz .status-text:where(.svelte-bez0nz) {color:#9ca3af;}.status-indicator.thinking.svelte-bez0nz .status-dot:where(.svelte-bez0nz) {background:#f59e0b;
70
70
  animation: svelte-bez0nz-pulse-dot 1.2s ease-in-out infinite;}.status-indicator.thinking.svelte-bez0nz .status-text:where(.svelte-bez0nz) {color:#fcd34d;}.status-indicator.acting.svelte-bez0nz .status-dot:where(.svelte-bez0nz) {background:#3b82f6;
@@ -94,6 +94,8 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
94
94
 
95
95
  /* Error messages */.msg-error.svelte-bez0nz {background:rgba(239, 68, 68, 0.08);border-radius:6px;margin:2px 8px;padding:8px 12px;}.msg-error.svelte-bez0nz .msg-icon:where(.svelte-bez0nz) {color:#ef4444;}.msg-error.svelte-bez0nz .msg-text:where(.svelte-bez0nz) {color:#f87171;}
96
96
 
97
+ /* Info messages (e.g. "Stopped by user") */.msg-info.svelte-bez0nz {background:rgba(148, 163, 184, 0.08);border-radius:6px;margin:2px 8px;padding:8px 12px;}.msg-info.svelte-bez0nz .msg-icon:where(.svelte-bez0nz) {color:#94a3b8;}.msg-info.svelte-bez0nz .msg-text:where(.svelte-bez0nz) {color:#cbd5e1;}
98
+
97
99
  /* Approval messages */.msg-approval.svelte-bez0nz {background:rgba(168, 85, 247, 0.08);border:1px solid rgba(168, 85, 247, 0.2);border-radius:6px;margin:4px 8px;padding:8px 12px;}.msg-approval.pending.svelte-bez0nz {border-color:rgba(168, 85, 247, 0.4);
98
100
  animation: svelte-bez0nz-approval-pulse 2s ease-in-out infinite;}.msg-approval.approved.svelte-bez0nz {background:rgba(16, 185, 129, 0.06);border-color:rgba(16, 185, 129, 0.2);}.msg-approval.skipped.svelte-bez0nz {background:rgba(107, 114, 128, 0.06);border-color:rgba(107, 114, 128, 0.2);opacity:0.7;}.msg-approval.svelte-bez0nz .msg-icon:where(.svelte-bez0nz) {color:#a855f7;}.msg-approval.approved.svelte-bez0nz .msg-icon:where(.svelte-bez0nz) {color:#10b981;}.msg-approval.skipped.svelte-bez0nz .msg-icon:where(.svelte-bez0nz) {color:#6b7280;}.msg-approval.svelte-bez0nz .msg-text:where(.svelte-bez0nz) {color:#e5e7eb;}.msg-approval.svelte-bez0nz .msg-tool:where(.svelte-bez0nz) {background:#2e1065;color:#c4b5fd;}
99
101
 
@@ -110,7 +112,7 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
110
112
  40% { transform: scale(1); opacity: 1; }
111
113
  }
112
114
 
113
- /* Input area */.input-area.svelte-bez0nz {flex-shrink:0;padding:8px 12px 12px;border-top:1px solid #1f2937;display:flex;flex-direction:column;gap:6px;}.input-row.svelte-bez0nz {display:flex;gap:6px;}.chat-input.svelte-bez0nz {flex:1;padding:8px 10px;border:1px solid #374151;border-radius:6px;font-size:13px;font-family:inherit;color:#e5e7eb;background:#1f2937;transition:border-color 0.15s;}.chat-input.svelte-bez0nz:focus {outline:none;border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59, 130, 246, 0.2);}.chat-input.svelte-bez0nz:disabled {opacity:0.5;cursor:not-allowed;}.chat-input.svelte-bez0nz::placeholder {color:#6b7280;}.send-btn.svelte-bez0nz {display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:6px;background:#3b82f6;color:white;cursor:pointer;flex-shrink:0;transition:background 0.15s;}.send-btn.svelte-bez0nz:hover:not(:disabled) {background:#2563eb;}.send-btn.svelte-bez0nz:disabled {opacity:0.3;cursor:not-allowed;}.stop-btn.svelte-bez0nz {display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px solid #ef4444;border-radius:6px;background:rgba(239, 68, 68, 0.1);color:#f87171;font-size:12px;font-family:inherit;cursor:pointer;transition:background 0.15s;}.stop-btn.svelte-bez0nz:hover {background:rgba(239, 68, 68, 0.2);}`};function AgentPanel(e,t){push(t,!0),append_styles(e,$$css$3);let n=prop(t,"messages",23,()=>[]),r=prop(t,"agentState",7,"idle"),o=prop(t,"currentStep",7,0),s=prop(t,"maxSteps",7,40),i=prop(t,"autoApprove",7,!1),a=prop(t,"onsend",7),l=prop(t,"onstop",7),u=prop(t,"onapprove",7),c=prop(t,"onskip",7),d=prop(t,"onautoapprovechange",7),p=state(""),g=state(void 0);user_effect(()=>{n().length&&get(g)&&requestAnimationFrame(()=>{get(g).scrollTop=get(g).scrollHeight})});function _(){var Z;const I=get(p).trim();!I||r()==="thinking"||r()==="acting"||(set(p,""),(Z=a())==null||Z(I))}function y(I){var Z;I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),_()),I.key==="Escape"&&(r()==="thinking"||r()==="acting")&&((Z=l())==null||Z())}function h(){var I;(I=l())==null||I()}const f=user_derived(()=>r()==="thinking"||r()==="acting"||r()==="awaiting_approval");function b(I){switch(I){case"user":return"›";case"thinking":return"…";case"action":return"⚡";case"result":return"✓";case"error":return"✕";case"approval":return"?"}}function m(I){return I<1e3?`${I}ms`:`${(I/1e3).toFixed(1)}s`}var x={get messages(){return n()},set messages(I=[]){n(I),flushSync()},get agentState(){return r()},set agentState(I="idle"){r(I),flushSync()},get currentStep(){return o()},set currentStep(I=0){o(I),flushSync()},get maxSteps(){return s()},set maxSteps(I=40){s(I),flushSync()},get autoApprove(){return i()},set autoApprove(I=!1){i(I),flushSync()},get onsend(){return a()},set onsend(I){a(I),flushSync()},get onstop(){return l()},set onstop(I){l(I),flushSync()},get onapprove(){return u()},set onapprove(I){u(I),flushSync()},get onskip(){return c()},set onskip(I){c(I),flushSync()},get onautoapprovechange(){return d()},set onautoapprovechange(I){d(I),flushSync()}},S=root$3(),N=child(S),P=child(N);let M;var re=sibling(child(P),2),oe=child(re);{var ne=I=>{var Z=text("Ready");append(I,Z)},ce=I=>{var Z=text("Thinking...");append(I,Z)},_e=I=>{var Z=text("Acting...");append(I,Z)},ge=I=>{var Z=text("Awaiting approval");append(I,Z)},$e=I=>{var Z=text("Error");append(I,Z)};if_block(oe,I=>{r()==="idle"?I(ne):r()==="thinking"?I(ce,1):r()==="acting"?I(_e,2):r()==="awaiting_approval"?I(ge,3):I($e,!1)})}reset(re),reset(P);var be=sibling(P,2),ye=child(be);{var de=I=>{var Z=root_6$2(),W=child(Z);reset(Z),template_effect(()=>set_text(W,`Step ${o()??""}/${s()??""}`)),append(I,Z)};if_block(ye,I=>{o()>0&&I(de)})}var v=sibling(ye,2),w=child(v);remove_input_defaults(w),next(2),reset(v),reset(be),reset(N);var z=sibling(N,2),R=child(z);{var k=I=>{var Z=root_7$2();append(I,Z)},U=I=>{var Z=root_8$2(),W=first_child(Z);each(W,17,n,Q=>Q.id,(Q,G)=>{var we=comment(),fe=first_child(we);{var A=L=>{var F=root_10$1();let q;var C=child(F),H=child(C);{var se=me=>{var Ee=text("✓");append(me,Ee)},ke=me=>{var Ee=text("⏭");append(me,Ee)},xe=me=>{var Ee=text("?");append(me,Ee)};if_block(H,me=>{get(G).approvalStatus==="approved"?me(se):get(G).approvalStatus==="skipped"?me(ke,1):me(xe,!1)})}reset(C);var Ue=sibling(C,2),Ke=child(Ue);{var rt=me=>{var Ee=root_14$2(),Me=child(Ee,!0);reset(Ee),template_effect(()=>set_text(Me,get(G).tool)),append(me,Ee)};if_block(Ke,me=>{get(G).tool&&me(rt)})}var Be=sibling(Ke,2),Kt=child(Be,!0);reset(Be);var Fe=sibling(Be,2);{var Pe=me=>{var Ee=root_15$2(),Me=child(Ee),lt=sibling(Me,2);reset(Ee),delegated("click",Me,()=>{var Et;return(Et=u())==null?void 0:Et(get(G).id)}),delegated("click",lt,()=>{var Et;return(Et=c())==null?void 0:Et(get(G).id)}),append(me,Ee)},ft=me=>{var Ee=root_16$2();let Me;var lt=child(Ee,!0);reset(Ee),template_effect(()=>{Me=set_class(Ee,1,"approval-badge svelte-bez0nz",null,Me,{"badge-approved":get(G).approvalStatus==="approved","badge-skipped":get(G).approvalStatus==="skipped"}),set_text(lt,get(G).approvalStatus)}),append(me,Ee)};if_block(Fe,me=>{get(G).approvalStatus==="pending"?me(Pe):me(ft,!1)})}reset(Ue);var Jt=sibling(Ue,2);{var pt=me=>{var Ee=root_17$2(),Me=child(Ee,!0);reset(Ee),template_effect(()=>set_text(Me,get(G).step)),append(me,Ee)};if_block(Jt,me=>{get(G).step&&me(pt)})}reset(F),template_effect(()=>{q=set_class(F,1,"message msg-approval svelte-bez0nz",null,q,{pending:get(G).approvalStatus==="pending",approved:get(G).approvalStatus==="approved",skipped:get(G).approvalStatus==="skipped"}),set_text(Kt,get(G).text)}),append(L,F)},O=L=>{var F=root_18$1(),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2),se=child(H);{var ke=Fe=>{var Pe=root_19$1(),ft=child(Pe,!0);reset(Pe),template_effect(()=>set_text(ft,get(G).tool)),append(Fe,Pe)};if_block(se,Fe=>{get(G).role==="action"&&get(G).tool&&Fe(ke)})}var xe=sibling(se,2),Ue=child(xe,!0);reset(xe);var Ke=sibling(xe,2);{var rt=Fe=>{var Pe=root_20$1(),ft=child(Pe,!0);reset(Pe),template_effect(Jt=>set_text(ft,Jt),[()=>m(get(G).duration)]),append(Fe,Pe)};if_block(Ke,Fe=>{get(G).duration!=null&&Fe(rt)})}reset(H);var Be=sibling(H,2);{var Kt=Fe=>{var Pe=root_21$1(),ft=child(Pe,!0);reset(Pe),template_effect(()=>set_text(ft,get(G).step)),append(Fe,Pe)};if_block(Be,Fe=>{get(G).step&&Fe(Kt)})}reset(F),template_effect(Fe=>{set_class(F,1,`message msg-${get(G).role??""}`,"svelte-bez0nz"),set_text(C,Fe),set_text(Ue,get(G).text)},[()=>b(get(G).role)]),append(L,F)};if_block(fe,L=>{get(G).role==="approval"?L(A):L(O,!1)})}append(Q,we)});var T=sibling(W,2);{var V=Q=>{var G=root_22$1();append(Q,G)};if_block(T,Q=>{r()==="thinking"&&Q(V)})}append(I,Z)};if_block(R,I=>{n().length===0?I(k):I(U,!1)})}reset(z),bind_this(z,I=>set(g,I),()=>get(g));var D=sibling(z,2),K=child(D);{var j=I=>{var Z=root_23();delegated("click",Z,h),append(I,Z)};if_block(K,I=>{get(f)&&I(j)})}var J=sibling(K,2),ee=child(J);remove_input_defaults(ee);var ie=sibling(ee,2);return reset(J),reset(D),reset(S),template_effect(I=>{M=set_class(P,1,"status-indicator svelte-bez0nz",null,M,{idle:r()==="idle",thinking:r()==="thinking",acting:r()==="acting",awaiting:r()==="awaiting_approval",error:r()==="error"}),set_checked(w,i()),set_attribute(ee,"placeholder",get(f)?"Agent is working...":"Type a command..."),ee.disabled=get(f),ie.disabled=I},[()=>get(f)||!get(p).trim()]),delegated("change",w,I=>{var Z;return(Z=d())==null?void 0:Z(I.target.checked)}),delegated("keydown",ee,y),bind_value(ee,()=>get(p),I=>set(p,I)),delegated("click",ie,_),append(e,S),pop(x)}delegate(["change","click","keydown"]),create_custom_element(AgentPanel,{messages:{},agentState:{},currentStep:{},maxSteps:{},autoApprove:{},onsend:{},onstop:{},onapprove:{},onskip:{},onautoapprovechange:{}},[],[],{mode:"open"});var root_2$2=from_html('<div class="loading svelte-zp32f3"><span class="spinner svelte-zp32f3"></span> Loading notes...</div>'),root_3$1=from_html('<div class="error-msg svelte-zp32f3"> <button class="retry-btn svelte-zp32f3">Retry</button></div>'),root_5$1=from_html('<button class="note-row site-note svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="1.8"></circle><path d="M2 12h20M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10A15.3 15.3 0 0112 2" stroke="currentColor" stroke-width="1.8"></path></svg> <div class="note-info svelte-zp32f3"><span class="note-name svelte-zp32f3"> </span> <span class="note-preview svelte-zp32f3"> </span></div></div> <span class="note-edit-hint svelte-zp32f3">edit</span></button>'),root_6$1=from_html('<button class="note-row site-note empty svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="1.8"></circle><path d="M2 12h20M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10A15.3 15.3 0 0112 2" stroke="currentColor" stroke-width="1.8"></path></svg> <span class="note-name add-prompt svelte-zp32f3">Add site-wide notes</span></div> <svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"></path></svg></button>'),root_7$1=from_html('<div class="section-divider svelte-zp32f3"><span>Routes</span></div>'),root_9$1=from_html('<span class="current-badge svelte-zp32f3">current</span>'),root_8$1=from_html('<button><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z" stroke="currentColor" stroke-width="1.8"></path><path d="M13 2v7h7" stroke="currentColor" stroke-width="1.8"></path></svg> <div class="note-info svelte-zp32f3"><span class="note-name svelte-zp32f3"> <!></span> <span class="note-preview svelte-zp32f3"> </span></div></div> <span class="note-edit-hint svelte-zp32f3">edit</span></button>'),root_10=from_html('<button class="note-row add-route svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> <span class="note-name add-prompt svelte-zp32f3"> </span></div></button>'),root_11$1=from_html('<div class="empty-state svelte-zp32f3"><svg width="28" height="28" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="1.5"></path><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg> <p class="svelte-zp32f3">No notes yet</p> <p class="empty-hint svelte-zp32f3">Notes give context to the page agent about your app</p></div>'),root_4$1=from_html("<!> <!> <!> <!> <!>",1),root_1$2=from_html('<div class="notes-list svelte-zp32f3"><div class="list-header svelte-zp32f3"><span class="list-title svelte-zp32f3">Notes</span> <button class="new-btn svelte-zp32f3" title="New site-wide note"><svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"></path></svg> New</button></div> <!></div>'),root_13$1=from_html('<div class="preview-area svelte-zp32f3"><!></div>'),root_14$1=from_html('<div class="field svelte-zp32f3"><label for="note-content" class="svelte-zp32f3">Content <span class="label-hint svelte-zp32f3">(markdown)</span></label> <textarea id="note-content" placeholder="Describe this page/app for the agent... Supports **bold**, *italic*, # headers, - lists, `code`" rows="12" class="svelte-zp32f3"></textarea></div>'),root_15$1=from_html('<div class="error-msg compact svelte-zp32f3"> </div>'),root_16$1=from_html("<button> </button>"),root_17$1=from_html('<span class="spinner svelte-zp32f3"></span>'),root_12$1=from_html('<div class="note-editor svelte-zp32f3"><div class="editor-header svelte-zp32f3"><button class="back-btn svelte-zp32f3" title="Back to list"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> <span class="editor-route svelte-zp32f3"> </span> <button> </button></div> <div class="editor-body svelte-zp32f3"><div class="field svelte-zp32f3"><label for="note-title" class="svelte-zp32f3">Title</label> <input id="note-title" type="text" placeholder="Note title" class="svelte-zp32f3"/></div> <!> <!></div> <div class="editor-actions svelte-zp32f3"><!> <div class="action-spacer svelte-zp32f3"></div> <button class="cancel-btn svelte-zp32f3">Cancel</button> <button class="save-btn svelte-zp32f3"><!> </button></div></div>'),root$2=from_html('<div class="notes-panel svelte-zp32f3"><!></div>');const $$css$2={hash:"svelte-zp32f3",code:`.notes-panel.svelte-zp32f3 {display:flex;flex-direction:column;height:100%;overflow:hidden;}
115
+ /* Input area */.input-area.svelte-bez0nz {flex-shrink:0;padding:8px 12px 12px;border-top:1px solid #1f2937;display:flex;flex-direction:column;gap:6px;}.input-row.svelte-bez0nz {display:flex;gap:6px;}.chat-input.svelte-bez0nz {flex:1;padding:8px 10px;border:1px solid #374151;border-radius:6px;font-size:13px;font-family:inherit;color:#e5e7eb;background:#1f2937;transition:border-color 0.15s;}.chat-input.svelte-bez0nz:focus {outline:none;border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59, 130, 246, 0.2);}.chat-input.svelte-bez0nz:disabled {opacity:0.5;cursor:not-allowed;}.chat-input.svelte-bez0nz::placeholder {color:#6b7280;}.send-btn.svelte-bez0nz {display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:6px;background:#3b82f6;color:white;cursor:pointer;flex-shrink:0;transition:background 0.15s;}.send-btn.svelte-bez0nz:hover:not(:disabled) {background:#2563eb;}.send-btn.svelte-bez0nz:disabled {opacity:0.3;cursor:not-allowed;}.stop-btn.svelte-bez0nz {display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px solid #ef4444;border-radius:6px;background:rgba(239, 68, 68, 0.1);color:#f87171;font-size:12px;font-family:inherit;cursor:pointer;transition:background 0.15s;}.stop-btn.svelte-bez0nz:hover {background:rgba(239, 68, 68, 0.2);}`};function AgentPanel(e,t){push(t,!0),append_styles(e,$$css$3);let n=prop(t,"messages",23,()=>[]),r=prop(t,"agentState",7,"idle"),o=prop(t,"currentStep",7,0),s=prop(t,"maxSteps",7,40),i=prop(t,"autoApprove",7,!1),a=prop(t,"onsend",7),l=prop(t,"onstop",7),u=prop(t,"onapprove",7),c=prop(t,"onskip",7),d=prop(t,"onautoapprovechange",7),p=state(""),g=state(void 0);user_effect(()=>{n().length&&get(g)&&requestAnimationFrame(()=>{get(g).scrollTop=get(g).scrollHeight})});function _(){var Z;const R=get(p).trim();!R||r()==="thinking"||r()==="acting"||(set(p,""),(Z=a())==null||Z(R))}function y(R){var Z;R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),_()),R.key==="Escape"&&(r()==="thinking"||r()==="acting")&&((Z=l())==null||Z())}function h(){var R;(R=l())==null||R()}const f=user_derived(()=>r()==="thinking"||r()==="acting"||r()==="awaiting_approval");function b(R){switch(R){case"user":return"›";case"thinking":return"…";case"action":return"⚡";case"result":return"✓";case"error":return"✕";case"info":return"●";case"approval":return"?"}}function m(R){return R<1e3?`${R}ms`:`${(R/1e3).toFixed(1)}s`}var x={get messages(){return n()},set messages(R=[]){n(R),flushSync()},get agentState(){return r()},set agentState(R="idle"){r(R),flushSync()},get currentStep(){return o()},set currentStep(R=0){o(R),flushSync()},get maxSteps(){return s()},set maxSteps(R=40){s(R),flushSync()},get autoApprove(){return i()},set autoApprove(R=!1){i(R),flushSync()},get onsend(){return a()},set onsend(R){a(R),flushSync()},get onstop(){return l()},set onstop(R){l(R),flushSync()},get onapprove(){return u()},set onapprove(R){u(R),flushSync()},get onskip(){return c()},set onskip(R){c(R),flushSync()},get onautoapprovechange(){return d()},set onautoapprovechange(R){d(R),flushSync()}},S=root$3(),N=child(S),M=child(N);let P;var re=sibling(child(M),2),oe=child(re);{var ne=R=>{var Z=text("Ready");append(R,Z)},ce=R=>{var Z=text("Thinking...");append(R,Z)},_e=R=>{var Z=text("Acting...");append(R,Z)},ge=R=>{var Z=text("Awaiting approval");append(R,Z)},$e=R=>{var Z=text("Error");append(R,Z)};if_block(oe,R=>{r()==="idle"?R(ne):r()==="thinking"?R(ce,1):r()==="acting"?R(_e,2):r()==="awaiting_approval"?R(ge,3):R($e,!1)})}reset(re),reset(M);var be=sibling(M,2),ye=child(be);{var de=R=>{var Z=root_6$2(),W=child(Z);reset(Z),template_effect(()=>set_text(W,`Step ${o()??""}/${s()??""}`)),append(R,Z)};if_block(ye,R=>{o()>0&&R(de)})}var v=sibling(ye,2),w=child(v);remove_input_defaults(w),next(2),reset(v),reset(be),reset(N);var z=sibling(N,2),I=child(z);{var k=R=>{var Z=root_7$2();append(R,Z)},U=R=>{var Z=root_8$2(),W=first_child(Z);each(W,17,n,Q=>Q.id,(Q,G)=>{var we=comment(),fe=first_child(we);{var A=L=>{var F=root_10$1();let q;var C=child(F),H=child(C);{var se=me=>{var Ee=text("✓");append(me,Ee)},ke=me=>{var Ee=text("⏭");append(me,Ee)},xe=me=>{var Ee=text("?");append(me,Ee)};if_block(H,me=>{get(G).approvalStatus==="approved"?me(se):get(G).approvalStatus==="skipped"?me(ke,1):me(xe,!1)})}reset(C);var Ue=sibling(C,2),Ke=child(Ue);{var rt=me=>{var Ee=root_14$2(),Pe=child(Ee,!0);reset(Ee),template_effect(()=>set_text(Pe,get(G).tool)),append(me,Ee)};if_block(Ke,me=>{get(G).tool&&me(rt)})}var Be=sibling(Ke,2),Kt=child(Be,!0);reset(Be);var Fe=sibling(Be,2);{var Me=me=>{var Ee=root_15$2(),Pe=child(Ee),lt=sibling(Pe,2);reset(Ee),delegated("click",Pe,()=>{var Et;return(Et=u())==null?void 0:Et(get(G).id)}),delegated("click",lt,()=>{var Et;return(Et=c())==null?void 0:Et(get(G).id)}),append(me,Ee)},ft=me=>{var Ee=root_16$2();let Pe;var lt=child(Ee,!0);reset(Ee),template_effect(()=>{Pe=set_class(Ee,1,"approval-badge svelte-bez0nz",null,Pe,{"badge-approved":get(G).approvalStatus==="approved","badge-skipped":get(G).approvalStatus==="skipped"}),set_text(lt,get(G).approvalStatus)}),append(me,Ee)};if_block(Fe,me=>{get(G).approvalStatus==="pending"?me(Me):me(ft,!1)})}reset(Ue);var Jt=sibling(Ue,2);{var pt=me=>{var Ee=root_17$2(),Pe=child(Ee,!0);reset(Ee),template_effect(()=>set_text(Pe,get(G).step)),append(me,Ee)};if_block(Jt,me=>{get(G).step&&me(pt)})}reset(F),template_effect(()=>{q=set_class(F,1,"message msg-approval svelte-bez0nz",null,q,{pending:get(G).approvalStatus==="pending",approved:get(G).approvalStatus==="approved",skipped:get(G).approvalStatus==="skipped"}),set_text(Kt,get(G).text)}),append(L,F)},O=L=>{var F=root_18$1(),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2),se=child(H);{var ke=Fe=>{var Me=root_19$1(),ft=child(Me,!0);reset(Me),template_effect(()=>set_text(ft,get(G).tool)),append(Fe,Me)};if_block(se,Fe=>{get(G).role==="action"&&get(G).tool&&Fe(ke)})}var xe=sibling(se,2),Ue=child(xe,!0);reset(xe);var Ke=sibling(xe,2);{var rt=Fe=>{var Me=root_20$1(),ft=child(Me,!0);reset(Me),template_effect(Jt=>set_text(ft,Jt),[()=>m(get(G).duration)]),append(Fe,Me)};if_block(Ke,Fe=>{get(G).duration!=null&&Fe(rt)})}reset(H);var Be=sibling(H,2);{var Kt=Fe=>{var Me=root_21$1(),ft=child(Me,!0);reset(Me),template_effect(()=>set_text(ft,get(G).step)),append(Fe,Me)};if_block(Be,Fe=>{get(G).step&&Fe(Kt)})}reset(F),template_effect(Fe=>{set_class(F,1,`message msg-${get(G).role??""}`,"svelte-bez0nz"),set_text(C,Fe),set_text(Ue,get(G).text)},[()=>b(get(G).role)]),append(L,F)};if_block(fe,L=>{get(G).role==="approval"?L(A):L(O,!1)})}append(Q,we)});var T=sibling(W,2);{var V=Q=>{var G=root_22$1();append(Q,G)};if_block(T,Q=>{r()==="thinking"&&Q(V)})}append(R,Z)};if_block(I,R=>{n().length===0?R(k):R(U,!1)})}reset(z),bind_this(z,R=>set(g,R),()=>get(g));var D=sibling(z,2),K=child(D);{var j=R=>{var Z=root_23();delegated("click",Z,h),append(R,Z)};if_block(K,R=>{get(f)&&R(j)})}var J=sibling(K,2),ee=child(J);remove_input_defaults(ee);var ie=sibling(ee,2);return reset(J),reset(D),reset(S),template_effect(R=>{P=set_class(M,1,"status-indicator svelte-bez0nz",null,P,{idle:r()==="idle",thinking:r()==="thinking",acting:r()==="acting",awaiting:r()==="awaiting_approval",error:r()==="error"}),set_checked(w,i()),set_attribute(ee,"placeholder",get(f)?"Agent is working...":"Type a command..."),ee.disabled=get(f),ie.disabled=R},[()=>get(f)||!get(p).trim()]),delegated("change",w,R=>{var Z;return(Z=d())==null?void 0:Z(R.target.checked)}),delegated("keydown",ee,y),bind_value(ee,()=>get(p),R=>set(p,R)),delegated("click",ie,_),append(e,S),pop(x)}delegate(["change","click","keydown"]),create_custom_element(AgentPanel,{messages:{},agentState:{},currentStep:{},maxSteps:{},autoApprove:{},onsend:{},onstop:{},onapprove:{},onskip:{},onautoapprovechange:{}},[],[],{mode:"open"});var root_2$2=from_html('<div class="loading svelte-zp32f3"><span class="spinner svelte-zp32f3"></span> Loading notes...</div>'),root_3$1=from_html('<div class="error-msg svelte-zp32f3"> <button class="retry-btn svelte-zp32f3">Retry</button></div>'),root_5$1=from_html('<button class="note-row site-note svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="1.8"></circle><path d="M2 12h20M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10A15.3 15.3 0 0112 2" stroke="currentColor" stroke-width="1.8"></path></svg> <div class="note-info svelte-zp32f3"><span class="note-name svelte-zp32f3"> </span> <span class="note-preview svelte-zp32f3"> </span></div></div> <span class="note-edit-hint svelte-zp32f3">edit</span></button>'),root_6$1=from_html('<button class="note-row site-note empty svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="1.8"></circle><path d="M2 12h20M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10A15.3 15.3 0 0112 2" stroke="currentColor" stroke-width="1.8"></path></svg> <span class="note-name add-prompt svelte-zp32f3">Add site-wide notes</span></div> <svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"></path></svg></button>'),root_7$1=from_html('<div class="section-divider svelte-zp32f3"><span>Routes</span></div>'),root_9$1=from_html('<span class="current-badge svelte-zp32f3">current</span>'),root_8$1=from_html('<button><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z" stroke="currentColor" stroke-width="1.8"></path><path d="M13 2v7h7" stroke="currentColor" stroke-width="1.8"></path></svg> <div class="note-info svelte-zp32f3"><span class="note-name svelte-zp32f3"> <!></span> <span class="note-preview svelte-zp32f3"> </span></div></div> <span class="note-edit-hint svelte-zp32f3">edit</span></button>'),root_10=from_html('<button class="note-row add-route svelte-zp32f3"><div class="note-row-left svelte-zp32f3"><svg class="note-icon svelte-zp32f3" width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> <span class="note-name add-prompt svelte-zp32f3"> </span></div></button>'),root_11$1=from_html('<div class="empty-state svelte-zp32f3"><svg width="28" height="28" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="1.5"></path><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg> <p class="svelte-zp32f3">No notes yet</p> <p class="empty-hint svelte-zp32f3">Notes give context to the page agent about your app</p></div>'),root_4$1=from_html("<!> <!> <!> <!> <!>",1),root_1$2=from_html('<div class="notes-list svelte-zp32f3"><div class="list-header svelte-zp32f3"><span class="list-title svelte-zp32f3">Notes</span> <button class="new-btn svelte-zp32f3" title="New site-wide note"><svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"></path></svg> New</button></div> <!></div>'),root_13$1=from_html('<div class="preview-area svelte-zp32f3"><!></div>'),root_14$1=from_html('<div class="field svelte-zp32f3"><label for="note-content" class="svelte-zp32f3">Content <span class="label-hint svelte-zp32f3">(markdown)</span></label> <textarea id="note-content" placeholder="Describe this page/app for the agent... Supports **bold**, *italic*, # headers, - lists, `code`" rows="12" class="svelte-zp32f3"></textarea></div>'),root_15$1=from_html('<div class="error-msg compact svelte-zp32f3"> </div>'),root_16$1=from_html("<button> </button>"),root_17$1=from_html('<span class="spinner svelte-zp32f3"></span>'),root_12$1=from_html('<div class="note-editor svelte-zp32f3"><div class="editor-header svelte-zp32f3"><button class="back-btn svelte-zp32f3" title="Back to list"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> <span class="editor-route svelte-zp32f3"> </span> <button> </button></div> <div class="editor-body svelte-zp32f3"><div class="field svelte-zp32f3"><label for="note-title" class="svelte-zp32f3">Title</label> <input id="note-title" type="text" placeholder="Note title" class="svelte-zp32f3"/></div> <!> <!></div> <div class="editor-actions svelte-zp32f3"><!> <div class="action-spacer svelte-zp32f3"></div> <button class="cancel-btn svelte-zp32f3">Cancel</button> <button class="save-btn svelte-zp32f3"><!> </button></div></div>'),root$2=from_html('<div class="notes-panel svelte-zp32f3"><!></div>');const $$css$2={hash:"svelte-zp32f3",code:`.notes-panel.svelte-zp32f3 {display:flex;flex-direction:column;height:100%;overflow:hidden;}
114
116
 
115
117
  /* List view */.notes-list.svelte-zp32f3 {display:flex;flex-direction:column;overflow-y:auto;padding:0;}.list-header.svelte-zp32f3 {display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-bottom:1px solid #1f2937;}.list-title.svelte-zp32f3 {font-size:13px;font-weight:600;color:#e5e7eb;}.new-btn.svelte-zp32f3 {display:inline-flex;align-items:center;gap:4px;padding:4px 10px;background:#1f2937;border:1px solid #374151;border-radius:5px;color:#d1d5db;font-size:11px;font-family:inherit;cursor:pointer;transition:background 0.15s;}.new-btn.svelte-zp32f3:hover:not(:disabled) {background:#374151;}.new-btn.svelte-zp32f3:disabled {opacity:0.4;cursor:not-allowed;}
116
118
 
@@ -122,8 +124,8 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
122
124
  animation: svelte-zp32f3-notes-spin 0.6s linear infinite;}
123
125
  @keyframes svelte-zp32f3-notes-spin {
124
126
  to { transform: rotate(360deg); }
125
- }`};function NotesPanel(e,t){push(t,!0),append_styles(e,$$css$2);let n=prop(t,"endpoint",7),r=prop(t,"project",7),o=prop(t,"onnoteschanged",7),s=state(proxy([])),i=state(!1),a=state(""),l=state(!1),u=state(proxy(window.location.pathname)),c=state("list"),d=state(null),p=state(!1),g=state(""),_=state(""),y=state(null),h=state(!1),f=state(!1),b=user_derived(()=>get(s).find(w=>w.route===null)),m=user_derived(()=>get(s).filter(w=>w.route!==null).sort((w,z)=>(w.route||"").localeCompare(z.route||""))),x=user_derived(()=>get(s).some(w=>w.route===get(u)));async function S(){set(i,!0),set(a,"");const w=await fetchNotes(n(),r());set(s,w.notes,!0),w.error&&set(a,w.error,!0),set(i,!1)}user_effect(()=>{n()&&r()&&S()}),user_effect(()=>{const w=setInterval(()=>{window.location.pathname!==get(u)&&set(u,window.location.pathname,!0)},1e3);return()=>clearInterval(w)});function N(w){set(d,w,!0),set(p,!1),set(g,w.title,!0),set(_,w.content,!0),set(y,w.route,!0),set(h,!1),set(f,!1),set(c,"edit")}function P(w){set(d,null),set(p,!0),set(g,w?ne(w):"Site-wide notes",!0),set(_,""),set(y,w,!0),set(h,!1),set(f,!1),set(c,"edit")}function M(){set(c,"list"),set(d,null),set(p,!1),set(f,!1)}async function re(){var w,z;if(get(g).trim()){if(set(l,!0),get(p)){const R=await createNote(n(),{project:r(),route:get(y),title:get(g).trim(),content:get(_)});R.ok&&R.note?(set(s,[...get(s),R.note],!0),(w=o())==null||w(),M()):set(a,R.error||"Failed to create note",!0)}else if(get(d)){const R=await updateNote(n(),get(d).id,{title:get(g).trim(),content:get(_)});R.ok?(set(s,get(s).map(k=>k.id===get(d).id?{...k,title:get(g).trim(),content:get(_),updated_at:new Date().toISOString()}:k),!0),(z=o())==null||z(),M()):set(a,R.error||"Failed to update note",!0)}set(l,!1)}}async function oe(){var z;if(!get(d))return;if(!get(f)){set(f,!0);return}set(l,!0);const w=await deleteNote(n(),get(d).id);w.ok?(set(s,get(s).filter(R=>R.id!==get(d).id),!0),(z=o())==null||z(),M()):set(a,w.error||"Failed to delete note",!0),set(l,!1)}function ne(w){return w||"Site-wide"}function ce(w){return w?w.split(`
126
- `).filter(z=>z.trim()).length:0}function _e(w){if(!w)return'<span style="color:#6b7280;font-style:italic">No content</span>';let z=w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return z=z.replace(/```([^`]*?)```/gs,'<pre style="background:#1f2937;padding:8px;border-radius:4px;font-size:11px;overflow-x:auto;margin:4px 0">$1</pre>'),z=z.replace(/`([^`]+)`/g,'<code style="background:#1f2937;padding:1px 4px;border-radius:3px;font-size:11px">$1</code>'),z=z.replace(/^### (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:12px;color:#d1d5db">$1</strong>'),z=z.replace(/^## (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:13px;color:#e5e7eb">$1</strong>'),z=z.replace(/^# (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:14px;color:#f3f4f6">$1</strong>'),z=z.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),z=z.replace(/\*(.+?)\*/g,"<em>$1</em>"),z=z.replace(/^- (.+)$/gm,'<span style="display:block;padding-left:12px">&#8226; $1</span>'),z=z.replace(/^(\d+)\. (.+)$/gm,'<span style="display:block;padding-left:12px">$1. $2</span>'),z=z.replace(/\n(?!<)/g,"<br>"),z}function ge(w){w.key==="Escape"&&get(c)==="edit"&&(w.stopPropagation(),M())}var $e={get endpoint(){return n()},set endpoint(w){n(w),flushSync()},get project(){return r()},set project(w){r(w),flushSync()},get onnoteschanged(){return o()},set onnoteschanged(w){o(w),flushSync()}},be=root$2(),ye=child(be);{var de=w=>{var z=root_1$2(),R=child(z),k=sibling(child(R),2);reset(R);var U=sibling(R,2);{var D=J=>{var ee=root_2$2();append(J,ee)},K=J=>{var ee=root_3$1(),ie=child(ee),I=sibling(ie);reset(ee),template_effect(()=>set_text(ie,`${get(a)??""} `)),delegated("click",I,S),append(J,ee)},j=J=>{var ee=root_4$1(),ie=first_child(ee);{var I=A=>{var O=root_5$1(),L=child(O),F=sibling(child(L),2),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2),se=child(H);reset(H),reset(F),reset(L),next(2),reset(O),template_effect((ke,xe)=>{set_text(C,get(b).title||"Site-wide notes"),set_text(se,`${ke??""} line${xe??""}`)},[()=>ce(get(b).content),()=>ce(get(b).content)!==1?"s":""]),delegated("click",O,()=>N(get(b))),append(A,O)},Z=A=>{var O=root_6$1();delegated("click",O,()=>P(null)),append(A,O)};if_block(ie,A=>{get(b)?A(I):A(Z,!1)})}var W=sibling(ie,2);{var T=A=>{var O=root_7$1();append(A,O)};if_block(W,A=>{(get(m).length>0||!get(x))&&A(T)})}var V=sibling(W,2);each(V,17,()=>get(m),index,(A,O)=>{var L=root_8$1();let F;var q=child(L),C=sibling(child(q),2),H=child(C),se=child(H),ke=sibling(se);{var xe=rt=>{var Be=root_9$1();append(rt,Be)};if_block(ke,rt=>{get(O).route===get(u)&&rt(xe)})}reset(H);var Ue=sibling(H,2),Ke=child(Ue);reset(Ue),reset(C),reset(q),next(2),reset(L),template_effect((rt,Be)=>{F=set_class(L,1,"note-row svelte-zp32f3",null,F,{current:get(O).route===get(u)}),set_text(se,`${get(O).route??""} `),set_text(Ke,`${rt??""} line${Be??""}`)},[()=>ce(get(O).content),()=>ce(get(O).content)!==1?"s":""]),delegated("click",L,()=>N(get(O))),append(A,L)});var Q=sibling(V,2);{var G=A=>{var O=root_10(),L=child(O),F=sibling(child(L),2),q=child(F);reset(F),reset(L),reset(O),template_effect(()=>set_text(q,`Add note for ${get(u)??""}`)),delegated("click",O,()=>P(get(u))),append(A,O)};if_block(Q,A=>{get(x)||A(G)})}var we=sibling(Q,2);{var fe=A=>{var O=root_11$1();append(A,O)};if_block(we,A=>{get(s).length===0&&!get(i)&&A(fe)})}append(J,ee)};if_block(U,J=>{get(i)?J(D):get(a)?J(K,1):J(j,!1)})}reset(z),template_effect(()=>k.disabled=!!get(b)),delegated("click",k,()=>P(null)),transition(3,z,()=>slide,()=>({duration:200})),append(w,z)},v=w=>{var z=root_12$1(),R=child(z),k=child(R),U=sibling(k,2),D=child(U,!0);reset(U);var K=sibling(U,2);let j;var J=child(K,!0);reset(K),reset(R);var ee=sibling(R,2),ie=child(ee),I=sibling(child(ie),2);remove_input_defaults(I),reset(ie);var Z=sibling(ie,2);{var W=C=>{var H=root_13$1(),se=child(H);html(se,()=>_e(get(_))),reset(H),append(C,H)},T=C=>{var H=root_14$1(),se=sibling(child(H),2);remove_textarea_child(se),reset(H),template_effect(()=>se.disabled=get(l)),bind_value(se,()=>get(_),ke=>set(_,ke)),append(C,H)};if_block(Z,C=>{get(h)?C(W):C(T,!1)})}var V=sibling(Z,2);{var Q=C=>{var H=root_15$1(),se=child(H,!0);reset(H),template_effect(()=>set_text(se,get(a))),append(C,H)};if_block(V,C=>{get(a)&&C(Q)})}reset(ee);var G=sibling(ee,2),we=child(G);{var fe=C=>{var H=root_16$1();let se;var ke=child(H,!0);reset(H),template_effect(()=>{se=set_class(H,1,"delete-btn svelte-zp32f3",null,se,{confirm:get(f)}),H.disabled=get(l),set_text(ke,get(f)?"Confirm delete?":"Delete")}),delegated("click",H,oe),append(C,H)};if_block(we,C=>{get(p)||C(fe)})}var A=sibling(we,4),O=sibling(A,2),L=child(O);{var F=C=>{var H=root_17$1();append(C,H)};if_block(L,C=>{get(l)&&C(F)})}var q=sibling(L);reset(O),reset(G),reset(z),template_effect(C=>{set_text(D,get(y)?get(y):"Site-wide"),j=set_class(K,1,"preview-toggle svelte-zp32f3",null,j,{active:get(h)}),set_text(J,get(h)?"Edit":"Preview"),I.disabled=get(l),A.disabled=get(l),O.disabled=C,set_text(q,` ${get(p)?"Create":"Save"}`)},[()=>get(l)||!get(g).trim()]),delegated("click",k,M),delegated("click",K,()=>set(h,!get(h))),bind_value(I,()=>get(g),C=>set(g,C)),delegated("click",A,M),delegated("click",O,re),transition(3,z,()=>slide,()=>({duration:200})),append(w,z)};if_block(ye,w=>{get(c)==="list"?w(de):get(c)==="edit"&&w(v,1)})}return reset(be),delegated("keydown",be,ge),append(e,be),pop($e)}delegate(["keydown","click"]),create_custom_element(NotesPanel,{endpoint:{},project:{},onnoteschanged:{}},[],[],{mode:"open"});function $constructor(e,t,n){function r(a,l){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(e),t(a,l);for(const c in i.prototype)c in a||Object.defineProperty(a,c,{value:i.prototype[c].bind(a)});a._zod.constr=i,a._zod.def=l}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var l;const u=n!=null&&n.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var l,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class $ZodAsyncError extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const globalConfig={};function config(e){return globalConfig}function getEnumValues(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function jsonStringifyReplacer(e,t){return typeof t=="bigint"?t.toString():t}function cached(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nullish(e){return e==null}function cleanRegex(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function floatSafeRemainder(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function defineLazy(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function assignProp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function esc(e){return JSON.stringify(e)}const captureStackTrace=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const allowsEval=cached(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(isObject(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function clone(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function normalizeParams(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){const n={},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(n[o]=r.shape[o])}return clone(e,{...e._zod.def,shape:n,checks:[]})}function omit(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete n[o]}return clone(e,{...e._zod.def,shape:n,checks:[]})}function extend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return assignProp(this,"shape",r),r},checks:[]};return clone(e,n)}function merge(e,t){return clone(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}function partial(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)o[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return clone(t,{...t._zod.def,shape:o,checks:[]})}function required(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return clone(t,{...t._zod.def,shape:o,checks:[]})}function aborted(e,t=0){var n;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function prefixIssues(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function unwrapMessage(e){return typeof e=="string"?e:e==null?void 0:e.message}function finalizeIssue(e,t,n){var o,s,i,a,l,u;const r={...e,path:e.path??[]};if(!e.message){const c=unwrapMessage((i=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??unwrapMessage((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??unwrapMessage((l=n.customError)==null?void 0:l.call(n,e))??unwrapMessage((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=c}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function getLengthableOrigin(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function issue(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const initializer$1=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,jsonStringifyReplacer,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function formatError(e,t){const n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(n(i));else{let a=r,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(i))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return o(e),r}function toDotPath(e){const t=[];for(const n of e)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function prettifyError(e){var r;const t=[],n=[...e.issues].sort((o,s)=>o.path.length-s.path.length);for(const o of n)t.push(`✖ ${o.message}`),(r=o.path)!=null&&r.length&&t.push(` → at ${toDotPath(o.path)}`);return t.join(`
127
+ }`};function NotesPanel(e,t){push(t,!0),append_styles(e,$$css$2);let n=prop(t,"endpoint",7),r=prop(t,"project",7),o=prop(t,"onnoteschanged",7),s=state(proxy([])),i=state(!1),a=state(""),l=state(!1),u=state(proxy(window.location.pathname)),c=state("list"),d=state(null),p=state(!1),g=state(""),_=state(""),y=state(null),h=state(!1),f=state(!1),b=user_derived(()=>get(s).find(w=>w.route===null)),m=user_derived(()=>get(s).filter(w=>w.route!==null).sort((w,z)=>(w.route||"").localeCompare(z.route||""))),x=user_derived(()=>get(s).some(w=>w.route===get(u)));async function S(){set(i,!0),set(a,"");const w=await fetchNotes(n(),r());set(s,w.notes,!0),w.error&&set(a,w.error,!0),set(i,!1)}user_effect(()=>{n()&&r()&&S()}),user_effect(()=>{const w=setInterval(()=>{window.location.pathname!==get(u)&&set(u,window.location.pathname,!0)},1e3);return()=>clearInterval(w)});function N(w){set(d,w,!0),set(p,!1),set(g,w.title,!0),set(_,w.content,!0),set(y,w.route,!0),set(h,!1),set(f,!1),set(c,"edit")}function M(w){set(d,null),set(p,!0),set(g,w?ne(w):"Site-wide notes",!0),set(_,""),set(y,w,!0),set(h,!1),set(f,!1),set(c,"edit")}function P(){set(c,"list"),set(d,null),set(p,!1),set(f,!1)}async function re(){var w,z;if(get(g).trim()){if(set(l,!0),get(p)){const I=await createNote(n(),{project:r(),route:get(y),title:get(g).trim(),content:get(_)});I.ok&&I.note?(set(s,[...get(s),I.note],!0),(w=o())==null||w(),P()):set(a,I.error||"Failed to create note",!0)}else if(get(d)){const I=await updateNote(n(),get(d).id,{title:get(g).trim(),content:get(_)});I.ok?(set(s,get(s).map(k=>k.id===get(d).id?{...k,title:get(g).trim(),content:get(_),updated_at:new Date().toISOString()}:k),!0),(z=o())==null||z(),P()):set(a,I.error||"Failed to update note",!0)}set(l,!1)}}async function oe(){var z;if(!get(d))return;if(!get(f)){set(f,!0);return}set(l,!0);const w=await deleteNote(n(),get(d).id);w.ok?(set(s,get(s).filter(I=>I.id!==get(d).id),!0),(z=o())==null||z(),P()):set(a,w.error||"Failed to delete note",!0),set(l,!1)}function ne(w){return w||"Site-wide"}function ce(w){return w?w.split(`
128
+ `).filter(z=>z.trim()).length:0}function _e(w){if(!w)return'<span style="color:#6b7280;font-style:italic">No content</span>';let z=w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return z=z.replace(/```([^`]*?)```/gs,'<pre style="background:#1f2937;padding:8px;border-radius:4px;font-size:11px;overflow-x:auto;margin:4px 0">$1</pre>'),z=z.replace(/`([^`]+)`/g,'<code style="background:#1f2937;padding:1px 4px;border-radius:3px;font-size:11px">$1</code>'),z=z.replace(/^### (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:12px;color:#d1d5db">$1</strong>'),z=z.replace(/^## (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:13px;color:#e5e7eb">$1</strong>'),z=z.replace(/^# (.+)$/gm,'<strong style="display:block;margin-top:8px;font-size:14px;color:#f3f4f6">$1</strong>'),z=z.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),z=z.replace(/\*(.+?)\*/g,"<em>$1</em>"),z=z.replace(/^- (.+)$/gm,'<span style="display:block;padding-left:12px">&#8226; $1</span>'),z=z.replace(/^(\d+)\. (.+)$/gm,'<span style="display:block;padding-left:12px">$1. $2</span>'),z=z.replace(/\n(?!<)/g,"<br>"),z}function ge(w){w.key==="Escape"&&get(c)==="edit"&&(w.stopPropagation(),P())}var $e={get endpoint(){return n()},set endpoint(w){n(w),flushSync()},get project(){return r()},set project(w){r(w),flushSync()},get onnoteschanged(){return o()},set onnoteschanged(w){o(w),flushSync()}},be=root$2(),ye=child(be);{var de=w=>{var z=root_1$2(),I=child(z),k=sibling(child(I),2);reset(I);var U=sibling(I,2);{var D=J=>{var ee=root_2$2();append(J,ee)},K=J=>{var ee=root_3$1(),ie=child(ee),R=sibling(ie);reset(ee),template_effect(()=>set_text(ie,`${get(a)??""} `)),delegated("click",R,S),append(J,ee)},j=J=>{var ee=root_4$1(),ie=first_child(ee);{var R=A=>{var O=root_5$1(),L=child(O),F=sibling(child(L),2),q=child(F),C=child(q,!0);reset(q);var H=sibling(q,2),se=child(H);reset(H),reset(F),reset(L),next(2),reset(O),template_effect((ke,xe)=>{set_text(C,get(b).title||"Site-wide notes"),set_text(se,`${ke??""} line${xe??""}`)},[()=>ce(get(b).content),()=>ce(get(b).content)!==1?"s":""]),delegated("click",O,()=>N(get(b))),append(A,O)},Z=A=>{var O=root_6$1();delegated("click",O,()=>M(null)),append(A,O)};if_block(ie,A=>{get(b)?A(R):A(Z,!1)})}var W=sibling(ie,2);{var T=A=>{var O=root_7$1();append(A,O)};if_block(W,A=>{(get(m).length>0||!get(x))&&A(T)})}var V=sibling(W,2);each(V,17,()=>get(m),index,(A,O)=>{var L=root_8$1();let F;var q=child(L),C=sibling(child(q),2),H=child(C),se=child(H),ke=sibling(se);{var xe=rt=>{var Be=root_9$1();append(rt,Be)};if_block(ke,rt=>{get(O).route===get(u)&&rt(xe)})}reset(H);var Ue=sibling(H,2),Ke=child(Ue);reset(Ue),reset(C),reset(q),next(2),reset(L),template_effect((rt,Be)=>{F=set_class(L,1,"note-row svelte-zp32f3",null,F,{current:get(O).route===get(u)}),set_text(se,`${get(O).route??""} `),set_text(Ke,`${rt??""} line${Be??""}`)},[()=>ce(get(O).content),()=>ce(get(O).content)!==1?"s":""]),delegated("click",L,()=>N(get(O))),append(A,L)});var Q=sibling(V,2);{var G=A=>{var O=root_10(),L=child(O),F=sibling(child(L),2),q=child(F);reset(F),reset(L),reset(O),template_effect(()=>set_text(q,`Add note for ${get(u)??""}`)),delegated("click",O,()=>M(get(u))),append(A,O)};if_block(Q,A=>{get(x)||A(G)})}var we=sibling(Q,2);{var fe=A=>{var O=root_11$1();append(A,O)};if_block(we,A=>{get(s).length===0&&!get(i)&&A(fe)})}append(J,ee)};if_block(U,J=>{get(i)?J(D):get(a)?J(K,1):J(j,!1)})}reset(z),template_effect(()=>k.disabled=!!get(b)),delegated("click",k,()=>M(null)),transition(3,z,()=>slide,()=>({duration:200})),append(w,z)},v=w=>{var z=root_12$1(),I=child(z),k=child(I),U=sibling(k,2),D=child(U,!0);reset(U);var K=sibling(U,2);let j;var J=child(K,!0);reset(K),reset(I);var ee=sibling(I,2),ie=child(ee),R=sibling(child(ie),2);remove_input_defaults(R),reset(ie);var Z=sibling(ie,2);{var W=C=>{var H=root_13$1(),se=child(H);html(se,()=>_e(get(_))),reset(H),append(C,H)},T=C=>{var H=root_14$1(),se=sibling(child(H),2);remove_textarea_child(se),reset(H),template_effect(()=>se.disabled=get(l)),bind_value(se,()=>get(_),ke=>set(_,ke)),append(C,H)};if_block(Z,C=>{get(h)?C(W):C(T,!1)})}var V=sibling(Z,2);{var Q=C=>{var H=root_15$1(),se=child(H,!0);reset(H),template_effect(()=>set_text(se,get(a))),append(C,H)};if_block(V,C=>{get(a)&&C(Q)})}reset(ee);var G=sibling(ee,2),we=child(G);{var fe=C=>{var H=root_16$1();let se;var ke=child(H,!0);reset(H),template_effect(()=>{se=set_class(H,1,"delete-btn svelte-zp32f3",null,se,{confirm:get(f)}),H.disabled=get(l),set_text(ke,get(f)?"Confirm delete?":"Delete")}),delegated("click",H,oe),append(C,H)};if_block(we,C=>{get(p)||C(fe)})}var A=sibling(we,4),O=sibling(A,2),L=child(O);{var F=C=>{var H=root_17$1();append(C,H)};if_block(L,C=>{get(l)&&C(F)})}var q=sibling(L);reset(O),reset(G),reset(z),template_effect(C=>{set_text(D,get(y)?get(y):"Site-wide"),j=set_class(K,1,"preview-toggle svelte-zp32f3",null,j,{active:get(h)}),set_text(J,get(h)?"Edit":"Preview"),R.disabled=get(l),A.disabled=get(l),O.disabled=C,set_text(q,` ${get(p)?"Create":"Save"}`)},[()=>get(l)||!get(g).trim()]),delegated("click",k,P),delegated("click",K,()=>set(h,!get(h))),bind_value(R,()=>get(g),C=>set(g,C)),delegated("click",A,P),delegated("click",O,re),transition(3,z,()=>slide,()=>({duration:200})),append(w,z)};if_block(ye,w=>{get(c)==="list"?w(de):get(c)==="edit"&&w(v,1)})}return reset(be),delegated("keydown",be,ge),append(e,be),pop($e)}delegate(["keydown","click"]),create_custom_element(NotesPanel,{endpoint:{},project:{},onnoteschanged:{}},[],[],{mode:"open"});function $constructor(e,t,n){function r(a,l){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(e),t(a,l);for(const c in i.prototype)c in a||Object.defineProperty(a,c,{value:i.prototype[c].bind(a)});a._zod.constr=i,a._zod.def=l}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var l;const u=n!=null&&n.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var l,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class $ZodAsyncError extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const globalConfig={};function config(e){return globalConfig}function getEnumValues(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function jsonStringifyReplacer(e,t){return typeof t=="bigint"?t.toString():t}function cached(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nullish(e){return e==null}function cleanRegex(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function floatSafeRemainder(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function defineLazy(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function assignProp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function esc(e){return JSON.stringify(e)}const captureStackTrace=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const allowsEval=cached(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(isObject(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function clone(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function normalizeParams(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){const n={},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(n[o]=r.shape[o])}return clone(e,{...e._zod.def,shape:n,checks:[]})}function omit(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete n[o]}return clone(e,{...e._zod.def,shape:n,checks:[]})}function extend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return assignProp(this,"shape",r),r},checks:[]};return clone(e,n)}function merge(e,t){return clone(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}function partial(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)o[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return clone(t,{...t._zod.def,shape:o,checks:[]})}function required(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return clone(t,{...t._zod.def,shape:o,checks:[]})}function aborted(e,t=0){var n;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function prefixIssues(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function unwrapMessage(e){return typeof e=="string"?e:e==null?void 0:e.message}function finalizeIssue(e,t,n){var o,s,i,a,l,u;const r={...e,path:e.path??[]};if(!e.message){const c=unwrapMessage((i=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??unwrapMessage((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??unwrapMessage((l=n.customError)==null?void 0:l.call(n,e))??unwrapMessage((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";r.message=c}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function getLengthableOrigin(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function issue(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const initializer$1=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,jsonStringifyReplacer,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function formatError(e,t){const n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(n(i));else{let a=r,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(i))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return o(e),r}function toDotPath(e){const t=[];for(const n of e)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function prettifyError(e){var r;const t=[],n=[...e.issues].sort((o,s)=>o.path.length-s.path.length);for(const o of n)t.push(`✖ ${o.message}`),(r=o.path)!=null&&r.length&&t.push(` → at ${toDotPath(o.path)}`);return t.join(`
127
129
  `)}const _parse=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new $ZodAsyncError;if(i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(l=>finalizeIssue(l,s,config())));throw captureStackTrace(a,o==null?void 0:o.callee),a}return i.value},_parseAsync=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(l=>finalizeIssue(l,s,config())));throw captureStackTrace(a,o==null?void 0:o.callee),a}return i.value},_safeParse=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new $ZodAsyncError;return s.issues.length?{success:!1,error:new(e??$ZodError)(s.issues.map(i=>finalizeIssue(i,o,config())))}:{success:!0,data:s.value}},safeParse$1=_safeParse($ZodRealError),_safeParseAsync=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>finalizeIssue(i,o,config())))}:{success:!0,data:s.value}},safeParseAsync$1=_safeParseAsync($ZodRealError),cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,duration$1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return new RegExp(_emoji$1,"u")}const ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,hostname=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,e164=/^\+(?:[0-9]){6,14}[0-9]$/,dateSource="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",date$1=new RegExp(`^${dateSource}$`);function timeSource(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function time$1(e){return new RegExp(`^${timeSource(e)}$`)}function datetime$1(e){const t=timeSource({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${dateSource}T(?:${r})$`)}const string$1=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},integer=/^\d+$/,number$1=/^-?\d+(?:\.\d+)?/i,boolean$1=/true|false/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);const n=numericOriginMap[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);const n=numericOriginMap[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):floatSafeRemainder(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{var i;$ZodCheck.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),r=n?"int":"number",[o,s]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=s,n&&(l.pattern=integer)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inst:e})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!nullish(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=getLengthableOrigin(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!nullish(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=getLengthableOrigin(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!nullish(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=getLengthableOrigin(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var n,r;$ZodCheck.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);const n=escapeRegex(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);const n=new RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);const n=new RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Doc{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
128
130
  `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
129
131
  `))}}const version={major:4,minor:0,patch:0},$ZodType=$constructor("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=version;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const i of s._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const s=(i,a,l)=>{let u=aborted(i),c;for(const d of a){if(d._zod.def.when){if(!d._zod.def.when(i))continue}else if(u)continue;const p=i.issues.length,g=d._zod.check(i);if(g instanceof Promise&&(l==null?void 0:l.async)===!1)throw new $ZodAsyncError;if(c||g instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await g,i.issues.length!==p&&(u||(u=aborted(i,p)))});else{if(i.issues.length===p)continue;u||(u=aborted(i,p))}}return c?c.then(()=>i):i};e._zod.run=(i,a)=>{const l=e._zod.parse(i,a);if(l instanceof Promise){if(a.async===!1)throw new $ZodAsyncError;return l.then(u=>s(u,r,a))}return s(l,r,a)}}e["~standard"]={validate:s=>{var i;try{const a=safeParse$1(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return safeParseAsync$1(e,s).then(l=>{var u;return l.success?{value:l.data}:{issues:(u=l.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}}),$ZodString=$constructor("$ZodString",(e,t)=>{var n;$ZodType.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??string$1(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(r))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=n=>{try{const r=n.value,o=new URL(r),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith("/")&&s.endsWith("/")?n.value=s.slice(0,-1):n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=date$1),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=time$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=duration$1),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=n=>{const[r,o]=n.value.split("/");try{if(!o)throw new Error;const s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=base64),$ZodStringFormat.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{isValidBase64(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return isValidBase64(n)}const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{isValidBase64URL(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=n=>{isValidJWT(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??number$1,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),$ZodNumberFormat=$constructor("$ZodNumber",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=boolean$1,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=n=>n}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function handleArrayResult(e,t,n){e.issues.length&&t.issues.push(...prefixIssues(n,e.issues)),t.value[n]=e.value}const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],l=t.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>handleArrayResult(u,n,i))):handleArrayResult(l,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function handleObjectResult(e,t,n){e.issues.length&&t.issues.push(...prefixIssues(n,e.issues)),t.value[n]=e.value}function handleOptionalObjectResult(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...prefixIssues(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const $ZodObject=$constructor("$ZodObject",(e,t)=>{$ZodType.init(e,t);const n=cached(()=>{const d=Object.keys(t.shape);for(const g of d)if(!(t.shape[g]instanceof $ZodType))throw new Error(`Invalid element at key "${g}": expected a Zod schema`);const p=optionalKeys(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});defineLazy(e._zod,"propValues",()=>{const d=t.shape,p={};for(const g in d){const _=d[g]._zod;if(_.values){p[g]??(p[g]=new Set);for(const y of _.values)p[g].add(y)}}return p});const r=d=>{const p=new Doc(["shape","payload","ctx"]),g=n.value,_=b=>{const m=esc(b);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};p.write("const input = payload.value;");const y=Object.create(null);let h=0;for(const b of g.keys)y[b]=`key_${h++}`;p.write("const newResult = {}");for(const b of g.keys)if(g.optionalKeys.has(b)){const m=y[b];p.write(`const ${m} = ${_(b)};`);const x=esc(b);p.write(`
@@ -149,9 +151,9 @@ var pr=Object.defineProperty;var nr=Se=>{throw TypeError(Se)};var hr=(Se,Te,Oe)=
149
151
  if (${m}.issues.length) payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
150
152
  ...iss,
151
153
  path: iss.path ? [${esc(b)}, ...iss.path] : [${esc(b)}]
152
- })));`),p.write(`newResult[${esc(b)}] = ${m}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");const f=p.compile();return(b,m)=>f(d,b,m)};let o;const s=isObject,i=!globalConfig.jitless,l=i&&allowsEval.value,u=t.catchall;let c;e._zod.parse=(d,p)=>{c??(c=n.value);const g=d.value;if(!s(g))return d.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),d;const _=[];if(i&&l&&(p==null?void 0:p.async)===!1&&p.jitless!==!0)o||(o=r(t.shape)),d=o(d,p);else{d.value={};const m=c.shape;for(const x of c.keys){const S=m[x],N=S._zod.run({value:g[x],issues:[]},p),P=S._zod.optin==="optional"&&S._zod.optout==="optional";N instanceof Promise?_.push(N.then(M=>P?handleOptionalObjectResult(M,d,x,g):handleObjectResult(M,d,x))):P?handleOptionalObjectResult(N,d,x,g):handleObjectResult(N,d,x)}}if(!u)return _.length?Promise.all(_).then(()=>d):d;const y=[],h=c.keySet,f=u._zod,b=f.def.type;for(const m of Object.keys(g)){if(h.has(m))continue;if(b==="never"){y.push(m);continue}const x=f.run({value:g[m],issues:[]},p);x instanceof Promise?_.push(x.then(S=>handleObjectResult(S,d,m))):handleObjectResult(x,d,m)}return y.length&&d.issues.push({code:"unrecognized_keys",keys:y,input:g,inst:e}),_.length?Promise.all(_).then(()=>d):d}});function handleUnionResults(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>finalizeIssue(s,r,config())))}),t}const $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>cleanRegex(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>handleUnionResults(i,n,e,r)):handleUnionResults(s,n,e,r)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([l,u])=>handleIntersectionResults(n,l,u)):handleIntersectionResults(n,s,i)}});function mergeValues(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=mergeValues(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=mergeValues(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),aborted(e))return e;const r=mergeValues(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);const n=getEnumValues(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>propertyKeyTypes.has(typeof r)).map(r=>typeof r=="string"?escapeRegex(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new $ZodAsyncError;return n.value=o,n}}),$ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${cleanRegex(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${cleanRegex(n.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>handleDefaultResult(s,t)):handleDefaultResult(o,t)}});function handleDefaultResult(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>handleNonOptionalResult(s,e)):handleNonOptionalResult(o,e)}});function handleNonOptionalResult(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const $ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>finalizeIssue(i,r,config()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>finalizeIssue(s,r,config()))},input:n.value}),n.issues=[]),n)}}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>handlePipeResult(s,t,r)):handlePipeResult(o,t,r)}});function handlePipeResult(e,t,n){return aborted(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(handleReadonlyResult):handleReadonlyResult(o)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}const $ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>handleRefineResult(s,n,r,e));handleRefineResult(o,n,r,e)}});function handleRefineResult(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(issue(o))}}class $ZodRegistry{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function registry(){return new $ZodRegistry}const globalRegistry=registry();function _string(e,t){return new e({type:"string",...normalizeParams(t)})}function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}function _emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}function _unknown(e){return new e({type:"unknown"})}function _never(e,t){return new e({type:"never",...normalizeParams(t)})}function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}function _normalize(e){return _overwrite(t=>t.normalize(e))}function _trim(){return _overwrite(e=>e.trim())}function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}function _array(e,t,n){return new e({type:"array",element:t,...normalizeParams(n)})}function _refine(e,t,n){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(n)})}class JSONSchemaGenerator{constructor(t){this.counter=0,this.metadataRegistry=(t==null?void 0:t.metadata)??globalRegistry,this.target=(t==null?void 0:t.target)??"draft-2020-12",this.unrepresentable=(t==null?void 0:t.unrepresentable)??"throw",this.override=(t==null?void 0:t.override)??(()=>{}),this.io=(t==null?void 0:t.io)??"output",this.seen=new Map}process(t,n={path:[],schemaPath:[]}){var d,p,g;var r;const o=t._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(t,a);const l=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(l)a.schema=l;else{const _={...n,schemaPath:[...n.schemaPath,t],path:n.path},y=t._zod.parent;if(y)a.ref=y,this.process(y,_),this.seen.get(y).isParent=!0;else{const h=a.schema;switch(o.type){case"string":{const f=h;f.type="string";const{minimum:b,maximum:m,format:x,patterns:S,contentEncoding:N}=t._zod.bag;if(typeof b=="number"&&(f.minLength=b),typeof m=="number"&&(f.maxLength=m),x&&(f.format=s[x]??x,f.format===""&&delete f.format),N&&(f.contentEncoding=N),S&&S.size>0){const P=[...S];P.length===1?f.pattern=P[0].source:P.length>1&&(a.schema.allOf=[...P.map(M=>({...this.target==="draft-7"?{type:"string"}:{},pattern:M.source}))])}break}case"number":{const f=h,{minimum:b,maximum:m,format:x,multipleOf:S,exclusiveMaximum:N,exclusiveMinimum:P}=t._zod.bag;typeof x=="string"&&x.includes("int")?f.type="integer":f.type="number",typeof P=="number"&&(f.exclusiveMinimum=P),typeof b=="number"&&(f.minimum=b,typeof P=="number"&&(P>=b?delete f.minimum:delete f.exclusiveMinimum)),typeof N=="number"&&(f.exclusiveMaximum=N),typeof m=="number"&&(f.maximum=m,typeof N=="number"&&(N<=m?delete f.maximum:delete f.exclusiveMaximum)),typeof S=="number"&&(f.multipleOf=S);break}case"boolean":{const f=h;f.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{h.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const f=h,{minimum:b,maximum:m}=t._zod.bag;typeof b=="number"&&(f.minItems=b),typeof m=="number"&&(f.maxItems=m),f.type="array",f.items=this.process(o.element,{..._,path:[..._.path,"items"]});break}case"object":{const f=h;f.type="object",f.properties={};const b=o.shape;for(const S in b)f.properties[S]=this.process(b[S],{..._,path:[..._.path,"properties",S]});const m=new Set(Object.keys(b)),x=new Set([...m].filter(S=>{const N=o.shape[S]._zod;return this.io==="input"?N.optin===void 0:N.optout===void 0}));x.size>0&&(f.required=Array.from(x)),((g=o.catchall)==null?void 0:g._zod.def.type)==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{..._,path:[..._.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{const f=h;f.anyOf=o.options.map((b,m)=>this.process(b,{..._,path:[..._.path,"anyOf",m]}));break}case"intersection":{const f=h,b=this.process(o.left,{..._,path:[..._.path,"allOf",0]}),m=this.process(o.right,{..._,path:[..._.path,"allOf",1]}),x=N=>"allOf"in N&&Object.keys(N).length===1,S=[...x(b)?b.allOf:[b],...x(m)?m.allOf:[m]];f.allOf=S;break}case"tuple":{const f=h;f.type="array";const b=o.items.map((S,N)=>this.process(S,{..._,path:[..._.path,"prefixItems",N]}));if(this.target==="draft-2020-12"?f.prefixItems=b:f.items=b,o.rest){const S=this.process(o.rest,{..._,path:[..._.path,"items"]});this.target==="draft-2020-12"?f.items=S:f.additionalItems=S}o.rest&&(f.items=this.process(o.rest,{..._,path:[..._.path,"items"]}));const{minimum:m,maximum:x}=t._zod.bag;typeof m=="number"&&(f.minItems=m),typeof x=="number"&&(f.maxItems=x);break}case"record":{const f=h;f.type="object",f.propertyNames=this.process(o.keyType,{..._,path:[..._.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{..._,path:[..._.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const f=h,b=getEnumValues(o.entries);b.every(m=>typeof m=="number")&&(f.type="number"),b.every(m=>typeof m=="string")&&(f.type="string"),f.enum=b;break}case"literal":{const f=h,b=[];for(const m of o.values)if(m===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");b.push(Number(m))}else b.push(m);if(b.length!==0)if(b.length===1){const m=b[0];f.type=m===null?"null":typeof m,f.const=m}else b.every(m=>typeof m=="number")&&(f.type="number"),b.every(m=>typeof m=="string")&&(f.type="string"),b.every(m=>typeof m=="boolean")&&(f.type="string"),b.every(m=>m===null)&&(f.type="null"),f.enum=b;break}case"file":{const f=h,b={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:x,mime:S}=t._zod.bag;m!==void 0&&(b.minLength=m),x!==void 0&&(b.maxLength=x),S?S.length===1?(b.contentMediaType=S[0],Object.assign(f,b)):f.anyOf=S.map(N=>({...b,contentMediaType:N})):Object.assign(f,b);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const f=this.process(o.innerType,_);h.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,_),a.ref=o.innerType;break}case"success":{const f=h;f.type="boolean";break}case"default":{this.process(o.innerType,_),a.ref=o.innerType,h.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,_),a.ref=o.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,_),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const f=h,b=t._zod.pattern;if(!b)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=b.source;break}case"pipe":{const f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,_),a.ref=f;break}case"readonly":{this.process(o.innerType,_),a.ref=o.innerType,h.readOnly=!0;break}case"promise":{this.process(o.innerType,_),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,_),a.ref=o.innerType;break}case"lazy":{const f=t._zod.innerType;this.process(f,_),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const u=this.metadataRegistry.get(t);return u&&Object.assign(a.schema,u),this.io==="input"&&isTransforming(t)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(t).schema}emit(t,n){var c,d,p,g,_,y;const r={cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0},o=this.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=h=>{var S;const f=this.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const N=(S=r.external.registry.get(h[0]))==null?void 0:S.id,P=r.external.uri??(re=>re);if(N)return{ref:P(N)};const M=h[1].defId??h[1].schema.id??`schema${this.counter++}`;return h[1].defId=M,{defId:M,ref:`${P("__shared")}#/${f}/${M}`}}if(h[1]===o)return{ref:"#"};const m=`#/${f}/`,x=h[1].schema.id??`__schema${this.counter++}`;return{defId:x,ref:m+x}},i=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:b,defId:m}=s(h);f.def={...f.schema},m&&(f.defId=m);const x=f.schema;for(const S in x)delete x[S];x.$ref=b};if(r.cycles==="throw")for(const h of this.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(c=f.cycle)==null?void 0:c.join("/")}/<root>
154
+ })));`),p.write(`newResult[${esc(b)}] = ${m}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");const f=p.compile();return(b,m)=>f(d,b,m)};let o;const s=isObject,i=!globalConfig.jitless,l=i&&allowsEval.value,u=t.catchall;let c;e._zod.parse=(d,p)=>{c??(c=n.value);const g=d.value;if(!s(g))return d.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),d;const _=[];if(i&&l&&(p==null?void 0:p.async)===!1&&p.jitless!==!0)o||(o=r(t.shape)),d=o(d,p);else{d.value={};const m=c.shape;for(const x of c.keys){const S=m[x],N=S._zod.run({value:g[x],issues:[]},p),M=S._zod.optin==="optional"&&S._zod.optout==="optional";N instanceof Promise?_.push(N.then(P=>M?handleOptionalObjectResult(P,d,x,g):handleObjectResult(P,d,x))):M?handleOptionalObjectResult(N,d,x,g):handleObjectResult(N,d,x)}}if(!u)return _.length?Promise.all(_).then(()=>d):d;const y=[],h=c.keySet,f=u._zod,b=f.def.type;for(const m of Object.keys(g)){if(h.has(m))continue;if(b==="never"){y.push(m);continue}const x=f.run({value:g[m],issues:[]},p);x instanceof Promise?_.push(x.then(S=>handleObjectResult(S,d,m))):handleObjectResult(x,d,m)}return y.length&&d.issues.push({code:"unrecognized_keys",keys:y,input:g,inst:e}),_.length?Promise.all(_).then(()=>d):d}});function handleUnionResults(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>finalizeIssue(s,r,config())))}),t}const $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>cleanRegex(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>handleUnionResults(i,n,e,r)):handleUnionResults(s,n,e,r)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([l,u])=>handleIntersectionResults(n,l,u)):handleIntersectionResults(n,s,i)}});function mergeValues(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=mergeValues(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=mergeValues(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),aborted(e))return e;const r=mergeValues(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);const n=getEnumValues(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>propertyKeyTypes.has(typeof r)).map(r=>typeof r=="string"?escapeRegex(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new $ZodAsyncError;return n.value=o,n}}),$ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${cleanRegex(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${cleanRegex(n.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>handleDefaultResult(s,t)):handleDefaultResult(o,t)}});function handleDefaultResult(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>handleNonOptionalResult(s,e)):handleNonOptionalResult(o,e)}});function handleNonOptionalResult(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const $ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>finalizeIssue(i,r,config()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>finalizeIssue(s,r,config()))},input:n.value}),n.issues=[]),n)}}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>handlePipeResult(s,t,r)):handlePipeResult(o,t,r)}});function handlePipeResult(e,t,n){return aborted(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(handleReadonlyResult):handleReadonlyResult(o)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}const $ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>handleRefineResult(s,n,r,e));handleRefineResult(o,n,r,e)}});function handleRefineResult(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(issue(o))}}class $ZodRegistry{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function registry(){return new $ZodRegistry}const globalRegistry=registry();function _string(e,t){return new e({type:"string",...normalizeParams(t)})}function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}function _emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}function _unknown(e){return new e({type:"unknown"})}function _never(e,t){return new e({type:"never",...normalizeParams(t)})}function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}function _normalize(e){return _overwrite(t=>t.normalize(e))}function _trim(){return _overwrite(e=>e.trim())}function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}function _array(e,t,n){return new e({type:"array",element:t,...normalizeParams(n)})}function _refine(e,t,n){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(n)})}class JSONSchemaGenerator{constructor(t){this.counter=0,this.metadataRegistry=(t==null?void 0:t.metadata)??globalRegistry,this.target=(t==null?void 0:t.target)??"draft-2020-12",this.unrepresentable=(t==null?void 0:t.unrepresentable)??"throw",this.override=(t==null?void 0:t.override)??(()=>{}),this.io=(t==null?void 0:t.io)??"output",this.seen=new Map}process(t,n={path:[],schemaPath:[]}){var d,p,g;var r;const o=t._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(t);if(i)return i.count++,n.schemaPath.includes(t)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};this.seen.set(t,a);const l=(p=(d=t._zod).toJSONSchema)==null?void 0:p.call(d);if(l)a.schema=l;else{const _={...n,schemaPath:[...n.schemaPath,t],path:n.path},y=t._zod.parent;if(y)a.ref=y,this.process(y,_),this.seen.get(y).isParent=!0;else{const h=a.schema;switch(o.type){case"string":{const f=h;f.type="string";const{minimum:b,maximum:m,format:x,patterns:S,contentEncoding:N}=t._zod.bag;if(typeof b=="number"&&(f.minLength=b),typeof m=="number"&&(f.maxLength=m),x&&(f.format=s[x]??x,f.format===""&&delete f.format),N&&(f.contentEncoding=N),S&&S.size>0){const M=[...S];M.length===1?f.pattern=M[0].source:M.length>1&&(a.schema.allOf=[...M.map(P=>({...this.target==="draft-7"?{type:"string"}:{},pattern:P.source}))])}break}case"number":{const f=h,{minimum:b,maximum:m,format:x,multipleOf:S,exclusiveMaximum:N,exclusiveMinimum:M}=t._zod.bag;typeof x=="string"&&x.includes("int")?f.type="integer":f.type="number",typeof M=="number"&&(f.exclusiveMinimum=M),typeof b=="number"&&(f.minimum=b,typeof M=="number"&&(M>=b?delete f.minimum:delete f.exclusiveMinimum)),typeof N=="number"&&(f.exclusiveMaximum=N),typeof m=="number"&&(f.maximum=m,typeof N=="number"&&(N<=m?delete f.maximum:delete f.exclusiveMaximum)),typeof S=="number"&&(f.multipleOf=S);break}case"boolean":{const f=h;f.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{h.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const f=h,{minimum:b,maximum:m}=t._zod.bag;typeof b=="number"&&(f.minItems=b),typeof m=="number"&&(f.maxItems=m),f.type="array",f.items=this.process(o.element,{..._,path:[..._.path,"items"]});break}case"object":{const f=h;f.type="object",f.properties={};const b=o.shape;for(const S in b)f.properties[S]=this.process(b[S],{..._,path:[..._.path,"properties",S]});const m=new Set(Object.keys(b)),x=new Set([...m].filter(S=>{const N=o.shape[S]._zod;return this.io==="input"?N.optin===void 0:N.optout===void 0}));x.size>0&&(f.required=Array.from(x)),((g=o.catchall)==null?void 0:g._zod.def.type)==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{..._,path:[..._.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{const f=h;f.anyOf=o.options.map((b,m)=>this.process(b,{..._,path:[..._.path,"anyOf",m]}));break}case"intersection":{const f=h,b=this.process(o.left,{..._,path:[..._.path,"allOf",0]}),m=this.process(o.right,{..._,path:[..._.path,"allOf",1]}),x=N=>"allOf"in N&&Object.keys(N).length===1,S=[...x(b)?b.allOf:[b],...x(m)?m.allOf:[m]];f.allOf=S;break}case"tuple":{const f=h;f.type="array";const b=o.items.map((S,N)=>this.process(S,{..._,path:[..._.path,"prefixItems",N]}));if(this.target==="draft-2020-12"?f.prefixItems=b:f.items=b,o.rest){const S=this.process(o.rest,{..._,path:[..._.path,"items"]});this.target==="draft-2020-12"?f.items=S:f.additionalItems=S}o.rest&&(f.items=this.process(o.rest,{..._,path:[..._.path,"items"]}));const{minimum:m,maximum:x}=t._zod.bag;typeof m=="number"&&(f.minItems=m),typeof x=="number"&&(f.maxItems=x);break}case"record":{const f=h;f.type="object",f.propertyNames=this.process(o.keyType,{..._,path:[..._.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{..._,path:[..._.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const f=h,b=getEnumValues(o.entries);b.every(m=>typeof m=="number")&&(f.type="number"),b.every(m=>typeof m=="string")&&(f.type="string"),f.enum=b;break}case"literal":{const f=h,b=[];for(const m of o.values)if(m===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");b.push(Number(m))}else b.push(m);if(b.length!==0)if(b.length===1){const m=b[0];f.type=m===null?"null":typeof m,f.const=m}else b.every(m=>typeof m=="number")&&(f.type="number"),b.every(m=>typeof m=="string")&&(f.type="string"),b.every(m=>typeof m=="boolean")&&(f.type="string"),b.every(m=>m===null)&&(f.type="null"),f.enum=b;break}case"file":{const f=h,b={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:x,mime:S}=t._zod.bag;m!==void 0&&(b.minLength=m),x!==void 0&&(b.maxLength=x),S?S.length===1?(b.contentMediaType=S[0],Object.assign(f,b)):f.anyOf=S.map(N=>({...b,contentMediaType:N})):Object.assign(f,b);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const f=this.process(o.innerType,_);h.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,_),a.ref=o.innerType;break}case"success":{const f=h;f.type="boolean";break}case"default":{this.process(o.innerType,_),a.ref=o.innerType,h.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,_),a.ref=o.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,_),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const f=h,b=t._zod.pattern;if(!b)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=b.source;break}case"pipe":{const f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,_),a.ref=f;break}case"readonly":{this.process(o.innerType,_),a.ref=o.innerType,h.readOnly=!0;break}case"promise":{this.process(o.innerType,_),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,_),a.ref=o.innerType;break}case"lazy":{const f=t._zod.innerType;this.process(f,_),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const u=this.metadataRegistry.get(t);return u&&Object.assign(a.schema,u),this.io==="input"&&isTransforming(t)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(t).schema}emit(t,n){var c,d,p,g,_,y;const r={cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0},o=this.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=h=>{var S;const f=this.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const N=(S=r.external.registry.get(h[0]))==null?void 0:S.id,M=r.external.uri??(re=>re);if(N)return{ref:M(N)};const P=h[1].defId??h[1].schema.id??`schema${this.counter++}`;return h[1].defId=P,{defId:P,ref:`${M("__shared")}#/${f}/${P}`}}if(h[1]===o)return{ref:"#"};const m=`#/${f}/`,x=h[1].schema.id??`__schema${this.counter++}`;return{defId:x,ref:m+x}},i=h=>{if(h[1].schema.$ref)return;const f=h[1],{ref:b,defId:m}=s(h);f.def={...f.schema},m&&(f.defId=m);const x=f.schema;for(const S in x)delete x[S];x.$ref=b};if(r.cycles==="throw")for(const h of this.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(c=f.cycle)==null?void 0:c.join("/")}/<root>
153
155
 
154
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of this.seen.entries()){const f=h[1];if(t===h[0]){i(h);continue}if(r.external){const m=(d=r.external.registry.get(h[0]))==null?void 0:d.id;if(t!==h[0]&&m){i(h);continue}}if((p=this.metadataRegistry.get(h[0]))==null?void 0:p.id){i(h);continue}if(f.cycle){i(h);continue}if(f.count>1&&r.reused==="ref"){i(h);continue}}const a=(h,f)=>{const b=this.seen.get(h),m=b.def??b.schema,x={...m};if(b.ref===null)return;const S=b.ref;if(b.ref=null,S){a(S,f);const N=this.seen.get(S).schema;N.$ref&&f.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(N)):(Object.assign(m,N),Object.assign(m,x))}b.isParent||this.override({zodSchema:h,jsonSchema:m,path:b.path??[]})};for(const h of[...this.seen.entries()].reverse())a(h[0],{target:this.target});const l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),(g=r.external)!=null&&g.uri){const h=(_=r.external.registry.get(t))==null?void 0:_.id;if(!h)throw new Error("Schema is missing an `id` property");l.$id=r.external.uri(h)}Object.assign(l,o.def);const u=((y=r.external)==null?void 0:y.defs)??{};for(const h of this.seen.entries()){const f=h[1];f.def&&f.defId&&(u[f.defId]=f.def)}r.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?l.$defs=u:l.definitions=u);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}}function toJSONSchema(e,t){if(e instanceof $ZodRegistry){const r=new JSONSchemaGenerator(t),o={};for(const a of e._idmap.entries()){const[l,u]=a;r.process(u)}const s={},i={registry:e,uri:t==null?void 0:t.uri,defs:o};for(const a of e._idmap.entries()){const[l,u]=a;s[l]=r.emit(u,{...t,external:i})}if(Object.keys(o).length>0){const a=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}const n=new JSONSchemaGenerator(t);return n.process(e),n.emit(e,t)}function isTransforming(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return isTransforming(o.element,n);case"object":{for(const s in o.shape)if(isTransforming(o.shape[s],n))return!0;return!1}case"union":{for(const s of o.options)if(isTransforming(s,n))return!0;return!1}case"intersection":return isTransforming(o.left,n)||isTransforming(o.right,n);case"tuple":{for(const s of o.items)if(isTransforming(s,n))return!0;return!!(o.rest&&isTransforming(o.rest,n))}case"record":return isTransforming(o.keyType,n)||isTransforming(o.valueType,n);case"map":return isTransforming(o.keyType,n)||isTransforming(o.valueType,n);case"set":return isTransforming(o.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return isTransforming(o.innerType,n);case"lazy":return isTransforming(o.getter(),n);case"default":return isTransforming(o.innerType,n);case"prefault":return isTransforming(o.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return isTransforming(o.in,n)||isTransforming(o.out,n);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${o.type}`)}const ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function datetime(e){return _isoDateTime(ZodISODateTime,e)}const ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function date(e){return _isoDate(ZodISODate,e)}const ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function time(e){return _isoTime(ZodISOTime,e)}const ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function duration(e){return _isoDuration(ZodISODuration,e)}const initializer=(e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>formatError(e,n)},flatten:{value:n=>flattenError(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},ZodRealError=$constructor("ZodError",initializer,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>clone(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>parse(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>safeParse(e,n,r),e.parseAsync=async(n,r)=>parseAsync(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>safeParseAsync(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(refine(n,r)),e.superRefine=n=>e.check(superRefine(n)),e.overwrite=n=>e.check(_overwrite(n)),e.optional=()=>optional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=n=>nonoptional(e,n),e.array=()=>array(e),e.or=n=>union([e,n]),e.and=n=>intersection(e,n),e.transform=n=>pipe(e,transform(n)),e.default=n=>_default(e,n),e.prefault=n=>prefault(e,n),e.catch=n=>_catch(e,n),e.pipe=n=>pipe(e,n),e.readonly=()=>readonly(e),e.describe=n=>{const r=e.clone();return globalRegistry.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=globalRegistry.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return globalRegistry.get(e);const r=e.clone();return globalRegistry.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(_regex(...r)),e.includes=(...r)=>e.check(_includes(...r)),e.startsWith=(...r)=>e.check(_startsWith(...r)),e.endsWith=(...r)=>e.check(_endsWith(...r)),e.min=(...r)=>e.check(_minLength(...r)),e.max=(...r)=>e.check(_maxLength(...r)),e.length=(...r)=>e.check(_length(...r)),e.nonempty=(...r)=>e.check(_minLength(1,...r)),e.lowercase=r=>e.check(_lowercase(r)),e.uppercase=r=>e.check(_uppercase(r)),e.trim=()=>e.check(_trim()),e.normalize=(...r)=>e.check(_normalize(...r)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=n=>e.check(_email(ZodEmail,n)),e.url=n=>e.check(_url(ZodURL,n)),e.jwt=n=>e.check(_jwt(ZodJWT,n)),e.emoji=n=>e.check(_emoji(ZodEmoji,n)),e.guid=n=>e.check(_guid(ZodGUID,n)),e.uuid=n=>e.check(_uuid(ZodUUID,n)),e.uuidv4=n=>e.check(_uuidv4(ZodUUID,n)),e.uuidv6=n=>e.check(_uuidv6(ZodUUID,n)),e.uuidv7=n=>e.check(_uuidv7(ZodUUID,n)),e.nanoid=n=>e.check(_nanoid(ZodNanoID,n)),e.guid=n=>e.check(_guid(ZodGUID,n)),e.cuid=n=>e.check(_cuid(ZodCUID,n)),e.cuid2=n=>e.check(_cuid2(ZodCUID2,n)),e.ulid=n=>e.check(_ulid(ZodULID,n)),e.base64=n=>e.check(_base64(ZodBase64,n)),e.base64url=n=>e.check(_base64url(ZodBase64URL,n)),e.xid=n=>e.check(_xid(ZodXID,n)),e.ksuid=n=>e.check(_ksuid(ZodKSUID,n)),e.ipv4=n=>e.check(_ipv4(ZodIPv4,n)),e.ipv6=n=>e.check(_ipv6(ZodIPv6,n)),e.cidrv4=n=>e.check(_cidrv4(ZodCIDRv4,n)),e.cidrv6=n=>e.check(_cidrv6(ZodCIDRv6,n)),e.e164=n=>e.check(_e164(ZodE164,n)),e.datetime=n=>e.check(datetime(n)),e.date=n=>e.check(date(n)),e.time=n=>e.check(time(n)),e.duration=n=>e.check(duration(n))});function string(e){return _string(ZodString,e)}const ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e.gt=(r,o)=>e.check(_gt(r,o)),e.gte=(r,o)=>e.check(_gte(r,o)),e.min=(r,o)=>e.check(_gte(r,o)),e.lt=(r,o)=>e.check(_lt(r,o)),e.lte=(r,o)=>e.check(_lte(r,o)),e.max=(r,o)=>e.check(_lte(r,o)),e.int=r=>e.check(int(r)),e.safe=r=>e.check(int(r)),e.positive=r=>e.check(_gt(0,r)),e.nonnegative=r=>e.check(_gte(0,r)),e.negative=r=>e.check(_lt(0,r)),e.nonpositive=r=>e.check(_lte(0,r)),e.multipleOf=(r,o)=>e.check(_multipleOf(r,o)),e.step=(r,o)=>e.check(_multipleOf(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function number(e){return _number(ZodNumber,e)}const ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}const ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t)});function boolean(e){return _boolean(ZodBoolean,e)}const ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t)});function unknown(){return _unknown(ZodUnknown)}const ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t)});function never(e){return _never(ZodNever,e)}const ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(_minLength(n,r)),e.nonempty=n=>e.check(_minLength(1,n)),e.max=(n,r)=>e.check(_maxLength(n,r)),e.length=(n,r)=>e.check(_length(n,r)),e.unwrap=()=>e.element});function array(e,t){return _array(ZodArray,e,t)}const ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObject.init(e,t),ZodType.init(e,t),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>_enum(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>extend(e,n),e.merge=n=>merge(e,n),e.pick=n=>pick(e,n),e.omit=n=>omit(e,n),e.partial=(...n)=>partial(ZodOptional,e,n[0]),e.required=(...n)=>required(ZodNonOptional,e,n[0])});function object(e,t){const n={type:"object",get shape(){return assignProp(this,"shape",{...e}),this.shape},...normalizeParams(t)};return new ZodObject(n)}const ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}const ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}const ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(o),entries:s})}});function _enum(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ZodEnum({type:"enum",entries:n,...normalizeParams(t)})}const ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=s=>{if(typeof s=="string")n.issues.push(issue(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),n.issues.push(issue(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}const ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}const ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}const ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}const ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}const ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t)});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}const ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t)});function check(e){const t=new $ZodCheck({check:"custom"});return t._zod.check=e,t}function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e){const t=check(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(issue(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(issue(o))}},e(n.value,n)));return t}const identity=e=>e,handler={get:()=>new Proxy(identity,handler)},chalk=new Proxy(identity,handler);var __defProp$3=Object.defineProperty,__name$3=(e,t)=>__defProp$3(e,"name",{value:t,configurable:!0});const InvokeErrorType={NETWORK_ERROR:"network_error",RATE_LIMIT:"rate_limit",SERVER_ERROR:"server_error",NO_TOOL_CALL:"no_tool_call",INVALID_TOOL_ARGS:"invalid_tool_args",TOOL_EXECUTION_ERROR:"tool_execution_error",UNKNOWN:"unknown",AUTH_ERROR:"auth_error",CONTEXT_LENGTH:"context_length",CONTENT_FILTER:"content_filter"},_InvokeError=class extends Error{constructor(n,r,o,s){super(r);te(this,"type");te(this,"retryable");te(this,"statusCode");te(this,"rawError");te(this,"rawResponse");this.name="InvokeError",this.type=n,this.retryable=this.isRetryable(n,o),this.rawError=o,this.rawResponse=s}isRetryable(n,r){return(r==null?void 0:r.name)==="AbortError"?!1:[InvokeErrorType.NETWORK_ERROR,InvokeErrorType.RATE_LIMIT,InvokeErrorType.SERVER_ERROR,InvokeErrorType.NO_TOOL_CALL,InvokeErrorType.INVALID_TOOL_ARGS,InvokeErrorType.TOOL_EXECUTION_ERROR,InvokeErrorType.UNKNOWN].includes(n)}};__name$3(_InvokeError,"InvokeError");let InvokeError=_InvokeError;const debug=console.debug.bind(console,chalk.gray("[LLM]"));function zodToOpenAITool(e,t){return{type:"function",function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:"openapi-3.0"})}}}__name$3(zodToOpenAITool,"zodToOpenAITool");function modelPatch(e){var r,o;const t=e.model||"";if(!t)return e;const n=normalizeModelName(t);return n.startsWith("qwen")&&(debug("Applying Qwen patch: use higher temperature for auto fixing"),e.temperature=Math.max(e.temperature||0,1),e.enable_thinking=!1),n.startsWith("claude")&&(debug("Applying Claude patch: disable thinking"),e.thinking={type:"disabled"},e.tool_choice==="required"?(debug('Applying Claude patch: convert tool_choice "required" to { type: "any" }'),e.tool_choice={type:"any"}):(o=(r=e.tool_choice)==null?void 0:r.function)!=null&&o.name&&(debug("Applying Claude patch: convert tool_choice format"),e.tool_choice={type:"tool",name:e.tool_choice.function.name})),n.startsWith("grok")&&(debug("Applying Grok patch: removing tool_choice"),delete e.tool_choice,debug("Applying Grok patch: disable reasoning and thinking"),e.thinking={type:"disabled",effort:"minimal"},e.reasoning={enabled:!1,effort:"low"}),n.startsWith("gpt")&&(debug("Applying GPT patch: set verbosity to low"),e.verbosity="low",n.startsWith("gpt-52")?(debug("Applying GPT-52 patch: disable reasoning"),e.reasoning_effort="none"):n.startsWith("gpt-51")?(debug("Applying GPT-51 patch: disable reasoning"),e.reasoning_effort="none"):n.startsWith("gpt-54")?(debug("Applying GPT-5.4 patch: skip reasoning_effort because chat/completions rejects it with function tools"),delete e.reasoning_effort):n.startsWith("gpt-5-mini")?(debug("Applying GPT-5-mini patch: set reasoning effort to low, temperature to 1"),e.reasoning_effort="low",e.temperature=1):n.startsWith("gpt-5")&&(debug("Applying GPT-5 patch: set reasoning effort to low"),e.reasoning_effort="low")),n.startsWith("gemini")&&(debug("Applying Gemini patch: set reasoning effort to minimal"),e.reasoning_effort="minimal"),e}__name$3(modelPatch,"modelPatch");function normalizeModelName(e){let t=e.toLowerCase();return t.includes("/")&&(t=t.split("/")[1]),t=t.replace(/_/g,""),t=t.replace(/\./g,""),t}__name$3(normalizeModelName,"normalizeModelName");const _OpenAIClient=class{constructor(t){te(this,"config");te(this,"fetch");this.config=t,this.fetch=t.customFetch}async invoke(t,n,r,o){var m,x,S,N,P,M,re,oe,ne,ce,_e,ge,$e,be,ye,de,v,w;const s=Object.entries(n).map(([z,R])=>zodToOpenAITool(z,R)),i={model:this.config.model,temperature:this.config.temperature,messages:t,tools:s,parallel_tool_calls:!1,tool_choice:o!=null&&o.toolChoiceName?{type:"function",function:{name:o.toolChoiceName}}:"required"};modelPatch(i);let a;try{a=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(i),signal:r})}catch(z){const R=(z==null?void 0:z.name)==="AbortError",k=R?"Network request aborted":"Network request failed";throw R||console.error(z),new InvokeError(InvokeErrorType.NETWORK_ERROR,k,z)}if(!a.ok){const z=await a.json().catch(),R=((m=z.error)==null?void 0:m.message)||a.statusText;throw a.status===401||a.status===403?new InvokeError(InvokeErrorType.AUTH_ERROR,`Authentication failed: ${R}`,z):a.status===429?new InvokeError(InvokeErrorType.RATE_LIMIT,`Rate limit exceeded: ${R}`,z):a.status>=500?new InvokeError(InvokeErrorType.SERVER_ERROR,`Server error: ${R}`,z):new InvokeError(InvokeErrorType.UNKNOWN,`HTTP ${a.status}: ${R}`,z)}const l=await a.json(),u=(x=l.choices)==null?void 0:x[0];if(!u)throw new InvokeError(InvokeErrorType.UNKNOWN,"No choices in response",l);switch(u.finish_reason){case"tool_calls":case"function_call":case"stop":break;case"length":throw new InvokeError(InvokeErrorType.CONTEXT_LENGTH,"Response truncated: max tokens reached",void 0,l);case"content_filter":throw new InvokeError(InvokeErrorType.CONTENT_FILTER,"Content filtered by safety system",void 0,l);default:throw new InvokeError(InvokeErrorType.UNKNOWN,`Unexpected finish_reason: ${u.finish_reason}`,void 0,l)}const d=(S=(o!=null&&o.normalizeResponse?o.normalizeResponse(l):l).choices)==null?void 0:S[0],p=(re=(M=(P=(N=d==null?void 0:d.message)==null?void 0:N.tool_calls)==null?void 0:P[0])==null?void 0:M.function)==null?void 0:re.name;if(!p)throw new InvokeError(InvokeErrorType.NO_TOOL_CALL,"No tool call found in response",void 0,l);const g=n[p];if(!g)throw new InvokeError(InvokeErrorType.UNKNOWN,`Tool "${p}" not found in tools`,void 0,l);const _=(_e=(ce=(ne=(oe=d.message)==null?void 0:oe.tool_calls)==null?void 0:ne[0])==null?void 0:ce.function)==null?void 0:_e.arguments;if(!_)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"No tool call arguments found",void 0,l);let y;try{y=JSON.parse(_)}catch(z){throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Failed to parse tool arguments as JSON",z,l)}const h=g.inputSchema.safeParse(y);if(!h.success)throw console.error(prettifyError(h.error)),new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Tool arguments validation failed",h.error,l);const f=h.data;let b;try{b=await g.execute(f)}catch(z){throw new InvokeError(InvokeErrorType.TOOL_EXECUTION_ERROR,`Tool execution failed: ${z.message}`,z,l)}return{toolCall:{name:p,args:f},toolResult:b,usage:{promptTokens:((ge=l.usage)==null?void 0:ge.prompt_tokens)??0,completionTokens:(($e=l.usage)==null?void 0:$e.completion_tokens)??0,totalTokens:((be=l.usage)==null?void 0:be.total_tokens)??0,cachedTokens:(de=(ye=l.usage)==null?void 0:ye.prompt_tokens_details)==null?void 0:de.cached_tokens,reasoningTokens:(w=(v=l.usage)==null?void 0:v.completion_tokens_details)==null?void 0:w.reasoning_tokens},rawResponse:l,rawRequest:i}}};__name$3(_OpenAIClient,"OpenAIClient");let OpenAIClient=_OpenAIClient;const LLM_MAX_RETRIES=2,DEFAULT_TEMPERATURE=.7;function parseLLMConfig(e){if(!e.baseURL||!e.apiKey||!e.model)throw new Error("[PageAgent] LLM configuration required. Please provide: baseURL, apiKey, model. See: https://alibaba.github.io/page-agent/docs/features/models");return{baseURL:e.baseURL,apiKey:e.apiKey,model:e.model,temperature:e.temperature??DEFAULT_TEMPERATURE,maxRetries:e.maxRetries??LLM_MAX_RETRIES,customFetch:(e.customFetch??fetch).bind(globalThis)}}__name$3(parseLLMConfig,"parseLLMConfig");const _LLM=class extends EventTarget{constructor(n){super();te(this,"config");te(this,"client");this.config=parseLLMConfig(n),this.client=new OpenAIClient(this.config)}async invoke(n,r,o,s){return await withRetry(async()=>{if(o.aborted)throw new Error("AbortError");return await this.client.invoke(n,r,o,s)},{maxRetries:this.config.maxRetries,onRetry:__name$3(i=>{this.dispatchEvent(new CustomEvent("retry",{detail:{attempt:i,maxAttempts:this.config.maxRetries}}))},"onRetry"),onError:__name$3(i=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:i}}))},"onError")})}};__name$3(_LLM,"LLM");let LLM=_LLM;async function withRetry(e,t){var o;let n=0,r=null;for(;n<=t.maxRetries;){n>0&&(t.onRetry(n),await new Promise(s=>setTimeout(s,100)));try{return await e()}catch(s){if(((o=s==null?void 0:s.rawError)==null?void 0:o.name)==="AbortError"||(console.error(s),t.onError(s),s instanceof InvokeError&&!s.retryable))throw s;r=s,n++,await new Promise(i=>setTimeout(i,100))}}throw r}__name$3(withRetry,"withRetry");var __defProp$2=Object.defineProperty,__typeError$1=e=>{throw TypeError(e)},__defNormalProp$1=(e,t,n)=>t in e?__defProp$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__name$2=(e,t)=>__defProp$2(e,"name",{value:t,configurable:!0}),__publicField$1=(e,t,n)=>__defNormalProp$1(e,typeof t!="symbol"?t+"":t,n),__accessCheck$1=(e,t,n)=>t.has(e)||__typeError$1("Cannot "+n),__privateGet$1=(e,t,n)=>(__accessCheck$1(e,t,"read from private field"),n?n.call(e):t.get(e)),__privateAdd$1=(e,t,n)=>t.has(e)?__typeError$1("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),__privateSet$1=(e,t,n,r)=>(__accessCheck$1(e,t,"write to private field"),t.set(e,n),n),__privateMethod$1=(e,t,n)=>(__accessCheck$1(e,t,"access private method"),n),_status,_llm,_abortController,_observations,_states,_PageAgentCore_instances,emitStatusChange_fn,emitHistoryChange_fn,emitActivity_fn,setStatus_fn,packMacroTool_fn,getSystemPrompt_fn,getInstructions_fn,handleObservations_fn,assembleUserPrompt_fn,onDone_fn;const SYSTEM_PROMPT=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
156
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of this.seen.entries()){const f=h[1];if(t===h[0]){i(h);continue}if(r.external){const m=(d=r.external.registry.get(h[0]))==null?void 0:d.id;if(t!==h[0]&&m){i(h);continue}}if((p=this.metadataRegistry.get(h[0]))==null?void 0:p.id){i(h);continue}if(f.cycle){i(h);continue}if(f.count>1&&r.reused==="ref"){i(h);continue}}const a=(h,f)=>{const b=this.seen.get(h),m=b.def??b.schema,x={...m};if(b.ref===null)return;const S=b.ref;if(b.ref=null,S){a(S,f);const N=this.seen.get(S).schema;N.$ref&&f.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(N)):(Object.assign(m,N),Object.assign(m,x))}b.isParent||this.override({zodSchema:h,jsonSchema:m,path:b.path??[]})};for(const h of[...this.seen.entries()].reverse())a(h[0],{target:this.target});const l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),(g=r.external)!=null&&g.uri){const h=(_=r.external.registry.get(t))==null?void 0:_.id;if(!h)throw new Error("Schema is missing an `id` property");l.$id=r.external.uri(h)}Object.assign(l,o.def);const u=((y=r.external)==null?void 0:y.defs)??{};for(const h of this.seen.entries()){const f=h[1];f.def&&f.defId&&(u[f.defId]=f.def)}r.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?l.$defs=u:l.definitions=u);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}}function toJSONSchema(e,t){if(e instanceof $ZodRegistry){const r=new JSONSchemaGenerator(t),o={};for(const a of e._idmap.entries()){const[l,u]=a;r.process(u)}const s={},i={registry:e,uri:t==null?void 0:t.uri,defs:o};for(const a of e._idmap.entries()){const[l,u]=a;s[l]=r.emit(u,{...t,external:i})}if(Object.keys(o).length>0){const a=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}const n=new JSONSchemaGenerator(t);return n.process(e),n.emit(e,t)}function isTransforming(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return isTransforming(o.element,n);case"object":{for(const s in o.shape)if(isTransforming(o.shape[s],n))return!0;return!1}case"union":{for(const s of o.options)if(isTransforming(s,n))return!0;return!1}case"intersection":return isTransforming(o.left,n)||isTransforming(o.right,n);case"tuple":{for(const s of o.items)if(isTransforming(s,n))return!0;return!!(o.rest&&isTransforming(o.rest,n))}case"record":return isTransforming(o.keyType,n)||isTransforming(o.valueType,n);case"map":return isTransforming(o.keyType,n)||isTransforming(o.valueType,n);case"set":return isTransforming(o.valueType,n);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return isTransforming(o.innerType,n);case"lazy":return isTransforming(o.getter(),n);case"default":return isTransforming(o.innerType,n);case"prefault":return isTransforming(o.innerType,n);case"custom":return!1;case"transform":return!0;case"pipe":return isTransforming(o.in,n)||isTransforming(o.out,n);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${o.type}`)}const ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function datetime(e){return _isoDateTime(ZodISODateTime,e)}const ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function date(e){return _isoDate(ZodISODate,e)}const ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function time(e){return _isoTime(ZodISOTime,e)}const ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function duration(e){return _isoDuration(ZodISODuration,e)}const initializer=(e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>formatError(e,n)},flatten:{value:n=>flattenError(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},ZodRealError=$constructor("ZodError",initializer,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>clone(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>parse(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>safeParse(e,n,r),e.parseAsync=async(n,r)=>parseAsync(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>safeParseAsync(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(refine(n,r)),e.superRefine=n=>e.check(superRefine(n)),e.overwrite=n=>e.check(_overwrite(n)),e.optional=()=>optional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=n=>nonoptional(e,n),e.array=()=>array(e),e.or=n=>union([e,n]),e.and=n=>intersection(e,n),e.transform=n=>pipe(e,transform(n)),e.default=n=>_default(e,n),e.prefault=n=>prefault(e,n),e.catch=n=>_catch(e,n),e.pipe=n=>pipe(e,n),e.readonly=()=>readonly(e),e.describe=n=>{const r=e.clone();return globalRegistry.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=globalRegistry.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return globalRegistry.get(e);const r=e.clone();return globalRegistry.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(_regex(...r)),e.includes=(...r)=>e.check(_includes(...r)),e.startsWith=(...r)=>e.check(_startsWith(...r)),e.endsWith=(...r)=>e.check(_endsWith(...r)),e.min=(...r)=>e.check(_minLength(...r)),e.max=(...r)=>e.check(_maxLength(...r)),e.length=(...r)=>e.check(_length(...r)),e.nonempty=(...r)=>e.check(_minLength(1,...r)),e.lowercase=r=>e.check(_lowercase(r)),e.uppercase=r=>e.check(_uppercase(r)),e.trim=()=>e.check(_trim()),e.normalize=(...r)=>e.check(_normalize(...r)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=n=>e.check(_email(ZodEmail,n)),e.url=n=>e.check(_url(ZodURL,n)),e.jwt=n=>e.check(_jwt(ZodJWT,n)),e.emoji=n=>e.check(_emoji(ZodEmoji,n)),e.guid=n=>e.check(_guid(ZodGUID,n)),e.uuid=n=>e.check(_uuid(ZodUUID,n)),e.uuidv4=n=>e.check(_uuidv4(ZodUUID,n)),e.uuidv6=n=>e.check(_uuidv6(ZodUUID,n)),e.uuidv7=n=>e.check(_uuidv7(ZodUUID,n)),e.nanoid=n=>e.check(_nanoid(ZodNanoID,n)),e.guid=n=>e.check(_guid(ZodGUID,n)),e.cuid=n=>e.check(_cuid(ZodCUID,n)),e.cuid2=n=>e.check(_cuid2(ZodCUID2,n)),e.ulid=n=>e.check(_ulid(ZodULID,n)),e.base64=n=>e.check(_base64(ZodBase64,n)),e.base64url=n=>e.check(_base64url(ZodBase64URL,n)),e.xid=n=>e.check(_xid(ZodXID,n)),e.ksuid=n=>e.check(_ksuid(ZodKSUID,n)),e.ipv4=n=>e.check(_ipv4(ZodIPv4,n)),e.ipv6=n=>e.check(_ipv6(ZodIPv6,n)),e.cidrv4=n=>e.check(_cidrv4(ZodCIDRv4,n)),e.cidrv6=n=>e.check(_cidrv6(ZodCIDRv6,n)),e.e164=n=>e.check(_e164(ZodE164,n)),e.datetime=n=>e.check(datetime(n)),e.date=n=>e.check(date(n)),e.time=n=>e.check(time(n)),e.duration=n=>e.check(duration(n))});function string(e){return _string(ZodString,e)}const ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e.gt=(r,o)=>e.check(_gt(r,o)),e.gte=(r,o)=>e.check(_gte(r,o)),e.min=(r,o)=>e.check(_gte(r,o)),e.lt=(r,o)=>e.check(_lt(r,o)),e.lte=(r,o)=>e.check(_lte(r,o)),e.max=(r,o)=>e.check(_lte(r,o)),e.int=r=>e.check(int(r)),e.safe=r=>e.check(int(r)),e.positive=r=>e.check(_gt(0,r)),e.nonnegative=r=>e.check(_gte(0,r)),e.negative=r=>e.check(_lt(0,r)),e.nonpositive=r=>e.check(_lte(0,r)),e.multipleOf=(r,o)=>e.check(_multipleOf(r,o)),e.step=(r,o)=>e.check(_multipleOf(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function number(e){return _number(ZodNumber,e)}const ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}const ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t)});function boolean(e){return _boolean(ZodBoolean,e)}const ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t)});function unknown(){return _unknown(ZodUnknown)}const ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t)});function never(e){return _never(ZodNever,e)}const ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(_minLength(n,r)),e.nonempty=n=>e.check(_minLength(1,n)),e.max=(n,r)=>e.check(_maxLength(n,r)),e.length=(n,r)=>e.check(_length(n,r)),e.unwrap=()=>e.element});function array(e,t){return _array(ZodArray,e,t)}const ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObject.init(e,t),ZodType.init(e,t),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>_enum(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>extend(e,n),e.merge=n=>merge(e,n),e.pick=n=>pick(e,n),e.omit=n=>omit(e,n),e.partial=(...n)=>partial(ZodOptional,e,n[0]),e.required=(...n)=>required(ZodNonOptional,e,n[0])});function object(e,t){const n={type:"object",get shape(){return assignProp(this,"shape",{...e}),this.shape},...normalizeParams(t)};return new ZodObject(n)}const ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}const ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}const ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(o),entries:s})}});function _enum(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ZodEnum({type:"enum",entries:n,...normalizeParams(t)})}const ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=s=>{if(typeof s=="string")n.issues.push(issue(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),n.issues.push(issue(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}const ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}const ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}const ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}const ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}const ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t)});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}const ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t)});function check(e){const t=new $ZodCheck({check:"custom"});return t._zod.check=e,t}function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e){const t=check(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(issue(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(issue(o))}},e(n.value,n)));return t}const identity=e=>e,handler={get:()=>new Proxy(identity,handler)},chalk=new Proxy(identity,handler);var __defProp$3=Object.defineProperty,__name$3=(e,t)=>__defProp$3(e,"name",{value:t,configurable:!0});const InvokeErrorType={NETWORK_ERROR:"network_error",RATE_LIMIT:"rate_limit",SERVER_ERROR:"server_error",NO_TOOL_CALL:"no_tool_call",INVALID_TOOL_ARGS:"invalid_tool_args",TOOL_EXECUTION_ERROR:"tool_execution_error",UNKNOWN:"unknown",AUTH_ERROR:"auth_error",CONTEXT_LENGTH:"context_length",CONTENT_FILTER:"content_filter"},_InvokeError=class extends Error{constructor(n,r,o,s){super(r);te(this,"type");te(this,"retryable");te(this,"statusCode");te(this,"rawError");te(this,"rawResponse");this.name="InvokeError",this.type=n,this.retryable=this.isRetryable(n,o),this.rawError=o,this.rawResponse=s}isRetryable(n,r){return(r==null?void 0:r.name)==="AbortError"?!1:[InvokeErrorType.NETWORK_ERROR,InvokeErrorType.RATE_LIMIT,InvokeErrorType.SERVER_ERROR,InvokeErrorType.NO_TOOL_CALL,InvokeErrorType.INVALID_TOOL_ARGS,InvokeErrorType.TOOL_EXECUTION_ERROR,InvokeErrorType.UNKNOWN].includes(n)}};__name$3(_InvokeError,"InvokeError");let InvokeError=_InvokeError;const debug=console.debug.bind(console,chalk.gray("[LLM]"));function zodToOpenAITool(e,t){return{type:"function",function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:"openapi-3.0"})}}}__name$3(zodToOpenAITool,"zodToOpenAITool");function modelPatch(e){var r,o;const t=e.model||"";if(!t)return e;const n=normalizeModelName(t);return n.startsWith("qwen")&&(debug("Applying Qwen patch: use higher temperature for auto fixing"),e.temperature=Math.max(e.temperature||0,1),e.enable_thinking=!1),n.startsWith("claude")&&(debug("Applying Claude patch: disable thinking"),e.thinking={type:"disabled"},e.tool_choice==="required"?(debug('Applying Claude patch: convert tool_choice "required" to { type: "any" }'),e.tool_choice={type:"any"}):(o=(r=e.tool_choice)==null?void 0:r.function)!=null&&o.name&&(debug("Applying Claude patch: convert tool_choice format"),e.tool_choice={type:"tool",name:e.tool_choice.function.name})),n.startsWith("grok")&&(debug("Applying Grok patch: removing tool_choice"),delete e.tool_choice,debug("Applying Grok patch: disable reasoning and thinking"),e.thinking={type:"disabled",effort:"minimal"},e.reasoning={enabled:!1,effort:"low"}),n.startsWith("gpt")&&(debug("Applying GPT patch: set verbosity to low"),e.verbosity="low",n.startsWith("gpt-52")?(debug("Applying GPT-52 patch: disable reasoning"),e.reasoning_effort="none"):n.startsWith("gpt-51")?(debug("Applying GPT-51 patch: disable reasoning"),e.reasoning_effort="none"):n.startsWith("gpt-54")?(debug("Applying GPT-5.4 patch: skip reasoning_effort because chat/completions rejects it with function tools"),delete e.reasoning_effort):n.startsWith("gpt-5-mini")?(debug("Applying GPT-5-mini patch: set reasoning effort to low, temperature to 1"),e.reasoning_effort="low",e.temperature=1):n.startsWith("gpt-5")&&(debug("Applying GPT-5 patch: set reasoning effort to low"),e.reasoning_effort="low")),n.startsWith("gemini")&&(debug("Applying Gemini patch: set reasoning effort to minimal"),e.reasoning_effort="minimal"),e}__name$3(modelPatch,"modelPatch");function normalizeModelName(e){let t=e.toLowerCase();return t.includes("/")&&(t=t.split("/")[1]),t=t.replace(/_/g,""),t=t.replace(/\./g,""),t}__name$3(normalizeModelName,"normalizeModelName");const _OpenAIClient=class{constructor(t){te(this,"config");te(this,"fetch");this.config=t,this.fetch=t.customFetch}async invoke(t,n,r,o){var m,x,S,N,M,P,re,oe,ne,ce,_e,ge,$e,be,ye,de,v,w;const s=Object.entries(n).map(([z,I])=>zodToOpenAITool(z,I)),i={model:this.config.model,temperature:this.config.temperature,messages:t,tools:s,parallel_tool_calls:!1,tool_choice:o!=null&&o.toolChoiceName?{type:"function",function:{name:o.toolChoiceName}}:"required"};modelPatch(i);let a;try{a=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(i),signal:r})}catch(z){const I=(z==null?void 0:z.name)==="AbortError",k=I?"Network request aborted":"Network request failed";throw I||console.error(z),new InvokeError(InvokeErrorType.NETWORK_ERROR,k,z)}if(!a.ok){const z=await a.json().catch(),I=((m=z.error)==null?void 0:m.message)||a.statusText;throw a.status===401||a.status===403?new InvokeError(InvokeErrorType.AUTH_ERROR,`Authentication failed: ${I}`,z):a.status===429?new InvokeError(InvokeErrorType.RATE_LIMIT,`Rate limit exceeded: ${I}`,z):a.status>=500?new InvokeError(InvokeErrorType.SERVER_ERROR,`Server error: ${I}`,z):new InvokeError(InvokeErrorType.UNKNOWN,`HTTP ${a.status}: ${I}`,z)}const l=await a.json(),u=(x=l.choices)==null?void 0:x[0];if(!u)throw new InvokeError(InvokeErrorType.UNKNOWN,"No choices in response",l);switch(u.finish_reason){case"tool_calls":case"function_call":case"stop":break;case"length":throw new InvokeError(InvokeErrorType.CONTEXT_LENGTH,"Response truncated: max tokens reached",void 0,l);case"content_filter":throw new InvokeError(InvokeErrorType.CONTENT_FILTER,"Content filtered by safety system",void 0,l);default:throw new InvokeError(InvokeErrorType.UNKNOWN,`Unexpected finish_reason: ${u.finish_reason}`,void 0,l)}const d=(S=(o!=null&&o.normalizeResponse?o.normalizeResponse(l):l).choices)==null?void 0:S[0],p=(re=(P=(M=(N=d==null?void 0:d.message)==null?void 0:N.tool_calls)==null?void 0:M[0])==null?void 0:P.function)==null?void 0:re.name;if(!p)throw new InvokeError(InvokeErrorType.NO_TOOL_CALL,"No tool call found in response",void 0,l);const g=n[p];if(!g)throw new InvokeError(InvokeErrorType.UNKNOWN,`Tool "${p}" not found in tools`,void 0,l);const _=(_e=(ce=(ne=(oe=d.message)==null?void 0:oe.tool_calls)==null?void 0:ne[0])==null?void 0:ce.function)==null?void 0:_e.arguments;if(!_)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"No tool call arguments found",void 0,l);let y;try{y=JSON.parse(_)}catch(z){throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Failed to parse tool arguments as JSON",z,l)}const h=g.inputSchema.safeParse(y);if(!h.success)throw console.error(prettifyError(h.error)),new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Tool arguments validation failed",h.error,l);const f=h.data;let b;try{b=await g.execute(f)}catch(z){throw new InvokeError(InvokeErrorType.TOOL_EXECUTION_ERROR,`Tool execution failed: ${z.message}`,z,l)}return{toolCall:{name:p,args:f},toolResult:b,usage:{promptTokens:((ge=l.usage)==null?void 0:ge.prompt_tokens)??0,completionTokens:(($e=l.usage)==null?void 0:$e.completion_tokens)??0,totalTokens:((be=l.usage)==null?void 0:be.total_tokens)??0,cachedTokens:(de=(ye=l.usage)==null?void 0:ye.prompt_tokens_details)==null?void 0:de.cached_tokens,reasoningTokens:(w=(v=l.usage)==null?void 0:v.completion_tokens_details)==null?void 0:w.reasoning_tokens},rawResponse:l,rawRequest:i}}};__name$3(_OpenAIClient,"OpenAIClient");let OpenAIClient=_OpenAIClient;const LLM_MAX_RETRIES=2,DEFAULT_TEMPERATURE=.7;function parseLLMConfig(e){if(!e.baseURL||!e.apiKey||!e.model)throw new Error("[PageAgent] LLM configuration required. Please provide: baseURL, apiKey, model. See: https://alibaba.github.io/page-agent/docs/features/models");return{baseURL:e.baseURL,apiKey:e.apiKey,model:e.model,temperature:e.temperature??DEFAULT_TEMPERATURE,maxRetries:e.maxRetries??LLM_MAX_RETRIES,customFetch:(e.customFetch??fetch).bind(globalThis)}}__name$3(parseLLMConfig,"parseLLMConfig");const _LLM=class extends EventTarget{constructor(n){super();te(this,"config");te(this,"client");this.config=parseLLMConfig(n),this.client=new OpenAIClient(this.config)}async invoke(n,r,o,s){return await withRetry(async()=>{if(o.aborted)throw new Error("AbortError");return await this.client.invoke(n,r,o,s)},{maxRetries:this.config.maxRetries,onRetry:__name$3(i=>{this.dispatchEvent(new CustomEvent("retry",{detail:{attempt:i,maxAttempts:this.config.maxRetries}}))},"onRetry"),onError:__name$3(i=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:i}}))},"onError")})}};__name$3(_LLM,"LLM");let LLM=_LLM;async function withRetry(e,t){var o;let n=0,r=null;for(;n<=t.maxRetries;){n>0&&(t.onRetry(n),await new Promise(s=>setTimeout(s,100)));try{return await e()}catch(s){if(((o=s==null?void 0:s.rawError)==null?void 0:o.name)==="AbortError"||(console.error(s),t.onError(s),s instanceof InvokeError&&!s.retryable))throw s;r=s,n++,await new Promise(i=>setTimeout(i,100))}}throw r}__name$3(withRetry,"withRetry");var __defProp$2=Object.defineProperty,__typeError$1=e=>{throw TypeError(e)},__defNormalProp$1=(e,t,n)=>t in e?__defProp$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__name$2=(e,t)=>__defProp$2(e,"name",{value:t,configurable:!0}),__publicField$1=(e,t,n)=>__defNormalProp$1(e,typeof t!="symbol"?t+"":t,n),__accessCheck$1=(e,t,n)=>t.has(e)||__typeError$1("Cannot "+n),__privateGet$1=(e,t,n)=>(__accessCheck$1(e,t,"read from private field"),n?n.call(e):t.get(e)),__privateAdd$1=(e,t,n)=>t.has(e)?__typeError$1("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),__privateSet$1=(e,t,n,r)=>(__accessCheck$1(e,t,"write to private field"),t.set(e,n),n),__privateMethod$1=(e,t,n)=>(__accessCheck$1(e,t,"access private method"),n),_status,_llm,_abortController,_observations,_states,_PageAgentCore_instances,emitStatusChange_fn,emitHistoryChange_fn,emitActivity_fn,setStatus_fn,packMacroTool_fn,getSystemPrompt_fn,getInstructions_fn,handleObservations_fn,assembleUserPrompt_fn,onDone_fn;const SYSTEM_PROMPT=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
155
157
 
156
158
  <intro>
157
159
  You excel at following tasks:
@@ -345,7 +347,7 @@ ${s}
345
347
 
346
348
  `,t+=`</browser_state>
347
349
 
348
- `,t},"#assembleUserPrompt"),onDone_fn=__name$2(function(e=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),__privateMethod$1(this,_PageAgentCore_instances,setStatus_fn).call(this,e?"completed":"error"),__privateGet$1(this,_abortController).abort()},"#onDone"),__name$2(_PageAgentCore,"PageAgentCore");let PageAgentCore=_PageAgentCore;var __defProp$1=Object.defineProperty,__name$1=(e,t)=>__defProp$1(e,"name",{value:t,configurable:!0});async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}__name$1(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:n,y:r}})),await waitFor(.3)}__name$1(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const n=e.get(t);if(!n)throw new Error(`No interactive element found at index ${t}`);const r=n.ref;if(!r)throw new Error(`Element at index ${t} does not have a reference`);if(!(r instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return r}__name$1(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}__name$1(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}__name$1(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){const n=e.isContentEditable;if(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)&&!n)throw new Error("Element is not an input, textarea, or contenteditable");await clickElement(e),n?(e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"deleteContent"}))&&(e.innerText="",e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"deleteContent"}))),e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))&&(e.innerText=t,e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertText",data:t}))),e.dispatchEvent(new Event("change",{bubbles:!0})),e.blur()):e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t),n||e.dispatchEvent(new Event("input",{bubbles:!0})),await waitFor(.1),blurLastClickedElement()}__name$1(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const r=Array.from(e.options).find(o=>{var s;return((s=o.textContent)==null?void 0:s.trim())===t.trim()});if(!r)throw new Error(`Option with text "${t}" not found in select element`);e.value=r.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}__name$1(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;typeof t.scrollIntoViewIfNeeded=="function"?t.scrollIntoViewIfNeeded():e.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}__name$1(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,n){if(n){const a=n;let l=a,u=!1,c=null,d=0,p=0;const g=t;for(;l&&p<10;){const _=window.getComputedStyle(l),y=/(auto|scroll|overlay)/.test(_.overflowY),h=l.scrollHeight>l.clientHeight;if(y&&h){const f=l.scrollTop,b=l.scrollHeight-l.clientHeight;let m=g/3;m>0?m=Math.min(m,b-f):m=Math.max(m,-f),l.scrollTop=f+m;const S=l.scrollTop-f;if(Math.abs(S)>.5){u=!0,c=l,d=S;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,p++}return u?`Scrolled container (${c==null?void 0:c.tagName}) by ${d}px`:`No scrollable container found for element (${a.tagName})`}const r=t,o=__name$1(a=>a.clientHeight>=window.innerHeight*.5,"bigEnough"),s=__name$1(a=>a&&/(auto|scroll|overlay)/.test(getComputedStyle(a).overflowY)&&a.scrollHeight>a.clientHeight&&o(a),"canScroll");let i=document.activeElement;for(;i&&!s(i)&&i!==document.body;)i=i.parentElement;if(i=s(i)?i:Array.from(document.querySelectorAll("*")).find(s)||document.scrollingElement||document.documentElement,i===document.scrollingElement||i===document.documentElement||i===document.body){const a=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,r);const u=window.scrollY,c=u-a;if(Math.abs(c)<1)return r>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled page by ${c}px. Reached the bottom of the page.`:p?`✅ Scrolled page by ${c}px. Reached the top of the page.`:`✅ Scrolled page by ${c}px.`}else{const a=i.scrollTop,l=i.scrollHeight-i.clientHeight;i.scrollBy({top:r,behavior:"smooth"}),await waitFor(.1);const u=i.scrollTop,c=u-a;if(Math.abs(c)<1)return r>0?`⚠️ Already at the bottom of container (${i.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${i.tagName}), cannot scroll up further.`;const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the bottom.`:p?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the top.`:`✅ Scrolled container (${i.tagName}) by ${c}px.`}}__name$1(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,n){if(n){const a=n;let l=a,u=!1,c=null,d=0,p=0;const g=e?t:-t;for(;l&&p<10;){const _=window.getComputedStyle(l),y=/(auto|scroll|overlay)/.test(_.overflowX),h=l.scrollWidth>l.clientWidth;if(y&&h){const f=l.scrollLeft,b=l.scrollWidth-l.clientWidth;let m=g/3;m>0?m=Math.min(m,b-f):m=Math.max(m,-f),l.scrollLeft=f+m;const S=l.scrollLeft-f;if(Math.abs(S)>.5){u=!0,c=l,d=S;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,p++}return u?`Scrolled container (${c==null?void 0:c.tagName}) horizontally by ${d}px`:`No horizontally scrollable container found for element (${a.tagName})`}const r=e?t:-t,o=__name$1(a=>a.clientWidth>=window.innerWidth*.5,"bigEnough"),s=__name$1(a=>a&&/(auto|scroll|overlay)/.test(getComputedStyle(a).overflowX)&&a.scrollWidth>a.clientWidth&&o(a),"canScroll");let i=document.activeElement;for(;i&&!s(i)&&i!==document.body;)i=i.parentElement;if(i=s(i)?i:Array.from(document.querySelectorAll("*")).find(s)||document.scrollingElement||document.documentElement,i===document.scrollingElement||i===document.documentElement||i===document.body){const a=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(r,0);const u=window.scrollX,c=u-a;if(Math.abs(c)<1)return r>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled page by ${c}px. Reached the right edge of the page.`:p?`✅ Scrolled page by ${c}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${c}px.`}else{const a=i.scrollLeft,l=i.scrollWidth-i.clientWidth;i.scrollBy({left:r,behavior:"smooth"}),await waitFor(.1);const u=i.scrollLeft,c=u-a;if(Math.abs(c)<1)return r>0?`⚠️ Already at the right edge of container (${i.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${i.tagName}), cannot scroll left further.`;const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the right edge.`:p?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the left edge.`:`✅ Scrolled container (${i.tagName}) horizontally by ${c}px.`}}__name$1(scrollHorizontally,"scrollHorizontally");const domTree=__name$1((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:n,highlightOpacity:r,highlightLabelOpacity:o}=e,{doHighlightElements:s,focusHighlightIndex:i,viewportExpansion:a,debugMode:l}=e;let u=0;const c=new WeakMap;function d(v,w){!v||v.nodeType!==Node.ELEMENT_NODE||c.set(v,{...c.get(v),...w})}__name$1(d,"addExtraData");const p={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:__name$1(()=>{p.boundingRects=new WeakMap,p.clientRects=new WeakMap,p.computedStyles=new WeakMap},"clearCache")};function g(v){if(!v)return null;if(p.boundingRects.has(v))return p.boundingRects.get(v);const w=v.getBoundingClientRect();return w&&p.boundingRects.set(v,w),w}__name$1(g,"getCachedBoundingRect");function _(v){if(!v)return null;if(p.computedStyles.has(v))return p.computedStyles.get(v);const w=window.getComputedStyle(v);return w&&p.computedStyles.set(v,w),w}__name$1(_,"getCachedComputedStyle");function y(v){if(!v)return null;if(p.clientRects.has(v))return p.clientRects.get(v);const w=v.getClientRects();return w&&p.clientRects.set(v,w),w}__name$1(y,"getCachedClientRects");const h={},f={current:0},b="playwright-highlight-container";function m(v,w,z=null){if(!v)return w;const R=[];let k=null,U=20,D=16,K=null;try{let j=document.getElementById(b);j||(j=document.createElement("div"),j.id=b,j.style.position="fixed",j.style.pointerEvents="none",j.style.top="0",j.style.left="0",j.style.width="100%",j.style.height="100%",j.style.zIndex="2147483640",j.style.backgroundColor="transparent",document.body.appendChild(j));const J=v.getClientRects();if(!J||J.length===0)return w;const ee=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],ie=w%ee.length;let I=ee[ie];const Z=I+Math.floor(r*255).toString(16).padStart(2,"0");I=I+Math.floor(o*255).toString(16).padStart(2,"0");let W={x:0,y:0};if(z){const F=z.getBoundingClientRect();W.x=F.left,W.y=F.top}const T=document.createDocumentFragment();for(const F of J){if(F.width===0||F.height===0)continue;const q=document.createElement("div");q.style.position="fixed",q.style.border=`2px solid ${I}`,q.style.backgroundColor=Z,q.style.pointerEvents="none",q.style.boxSizing="border-box";const C=F.top+W.y,H=F.left+W.x;q.style.top=`${C}px`,q.style.left=`${H}px`,q.style.width=`${F.width}px`,q.style.height=`${F.height}px`,T.appendChild(q),R.push({element:q,initialRect:F})}const V=J[0];k=document.createElement("div"),k.className="playwright-highlight-label",k.style.position="fixed",k.style.background=I,k.style.color="white",k.style.padding="1px 4px",k.style.borderRadius="4px",k.style.fontSize=`${Math.min(12,Math.max(8,V.height/2))}px`,k.textContent=w.toString(),U=k.offsetWidth>0?k.offsetWidth:U,D=k.offsetHeight>0?k.offsetHeight:D;const Q=V.top+W.y,G=V.left+W.x;let we=Q+2,fe=G+V.width-U-2;(V.width<U+4||V.height<D+4)&&(we=Q-D-2,fe=G+V.width-U,fe<W.x&&(fe=G)),we=Math.max(0,Math.min(we,window.innerHeight-D)),fe=Math.max(0,Math.min(fe,window.innerWidth-U)),k.style.top=`${we}px`,k.style.left=`${fe}px`,T.appendChild(k);const L=__name$1((F,q)=>{let C=0;return(...H)=>{const se=performance.now();if(!(se-C<q))return C=se,F(...H)}},"throttleFunction")(__name$1(()=>{const F=v.getClientRects();let q={x:0,y:0};if(z){const C=z.getBoundingClientRect();q.x=C.left,q.y=C.top}if(R.forEach((C,H)=>{if(H<F.length){const se=F[H],ke=se.top+q.y,xe=se.left+q.x;C.element.style.top=`${ke}px`,C.element.style.left=`${xe}px`,C.element.style.width=`${se.width}px`,C.element.style.height=`${se.height}px`,C.element.style.display=se.width===0||se.height===0?"none":"block"}else C.element.style.display="none"}),F.length<R.length)for(let C=F.length;C<R.length;C++)R[C].element.style.display="none";if(k&&F.length>0){const C=F[0],H=C.top+q.y,se=C.left+q.x;let ke=H+2,xe=se+C.width-U-2;(C.width<U+4||C.height<D+4)&&(ke=H-D-2,xe=se+C.width-U,xe<q.x&&(xe=se)),ke=Math.max(0,Math.min(ke,window.innerHeight-D)),xe=Math.max(0,Math.min(xe,window.innerWidth-U)),k.style.top=`${ke}px`,k.style.left=`${xe}px`,k.style.display="block"}else k&&(k.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),K=__name$1(()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L),R.forEach(F=>F.element.remove()),k&&k.remove()},"cleanupFn"),j.appendChild(T),w+1}finally{K&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(K)}}__name$1(m,"highlightElement");function x(v){if(!v||v.nodeType!==Node.ELEMENT_NODE)return null;const w=_(v);if(!w)return null;const z=w.display;if(z==="inline"||z==="inline-block")return null;const R=w.overflowX,k=w.overflowY,U=R==="auto"||R==="scroll",D=k==="auto"||k==="scroll";if(!U&&!D)return null;const K=v.scrollWidth-v.clientWidth,j=v.scrollHeight-v.clientHeight,J=4;if(K<J&&j<J||!D&&K<J||!U&&j<J)return null;const ee=v.scrollTop,ie=v.scrollLeft,I=v.scrollWidth-v.clientWidth-v.scrollLeft,Z=v.scrollHeight-v.clientHeight-v.scrollTop,W={top:ee,right:I,bottom:Z,left:ie};return d(v,{scrollable:!0,scrollData:W}),W}__name$1(x,"isScrollableElement");function S(v){try{if(a===-1){const D=v.parentElement;if(!D)return!1;try{return D.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const j=window.getComputedStyle(D);return j.display!=="none"&&j.visibility!=="hidden"&&j.opacity!=="0"}}const w=document.createRange();w.selectNodeContents(v);const z=w.getClientRects();if(!z||z.length===0)return!1;let R=!1,k=!1;for(const D of z)if(D.width>0&&D.height>0&&(R=!0,!(D.bottom<-a||D.top>window.innerHeight+a||D.right<-a||D.left>window.innerWidth+a))){k=!0;break}if(!R||!k)return!1;const U=v.parentElement;if(!U)return!1;try{return U.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const K=window.getComputedStyle(U);return K.display!=="none"&&K.visibility!=="hidden"&&K.opacity!=="0"}}catch(w){return console.warn("Error checking text node visibility:",w),!1}}__name$1(S,"isTextNodeVisible");function N(v){if(!v||!v.tagName)return!1;const w=new Set(["body","div","main","article","section","nav","header","footer"]),z=v.tagName.toLowerCase();return w.has(z)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(z)}__name$1(N,"isElementAccepted");function P(v){const w=_(v);return v.offsetWidth>0&&v.offsetHeight>0&&(w==null?void 0:w.visibility)!=="hidden"&&(w==null?void 0:w.display)!=="none"}__name$1(P,"isElementVisible");function M(v){var Z,W;if(!v||v.nodeType!==Node.ELEMENT_NODE||t.includes(v))return!1;if(n.includes(v))return!0;const w=v.tagName.toLowerCase(),z=_(v),R=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),k=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function U(T){return T.tagName.toLowerCase()==="html"?!1:!!(z!=null&&z.cursor&&R.has(z.cursor))}if(__name$1(U,"doesElementHaveInteractivePointer"),U(v))return!0;const K=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),j=new Set(["disabled","readonly"]);if(K.has(w)){if(z!=null&&z.cursor&&k.has(z.cursor))return!1;for(const T of j)if(v.hasAttribute(T)||v.getAttribute(T)==="true"||v.getAttribute(T)==="")return!1;return!(v.disabled||v.readOnly||v.inert)}const J=v.getAttribute("role"),ee=v.getAttribute("aria-role");if(v.getAttribute("contenteditable")==="true"||v.isContentEditable||v.classList&&(v.classList.contains("button")||v.classList.contains("dropdown-toggle")||v.getAttribute("data-index")||v.getAttribute("data-toggle")==="dropdown"||v.getAttribute("aria-haspopup")==="true"))return!0;const ie=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(K.has(w)||J&&ie.has(J)||ee&&ie.has(ee))return!0;try{if(typeof getEventListeners=="function"){const Q=getEventListeners(v),G=["click","mousedown","mouseup","dblclick"];for(const we of G)if(Q[we]&&Q[we].length>0)return!0}const T=((W=(Z=v==null?void 0:v.ownerDocument)==null?void 0:Z.defaultView)==null?void 0:W.getEventListenersForNode)||window.getEventListenersForNode;if(typeof T=="function"){const Q=T(v),G=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const we of G)for(const fe of Q)if(fe.type===we)return!0}const V=["onclick","onmousedown","onmouseup","ondblclick"];for(const Q of V)if(v.hasAttribute(Q)||typeof v[Q]=="function")return!0}catch{}return!!x(v)}__name$1(M,"isInteractiveElement");function re(v){if(a===-1)return!0;const w=y(v);if(!w||w.length===0)return!1;let z=!1;for(const j of w)if(j.width>0&&j.height>0&&!(j.bottom<-a||j.top>window.innerHeight+a||j.right<-a||j.left>window.innerWidth+a)){z=!0;break}if(!z)return!1;if(v.ownerDocument!==window.document)return!0;let k=Array.from(w).find(j=>j.width>0&&j.height>0);if(!k)return!1;const U=v.getRootNode();if(U instanceof ShadowRoot){const j=k.left+k.width/2,J=k.top+k.height/2;try{const ee=U.elementFromPoint(j,J);if(!ee)return!1;let ie=ee;for(;ie&&ie!==U;){if(ie===v)return!0;ie=ie.parentElement}return!1}catch{return!0}}const D=5;return[{x:k.left+k.width/2,y:k.top+k.height/2},{x:k.left+D,y:k.top+D},{x:k.right-D,y:k.bottom-D}].some(({x:j,y:J})=>{try{const ee=document.elementFromPoint(j,J);if(!ee)return!1;let ie=ee;for(;ie&&ie!==document.documentElement;){if(ie===v)return!0;ie=ie.parentElement}return!1}catch{return!0}})}__name$1(re,"isTopElement");function oe(v,w){if(w===-1)return!0;const z=v.getClientRects();if(!z||z.length===0){const R=g(v);return!R||R.width===0||R.height===0?!1:!(R.bottom<-w||R.top>window.innerHeight+w||R.right<-w||R.left>window.innerWidth+w)}for(const R of z)if(!(R.width===0||R.height===0)&&!(R.bottom<-w||R.top>window.innerHeight+w||R.right<-w||R.left>window.innerWidth+w))return!0;return!1}__name$1(oe,"isInExpandedViewport");function ne(v){if(!v||v.nodeType!==Node.ELEMENT_NODE)return!1;const w=v.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(w)?!0:v.hasAttribute("onclick")||v.hasAttribute("role")||v.hasAttribute("tabindex")||v.hasAttribute("aria-")||v.hasAttribute("data-action")||v.getAttribute("contenteditable")==="true"}__name$1(ne,"isInteractiveCandidate");const ce=new Set(["a","button","input","select","textarea","summary","details","label","option"]),_e=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function ge(v){if(!v||v.nodeType!==Node.ELEMENT_NODE||!P(v))return!1;const w=v.hasAttribute("role")||v.hasAttribute("tabindex")||v.hasAttribute("onclick")||typeof v.onclick=="function",z=/\b(btn|clickable|menu|item|entry|link)\b/i.test(v.className||""),R=!!v.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),k=[...v.children].some(P),U=v.parentElement&&v.parentElement.isSameNode(document.body);return(M(v)||w||z)&&k&&R&&!U}__name$1(ge,"isHeuristicallyInteractive");function $e(v){var R,k;if(!v||v.nodeType!==Node.ELEMENT_NODE)return!1;const w=v.tagName.toLowerCase(),z=v.getAttribute("role");if(w==="iframe"||ce.has(w)||z&&_e.has(z)||v.isContentEditable||v.getAttribute("contenteditable")==="true"||v.hasAttribute("data-testid")||v.hasAttribute("data-cy")||v.hasAttribute("data-test")||v.hasAttribute("onclick")||typeof v.onclick=="function")return!0;try{const U=((k=(R=v==null?void 0:v.ownerDocument)==null?void 0:R.defaultView)==null?void 0:k.getEventListenersForNode)||window.getEventListenersForNode;if(typeof U=="function"){const K=U(v),j=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const J of j)for(const ee of K)if(ee.type===J)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(K=>v.hasAttribute(K)))return!0}catch{}return!!ge(v)}__name$1($e,"isElementDistinctInteraction");function be(v,w,z,R){if(!v.isInteractive)return!1;let k=!1;return R?$e(w)?k=!0:k=!1:k=!0,k&&(v.isInViewport=oe(w,a),(v.isInViewport||a===-1)&&(v.highlightIndex=u++,s))?(i>=0?i===v.highlightIndex&&m(w,v.highlightIndex,z):m(w,v.highlightIndex,z),!0):!1}__name$1(be,"handleHighlighting");function ye(v,w=null,z=!1){var D,K,j,J,ee,ie,I;if(!v||v.id===b||v.nodeType!==Node.ELEMENT_NODE&&v.nodeType!==Node.TEXT_NODE||!v||v.id===b||((D=v.dataset)==null?void 0:D.browserUseIgnore)==="true"||((K=v.dataset)==null?void 0:K.pageAgentIgnore)==="true"||v.getAttribute&&v.getAttribute("aria-hidden")==="true")return null;if(v===document.body){const Z={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const T of v.childNodes){const V=ye(T,w,!1);V&&Z.children.push(V)}const W=`${f.current++}`;return h[W]=Z,W}if(v.nodeType!==Node.ELEMENT_NODE&&v.nodeType!==Node.TEXT_NODE)return null;if(v.nodeType===Node.TEXT_NODE){const Z=(j=v.textContent)==null?void 0:j.trim();if(!Z)return null;const W=v.parentElement;if(!W||W.tagName.toLowerCase()==="script")return null;const T=`${f.current++}`;return h[T]={type:"TEXT_NODE",text:Z,isVisible:S(v)},T}if(v.nodeType===Node.ELEMENT_NODE&&!N(v))return null;if(a!==-1&&!v.shadowRoot){const Z=g(v),W=_(v),T=W&&(W.position==="fixed"||W.position==="sticky"),V=v.offsetWidth>0||v.offsetHeight>0;if(!Z||!T&&!V&&(Z.bottom<-a||Z.top>window.innerHeight+a||Z.right<-a||Z.left>window.innerWidth+a))return null}const R={tagName:v.tagName.toLowerCase(),attributes:{},children:[]};if(ne(v)||v.tagName.toLowerCase()==="iframe"||v.tagName.toLowerCase()==="body"){const Z=((J=v.getAttributeNames)==null?void 0:J.call(v))||[];for(const W of Z){const T=v.getAttribute(W);R.attributes[W]=T}v.tagName.toLowerCase()==="input"&&(v.type==="checkbox"||v.type==="radio")&&(R.attributes.checked=v.checked?"true":"false")}let k=!1;if(v.nodeType===Node.ELEMENT_NODE&&(R.isVisible=P(v),R.isVisible)){R.isTopElement=re(v);const Z=v.getAttribute("role"),W=Z==="menu"||Z==="menubar"||Z==="listbox";if((R.isTopElement||W)&&(R.isInteractive=M(v),k=be(R,v,w,z),R.ref=v,R.isInteractive&&Object.keys(R.attributes).length===0)){const T=((ee=v.getAttributeNames)==null?void 0:ee.call(v))||[];for(const V of T){const Q=v.getAttribute(V);R.attributes[V]=Q}}}if(v.tagName){const Z=v.tagName.toLowerCase();if(Z==="iframe")try{const W=v.contentDocument||((ie=v.contentWindow)==null?void 0:ie.document);if(W)for(const T of W.childNodes){const V=ye(T,v,!1);V&&R.children.push(V)}}catch(W){console.warn("Unable to access iframe:",W)}else if(v.isContentEditable||v.getAttribute("contenteditable")==="true"||v.id==="tinymce"||v.classList.contains("mce-content-body")||Z==="body"&&((I=v.getAttribute("data-id"))!=null&&I.startsWith("mce_")))for(const W of v.childNodes){const T=ye(W,w,k);T&&R.children.push(T)}else{if(v.shadowRoot){R.shadowRoot=!0;for(const W of v.shadowRoot.childNodes){const T=ye(W,w,k);T&&R.children.push(T)}}for(const W of v.childNodes){const V=ye(W,w,k||z);V&&R.children.push(V)}}}if(R.tagName==="a"&&R.children.length===0&&!R.attributes.href){const Z=g(v);if(!(Z&&Z.width>0&&Z.height>0||v.offsetWidth>0||v.offsetHeight>0))return null}R.extra=c.get(v)||null;const U=`${f.current++}`;return h[U]=R,U}__name$1(ye,"buildDomTree");const de=ye(document.body);return p.clearCache(),{rootId:de,map:h}},"domTree"),DEFAULT_VIEWPORT_EXPANSION=-1;function resolveViewportExpansion(e){return e??DEFAULT_VIEWPORT_EXPANSION}__name$1(resolveViewportExpansion,"resolveViewportExpansion");const newElementsCache=new WeakMap;function getFlatTree(e){const t=resolveViewportExpansion(e.viewportExpansion),n=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?n.push(i()):n.push(i);const r=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?r.push(i()):r.push(i);const o=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:t,interactiveBlacklist:n,interactiveWhitelist:r,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),s=window.location.href;for(const i in o.map){const a=o.map[i];if(a.isInteractive&&a.ref){const l=a.ref;newElementsCache.has(l)||(newElementsCache.set(l,s),a.isNew=!0)}}return o}__name$1(getFlatTree,"getFlatTree");const globRegexCache=new Map;function globToRegex(e){let t=globRegexCache.get(e);if(!t){const n=e.replace(/[.+^${}()|[\]\\]/g,"\\$&");t=new RegExp(`^${n.replace(/\*/g,".*")}$`),globRegexCache.set(e,t)}return t}__name$1(globToRegex,"globToRegex");function matchAttributes(e,t){const n={};for(const r of t)if(r.includes("*")){const o=globToRegex(r);for(const s of Object.keys(e))o.test(s)&&e[s].trim()&&(n[s]=e[s].trim())}else{const o=e[r];o&&o.trim()&&(n[r]=o.trim())}return n}__name$1(matchAttributes,"matchAttributes");function flatTreeToString(e,t){const n=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns","contenteditable"],r=[...t||[],...n],o=__name$1((d,p)=>d.length>p?d.substring(0,p)+"...":d,"capTextLength"),s=__name$1(d=>{const p=e.map[d];if(!p)return null;if(p.type==="TEXT_NODE"){const g=p;return{type:"text",text:g.text,isVisible:g.isVisible,parent:null,children:[]}}else{const g=p,_=[];if(g.children)for(const y of g.children){const h=s(y);h&&(h.parent=null,_.push(h))}return{type:"element",tagName:g.tagName,attributes:g.attributes??{},isVisible:g.isVisible??!1,isInteractive:g.isInteractive??!1,isTopElement:g.isTopElement??!1,isNew:g.isNew??!1,highlightIndex:g.highlightIndex,parent:null,children:_,extra:g.extra??{}}}},"buildTreeNode"),i=__name$1((d,p=null)=>{d.parent=p;for(const g of d.children)i(g,d)},"setParentReferences"),a=s(e.rootId);if(!a)return"";i(a);const l=__name$1(d=>{let p=d.parent;for(;p;){if(p.type==="element"&&p.highlightIndex!==void 0)return!0;p=p.parent}return!1},"hasParentWithHighlightIndex"),u=__name$1((d,p,g)=>{var h,f,b,m;let _=p;const y=" ".repeat(p);if(d.type==="element"){if(d.highlightIndex!==void 0){_+=1;const x=getAllTextTillNextClickableElement(d);let S="";if(r.length>0&&d.attributes){const M=matchAttributes(d.attributes,r),re=Object.keys(M);if(re.length>1){const ne=new Set,ce={};for(const _e of re){const ge=M[_e];ge.length>5&&(ge in ce?ne.add(_e):ce[ge]=_e)}for(const _e of ne)delete M[_e]}M.role===d.tagName&&delete M.role;const oe=["aria-label","placeholder","title"];for(const ne of oe)M[ne]&&M[ne].toLowerCase().trim()===x.toLowerCase().trim()&&delete M[ne];Object.keys(M).length>0&&(S=Object.entries(M).map(([ne,ce])=>`${ne}=${o(ce,20)}`).join(" "))}const N=d.isNew?`*[${d.highlightIndex}]`:`[${d.highlightIndex}]`;let P=`${y}${N}<${d.tagName??""}`;if(S&&(P+=` ${S}`),d.extra&&d.extra.scrollable){let M="";(h=d.extra.scrollData)!=null&&h.left&&(M+=`left=${d.extra.scrollData.left}, `),(f=d.extra.scrollData)!=null&&f.top&&(M+=`top=${d.extra.scrollData.top}, `),(b=d.extra.scrollData)!=null&&b.right&&(M+=`right=${d.extra.scrollData.right}, `),(m=d.extra.scrollData)!=null&&m.bottom&&(M+=`bottom=${d.extra.scrollData.bottom}`),P+=` data-scrollable="${M}"`}if(x){const M=x.trim();S||(P+=" "),P+=`>${M}`}else S||(P+=" ");P+=" />",g.push(P)}for(const x of d.children)u(x,_,g)}else if(d.type==="text"){if(l(d))return;d.parent&&d.parent.type==="element"&&d.parent.isVisible&&d.parent.isTopElement&&g.push(`${y}${d.text??""}`)}},"processNode"),c=[];return u(a,0,c),c.join(`
350
+ `,t},"#assembleUserPrompt"),onDone_fn=__name$2(function(e=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),__privateMethod$1(this,_PageAgentCore_instances,setStatus_fn).call(this,e?"completed":"error"),__privateGet$1(this,_abortController).abort()},"#onDone"),__name$2(_PageAgentCore,"PageAgentCore");let PageAgentCore=_PageAgentCore;var __defProp$1=Object.defineProperty,__name$1=(e,t)=>__defProp$1(e,"name",{value:t,configurable:!0});async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}__name$1(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:n,y:r}})),await waitFor(.3)}__name$1(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const n=e.get(t);if(!n)throw new Error(`No interactive element found at index ${t}`);const r=n.ref;if(!r)throw new Error(`Element at index ${t} does not have a reference`);if(!(r instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return r}__name$1(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}__name$1(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}__name$1(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){const n=e.isContentEditable;if(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)&&!n)throw new Error("Element is not an input, textarea, or contenteditable");await clickElement(e),n?(e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"deleteContent"}))&&(e.innerText="",e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"deleteContent"}))),e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))&&(e.innerText=t,e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertText",data:t}))),e.dispatchEvent(new Event("change",{bubbles:!0})),e.blur()):e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t),n||e.dispatchEvent(new Event("input",{bubbles:!0})),await waitFor(.1),blurLastClickedElement()}__name$1(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const r=Array.from(e.options).find(o=>{var s;return((s=o.textContent)==null?void 0:s.trim())===t.trim()});if(!r)throw new Error(`Option with text "${t}" not found in select element`);e.value=r.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}__name$1(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;typeof t.scrollIntoViewIfNeeded=="function"?t.scrollIntoViewIfNeeded():e.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}__name$1(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,n){if(n){const a=n;let l=a,u=!1,c=null,d=0,p=0;const g=t;for(;l&&p<10;){const _=window.getComputedStyle(l),y=/(auto|scroll|overlay)/.test(_.overflowY),h=l.scrollHeight>l.clientHeight;if(y&&h){const f=l.scrollTop,b=l.scrollHeight-l.clientHeight;let m=g/3;m>0?m=Math.min(m,b-f):m=Math.max(m,-f),l.scrollTop=f+m;const S=l.scrollTop-f;if(Math.abs(S)>.5){u=!0,c=l,d=S;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,p++}return u?`Scrolled container (${c==null?void 0:c.tagName}) by ${d}px`:`No scrollable container found for element (${a.tagName})`}const r=t,o=__name$1(a=>a.clientHeight>=window.innerHeight*.5,"bigEnough"),s=__name$1(a=>a&&/(auto|scroll|overlay)/.test(getComputedStyle(a).overflowY)&&a.scrollHeight>a.clientHeight&&o(a),"canScroll");let i=document.activeElement;for(;i&&!s(i)&&i!==document.body;)i=i.parentElement;if(i=s(i)?i:Array.from(document.querySelectorAll("*")).find(s)||document.scrollingElement||document.documentElement,i===document.scrollingElement||i===document.documentElement||i===document.body){const a=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,r);const u=window.scrollY,c=u-a;if(Math.abs(c)<1)return r>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled page by ${c}px. Reached the bottom of the page.`:p?`✅ Scrolled page by ${c}px. Reached the top of the page.`:`✅ Scrolled page by ${c}px.`}else{const a=i.scrollTop,l=i.scrollHeight-i.clientHeight;i.scrollBy({top:r,behavior:"smooth"}),await waitFor(.1);const u=i.scrollTop,c=u-a;if(Math.abs(c)<1)return r>0?`⚠️ Already at the bottom of container (${i.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${i.tagName}), cannot scroll up further.`;const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the bottom.`:p?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the top.`:`✅ Scrolled container (${i.tagName}) by ${c}px.`}}__name$1(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,n){if(n){const a=n;let l=a,u=!1,c=null,d=0,p=0;const g=e?t:-t;for(;l&&p<10;){const _=window.getComputedStyle(l),y=/(auto|scroll|overlay)/.test(_.overflowX),h=l.scrollWidth>l.clientWidth;if(y&&h){const f=l.scrollLeft,b=l.scrollWidth-l.clientWidth;let m=g/3;m>0?m=Math.min(m,b-f):m=Math.max(m,-f),l.scrollLeft=f+m;const S=l.scrollLeft-f;if(Math.abs(S)>.5){u=!0,c=l,d=S;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,p++}return u?`Scrolled container (${c==null?void 0:c.tagName}) horizontally by ${d}px`:`No horizontally scrollable container found for element (${a.tagName})`}const r=e?t:-t,o=__name$1(a=>a.clientWidth>=window.innerWidth*.5,"bigEnough"),s=__name$1(a=>a&&/(auto|scroll|overlay)/.test(getComputedStyle(a).overflowX)&&a.scrollWidth>a.clientWidth&&o(a),"canScroll");let i=document.activeElement;for(;i&&!s(i)&&i!==document.body;)i=i.parentElement;if(i=s(i)?i:Array.from(document.querySelectorAll("*")).find(s)||document.scrollingElement||document.documentElement,i===document.scrollingElement||i===document.documentElement||i===document.body){const a=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(r,0);const u=window.scrollX,c=u-a;if(Math.abs(c)<1)return r>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled page by ${c}px. Reached the right edge of the page.`:p?`✅ Scrolled page by ${c}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${c}px.`}else{const a=i.scrollLeft,l=i.scrollWidth-i.clientWidth;i.scrollBy({left:r,behavior:"smooth"}),await waitFor(.1);const u=i.scrollLeft,c=u-a;if(Math.abs(c)<1)return r>0?`⚠️ Already at the right edge of container (${i.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${i.tagName}), cannot scroll left further.`;const d=r>0&&u>=l-1,p=r<0&&u<=1;return d?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the right edge.`:p?`✅ Scrolled container (${i.tagName}) by ${c}px. Reached the left edge.`:`✅ Scrolled container (${i.tagName}) horizontally by ${c}px.`}}__name$1(scrollHorizontally,"scrollHorizontally");const domTree=__name$1((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:n,highlightOpacity:r,highlightLabelOpacity:o}=e,{doHighlightElements:s,focusHighlightIndex:i,viewportExpansion:a,debugMode:l}=e;let u=0;const c=new WeakMap;function d(v,w){!v||v.nodeType!==Node.ELEMENT_NODE||c.set(v,{...c.get(v),...w})}__name$1(d,"addExtraData");const p={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:__name$1(()=>{p.boundingRects=new WeakMap,p.clientRects=new WeakMap,p.computedStyles=new WeakMap},"clearCache")};function g(v){if(!v)return null;if(p.boundingRects.has(v))return p.boundingRects.get(v);const w=v.getBoundingClientRect();return w&&p.boundingRects.set(v,w),w}__name$1(g,"getCachedBoundingRect");function _(v){if(!v)return null;if(p.computedStyles.has(v))return p.computedStyles.get(v);const w=window.getComputedStyle(v);return w&&p.computedStyles.set(v,w),w}__name$1(_,"getCachedComputedStyle");function y(v){if(!v)return null;if(p.clientRects.has(v))return p.clientRects.get(v);const w=v.getClientRects();return w&&p.clientRects.set(v,w),w}__name$1(y,"getCachedClientRects");const h={},f={current:0},b="playwright-highlight-container";function m(v,w,z=null){if(!v)return w;const I=[];let k=null,U=20,D=16,K=null;try{let j=document.getElementById(b);j||(j=document.createElement("div"),j.id=b,j.style.position="fixed",j.style.pointerEvents="none",j.style.top="0",j.style.left="0",j.style.width="100%",j.style.height="100%",j.style.zIndex="2147483640",j.style.backgroundColor="transparent",document.body.appendChild(j));const J=v.getClientRects();if(!J||J.length===0)return w;const ee=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],ie=w%ee.length;let R=ee[ie];const Z=R+Math.floor(r*255).toString(16).padStart(2,"0");R=R+Math.floor(o*255).toString(16).padStart(2,"0");let W={x:0,y:0};if(z){const F=z.getBoundingClientRect();W.x=F.left,W.y=F.top}const T=document.createDocumentFragment();for(const F of J){if(F.width===0||F.height===0)continue;const q=document.createElement("div");q.style.position="fixed",q.style.border=`2px solid ${R}`,q.style.backgroundColor=Z,q.style.pointerEvents="none",q.style.boxSizing="border-box";const C=F.top+W.y,H=F.left+W.x;q.style.top=`${C}px`,q.style.left=`${H}px`,q.style.width=`${F.width}px`,q.style.height=`${F.height}px`,T.appendChild(q),I.push({element:q,initialRect:F})}const V=J[0];k=document.createElement("div"),k.className="playwright-highlight-label",k.style.position="fixed",k.style.background=R,k.style.color="white",k.style.padding="1px 4px",k.style.borderRadius="4px",k.style.fontSize=`${Math.min(12,Math.max(8,V.height/2))}px`,k.textContent=w.toString(),U=k.offsetWidth>0?k.offsetWidth:U,D=k.offsetHeight>0?k.offsetHeight:D;const Q=V.top+W.y,G=V.left+W.x;let we=Q+2,fe=G+V.width-U-2;(V.width<U+4||V.height<D+4)&&(we=Q-D-2,fe=G+V.width-U,fe<W.x&&(fe=G)),we=Math.max(0,Math.min(we,window.innerHeight-D)),fe=Math.max(0,Math.min(fe,window.innerWidth-U)),k.style.top=`${we}px`,k.style.left=`${fe}px`,T.appendChild(k);const L=__name$1((F,q)=>{let C=0;return(...H)=>{const se=performance.now();if(!(se-C<q))return C=se,F(...H)}},"throttleFunction")(__name$1(()=>{const F=v.getClientRects();let q={x:0,y:0};if(z){const C=z.getBoundingClientRect();q.x=C.left,q.y=C.top}if(I.forEach((C,H)=>{if(H<F.length){const se=F[H],ke=se.top+q.y,xe=se.left+q.x;C.element.style.top=`${ke}px`,C.element.style.left=`${xe}px`,C.element.style.width=`${se.width}px`,C.element.style.height=`${se.height}px`,C.element.style.display=se.width===0||se.height===0?"none":"block"}else C.element.style.display="none"}),F.length<I.length)for(let C=F.length;C<I.length;C++)I[C].element.style.display="none";if(k&&F.length>0){const C=F[0],H=C.top+q.y,se=C.left+q.x;let ke=H+2,xe=se+C.width-U-2;(C.width<U+4||C.height<D+4)&&(ke=H-D-2,xe=se+C.width-U,xe<q.x&&(xe=se)),ke=Math.max(0,Math.min(ke,window.innerHeight-D)),xe=Math.max(0,Math.min(xe,window.innerWidth-U)),k.style.top=`${ke}px`,k.style.left=`${xe}px`,k.style.display="block"}else k&&(k.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),K=__name$1(()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L),I.forEach(F=>F.element.remove()),k&&k.remove()},"cleanupFn"),j.appendChild(T),w+1}finally{K&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(K)}}__name$1(m,"highlightElement");function x(v){if(!v||v.nodeType!==Node.ELEMENT_NODE)return null;const w=_(v);if(!w)return null;const z=w.display;if(z==="inline"||z==="inline-block")return null;const I=w.overflowX,k=w.overflowY,U=I==="auto"||I==="scroll",D=k==="auto"||k==="scroll";if(!U&&!D)return null;const K=v.scrollWidth-v.clientWidth,j=v.scrollHeight-v.clientHeight,J=4;if(K<J&&j<J||!D&&K<J||!U&&j<J)return null;const ee=v.scrollTop,ie=v.scrollLeft,R=v.scrollWidth-v.clientWidth-v.scrollLeft,Z=v.scrollHeight-v.clientHeight-v.scrollTop,W={top:ee,right:R,bottom:Z,left:ie};return d(v,{scrollable:!0,scrollData:W}),W}__name$1(x,"isScrollableElement");function S(v){try{if(a===-1){const D=v.parentElement;if(!D)return!1;try{return D.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const j=window.getComputedStyle(D);return j.display!=="none"&&j.visibility!=="hidden"&&j.opacity!=="0"}}const w=document.createRange();w.selectNodeContents(v);const z=w.getClientRects();if(!z||z.length===0)return!1;let I=!1,k=!1;for(const D of z)if(D.width>0&&D.height>0&&(I=!0,!(D.bottom<-a||D.top>window.innerHeight+a||D.right<-a||D.left>window.innerWidth+a))){k=!0;break}if(!I||!k)return!1;const U=v.parentElement;if(!U)return!1;try{return U.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const K=window.getComputedStyle(U);return K.display!=="none"&&K.visibility!=="hidden"&&K.opacity!=="0"}}catch(w){return console.warn("Error checking text node visibility:",w),!1}}__name$1(S,"isTextNodeVisible");function N(v){if(!v||!v.tagName)return!1;const w=new Set(["body","div","main","article","section","nav","header","footer"]),z=v.tagName.toLowerCase();return w.has(z)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(z)}__name$1(N,"isElementAccepted");function M(v){const w=_(v);return v.offsetWidth>0&&v.offsetHeight>0&&(w==null?void 0:w.visibility)!=="hidden"&&(w==null?void 0:w.display)!=="none"}__name$1(M,"isElementVisible");function P(v){var Z,W;if(!v||v.nodeType!==Node.ELEMENT_NODE||t.includes(v))return!1;if(n.includes(v))return!0;const w=v.tagName.toLowerCase(),z=_(v),I=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),k=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function U(T){return T.tagName.toLowerCase()==="html"?!1:!!(z!=null&&z.cursor&&I.has(z.cursor))}if(__name$1(U,"doesElementHaveInteractivePointer"),U(v))return!0;const K=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),j=new Set(["disabled","readonly"]);if(K.has(w)){if(z!=null&&z.cursor&&k.has(z.cursor))return!1;for(const T of j)if(v.hasAttribute(T)||v.getAttribute(T)==="true"||v.getAttribute(T)==="")return!1;return!(v.disabled||v.readOnly||v.inert)}const J=v.getAttribute("role"),ee=v.getAttribute("aria-role");if(v.getAttribute("contenteditable")==="true"||v.isContentEditable||v.classList&&(v.classList.contains("button")||v.classList.contains("dropdown-toggle")||v.getAttribute("data-index")||v.getAttribute("data-toggle")==="dropdown"||v.getAttribute("aria-haspopup")==="true"))return!0;const ie=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(K.has(w)||J&&ie.has(J)||ee&&ie.has(ee))return!0;try{if(typeof getEventListeners=="function"){const Q=getEventListeners(v),G=["click","mousedown","mouseup","dblclick"];for(const we of G)if(Q[we]&&Q[we].length>0)return!0}const T=((W=(Z=v==null?void 0:v.ownerDocument)==null?void 0:Z.defaultView)==null?void 0:W.getEventListenersForNode)||window.getEventListenersForNode;if(typeof T=="function"){const Q=T(v),G=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const we of G)for(const fe of Q)if(fe.type===we)return!0}const V=["onclick","onmousedown","onmouseup","ondblclick"];for(const Q of V)if(v.hasAttribute(Q)||typeof v[Q]=="function")return!0}catch{}return!!x(v)}__name$1(P,"isInteractiveElement");function re(v){if(a===-1)return!0;const w=y(v);if(!w||w.length===0)return!1;let z=!1;for(const j of w)if(j.width>0&&j.height>0&&!(j.bottom<-a||j.top>window.innerHeight+a||j.right<-a||j.left>window.innerWidth+a)){z=!0;break}if(!z)return!1;if(v.ownerDocument!==window.document)return!0;let k=Array.from(w).find(j=>j.width>0&&j.height>0);if(!k)return!1;const U=v.getRootNode();if(U instanceof ShadowRoot){const j=k.left+k.width/2,J=k.top+k.height/2;try{const ee=U.elementFromPoint(j,J);if(!ee)return!1;let ie=ee;for(;ie&&ie!==U;){if(ie===v)return!0;ie=ie.parentElement}return!1}catch{return!0}}const D=5;return[{x:k.left+k.width/2,y:k.top+k.height/2},{x:k.left+D,y:k.top+D},{x:k.right-D,y:k.bottom-D}].some(({x:j,y:J})=>{try{const ee=document.elementFromPoint(j,J);if(!ee)return!1;let ie=ee;for(;ie&&ie!==document.documentElement;){if(ie===v)return!0;ie=ie.parentElement}return!1}catch{return!0}})}__name$1(re,"isTopElement");function oe(v,w){if(w===-1)return!0;const z=v.getClientRects();if(!z||z.length===0){const I=g(v);return!I||I.width===0||I.height===0?!1:!(I.bottom<-w||I.top>window.innerHeight+w||I.right<-w||I.left>window.innerWidth+w)}for(const I of z)if(!(I.width===0||I.height===0)&&!(I.bottom<-w||I.top>window.innerHeight+w||I.right<-w||I.left>window.innerWidth+w))return!0;return!1}__name$1(oe,"isInExpandedViewport");function ne(v){if(!v||v.nodeType!==Node.ELEMENT_NODE)return!1;const w=v.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(w)?!0:v.hasAttribute("onclick")||v.hasAttribute("role")||v.hasAttribute("tabindex")||v.hasAttribute("aria-")||v.hasAttribute("data-action")||v.getAttribute("contenteditable")==="true"}__name$1(ne,"isInteractiveCandidate");const ce=new Set(["a","button","input","select","textarea","summary","details","label","option"]),_e=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function ge(v){if(!v||v.nodeType!==Node.ELEMENT_NODE||!M(v))return!1;const w=v.hasAttribute("role")||v.hasAttribute("tabindex")||v.hasAttribute("onclick")||typeof v.onclick=="function",z=/\b(btn|clickable|menu|item|entry|link)\b/i.test(v.className||""),I=!!v.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),k=[...v.children].some(M),U=v.parentElement&&v.parentElement.isSameNode(document.body);return(P(v)||w||z)&&k&&I&&!U}__name$1(ge,"isHeuristicallyInteractive");function $e(v){var I,k;if(!v||v.nodeType!==Node.ELEMENT_NODE)return!1;const w=v.tagName.toLowerCase(),z=v.getAttribute("role");if(w==="iframe"||ce.has(w)||z&&_e.has(z)||v.isContentEditable||v.getAttribute("contenteditable")==="true"||v.hasAttribute("data-testid")||v.hasAttribute("data-cy")||v.hasAttribute("data-test")||v.hasAttribute("onclick")||typeof v.onclick=="function")return!0;try{const U=((k=(I=v==null?void 0:v.ownerDocument)==null?void 0:I.defaultView)==null?void 0:k.getEventListenersForNode)||window.getEventListenersForNode;if(typeof U=="function"){const K=U(v),j=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const J of j)for(const ee of K)if(ee.type===J)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(K=>v.hasAttribute(K)))return!0}catch{}return!!ge(v)}__name$1($e,"isElementDistinctInteraction");function be(v,w,z,I){if(!v.isInteractive)return!1;let k=!1;return I?$e(w)?k=!0:k=!1:k=!0,k&&(v.isInViewport=oe(w,a),(v.isInViewport||a===-1)&&(v.highlightIndex=u++,s))?(i>=0?i===v.highlightIndex&&m(w,v.highlightIndex,z):m(w,v.highlightIndex,z),!0):!1}__name$1(be,"handleHighlighting");function ye(v,w=null,z=!1){var D,K,j,J,ee,ie,R;if(!v||v.id===b||v.nodeType!==Node.ELEMENT_NODE&&v.nodeType!==Node.TEXT_NODE||!v||v.id===b||((D=v.dataset)==null?void 0:D.browserUseIgnore)==="true"||((K=v.dataset)==null?void 0:K.pageAgentIgnore)==="true"||v.getAttribute&&v.getAttribute("aria-hidden")==="true")return null;if(v===document.body){const Z={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const T of v.childNodes){const V=ye(T,w,!1);V&&Z.children.push(V)}const W=`${f.current++}`;return h[W]=Z,W}if(v.nodeType!==Node.ELEMENT_NODE&&v.nodeType!==Node.TEXT_NODE)return null;if(v.nodeType===Node.TEXT_NODE){const Z=(j=v.textContent)==null?void 0:j.trim();if(!Z)return null;const W=v.parentElement;if(!W||W.tagName.toLowerCase()==="script")return null;const T=`${f.current++}`;return h[T]={type:"TEXT_NODE",text:Z,isVisible:S(v)},T}if(v.nodeType===Node.ELEMENT_NODE&&!N(v))return null;if(a!==-1&&!v.shadowRoot){const Z=g(v),W=_(v),T=W&&(W.position==="fixed"||W.position==="sticky"),V=v.offsetWidth>0||v.offsetHeight>0;if(!Z||!T&&!V&&(Z.bottom<-a||Z.top>window.innerHeight+a||Z.right<-a||Z.left>window.innerWidth+a))return null}const I={tagName:v.tagName.toLowerCase(),attributes:{},children:[]};if(ne(v)||v.tagName.toLowerCase()==="iframe"||v.tagName.toLowerCase()==="body"){const Z=((J=v.getAttributeNames)==null?void 0:J.call(v))||[];for(const W of Z){const T=v.getAttribute(W);I.attributes[W]=T}v.tagName.toLowerCase()==="input"&&(v.type==="checkbox"||v.type==="radio")&&(I.attributes.checked=v.checked?"true":"false")}let k=!1;if(v.nodeType===Node.ELEMENT_NODE&&(I.isVisible=M(v),I.isVisible)){I.isTopElement=re(v);const Z=v.getAttribute("role"),W=Z==="menu"||Z==="menubar"||Z==="listbox";if((I.isTopElement||W)&&(I.isInteractive=P(v),k=be(I,v,w,z),I.ref=v,I.isInteractive&&Object.keys(I.attributes).length===0)){const T=((ee=v.getAttributeNames)==null?void 0:ee.call(v))||[];for(const V of T){const Q=v.getAttribute(V);I.attributes[V]=Q}}}if(v.tagName){const Z=v.tagName.toLowerCase();if(Z==="iframe")try{const W=v.contentDocument||((ie=v.contentWindow)==null?void 0:ie.document);if(W)for(const T of W.childNodes){const V=ye(T,v,!1);V&&I.children.push(V)}}catch(W){console.warn("Unable to access iframe:",W)}else if(v.isContentEditable||v.getAttribute("contenteditable")==="true"||v.id==="tinymce"||v.classList.contains("mce-content-body")||Z==="body"&&((R=v.getAttribute("data-id"))!=null&&R.startsWith("mce_")))for(const W of v.childNodes){const T=ye(W,w,k);T&&I.children.push(T)}else{if(v.shadowRoot){I.shadowRoot=!0;for(const W of v.shadowRoot.childNodes){const T=ye(W,w,k);T&&I.children.push(T)}}for(const W of v.childNodes){const V=ye(W,w,k||z);V&&I.children.push(V)}}}if(I.tagName==="a"&&I.children.length===0&&!I.attributes.href){const Z=g(v);if(!(Z&&Z.width>0&&Z.height>0||v.offsetWidth>0||v.offsetHeight>0))return null}I.extra=c.get(v)||null;const U=`${f.current++}`;return h[U]=I,U}__name$1(ye,"buildDomTree");const de=ye(document.body);return p.clearCache(),{rootId:de,map:h}},"domTree"),DEFAULT_VIEWPORT_EXPANSION=-1;function resolveViewportExpansion(e){return e??DEFAULT_VIEWPORT_EXPANSION}__name$1(resolveViewportExpansion,"resolveViewportExpansion");const newElementsCache=new WeakMap;function getFlatTree(e){const t=resolveViewportExpansion(e.viewportExpansion),n=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?n.push(i()):n.push(i);const r=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?r.push(i()):r.push(i);const o=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:t,interactiveBlacklist:n,interactiveWhitelist:r,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),s=window.location.href;for(const i in o.map){const a=o.map[i];if(a.isInteractive&&a.ref){const l=a.ref;newElementsCache.has(l)||(newElementsCache.set(l,s),a.isNew=!0)}}return o}__name$1(getFlatTree,"getFlatTree");const globRegexCache=new Map;function globToRegex(e){let t=globRegexCache.get(e);if(!t){const n=e.replace(/[.+^${}()|[\]\\]/g,"\\$&");t=new RegExp(`^${n.replace(/\*/g,".*")}$`),globRegexCache.set(e,t)}return t}__name$1(globToRegex,"globToRegex");function matchAttributes(e,t){const n={};for(const r of t)if(r.includes("*")){const o=globToRegex(r);for(const s of Object.keys(e))o.test(s)&&e[s].trim()&&(n[s]=e[s].trim())}else{const o=e[r];o&&o.trim()&&(n[r]=o.trim())}return n}__name$1(matchAttributes,"matchAttributes");function flatTreeToString(e,t){const n=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns","contenteditable"],r=[...t||[],...n],o=__name$1((d,p)=>d.length>p?d.substring(0,p)+"...":d,"capTextLength"),s=__name$1(d=>{const p=e.map[d];if(!p)return null;if(p.type==="TEXT_NODE"){const g=p;return{type:"text",text:g.text,isVisible:g.isVisible,parent:null,children:[]}}else{const g=p,_=[];if(g.children)for(const y of g.children){const h=s(y);h&&(h.parent=null,_.push(h))}return{type:"element",tagName:g.tagName,attributes:g.attributes??{},isVisible:g.isVisible??!1,isInteractive:g.isInteractive??!1,isTopElement:g.isTopElement??!1,isNew:g.isNew??!1,highlightIndex:g.highlightIndex,parent:null,children:_,extra:g.extra??{}}}},"buildTreeNode"),i=__name$1((d,p=null)=>{d.parent=p;for(const g of d.children)i(g,d)},"setParentReferences"),a=s(e.rootId);if(!a)return"";i(a);const l=__name$1(d=>{let p=d.parent;for(;p;){if(p.type==="element"&&p.highlightIndex!==void 0)return!0;p=p.parent}return!1},"hasParentWithHighlightIndex"),u=__name$1((d,p,g)=>{var h,f,b,m;let _=p;const y=" ".repeat(p);if(d.type==="element"){if(d.highlightIndex!==void 0){_+=1;const x=getAllTextTillNextClickableElement(d);let S="";if(r.length>0&&d.attributes){const P=matchAttributes(d.attributes,r),re=Object.keys(P);if(re.length>1){const ne=new Set,ce={};for(const _e of re){const ge=P[_e];ge.length>5&&(ge in ce?ne.add(_e):ce[ge]=_e)}for(const _e of ne)delete P[_e]}P.role===d.tagName&&delete P.role;const oe=["aria-label","placeholder","title"];for(const ne of oe)P[ne]&&P[ne].toLowerCase().trim()===x.toLowerCase().trim()&&delete P[ne];Object.keys(P).length>0&&(S=Object.entries(P).map(([ne,ce])=>`${ne}=${o(ce,20)}`).join(" "))}const N=d.isNew?`*[${d.highlightIndex}]`:`[${d.highlightIndex}]`;let M=`${y}${N}<${d.tagName??""}`;if(S&&(M+=` ${S}`),d.extra&&d.extra.scrollable){let P="";(h=d.extra.scrollData)!=null&&h.left&&(P+=`left=${d.extra.scrollData.left}, `),(f=d.extra.scrollData)!=null&&f.top&&(P+=`top=${d.extra.scrollData.top}, `),(b=d.extra.scrollData)!=null&&b.right&&(P+=`right=${d.extra.scrollData.right}, `),(m=d.extra.scrollData)!=null&&m.bottom&&(P+=`bottom=${d.extra.scrollData.bottom}`),M+=` data-scrollable="${P}"`}if(x){const P=x.trim();S||(M+=" "),M+=`>${P}`}else S||(M+=" ");M+=" />",g.push(M)}for(const x of d.children)u(x,_,g)}else if(d.type==="text"){if(l(d))return;d.parent&&d.parent.type==="element"&&d.parent.isVisible&&d.parent.isTopElement&&g.push(`${y}${d.text??""}`)}},"processNode"),c=[];return u(a,0,c),c.join(`
349
351
  `)}__name$1(flatTreeToString,"flatTreeToString");const getAllTextTillNextClickableElement=__name$1((e,t=-1)=>{const n=[],r=__name$1((o,s)=>{if(!(t!==-1&&s>t)&&!(o.type==="element"&&o!==e&&o.highlightIndex!==void 0)){if(o.type==="text"&&o.text)n.push(o.text);else if(o.type==="element")for(const i of o.children)r(i,s+1)}},"collectText");return r(e,0),n.join(`
350
352
  `).trim()},"getAllTextTillNextClickableElement");function getSelectorMap(e){const t=new Map,n=Object.keys(e.map);for(const r of n){const o=e.map[r];o.isInteractive&&typeof o.highlightIndex=="number"&&t.set(o.highlightIndex,o)}return t}__name$1(getSelectorMap,"getSelectorMap");function getElementTextMap(e){const t=e.split(`
351
353
  `).map(r=>r.trim()).filter(r=>r.length>0),n=new Map;for(const r of t){const s=/^\[(\d+)\]<[^>]+>([^<]*)/.exec(r);if(s){const i=parseInt(s[1],10);n.set(i,r)}}return n}__name$1(getElementTextMap,"getElementTextMap");function cleanUpHighlights(){const e=window._highlightCleanupFunctions||[];for(const t of e)typeof t=="function"&&t();window._highlightCleanupFunctions=[]}__name$1(cleanUpHighlights,"cleanUpHighlights"),window.addEventListener("popstate",()=>{cleanUpHighlights()}),window.addEventListener("hashchange",()=>{cleanUpHighlights()}),window.addEventListener("beforeunload",()=>{cleanUpHighlights()});const navigation=window.navigation;if(navigation&&typeof navigation.addEventListener=="function")navigation.addEventListener("navigate",()=>{cleanUpHighlights()});else{let e=window.location.href;setInterval(()=>{window.location.href!==e&&(e=window.location.href,cleanUpHighlights())},500)}function getPageInfo(){const e=window.innerWidth,t=window.innerHeight,n=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth||0),r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight||0),o=window.scrollX||window.pageXOffset||document.documentElement.scrollLeft||0,s=window.scrollY||window.pageYOffset||document.documentElement.scrollTop||0,i=Math.max(0,r-(window.innerHeight+s)),a=Math.max(0,n-(window.innerWidth+o));return{viewport_width:e,viewport_height:t,page_width:n,page_height:r,scroll_x:o,scroll_y:s,pixels_above:s,pixels_below:i,pages_above:t>0?s/t:0,pages_below:t>0?i/t:0,total_pages:t>0?r/t:0,current_page_position:s/Math.max(1,r-t),pixels_left:o,pixels_right:a}}__name$1(getPageInfo,"getPageInfo");function patchReact(e){const t=document.querySelectorAll('[data-reactroot], [data-reactid], [data-react-checksum], #root, #app, [id^="root-"], [id^="app-"], #adex-wrapper, #adex-root');for(const n of t)n.setAttribute("data-page-agent-not-interactive","true")}__name$1(patchReact,"patchReact");const _PageController=class extends EventTarget{constructor(t={}){super();te(this,"config");te(this,"flatTree",null);te(this,"selectorMap",new Map);te(this,"elementTextMap",new Map);te(this,"simplifiedHTML","<EMPTY>");te(this,"lastTimeUpdate",0);te(this,"isIndexed",!1);te(this,"mask",null);te(this,"maskReady",null);this.config=t,patchReact(),t.enableMask&&this.initMask()}initMask(){this.maskReady===null&&(this.maskReady=(async()=>{const{SimulatorMask:t}=await Promise.resolve().then(()=>SimulatorMaskBHnQ6LmL);this.mask=new t})())}async getCurrentUrl(){return window.location.href}async getLastUpdateTime(){return this.lastTimeUpdate}async getBrowserState(){const t=window.location.href,n=document.title,r=getPageInfo(),o=resolveViewportExpansion(this.config.viewportExpansion);await this.updateTree();const s=this.simplifiedHTML,i=`Current Page: [${n}](${t})`,a=`Page info: ${r.viewport_width}x${r.viewport_height}px viewport, ${r.page_width}x${r.page_height}px total page size, ${r.pages_above.toFixed(1)} pages above, ${r.pages_below.toFixed(1)} pages below, ${r.total_pages.toFixed(1)} total pages, at ${(r.current_page_position*100).toFixed(0)}% of page`,l=o===-1?"Interactive elements from top layer of the current page (full page):":"Interactive elements from top layer of the current page inside the viewport:",c=r.pixels_above>4&&o!==-1?`... ${r.pixels_above} pixels above (${r.pages_above.toFixed(1)} pages) - scroll to see more ...`:"[Start of page]",d=`${i}
@@ -353,7 +355,7 @@ ${a}
353
355
 
354
356
  ${l}
355
357
 
356
- ${c}`,g=r.pixels_below>4&&o!==-1?`... ${r.pixels_below} pixels below (${r.pages_below.toFixed(1)} pages) - scroll to see more ...`:"[End of page]";return{url:t,title:n,header:d,content:s,footer:g}}async updateTree(){this.dispatchEvent(new Event("beforeUpdate")),this.lastTimeUpdate=Date.now(),this.mask&&(this.mask.wrapper.style.pointerEvents="none"),cleanUpHighlights();const t=[...this.config.interactiveBlacklist||[],...document.querySelectorAll("[data-page-agent-not-interactive]").values()];return this.flatTree=getFlatTree({...this.config,interactiveBlacklist:t}),this.simplifiedHTML=flatTreeToString(this.flatTree,this.config.includeAttributes),this.selectorMap.clear(),this.selectorMap=getSelectorMap(this.flatTree),this.elementTextMap.clear(),this.elementTextMap=getElementTextMap(this.simplifiedHTML),this.isIndexed=!0,this.mask&&(this.mask.wrapper.style.pointerEvents="auto"),this.dispatchEvent(new Event("afterUpdate")),this.simplifiedHTML}async cleanUpHighlights(){cleanUpHighlights()}assertIndexed(){if(!this.isIndexed)throw new Error("DOM tree not indexed yet. Can not perform actions on elements.")}async clickElement(t){try{this.assertIndexed();const n=getElementByIndex(this.selectorMap,t),r=this.elementTextMap.get(t);return await clickElement(n),n instanceof HTMLAnchorElement&&n.target==="_blank"?{success:!0,message:`✅ Clicked element (${r??t}). ⚠️ Link opened in a new tab.`}:{success:!0,message:`✅ Clicked element (${r??t}).`}}catch(n){return{success:!1,message:`❌ Failed to click element: ${n}`}}}async inputText(t,n){try{this.assertIndexed();const r=getElementByIndex(this.selectorMap,t),o=this.elementTextMap.get(t);return await inputTextElement(r,n),{success:!0,message:`✅ Input text (${n}) into element (${o??t}).`}}catch(r){return{success:!1,message:`❌ Failed to input text: ${r}`}}}async selectOption(t,n){try{this.assertIndexed();const r=getElementByIndex(this.selectorMap,t),o=this.elementTextMap.get(t);return await selectOptionElement(r,n),{success:!0,message:`✅ Selected option (${n}) in element (${o??t}).`}}catch(r){return{success:!1,message:`❌ Failed to select option: ${r}`}}}async scroll(t){try{const{down:n,numPages:r,pixels:o,index:s}=t;this.assertIndexed();const i=o??r*(n?1:-1)*window.innerHeight,a=s!==void 0?getElementByIndex(this.selectorMap,s):null;return{success:!0,message:await scrollVertically(n,i,a)}}catch(n){return{success:!1,message:`❌ Failed to scroll: ${n}`}}}async scrollHorizontally(t){try{const{right:n,pixels:r,index:o}=t;this.assertIndexed();const s=r*(n?1:-1),i=o!==void 0?getElementByIndex(this.selectorMap,o):null;return{success:!0,message:await scrollHorizontally(n,s,i)}}catch(n){return{success:!1,message:`❌ Failed to scroll horizontally: ${n}`}}}async executeJavascript(script){try{const asyncFunction=eval(`(async () => { ${script} })`),result=await asyncFunction();return{success:!0,message:`✅ Executed JavaScript. Result: ${result}`}}catch(t){return{success:!1,message:`❌ Error executing JavaScript: ${t}`}}}async showMask(){var t;await this.maskReady,(t=this.mask)==null||t.show()}async hideMask(){var t;await this.maskReady,(t=this.mask)==null||t.hide()}dispose(){var t;cleanUpHighlights(),this.flatTree=null,this.selectorMap.clear(),this.elementTextMap.clear(),this.simplifiedHTML="<EMPTY>",this.isIndexed=!1,(t=this.mask)==null||t.dispose(),this.mask=null}};__name$1(_PageController,"PageController");let PageController=_PageController;const APPROVAL_REQUIRED_TOOLS=new Set(["click_element_by_index","input_text","select_dropdown_option","execute_javascript"]);let nextMsgId=0;function msgId(){return`msg-${++nextMsgId}`}function describeAction(e,t){const n=t;switch(e){case"click_element_by_index":return`Click element [${n.index}]`;case"input_text":return`Type "${truncate(String(n.text||""),40)}" into element [${n.index}]`;case"select_dropdown_option":return`Select "${truncate(String(n.text||""),40)}" in dropdown [${n.index}]`;case"execute_javascript":return`Run script: ${truncate(String(n.script||""),60)}`;default:return`${e}(${summarizeInput(t)})`}}class AgentBridge{constructor(t){this.agent=null,this.controller=null,this.messages=[],this.currentStep=0,this.disposed=!1,this.agentConfig=null,this.notesCache=null,this.autoApprove=!1,this.pendingApprovals=new Map,this.config=t}async loadNotes(){if(this.notesCache!==null)return this.notesCache;if(!this.config.endpoint||!this.config.project)return this.notesCache=[],this.notesCache;const t=await fetchNotes(this.config.endpoint,this.config.project);return this.notesCache=t.notes||[],this.notesCache}buildSystemPrompt(t){const n=[];this.config.appContext&&n.push(`[Developer context]
358
+ ${c}`,g=r.pixels_below>4&&o!==-1?`... ${r.pixels_below} pixels below (${r.pages_below.toFixed(1)} pages) - scroll to see more ...`:"[End of page]";return{url:t,title:n,header:d,content:s,footer:g}}async updateTree(){this.dispatchEvent(new Event("beforeUpdate")),this.lastTimeUpdate=Date.now(),this.mask&&(this.mask.wrapper.style.pointerEvents="none"),cleanUpHighlights();const t=[...this.config.interactiveBlacklist||[],...document.querySelectorAll("[data-page-agent-not-interactive]").values()];return this.flatTree=getFlatTree({...this.config,interactiveBlacklist:t}),this.simplifiedHTML=flatTreeToString(this.flatTree,this.config.includeAttributes),this.selectorMap.clear(),this.selectorMap=getSelectorMap(this.flatTree),this.elementTextMap.clear(),this.elementTextMap=getElementTextMap(this.simplifiedHTML),this.isIndexed=!0,this.mask&&(this.mask.wrapper.style.pointerEvents="auto"),this.dispatchEvent(new Event("afterUpdate")),this.simplifiedHTML}async cleanUpHighlights(){cleanUpHighlights()}assertIndexed(){if(!this.isIndexed)throw new Error("DOM tree not indexed yet. Can not perform actions on elements.")}async clickElement(t){try{this.assertIndexed();const n=getElementByIndex(this.selectorMap,t),r=this.elementTextMap.get(t);return await clickElement(n),n instanceof HTMLAnchorElement&&n.target==="_blank"?{success:!0,message:`✅ Clicked element (${r??t}). ⚠️ Link opened in a new tab.`}:{success:!0,message:`✅ Clicked element (${r??t}).`}}catch(n){return{success:!1,message:`❌ Failed to click element: ${n}`}}}async inputText(t,n){try{this.assertIndexed();const r=getElementByIndex(this.selectorMap,t),o=this.elementTextMap.get(t);return await inputTextElement(r,n),{success:!0,message:`✅ Input text (${n}) into element (${o??t}).`}}catch(r){return{success:!1,message:`❌ Failed to input text: ${r}`}}}async selectOption(t,n){try{this.assertIndexed();const r=getElementByIndex(this.selectorMap,t),o=this.elementTextMap.get(t);return await selectOptionElement(r,n),{success:!0,message:`✅ Selected option (${n}) in element (${o??t}).`}}catch(r){return{success:!1,message:`❌ Failed to select option: ${r}`}}}async scroll(t){try{const{down:n,numPages:r,pixels:o,index:s}=t;this.assertIndexed();const i=o??r*(n?1:-1)*window.innerHeight,a=s!==void 0?getElementByIndex(this.selectorMap,s):null;return{success:!0,message:await scrollVertically(n,i,a)}}catch(n){return{success:!1,message:`❌ Failed to scroll: ${n}`}}}async scrollHorizontally(t){try{const{right:n,pixels:r,index:o}=t;this.assertIndexed();const s=r*(n?1:-1),i=o!==void 0?getElementByIndex(this.selectorMap,o):null;return{success:!0,message:await scrollHorizontally(n,s,i)}}catch(n){return{success:!1,message:`❌ Failed to scroll horizontally: ${n}`}}}async executeJavascript(script){try{const asyncFunction=eval(`(async () => { ${script} })`),result=await asyncFunction();return{success:!0,message:`✅ Executed JavaScript. Result: ${result}`}}catch(t){return{success:!1,message:`❌ Error executing JavaScript: ${t}`}}}async showMask(){var t;await this.maskReady,(t=this.mask)==null||t.show()}async hideMask(){var t;await this.maskReady,(t=this.mask)==null||t.hide()}dispose(){var t;cleanUpHighlights(),this.flatTree=null,this.selectorMap.clear(),this.elementTextMap.clear(),this.simplifiedHTML="<EMPTY>",this.isIndexed=!1,(t=this.mask)==null||t.dispose(),this.mask=null}};__name$1(_PageController,"PageController");let PageController=_PageController;const APPROVAL_REQUIRED_TOOLS=new Set(["click_element_by_index","input_text","select_dropdown_option","execute_javascript"]);let nextMsgId=0;function msgId(){return`msg-${++nextMsgId}`}function describeAction(e,t){const n=t;switch(e){case"click_element_by_index":return`Click element [${n.index}]`;case"input_text":return`Type "${truncate(String(n.text||""),40)}" into element [${n.index}]`;case"select_dropdown_option":return`Select "${truncate(String(n.text||""),40)}" in dropdown [${n.index}]`;case"execute_javascript":return`Run script: ${truncate(String(n.script||""),60)}`;default:return`${e}(${summarizeInput(t)})`}}class AgentBridge{constructor(t){this.agent=null,this.controller=null,this.messages=[],this.currentStep=0,this.disposed=!1,this.stopped=!1,this.agentConfig=null,this.notesCache=null,this.autoApprove=!1,this.pendingApprovals=new Map,this.config=t}async loadNotes(){if(this.notesCache!==null)return this.notesCache;if(!this.config.endpoint||!this.config.project)return this.notesCache=[],this.notesCache;const t=await fetchNotes(this.config.endpoint,this.config.project);return this.notesCache=t.notes||[],this.notesCache}buildSystemPrompt(t){const n=[];this.config.appContext&&n.push(`[Developer context]
357
359
  ${this.config.appContext}`);const r=t.filter(o=>o.route===null);return r.length>0&&n.push(`[Site-wide notes]
358
360
  ${r.map(o=>o.content).join(`
359
361
 
@@ -362,7 +364,7 @@ ${r.map(o=>o.content).join(`
362
364
  `):void 0}getRouteNotes(t){if(!(!this.notesCache||this.notesCache.length===0))try{const n=new URL(t).pathname,r=this.notesCache.filter(o=>o.route!==null&&o.route===n);return r.length===0?void 0:`[Page notes: ${n}]
363
365
  ${r.map(o=>o.content).join(`
364
366
 
365
- `)}`}catch{return}}invalidateNotesCache(){this.notesCache=null}init(){if(this.agent)return;this.controller=new PageController({});const t=this;this.agentConfig={pageController:this.controller,baseURL:this.config.proxyUrl,apiKey:"proxy",model:this.config.model||"claude-sonnet-4-6",maxSteps:this.config.maxSteps||20,customFetch:this.createProxyFetch(),instructions:{getPageInstructions:n=>t.getRouteNotes(n)},customTools:{click_element_by_index:{description:"Click element by index",inputSchema:object({index:int().min(0)}),async execute(n){return await t.requestApproval("click_element_by_index",n)?(await this.pageController.clickElement(n.index)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},input_text:{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),async execute(n){return await t.requestApproval("input_text",n)?(await this.pageController.inputText(n.index,n.text)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},select_dropdown_option:{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),async execute(n){return await t.requestApproval("select_dropdown_option",n)?(await this.pageController.selectOption(n.index,n.text)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},execute_javascript:{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),async execute(n){return await t.requestApproval("execute_javascript",n)?(await this.pageController.executeJavascript(n.script)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}}}},this.agent=new PageAgentCore(this.agentConfig),this.agent.addEventListener("activity",(n=>{this.handleActivity(n.detail)})),this.agent.addEventListener("statuschange",(()=>{this.syncState()}))}async requestApproval(t,n){if(this.autoApprove)return!0;const r=msgId(),o=describeAction(t,n);return this.addMessage({id:r,role:"approval",text:o,tool:t,step:this.currentStep,timestamp:Date.now(),approvalStatus:"pending"}),this.config.onStateChange("awaiting_approval",this.currentStep),new Promise(s=>{this.pendingApprovals.set(r,s)})}approve(t){const n=this.pendingApprovals.get(t);n&&(this.pendingApprovals.delete(t),this.updateMessageApproval(t,"approved"),this.config.onStateChange("acting",this.currentStep),n(!0))}skip(t){const n=this.pendingApprovals.get(t);n&&(this.pendingApprovals.delete(t),this.updateMessageApproval(t,"skipped"),this.config.onStateChange("thinking",this.currentStep),n(!1))}updateMessageApproval(t,n){this.messages=this.messages.map(r=>r.id===t?{...r,approvalStatus:n}:r),this.config.onMessagesChange(this.messages)}createProxyFetch(){const t=this.config.proxyUrl;return async(n,r)=>{const s=(typeof n=="string"?n:n instanceof URL?n.toString():n.url).match(/\/v1\/(.*)/),i=s?s[1]:"chat/completions",a=t.endsWith("/")?t+i:t+"/"+i,l=new AbortController,u=setTimeout(()=>l.abort(),6e4);let c;try{c=await globalThis.fetch(a,{...r,signal:l.signal,headers:{...Object.fromEntries(new Headers(r==null?void 0:r.headers).entries()),"Content-Type":"application/json"}})}catch(d){throw clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?new Error("Agent proxy request timed out. The server may be overloaded — try again."):new Error(`Cannot reach agent proxy at ${t}. Check that your server is running.`)}if(clearTimeout(u),!c.ok){const d=c.status;let p="";try{p=await c.text()}catch{}throw d===401||d===403?new Error("Agent proxy returned 401 Unauthorized. Check that the server has a valid API key configured."):d===429?new Error("Agent proxy rate limited (429). Too many requests — wait a moment and try again."):d>=500?new Error(`Agent proxy server error (${d}). ${p?p.slice(0,200):"Check server logs for details."}`):new Error(`Agent proxy error (${d}): ${p?p.slice(0,200):"Unknown error"}`)}return c}}handleActivity(t){switch(t.type){case"thinking":this.config.onStateChange("thinking",this.currentStep);break;case"executing":this.currentStep++,APPROVAL_REQUIRED_TOOLS.has(t.tool)||(this.config.onStateChange("acting",this.currentStep),this.addMessage({id:msgId(),role:"action",text:`${t.tool}(${summarizeInput(t.input)})`,tool:t.tool,step:this.currentStep,timestamp:Date.now()}));break;case"executed":this.addMessage({id:msgId(),role:"result",text:truncate(t.output,200),tool:t.tool,duration:t.duration,step:this.currentStep,timestamp:Date.now()});break;case"retrying":this.addMessage({id:msgId(),role:"thinking",text:`Retrying (${t.attempt}/${t.maxAttempts})...`,timestamp:Date.now()});break;case"error":this.addMessage({id:msgId(),role:"error",text:t.message,timestamp:Date.now()}),this.config.onStateChange("error",this.currentStep);break}}syncState(){if(!this.agent)return;switch(this.agent.status){case"idle":case"completed":this.config.onStateChange("idle",this.currentStep);break;case"running":break;case"error":this.config.onStateChange("error",this.currentStep);break}}addMessage(t){this.messages=[...this.messages,t],this.config.onMessagesChange(this.messages)}async execute(t){if(this.disposed||(this.init(),!this.agent||!this.agentConfig))return;const n=await this.loadNotes();this.agentConfig.instructions.system=this.buildSystemPrompt(n),this.addMessage({id:msgId(),role:"user",text:t,timestamp:Date.now()}),this.currentStep=0,this.config.onStateChange("thinking",0);try{const r=await this.agent.execute(t);for(const o of r.history)o.type==="step"&&o.reflection.next_goal;r.success?this.addMessage({id:msgId(),role:"result",text:r.data||"Task completed successfully.",timestamp:Date.now()}):this.addMessage({id:msgId(),role:"error",text:r.data||"Task failed.",timestamp:Date.now()})}catch(r){this.addMessage({id:msgId(),role:"error",text:r instanceof Error?r.message:"Unknown error",timestamp:Date.now()}),this.config.onStateChange("error",this.currentStep)}this.config.onStateChange("idle",this.currentStep)}stop(){for(const[t,n]of this.pendingApprovals)this.updateMessageApproval(t,"skipped"),n(!1);this.pendingApprovals.clear(),this.agent&&this.agent.status==="running"&&(this.agent.stop(),this.addMessage({id:msgId(),role:"error",text:"Stopped by user.",timestamp:Date.now()}),this.config.onStateChange("idle",this.currentStep))}getMessages(){return this.messages}getMaxSteps(){return this.config.maxSteps||20}dispose(){this.disposed=!0;for(const[,t]of this.pendingApprovals)t(!1);this.pendingApprovals.clear(),this.agent&&(this.agent.dispose(),this.agent=null),this.controller&&(this.controller.dispose(),this.controller=null)}}function summarizeInput(e){if(e==null)return"";if(typeof e=="string")return truncate(e,60);if(typeof e=="number"||typeof e=="boolean")return String(e);try{const t=JSON.stringify(e);return truncate(t,80)}catch{return"..."}}function truncate(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}var root_1$1=from_html('<div class="drag-handle svelte-nv4d5v"><svg width="10" height="16" viewBox="0 0 10 16" fill="none"><circle cx="3" cy="3" r="1.5" fill="currentColor"></circle><circle cx="7" cy="3" r="1.5" fill="currentColor"></circle><circle cx="3" cy="8" r="1.5" fill="currentColor"></circle><circle cx="7" cy="8" r="1.5" fill="currentColor"></circle><circle cx="3" cy="13" r="1.5" fill="currentColor"></circle><circle cx="7" cy="13" r="1.5" fill="currentColor"></circle></svg></div>'),root_2$1=from_html('<span class="tab-badge svelte-nv4d5v"> </span>'),root_3=from_html('<button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.8"></rect><circle cx="9" cy="10" r="1.5" fill="currentColor"></circle><circle cx="15" cy="10" r="1.5" fill="currentColor"></circle><path d="M8 20h8M12 16v4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg> Agent</button>'),root_5=from_html("<option> </option>"),root_6=from_html("<option> </option>"),root_7=from_html('<span class="capture-spinner svelte-nv4d5v"></span> Capturing...',1),root_9=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_8=from_svg('<svg width="14" height="14" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="2" stroke="currentColor" stroke-width="2"></rect><circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"></circle></svg> Screenshot<!>',1),root_12=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_11=from_html("Pick<!>",1),root_13=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_16=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"></path><path d="M14 2v6h6" stroke="currentColor" stroke-width="2"></path></svg>'),root_17=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M4 4h16v16H4z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path><path d="M7 15V9l3 4 3-4v6M17 12h-3v3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),root_18=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"></path><path d="M14 2v6h6" stroke="currentColor" stroke-width="2"></path></svg>'),root_15=from_html('<div class="attachment-item svelte-nv4d5v"><span class="attachment-icon svelte-nv4d5v"><!></span> <span class="attachment-name svelte-nv4d5v"> </span> <span class="attachment-size svelte-nv4d5v"> </span> <button class="attachment-remove svelte-nv4d5v" aria-label="Remove">&times;</button></div>'),root_14=from_html('<div class="attachments-list svelte-nv4d5v"></div>'),root_20=from_html('<div class="element-item svelte-nv4d5v"><span class="element-tag svelte-nv4d5v"> </span> <span class="element-text svelte-nv4d5v"> </span> <button class="element-remove svelte-nv4d5v" aria-label="Remove">&times;</button></div>'),root_19=from_html('<div class="elements-list svelte-nv4d5v"></div>'),root_21=from_html('<div class="attach-summary svelte-nv4d5v"> </div>'),root_22=from_html('<span class="spinner svelte-nv4d5v"></span> Submitting...',1),root_4=from_html('<form class="panel-body svelte-nv4d5v"><div class="field svelte-nv4d5v"><label for="jat-fb-title" class="svelte-nv4d5v">Title <span class="req svelte-nv4d5v">*</span></label> <input id="jat-fb-title" type="text" placeholder="Brief description" required="" class="svelte-nv4d5v"/></div> <div class="field svelte-nv4d5v"><label for="jat-fb-desc" class="svelte-nv4d5v">Description</label> <textarea id="jat-fb-desc" placeholder="Steps to reproduce, expected vs actual..." rows="3" class="svelte-nv4d5v"></textarea></div> <div class="field-row svelte-nv4d5v"><div class="field half svelte-nv4d5v"><label for="jat-fb-type" class="svelte-nv4d5v">Type</label> <select id="jat-fb-type" class="svelte-nv4d5v"></select></div> <div class="field half svelte-nv4d5v"><label for="jat-fb-priority" class="svelte-nv4d5v">Priority</label> <select id="jat-fb-priority" class="svelte-nv4d5v"></select></div></div> <div class="tools svelte-nv4d5v"><div class="tool-buttons svelte-nv4d5v"><button type="button" class="tool-btn svelte-nv4d5v"><!></button> <button type="button" class="tool-btn svelte-nv4d5v"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M7 2L7 22M17 2V22M2 7H22M2 17H22" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> <!></button> <button type="button" class="tool-btn svelte-nv4d5v"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Upload<!></button> <input type="file" multiple="" accept="image/*,video/*,.md,.txt,.pdf,.doc,.docx,.csv,.json,.xml,.html,.log" style="display:none" class="svelte-nv4d5v"/></div> <!></div> <!> <!> <!> <!> <div class="actions svelte-nv4d5v"><span class="panel-version svelte-nv4d5v"> </span> <button type="button" class="cancel-btn svelte-nv4d5v">Cancel</button> <button type="submit" class="submit-btn svelte-nv4d5v"><!></button></div></form>'),root_24=from_html('<div class="requests-wrapper svelte-nv4d5v"><!></div>'),root_25=from_html('<div class="agent-wrapper svelte-nv4d5v"><!></div>'),root_26=from_html('<div class="notes-wrapper svelte-nv4d5v"><!></div>'),root$1=from_html('<div class="panel svelte-nv4d5v"><div class="panel-header svelte-nv4d5v"><!> <div class="tabs svelte-nv4d5v"><button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> New</button> <button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"></path></svg> History <!></button> <!> <button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="1.8"></path><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg> Notes</button></div> <button class="close-btn svelte-nv4d5v" aria-label="Close">&times;</button></div> <!> <!> <!> <!> <!></div> <!>',1);const $$css$1={hash:"svelte-nv4d5v",code:`.panel.svelte-nv4d5v {width:380px;max-height:702px;background:#111827;border:1px solid #374151;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,0.4);font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;color:#e5e7eb;display:flex;flex-direction:column;overflow:hidden;position:relative;}.panel-header.svelte-nv4d5v {display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 0;border-bottom:1px solid #1f2937;}.drag-handle.svelte-nv4d5v {display:flex;align-items:center;justify-content:center;width:24px;padding:0 2px 0 8px;color:#6b7280;cursor:grab;flex-shrink:0;user-select:none;transition:color 0.15s;}.drag-handle.svelte-nv4d5v:hover {color:#d1d5db;}.drag-handle.svelte-nv4d5v:active {cursor:grabbing;color:#e5e7eb;}.tabs.svelte-nv4d5v {display:flex;flex:1;}.tab.svelte-nv4d5v {display:flex;align-items:center;gap:5px;padding:11px 14px;background:none;border:none;border-bottom:2px solid transparent;color:#6b7280;font-size:13px;font-weight:500;cursor:pointer;font-family:inherit;transition:color 0.15s, border-color 0.15s;white-space:nowrap;}.tab.svelte-nv4d5v:hover {color:#d1d5db;}.tab.active.svelte-nv4d5v {color:#f9fafb;border-bottom-color:#3b82f6;}.tab-badge.svelte-nv4d5v {display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:#f59e0b;color:#111827;font-size:10px;font-weight:700;line-height:1;}.close-btn.svelte-nv4d5v {background:none;border:none;color:#9ca3af;font-size:20px;cursor:pointer;padding:0 4px;line-height:1;flex-shrink:0;}.close-btn.svelte-nv4d5v:hover {color:#e5e7eb;}.panel-body.svelte-nv4d5v {padding:14px 16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;}.field.svelte-nv4d5v {display:flex;flex-direction:column;gap:4px;}.field-row.svelte-nv4d5v {display:flex;gap:10px;}.half.svelte-nv4d5v {flex:1;}label.svelte-nv4d5v {font-weight:600;font-size:12px;color:#9ca3af;}.req.svelte-nv4d5v {color:#ef4444;}input.svelte-nv4d5v, textarea.svelte-nv4d5v, select.svelte-nv4d5v {padding:7px 10px;border:1px solid #374151;border-radius:5px;font-size:13px;font-family:inherit;color:#e5e7eb;background:#1f2937;transition:border-color 0.15s;}input.svelte-nv4d5v:focus, textarea.svelte-nv4d5v:focus, select.svelte-nv4d5v:focus {outline:none;border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59, 130, 246, 0.2);}input.svelte-nv4d5v:disabled, textarea.svelte-nv4d5v:disabled, select.svelte-nv4d5v:disabled {opacity:0.5;cursor:not-allowed;}textarea.svelte-nv4d5v {resize:vertical;min-height:48px;}select.svelte-nv4d5v {appearance:auto;}.tools.svelte-nv4d5v {display:flex;flex-direction:column;gap:6px;}.tool-buttons.svelte-nv4d5v {display:flex;gap:6px;}.tool-buttons.svelte-nv4d5v .tool-btn:where(.svelte-nv4d5v) {flex:1;}.tool-btn.svelte-nv4d5v {display:inline-flex;align-items:center;gap:6px;padding:6px 12px;background:#1f2937;border:1px solid #374151;border-radius:5px;color:#d1d5db;font-size:12px;cursor:pointer;font-family:inherit;transition:background 0.15s;}.tool-btn.svelte-nv4d5v:hover:not(:disabled) {background:#374151;}.tool-btn.svelte-nv4d5v:disabled {opacity:0.5;cursor:not-allowed;}.capture-spinner.svelte-nv4d5v {display:inline-block;width:12px;height:12px;border:2px solid rgba(255,255,255,0.2);border-top-color:white;border-radius:50%;
367
+ `)}`}catch{return}}invalidateNotesCache(){this.notesCache=null}init(){if(this.agent)return;this.controller=new PageController({});const t=this;this.agentConfig={pageController:this.controller,baseURL:this.config.proxyUrl,apiKey:"proxy",model:this.config.model||"claude-sonnet-4-6",maxSteps:this.config.maxSteps||20,customFetch:this.createProxyFetch(),instructions:{getPageInstructions:n=>t.getRouteNotes(n)},customTools:{click_element_by_index:{description:"Click element by index",inputSchema:object({index:int().min(0)}),async execute(n){return await t.requestApproval("click_element_by_index",n)?(await this.pageController.clickElement(n.index)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},input_text:{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),async execute(n){return await t.requestApproval("input_text",n)?(await this.pageController.inputText(n.index,n.text)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},select_dropdown_option:{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),async execute(n){return await t.requestApproval("select_dropdown_option",n)?(await this.pageController.selectOption(n.index,n.text)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}},execute_javascript:{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),async execute(n){return await t.requestApproval("execute_javascript",n)?(await this.pageController.executeJavascript(n.script)).message:"⏭️ Action skipped by user. Re-plan with a different approach."}}}},this.agent=new PageAgentCore(this.agentConfig),this.agent.addEventListener("activity",(n=>{this.handleActivity(n.detail)})),this.agent.addEventListener("statuschange",(()=>{this.syncState()}))}async requestApproval(t,n){if(this.autoApprove)return!0;const r=msgId(),o=describeAction(t,n);return this.addMessage({id:r,role:"approval",text:o,tool:t,step:this.currentStep,timestamp:Date.now(),approvalStatus:"pending"}),this.config.onStateChange("awaiting_approval",this.currentStep),new Promise(s=>{this.pendingApprovals.set(r,s)})}approve(t){const n=this.pendingApprovals.get(t);n&&(this.pendingApprovals.delete(t),this.updateMessageApproval(t,"approved"),this.config.onStateChange("acting",this.currentStep),n(!0))}skip(t){const n=this.pendingApprovals.get(t);n&&(this.pendingApprovals.delete(t),this.updateMessageApproval(t,"skipped"),this.config.onStateChange("thinking",this.currentStep),n(!1))}updateMessageApproval(t,n){this.messages=this.messages.map(r=>r.id===t?{...r,approvalStatus:n}:r),this.config.onMessagesChange(this.messages)}createProxyFetch(){const t=this.config.proxyUrl;return async(n,r)=>{const s=(typeof n=="string"?n:n instanceof URL?n.toString():n.url).match(/\/v1\/(.*)/),i=s?s[1]:"chat/completions",a=t.endsWith("/")?t+i:t+"/"+i,l=new AbortController,u=setTimeout(()=>l.abort(),6e4);let c;try{c=await globalThis.fetch(a,{...r,signal:l.signal,headers:{...Object.fromEntries(new Headers(r==null?void 0:r.headers).entries()),"Content-Type":"application/json"}})}catch(d){throw clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?new Error("Agent proxy request timed out. The server may be overloaded — try again."):new Error(`Cannot reach agent proxy at ${t}. Check that your server is running.`)}if(clearTimeout(u),!c.ok){const d=c.status;let p="";try{p=await c.text()}catch{}throw d===401||d===403?new Error("Agent proxy returned 401 Unauthorized. Check that the server has a valid API key configured."):d===429?new Error("Agent proxy rate limited (429). Too many requests — wait a moment and try again."):d>=500?new Error(`Agent proxy server error (${d}). ${p?p.slice(0,200):"Check server logs for details."}`):new Error(`Agent proxy error (${d}): ${p?p.slice(0,200):"Unknown error"}`)}return c}}handleActivity(t){if(!this.stopped)switch(t.type){case"thinking":this.config.onStateChange("thinking",this.currentStep);break;case"executing":this.currentStep++,APPROVAL_REQUIRED_TOOLS.has(t.tool)||(this.config.onStateChange("acting",this.currentStep),this.addMessage({id:msgId(),role:"action",text:`${t.tool}(${summarizeInput(t.input)})`,tool:t.tool,step:this.currentStep,timestamp:Date.now()}));break;case"executed":this.addMessage({id:msgId(),role:"result",text:truncate(t.output,200),tool:t.tool,duration:t.duration,step:this.currentStep,timestamp:Date.now()});break;case"retrying":this.addMessage({id:msgId(),role:"thinking",text:`Retrying (${t.attempt}/${t.maxAttempts})...`,timestamp:Date.now()});break;case"error":this.addMessage({id:msgId(),role:"error",text:t.message,timestamp:Date.now()}),this.config.onStateChange("error",this.currentStep);break}}syncState(){if(!this.agent)return;switch(this.agent.status){case"idle":case"completed":this.config.onStateChange("idle",this.currentStep);break;case"running":break;case"error":this.config.onStateChange("error",this.currentStep);break}}addMessage(t){this.messages=[...this.messages,t],this.config.onMessagesChange(this.messages)}async execute(t){if(this.disposed||(this.init(),!this.agent||!this.agentConfig))return;const n=await this.loadNotes();this.agentConfig.instructions.system=this.buildSystemPrompt(n),this.addMessage({id:msgId(),role:"user",text:t,timestamp:Date.now()}),this.currentStep=0,this.stopped=!1,this.config.onStateChange("thinking",0);try{const r=await this.agent.execute(t);if(this.stopped)return;r.success?this.addMessage({id:msgId(),role:"result",text:r.data||"Task completed successfully.",timestamp:Date.now()}):this.addMessage({id:msgId(),role:"error",text:r.data||"Task failed.",timestamp:Date.now()})}catch(r){if(this.stopped)return;if(r instanceof DOMException&&r.name==="AbortError"||r instanceof Error&&r.message==="AbortError"){this.addMessage({id:msgId(),role:"info",text:"Stopped by user.",timestamp:Date.now()}),this.config.onStateChange("idle",this.currentStep);return}this.addMessage({id:msgId(),role:"error",text:r instanceof Error?r.message:"Unknown error",timestamp:Date.now()}),this.config.onStateChange("error",this.currentStep);return}this.config.onStateChange("idle",this.currentStep)}stop(){this.stopped=!0;for(const[t,n]of this.pendingApprovals)this.updateMessageApproval(t,"skipped"),n(!1);this.pendingApprovals.clear(),this.agent&&this.agent.status==="running"&&this.agent.stop(),this.addMessage({id:msgId(),role:"info",text:"Stopped by user.",timestamp:Date.now()}),this.config.onStateChange("idle",this.currentStep)}getMessages(){return this.messages}getMaxSteps(){return this.config.maxSteps||20}dispose(){this.disposed=!0;for(const[,t]of this.pendingApprovals)t(!1);this.pendingApprovals.clear(),this.agent&&(this.agent.dispose(),this.agent=null),this.controller&&(this.controller.dispose(),this.controller=null)}}function summarizeInput(e){if(e==null)return"";if(typeof e=="string")return truncate(e,60);if(typeof e=="number"||typeof e=="boolean")return String(e);try{const t=JSON.stringify(e);return truncate(t,80)}catch{return"..."}}function truncate(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}var root_1$1=from_html('<div class="drag-handle svelte-nv4d5v"><svg width="10" height="16" viewBox="0 0 10 16" fill="none"><circle cx="3" cy="3" r="1.5" fill="currentColor"></circle><circle cx="7" cy="3" r="1.5" fill="currentColor"></circle><circle cx="3" cy="8" r="1.5" fill="currentColor"></circle><circle cx="7" cy="8" r="1.5" fill="currentColor"></circle><circle cx="3" cy="13" r="1.5" fill="currentColor"></circle><circle cx="7" cy="13" r="1.5" fill="currentColor"></circle></svg></div>'),root_2$1=from_html('<span class="tab-badge svelte-nv4d5v"> </span>'),root_3=from_html('<button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.8"></rect><circle cx="9" cy="10" r="1.5" fill="currentColor"></circle><circle cx="15" cy="10" r="1.5" fill="currentColor"></circle><path d="M8 20h8M12 16v4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg> Agent</button>'),root_5=from_html("<option> </option>"),root_6=from_html("<option> </option>"),root_7=from_html('<span class="capture-spinner svelte-nv4d5v"></span> Capturing...',1),root_9=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_8=from_svg('<svg width="14" height="14" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="2" stroke="currentColor" stroke-width="2"></rect><circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"></circle></svg> Screenshot<!>',1),root_12=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_11=from_html("Pick<!>",1),root_13=from_html('<span class="tool-count svelte-nv4d5v"> </span>'),root_16=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"></path><path d="M14 2v6h6" stroke="currentColor" stroke-width="2"></path></svg>'),root_17=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M4 4h16v16H4z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path><path d="M7 15V9l3 4 3-4v6M17 12h-3v3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),root_18=from_svg('<svg width="12" height="12" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="2"></path><path d="M14 2v6h6" stroke="currentColor" stroke-width="2"></path></svg>'),root_15=from_html('<div class="attachment-item svelte-nv4d5v"><span class="attachment-icon svelte-nv4d5v"><!></span> <span class="attachment-name svelte-nv4d5v"> </span> <span class="attachment-size svelte-nv4d5v"> </span> <button class="attachment-remove svelte-nv4d5v" aria-label="Remove">&times;</button></div>'),root_14=from_html('<div class="attachments-list svelte-nv4d5v"></div>'),root_20=from_html('<div class="element-item svelte-nv4d5v"><span class="element-tag svelte-nv4d5v"> </span> <span class="element-text svelte-nv4d5v"> </span> <button class="element-remove svelte-nv4d5v" aria-label="Remove">&times;</button></div>'),root_19=from_html('<div class="elements-list svelte-nv4d5v"></div>'),root_21=from_html('<div class="attach-summary svelte-nv4d5v"> </div>'),root_22=from_html('<span class="spinner svelte-nv4d5v"></span> Submitting...',1),root_4=from_html('<form class="panel-body svelte-nv4d5v"><div class="field svelte-nv4d5v"><label for="jat-fb-title" class="svelte-nv4d5v">Title <span class="req svelte-nv4d5v">*</span></label> <input id="jat-fb-title" type="text" placeholder="Brief description" required="" class="svelte-nv4d5v"/></div> <div class="field svelte-nv4d5v"><label for="jat-fb-desc" class="svelte-nv4d5v">Description</label> <textarea id="jat-fb-desc" placeholder="Steps to reproduce, expected vs actual..." rows="3" class="svelte-nv4d5v"></textarea></div> <div class="field-row svelte-nv4d5v"><div class="field half svelte-nv4d5v"><label for="jat-fb-type" class="svelte-nv4d5v">Type</label> <select id="jat-fb-type" class="svelte-nv4d5v"></select></div> <div class="field half svelte-nv4d5v"><label for="jat-fb-priority" class="svelte-nv4d5v">Priority</label> <select id="jat-fb-priority" class="svelte-nv4d5v"></select></div></div> <div class="tools svelte-nv4d5v"><div class="tool-buttons svelte-nv4d5v"><button type="button" class="tool-btn svelte-nv4d5v"><!></button> <button type="button" class="tool-btn svelte-nv4d5v"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M7 2L7 22M17 2V22M2 7H22M2 17H22" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> <!></button> <button type="button" class="tool-btn svelte-nv4d5v"><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> Upload<!></button> <input type="file" multiple="" accept="image/*,video/*,.md,.txt,.pdf,.doc,.docx,.csv,.json,.xml,.html,.log" style="display:none" class="svelte-nv4d5v"/></div> <!></div> <!> <!> <!> <!> <div class="actions svelte-nv4d5v"><span class="panel-version svelte-nv4d5v"> </span> <button type="button" class="cancel-btn svelte-nv4d5v">Cancel</button> <button type="submit" class="submit-btn svelte-nv4d5v"><!></button></div></form>'),root_24=from_html('<div class="requests-wrapper svelte-nv4d5v"><!></div>'),root_25=from_html('<div class="agent-wrapper svelte-nv4d5v"><!></div>'),root_26=from_html('<div class="notes-wrapper svelte-nv4d5v"><!></div>'),root$1=from_html('<div class="panel svelte-nv4d5v"><div class="panel-header svelte-nv4d5v"><!> <div class="tabs svelte-nv4d5v"><button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg> New</button> <button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"></path></svg> History <!></button> <!> <button><svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" stroke="currentColor" stroke-width="1.8"></path><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"></path></svg> Notes</button></div> <button class="close-btn svelte-nv4d5v" aria-label="Close">&times;</button></div> <!> <!> <!> <!> <!></div> <!>',1);const $$css$1={hash:"svelte-nv4d5v",code:`.panel.svelte-nv4d5v {width:380px;max-height:702px;background:#111827;border:1px solid #374151;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,0.4);font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;color:#e5e7eb;display:flex;flex-direction:column;overflow:hidden;position:relative;}.panel-header.svelte-nv4d5v {display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 0;border-bottom:1px solid #1f2937;}.drag-handle.svelte-nv4d5v {display:flex;align-items:center;justify-content:center;width:24px;padding:0 2px 0 8px;color:#6b7280;cursor:grab;flex-shrink:0;user-select:none;transition:color 0.15s;}.drag-handle.svelte-nv4d5v:hover {color:#d1d5db;}.drag-handle.svelte-nv4d5v:active {cursor:grabbing;color:#e5e7eb;}.tabs.svelte-nv4d5v {display:flex;flex:1;}.tab.svelte-nv4d5v {display:flex;align-items:center;gap:5px;padding:11px 14px;background:none;border:none;border-bottom:2px solid transparent;color:#6b7280;font-size:13px;font-weight:500;cursor:pointer;font-family:inherit;transition:color 0.15s, border-color 0.15s;white-space:nowrap;}.tab.svelte-nv4d5v:hover {color:#d1d5db;}.tab.active.svelte-nv4d5v {color:#f9fafb;border-bottom-color:#3b82f6;}.tab-badge.svelte-nv4d5v {display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:#f59e0b;color:#111827;font-size:10px;font-weight:700;line-height:1;}.close-btn.svelte-nv4d5v {background:none;border:none;color:#9ca3af;font-size:20px;cursor:pointer;padding:0 4px;line-height:1;flex-shrink:0;}.close-btn.svelte-nv4d5v:hover {color:#e5e7eb;}.panel-body.svelte-nv4d5v {padding:14px 16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;}.field.svelte-nv4d5v {display:flex;flex-direction:column;gap:4px;}.field-row.svelte-nv4d5v {display:flex;gap:10px;}.half.svelte-nv4d5v {flex:1;}label.svelte-nv4d5v {font-weight:600;font-size:12px;color:#9ca3af;}.req.svelte-nv4d5v {color:#ef4444;}input.svelte-nv4d5v, textarea.svelte-nv4d5v, select.svelte-nv4d5v {padding:7px 10px;border:1px solid #374151;border-radius:5px;font-size:13px;font-family:inherit;color:#e5e7eb;background:#1f2937;transition:border-color 0.15s;}input.svelte-nv4d5v:focus, textarea.svelte-nv4d5v:focus, select.svelte-nv4d5v:focus {outline:none;border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59, 130, 246, 0.2);}input.svelte-nv4d5v:disabled, textarea.svelte-nv4d5v:disabled, select.svelte-nv4d5v:disabled {opacity:0.5;cursor:not-allowed;}textarea.svelte-nv4d5v {resize:vertical;min-height:48px;}select.svelte-nv4d5v {appearance:auto;}.tools.svelte-nv4d5v {display:flex;flex-direction:column;gap:6px;}.tool-buttons.svelte-nv4d5v {display:flex;gap:6px;}.tool-buttons.svelte-nv4d5v .tool-btn:where(.svelte-nv4d5v) {flex:1;}.tool-btn.svelte-nv4d5v {display:inline-flex;align-items:center;gap:6px;padding:6px 12px;background:#1f2937;border:1px solid #374151;border-radius:5px;color:#d1d5db;font-size:12px;cursor:pointer;font-family:inherit;transition:background 0.15s;}.tool-btn.svelte-nv4d5v:hover:not(:disabled) {background:#374151;}.tool-btn.svelte-nv4d5v:disabled {opacity:0.5;cursor:not-allowed;}.capture-spinner.svelte-nv4d5v {display:inline-block;width:12px;height:12px;border:2px solid rgba(255,255,255,0.2);border-top-color:white;border-radius:50%;
366
368
  animation: svelte-nv4d5v-capture-spin 0.6s linear infinite;}
367
369
  @keyframes svelte-nv4d5v-capture-spin {
368
370
  to { transform: rotate(360deg); }
@@ -370,18 +372,18 @@ ${r.map(o=>o.content).join(`
370
372
  animation: svelte-nv4d5v-spin 0.6s linear infinite;}
371
373
  @keyframes svelte-nv4d5v-spin {
372
374
  to { transform: rotate(360deg); }
373
- }.requests-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.agent-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.notes-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.panel-version.svelte-nv4d5v {font-size:10px;color:#4b5563;margin-right:auto;align-self:flex-end;padding-bottom:6px;}`};function FeedbackPanel(e,t){push(t,!0),append_styles(e,$$css$1);const n="2.0.0";let r=prop(t,"endpoint",7),o=prop(t,"project",7),s=prop(t,"isOpen",7,!1),i=prop(t,"userId",7,""),a=prop(t,"userEmail",7,""),l=prop(t,"userName",7,""),u=prop(t,"userRole",7,""),c=prop(t,"orgId",7,""),d=prop(t,"orgName",7,""),p=prop(t,"onclose",7),g=prop(t,"ongrip",7),_=prop(t,"agentProxy",7,""),y=prop(t,"agentModel",7,""),h=prop(t,"agentContext",7,""),f=state("new"),b=state(!1),m=state(!1),x=state(proxy([])),S=state("idle"),N=state(0),P=state(!1),M=state(null);function re(){return get(M)||set(M,new AgentBridge({proxyUrl:_(),model:y()||void 0,maxSteps:20,appContext:h()||void 0,endpoint:r(),project:o(),onMessagesChange:$=>{set(x,$,!0)},onStateChange:($,B)=>{set(S,$,!0),set(N,B,!0)}}),!0),get(M)}function oe(){var $;($=get(M))==null||$.invalidateNotesCache()}user_effect(()=>{get(f)==="agent"&&!get(b)&&set(b,!0)}),user_effect(()=>{get(f)==="notes"&&!get(m)&&set(m,!0)});function ne($){re().execute($)}function ce(){var $;($=get(M))==null||$.stop()}function _e($){var B;(B=get(M))==null||B.approve($)}function ge($){var B;(B=get(M))==null||B.skip($)}function $e($){set(P,$,!0),get(M)&&(get(M).autoApprove=$)}onDestroy(()=>{var $;($=get(M))==null||$.dispose()});let be=state(proxy([])),ye=state(!1),de=state(""),v=user_derived(()=>get(be).filter($=>$.status==="completed").length);async function w(){set(ye,!0),set(de,"");const $=await fetchReports(r());set(be,$.reports,!0),$.error&&set(de,$.error,!0),set(ye,!1)}user_effect(()=>{r()&&w()});let z=state(""),R=state(""),k=state("bug"),U=state("medium"),D=state(proxy([])),K=state(proxy([])),j=state(proxy([])),J=state(proxy([])),ee=state(void 0);const ie=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml"];function I(){var $;($=get(ee))==null||$.click()}async function Z($){const B=$.target,Y=B.files;if(!(!Y||Y.length===0)){for(const he of Y)try{const He=await W(he);ie.includes(he.type)?(set(D,[...get(D),He],!0),H(`Image added: ${he.name}`,"success")):(set(K,[...get(K),{name:he.name,type:he.type||"application/octet-stream",data:He,size:he.size}],!0),H(`File attached: ${he.name}`,"success"))}catch{H(`Failed to read: ${he.name}`,"error")}B.value=""}}function W($){return new Promise((B,Y)=>{const he=new FileReader;he.onload=()=>B(he.result),he.onerror=()=>Y(he.error),he.readAsDataURL($)})}function T($){set(K,get(K).filter((B,Y)=>Y!==$),!0)}function V($){return $<1024?`${$}B`:$<1024*1024?`${($/1024).toFixed(1)}KB`:`${($/(1024*1024)).toFixed(1)}MB`}let Q=state(!1),G=state(!1),we=state(!1),fe=state(null),A=state(""),O=state(void 0),L=!1;user_effect(()=>{s()&&!L&&(requestAnimationFrame(()=>{requestAnimationFrame(()=>{var $;($=get(O))==null||$.focus()})}),get(f)==="new"&&get(D).length===0&&setTimeout(()=>{captureViewportQuick().then($=>{set(D,[...get(D),$],!0)}).catch(()=>{})},300)),L=s()});let F=state(""),q=state("success"),C=state(!1);function H($,B){set(F,$,!0),set(q,B,!0),set(C,!0),setTimeout(()=>{set(C,!1)},3e3)}async function se(){set(G,!0);try{const $=await captureViewport();set(A,$,!0),set(fe,get(D).length,!0)}catch($){console.error("[jat-feedback] Screenshot failed:",$),H("Screenshot failed: "+($ instanceof Error?$.message:"unknown error"),"error")}finally{set(G,!1)}}function ke($){set(D,get(D).filter((B,Y)=>Y!==$),!0)}function xe($){set(A,get(D)[$],!0),set(fe,$,!0)}function Ue($){get(fe)!==null&&(get(fe)>=get(D).length?(set(D,[...get(D),$],!0),H(`Screenshot captured (${get(D).length})`,"success")):(set(D,get(D).map((B,Y)=>Y===get(fe)?$:B),!0),H("Screenshot updated","success"))),set(fe,null),set(A,"")}function Ke(){get(fe)!==null&&get(fe)>=get(D).length&&(set(D,[...get(D),get(A)],!0),H(`Screenshot captured (${get(D).length})`,"success")),set(fe,null),set(A,"")}function rt(){set(we,!0),startElementPicker($=>{set(j,[...get(j),$],!0),set(we,!1),H(`Element captured: <${$.tagName.toLowerCase()}>`,"success")})}function Be(){set(J,getCapturedLogs(),!0)}async function Kt($){if($.preventDefault(),!get(z).trim())return;set(Q,!0),Be();const B={};(i()||a()||l()||u())&&(B.reporter={},i()&&(B.reporter.userId=i()),a()&&(B.reporter.email=a()),l()&&(B.reporter.name=l()),u()&&(B.reporter.role=u())),(c()||d())&&(B.organization={},c()&&(B.organization.id=c()),d()&&(B.organization.name=d()));const Y={title:get(z).trim(),description:get(R).trim(),type:get(k),priority:get(U),project:o()||"",page_url:window.location.href,user_agent:navigator.userAgent,console_logs:get(J).length>0?get(J):null,selected_elements:get(j).length>0?get(j):null,screenshots:get(D).length>0?get(D):null,attachments:get(K).length>0?get(K):null,metadata:Object.keys(B).length>0?B:null};try{const he=await submitReport(r(),Y);he.ok?(H(`Report submitted (${he.id})`,"success"),Fe(),setTimeout(()=>{w(),set(f,"requests")},1200)):(enqueue(r(),Y),H("Queued for retry (endpoint unreachable)","error"))}catch{enqueue(r(),Y),H("Queued for retry (endpoint unreachable)","error")}finally{set(Q,!1)}}function Fe(){set(z,""),set(R,""),set(k,"bug"),set(U,"medium"),set(D,[],!0),set(K,[],!0),set(j,[],!0),set(J,[],!0)}user_effect(()=>{Be()});function Pe($){$.stopPropagation()}const ft=[{value:"bug",label:"Bug"},{value:"enhancement",label:"Enhancement"},{value:"other",label:"Other"}],Jt=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"critical",label:"Critical"}];function pt(){return get(D).length+get(K).length+get(j).length}var me={get endpoint(){return r()},set endpoint($){r($),flushSync()},get project(){return o()},set project($){o($),flushSync()},get isOpen(){return s()},set isOpen($=!1){s($),flushSync()},get userId(){return i()},set userId($=""){i($),flushSync()},get userEmail(){return a()},set userEmail($=""){a($),flushSync()},get userName(){return l()},set userName($=""){l($),flushSync()},get userRole(){return u()},set userRole($=""){u($),flushSync()},get orgId(){return c()},set orgId($=""){c($),flushSync()},get orgName(){return d()},set orgName($=""){d($),flushSync()},get onclose(){return p()},set onclose($){p($),flushSync()},get ongrip(){return g()},set ongrip($){g($),flushSync()},get agentProxy(){return _()},set agentProxy($=""){_($),flushSync()},get agentModel(){return y()},set agentModel($=""){y($),flushSync()},get agentContext(){return h()},set agentContext($=""){h($),flushSync()}},Ee=root$1(),Me=first_child(Ee),lt=child(Me),Et=child(lt);{var zn=$=>{var B=root_1$1();delegated("mousedown",B,function(...Y){var he;(he=g())==null||he.apply(this,Y)}),append($,B)};if_block(Et,$=>{g()&&$(zn)})}var yn=sibling(Et,2),wn=child(yn);let xn;var Qt=sibling(wn,2);let kn;var Mn=sibling(child(Qt),2);{var An=$=>{var B=root_2$1(),Y=child(B,!0);reset(B),template_effect(()=>set_text(Y,get(v))),append($,B)};if_block(Mn,$=>{get(v)>0&&$(An)})}reset(Qt);var fn=sibling(Qt,2);{var Fn=$=>{var B=root_3();let Y;template_effect(()=>Y=set_class(B,1,"tab svelte-nv4d5v",null,Y,{active:get(f)==="agent"})),delegated("click",B,()=>{set(f,"agent"),set(b,!0)}),append($,B)};if_block(fn,$=>{_()&&$(Fn)})}var Rn=sibling(fn,2);let In;reset(yn);var Dn=sibling(yn,2);reset(lt);var Nn=sibling(lt,2);{var pe=$=>{var B=root_4(),Y=child(B),he=sibling(child(Y),2);remove_input_defaults(he),bind_this(he,X=>set(O,X),()=>get(O)),reset(Y);var He=sibling(Y,2),Ft=sibling(child(He),2);remove_textarea_child(Ft),reset(He);var ht=sibling(He,2),jt=child(ht),Qe=sibling(child(jt),2);each(Qe,21,()=>ft,index,(X,le)=>{var Ae=root_5(),De=child(Ae,!0);reset(Ae);var Ze={};template_effect(()=>{set_text(De,get(le).label),Ze!==(Ze=get(le).value)&&(Ae.value=(Ae.__value=get(le).value)??"")}),append(X,Ae)}),reset(Qe),reset(jt);var en=sibling(jt,2),Bt=sibling(child(en),2);each(Bt,21,()=>Jt,index,(X,le)=>{var Ae=root_6(),De=child(Ae,!0);reset(Ae);var Ze={};template_effect(()=>{set_text(De,get(le).label),Ze!==(Ze=get(le).value)&&(Ae.value=(Ae.__value=get(le).value)??"")}),append(X,Ae)}),reset(Bt),reset(en),reset(ht);var Vt=sibling(ht,2),tn=child(Vt),ze=child(tn),Ge=child(ze);{var St=X=>{var le=root_7();next(),append(X,le)},gt=X=>{var le=root_8(),Ae=sibling(first_child(le),2);{var De=Ze=>{var Ye=root_9(),_t=child(Ye,!0);reset(Ye),template_effect(()=>set_text(_t,get(D).length)),append(Ze,Ye)};if_block(Ae,Ze=>{get(D).length>0&&Ze(De)})}append(X,le)};if_block(Ge,X=>{get(G)?X(St):X(gt,!1)})}reset(ze);var ot=sibling(ze,2),vt=sibling(child(ot),2);{var Tt=X=>{var le=text("Click an element...");append(X,le)},nn=X=>{var le=root_11(),Ae=sibling(first_child(le));{var De=Ze=>{var Ye=root_12(),_t=child(Ye,!0);reset(Ye),template_effect(()=>set_text(_t,get(j).length)),append(Ze,Ye)};if_block(Ae,Ze=>{get(j).length>0&&Ze(De)})}append(X,le)};if_block(vt,X=>{get(we)?X(Tt):X(nn,!1)})}reset(ot);var Ne=sibling(ot,2),et=sibling(child(Ne),2);{var Dt=X=>{var le=root_13(),Ae=child(le,!0);reset(le),template_effect(()=>set_text(Ae,get(K).length)),append(X,le)};if_block(et,X=>{get(K).length>0&&X(Dt)})}reset(Ne);var st=sibling(Ne,2);bind_this(st,X=>set(ee,X),()=>get(ee)),reset(tn);var ct=sibling(tn,2);ScreenshotPreview(ct,{get screenshots(){return get(D)},get capturing(){return get(G)},oncapture:se,onremove:ke,onedit:xe}),reset(Vt);var ut=sibling(Vt,2);{var Ct=X=>{var le=root_14();each(le,21,()=>get(K),index,(Ae,De,Ze)=>{var Ye=root_15(),_t=child(Ye),Bn=child(_t);{var En=mt=>{var Sn=root_16();append(mt,Sn)},Vn=user_derived(()=>get(De).type.includes("pdf")),Hn=mt=>{var Sn=root_17();append(mt,Sn)},on=user_derived(()=>get(De).type.includes("markdown")||get(De).name.endsWith(".md")),$n=mt=>{var Sn=root_18();append(mt,Sn)};if_block(Bn,mt=>{get(Vn)?mt(En):get(on)?mt(Hn,1):mt($n,!1)})}reset(_t);var qn=sibling(_t,2),ur=child(qn,!0);reset(qn);var Wn=sibling(qn,2),dr=child(Wn,!0);reset(Wn);var fr=sibling(Wn,2);reset(Ye),template_effect(mt=>{set_text(ur,get(De).name),set_text(dr,mt)},[()=>V(get(De).size)]),delegated("click",fr,()=>T(Ze)),append(Ae,Ye)}),reset(le),append(X,le)};if_block(ut,X=>{get(K).length>0&&X(Ct)})}var zt=sibling(ut,2);{var pn=X=>{var le=root_19();each(le,21,()=>get(j),index,(Ae,De,Ze)=>{var Ye=root_20(),_t=child(Ye),Bn=child(_t);reset(_t);var En=sibling(_t,2),Vn=child(En,!0);reset(En);var Hn=sibling(En,2);reset(Ye),template_effect((on,$n)=>{set_text(Bn,`<${on??""}>`),set_text(Vn,$n)},[()=>get(De).tagName.toLowerCase(),()=>{var on;return((on=get(De).textContent)==null?void 0:on.substring(0,40))||get(De).selector}]),delegated("click",Hn,()=>{set(j,get(j).filter((on,$n)=>$n!==Ze),!0)}),append(Ae,Ye)}),reset(le),append(X,le)};if_block(zt,X=>{get(j).length>0&&X(pn)})}var hn=sibling(zt,2);ConsoleLogList(hn,{get logs(){return get(J)}});var At=sibling(hn,2);{var Zt=X=>{var le=root_21(),Ae=child(le);reset(le),template_effect((De,Ze)=>set_text(Ae,`${De??""} attachment${Ze??""} will be included`),[pt,()=>pt()>1?"s":""]),append(X,le)},Rt=user_derived(()=>pt()>0);if_block(At,X=>{get(Rt)&&X(Zt)})}var rn=sibling(At,2),Zn=child(rn),ir=child(Zn);reset(Zn);var Un=sibling(Zn,2),jn=sibling(Un,2),ar=child(jn);{var lr=X=>{var le=root_22();next(),append(X,le)},cr=X=>{var le=text("Submit");append(X,le)};if_block(ar,X=>{get(Q)?X(lr):X(cr,!1)})}reset(jn),reset(rn),reset(B),template_effect(X=>{he.disabled=get(Q),Ft.disabled=get(Q),Qe.disabled=get(Q),Bt.disabled=get(Q),ze.disabled=get(G),ot.disabled=get(we),Ne.disabled=get(Q),set_text(ir,`v${n}`),Un.disabled=get(Q),jn.disabled=X},[()=>get(Q)||!get(z).trim()]),event("submit",B,Kt),bind_value(he,()=>get(z),X=>set(z,X)),bind_value(Ft,()=>get(R),X=>set(R,X)),bind_select_value(Qe,()=>get(k),X=>set(k,X)),bind_select_value(Bt,()=>get(U),X=>set(U,X)),delegated("click",ze,se),delegated("click",ot,rt),delegated("click",Ne,I),delegated("change",st,Z),delegated("click",Un,function(...X){var le;(le=p())==null||le.apply(this,X)}),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(Nn,$=>{get(f)==="new"&&$(pe)})}var ve=sibling(Nn,2);{var Re=$=>{var B=root_24(),Y=child(B);RequestList(Y,{get endpoint(){return r()},get loading(){return get(ye)},get error(){return get(de)},onreload:w,get reports(){return get(be)},set reports(he){set(be,he,!0)}}),reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(ve,$=>{get(f)==="requests"&&$(Re)})}var qe=sibling(ve,2);{var $t=$=>{var B=root_25(),Y=child(B);{let he=user_derived(()=>{var He;return((He=get(M))==null?void 0:He.getMaxSteps())??20});AgentPanel(Y,{get messages(){return get(x)},get agentState(){return get(S)},get currentStep(){return get(N)},get maxSteps(){return get(he)},get autoApprove(){return get(P)},onsend:ne,onstop:ce,onapprove:_e,onskip:ge,onautoapprovechange:$e})}reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(qe,$=>{get(f)==="agent"&&get(b)&&$($t)})}var Je=sibling(qe,2);{var Ve=$=>{var B=root_26(),Y=child(B);NotesPanel(Y,{get endpoint(){return r()},get project(){return o()},onnoteschanged:oe}),reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(Je,$=>{get(f)==="notes"&&get(m)&&$(Ve)})}var Ie=sibling(Je,2);StatusToast(Ie,{get message(){return get(F)},get type(){return get(q)},get visible(){return get(C)}}),reset(Me);var We=sibling(Me,2);{var Ce=$=>{AnnotationEditor($,{get imageDataUrl(){return get(A)},onsave:Ue,oncancel:Ke})};if_block(We,$=>{get(fe)!==null&&$(Ce)})}return template_effect(()=>{xn=set_class(wn,1,"tab svelte-nv4d5v",null,xn,{active:get(f)==="new"}),kn=set_class(Qt,1,"tab svelte-nv4d5v",null,kn,{active:get(f)==="requests"}),In=set_class(Rn,1,"tab svelte-nv4d5v",null,In,{active:get(f)==="notes"})}),delegated("keydown",Me,Pe),delegated("keyup",Me,Pe),event("keypress",Me,Pe),delegated("click",wn,()=>set(f,"new")),delegated("click",Qt,()=>set(f,"requests")),delegated("click",Rn,()=>{set(f,"notes"),set(m,!0)}),delegated("click",Dn,function(...$){var B;(B=p())==null||B.apply(this,$)}),append(e,Ee),pop(me)}delegate(["keydown","keyup","mousedown","click","change"]),create_custom_element(FeedbackPanel,{endpoint:{},project:{},isOpen:{},userId:{},userEmail:{},userName:{},userRole:{},orgId:{},orgName:{},onclose:{},ongrip:{},agentProxy:{},agentModel:{},agentContext:{}},[],[],{mode:"open"});var root_1=from_html("<div><!></div>"),root_2=from_html('<div class="jat-feedback-panel svelte-qpyrvv"><div class="no-endpoint svelte-qpyrvv"><p class="svelte-qpyrvv">No endpoint configured.</p> <p class="svelte-qpyrvv">Add the <code class="svelte-qpyrvv">endpoint</code> attribute:</p> <code class="example svelte-qpyrvv">&lt;jat-feedback endpoint="http://localhost:3333"&gt;</code></div></div>'),root=from_html('<div class="jat-feedback-root svelte-qpyrvv" data-page-agent-not-interactive=""><!> <!></div>');const $$css={hash:"svelte-qpyrvv",code:`.jat-feedback-root.svelte-qpyrvv {position:fixed;z-index:2147483647;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;}.jat-feedback-panel.svelte-qpyrvv {position:absolute;
375
+ }.requests-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.agent-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.notes-wrapper.svelte-nv4d5v {flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.panel-version.svelte-nv4d5v {font-size:10px;color:#4b5563;margin-right:auto;align-self:flex-end;padding-bottom:6px;}`};function FeedbackPanel(e,t){push(t,!0),append_styles(e,$$css$1);const n="2.0.1";let r=prop(t,"endpoint",7),o=prop(t,"project",7),s=prop(t,"isOpen",7,!1),i=prop(t,"userId",7,""),a=prop(t,"userEmail",7,""),l=prop(t,"userName",7,""),u=prop(t,"userRole",7,""),c=prop(t,"orgId",7,""),d=prop(t,"orgName",7,""),p=prop(t,"onclose",7),g=prop(t,"ongrip",7),_=prop(t,"agentProxy",7,""),y=prop(t,"agentModel",7,""),h=prop(t,"agentContext",7,""),f=state("new"),b=state(!1),m=state(!1),x=state(proxy([])),S=state("idle"),N=state(0),M=state(!1),P=state(null);function re(){return get(P)||set(P,new AgentBridge({proxyUrl:_(),model:y()||void 0,maxSteps:20,appContext:h()||void 0,endpoint:r(),project:o(),onMessagesChange:$=>{set(x,$,!0)},onStateChange:($,B)=>{set(S,$,!0),set(N,B,!0)}}),!0),get(P)}function oe(){var $;($=get(P))==null||$.invalidateNotesCache()}user_effect(()=>{get(f)==="agent"&&!get(b)&&set(b,!0)}),user_effect(()=>{get(f)==="notes"&&!get(m)&&set(m,!0)});function ne($){re().execute($)}function ce(){var $;($=get(P))==null||$.stop()}function _e($){var B;(B=get(P))==null||B.approve($)}function ge($){var B;(B=get(P))==null||B.skip($)}function $e($){set(M,$,!0),get(P)&&(get(P).autoApprove=$)}onDestroy(()=>{var $;($=get(P))==null||$.dispose()});let be=state(proxy([])),ye=state(!1),de=state(""),v=user_derived(()=>get(be).filter($=>$.status==="completed").length);async function w(){set(ye,!0),set(de,"");const $=await fetchReports(r());set(be,$.reports,!0),$.error&&set(de,$.error,!0),set(ye,!1)}user_effect(()=>{r()&&w()});let z=state(""),I=state(""),k=state("bug"),U=state("medium"),D=state(proxy([])),K=state(proxy([])),j=state(proxy([])),J=state(proxy([])),ee=state(void 0);const ie=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml"];function R(){var $;($=get(ee))==null||$.click()}async function Z($){const B=$.target,Y=B.files;if(!(!Y||Y.length===0)){for(const he of Y)try{const He=await W(he);ie.includes(he.type)?(set(D,[...get(D),He],!0),H(`Image added: ${he.name}`,"success")):(set(K,[...get(K),{name:he.name,type:he.type||"application/octet-stream",data:He,size:he.size}],!0),H(`File attached: ${he.name}`,"success"))}catch{H(`Failed to read: ${he.name}`,"error")}B.value=""}}function W($){return new Promise((B,Y)=>{const he=new FileReader;he.onload=()=>B(he.result),he.onerror=()=>Y(he.error),he.readAsDataURL($)})}function T($){set(K,get(K).filter((B,Y)=>Y!==$),!0)}function V($){return $<1024?`${$}B`:$<1024*1024?`${($/1024).toFixed(1)}KB`:`${($/(1024*1024)).toFixed(1)}MB`}let Q=state(!1),G=state(!1),we=state(!1),fe=state(null),A=state(""),O=state(void 0),L=!1;user_effect(()=>{s()&&!L&&(requestAnimationFrame(()=>{requestAnimationFrame(()=>{var $;($=get(O))==null||$.focus()})}),get(f)==="new"&&get(D).length===0&&setTimeout(()=>{captureViewportQuick().then($=>{set(D,[...get(D),$],!0)}).catch(()=>{})},300)),L=s()});let F=state(""),q=state("success"),C=state(!1);function H($,B){set(F,$,!0),set(q,B,!0),set(C,!0),setTimeout(()=>{set(C,!1)},3e3)}async function se(){set(G,!0);try{const $=await captureViewport();set(A,$,!0),set(fe,get(D).length,!0)}catch($){console.error("[jat-feedback] Screenshot failed:",$),H("Screenshot failed: "+($ instanceof Error?$.message:"unknown error"),"error")}finally{set(G,!1)}}function ke($){set(D,get(D).filter((B,Y)=>Y!==$),!0)}function xe($){set(A,get(D)[$],!0),set(fe,$,!0)}function Ue($){get(fe)!==null&&(get(fe)>=get(D).length?(set(D,[...get(D),$],!0),H(`Screenshot captured (${get(D).length})`,"success")):(set(D,get(D).map((B,Y)=>Y===get(fe)?$:B),!0),H("Screenshot updated","success"))),set(fe,null),set(A,"")}function Ke(){get(fe)!==null&&get(fe)>=get(D).length&&(set(D,[...get(D),get(A)],!0),H(`Screenshot captured (${get(D).length})`,"success")),set(fe,null),set(A,"")}function rt(){set(we,!0),startElementPicker($=>{set(j,[...get(j),$],!0),set(we,!1),H(`Element captured: <${$.tagName.toLowerCase()}>`,"success")})}function Be(){set(J,getCapturedLogs(),!0)}async function Kt($){if($.preventDefault(),!get(z).trim())return;set(Q,!0),Be();const B={};(i()||a()||l()||u())&&(B.reporter={},i()&&(B.reporter.userId=i()),a()&&(B.reporter.email=a()),l()&&(B.reporter.name=l()),u()&&(B.reporter.role=u())),(c()||d())&&(B.organization={},c()&&(B.organization.id=c()),d()&&(B.organization.name=d()));const Y={title:get(z).trim(),description:get(I).trim(),type:get(k),priority:get(U),project:o()||"",page_url:window.location.href,user_agent:navigator.userAgent,console_logs:get(J).length>0?get(J):null,selected_elements:get(j).length>0?get(j):null,screenshots:get(D).length>0?get(D):null,attachments:get(K).length>0?get(K):null,metadata:Object.keys(B).length>0?B:null};try{const he=await submitReport(r(),Y);he.ok?(H(`Report submitted (${he.id})`,"success"),Fe(),setTimeout(()=>{w(),set(f,"requests")},1200)):(enqueue(r(),Y),H("Queued for retry (endpoint unreachable)","error"))}catch{enqueue(r(),Y),H("Queued for retry (endpoint unreachable)","error")}finally{set(Q,!1)}}function Fe(){set(z,""),set(I,""),set(k,"bug"),set(U,"medium"),set(D,[],!0),set(K,[],!0),set(j,[],!0),set(J,[],!0)}user_effect(()=>{Be()});function Me($){$.stopPropagation()}const ft=[{value:"bug",label:"Bug"},{value:"enhancement",label:"Enhancement"},{value:"other",label:"Other"}],Jt=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"critical",label:"Critical"}];function pt(){return get(D).length+get(K).length+get(j).length}var me={get endpoint(){return r()},set endpoint($){r($),flushSync()},get project(){return o()},set project($){o($),flushSync()},get isOpen(){return s()},set isOpen($=!1){s($),flushSync()},get userId(){return i()},set userId($=""){i($),flushSync()},get userEmail(){return a()},set userEmail($=""){a($),flushSync()},get userName(){return l()},set userName($=""){l($),flushSync()},get userRole(){return u()},set userRole($=""){u($),flushSync()},get orgId(){return c()},set orgId($=""){c($),flushSync()},get orgName(){return d()},set orgName($=""){d($),flushSync()},get onclose(){return p()},set onclose($){p($),flushSync()},get ongrip(){return g()},set ongrip($){g($),flushSync()},get agentProxy(){return _()},set agentProxy($=""){_($),flushSync()},get agentModel(){return y()},set agentModel($=""){y($),flushSync()},get agentContext(){return h()},set agentContext($=""){h($),flushSync()}},Ee=root$1(),Pe=first_child(Ee),lt=child(Pe),Et=child(lt);{var zn=$=>{var B=root_1$1();delegated("mousedown",B,function(...Y){var he;(he=g())==null||he.apply(this,Y)}),append($,B)};if_block(Et,$=>{g()&&$(zn)})}var yn=sibling(Et,2),wn=child(yn);let xn;var Qt=sibling(wn,2);let kn;var Pn=sibling(child(Qt),2);{var An=$=>{var B=root_2$1(),Y=child(B,!0);reset(B),template_effect(()=>set_text(Y,get(v))),append($,B)};if_block(Pn,$=>{get(v)>0&&$(An)})}reset(Qt);var fn=sibling(Qt,2);{var Fn=$=>{var B=root_3();let Y;template_effect(()=>Y=set_class(B,1,"tab svelte-nv4d5v",null,Y,{active:get(f)==="agent"})),delegated("click",B,()=>{set(f,"agent"),set(b,!0)}),append($,B)};if_block(fn,$=>{_()&&$(Fn)})}var In=sibling(fn,2);let Rn;reset(yn);var Dn=sibling(yn,2);reset(lt);var Nn=sibling(lt,2);{var pe=$=>{var B=root_4(),Y=child(B),he=sibling(child(Y),2);remove_input_defaults(he),bind_this(he,X=>set(O,X),()=>get(O)),reset(Y);var He=sibling(Y,2),Ft=sibling(child(He),2);remove_textarea_child(Ft),reset(He);var ht=sibling(He,2),jt=child(ht),Qe=sibling(child(jt),2);each(Qe,21,()=>ft,index,(X,le)=>{var Ae=root_5(),De=child(Ae,!0);reset(Ae);var Ze={};template_effect(()=>{set_text(De,get(le).label),Ze!==(Ze=get(le).value)&&(Ae.value=(Ae.__value=get(le).value)??"")}),append(X,Ae)}),reset(Qe),reset(jt);var en=sibling(jt,2),Bt=sibling(child(en),2);each(Bt,21,()=>Jt,index,(X,le)=>{var Ae=root_6(),De=child(Ae,!0);reset(Ae);var Ze={};template_effect(()=>{set_text(De,get(le).label),Ze!==(Ze=get(le).value)&&(Ae.value=(Ae.__value=get(le).value)??"")}),append(X,Ae)}),reset(Bt),reset(en),reset(ht);var Vt=sibling(ht,2),tn=child(Vt),ze=child(tn),Ge=child(ze);{var St=X=>{var le=root_7();next(),append(X,le)},gt=X=>{var le=root_8(),Ae=sibling(first_child(le),2);{var De=Ze=>{var Ye=root_9(),_t=child(Ye,!0);reset(Ye),template_effect(()=>set_text(_t,get(D).length)),append(Ze,Ye)};if_block(Ae,Ze=>{get(D).length>0&&Ze(De)})}append(X,le)};if_block(Ge,X=>{get(G)?X(St):X(gt,!1)})}reset(ze);var ot=sibling(ze,2),vt=sibling(child(ot),2);{var Tt=X=>{var le=text("Click an element...");append(X,le)},nn=X=>{var le=root_11(),Ae=sibling(first_child(le));{var De=Ze=>{var Ye=root_12(),_t=child(Ye,!0);reset(Ye),template_effect(()=>set_text(_t,get(j).length)),append(Ze,Ye)};if_block(Ae,Ze=>{get(j).length>0&&Ze(De)})}append(X,le)};if_block(vt,X=>{get(we)?X(Tt):X(nn,!1)})}reset(ot);var Ne=sibling(ot,2),et=sibling(child(Ne),2);{var Dt=X=>{var le=root_13(),Ae=child(le,!0);reset(le),template_effect(()=>set_text(Ae,get(K).length)),append(X,le)};if_block(et,X=>{get(K).length>0&&X(Dt)})}reset(Ne);var st=sibling(Ne,2);bind_this(st,X=>set(ee,X),()=>get(ee)),reset(tn);var ct=sibling(tn,2);ScreenshotPreview(ct,{get screenshots(){return get(D)},get capturing(){return get(G)},oncapture:se,onremove:ke,onedit:xe}),reset(Vt);var ut=sibling(Vt,2);{var Ct=X=>{var le=root_14();each(le,21,()=>get(K),index,(Ae,De,Ze)=>{var Ye=root_15(),_t=child(Ye),Bn=child(_t);{var En=mt=>{var Sn=root_16();append(mt,Sn)},Vn=user_derived(()=>get(De).type.includes("pdf")),Hn=mt=>{var Sn=root_17();append(mt,Sn)},on=user_derived(()=>get(De).type.includes("markdown")||get(De).name.endsWith(".md")),$n=mt=>{var Sn=root_18();append(mt,Sn)};if_block(Bn,mt=>{get(Vn)?mt(En):get(on)?mt(Hn,1):mt($n,!1)})}reset(_t);var qn=sibling(_t,2),ur=child(qn,!0);reset(qn);var Wn=sibling(qn,2),dr=child(Wn,!0);reset(Wn);var fr=sibling(Wn,2);reset(Ye),template_effect(mt=>{set_text(ur,get(De).name),set_text(dr,mt)},[()=>V(get(De).size)]),delegated("click",fr,()=>T(Ze)),append(Ae,Ye)}),reset(le),append(X,le)};if_block(ut,X=>{get(K).length>0&&X(Ct)})}var zt=sibling(ut,2);{var pn=X=>{var le=root_19();each(le,21,()=>get(j),index,(Ae,De,Ze)=>{var Ye=root_20(),_t=child(Ye),Bn=child(_t);reset(_t);var En=sibling(_t,2),Vn=child(En,!0);reset(En);var Hn=sibling(En,2);reset(Ye),template_effect((on,$n)=>{set_text(Bn,`<${on??""}>`),set_text(Vn,$n)},[()=>get(De).tagName.toLowerCase(),()=>{var on;return((on=get(De).textContent)==null?void 0:on.substring(0,40))||get(De).selector}]),delegated("click",Hn,()=>{set(j,get(j).filter((on,$n)=>$n!==Ze),!0)}),append(Ae,Ye)}),reset(le),append(X,le)};if_block(zt,X=>{get(j).length>0&&X(pn)})}var hn=sibling(zt,2);ConsoleLogList(hn,{get logs(){return get(J)}});var At=sibling(hn,2);{var Zt=X=>{var le=root_21(),Ae=child(le);reset(le),template_effect((De,Ze)=>set_text(Ae,`${De??""} attachment${Ze??""} will be included`),[pt,()=>pt()>1?"s":""]),append(X,le)},It=user_derived(()=>pt()>0);if_block(At,X=>{get(It)&&X(Zt)})}var rn=sibling(At,2),Zn=child(rn),ir=child(Zn);reset(Zn);var Un=sibling(Zn,2),jn=sibling(Un,2),ar=child(jn);{var lr=X=>{var le=root_22();next(),append(X,le)},cr=X=>{var le=text("Submit");append(X,le)};if_block(ar,X=>{get(Q)?X(lr):X(cr,!1)})}reset(jn),reset(rn),reset(B),template_effect(X=>{he.disabled=get(Q),Ft.disabled=get(Q),Qe.disabled=get(Q),Bt.disabled=get(Q),ze.disabled=get(G),ot.disabled=get(we),Ne.disabled=get(Q),set_text(ir,`v${n}`),Un.disabled=get(Q),jn.disabled=X},[()=>get(Q)||!get(z).trim()]),event("submit",B,Kt),bind_value(he,()=>get(z),X=>set(z,X)),bind_value(Ft,()=>get(I),X=>set(I,X)),bind_select_value(Qe,()=>get(k),X=>set(k,X)),bind_select_value(Bt,()=>get(U),X=>set(U,X)),delegated("click",ze,se),delegated("click",ot,rt),delegated("click",Ne,R),delegated("change",st,Z),delegated("click",Un,function(...X){var le;(le=p())==null||le.apply(this,X)}),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(Nn,$=>{get(f)==="new"&&$(pe)})}var ve=sibling(Nn,2);{var Ie=$=>{var B=root_24(),Y=child(B);RequestList(Y,{get endpoint(){return r()},get loading(){return get(ye)},get error(){return get(de)},onreload:w,get reports(){return get(be)},set reports(he){set(be,he,!0)}}),reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(ve,$=>{get(f)==="requests"&&$(Ie)})}var qe=sibling(ve,2);{var $t=$=>{var B=root_25(),Y=child(B);{let he=user_derived(()=>{var He;return((He=get(P))==null?void 0:He.getMaxSteps())??20});AgentPanel(Y,{get messages(){return get(x)},get agentState(){return get(S)},get currentStep(){return get(N)},get maxSteps(){return get(he)},get autoApprove(){return get(M)},onsend:ne,onstop:ce,onapprove:_e,onskip:ge,onautoapprovechange:$e})}reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(qe,$=>{get(f)==="agent"&&get(b)&&$($t)})}var Je=sibling(qe,2);{var Ve=$=>{var B=root_26(),Y=child(B);NotesPanel(Y,{get endpoint(){return r()},get project(){return o()},onnoteschanged:oe}),reset(B),transition(3,B,()=>slide,()=>({duration:200})),append($,B)};if_block(Je,$=>{get(f)==="notes"&&get(m)&&$(Ve)})}var Re=sibling(Je,2);StatusToast(Re,{get message(){return get(F)},get type(){return get(q)},get visible(){return get(C)}}),reset(Pe);var We=sibling(Pe,2);{var Ce=$=>{AnnotationEditor($,{get imageDataUrl(){return get(A)},onsave:Ue,oncancel:Ke})};if_block(We,$=>{get(fe)!==null&&$(Ce)})}return template_effect(()=>{xn=set_class(wn,1,"tab svelte-nv4d5v",null,xn,{active:get(f)==="new"}),kn=set_class(Qt,1,"tab svelte-nv4d5v",null,kn,{active:get(f)==="requests"}),Rn=set_class(In,1,"tab svelte-nv4d5v",null,Rn,{active:get(f)==="notes"})}),delegated("keydown",Pe,Me),delegated("keyup",Pe,Me),event("keypress",Pe,Me),delegated("click",wn,()=>set(f,"new")),delegated("click",Qt,()=>set(f,"requests")),delegated("click",In,()=>{set(f,"notes"),set(m,!0)}),delegated("click",Dn,function(...$){var B;(B=p())==null||B.apply(this,$)}),append(e,Ee),pop(me)}delegate(["keydown","keyup","mousedown","click","change"]),create_custom_element(FeedbackPanel,{endpoint:{},project:{},isOpen:{},userId:{},userEmail:{},userName:{},userRole:{},orgId:{},orgName:{},onclose:{},ongrip:{},agentProxy:{},agentModel:{},agentContext:{}},[],[],{mode:"open"});var root_1=from_html("<div><!></div>"),root_2=from_html('<div class="jat-feedback-panel svelte-qpyrvv"><div class="no-endpoint svelte-qpyrvv"><p class="svelte-qpyrvv">No endpoint configured.</p> <p class="svelte-qpyrvv">Add the <code class="svelte-qpyrvv">endpoint</code> attribute:</p> <code class="example svelte-qpyrvv">&lt;jat-feedback endpoint="http://localhost:3333"&gt;</code></div></div>'),root=from_html('<div class="jat-feedback-root svelte-qpyrvv" data-page-agent-not-interactive=""><!> <!></div>');const $$css={hash:"svelte-qpyrvv",code:`.jat-feedback-root.svelte-qpyrvv {position:fixed;z-index:2147483647;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;}.jat-feedback-panel.svelte-qpyrvv {position:absolute;
374
376
  animation: svelte-qpyrvv-panel-in 0.2s ease;}.jat-feedback-panel.hidden.svelte-qpyrvv {display:none;}.jat-feedback-panel.dragging.svelte-qpyrvv {pointer-events:none;opacity:0.9;}.no-endpoint.svelte-qpyrvv {width:320px;background:#111827;border:1px solid #374151;border-radius:12px;padding:20px;color:#d1d5db;font-size:13px;box-shadow:0 20px 60px rgba(0,0,0,0.4);}.no-endpoint.svelte-qpyrvv p:where(.svelte-qpyrvv) {margin:0 0 8px;}.no-endpoint.svelte-qpyrvv code:where(.svelte-qpyrvv) {font-family:'SF Mono', 'Fira Code', monospace;font-size:11px;color:#93c5fd;}.no-endpoint.svelte-qpyrvv code.example:where(.svelte-qpyrvv) {display:block;background:#1f2937;padding:8px 10px;border-radius:4px;margin-top:4px;}
375
377
  @keyframes svelte-qpyrvv-panel-in {
376
378
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
377
379
  to { opacity: 1; transform: translateY(0) scale(1); }
378
- }`};function JatFeedback(e,t){push(t,!0),append_styles(e,$$css);let n=prop(t,"endpoint",7,""),r=prop(t,"project",7,""),o=prop(t,"position",7,"bottom-right"),s=prop(t,"theme",7,"dark"),i=prop(t,"buttoncolor",7,"#3b82f6"),a=prop(t,"user-id",7,""),l=prop(t,"user-email",7,""),u=prop(t,"user-name",7,""),c=prop(t,"user-role",7,""),d=prop(t,"org-id",7,""),p=prop(t,"org-name",7,""),g=prop(t,"agent-proxy",7,""),_=prop(t,"agent-model",7,""),y=prop(t,"agent-context",7,""),h=state(!1),f=state(!1),b=state(!1),m={x:0,y:0},x=state(void 0);const S=5;function N(k,{onDragEnd:U}={}){if(!get(x))return;const D=k.clientX,K=k.clientY,j=get(x).getBoundingClientRect();m={x:k.clientX-j.left,y:k.clientY-j.top};let J=!1;function ee(I){if(!get(x))return;const Z=I.clientX-D,W=I.clientY-K;if(!J&&Math.abs(Z)+Math.abs(W)<S)return;J=!0,set(b,!0),I.preventDefault();const T=I.clientX-m.x,V=I.clientY-m.y;get(x).style.top=`${V}px`,get(x).style.left=`${T}px`,get(x).style.bottom="auto",get(x).style.right="auto"}function ie(){set(b,!1),window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",ie),U==null||U(J)}window.addEventListener("mousemove",ee),window.addEventListener("mouseup",ie)}function P(k){N(k)}function M(k){k.button===0&&(k.preventDefault(),N(k,{onDragEnd(U){U||ce()}}))}let re=null;function oe(){re=setInterval(()=>{const k=isElementPickerActive();k&&!get(f)?set(f,!0):!k&&get(f)&&set(f,!1)},100)}let ne=user_derived(()=>({...DEFAULT_CONFIG,endpoint:n()||DEFAULT_CONFIG.endpoint,position:o()||DEFAULT_CONFIG.position,theme:s()||DEFAULT_CONFIG.theme,buttonColor:i()||DEFAULT_CONFIG.buttonColor}));function ce(){set(h,!get(h))}function _e(){set(h,!1)}const ge={"bottom-right":"bottom: 20px; right: 20px;","bottom-left":"bottom: 20px; left: 20px;","top-right":"top: 20px; right: 20px;","top-left":"top: 20px; left: 20px;"},$e={"bottom-right":"bottom: 80px; right: 0;","bottom-left":"bottom: 80px; left: 0;","top-right":"top: 80px; right: 0;","top-left":"top: 80px; left: 0;"};function be(k){if(k.key==="Escape"&&get(h)){if(isAnnotationEditorOpen())return;k.stopPropagation(),k.stopImmediatePropagation(),_e()}}onMount(()=>{get(ne).captureConsole&&startConsoleCapture(get(ne).maxConsoleLogs),startRetryLoop(),oe(),window.addEventListener("keydown",be,!0);const k=()=>{set(h,!0)};return window.addEventListener("jat-feedback:open",k),()=>window.removeEventListener("jat-feedback:open",k)}),onDestroy(()=>{stopConsoleCapture(),stopRetryLoop(),window.removeEventListener("keydown",be,!0),re&&clearInterval(re)});var ye={get endpoint(){return n()},set endpoint(k=""){n(k),flushSync()},get project(){return r()},set project(k=""){r(k),flushSync()},get position(){return o()},set position(k="bottom-right"){o(k),flushSync()},get theme(){return s()},set theme(k="dark"){s(k),flushSync()},get buttoncolor(){return i()},set buttoncolor(k="#3b82f6"){i(k),flushSync()},get"user-id"(){return a()},set"user-id"(k=""){a(k),flushSync()},get"user-email"(){return l()},set"user-email"(k=""){l(k),flushSync()},get"user-name"(){return u()},set"user-name"(k=""){u(k),flushSync()},get"user-role"(){return c()},set"user-role"(k=""){c(k),flushSync()},get"org-id"(){return d()},set"org-id"(k=""){d(k),flushSync()},get"org-name"(){return p()},set"org-name"(k=""){p(k),flushSync()},get"agent-proxy"(){return g()},set"agent-proxy"(k=""){g(k),flushSync()},get"agent-model"(){return _()},set"agent-model"(k=""){_(k),flushSync()},get"agent-context"(){return y()},set"agent-context"(k=""){y(k),flushSync()}},de=root(),v=child(de);{var w=k=>{var U=root_1();let D;var K=child(U);FeedbackPanel(K,{get endpoint(){return get(ne).endpoint},get project(){return r()},get isOpen(){return get(h)},get userId(){return a()},get userEmail(){return l()},get userName(){return u()},get userRole(){return c()},get orgId(){return d()},get orgName(){return p()},get agentProxy(){return g()},get agentModel(){return _()},get agentContext(){return y()},onclose:_e,ongrip:P}),reset(U),template_effect(()=>{D=set_class(U,1,"jat-feedback-panel svelte-qpyrvv",null,D,{dragging:get(b),hidden:!get(h)}),set_style(U,$e[get(ne).position]||$e["bottom-right"])}),append(k,U)},z=k=>{var U=root_2();template_effect(()=>set_style(U,$e[get(ne).position]||$e["bottom-right"])),append(k,U)};if_block(v,k=>{get(ne).endpoint?k(w):get(h)&&k(z,1)})}var R=sibling(v,2);return FeedbackButton(R,{onmousedown:M,get open(){return get(h)}}),reset(de),bind_this(de,k=>set(x,k),()=>get(x)),template_effect(()=>set_style(de,`${(ge[get(ne).position]||ge["bottom-right"])??""}; --jat-btn-color: ${get(ne).buttonColor??""}; ${get(f)?"display: none;":""}`)),append(e,de),pop(ye)}customElements.define("jat-feedback",create_custom_element(JatFeedback,{endpoint:{},project:{},position:{},theme:{},buttoncolor:{},"user-id":{},"user-email":{},"user-name":{},"user-role":{},"org-id":{},"org-name":{},"agent-proxy":{},"agent-model":{},"agent-context":{}},[],[],{mode:"open"}));/**
380
+ }`};function JatFeedback(e,t){push(t,!0),append_styles(e,$$css);let n=prop(t,"endpoint",7,""),r=prop(t,"project",7,""),o=prop(t,"position",7,"bottom-right"),s=prop(t,"theme",7,"dark"),i=prop(t,"buttoncolor",7,"#3b82f6"),a=prop(t,"user-id",7,""),l=prop(t,"user-email",7,""),u=prop(t,"user-name",7,""),c=prop(t,"user-role",7,""),d=prop(t,"org-id",7,""),p=prop(t,"org-name",7,""),g=prop(t,"agent-proxy",7,""),_=prop(t,"agent-model",7,""),y=prop(t,"agent-context",7,""),h=state(!1),f=state(!1),b=state(!1),m={x:0,y:0},x=state(void 0);const S=5;function N(k,{onDragEnd:U}={}){if(!get(x))return;const D=k.clientX,K=k.clientY,j=get(x).getBoundingClientRect();m={x:k.clientX-j.left,y:k.clientY-j.top};let J=!1;function ee(R){if(!get(x))return;const Z=R.clientX-D,W=R.clientY-K;if(!J&&Math.abs(Z)+Math.abs(W)<S)return;J=!0,set(b,!0),R.preventDefault();const T=R.clientX-m.x,V=R.clientY-m.y;get(x).style.top=`${V}px`,get(x).style.left=`${T}px`,get(x).style.bottom="auto",get(x).style.right="auto"}function ie(){set(b,!1),window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",ie),U==null||U(J)}window.addEventListener("mousemove",ee),window.addEventListener("mouseup",ie)}function M(k){N(k)}function P(k){k.button===0&&(k.preventDefault(),N(k,{onDragEnd(U){U||ce()}}))}let re=null;function oe(){re=setInterval(()=>{const k=isElementPickerActive();k&&!get(f)?set(f,!0):!k&&get(f)&&set(f,!1)},100)}let ne=user_derived(()=>({...DEFAULT_CONFIG,endpoint:n()||DEFAULT_CONFIG.endpoint,position:o()||DEFAULT_CONFIG.position,theme:s()||DEFAULT_CONFIG.theme,buttonColor:i()||DEFAULT_CONFIG.buttonColor}));function ce(){set(h,!get(h))}function _e(){set(h,!1)}const ge={"bottom-right":"bottom: 20px; right: 20px;","bottom-left":"bottom: 20px; left: 20px;","top-right":"top: 20px; right: 20px;","top-left":"top: 20px; left: 20px;"},$e={"bottom-right":"bottom: 80px; right: 0;","bottom-left":"bottom: 80px; left: 0;","top-right":"top: 80px; right: 0;","top-left":"top: 80px; left: 0;"};function be(k){if(k.key==="Escape"&&get(h)){if(isAnnotationEditorOpen())return;k.stopPropagation(),k.stopImmediatePropagation(),_e()}}onMount(()=>{get(ne).captureConsole&&startConsoleCapture(get(ne).maxConsoleLogs),startRetryLoop(),oe(),window.addEventListener("keydown",be,!0);const k=()=>{set(h,!0)};return window.addEventListener("jat-feedback:open",k),()=>window.removeEventListener("jat-feedback:open",k)}),onDestroy(()=>{stopConsoleCapture(),stopRetryLoop(),window.removeEventListener("keydown",be,!0),re&&clearInterval(re)});var ye={get endpoint(){return n()},set endpoint(k=""){n(k),flushSync()},get project(){return r()},set project(k=""){r(k),flushSync()},get position(){return o()},set position(k="bottom-right"){o(k),flushSync()},get theme(){return s()},set theme(k="dark"){s(k),flushSync()},get buttoncolor(){return i()},set buttoncolor(k="#3b82f6"){i(k),flushSync()},get"user-id"(){return a()},set"user-id"(k=""){a(k),flushSync()},get"user-email"(){return l()},set"user-email"(k=""){l(k),flushSync()},get"user-name"(){return u()},set"user-name"(k=""){u(k),flushSync()},get"user-role"(){return c()},set"user-role"(k=""){c(k),flushSync()},get"org-id"(){return d()},set"org-id"(k=""){d(k),flushSync()},get"org-name"(){return p()},set"org-name"(k=""){p(k),flushSync()},get"agent-proxy"(){return g()},set"agent-proxy"(k=""){g(k),flushSync()},get"agent-model"(){return _()},set"agent-model"(k=""){_(k),flushSync()},get"agent-context"(){return y()},set"agent-context"(k=""){y(k),flushSync()}},de=root(),v=child(de);{var w=k=>{var U=root_1();let D;var K=child(U);FeedbackPanel(K,{get endpoint(){return get(ne).endpoint},get project(){return r()},get isOpen(){return get(h)},get userId(){return a()},get userEmail(){return l()},get userName(){return u()},get userRole(){return c()},get orgId(){return d()},get orgName(){return p()},get agentProxy(){return g()},get agentModel(){return _()},get agentContext(){return y()},onclose:_e,ongrip:M}),reset(U),template_effect(()=>{D=set_class(U,1,"jat-feedback-panel svelte-qpyrvv",null,D,{dragging:get(b),hidden:!get(h)}),set_style(U,$e[get(ne).position]||$e["bottom-right"])}),append(k,U)},z=k=>{var U=root_2();template_effect(()=>set_style(U,$e[get(ne).position]||$e["bottom-right"])),append(k,U)};if_block(v,k=>{get(ne).endpoint?k(w):get(h)&&k(z,1)})}var I=sibling(v,2);return FeedbackButton(I,{onmousedown:P,get open(){return get(h)}}),reset(de),bind_this(de,k=>set(x,k),()=>get(x)),template_effect(()=>set_style(de,`${(ge[get(ne).position]||ge["bottom-right"])??""}; --jat-btn-color: ${get(ne).buttonColor??""}; ${get(f)?"display: none;":""}`)),append(e,de),pop(ye)}customElements.define("jat-feedback",create_custom_element(JatFeedback,{endpoint:{},project:{},position:{},theme:{},buttoncolor:{},"user-id":{},"user-email":{},"user-name":{},"user-role":{},"org-id":{},"org-name":{},"agent-proxy":{},"agent-model":{},"agent-context":{}},[],[],{mode:"open"}));/**
379
381
  * AI Motion - WebGL2 animated border with AI-style glow effects
380
382
  *
381
383
  * @author Simon<gaomeng1900@gmail.com>
382
384
  * @license MIT
383
385
  * @repository https://github.com/gaomeng1900/ai-motion
384
- */function computeBorderGeometry(e,t,n,r){const o=Math.max(1,Math.min(e,t)),s=Math.min(n,20),a=Math.min(s+r,o),l=Math.min(a,Math.floor(e/2)),u=Math.min(a,Math.floor(t/2)),c=R=>R/e*2-1,d=R=>R/t*2-1,p=0,g=e,_=0,y=t,h=l,f=e-l,b=u,m=t-u,x=c(p),S=c(g),N=d(_),P=d(y),M=c(h),re=c(f),oe=d(b),ne=d(m),ce=0,_e=0,ge=1,$e=1,be=l/e,ye=1-l/e,de=u/t,v=1-u/t,w=new Float32Array([x,N,S,N,x,oe,x,oe,S,N,S,oe,x,ne,S,ne,x,P,x,P,S,ne,S,P,x,oe,M,oe,x,ne,x,ne,M,oe,M,ne,re,oe,S,oe,re,ne,re,ne,S,oe,S,ne]),z=new Float32Array([ce,_e,ge,_e,ce,de,ce,de,ge,_e,ge,de,ce,v,ge,v,ce,$e,ce,$e,ge,v,ge,$e,ce,de,be,de,ce,v,ce,v,be,de,be,v,ye,de,ge,de,ye,v,ye,v,ge,de,ge,v]);return{positions:w,uvs:z}}/**
386
+ */function computeBorderGeometry(e,t,n,r){const o=Math.max(1,Math.min(e,t)),s=Math.min(n,20),a=Math.min(s+r,o),l=Math.min(a,Math.floor(e/2)),u=Math.min(a,Math.floor(t/2)),c=I=>I/e*2-1,d=I=>I/t*2-1,p=0,g=e,_=0,y=t,h=l,f=e-l,b=u,m=t-u,x=c(p),S=c(g),N=d(_),M=d(y),P=c(h),re=c(f),oe=d(b),ne=d(m),ce=0,_e=0,ge=1,$e=1,be=l/e,ye=1-l/e,de=u/t,v=1-u/t,w=new Float32Array([x,N,S,N,x,oe,x,oe,S,N,S,oe,x,ne,S,ne,x,M,x,M,S,ne,S,M,x,oe,P,oe,x,ne,x,ne,P,oe,P,ne,re,oe,S,oe,re,ne,re,ne,S,oe,S,ne]),z=new Float32Array([ce,_e,ge,_e,ce,de,ce,de,ge,_e,ge,de,ce,v,ge,v,ce,$e,ce,$e,ge,v,ge,$e,ce,de,be,de,ce,v,ce,v,be,de,be,v,ye,de,ge,de,ye,v,ye,v,ge,de,ge,v]);return{positions:w,uvs:z}}/**
385
387
  * AI Motion - WebGL2 animated border with AI-style glow effects
386
388
  *
387
389
  * @author Simon<gaomeng1900@gmail.com>